sw/qa/extras/ooxmlexport/data/tdf132149_pgBreakB.odt  |binary
 sw/qa/extras/ooxmlexport/data/tdf136952_pgBreak3B.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx            |   24 ++++++++++++++++++
 sw/source/filter/ww8/wrtw8nds.cxx                     |   13 +++++++++
 4 files changed, 37 insertions(+)

New commits:
commit f0a495a56489b781177be8ff28c4660214c9bdf2
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Sep 23 22:26:46 2020 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Nov 6 15:07:07 2020 +0100

    tdf#136952 ww8export: always check for breakAfter on last split
    
    This patch primarily adds support for
    covering the situation where a rare page-after break
    exists on a split paragraph node.
    
    This patch also adds one more aspect to the fixes for tdf#132149,
    where a breakBefore wasn't evaluated with the correct CurrentPageDesc.
    
    Change-Id: Ia548c611c1b7b6c66cb7a7c58be1705cd8c42b77
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103275
    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/tdf132149_pgBreakB.odt 
b/sw/qa/extras/ooxmlexport/data/tdf132149_pgBreakB.odt
new file mode 100644
index 000000000000..86ea177a9f11
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf132149_pgBreakB.odt differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf136952_pgBreak3B.odt 
b/sw/qa/extras/ooxmlexport/data/tdf136952_pgBreak3B.odt
new file mode 100644
index 000000000000..e39ebdef2b5d
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf136952_pgBreak3B.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 8d98ccd39487..07f2e06288f9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -552,6 +552,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf132149_pgBreak, 
"tdf132149_pgBreak.odt")
     CPPUNIT_ASSERT(getXPath(pDump, "//page[6]/body/txt[1]/Text[1]", 
"Portion").startsWith("Lorem ipsum"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf132149_pgBreakB, "tdf132149_pgBreakB.odt")
+{
+    // This 5 page document is designed to visually exaggerate the problems
+    // of emulating LO's followed-by-page-style into MSWord's sections.
+    xmlDocUniquePtr pDump = parseLayoutDump();
+
+    //Sanity check to ensure the correct page is being tested. This SHOULD be 
on page 3, but sadly it is not.
+    CPPUNIT_ASSERT(getXPath(pDump, "//page[5]/body/txt[1]/Text[1]", 
"Portion").startsWith("Lorem ipsum"));
+    //Prior to this fix, the original alternation between portrait and 
landscape was completely lost.
+    assertXPath(pDump, "//page[5]/infos/bounds", "width", "8391");  //landscape
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf132149_pgBreak2, "tdf132149_pgBreak2.odt")
 {
     // This 3 page document is designed to visually exaggerate the problems
@@ -566,6 +578,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf132149_pgBreak2, 
"tdf132149_pgBreak2.odt")
     CPPUNIT_ASSERT_LESSEQUAL( 3, getParagraphs() );
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf136952_pgBreak3B, "tdf136952_pgBreak3B.odt")
+{
+    // This 4 page document is designed to visually exaggerate the problems
+    // of emulating LO's followed-by-page-style into MSWord's sections.
+    xmlDocUniquePtr pDump = parseLayoutDump();
+
+    //page::breakAfter must not be lost.
+    //Prior to this bug fix, the Lorem ipsum paragraph was in the middle of a 
portrait page, with no switch to landscape occurring.
+    CPPUNIT_ASSERT(getXPath(pDump, "//page[3]/body/txt[1]/Text[1]", 
"Portion").startsWith("Lorem ipsum"));
+    assertXPath(pDump, "//page[3]/infos/bounds", "width", "8391");  //landscape
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf135949_anchoredBeforeBreak, 
"tdf135949_anchoredBeforeBreak.docx")
 {
     xmlDocUniquePtr pDump = parseLayoutDump();
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index a59a13fe4766..5b29f8d07a55 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2736,9 +2736,22 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode 
)
             // only try to sectionBreak after a split para if the next node 
specifies a break
             if ( bNeedParaSplit )
             {
+                m_pCurrentPageDesc = pNextSplitParaPageDesc;
                 SwNodeIndex aNextIndex( rNode, 1 );
                 const SwTextNode* pNextNode = 
aNextIndex.GetNode().GetTextNode();
                 bCheckSectionBreak = pNextNode && !NoPageBreakSection( 
pNextNode->GetpSwAttrSet() );
+
+                if ( !bCheckSectionBreak )
+                {
+                    auto rBreak = 
ItemGet<SvxFormatBreakItem>(rNode.GetSwAttrSet(), RES_BREAK);
+                    if ( rBreak.GetBreak() == SvxBreak::PageAfter )
+                    {
+                        if ( pNextNode && pNextNode->FindPageDesc() != 
pNextSplitParaPageDesc )
+                            bCheckSectionBreak = true;
+                        else
+                            AttrOutput().SectionBreak(msword::PageBreak, 
/*bBreakAfter=*/true);
+                    }
+                }
             }
 
             if ( bCheckSectionBreak )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to