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_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@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 0000000..86ea177
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf132149_pgBreakB.odt
Binary files 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 0000000..e39ebde
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf136952_pgBreak3B.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 8d98ccd..07f2e06 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 a59a13f..5b29f8d 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 )