sw/qa/core/unocore/data/tdf149555.docx |binary sw/qa/core/unocore/unocore.cxx | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
New commits: commit 97b6b6b16c4b623f8a34393a906272439a7f0314 Author: OmkarAcharekar <omkarachareka...@gmail.com> AuthorDate: Sat Oct 14 00:42:35 2023 +0530 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Oct 23 13:16:42 2023 +0200 tdf#149555: sw_unocore: Add test for convert RANGE_IS_SECTION SwXTextRange Change-Id: I5e9fe7c59ac81004ce44ac04d5c50f65b754d847 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157947 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/core/unocore/data/tdf149555.docx b/sw/qa/core/unocore/data/tdf149555.docx new file mode 100755 index 000000000000..b1f983c3402f Binary files /dev/null and b/sw/qa/core/unocore/data/tdf149555.docx differ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 90970b6f680b..ea0f802ad515 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -17,6 +17,7 @@ #include <com/sun/star/document/XDocumentInsertable.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XPageCursor.hpp> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -984,6 +985,44 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testCollectFrameAtNodeWithLayout) assertXPath(pXmlDoc, "//draw:frame", 1); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf149555) +{ + createSwDoc("tdf149555.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); + + xCursor->jumpToFirstPage(); + OUString sPageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>( + getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("HEADER 1"), xHeaderText->getString()); + + // Without the fix in place, this test would have failed with + // - Expected: HEADER 2 + // - Actual: HEADER 1 + xCursor->jumpToPage(2); + sPageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xHeaderText = getProperty<uno::Reference<text::XText>>( + getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("HEADER 2"), xHeaderText->getString()); + + xCursor->jumpToPage(3); + sPageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xHeaderText = getProperty<uno::Reference<text::XText>>( + getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("HEADER 2"), xHeaderText->getString()); + + xCursor->jumpToPage(4); + sPageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xHeaderText = getProperty<uno::Reference<text::XText>>( + getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL(OUString("HEADER 2"), xHeaderText->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */