diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-11-24 12:55:25 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-11-28 04:02:22 +0100 |
commit | 9e876c164a1d9e552c08be3112ada09712a20eb3 (patch) | |
tree | 2d0bdb15597fc9c049590964bd45f26cdc7b6119 /sw | |
parent | 5589659829f8a1cef8ca1c8a468732105bbe231b (diff) |
sw: move header/footer tests to own class in core tests
In addition add some more basic header/footer tests.
This makes refactoring of header and footer OOXML import
much easier.
Change-Id: I5b3b3714656ba2f7b1dda8d8f067c3bfe68857a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159946
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_core_header_footer.mk | 73 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/core/header_footer/HeaderFooterTest.cxx | 1274 | ||||
-rw-r--r-- | sw/qa/core/header_footer/data/DoubleFirstLeftRight.docx | bin | 0 -> 11824 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/DoubleFirstLeftRight.odt | bin | 0 -> 12626 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/FirstPageHeaderShape.docx | bin | 0 -> 6189 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/FirstPageHeaderShape.odt | bin | 0 -> 9647 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/SimpleFirst.docx (renamed from sw/qa/extras/ooxmlimport/data/SimpleFirst.docx) | bin | 5543 -> 5543 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/SimpleFirst.odt (renamed from sw/qa/extras/ooxmlimport/data/SimpleFirst.odt) | bin | 9468 -> 9468 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/SimpleFirstLeftRight.docx | bin | 0 -> 8450 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/SimpleFirstLeftRight.odt | bin | 0 -> 10754 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/SimpleLeftRight.docx (renamed from sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx) | bin | 5531 -> 5531 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/SimpleLeftRight.odt (renamed from sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt) | bin | 9601 -> 9601 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/TestFirstFooterDisabled.docx | bin | 0 -> 85485 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/TestPageStyleOnlyLeft.docx | bin | 0 -> 10191 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/bnc519228_odd-breaksB.docx (renamed from sw/qa/extras/ooxmlexport/data/bnc519228_odd-breaksB.docx) | bin | 13674 -> 13674 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/bnc875718.docx (renamed from sw/qa/extras/ooxmlexport/data/bnc875718.docx) | bin | 7369 -> 7369 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/bnc884615-mso-position.docx (renamed from sw/qa/extras/ooxmlexport/data/bnc884615-mso-position.docx) | bin | 7751 -> 7751 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/cont-sect-break-header-footer.docx (renamed from sw/qa/extras/ooxmlexport/data/cont-sect-break-header-footer.docx) | bin | 18294 -> 18294 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/fdo64238_a.docx (renamed from sw/qa/extras/ooxmlexport/data/fdo64238_a.docx) | bin | 16401 -> 16401 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/fdo64238_b.docx (renamed from sw/qa/extras/ooxmlexport/data/fdo64238_b.docx) | bin | 14359 -> 14359 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/fdo65655.docx (renamed from sw/qa/extras/ooxmlexport/data/fdo65655.docx) | bin | 13760 -> 13760 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/fdo66145.docx (renamed from sw/qa/extras/ooxmlexport/data/fdo66145.docx) | bin | 16245 -> 16245 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/first-header-footer.doc (renamed from sw/qa/extras/ww8export/data/first-header-footer.doc) | bin | 23552 -> 23552 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/first-header-footer.docx (renamed from sw/qa/extras/ooxmlexport/data/first-header-footer.docx) | bin | 21998 -> 21998 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/first-header-footer.odt (renamed from sw/qa/extras/odfexport/data/first-header-footer.odt) | bin | 9644 -> 9644 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/first-header-footerB.odt (renamed from sw/qa/extras/ooxmlexport/data/first-header-footerB.odt) | bin | 11341 -> 11341 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/headerfooter-link-to-prev.docx (renamed from sw/qa/extras/ooxmlexport/data/headerfooter-link-to-prev.docx) | bin | 18770 -> 18770 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/n750935.docx (renamed from sw/qa/extras/ooxmlexport/data/n750935.docx) | bin | 57750 -> 57750 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf112694.docx (renamed from sw/qa/extras/ooxmlexport/data/tdf112694.docx) | bin | 14741 -> 14741 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf113849_evenAndOddHeaders.odt (renamed from sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt) | bin | 24355 -> 24355 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf118393.odt (renamed from sw/qa/extras/odfexport/data/tdf118393.odt) | bin | 14208 -> 14208 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf127778.docx (renamed from sw/qa/extras/ooxmlimport/data/tdf127778.docx) | bin | 23220 -> 23220 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf129582.docx (renamed from sw/qa/extras/ooxmlexport/data/tdf129582.docx) | bin | 129975 -> 129975 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf135216_evenOddFooter.docx | bin | 0 -> 10784 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf135216_evenOddFooter.odt (renamed from sw/qa/extras/ooxmlexport/data/tdf135216_evenOddFooter.odt) | bin | 12457 -> 12457 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf145998_firstHeader.odt (renamed from sw/qa/extras/ooxmlexport/data/tdf145998_firstHeader.odt) | bin | 9691 -> 9691 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf57155.docx (renamed from sw/qa/extras/ooxmlexport/data/tdf57155.docx) | bin | 27287 -> 27287 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf69635.docx (renamed from sw/qa/extras/ooxmlexport/data/tdf69635.docx) | bin | 6042 -> 6042 bytes | |||
-rw-r--r-- | sw/qa/core/header_footer/data/tdf79639.docx (renamed from sw/qa/extras/ooxmlexport/data/tdf79639.docx) | bin | 18409 -> 18409 bytes | |||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 61 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf118393.odt | bin | 14208 -> 0 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 129 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 26 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 26 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 43 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 45 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 17 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 67 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 14 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 18 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 127 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx | bin | 6820 -> 0 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt | bin | 10118 -> 0 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 226 | ||||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export.cxx | 20 |
56 files changed, 1348 insertions, 819 deletions
diff --git a/sw/CppunitTest_sw_core_header_footer.mk b/sw/CppunitTest_sw_core_header_footer.mk new file mode 100644 index 000000000000..5f1668c3fb49 --- /dev/null +++ b/sw/CppunitTest_sw_core_header_footer.mk @@ -0,0 +1,73 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_header_footer, \ + sw/qa/core/header_footer/HeaderFooterTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_core_header_footer, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + sfx \ + subsequenttest \ + sw \ + swqahelper \ + test \ + unotest \ + utl \ + vcl \ + svt \ + tl \ + svl \ + svxcore \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_core_header_footer,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_core_header_footer,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ + -I$(SRCDIR)/sw/qa/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_core_header_footer,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_core_header_footer)) +$(eval $(call gb_CppunitTest_use_vcl,sw_core_header_footer)) +$(eval $(call gb_CppunitTest_use_rdb,sw_core_header_footer,services)) +$(eval $(call gb_CppunitTest_use_configuration,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_header_footer,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_header_footer, \ + modules/swriter \ + svt \ + svx \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 22cea818178a..0123a56468de 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -158,6 +158,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_uibase_fldui \ CppunitTest_sw_core_view \ CppunitTest_sw_core_attr \ + CppunitTest_sw_core_header_footer \ CppunitTest_sw_filter_ww8 \ CppunitTest_sw_filter_html \ CppunitTest_sw_filter_xml \ diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx b/sw/qa/core/header_footer/HeaderFooterTest.cxx new file mode 100644 index 000000000000..8b78363a0c1b --- /dev/null +++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx @@ -0,0 +1,1274 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XFootnote.hpp> +#include <com/sun/star/text/XFootnotesSupplier.hpp> +#include <com/sun/star/text/XSimpleText.hpp> +#include <com/sun/star/text/XTextField.hpp> +#include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/text/XTextCursor.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XTextFrame.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/style/PageStyleLayout.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/container/XNameContainer.hpp> + +#include <cppunit/TestAssert.h> +#include <cppunit/extensions/HelperMacros.h> + +namespace +{ +class HeaderFooterTest : public SwModelTestBase +{ +public: + void checkParagraph(sal_Int32 nNumber, OUString const& rParagraphString, + OUString const& rConnectedPageStyle); + void checkFirstRestHeaderPageStyles(); + void checkLeftRightHeaderPageStyles(); + void checkFirstLeftRightHeaderPageStyles(); + void checkDoubleFirstLeftRightHeaderPageStyles(OUString const& rCustomPageStyleName); + void checkShapeInFirstPageHeader(); + + HeaderFooterTest() + : SwModelTestBase("/sw/qa/core/header_footer/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testNonFirstHeaderIsDisabled) +{ + // related to tdf#127778 + // Header for the first page is enabled, but for the second page it should be disabled or act like it is disabled + // so the header vertical size is consistent. + + createSwDoc("tdf127778.docx"); + + xmlDocUniquePtr pLayout = parseLayoutDump(); + assertXPath(pLayout, "//page[2]/header"_ostr, 0); +} + +// Check for correct header/footer with special first page with TOC inside +// Related to tdf#118393 +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testHeaderFooterWithSpecialFirstPage_OOXML) +{ + // Load, save in OOXML format and reload + createSwDoc("tdf118393.odt"); + saveAndReload("Office Open XML Text"); + + CPPUNIT_ASSERT_EQUAL(7, getPages()); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // check first page + assertXPath(pXmlDoc, "/root/page[1]/header"_ostr, 0); + assertXPath(pXmlDoc, "/root/page[1]/footer"_ostr, 0); + // check second page in the same way + assertXPath(pXmlDoc, "/root/page[2]/header"_ostr); + assertXPath(pXmlDoc, "/root/page[2]/footer"_ostr); + } + // All other pages should have header/footer + OUString sExpected("Seite * von *"); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[6]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[7]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[7]/footer/txt/text()"_ostr)); +} + +// Check for correct header/footer with special first page with TOC inside +// Related to tdf#118393 +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testHeaderFooterWithSpecialFirstPage_ODF) +{ + // Load, save in ODF format and reload + createSwDoc("tdf118393.odt"); + saveAndReload("writer8"); + + CPPUNIT_ASSERT_EQUAL(7, getPages()); + + // First page has no header/footer + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // check first page + assertXPath(pXmlDoc, "/root/page[1]/header"_ostr, 0); + assertXPath(pXmlDoc, "/root/page[1]/footer"_ostr, 0); + // check second page in the same way + assertXPath(pXmlDoc, "/root/page[2]/header"_ostr); + assertXPath(pXmlDoc, "/root/page[2]/footer"_ostr); + } + + // All other pages should have header/footer + OUString sExpected("Seite * von *"); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[6]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[7]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(sExpected, parseDump("/root/page[7]/footer/txt/text()"_ostr)); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFloatingTableInHeader) +{ + // Related to tdf#79639 + createSwDoc("tdf79639.docx"); + + // This was 0, floating table in header wasn't converted to a TextFrame. + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + saveAndReload("Office Open XML Text"); + + // This was 0, floating table in header wasn't converted to a TextFrame. + CPPUNIT_ASSERT_EQUAL(1, getShapes()); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFdo64238_a) +{ + createSwDoc("fdo64238_a.docx"); + + // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled* + // then LO would still import the Even footer and concatenate it to the odd footer. + // This case specifically is for : + // 'Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word + // In this case the imported footer in LO was supposed to be blank, but instead was the 'even' footer + uno::Reference<text::XText> xFooterText = getProperty<uno::Reference<text::XText>>( + getStyles("PageStyles")->getByName("Standard"), "FooterText"); + uno::Reference<text::XTextRange> xFooterParagraph = getParagraphOfText(1, xFooterText); + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + sal_Int32 numOfRuns = 0; + while (xRunEnum->hasMoreElements()) + { + xRunEnum->nextElement(); + numOfRuns++; + } + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), numOfRuns); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFdo64238_b) +{ + createSwDoc("fdo64238_b.docx"); + + // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled* + // then LO would still import the Even footer and concatenate it to the odd footer. + // This case specifically is for : + // 'Non-Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word + // In this case the imported footer in LO was supposed to be just the odd footer, but instead was the 'odd' and 'even' footers concatenated + uno::Reference<text::XText> xFooterText = getProperty<uno::Reference<text::XText>>( + getStyles("PageStyles")->getByName("Standard"), "FooterText"); + uno::Reference<text::XTextRange> xFooterParagraph = getParagraphOfText(1, xFooterText); + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + sal_Int32 numOfRuns = 0; + while (xRunEnum->hasMoreElements()) + { + xRunEnum->nextElement(); + numOfRuns++; + } + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstPageHeadersAndEmptyFooters) +{ + // Test for fdo#66145 + + // Test case where headers and footers for first page are set, but footers are empty + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(OUString("This is the FIRST page header."), + parseDump("/root/page[1]/header/txt/text()"_ostr)); + + CPPUNIT_ASSERT_EQUAL(OUString("This is the header for the REST OF THE FILE."), + parseDump("/root/page[2]/header/txt/text()"_ostr)); + + CPPUNIT_ASSERT_EQUAL(OUString("This is the header for the REST OF THE FILE."), + parseDump("/root/page[3]/header/txt/text()"_ostr)); + }; + + createSwDoc("fdo66145.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooterImport) +{ + // Test import and export of a section's headerf/footerf properties. + // (copied from a ww8export test, with doc converted to docx using Word) + auto verify = [this]() { + 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()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), + parseDump("/root/page[1]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), + parseDump("/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), + parseDump("/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), + parseDump("/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), + parseDump("/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), + parseDump("/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), + parseDump("/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), + parseDump("/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), + parseDump("/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), + parseDump("/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), + parseDump("/root/page[6]/footer/txt/text()"_ostr)); + }; + + createSwDoc("first-header-footer.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooterRoundTrip) +{ + createSwDoc("first-header-footerB.odt"); + saveAndReload("Office Open XML Text"); + + CPPUNIT_ASSERT_EQUAL(6, getPages()); + + CPPUNIT_ASSERT_EQUAL(OUString("First page header"), + parseDump("/root/page[1]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), + parseDump("/root/page[1]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), + parseDump("/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), + parseDump("/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), + parseDump("/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), + parseDump("/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), + parseDump("/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), + parseDump("/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), + parseDump("/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), + parseDump("/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), + parseDump("/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), + parseDump("/root/page[6]/footer/txt/text()"_ostr)); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooter_ODF) +{ + createSwDoc("first-header-footer.odt"); + saveAndReload("writer8"); + + CPPUNIT_ASSERT_EQUAL(6, getPages()); + // Test import and export of the header-first token. + + // The document has 6 pages, two page styles for the first and second half of pages. + CPPUNIT_ASSERT_EQUAL(OUString("First header"), + parseDump("/root/page[1]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First footer"), + parseDump("/root/page[1]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Left header"), + parseDump("/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Left footer"), + parseDump("/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Right header"), + parseDump("/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Right footer"), + parseDump("/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First header2"), + parseDump("/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First footer2"), + parseDump("/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Right header2"), + parseDump("/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Right footer2"), + parseDump("/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Left header2"), + parseDump("/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Left footer2"), + parseDump("/root/page[6]/footer/txt/text()"_ostr)); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstHeaderFooter_DOC) +{ + createSwDoc("first-header-footer.doc"); + saveAndReload("MS Word 97"); + + // Test import and export of a section's headerf/footerf properties. + + // 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()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), + parseDump("/root/page[1]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), + parseDump("/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), + parseDump("/root/page[2]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), + parseDump("/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), + parseDump("/root/page[3]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), + parseDump("/root/page[4]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), + parseDump("/root/page[4]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), + parseDump("/root/page[5]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), + parseDump("/root/page[5]/footer/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), + parseDump("/root/page[6]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), + parseDump("/root/page[6]/footer/txt/text()"_ostr)); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFdo65655) +{ + // related - fdo#65655 + + // The problem was that the DOCX had a non-blank odd footer and a blank even footer + // The 'Different Odd & Even Pages' was turned on + // However - LO assumed that because the 'even' footer is blank - it should ignore the 'Different Odd & Even Pages' flag + // So it did not import it and did not export it + + auto verify = [this]() { + uno::Reference<beans::XPropertySet> xPropertySet( + getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + { + bool bValue = false; + xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue; + CPPUNIT_ASSERT_EQUAL(false, bValue); + } + { + bool bValue = false; + xPropertySet->getPropertyValue("FooterIsShared") >>= bValue; + CPPUNIT_ASSERT_EQUAL(false, bValue); + } + }; + createSwDoc("fdo65655.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testImageInHeader) +{ + // Related bug tdf#57155 + createSwDoc("tdf57155.docx"); + + // Without the fix in place, the image in the header of page 2 wouldn't exist + CPPUNIT_ASSERT_EQUAL(2, getPages()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + saveAndReload("Office Open XML Text"); + + CPPUNIT_ASSERT_EQUAL(2, getPages()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testImageInFooter) +{ + // Related bug tdf#129582 + createSwDoc("tdf129582.docx"); + + // Without the fix in place, the image in the footer of page 2 wouldn't exist + CPPUNIT_ASSERT_EQUAL(2, getPages()); + CPPUNIT_ASSERT_EQUAL(2, getShapes()); + + saveAndReload("Office Open XML Text"); + + CPPUNIT_ASSERT_EQUAL(2, getPages()); + CPPUNIT_ASSERT_EQUAL(2, getShapes()); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf112694) +{ + auto verify = [this]() { + uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard"); + // Header was on when header for file was for explicit first pages only + // (marked via <w:titlePg>). + CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn")); + }; + + createSwDoc("tdf112694.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testContSectBreakHeaderFooter) +{ + auto verify = [this]() { + // Load a document with a continuous section break on page 2. + CPPUNIT_ASSERT_EQUAL(OUString("First page header, section 1"), + parseDump("/root/page[1]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer, section 1"), + parseDump("/root/page[1]/footer/txt/text()"_ostr)); + + // Make sure the header stays like this; if we naively just update the page style name of the + // first para on page 2, then this would be 'Header, section 2', which is incorrect. + CPPUNIT_ASSERT_EQUAL(OUString("First page header, section 2"), + parseDump("/root/page[2]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer, section 2"), + parseDump("/root/page[2]/footer/txt/text()"_ostr)); + + // This is inherited from page 2. + CPPUNIT_ASSERT_EQUAL(OUString("Header, section 2"), + parseDump("/root/page[3]/header/txt/text()"_ostr)); + CPPUNIT_ASSERT_EQUAL(OUString("Footer, section 3"), + parseDump("/root/page[3]/footer/txt/text()"_ostr)); + + // Without the export fix in place, the import-export-import test would have failed with: + // - Expected: Header, section 2 + // - Actual : First page header, section 2 + // i.e. both the header and the footer on page 3 was wrong. + + // Additional problem: top margin on page 3 was wrong. + if (isExported()) + { + xmlDocUniquePtr pXml = parseExport("word/document.xml"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2200 + // - Actual : 2574 + // i.e. the top margin on page 3 was too large and now matches the value from the input + // document. + assertXPath(pXml, "/w:document/w:body/w:sectPr/w:pgMar"_ostr, "top"_ostr, "2200"); + } + }; + + createSwDoc("cont-sect-break-header-footer.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf145998_firstHeader) +{ + createSwDoc("tdf145998_firstHeader.odt"); + saveAndReload("Office Open XML Text"); + + // Sanity check - always good to test when dealing with page styles and breaks. + CPPUNIT_ASSERT_EQUAL(2, getPages()); + + CPPUNIT_ASSERT_EQUAL(OUString("Very first header"), parseDump("/root/page[1]/header/txt"_ostr)); + + // Page Style is already used in prior section - this can't be the first-header + CPPUNIT_ASSERT_EQUAL(OUString("Normal Header"), parseDump("/root/page[2]/header/txt"_ostr)); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testEvenPageOddPageFooter_Import) +{ + // Related tdf#135216 + + createSwDoc("tdf135216_evenOddFooter.docx"); + + 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); + + // get LO page style for the first page (even page #2) + OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles"); + uno::Reference<style::XStyle> xPageStyle(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + + xCursor->jumpToFirstPage(); // Even/Left page #2 + uno::Reference<text::XText> xFooter + = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("even page"), xFooter->getString()); + + xCursor->jumpToNextPage(); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + xFooter.set(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextFirst")); + CPPUNIT_ASSERT_EQUAL(OUString("odd page - first footer"), xFooter->getString()); + + xCursor->jumpToNextPage(); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + xFooter.set(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft")); + CPPUNIT_ASSERT_EQUAL(OUString("even page"), xFooter->getString()); + + // The contents of paragraph 2 should be the page number (2) located on page 1. + getParagraph(2, "2"); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testEvenPageOddPageFooter_Roundtrip) +{ + // Related tdf#135216 + + // Load, save as OOXML and reload + createSwDoc("tdf135216_evenOddFooter.odt"); + saveAndReload("Office Open XML Text"); + + 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); + + // get LO page style for the first page (even page #2) + OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles"); + uno::Reference<style::XStyle> xPageStyle(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + + xCursor->jumpToFirstPage(); // Even/Left page #2 + uno::Reference<text::XText> xFooter + = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("even page"), xFooter->getString()); + + xCursor->jumpToNextPage(); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + xFooter.set(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextFirst")); + CPPUNIT_ASSERT_EQUAL(OUString("odd page - first footer"), xFooter->getString()); + + xCursor->jumpToNextPage(); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + xFooter.set(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft")); + CPPUNIT_ASSERT_EQUAL(OUString("even page"), xFooter->getString()); + + // The contents of paragraph 2 should be the page number (2) located on page 1. + getParagraph(2, "2"); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf69635) +{ + createSwDoc("tdf69635.docx"); + saveAndReload("Office Open XML Text"); + + xmlDocUniquePtr pXmlHeader1 = parseExport("word/header1.xml"); + CPPUNIT_ASSERT(pXmlHeader1); + + xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml"); + CPPUNIT_ASSERT(pXmlSettings); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: "left" + // - Actual : "right" + assertXPathContent(pXmlHeader1, "/w:hdr/w:p/w:r/w:t"_ostr, "left"); + + // Make sure "left" appears as a hidden header + assertXPath(pXmlSettings, "/w:settings/w:evenAndOddHeaders"_ostr, 0); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf113849_evenAndOddHeaders) +{ + createSwDoc("tdf113849_evenAndOddHeaders.odt"); + saveAndReload("Office Open XML Text"); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Header2 text", OUString("L. J. Kendall"), + parseDump("/root/page[2]/header/txt"_ostr)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer2 text", OUString("*"), + parseDump("/root/page[2]/footer/txt"_ostr)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Header3 text", OUString("Shadow Hunt"), + parseDump("/root/page[3]/header/txt"_ostr)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer3 text", OUString("*"), + parseDump("/root/page[3]/footer/txt"_ostr)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Header4 text", OUString("L. J. Kendall"), + parseDump("/root/page[4]/header/txt"_ostr)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer4 text", OUString("*"), + parseDump("/root/page[4]/footer/txt"_ostr)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer5 text", OUString(""), + parseDump("/root/page[5]/footer/txt"_ostr)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer6 text", OUString(""), + parseDump("/root/page[6]/footer/txt"_ostr)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages", 6, getPages()); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstPageFooterEnabled) +{ + // tdf#106572 + // Page style with first page and other pages. + // Footer shouldn't be enabled on first page, but then on the other pages + auto verify = [this]() { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/footer/txt"_ostr, 0); + }; + createSwDoc("TestFirstFooterDisabled.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testBnc519228OddBreaks) +{ + auto verify = [this]() { + // Check that all the normal styles are not set as right-only, those should be only those used after odd page breaks. + auto xStyles = getStyles("PageStyles"); + uno::Reference<beans::XPropertySet> xStyle; + { + xStyle.set(xStyles->getByName("Standard"), uno::UNO_QUERY); + auto aPageLayout = xStyle->getPropertyValue("PageStyleLayout"); + CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), aPageLayout); + } + { + xStyle.set(xStyles->getByName("First Page"), uno::UNO_QUERY); + auto aPageLayout = xStyle->getPropertyValue("PageStyleLayout"); + CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), aPageLayout); + } + + uno::Reference<beans::XPropertySet> page1Style; + { + auto xPara = getParagraph(1); + CPPUNIT_ASSERT_EQUAL(OUString("This is the first page."), xPara->getString()); + OUString page1StyleName = getProperty<OUString>(xPara, "PageDescName"); + page1Style.set(xStyles->getByName(page1StyleName), uno::UNO_QUERY); + auto aPageLayout = page1Style->getPropertyValue("PageStyleLayout"); + CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_RIGHT), aPageLayout); + + auto xHeaderText = getProperty<uno::Reference<text::XText>>(page1Style, "HeaderText"); + auto xHeaderPara = getParagraphOfText(1, xHeaderText); + CPPUNIT_ASSERT_EQUAL(OUString("This is the header for odd pages"), + xHeaderPara->getString()); + } + + // Page2 comes from follow of style for page 1 and should be a normal page. Also check the two page style have the same properties, + // since page style for page1 was created from page style for page 2. + { + auto aFollowStyleName = getProperty<OUString>(page1Style, "FollowStyle"); + + uno::Reference<beans::XPropertySet> page2Style; + page2Style.set(xStyles->getByName(aFollowStyleName), uno::UNO_QUERY); + auto aPage2Layout = page2Style->getPropertyValue("PageStyleLayout"); + CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), aPage2Layout); + + auto xHeaderTextLeft + = getProperty<uno::Reference<text::XText>>(page2Style, "HeaderTextLeft"); + auto xHeaderLeftPara = getParagraphOfText(1, xHeaderTextLeft); + CPPUNIT_ASSERT_EQUAL(OUString("This is the even header"), xHeaderLeftPara->getString()); + + auto xHeaderTextRight + = getProperty<uno::Reference<text::XText>>(page2Style, "HeaderTextRight"); + auto xHeaderRightPara = getParagraphOfText(1, xHeaderTextRight); + CPPUNIT_ASSERT_EQUAL(OUString("This is the header for odd pages"), + xHeaderRightPara->getString()); + + CPPUNIT_ASSERT_EQUAL(getProperty<sal_Int32>(page1Style, "TopMargin"), + getProperty<sal_Int32>(page2Style, "TopMargin")); + } + + // Page 5 + { + auto xPara = getParagraph(4); + CPPUNIT_ASSERT_EQUAL( + OUString("Then an odd break after an odd page, should lead us to page #5."), + xPara->getString()); + + OUString page5StyleName = getProperty<OUString>(xPara, "PageDescName"); + uno::Reference<beans::XPropertySet> page5Style(xStyles->getByName(page5StyleName), + uno::UNO_QUERY); + auto aPageLayout = page5Style->getPropertyValue("PageStyleLayout"); + CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_RIGHT), aPageLayout); + + auto xHeaderText = getProperty<uno::Reference<text::XText>>(page5Style, "HeaderText"); + auto xHeaderTextPara = getParagraphOfText(1, xHeaderText); + CPPUNIT_ASSERT_EQUAL(OUString("This is the header for odd pages"), + xHeaderTextPara->getString()); + } + }; + + createSwDoc("bnc519228_odd-breaksB.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testBnc875718) +{ + createSwDoc("bnc875718.docx"); + saveAndReload("Office Open XML Text"); + + // The frame in the footer must not accidentally end up in the document body. + // The easiest way for this to test I've found is checking that + // xray ThisComponent.TextFrames.GetByIndex( index ).Anchor.Text.ImplementationName + // is not SwXBodyText but rather SwXHeadFootText + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), + uno::UNO_QUERY); + // The sample bugdoc has 3 footer.xml and has a textframe in each. The first one is hidden + // and it has no text in its anchored text range: it is anchored to body text. Ignoring... + for (int i = 1; i < xIndexAccess->getCount(); ++i) + { + uno::Reference<text::XTextFrame> frame(xIndexAccess->getByIndex(i), uno::UNO_QUERY); + uno::Reference<text::XTextRange> range = frame->getAnchor(); + uno::Reference<lang::XServiceInfo> text(range->getText(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("SwXHeadFootText"), text->getImplementationName()); + } + // Also check that the footer contents are not in the body text. + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XText> text = textDocument->getText(); + CPPUNIT_ASSERT(text); //Do not crash on empty content + CPPUNIT_ASSERT_EQUAL(OUString("Text"), text->getString()); +} + +// base class to supply a helper method for testHFLinkToPrev +class TestHFBase : public HeaderFooterTest +{ +protected: + OUString getHFText(const uno::Reference<style::XStyle>& xPageStyle, const OUString& sPropName) + { + auto xTextRange = getProperty<uno::Reference<text::XTextRange>>(xPageStyle, sPropName); + return xTextRange->getString(); + } +}; + +CPPUNIT_TEST_FIXTURE(TestHFBase, testHFLinkToPrev) +{ + auto verify = [this]() { + uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles"); + + // get a page cursor + 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); + + // get LO page style for page 1, corresponding to docx section 1 first page + xCursor->jumpToFirstPage(); + OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + uno::Reference<style::XStyle> xPageStyle(xPageStyles->getByName(pageStyleName), + uno::UNO_QUERY); + // check page 1 header & footer text + CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), + getHFText(xPageStyle, "HeaderTextFirst")); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer for section 1 only"), + getHFText(xPageStyle, "FooterTextFirst")); + + // get LO page style for page 2, corresponding to docx section 1 + xCursor->jumpToPage(2); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + // check header & footer text + CPPUNIT_ASSERT_EQUAL(OUString("Even page header for section 1 only"), + getHFText(xPageStyle, "HeaderTextLeft")); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"), + getHFText(xPageStyle, "FooterTextLeft")); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"), + getHFText(xPageStyle, "HeaderText")); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for section 1 only"), + getHFText(xPageStyle, "FooterText")); + + // get LO page style for page 4, corresponding to docx section 2 first page + xCursor->jumpToPage(4); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + // check header & footer text + CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), + getHFText(xPageStyle, "HeaderTextFirst")); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer for sections 2 and 3 only"), + getHFText(xPageStyle, "FooterTextFirst")); + + // get LO page style for page 5, corresponding to docx section 2 + xCursor->jumpToPage(5); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + // check header & footer text + CPPUNIT_ASSERT_EQUAL(OUString("Even page header for sections 2 and 3 only"), + getHFText(xPageStyle, "HeaderTextLeft")); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"), + getHFText(xPageStyle, "FooterTextLeft")); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"), + getHFText(xPageStyle, "HeaderText")); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for sections 2 and 3 only"), + getHFText(xPageStyle, "FooterText")); + + // get LO page style for page 7, corresponding to docx section 3 first page + xCursor->jumpToPage(7); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + // check header & footer text + CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), + getHFText(xPageStyle, "HeaderTextFirst")); + CPPUNIT_ASSERT_EQUAL(OUString("First page footer for sections 2 and 3 only"), + getHFText(xPageStyle, "FooterTextFirst")); + + // get LO page style for page 8, corresponding to docx section 3 + xCursor->jumpToPage(8); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); + // check header & footer text + CPPUNIT_ASSERT_EQUAL(OUString("Even page header for sections 2 and 3 only"), + getHFText(xPageStyle, "HeaderTextLeft")); + CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"), + getHFText(xPageStyle, "FooterTextLeft")); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"), + getHFText(xPageStyle, "HeaderText")); + CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for sections 2 and 3 only"), + getHFText(xPageStyle, "FooterText")); + }; + createSwDoc("headerfooter-link-to-prev.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testN750935) +{ + auto verify = [this]() { + // Some page break types were ignores, resulting in less pages. + CPPUNIT_ASSERT_EQUAL(5, getPages()); + + // The problem was that the header and footer was not shared. + // xray ThisComponent.StyleFamilies.PageStyles.Default.FooterIsShared + uno::Reference<beans::XPropertySet> xPropertySet( + getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + bool bValue = false; + xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue; + CPPUNIT_ASSERT_EQUAL(true, bValue); + xPropertySet->getPropertyValue("FooterIsShared") >>= bValue; + CPPUNIT_ASSERT_EQUAL(true, bValue); + }; + createSwDoc("n750935.docx"); + verify(); + saveAndReload("Office Open XML Text"); + verify(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testOnlyLeftPageStyle) +{ + createSwDoc("TestPageStyleOnlyLeft.docx"); + saveAndReload("Office Open XML Text"); + // There should be 2 pages - first page should be blank + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testMsoPosition) +{ + auto verifyFooter = [this]() { + xmlDocUniquePtr doc = parseExport("word/footer1.xml"); + // We write the frames out in different order than they were read, so check it's the correct + // textbox first by checking width. These tests may need reordering if that gets fixed. + OUString style1 + = getXPath(doc, "/w:ftr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, + "style"_ostr); + CPPUNIT_ASSERT(style1.indexOf(";width:531pt;") >= 0); + CPPUNIT_ASSERT(style1.indexOf(";mso-position-vertical-relative:page") >= 0); + CPPUNIT_ASSERT(style1.indexOf(";mso-position-horizontal-relative:page") >= 0); + OUString style2 + = getXPath(doc, "/w:ftr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, + "style"_ostr); + CPPUNIT_ASSERT(style2.indexOf(";width:549pt;") >= 0); + CPPUNIT_ASSERT(style2.indexOf(";mso-position-vertical-relative:text") >= 0); + CPPUNIT_ASSERT(style2.indexOf(";mso-position-horizontal:center") >= 0); + CPPUNIT_ASSERT(style2.indexOf(";mso-position-horizontal-relative:text") >= 0); + OUString style3 + = getXPath(doc, "/w:ftr/w:p/w:r[5]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, + "style"_ostr); + CPPUNIT_ASSERT(style3.indexOf(";width:36pt;") >= 0); + CPPUNIT_ASSERT(style3.indexOf(";mso-position-horizontal-relative:text") >= 0); + CPPUNIT_ASSERT(style3.indexOf(";mso-position-vertical-relative:text") >= 0); + }; + + auto verifyHeader = [this]() { + xmlDocUniquePtr doc = parseExport("word/header1.xml"); + OUString style1 + = getXPath(doc, "/w:hdr/w:p/w:r[2]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, + "style"_ostr); + CPPUNIT_ASSERT(style1.indexOf(";width:335.75pt;") >= 0); + CPPUNIT_ASSERT(style1.indexOf(";mso-position-horizontal-relative:page") >= 0); + CPPUNIT_ASSERT(style1.indexOf(";mso-position-vertical-relative:page") >= 0); + OUString style2 + = getXPath(doc, "/w:hdr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, + "style"_ostr); + CPPUNIT_ASSERT(style2.indexOf(";width:138.15pt;") >= 0); + CPPUNIT_ASSERT(style2.indexOf(";mso-position-horizontal-relative:page") >= 0); + CPPUNIT_ASSERT(style2.indexOf(";mso-position-vertical-relative:page") >= 0); + OUString style3 + = getXPath(doc, "/w:hdr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, + "style"_ostr); + CPPUNIT_ASSERT(style3.indexOf(";width:163.8pt;") >= 0); + CPPUNIT_ASSERT(style3.indexOf(";mso-position-horizontal-relative:page") >= 0); + CPPUNIT_ASSERT(style3.indexOf(";mso-position-vertical-relative:page") >= 0); + }; + + createSwDoc("bnc884615-mso-position.docx"); + saveAndReload("Office Open XML Text"); + verifyHeader(); + verifyFooter(); +} + +void HeaderFooterTest::checkParagraph(sal_Int32 nNumber, OUString const& rParagraphString, + OUString const& rConnectedPageStyle) +{ + uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(nNumber), uno::UNO_QUERY); + + uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(rParagraphString, xTextRange->getString()); + + OUString pageStyle; + xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; + CPPUNIT_ASSERT_EQUAL(rConnectedPageStyle, pageStyle); +} + +void HeaderFooterTest::checkFirstRestHeaderPageStyles() +{ + // Page 1 + checkParagraph(1, "P1", "Standard"); + + // Page 2 + checkParagraph(2, "P2", "Standard"); + + // Page 3 + checkParagraph(3, "P3", "Standard"); + + // Check Default Style + { + uno::Reference<beans::XPropertySet> xPageStyle( + getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + + bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bHeader); + + bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared"); + CPPUNIT_ASSERT_EQUAL(true, bHeaderIsShared); + + bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bFirstIsShared); + + auto xHeaderTextFirst + = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("FIRST"), xHeaderTextFirst->getString()); + + auto xHeaderText = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("NON-FIRST"), xHeaderText->getString()); + } +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstRestHeaderPageStyles_ODF) +{ + createSwDoc("SimpleFirst.odt"); + checkFirstRestHeaderPageStyles(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstRestHeaderPageStyles_OOXML) +{ + //createSwDoc("SimpleFirst.docx"); + //checkFirstRestHeaderPageStyles(); +} + +void HeaderFooterTest::checkLeftRightHeaderPageStyles() +{ + // Page 1 + checkParagraph(1, "P1", "Standard"); + + // Page 2 + checkParagraph(2, "P2", "Standard"); + + // Page 3 + checkParagraph(3, "P3", "Standard"); + + // Page 4 + checkParagraph(4, "P4", "Standard"); + + // Check Default Style + { + uno::Reference<beans::XPropertySet> xPageStyle( + getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + + bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bHeader); + + bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bHeaderIsShared); + + bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared"); + CPPUNIT_ASSERT_EQUAL(true, bFirstIsShared); + + auto xHeaderTextLeft + = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("LEFT"), xHeaderTextLeft->getString()); + + auto xHeaderTextRight + = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextRight"); + CPPUNIT_ASSERT_EQUAL(OUString("RIGHT"), xHeaderTextRight->getString()); + } +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testLeftRightHeaderPageStyles_ODF) +{ + createSwDoc("SimpleLeftRight.odt"); + checkLeftRightHeaderPageStyles(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testLeftRightHeaderPageStyles_OOXML) +{ + //createSwDoc("SimpleLeftRight.docx"); + //checkLeftRightHeaderPageStyles(); +} + +void HeaderFooterTest::checkFirstLeftRightHeaderPageStyles() +{ + // Page 1 + checkParagraph(1, "Para 1", "Standard"); + + // Page 2 + checkParagraph(2, "Para 2", "Standard"); + + // Page 3 + checkParagraph(3, "Para 3", "Standard"); + + // Page 4 + checkParagraph(4, "Para 4", "Standard"); + + // Page 5 + checkParagraph(5, "Para 5", "Standard"); + + // Check Default Style + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + + bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bHeader); + + bool bFooter = getProperty<bool>(xPageStyle, "FooterIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bFooter); + + bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bHeaderIsShared); + + bool bFooterIsShared = getProperty<bool>(xPageStyle, "FooterIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bFooterIsShared); + + bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bFirstIsShared); + + auto xHeaderTextFirst = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("FIRST HEADER"), xHeaderTextFirst->getString()); + + auto xHeaderTextLeft = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("LEFT HEADER"), xHeaderTextLeft->getString()); + + auto xHeaderTextRight = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("RIGHT HEADER"), xHeaderTextRight->getString()); + + auto xFooterTextFirst = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("FIRST FOOTER"), xFooterTextFirst->getString()); + + auto xFooterTextLeft = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("LEFT FOOTER"), xFooterTextLeft->getString()); + + auto xFooterTextRight = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterText"); + CPPUNIT_ASSERT_EQUAL(OUString("RIGHT FOOTER"), xFooterTextRight->getString()); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstLeftRightHeaderPageStyles_ODF) +{ + createSwDoc("SimpleFirstLeftRight.odt"); + checkFirstLeftRightHeaderPageStyles(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstLeftRightHeaderPageStyles_OOXML) +{ + //createSwDoc("SimpleFirstLeftRight.docx"); + //checkFirstLeftRightHeaderPageStyles(); +} + +void HeaderFooterTest::checkDoubleFirstLeftRightHeaderPageStyles( + OUString const& rCustomPageStyleName) +{ + // Page 1 + checkParagraph(1, "Para 1 - Default", "Standard"); + + // Page 2 + checkParagraph(2, "Para 2 - Default", "Standard"); + + // Page 3 + checkParagraph(3, "Para 3 - Default", "Standard"); + + // Page 4 + checkParagraph(4, "Para 4 - Custom", rCustomPageStyleName); + + // Page 5 + checkParagraph(5, "Para 5 - Custom", rCustomPageStyleName); + + // Page 6 + checkParagraph(6, "Para 6 - Custom", rCustomPageStyleName); + + // Check Default Style + { + uno::Reference<beans::XPropertySet> xPageStyle( + getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + + bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bHeader); + + bool bFooter = getProperty<bool>(xPageStyle, "FooterIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bFooter); + + bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bHeaderIsShared); + + bool bFooterIsShared = getProperty<bool>(xPageStyle, "FooterIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bFooterIsShared); + + bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bFirstIsShared); + + auto xHeaderTextFirst + = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("FIRST HEADER"), xHeaderTextFirst->getString()); + + auto xHeaderTextLeft + = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("LEFT HEADER"), xHeaderTextLeft->getString()); + + auto xHeaderTextRight = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("RIGHT HEADER"), xHeaderTextRight->getString()); + + auto xFooterTextFirst + = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("FIRST FOOTER"), xFooterTextFirst->getString()); + + auto xFooterTextLeft + = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("LEFT FOOTER"), xFooterTextLeft->getString()); + + auto xFooterTextRight = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterText"); + CPPUNIT_ASSERT_EQUAL(OUString("RIGHT FOOTER"), xFooterTextRight->getString()); + } + + { + uno::Reference<beans::XPropertySet> xPageStyle( + getStyles("PageStyles")->getByName(rCustomPageStyleName), uno::UNO_QUERY); + + bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bHeader); + + bool bFooter = getProperty<bool>(xPageStyle, "FooterIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bFooter); + + bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bHeaderIsShared); + + bool bFooterIsShared = getProperty<bool>(xPageStyle, "FooterIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bFooterIsShared); + + bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bFirstIsShared); + + auto xHeaderTextFirst + = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("FIRST HEADER - CUSTOM"), xHeaderTextFirst->getString()); + + auto xHeaderTextLeft + = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("LEFT HEADER - CUSTOM"), xHeaderTextLeft->getString()); + + auto xHeaderTextRight = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("RIGHT HEADER - CUSTOM"), xHeaderTextRight->getString()); + + auto xFooterTextFirst + = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextFirst"); + CPPUNIT_ASSERT_EQUAL(OUString("FIRST FOOTER - CUSTOM"), xFooterTextFirst->getString()); + + auto xFooterTextLeft + = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft"); + CPPUNIT_ASSERT_EQUAL(OUString("LEFT FOOTER - CUSTOM"), xFooterTextLeft->getString()); + + auto xFooterTextRight = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterText"); + CPPUNIT_ASSERT_EQUAL(OUString("RIGHT FOOTER - CUSTOM"), xFooterTextRight->getString()); + } +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testDoubleFirstLeftRightHeaderPageStyles_ODF) +{ + createSwDoc("DoubleFirstLeftRight.odt"); + checkDoubleFirstLeftRightHeaderPageStyles("Custom Page Style"); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testDoubleFirstLeftRightHeaderPageStyles_OOXML) +{ + //createSwDoc("DoubleFirstLeftRight.docx"); + //checkDoubleFirstLeftRightHeaderPageStyles("Converted1"); +} + +void HeaderFooterTest::checkShapeInFirstPageHeader() +{ + // Check Default Style + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), + uno::UNO_QUERY); + + bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT_EQUAL(true, bHeader); + + bool bFooter = getProperty<bool>(xPageStyle, "FooterIsOn"); + CPPUNIT_ASSERT_EQUAL(false, bFooter); + + bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared"); + CPPUNIT_ASSERT_EQUAL(true, bHeaderIsShared); + + bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared"); + CPPUNIT_ASSERT_EQUAL(false, bFirstIsShared); + + // Check shape is anchored to paragraph belonging to XText from "HeaderTextFirst" property + auto xHeaderTextFirst = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextFirst"); + CPPUNIT_ASSERT(xHeaderTextFirst.is()); + + uno::Reference<text::XTextContent> xShapeText(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapeText.is()); + uno::Reference<text::XTextRange> xAnchor = xShapeText->getAnchor(); + CPPUNIT_ASSERT(xAnchor.is()); + + CPPUNIT_ASSERT_EQUAL(xHeaderTextFirst, xAnchor->getText()); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstPageHeaderShape_ODF) +{ + createSwDoc("FirstPageHeaderShape.odt"); + checkShapeInFirstPageHeader(); +} + +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstPageHeaderShape_OOXML) +{ + //createSwDoc("FirstPageHeaderShape.docx"); + //checkShapeInFirstPageHeader(); +} + +} // end anonymous namespace + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/header_footer/data/DoubleFirstLeftRight.docx b/sw/qa/core/header_footer/data/DoubleFirstLeftRight.docx Binary files differnew file mode 100644 index 000000000000..307567507d2e --- /dev/null +++ b/sw/qa/core/header_footer/data/DoubleFirstLeftRight.docx diff --git a/sw/qa/core/header_footer/data/DoubleFirstLeftRight.odt b/sw/qa/core/header_footer/data/DoubleFirstLeftRight.odt Binary files differnew file mode 100644 index 000000000000..3bef1c87b655 --- /dev/null +++ b/sw/qa/core/header_footer/data/DoubleFirstLeftRight.odt diff --git a/sw/qa/core/header_footer/data/FirstPageHeaderShape.docx b/sw/qa/core/header_footer/data/FirstPageHeaderShape.docx Binary files differnew file mode 100644 index 000000000000..baed4b215ec1 --- /dev/null +++ b/sw/qa/core/header_footer/data/FirstPageHeaderShape.docx diff --git a/sw/qa/core/header_footer/data/FirstPageHeaderShape.odt b/sw/qa/core/header_footer/data/FirstPageHeaderShape.odt Binary files differnew file mode 100644 index 000000000000..7053423d000d --- /dev/null +++ b/sw/qa/core/header_footer/data/FirstPageHeaderShape.odt diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx b/sw/qa/core/header_footer/data/SimpleFirst.docx Binary files differindex 1641a2d084ed..1641a2d084ed 100644 --- a/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx +++ b/sw/qa/core/header_footer/data/SimpleFirst.docx diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt b/sw/qa/core/header_footer/data/SimpleFirst.odt Binary files differindex fc165e966f85..fc165e966f85 100644 --- a/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt +++ b/sw/qa/core/header_footer/data/SimpleFirst.odt diff --git a/sw/qa/core/header_footer/data/SimpleFirstLeftRight.docx b/sw/qa/core/header_footer/data/SimpleFirstLeftRight.docx Binary files differnew file mode 100644 index 000000000000..d0a8ed02e868 --- /dev/null +++ b/sw/qa/core/header_footer/data/SimpleFirstLeftRight.docx diff --git a/sw/qa/core/header_footer/data/SimpleFirstLeftRight.odt b/sw/qa/core/header_footer/data/SimpleFirstLeftRight.odt Binary files differnew file mode 100644 index 000000000000..a16cc922fc9f --- /dev/null +++ b/sw/qa/core/header_footer/data/SimpleFirstLeftRight.odt diff --git a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx b/sw/qa/core/header_footer/data/SimpleLeftRight.docx Binary files differindex 80dbda0420d7..80dbda0420d7 100644 --- a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx +++ b/sw/qa/core/header_footer/data/SimpleLeftRight.docx diff --git a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt b/sw/qa/core/header_footer/data/SimpleLeftRight.odt Binary files differindex 61302944da30..61302944da30 100644 --- a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt +++ b/sw/qa/core/header_footer/data/SimpleLeftRight.odt diff --git a/sw/qa/core/header_footer/data/TestFirstFooterDisabled.docx b/sw/qa/core/header_footer/data/TestFirstFooterDisabled.docx Binary files differnew file mode 100644 index 000000000000..2fe9a176689b --- /dev/null +++ b/sw/qa/core/header_footer/data/TestFirstFooterDisabled.docx diff --git a/sw/qa/core/header_footer/data/TestPageStyleOnlyLeft.docx b/sw/qa/core/header_footer/data/TestPageStyleOnlyLeft.docx Binary files differnew file mode 100644 index 000000000000..4714b8e27f87 --- /dev/null +++ b/sw/qa/core/header_footer/data/TestPageStyleOnlyLeft.docx diff --git a/sw/qa/extras/ooxmlexport/data/bnc519228_odd-breaksB.docx b/sw/qa/core/header_footer/data/bnc519228_odd-breaksB.docx Binary files differindex 674d71401110..674d71401110 100644 --- a/sw/qa/extras/ooxmlexport/data/bnc519228_odd-breaksB.docx +++ b/sw/qa/core/header_footer/data/bnc519228_odd-breaksB.docx diff --git a/sw/qa/extras/ooxmlexport/data/bnc875718.docx b/sw/qa/core/header_footer/data/bnc875718.docx Binary files differindex 878a46fdf912..878a46fdf912 100644 --- a/sw/qa/extras/ooxmlexport/data/bnc875718.docx +++ b/sw/qa/core/header_footer/data/bnc875718.docx diff --git a/sw/qa/extras/ooxmlexport/data/bnc884615-mso-position.docx b/sw/qa/core/header_footer/data/bnc884615-mso-position.docx Binary files differindex 2fb28ecfb3fd..2fb28ecfb3fd 100644 --- a/sw/qa/extras/ooxmlexport/data/bnc884615-mso-position.docx +++ b/sw/qa/core/header_footer/data/bnc884615-mso-position.docx diff --git a/sw/qa/extras/ooxmlexport/data/cont-sect-break-header-footer.docx b/sw/qa/core/header_footer/data/cont-sect-break-header-footer.docx Binary files differindex 61c18298d083..61c18298d083 100644 --- a/sw/qa/extras/ooxmlexport/data/cont-sect-break-header-footer.docx +++ b/sw/qa/core/header_footer/data/cont-sect-break-header-footer.docx diff --git a/sw/qa/extras/ooxmlexport/data/fdo64238_a.docx b/sw/qa/core/header_footer/data/fdo64238_a.docx Binary files differindex 7c43feaf75a7..7c43feaf75a7 100644 --- a/sw/qa/extras/ooxmlexport/data/fdo64238_a.docx +++ b/sw/qa/core/header_footer/data/fdo64238_a.docx diff --git a/sw/qa/extras/ooxmlexport/data/fdo64238_b.docx b/sw/qa/core/header_footer/data/fdo64238_b.docx Binary files differindex bfaf92cca2fc..bfaf92cca2fc 100644 --- a/sw/qa/extras/ooxmlexport/data/fdo64238_b.docx +++ b/sw/qa/core/header_footer/data/fdo64238_b.docx diff --git a/sw/qa/extras/ooxmlexport/data/fdo65655.docx b/sw/qa/core/header_footer/data/fdo65655.docx Binary files differindex 5fe9451bb091..5fe9451bb091 100644 --- a/sw/qa/extras/ooxmlexport/data/fdo65655.docx +++ b/sw/qa/core/header_footer/data/fdo65655.docx diff --git a/sw/qa/extras/ooxmlexport/data/fdo66145.docx b/sw/qa/core/header_footer/data/fdo66145.docx Binary files differindex 62ffdbe22e98..62ffdbe22e98 100644 --- a/sw/qa/extras/ooxmlexport/data/fdo66145.docx +++ b/sw/qa/core/header_footer/data/fdo66145.docx diff --git a/sw/qa/extras/ww8export/data/first-header-footer.doc b/sw/qa/core/header_footer/data/first-header-footer.doc Binary files differindex 023c494862a5..023c494862a5 100644 --- a/sw/qa/extras/ww8export/data/first-header-footer.doc +++ b/sw/qa/core/header_footer/data/first-header-footer.doc diff --git a/sw/qa/extras/ooxmlexport/data/first-header-footer.docx b/sw/qa/core/header_footer/data/first-header-footer.docx Binary files differindex d18eea5866b5..d18eea5866b5 100644 --- a/sw/qa/extras/ooxmlexport/data/first-header-footer.docx +++ b/sw/qa/core/header_footer/data/first-header-footer.docx diff --git a/sw/qa/extras/odfexport/data/first-header-footer.odt b/sw/qa/core/header_footer/data/first-header-footer.odt Binary files differindex 2ed6b740a102..2ed6b740a102 100644 --- a/sw/qa/extras/odfexport/data/first-header-footer.odt +++ b/sw/qa/core/header_footer/data/first-header-footer.odt diff --git a/sw/qa/extras/ooxmlexport/data/first-header-footerB.odt b/sw/qa/core/header_footer/data/first-header-footerB.odt Binary files differindex 0ae1992ed7e1..0ae1992ed7e1 100644 --- a/sw/qa/extras/ooxmlexport/data/first-header-footerB.odt +++ b/sw/qa/core/header_footer/data/first-header-footerB.odt diff --git a/sw/qa/extras/ooxmlexport/data/headerfooter-link-to-prev.docx b/sw/qa/core/header_footer/data/headerfooter-link-to-prev.docx Binary files differindex cc4ddc89bb9b..cc4ddc89bb9b 100644 --- a/sw/qa/extras/ooxmlexport/data/headerfooter-link-to-prev.docx +++ b/sw/qa/core/header_footer/data/headerfooter-link-to-prev.docx diff --git a/sw/qa/extras/ooxmlexport/data/n750935.docx b/sw/qa/core/header_footer/data/n750935.docx Binary files differindex 0dd01592dd65..0dd01592dd65 100644 --- a/sw/qa/extras/ooxmlexport/data/n750935.docx +++ b/sw/qa/core/header_footer/data/n750935.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf112694.docx b/sw/qa/core/header_footer/data/tdf112694.docx Binary files differindex f629a388e3cb..f629a388e3cb 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf112694.docx +++ b/sw/qa/core/header_footer/data/tdf112694.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt b/sw/qa/core/header_footer/data/tdf113849_evenAndOddHeaders.odt Binary files differindex d9aa0ae23541..d9aa0ae23541 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf113849_evenAndOddHeaders.odt +++ b/sw/qa/core/header_footer/data/tdf113849_evenAndOddHeaders.odt diff --git a/sw/qa/extras/odfexport/data/tdf118393.odt b/sw/qa/core/header_footer/data/tdf118393.odt Binary files differindex ff8d5400950b..ff8d5400950b 100644 --- a/sw/qa/extras/odfexport/data/tdf118393.odt +++ b/sw/qa/core/header_footer/data/tdf118393.odt diff --git a/sw/qa/extras/ooxmlimport/data/tdf127778.docx b/sw/qa/core/header_footer/data/tdf127778.docx Binary files differindex a706d575763f..a706d575763f 100644 --- a/sw/qa/extras/ooxmlimport/data/tdf127778.docx +++ b/sw/qa/core/header_footer/data/tdf127778.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf129582.docx b/sw/qa/core/header_footer/data/tdf129582.docx Binary files differindex d160262ae745..d160262ae745 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf129582.docx +++ b/sw/qa/core/header_footer/data/tdf129582.docx diff --git a/sw/qa/core/header_footer/data/tdf135216_evenOddFooter.docx b/sw/qa/core/header_footer/data/tdf135216_evenOddFooter.docx Binary files differnew file mode 100644 index 000000000000..05840f984827 --- /dev/null +++ b/sw/qa/core/header_footer/data/tdf135216_evenOddFooter.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf135216_evenOddFooter.odt b/sw/qa/core/header_footer/data/tdf135216_evenOddFooter.odt Binary files differindex ab0ac591e29a..ab0ac591e29a 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf135216_evenOddFooter.odt +++ b/sw/qa/core/header_footer/data/tdf135216_evenOddFooter.odt diff --git a/sw/qa/extras/ooxmlexport/data/tdf145998_firstHeader.odt b/sw/qa/core/header_footer/data/tdf145998_firstHeader.odt Binary files differindex ad5e4c3e0320..ad5e4c3e0320 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf145998_firstHeader.odt +++ b/sw/qa/core/header_footer/data/tdf145998_firstHeader.odt diff --git a/sw/qa/extras/ooxmlexport/data/tdf57155.docx b/sw/qa/core/header_footer/data/tdf57155.docx Binary files differindex 5cca9b3ea9a2..5cca9b3ea9a2 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf57155.docx +++ b/sw/qa/core/header_footer/data/tdf57155.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf69635.docx b/sw/qa/core/header_footer/data/tdf69635.docx Binary files differindex 94cced4d2ae4..94cced4d2ae4 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf69635.docx +++ b/sw/qa/core/header_footer/data/tdf69635.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf79639.docx b/sw/qa/core/header_footer/data/tdf79639.docx Binary files differindex b84aaea70389..b84aaea70389 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf79639.docx +++ b/sw/qa/core/header_footer/data/tdf79639.docx diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index c8ff08965f93..51cfa15b7bcc 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -758,26 +758,6 @@ DECLARE_ODFEXPORT_TEST(testFdo79358, "fdo79358.odt") CPPUNIT_ASSERT_EQUAL(uno::Any(uno::Sequence<OUString>()), xLevels->getByIndex(2)); } -DECLARE_ODFEXPORT_TEST(testFirstHeaderFooter, "first-header-footer.odt") -{ - CPPUNIT_ASSERT_EQUAL(6, getPages()); - // Test import and export of the header-first token. - - // The document has 6 pages, two page styles for the first and second half of pages. - CPPUNIT_ASSERT_EQUAL(OUString("First header"), parseDump("/root/page[1]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First footer"), parseDump("/root/page[1]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Left header"), parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Left footer"), parseDump("/root/page[2]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Right header"), parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Right footer"), parseDump("/root/page[3]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First header2"), parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First footer2"), parseDump("/root/page[4]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Right header2"), parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Right footer2"), parseDump("/root/page[5]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Left header2"), parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Left footer2"), parseDump("/root/page[6]/footer/txt/text()"_ostr)); -} - DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt") { CPPUNIT_ASSERT_EQUAL(2, getShapes()); @@ -1874,47 +1854,6 @@ DECLARE_ODFEXPORT_TEST(testFdo86963, "fdo86963.odt") CPPUNIT_ASSERT_EQUAL(1, getShapes()); } -// 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 - { - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // check first page - assertXPath(pXmlDoc, "/root/page[1]/header"_ostr, 0); - assertXPath(pXmlDoc, "/root/page[1]/footer"_ostr, 0); - - // check second page in the same way - assertXPath(pXmlDoc, "/root/page[2]/header"_ostr); - assertXPath(pXmlDoc, "/root/page[2]/footer"_ostr); - } - - // All other pages should have header/footer - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/footer/txt/text()"_ostr)); -} - DECLARE_ODFEXPORT_TEST(testTdf135338_firstLeftPageFooter, "tdf135338_firstLeftPageFooter.odt") { CPPUNIT_ASSERT_EQUAL(6, getPages()); diff --git a/sw/qa/extras/ooxmlexport/data/tdf118393.odt b/sw/qa/extras/ooxmlexport/data/tdf118393.odt Binary files differdeleted file mode 100644 index ff8d5400950b..000000000000 --- a/sw/qa/extras/ooxmlexport/data/tdf118393.odt +++ /dev/null diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 1d66a55b331d..6293b6c44d03 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -63,48 +63,6 @@ CPPUNIT_TEST_FIXTURE(Test, testFooterBodyDistance) assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br"_ostr, 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") -CPPUNIT_TEST_FIXTURE(Test, testTdf118393) -{ - loadAndReload("tdf118393.odt"); - CPPUNIT_ASSERT_EQUAL( 7, getPages() ); - - // First page has no header/footer - { - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // check first page - assertXPath(pXmlDoc, "/root/page[1]/header"_ostr, 0); - assertXPath(pXmlDoc, "/root/page[1]/footer"_ostr, 0); - - // check second page in the same way - assertXPath(pXmlDoc, "/root/page[2]/header"_ostr); - assertXPath(pXmlDoc, "/root/page[2]/footer"_ostr); - } - - // All other pages should have header/footer - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[2]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[3]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[4]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[5]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[6]/footer/txt/text()"_ostr)); - - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/footer/txt/text()"_ostr)); -} - DECLARE_OOXMLEXPORT_TEST(testfdo81031, "fdo81031.docx") { // vml image was not rendered @@ -170,48 +128,6 @@ CPPUNIT_TEST_FIXTURE(Test, testParaShading) assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:shd"_ostr, "themeColor"_ostr); } -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()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), parseDump("/root/page[1]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), parseDump("/root/page[2]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), parseDump("/root/page[3]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), parseDump("/root/page[6]/footer/txt/text()"_ostr)); -} - -CPPUNIT_TEST_FIXTURE(Test, testFirstHeaderFooterB) -{ - loadAndReload("first-header-footerB.odt"); - CPPUNIT_ASSERT_EQUAL( 6, getPages() ); - - CPPUNIT_ASSERT_EQUAL(OUString("First page header"), parseDump("/root/page[1]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), parseDump("/root/page[1]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), parseDump("/root/page[2]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), parseDump("/root/page[3]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), parseDump("/root/page[6]/footer/txt/text()"_ostr)); -} - CPPUNIT_TEST_FIXTURE(Test, testFDO83044) { loadAndSave("fdo83044.docx"); @@ -483,44 +399,6 @@ CPPUNIT_TEST_FIXTURE(Test, testRot270Flipv) assertXPath(pXmlDoc, "//a:xfrm"_ostr, "rot"_ostr, "16200000"); } -CPPUNIT_TEST_FIXTURE(Test, testMsoPosition) -{ - loadAndSave("bnc884615-mso-position.docx"); - { - xmlDocUniquePtr doc = parseExport("word/footer1.xml"); - // We write the frames out in different order than they were read, so check it's the correct - // textbox first by checking width. These tests may need reordering if that gets fixed. - OUString style1 = getXPath(doc, "/w:ftr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, "style"_ostr); - CPPUNIT_ASSERT( style1.indexOf( ";width:531pt;" ) >= 0 ); - CPPUNIT_ASSERT( style1.indexOf( ";mso-position-vertical-relative:page" ) >= 0 ); - CPPUNIT_ASSERT( style1.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 ); - OUString style2 = getXPath(doc, "/w:ftr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, "style"_ostr); - CPPUNIT_ASSERT( style2.indexOf( ";width:549pt;" ) >= 0 ); - CPPUNIT_ASSERT( style2.indexOf( ";mso-position-vertical-relative:text" ) >= 0 ); - CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal:center" ) >= 0 ); - CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal-relative:text" ) >= 0 ); - OUString style3 = getXPath(doc, "/w:ftr/w:p/w:r[5]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, "style"_ostr); - CPPUNIT_ASSERT( style3.indexOf( ";width:36pt;" ) >= 0 ); - CPPUNIT_ASSERT( style3.indexOf( ";mso-position-horizontal-relative:text" ) >= 0 ); - CPPUNIT_ASSERT( style3.indexOf( ";mso-position-vertical-relative:text" ) >= 0 ); - } - - xmlDocUniquePtr doc = parseExport("word/header1.xml"); - OUString style1 = getXPath(doc, "/w:hdr/w:p/w:r[2]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, "style"_ostr); - CPPUNIT_ASSERT( style1.indexOf( ";width:335.75pt;" ) >= 0 ); - CPPUNIT_ASSERT( style1.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 ); - CPPUNIT_ASSERT( style1.indexOf( ";mso-position-vertical-relative:page" ) >= 0 ); - OUString style2 = getXPath(doc, "/w:hdr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, "style"_ostr); - CPPUNIT_ASSERT( style2.indexOf( ";width:138.15pt;" ) >= 0 ); - CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 ); - CPPUNIT_ASSERT( style2.indexOf( ";mso-position-vertical-relative:page" ) >= 0 ); - OUString style3 = getXPath(doc, "/w:hdr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect"_ostr, "style"_ostr); - CPPUNIT_ASSERT( style3.indexOf( ";width:163.8pt;" ) >= 0 ); - CPPUNIT_ASSERT( style3.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 ); - CPPUNIT_ASSERT( style3.indexOf( ";mso-position-vertical-relative:page" ) >= 0 ); - -} - DECLARE_OOXMLEXPORT_TEST(testWpsCharColor, "wps-char-color.docx") { uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); @@ -935,13 +813,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf91261, "tdf91261.docx") bool bGridSnapToChars; xStyle->getPropertyValue("GridSnapToChars") >>= bGridSnapToChars; CPPUNIT_ASSERT_EQUAL(true, bGridSnapToChars); - -} - -DECLARE_OOXMLEXPORT_TEST(testTdf79639, "tdf79639.docx") -{ - // This was 0, floating table in header wasn't converted to a TextFrame. - CPPUNIT_ASSERT_EQUAL(1, getShapes()); } DECLARE_OOXMLEXPORT_TEST(testTdf89890, "tdf89890.docx") diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 3036f83e488e..8b12728daa57 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -706,32 +706,6 @@ DECLARE_OOXMLEXPORT_TEST(testFdo79535, "fdo79535.docx") CPPUNIT_ASSERT_EQUAL(1, getPages()); } -DECLARE_OOXMLEXPORT_TEST(testBnc875718, "bnc875718.docx") -{ - // The frame in the footer must not accidentally end up in the document body. - // The easiest way for this to test I've found is checking that - // xray ThisComponent.TextFrames.GetByIndex( index ).Anchor.Text.ImplementationName - // is not SwXBodyText but rather SwXHeadFootText - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); - // The sample bugdoc has 3 footer.xml and has a textframe in each. The first one is hidden - // and it has no text in its anchored text range: it is anchored to body text. Ignoring... - for( int i = 1; - i < xIndexAccess->getCount(); - ++i ) - { - uno::Reference<text::XTextFrame> frame(xIndexAccess->getByIndex( i ), uno::UNO_QUERY); - uno::Reference<text::XTextRange> range = frame->getAnchor(); - uno::Reference<lang::XServiceInfo> text(range->getText(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( OUString( "SwXHeadFootText" ), text->getImplementationName()); - } - // Also check that the footer contents are not in the body text. - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XText> text = textDocument->getText(); - CPPUNIT_ASSERT(text); //Do not crash on empty content - CPPUNIT_ASSERT_EQUAL( OUString( "Text" ), text->getString()); -} - DECLARE_OOXMLEXPORT_TEST(testCaption, "caption.docx") { uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Caption"), uno::UNO_QUERY); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index a4f01adaa7c2..f7df210641af 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -254,32 +254,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf76683_negativeTwipsMeasure) CPPUNIT_ASSERT( nColumn1 > nColumn2 ); } -DECLARE_OOXMLEXPORT_TEST(testTdf112694, "tdf112694.docx") -{ - uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard"); - // Header was on when header for file was for explicit first pages only - // (marked via <w:titlePg>). - CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn")); -} - -CPPUNIT_TEST_FIXTURE(Test, testTdf113849_evenAndOddHeaders) -{ - loadAndReload("tdf113849_evenAndOddHeaders.odt"); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Header2 text", OUString("L. J. Kendall"), parseDump("/root/page[2]/header/txt"_ostr)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer2 text", OUString("*"), parseDump("/root/page[2]/footer/txt"_ostr)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE("Header3 text", OUString("Shadow Hunt"), parseDump("/root/page[3]/header/txt"_ostr)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer3 text", OUString("*"), parseDump("/root/page[3]/footer/txt"_ostr)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE("Header4 text", OUString("L. J. Kendall"), parseDump("/root/page[4]/header/txt"_ostr)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer4 text", OUString("*"), parseDump("/root/page[4]/footer/txt"_ostr)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer5 text", OUString(""), parseDump("/root/page[5]/footer/txt"_ostr)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Footer6 text", OUString(""), parseDump("/root/page[6]/footer/txt"_ostr)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages", 6, getPages() ); -} - DECLARE_OOXMLEXPORT_TEST(testTdf118361_RTLfootnoteSeparator, "tdf118361_RTLfootnoteSeparator.docx") { uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 71aa3052bf6d..d9ef6b8a48d0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -1408,49 +1408,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf130088, "tdf130088.docx") CPPUNIT_ASSERT_EQUAL(1, getPages()); } -DECLARE_OOXMLEXPORT_TEST(testContSectBreakHeaderFooter, "cont-sect-break-header-footer.docx") -{ - // Load a document with a continuous section break on page 2. - CPPUNIT_ASSERT_EQUAL(OUString("First page header, section 1"), - parseDump("/root/page[1]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer, section 1"), - parseDump("/root/page[1]/footer/txt/text()"_ostr)); - // Make sure the header stays like this; if we naively just update the page style name of the - // first para on page 2, then this would be 'Header, section 2', which is incorrect. - CPPUNIT_ASSERT_EQUAL(OUString("First page header, section 2"), - parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer, section 2"), - parseDump("/root/page[2]/footer/txt/text()"_ostr)); - // This is inherited from page 2. - CPPUNIT_ASSERT_EQUAL(OUString("Header, section 2"), - parseDump("/root/page[3]/header/txt/text()"_ostr)); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 1 - // - Actual : 0 - // - xpath should match exactly 1 node - // i.e. the footer had no text (inherited from page 2), while the correct behavior is to provide - // the own footer text. - CPPUNIT_ASSERT_EQUAL(OUString("Footer, section 3"), - parseDump("/root/page[3]/footer/txt/text()"_ostr)); - - // Without the export fix in place, the import-export-import test would have failed with: - // - Expected: Header, section 2 - // - Actual : First page header, section 2 - // i.e. both the header and the footer on page 3 was wrong. - - // Additional problem: top margin on page 3 was wrong. - if (isExported()) - { - xmlDocUniquePtr pXml = parseExport("word/document.xml"); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 2200 - // - Actual : 2574 - // i.e. the top margin on page 3 was too large and now matches the value from the input - // document. - assertXPath(pXml, "/w:document/w:body/w:sectPr/w:pgMar"_ostr, "top"_ostr, "2200"); - } -} - CPPUNIT_TEST_FIXTURE(Test, testHyphenationAuto) { loadAndReload("hyphenation.odt"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index 8b5359b37ec7..96e7e6bae029 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -505,51 +505,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf145998_unnecessaryPageStyles) CPPUNIT_ASSERT_EQUAL(OUString(), parseDump("/root/page[5]/footer/txt"_ostr)); } -CPPUNIT_TEST_FIXTURE(Test, testTdf145998_firstHeader) -{ - loadAndReload("tdf145998_firstHeader.odt"); - - // Sanity check - always good to test when dealing with page styles and breaks. - CPPUNIT_ASSERT_EQUAL(2, getPages()); - - CPPUNIT_ASSERT_EQUAL(OUString("Very first header"), parseDump("/root/page[1]/header/txt"_ostr)); - - // Page Style is already used in prior section - this can't be the first-header - CPPUNIT_ASSERT_EQUAL(OUString("Normal Header"), parseDump("/root/page[2]/header/txt"_ostr)); -} - -CPPUNIT_TEST_FIXTURE(Test, testTdf135216_evenOddFooter) -{ - loadAndReload("tdf135216_evenOddFooter.odt"); - 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); - - // get LO page style for the first page (even page #2) - OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles"); - uno::Reference<style::XStyle> xPageStyle(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); - - xCursor->jumpToFirstPage(); // Even/Left page #2 - uno::Reference<text::XText> xFooter = getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft"); - CPPUNIT_ASSERT_EQUAL(OUString("even page"), xFooter->getString()); - - xCursor->jumpToNextPage(); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); - xFooter.set(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextFirst")); - CPPUNIT_ASSERT_EQUAL(OUString("odd page - first footer"), xFooter->getString()); - - xCursor->jumpToNextPage(); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - xPageStyle.set(xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); - xFooter.set(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextLeft")); - CPPUNIT_ASSERT_EQUAL(OUString("even page"), xFooter->getString()); - - // The contents of paragraph 2 should be the page number (2) located on page 1. - getParagraph(2, "2"); -} - CPPUNIT_TEST_FIXTURE(Test, testTdf136929_framesOfParagraph) { loadAndReload("tdf136929_framesOfParagraph.odt"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 6885f0b4b91a..f7e62615e8a8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -478,23 +478,6 @@ CPPUNIT_TEST_FIXTURE(Test, testCustomShapePresetExport) CPPUNIT_ASSERT_EQUAL(17, nCount); } -CPPUNIT_TEST_FIXTURE(Test, testTdf69635) -{ - loadAndSave("tdf69635.docx"); - xmlDocUniquePtr pXmlHeader1 = parseExport("word/header1.xml"); - xmlDocUniquePtr pXmlSettings = parseExport("word/settings.xml"); - CPPUNIT_ASSERT(pXmlHeader1); - CPPUNIT_ASSERT(pXmlSettings); - - // Without the accompanying fix in place, this test would have failed with: - // - Expected: "left" - // - Actual : "right" - assertXPathContent(pXmlHeader1, "/w:hdr/w:p/w:r/w:t"_ostr, "left"); - - // Make sure "left" appears as a hidden header - assertXPath(pXmlSettings, "/w:settings/w:evenAndOddHeaders"_ostr, 0); -} - DECLARE_OOXMLEXPORT_TEST(testTdf148671, "tdf148671.docx") { // Don't assert with 'pFieldMark' failed when document is opened diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index de3d073d9900..6e27f9a6a1ab 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -712,20 +712,6 @@ DECLARE_OOXMLEXPORT_TEST(testFdo65265, "fdo65265.docx") CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph2, 2), "RedlineType")); } -DECLARE_OOXMLEXPORT_TEST(testFdo65655, "fdo65655.docx") -{ - // The problem was that the DOCX had a non-blank odd footer and a blank even footer - // The 'Different Odd & Even Pages' was turned on - // However - LO assumed that because the 'even' footer is blank - it should ignore the 'Different Odd & Even Pages' flag - // So it did not import it and did not export it - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - bool bValue = false; - xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue; - CPPUNIT_ASSERT_EQUAL(false, bValue); - xPropertySet->getPropertyValue("FooterIsShared") >>= bValue; - CPPUNIT_ASSERT_EQUAL(false, bValue); -} - DECLARE_OOXMLEXPORT_TEST(testFDO63053, "fdo63053.docx") { uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); @@ -813,46 +799,6 @@ DECLARE_OOXMLEXPORT_TEST(testFdo43093, "fdo43093.docx") CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); } -DECLARE_OOXMLEXPORT_TEST(testFdo64238_a, "fdo64238_a.docx") -{ - // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled* - // then LO would still import the Even footer and concatenate it to the odd footer. - // This case specifically is for : - // 'Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word - // In this case the imported footer in LO was supposed to be blank, but instead was the 'even' footer - uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Standard"), "FooterText"); - uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); - uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); - sal_Int32 numOfRuns = 0; - while (xRunEnum->hasMoreElements()) - { - xRunEnum->nextElement(); - numOfRuns++; - } - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), numOfRuns); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo64238_b, "fdo64238_b.docx") -{ - // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled* - // then LO would still import the Even footer and concatenate it to the odd footer. - // This case specifically is for : - // 'Non-Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word - // In this case the imported footer in LO was supposed to be just the odd footer, but instead was the 'odd' and 'even' footers concatenated - uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Standard"), "FooterText"); - uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); - uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); - sal_Int32 numOfRuns = 0; - while (xRunEnum->hasMoreElements()) - { - xRunEnum->nextElement(); - numOfRuns++; - } - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns); -} - DECLARE_OOXMLEXPORT_TEST(testFdo56679, "fdo56679.docx") { // The problem was that the DOCX importer and exporter did not handle the 'color' of an underline @@ -989,19 +935,6 @@ CPPUNIT_TEST_FIXTURE(Test, testPageBorderSpacingExportCase2) assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders/w:right"_ostr, "space"_ostr, "24"); } -DECLARE_OOXMLEXPORT_TEST(testFdo66145, "fdo66145.docx") -{ - // The Writer ignored the 'First Is Shared' flag - CPPUNIT_ASSERT_EQUAL(OUString("This is the FIRST page header."), - parseDump("/root/page[1]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL( - OUString("This is the header for the REST OF THE FILE."), - parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL( - OUString("This is the header for the REST OF THE FILE."), - parseDump("/root/page[3]/header/txt/text()"_ostr)); -} - CPPUNIT_TEST_FIXTURE(Test, testGrabBag) { loadAndSave("grabbag.docx"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 736b51886d90..85c4396cba0a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -152,20 +152,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf104539) "dir"_ostr, "13500000"); } -DECLARE_OOXMLEXPORT_TEST(testTdf57155, "tdf57155.docx") -{ - CPPUNIT_ASSERT_EQUAL(2, getPages()); - // Without the fix in place, the image in the header of page 2 wouldn't exist - CPPUNIT_ASSERT_EQUAL(4, getShapes()); -} - -DECLARE_OOXMLEXPORT_TEST(testTdf129582, "tdf129582.docx") -{ - CPPUNIT_ASSERT_EQUAL(2, getPages()); - // Without the fix in place, the image in the footer of page 2 wouldn't exist - CPPUNIT_ASSERT_EQUAL(2, getShapes()); -} - CPPUNIT_TEST_FIXTURE(Test, testShapeEffectPreservation) { loadAndSave("shape-effect-preservation.docx"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 2b9c87dd0dcc..bef8fa773328 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -63,24 +63,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf48569) CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, eValue); } -DECLARE_OOXMLEXPORT_TEST(testN750935, "n750935.docx") -{ - // Some page break types were ignores, resulting in less pages. - CPPUNIT_ASSERT_EQUAL(5, getPages()); - - /* - * The problem was that the header and footer was not shared. - * - * xray ThisComponent.StyleFamilies.PageStyles.Default.FooterIsShared - */ - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - bool bValue = false; - xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue; - CPPUNIT_ASSERT_EQUAL(true, bValue); - xPropertySet->getPropertyValue("FooterIsShared") >>= bValue; - CPPUNIT_ASSERT_EQUAL(true, bValue); -} - DECLARE_OOXMLEXPORT_TEST(testN751117, "n751117.docx") { // First shape: the end should be an arrow, should be rotated and should be flipped. diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 9886af42c6e7..ad3bba49df49 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -591,105 +591,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf98700_keepWithNext) CPPUNIT_ASSERT_EQUAL(OUString("Text body"), getProperty<OUString>(properties, "FollowStyle")); } -// base class to supply a helper method for testHFLinkToPrev -class testHFBase : public Test -{ -protected: - OUString - getHFText(const uno::Reference<style::XStyle>& xPageStyle, - const OUString &sPropName) - { - auto xTextRange = getProperty< uno::Reference<text::XTextRange> >( - xPageStyle, sPropName); - return xTextRange->getString(); - } -}; - -DECLARE_SW_EXPORT_TEST(testHFLinkToPrev, "headerfooter-link-to-prev.docx", nullptr, testHFBase) -{ - uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles"); - - // get a page cursor - 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); - - // get LO page style for page 1, corresponding to docx section 1 first page - xCursor->jumpToFirstPage(); - OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - uno::Reference<style::XStyle> xPageStyle( - xPageStyles->getByName(pageStyleName), uno::UNO_QUERY); - // check page 1 header & footer text - CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), - getHFText(xPageStyle, "HeaderTextFirst")); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer for section 1 only"), - getHFText(xPageStyle, "FooterTextFirst")); - - // get LO page style for page 2, corresponding to docx section 1 - xCursor->jumpToPage(2); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY ); - // check header & footer text - CPPUNIT_ASSERT_EQUAL(OUString("Even page header for section 1 only"), - getHFText(xPageStyle, "HeaderTextLeft")); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"), - getHFText(xPageStyle, "FooterTextLeft")); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"), - getHFText(xPageStyle, "HeaderText")); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for section 1 only"), - getHFText(xPageStyle, "FooterText")); - - // get LO page style for page 4, corresponding to docx section 2 first page - xCursor->jumpToPage(4); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY ); - // check header & footer text - CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), - getHFText(xPageStyle, "HeaderTextFirst")); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer for sections 2 and 3 only"), - getHFText(xPageStyle, "FooterTextFirst")); - - // get LO page style for page 5, corresponding to docx section 2 - xCursor->jumpToPage(5); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY ); - // check header & footer text - CPPUNIT_ASSERT_EQUAL(OUString("Even page header for sections 2 and 3 only"), - getHFText(xPageStyle, "HeaderTextLeft")); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"), - getHFText(xPageStyle, "FooterTextLeft")); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"), - getHFText(xPageStyle, "HeaderText")); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for sections 2 and 3 only"), - getHFText(xPageStyle, "FooterText")); - - // get LO page style for page 7, corresponding to docx section 3 first page - xCursor->jumpToPage(7); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY ); - // check header & footer text - CPPUNIT_ASSERT_EQUAL(OUString("First page header for all sections"), - getHFText(xPageStyle, "HeaderTextFirst")); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer for sections 2 and 3 only"), - getHFText(xPageStyle, "FooterTextFirst")); - - // get LO page style for page 8, corresponding to docx section 3 - xCursor->jumpToPage(8); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - xPageStyle.set( xPageStyles->getByName(pageStyleName), uno::UNO_QUERY ); - // check header & footer text - CPPUNIT_ASSERT_EQUAL(OUString("Even page header for sections 2 and 3 only"), - getHFText(xPageStyle, "HeaderTextLeft")); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer for all sections"), - getHFText(xPageStyle, "FooterTextLeft")); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header for all sections"), - getHFText(xPageStyle, "HeaderText")); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer for sections 2 and 3 only"), - getHFText(xPageStyle, "FooterText")); -} - DECLARE_OOXMLEXPORT_TEST(testRhbz988516, "rhbz988516.docx") { // The problem was that the list properties of the footer leaked into body @@ -845,34 +746,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106132, "tdf106132.docx") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xShape, "TextRightDistance")); } -DECLARE_OOXMLEXPORT_TEST(testBnc519228OddBreaks, "bnc519228_odd-breaksB.docx") -{ - // Check that all the normal styles are not set as right-only, those should be only those used after odd page breaks. - uno::Reference<beans::XPropertySet> defaultStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), defaultStyle->getPropertyValue("PageStyleLayout")); - uno::Reference<beans::XPropertySet> firstPage( getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY ); - CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), firstPage->getPropertyValue("PageStyleLayout")); - - OUString page1StyleName = getProperty<OUString>( getParagraph( 1, "This is the first page." ), "PageDescName"); - uno::Reference<beans::XPropertySet> page1Style(getStyles("PageStyles")->getByName(page1StyleName), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_RIGHT), page1Style->getPropertyValue("PageStyleLayout")); - getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page1Style, "HeaderText"), "This is the header for odd pages"); - - // Page2 comes from follow of style for page 1 and should be a normal page. Also check the two page style have the same properties, - // since page style for page1 was created from page style for page 2. - OUString page2StyleName = getProperty<OUString>( page1Style, "FollowStyle" ); - uno::Reference<beans::XPropertySet> page2Style(getStyles("PageStyles")->getByName(page2StyleName), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_ALL), page2Style->getPropertyValue("PageStyleLayout")); - getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page2Style, "HeaderTextLeft"), "This is the even header"); - getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page2Style, "HeaderTextRight"), "This is the header for odd pages"); - CPPUNIT_ASSERT_EQUAL(getProperty<sal_Int32>(page1Style, "TopMargin"), getProperty<sal_Int32>(page2Style, "TopMargin")); - - OUString page5StyleName = getProperty<OUString>( getParagraph( 4, "Then an odd break after an odd page, should lead us to page #5." ), "PageDescName"); - uno::Reference<beans::XPropertySet> page5Style(getStyles("PageStyles")->getByName(page5StyleName), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(uno::Any(style::PageStyleLayout_RIGHT), page5Style->getPropertyValue("PageStyleLayout")); - getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page5Style, "HeaderText"), "This is the header for odd pages"); -} - CPPUNIT_TEST_FIXTURE(Test, testTdf79329) { auto verify = [this]() { diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx Binary files differdeleted file mode 100644 index 2b530a5e324f..000000000000 --- a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx +++ /dev/null diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt Binary files differdeleted file mode 100644 index d5035ac8f581..000000000000 --- a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt +++ /dev/null diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 053f5334021e..ebc094803153 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -48,10 +48,6 @@ class Test : public SwModelTestBase { public: - void checkFirstLeftRightHeaderPageStyles(); - void checkFirstRestHeaderPageStyles(); - void checkLeftRightHeaderPageStyles(); - Test() : SwModelTestBase("/sw/qa/extras/ooxmlimport/data/", "Office Open XML Text") { @@ -530,18 +526,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf43017) getProperty<sal_Int32>(xText, "CharColor")); } -CPPUNIT_TEST_FIXTURE(Test, testTdf127778) -{ - createSwDoc("tdf127778.docx"); - xmlDocUniquePtr pLayout = parseLayoutDump(); - // Without the accompanying fix in place, this test would have failed with: - // equality assertion failed - // - Expected: 0 - // - Actual : 1 - // i.e. the 2nd page had an unexpected header. - assertXPath(pLayout, "//page[2]/header"_ostr, 0); -} - // related tdf#43017 CPPUNIT_TEST_FIXTURE(Test, testTdf124754) { @@ -1204,216 +1188,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141969) CPPUNIT_ASSERT_EQUAL(8.0f, getProperty<float>(xRun, "CharHeight")); } -void Test::checkFirstLeftRightHeaderPageStyles() -{ - // Page 1 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(1), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Para 1"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } - - // Page 2 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(2), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Para 2"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } - - // Page 3 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(3), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Para 3"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } -} - -void Test::checkFirstRestHeaderPageStyles() -{ - // Page 1 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(1), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("P1"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } - - // Page 2 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(2), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("P2"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } - - // Page 3 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(3), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("P3"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } - - // Check Default Style - { - uno::Reference<beans::XPropertySet> xPageStyle( - getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - - bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn"); - CPPUNIT_ASSERT_EQUAL(true, bHeader); - - bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared"); - CPPUNIT_ASSERT_EQUAL(true, bHeaderIsShared); - - bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared"); - CPPUNIT_ASSERT_EQUAL(false, bFirstIsShared); - - auto xHeaderTextLeft - = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextFirst"); - //CPPUNIT_ASSERT_EQUAL(OUString("FIRST"), xHeaderTextLeft->getString()); - - auto xHeaderTextRight = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText"); - CPPUNIT_ASSERT_EQUAL(OUString("NON-FIRST"), xHeaderTextRight->getString()); - } -} - -void Test::checkLeftRightHeaderPageStyles() -{ - // Page 1 - { - OUString aPageStyleName; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(1), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("P1"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= aPageStyleName; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), aPageStyleName); - } - - // Page 2 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(2), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("P2"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } - - // Page 3 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(3), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("P3"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } - - // Page 3 - { - OUString pageStyle; - uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(4), uno::UNO_QUERY); - - uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("P4"), xTextRange->getString()); - - xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); - } - - // Check Default Style - { - uno::Reference<beans::XPropertySet> xPageStyle( - getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - - bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn"); - CPPUNIT_ASSERT_EQUAL(true, bHeader); - - bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared"); - CPPUNIT_ASSERT_EQUAL(false, bHeaderIsShared); - - bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared"); - CPPUNIT_ASSERT_EQUAL(true, bFirstIsShared); - - auto xHeaderTextLeft - = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextLeft"); - CPPUNIT_ASSERT_EQUAL(OUString("LEFT"), xHeaderTextLeft->getString()); - - auto xHeaderTextRight - = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextRight"); - CPPUNIT_ASSERT_EQUAL(OUString("RIGHT"), xHeaderTextRight->getString()); - } -} - -CPPUNIT_TEST_FIXTURE(Test, testFirstLeftRightHeaderPageStyles_ODF) -{ - createSwDoc("SimpleFirstLeftRight.odt"); - checkFirstLeftRightHeaderPageStyles(); -} - -CPPUNIT_TEST_FIXTURE(Test, testFirstLeftRightHeaderPageStyles_OOXML) -{ - //createSwDoc("SimpleFirstLeftRight.docx"); - //checkFirstLeftRightHeaderPageStyles(); -} - -CPPUNIT_TEST_FIXTURE(Test, testFirstRestHeaderPageStyles_ODF) -{ - createSwDoc("SimpleFirst.odt"); - checkFirstRestHeaderPageStyles(); -} - -CPPUNIT_TEST_FIXTURE(Test, testFirstRestHeaderPageStyles_OOXML) -{ - //createSwDoc("SimpleFirst.docx"); - //checkFirstRestHeaderPageStyles(); -} - -CPPUNIT_TEST_FIXTURE(Test, testLeftRightHeaderPageStyles_ODF) -{ - createSwDoc("SimpleLeftRight.odt"); - checkLeftRightHeaderPageStyles(); -} - -CPPUNIT_TEST_FIXTURE(Test, testLeftRightHeaderPageStyles_OOXML) -{ - //createSwDoc("SimpleLeftRight.docx"); - //checkLeftRightHeaderPageStyles(); -} - // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 28af67bfbac1..89d57de6e677 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -888,26 +888,6 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo46020) CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount()); } -DECLARE_WW8EXPORT_TEST(testFirstHeaderFooter, "first-header-footer.doc") -{ - // Test import and export of a section's headerf/footerf properties. - - // 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()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer"), parseDump("/root/page[1]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page header"), parseDump("/root/page[2]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"), parseDump("/root/page[2]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"), parseDump("/root/page[3]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"), parseDump("/root/page[3]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"), parseDump("/root/page[6]/header/txt/text()"_ostr)); - CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"), parseDump("/root/page[6]/footer/txt/text()"_ostr)); -} - DECLARE_WW8EXPORT_TEST(testZoom, "zoom.doc") { uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); |