diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-03-07 13:44:49 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-03-07 21:53:48 +0000 |
commit | d899cc680b7a0a21d863a1e1746262bf958de882 (patch) | |
tree | 0052ed1d05a830097e379f4ad39d7a6ea566aee0 /sw | |
parent | cc6fe41b051722ab73a44c7aa00b9101ae0284ca (diff) |
tdf#114773: sw_uiwriter3: Add unittest
Change-Id: Idb5edf4c3d7179eca0d1e66801aedd07712c2da8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148419
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf114773.odt | bin | 0 -> 22545 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 28 |
2 files changed, 28 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf114773.odt b/sw/qa/extras/uiwriter/data/tdf114773.odt Binary files differnew file mode 100644 index 000000000000..d4b025366cdc --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf114773.odt diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index f81232ddca62..aab3bcc27339 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -614,6 +614,34 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139638) xTOCIndex->update(); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf114773) +{ + createSwDoc("tdf114773.odt"); + + uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexes->getCount()); + uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), uno::UNO_QUERY); + + xTOCIndex->update(); + uno::Reference<text::XTextRange> xTextRange = xTOCIndex->getAnchor(); + uno::Reference<text::XText> xText = xTextRange->getText(); + uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor(); + xTextCursor->gotoRange(xTextRange->getStart(), false); + xTextCursor->gotoRange(xTextRange->getEnd(), true); + OUString aIndexString(convertLineEnd(xTextCursor->getString(), LineEnd::LINEEND_LF)); + + // Without the fix in place, this test would have failed with + // - Expected: 2 Heading Level 1 2-1 + // - Actual : 2 Heading Level 1 2 -1 + CPPUNIT_ASSERT_EQUAL(OUString("Full ToC\n" + "2 Heading Level 1\t2-1\n" + "2.1 Heading Level 2\t2-2\n" + "2.1.1 Heading Level 3\t2-2\n" + "2.1.1.1 Heading Level 4\t2-2"), + aIndexString); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135412) { createSwDoc("tdf135412.docx"); |