diff options
author | Justin Luth <justin_luth@sil.org> | 2016-09-27 16:01:46 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2016-09-29 04:34:34 +0000 |
commit | 13c0122ad18dd1db187de8afc2ef406421d6d0e5 (patch) | |
tree | 8ff0ce3ed02e1c86d1fb9e80e0636044e7319793 /sw | |
parent | a87a31602165cb2a37c32f5928e4f9daade7271d (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex2.docx | bin | 0 -> 16057 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 26 |
2 files changed, 26 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex2.docx b/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex2.docx Binary files differnew file mode 100644 index 000000000000..18b63c07c447 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex2.docx 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<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(); + + sal_Int16 nPages = xCursor->getPage(); + while( nPages > 0 ) + { + OUString sPageStyleName = getProperty<OUString>( xCursor, "PageStyleName" ); + uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(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. |