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 <xiscofauli@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 0000000..b1f983c
--- /dev/null
+++ b/sw/qa/core/unocore/data/tdf149555.docx
Binary files differ
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index 90970b6..ea0f802 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: */