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 5c37d06aeec3cdfb1bdcc94d957a84c514b845b2
Author:     Justin Luth <[email protected]>
AuthorDate: Thu Feb 26 13:25:01 2026 -0500
Commit:     Justin Luth <[email protected]>
CommitDate: Fri Feb 27 23:34:28 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 it simply adds an explicit page break
    just connected before the sectPr - common enough in DOCX.
    
    Change-Id: I718bf6d3cf240fd4ab1140c02194ea11d3767b74
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200539
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <[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 a18288e0e137..ddac9aa94ec8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx
@@ -41,6 +41,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148057_columnBreak, 
"tdf148057_columnBreak.docx"
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+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 4589ee750553..febe11d813ac 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7218,7 +7218,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
@@ -7280,7 +7280,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