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 140e8861566afcd1c51ede4bafd9ac2c6192cd68
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Tue Jul 21 21:02:44 2020 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Jul 22 09:37:48 2020 +0200

    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>

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<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_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<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())
         {
@@ -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<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 8753314664ca..d93ce60c007a 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -491,7 +491,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;
@@ -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#
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to