sw/qa/extras/ooxmlexport/data/tdf171025_pageAfter.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport25.cxx             |    7 +++++++
 sw/source/filter/ww8/docxattributeoutput.cxx           |    4 ++--
 3 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit a374143c70ded5b51a1f0878cf19e404526b4780
Author:     Justin Luth <[email protected]>
AuthorDate: Thu Feb 26 13:25:01 2026 -0500
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Mar 2 14:24:42 2026 +0100

    tdf#171025 docx export: don't lose pageAfter break in ParaProps
    
    DOCX PrepareNewSectionBreak passes the CurrentSectionInfo
    to SectionBreak, so it always followed the pSectionInfo path.
    
    However, the options in that path do not work
    when StartParagraphProperties is the context.
    
    So, if there is a PageAfter break as one of the paragraph properties,
    and since StartParagraphProperties happens just before EndParagraph
    (i.e. all the pargraph runs have already been written)
    then the request to SvxBreak::PageAfter can be written
    as the last run in the paragraph - right before </w:p>.
    
    That is accomplished with m_bPageBreakAfter.
    
    make CppunitTest_sw_ooxmlexport25 \
        CPPUNIT_TEST_NAME=testTdf171025_pageAfter
    
    The only unit test this patch matched was
    make CppunitTest_sw_ooxmlexport15 \
        CPPUNIT_TEST_NAME=testTdf136952_pgBreak3B
    and (with this patch) simply adds an w:r page break
    just connected before the sectPr - common enough in DOCX.
    And that is fine - after all, the ODT
    does have an explicit page break here...
    
    Change-Id: I718bf6d3cf240fd4ab1140c02194ea11d3767b74
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200633
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Justin Luth <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf171025_pageAfter.docx 
b/sw/qa/extras/ooxmlexport/data/tdf171025_pageAfter.docx
new file mode 100644
index 000000000000..ff6a768000a1
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf171025_pageAfter.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx
index 76578969857f..d5026acfc530 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx
@@ -33,6 +33,13 @@ public:
     }
 };
 
+DECLARE_OOXMLEXPORT_TEST(testTdf171025_pageAfter, "tdf171025_pageAfter.docx")
+{
+    // given a document with a LO specialty pageAfter break
+    // coupled with IsPlausableSingleWordSection
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf171038_pageAfter)
 {
     // given a document with a LO-specialty PageAfter break
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 6fafad9d187e..cf83999358fa 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7126,7 +7126,7 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, 
bool bBreakAfter, const WW
                 m_nColBreakStatus = COLBRK_POSTPONE;
             break;
         case msword::PageBreak:
-            if ( pSectionInfo )
+            if (pSectionInfo && !m_bOpenedParaPr)
             {
                 // Detect when the current node is the last node in the
                 // document: the last section is written explicitly in
@@ -7188,7 +7188,7 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, 
bool bBreakAfter, const WW
             }
             else if ( m_bParagraphOpened )
             {
-                if (bBreakAfter)
+                if (bBreakAfter || m_bOpenedParaPr)
                     // tdf#128889
                     m_bPageBreakAfter = true;
                 else

Reply via email to