sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 2 +- sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 23 +++++------------------ sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 29 +++++++---------------------- sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 12 ++++++------ 4 files changed, 19 insertions(+), 47 deletions(-)
New commits: commit bac1b748f5b600952b9bf3eaaaf5a4bb8342fe59 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue Nov 2 09:11:19 2021 +0200 Commit: Justin Luth <justin_l...@sil.org> CommitDate: Thu Nov 4 06:24:20 2021 +0100 prelim tdf#136472: adjust implementation specific unit tests Using a "First Page" style before a "Default Page Style" in order to apply a different header to the first page is an implementation specific detail. As of LO 4.0/4.1, we have the ability to set a different first-header (different even-odd were already available). So remove any dependency on "First Page". 4-inheritFirstHeader.docx: just test the actual layout 8-n777337.docx: margins must match both page styles. -First and Standard are defined from the same settings 8-n779642.docx: reverting the patch breaks unit test: GOOD 8-n780843.docx: export of footer works now - so test that. -PROOF: CONTINUOUS BREAK - SHOULDN"T SHOW FIRST PAGE - so turn off. 9-headerfooter-link-to-prev.docx: a real thorn test. -happy it still passes after making this logical-seeming change. 15-tdf135216_evenOddFooter.odt: is first of odd in ODT. -when first is shared, it still works to check first. Change-Id: Ice54ef9626f851f9154f3c274ffbe39455538589 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124591 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index 9decd693f327..d5da1882eb35 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -474,7 +474,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135216_evenOddFooter, "tdf135216_evenOddFooter.o xCursor->jumpToNextPage(); pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); - xFooter.set(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextRight")); + xFooter.set(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextFirst")); CPPUNIT_ASSERT_EQUAL(OUString("odd page - first footer"), xFooter->getString()); xCursor->jumpToNextPage(); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 5cd8f4a0fe32..5858eec46524 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -1187,24 +1187,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf95367_inheritFollowStyle, "tdf95367_inheritFollo DECLARE_OOXMLEXPORT_TEST(testInheritFirstHeader,"inheritFirstHeader.docx") { // First page headers always link to last used first header, never to a follow header - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - - xCursor->jumpToLastPage(); - OUString sPageStyleName = getProperty<OUString>( xCursor, "PageStyleName" ); - uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); - CPPUNIT_ASSERT_EQUAL( OUString("Last Header"), xHeaderText->getString() ); - - xCursor->jumpToPreviousPage(); - sPageStyleName = getProperty<OUString>( xCursor, "PageStyleName" ); - xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); - CPPUNIT_ASSERT_EQUAL( OUString("First Header"), xHeaderText->getString() ); - - xCursor->jumpToPreviousPage(); - sPageStyleName = getProperty<OUString>( xCursor, "PageStyleName" ); - xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); - CPPUNIT_ASSERT_EQUAL( OUString("Follow Header"), xHeaderText->getString() ); + CPPUNIT_ASSERT_EQUAL(OUString("First Header"), parseDump("/root/page[1]/header/txt/text()")); + CPPUNIT_ASSERT_EQUAL(OUString("Follow Header"), parseDump("/root/page[2]/header/txt/text()")); + CPPUNIT_ASSERT_EQUAL(OUString("Follow Header"), parseDump("/root/page[3]/header/txt/text()")); + CPPUNIT_ASSERT_EQUAL(OUString("First Header"), parseDump("/root/page[4]/header/txt/text()")); + CPPUNIT_ASSERT_EQUAL(OUString("Last Header"), parseDump("/root/page[5]/header/txt/text()")); } #if HAVE_MORE_FONTS diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 1ac07aaff0cc..59d713fdfb04 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -419,14 +419,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf59699, "tdf59699.docx") DECLARE_OOXMLEXPORT_TEST(testN777337, "n777337.docx") { - /* - * The problem was that the top and bottom margin on the first page was only 0.1cm instead of 1.7cm. - * - * oFirst = ThisComponent.StyleFamilies.PageStyles.getByName("First Page") - * xray oFirst.TopMargin - * xray oFirst.BottomMargin - */ - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY); + // The problem was that the top and bottom margin on the first page was only 0.1cm instead of 1.7cm. + uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1702), getProperty<sal_Int32>(xPropertySet, "TopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(1702), getProperty<sal_Int32>(xPropertySet, "BottomMargin")); } @@ -586,19 +580,7 @@ DECLARE_OOXMLEXPORT_TEST(testN780853, "n780853.docx") DECLARE_OOXMLEXPORT_TEST(testN780843, "n780843.docx") { - uno::Reference< text::XTextRange > xPara = getParagraph(1); - OUString aStyleName = getProperty<OUString>(xPara, "PageStyleName"); - // what happens on export here is that the "Default Style" isn't actually - // used on page 2, because of the hard page break with style "Converted2" - // and therefore SwPageDesc::IsFollowNextPageOfNode() returns false and - // "w:titlepg" element is not written - // (the export result is wrong with or without w:titlepg, because the footer - // on the 2nd page should be the text "shown footer") - if (mbExported) - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), aStyleName); - else - CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aStyleName); - + CPPUNIT_ASSERT_EQUAL(OUString("shown footer"), parseDump("/root/page[2]/footer/txt/text()")); //tdf64372 this document should only have one page break (2 pages, not 3) CPPUNIT_ASSERT_EQUAL(2, getPages()); @@ -786,7 +768,10 @@ DECLARE_OOXMLEXPORT_TEST(testN779642, "n779642.docx") // tdf#106572 - perhaps not the best test to hijack since this file // produces an error in Word, but it nicely matches danger points, // and has a different first footer, so nice visual confirmation. - CPPUNIT_ASSERT_EQUAL(OUString("First Page"), getProperty<OUString>(getParagraphOrTable(1), "PageDescName")); + discardDumpedLayout(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // There is no footer text on the first page. + assertXPath(pXmlDoc, "/root/page[1]/footer/txt", 0); } DECLARE_OOXMLEXPORT_TEST(testTbLrHeight, "tblr-height.docx") diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 57de8c58a3ed..4416edc4ef69 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -586,9 +586,9 @@ DECLARE_SW_EXPORT_TEST(testHFLinkToPrev, "headerfooter-link-to-prev.docx", nullp xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); // check page 1 header & footer text CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), - getHFText(xPageStyle, "HeaderText")); + getHFText(xPageStyle, "HeaderTextFirst")); CPPUNIT_ASSERT_EQUAL(OUString("First page footer for section 1 only"), - getHFText(xPageStyle, "FooterText")); + getHFText(xPageStyle, "FooterTextFirst")); // get LO page style for page 2, corresponding to docx section 1 xCursor->jumpToPage(2); @@ -610,9 +610,9 @@ DECLARE_SW_EXPORT_TEST(testHFLinkToPrev, "headerfooter-link-to-prev.docx", nullp xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY ); // check header & footer text CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), - getHFText(xPageStyle, "HeaderText")); + getHFText(xPageStyle, "HeaderTextFirst")); CPPUNIT_ASSERT_EQUAL(OUString("First page footer for sections 2 and 3 only"), - getHFText(xPageStyle, "FooterText")); + getHFText(xPageStyle, "FooterTextFirst")); // get LO page style for page 5, corresponding to docx section 2 xCursor->jumpToPage(5); @@ -634,9 +634,9 @@ DECLARE_SW_EXPORT_TEST(testHFLinkToPrev, "headerfooter-link-to-prev.docx", nullp xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY ); // check header & footer text CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), - getHFText(xPageStyle, "HeaderText")); + getHFText(xPageStyle, "HeaderTextFirst")); CPPUNIT_ASSERT_EQUAL(OUString("First page footer for sections 2 and 3 only"), - getHFText(xPageStyle, "FooterText")); + getHFText(xPageStyle, "FooterTextFirst")); // get LO page style for page 8, corresponding to docx section 3 xCursor->jumpToPage(8);