From 140e8861566afcd1c51ede4bafd9ac2c6192cd68 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 21 Jul 2020 21:02:44 +0300 Subject: tdf#98000 docx export: blank paragraphs don't affect page breaks Umm, how could that ever have possibly made sense? And why wasn't it found and fixed earlier? This goes way back to when first/follow page styles were first being handled in tdf#66145, where a blank line skipped calling OutputSectionBreak. Then in LO 4.3, tdf#74566 adjusted that a bit more, and tdf#77890 decided to do the same thing for a previous blank line. These all have unit tests to "prove" it too. But none of that makes any sense, and by reverting all of that garbage, all the unit tests still pass. I also looked at the original bug documents, and they also look fine after the revert. So I think it is safe to kill this nonsense, but I don't plan to backport it, just in case... Change-Id: I4aaca0435fbf030fe9c3113b068ea3370eccd889 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99171 Tested-by: Jenkins Reviewed-by: Justin Luth Reviewed-by: Miklos Vajna --- .../extras/ooxmlexport/data/tdf98000_changePageStyle.odt | Bin 0 -> 9418 bytes sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 13 +++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 4 ++-- sw/source/filter/ww8/wrtww8.cxx | 1 - sw/source/filter/ww8/wrtww8.hxx | 3 +-- sw/source/filter/ww8/ww8atr.cxx | 11 ++--------- 6 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf98000_changePageStyle.odt (limited to 'sw') diff --git a/sw/qa/extras/ooxmlexport/data/tdf98000_changePageStyle.odt b/sw/qa/extras/ooxmlexport/data/tdf98000_changePageStyle.odt new file mode 100644 index 000000000000..95f65e919fb6 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf98000_changePageStyle.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index 70addfd3c60b..6c6dca1e70ed 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -64,6 +64,19 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf118701, "tdf118701.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:p[10]/w:pPr[1]/w:numPr", 1); } +DECLARE_OOXMLEXPORT_TEST(testTdf98000_changePageStyle, "tdf98000_changePageStyle.odt") +{ + uno::Reference xModel(mxComponent, uno::UNO_QUERY); + uno::Reference xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + + uno::Reference xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY_THROW); + OUString sPageOneStyle = getProperty( xCursor, "PageStyleName" ); + + xCursor->jumpToNextPage(); + OUString sPageTwoStyle = getProperty( xCursor, "PageStyleName" ); + CPPUNIT_ASSERT_MESSAGE("Different page1/page2 styles", sPageOneStyle != sPageTwoStyle); +} + DECLARE_OOXMLEXPORT_TEST(testTdf133370_columnBreak, "tdf133370_columnBreak.odt") { // Since non-DOCX formats ignores column breaks in non-column situations, don't export to docx. diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5090d63fad71..e90a9efc2e08 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -999,7 +999,7 @@ void DocxAttributeOutput::SectionBreaks(const SwNode& rNode) if (aNextIndex.GetNode().IsTextNode()) { const SwTextNode* pTextNode = static_cast(&aNextIndex.GetNode()); - m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen, pTextNode->GetText().isEmpty()); + m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen); } else if (aNextIndex.GetNode().IsTableNode()) { @@ -1016,7 +1016,7 @@ void DocxAttributeOutput::SectionBreaks(const SwNode& rNode) // Also handle section endings const SwTextNode* pTextNode = aNextIndex.GetNode().GetTextNode(); if (rNode.StartOfSectionNode()->IsTableNode() || rNode.StartOfSectionNode()->IsSectionNode()) - m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen, pTextNode->GetText().isEmpty()); + m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen); } } } diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 294ce05635fd..5925fa470cd7 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3862,7 +3862,6 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, std::shared_ptr m_aImplicitBookmarks; ww8::Frames m_aFrames; // The floating frames in this document const SwPageDesc *m_pCurrentPageDesc; - bool m_bPrevTextNodeIsEmpty; bool m_bFirstTOCNodeWithSection; std::unique_ptr m_pPapPlc; std::unique_ptr m_pChpPlc; @@ -751,7 +750,7 @@ public: static sal_uLong GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ); /// Start new section. - void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen = false, bool isTextNodeEmpty = false); + void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen = false ); /// Write section properties. /// diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 606e3356eb9f..f56f0de8e820 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -432,7 +432,7 @@ bool MSWordExportBase::SetCurrentPageDescFromNode(const SwNode &rNd) * because that one only exits once for CHP and PAP and therefore end up in * the wrong one. */ -void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen, bool isTextNodeEmpty) +void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen ) { if ( m_bStyDef || m_bOutKF || m_bInWriteEscher || m_bOutPageDescs ) return; @@ -453,14 +453,10 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode // Even if pAktPageDesc != pPageDesc ,it might be because of the different header & footer types. if (m_pCurrentPageDesc != pPageDesc) { - if ( ( isCellOpen && ( m_pCurrentPageDesc->GetName() != pPageDesc->GetName() )) || - ( isTextNodeEmpty || m_bPrevTextNodeIsEmpty )) + if (isCellOpen && ( m_pCurrentPageDesc->GetName() != pPageDesc->GetName() )) { /* Do not output a section break in the following scenarios. 1) Table cell is open and page header types are different - 2) PageBreak is present but text node has no string - it is an empty node. - 3) If the previous node was an empty text node and current node is a non empty text node or vice versa. - 4) If previous node and current node both are empty text nodes. Converting a page break to section break would cause serious issues while importing the RT files with different first page being set. */ @@ -563,8 +559,6 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode { bNewPageDesc |= SetCurrentPageDescFromNode( rNd ); } - if( isTextNodeEmpty ) - bNewPageDesc = false; } if ( !bNewPageDesc ) AttrOutput().OutputItem( *pItem ); @@ -611,7 +605,6 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode PrepareNewPageDesc( pSet, rNd, pPgDesc, m_pCurrentPageDesc ); } m_bBreakBefore = false; - m_bPrevTextNodeIsEmpty = isTextNodeEmpty ; } // #i76300# -- cgit