[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-5-2+backports' - sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Sep 21 09:21:52 UTC 2018
sw/qa/extras/odfexport/data/tdf118393.odt |binary
sw/qa/extras/odfexport/odfexport.cxx | 47 +++++++++++++++++++++++++
sw/qa/extras/ooxmlexport/data/tdf118393.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 51 ++++++++++++++++++++++++++++
sw/source/filter/ww8/wrtw8sty.cxx | 9 +++-
sw/source/filter/ww8/wrtww8.cxx | 1
sw/source/filter/ww8/wrtww8.hxx | 1
sw/source/filter/ww8/ww8atr.cxx | 31 ++++++++++++++++-
8 files changed, 137 insertions(+), 3 deletions(-)
New commits:
commit ddfe489930704e0380e09da5755599daa3ae4ab0
Author: Serge Krot <Serge.Krot at cib.de>
AuthorDate: Wed Jun 27 11:18:41 2018 +0200
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Sep 21 11:21:28 2018 +0200
tdf#118393: FILESAVE: DOCX Export loses header/footer
Change-Id: If47a2e4953e4b98f41c9115779522a755eea8192
Reviewed-on: https://gerrit.libreoffice.org/56522
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Reviewed-on: https://gerrit.libreoffice.org/60823
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/qa/extras/odfexport/data/tdf118393.odt b/sw/qa/extras/odfexport/data/tdf118393.odt
new file mode 100755
index 000000000000..ff8d5400950b
Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf118393.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index fbb9df3a9f9d..8a3662f623a6 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -905,6 +905,53 @@ DECLARE_ODFEXPORT_TEST(testFdo86963, "fdo86963.odt")
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
}
+// Check for correct header/footer with special first page with TOC inside:
+// - DECLARE_ODFEXPORT_TEST(testTdf118393, "tdf118393.odt")
+// - DECLARE_OOXMLEXPORT_TEST(testTdf118393, "tdf118393.odt")
+DECLARE_ODFEXPORT_TEST(testTdf118393, "tdf118393.odt")
+{
+ CPPUNIT_ASSERT_EQUAL( 7, getPages() );
+
+ // First page has no header/footer
+ {
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+
+ // check first page
+ xmlXPathObjectPtr pXmlPage1Header = getXPathNode(pXmlDoc, "/root/page[1]/header");
+ CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlPage1Header->nodesetval));
+
+ xmlXPathObjectPtr pXmlPage1Footer = getXPathNode(pXmlDoc, "/root/page[1]/footer");
+ CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlPage1Footer->nodesetval));
+
+ // check second page in the same way
+ xmlXPathObjectPtr pXmlPage2Header = getXPathNode(pXmlDoc, "/root/page[2]/header");
+ CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlPage2Header->nodesetval));
+
+ xmlXPathObjectPtr pXmlPage2Footer = getXPathNode(pXmlDoc, "/root/page[2]/footer");
+ CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlPage2Footer->nodesetval));
+ }
+
+ // All other pages should have header/footer
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/footer/txt/text()"));
+}
+
DECLARE_ODFEXPORT_TEST(testGerrit13858, "gerrit13858.odt")
{
// Just make sure the output is valid.
diff --git a/sw/qa/extras/ooxmlexport/data/tdf118393.odt b/sw/qa/extras/ooxmlexport/data/tdf118393.odt
new file mode 100644
index 000000000000..ff8d5400950b
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf118393.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 90968b7a53d0..76dc7a87153f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -119,6 +119,53 @@ DECLARE_OOXMLEXPORT_TEST(testFooterBodyDistance, "footer-body-distance.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
}
+// Check for correct header/footer with special first page with TOC inside:
+// - DECLARE_ODFEXPORT_TEST(testTdf118393, "tdf118393.odt")
+// - DECLARE_OOXMLEXPORT_TEST(testTdf118393, "tdf118393.odt")
+DECLARE_OOXMLEXPORT_TEST(testTdf118393, "tdf118393.odt")
+{
+ CPPUNIT_ASSERT_EQUAL( 7, getPages() );
+
+ // First page has no header/footer
+ {
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+
+ // check first page
+ xmlXPathObjectPtr pXmlPage1Header = getXPathNode(pXmlDoc, "/root/page[1]/header");
+ CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlPage1Header->nodesetval));
+
+ xmlXPathObjectPtr pXmlPage1Footer = getXPathNode(pXmlDoc, "/root/page[1]/footer");
+ CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlPage1Footer->nodesetval));
+
+ // check second page in the same way
+ xmlXPathObjectPtr pXmlPage2Header = getXPathNode(pXmlDoc, "/root/page[2]/header");
+ CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlPage2Header->nodesetval));
+
+ xmlXPathObjectPtr pXmlPage2Footer = getXPathNode(pXmlDoc, "/root/page[2]/footer");
+ CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlPage2Footer->nodesetval));
+ }
+
+ // All other pages should have header/footer
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/footer/txt/text()"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/header/txt/text()"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/footer/txt/text()"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testfdo81031, "fdo81031.docx")
{
// vml image was not rendered
@@ -139,6 +186,8 @@ DECLARE_OOXMLEXPORT_TEST(testPlausableBorder, "plausable-border.docx")
if (xmlDocPtr pXmlDoc = parseExport())
// Page break was exported as section break, this was 0
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
+
+ CPPUNIT_ASSERT_EQUAL( 2, getPages() );
}
DECLARE_OOXMLEXPORT_TEST(testUnwantedSectionBreak, "unwanted-section-break.docx")
@@ -186,6 +235,8 @@ DECLARE_OOXMLEXPORT_TEST(testFirstHeaderFooter, "first-header-footer.docx")
// Test import and export of a section's headerf/footerf properties.
// (copied from a ww8export test, with doc converted to docx using Word)
+ CPPUNIT_ASSERT_EQUAL( 6, getPages() );
+
// The document has 6 pages. Note that we don't test if 4 or just 2 page
// styles are created, the point is that layout should be correct.
CPPUNIT_ASSERT_EQUAL(OUString("First page header"), parseDump("/root/page[1]/header/txt/text()"));
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index d16c9fdb28c8..2300f80401f5 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -989,7 +989,7 @@ MSWordSections::MSWordSections( MSWordExportBase& rExport )
sal_uLong nRstLnNum = pSet ? static_cast<const SwFormatLineNumber&>(pSet->Get( RES_LINENUMBER )).GetStartValue() : 0;
const SwTableNode* pTableNd = rExport.m_pCurPam->GetNode().FindTableNode();
- const SwSectionNode* pSectNd;
+ const SwSectionNode* pSectNd = nullptr;
if ( pTableNd )
{
pSet = &pTableNd->GetTable().GetFrameFormat()->GetAttrSet();
@@ -1013,7 +1013,12 @@ MSWordSections::MSWordSections( MSWordExportBase& rExport )
pFormat = pSectNd->GetSection().GetFormat();
}
- // Hole evtl. Pagedesc des 1. Nodes
+ // tdf#118393: FILESAVE: DOCX Export loses header/footer
+ rExport.m_bFirstTOCNodeWithSection = pSectNd &&
+ ( TOX_HEADER_SECTION == pSectNd->GetSection().GetType() ||
+ TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() );
+
+ // Try to get page descriptor of the first node
if ( pSet &&
SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC, true, &pI ) &&
static_cast<const SwFormatPageDesc*>(pI)->GetPageDesc() )
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 054d33ba09e7..0e671a6aee23 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3521,6 +3521,7 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM
, m_nOrigRedlineMode(0)
, m_pAktPageDesc(nullptr)
, m_bPrevTextNodeIsEmpty(false)
+ , m_bFirstTOCNodeWithSection(false)
, m_pPapPlc(nullptr)
, m_pChpPlc(nullptr)
, m_pChpIter(nullptr)
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 4d4a1fa76747..fb8002b6b488 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -479,6 +479,7 @@ public:
ww8::Frames m_aFrames; // The floating frames in this document
const SwPageDesc *m_pAktPageDesc;
bool m_bPrevTextNodeIsEmpty;
+ bool m_bFirstTOCNodeWithSection;
WW8_WrPlcPn* m_pPapPlc;
WW8_WrPlcPn* m_pChpPlc;
MSWordAttrIter* m_pChpIter;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 33b1bc42ee66..8025609f701f 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -452,6 +452,35 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
*/
if ( isCellOpen && ( m_pAktPageDesc->GetName() != pPageDesc->GetName() ) )
pSet = nullptr;
+
+ // tdf#118393: FILESAVE: DOCX Export loses header/footer
+ {
+ bool bPlausableSingleWordSection = sw::util::IsPlausableSingleWordSection(m_pAktPageDesc->GetFirstMaster(), pPageDesc->GetMaster());
+
+ {
+ const SwFrameFormat& rTitleFormat = m_pAktPageDesc->GetFirstMaster();
+ const SwFrameFormat& rFollowFormat = pPageDesc->GetMaster();
+
+ auto pHeaderFormat1 = rTitleFormat.GetHeader().GetHeaderFormat();
+ auto pHeaderFormat2 = rFollowFormat.GetHeader().GetHeaderFormat();
+
+ if (pHeaderFormat1 != pHeaderFormat2)
+ bPlausableSingleWordSection = false;
+
+ auto pFooterFormat1 = rTitleFormat.GetFooter().GetFooterFormat();
+ auto pFooterFormat2 = rFollowFormat.GetFooter().GetFooterFormat();
+
+ if (pFooterFormat1 != pFooterFormat2)
+ bPlausableSingleWordSection = false;
+ }
+
+ if ( !bPlausableSingleWordSection && m_bFirstTOCNodeWithSection )
+ {
+ bBreakSet = false;
+ bNewPageDesc = true;
+ m_pAktPageDesc = pPageDesc;
+ }
+ }
}
else if (!sw::util::IsPlausableSingleWordSection(m_pAktPageDesc->GetFirstMaster(), pPageDesc->GetMaster()))
{
@@ -493,7 +522,7 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
}
}
}
- bNewPageDesc = false; // if next node has RES_BREAK(page break) then bNewPageDesc value should be false.
+
bBreakSet = true;
if ( !bRemoveHardBreakInsideTable )
More information about the Libreoffice-commits
mailing list