From 13c0122ad18dd1db187de8afc2ef406421d6d0e5 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 27 Sep 2016 16:01:46 +0300 Subject: tdf#90697 unit test for an unused FirstPage header Continuous section breaks are tricky to handle. Here is a strange case where the first page header is defined in the middle of a page, so it is unused. Also added is an extra section page break for added complexity (which inherits from the previous section). Except for not dynamically switching to the most recently defined headers/footers (which Writer is not designed to do), these breaks are currently handled somewhat properly. Adding this test to prevent regressions. Change-Id: I6fe464c8839660a6eb19e0dd205adfa6ec988d7d Reviewed-on: https://gerrit.libreoffice.org/29322 Tested-by: Jenkins Reviewed-by: Justin Luth --- .../data/tdf92724_continuousBreaksComplex2.docx | Bin 0 -> 16057 bytes sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 26 +++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex2.docx (limited to 'sw') diff --git a/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex2.docx b/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex2.docx new file mode 100644 index 000000000000..18b63c07c447 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex2.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 4ddf5e46a901..559c4a7a976e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -1005,6 +1005,32 @@ DECLARE_OOXMLEXPORT_TEST(testTdf92724_continuousBreaksComplex,"tdf92724_continuo CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCursor->getPage()); } +DECLARE_OOXMLEXPORT_TEST(testTdf90697_continuousBreaksComplex2,"tdf92724_continuousBreaksComplex2.docx") +{ +// Continuous section breaks with new headers/footers should not immediately switch to a new page style. + uno::Reference xModel(mxComponent, uno::UNO_QUERY); + uno::Reference xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + + sal_Int16 nPages = xCursor->getPage(); + while( nPages > 0 ) + { + OUString sPageStyleName = getProperty( xCursor, "PageStyleName" ); + uno::Reference xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); +// Specific case to avoid. Testing separately (even though redundant). +// The first header (defined on page 3) ONLY is shown IF the section happens to start on a new page (which it doesn't in this document). + CPPUNIT_ASSERT( xHeaderText->getString() != "Third section - First page header. No follow defined" ); +// Same test stated differently: Pages 4 and 5 OUGHT to use "Second section header", but currently don't. Page 6 does. + if( nPages <= 3 ) + CPPUNIT_ASSERT_EQUAL( xHeaderText->getString(), OUString("First section header") ); + else + CPPUNIT_ASSERT( xHeaderText->getString() == "First section header" || xHeaderText->getString() == "Second section header" ); + + xCursor->jumpToPage( --nPages ); + } +} + DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original,"tdf81345.docx") { //Header wasn't replaced and columns were missing because no new style was created. -- cgit