sw/qa/extras/ooxmlexport/data/tdf98000_changePageStyle.odt |binary
 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(-)

New commits:
commit 1433ed1347407d07ff0410d1749eeed465c5ad28
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Tue Jul 21 21:02:44 2020 +0300
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Wed Mar 16 13:36:55 2022 +0100

    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 <justin_l...@sil.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131653
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

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 5aff15ca6f5d..95359aebf820 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -35,6 +35,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133334_followPgStyle, 
"tdf133334_followPgStyle.o
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf98000_changePageStyle, 
"tdf98000_changePageStyle.odt")
+{
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> 
xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
+
+    uno::Reference<text::XPageCursor> 
xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY_THROW);
+    OUString sPageOneStyle = getProperty<OUString>( xCursor, "PageStyleName" );
+
+    xCursor->jumpToNextPage();
+    OUString sPageTwoStyle = getProperty<OUString>( xCursor, "PageStyleName" );
+    CPPUNIT_ASSERT_MESSAGE("Different page1/page2 styles", sPageOneStyle != 
sPageTwoStyle);
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf131801, "tdf131801.docx")
 {
     CPPUNIT_ASSERT_EQUAL(1, getPages());
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 40256891d509..912feef0816a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1175,7 +1175,7 @@ void DocxAttributeOutput::SectionBreaks(const SwNode& 
rNode)
         if (aNextIndex.GetNode().IsTextNode())
         {
             const SwTextNode* pTextNode = 
static_cast<SwTextNode*>(&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())
         {
@@ -1192,7 +1192,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 8d4add7b34bf..86899e1dba88 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3673,7 +3673,6 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, 
std::shared_ptr<SwUnoCurso
     , m_nOrigRedlineFlags(RedlineFlags::NONE)
     , m_bOrigShowChanges(true)
     , m_pCurrentPageDesc(nullptr)
-    , m_bPrevTextNodeIsEmpty(false)
     , m_bFirstTOCNodeWithSection(false)
     , m_pChpIter(nullptr)
     , m_pAtn(nullptr)
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 0433332493ef..0e1cfea0a51a 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -496,7 +496,6 @@ public:
     std::vector<aBookmarkPair> 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<WW8_WrPlcPn> m_pPapPlc;
     std::unique_ptr<WW8_WrPlcPn> m_pChpPlc;
@@ -759,7 +758,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 2cd9466715ce..cfd58d9d643d 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -441,7 +441,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;
@@ -462,14 +462,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.
             */
@@ -572,8 +568,6 @@ void MSWordExportBase::OutputSectionBreaks( const 
SfxItemSet *pSet, const SwNode
                     {
                         bNewPageDesc |= SetCurrentPageDescFromNode( rNd );
                     }
-                    if( isTextNodeEmpty )
-                       bNewPageDesc = false;
                 }
                 if ( !bNewPageDesc )
                     AttrOutput().OutputItem( *pItem );
@@ -620,7 +614,6 @@ void MSWordExportBase::OutputSectionBreaks( const 
SfxItemSet *pSet, const SwNode
         PrepareNewPageDesc( pSet, rNd, pPgDesc, m_pCurrentPageDesc );
     }
     m_bBreakBefore = false;
-    m_bPrevTextNodeIsEmpty = isTextNodeEmpty ;
 }
 
 // #i76300#

Reply via email to