sw/qa/extras/uiwriter/data/tdf104315.odt |binary sw/qa/extras/uiwriter/data/tdf114773.odt |binary sw/qa/extras/uiwriter/uiwriter3.cxx | 54 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
New commits: commit 22069151cdf12729ef675f2f5a8d7a069e1c5378 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Mar 7 14:11:04 2023 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Mar 7 21:53:56 2023 +0000 tdf#104315: sw_uiwriter3: Add unittest Change-Id: Id789db24b570242928a650f6e9dedd5691f0625c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148420 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/uiwriter/data/tdf104315.odt b/sw/qa/extras/uiwriter/data/tdf104315.odt new file mode 100644 index 000000000000..d8726efb4cae Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf104315.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index aab3bcc27339..dfcde8d7eaa7 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -642,6 +642,32 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf114773) aIndexString); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf104315) +{ + createSwDoc("tdf104315.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: This is a headlinex 1 + // - Actual : This is a headlinx 1 + CPPUNIT_ASSERT_EQUAL(OUString("Table of contents\n" + "This is a headlinex\t1\n" + "This is another headlinex\t1"), + aIndexString); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135412) { createSwDoc("tdf135412.docx"); commit d899cc680b7a0a21d863a1e1746262bf958de882 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Mar 7 13:44:49 2023 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Mar 7 21:53:48 2023 +0000 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 <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/uiwriter/data/tdf114773.odt b/sw/qa/extras/uiwriter/data/tdf114773.odt new file mode 100644 index 000000000000..d4b025366cdc Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf114773.odt differ 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");