diff options
author | László Németh <nemeth@numbertext.org> | 2023-03-20 17:27:32 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-03-21 15:57:27 +0000 |
commit | ed0372bac123b402fe3cd694a455e8328117752d (patch) | |
tree | 92ddbac4183d21bcdc739eb085fb37d91cdc2b00 /sw/qa | |
parent | 808c5bf66370f78f36e98887db0848ee7e55bb3a (diff) |
tdf#153255 DOCX import: fix footnote order
Simple unit test for tdf#152203 allowed to create
bad ordering algorithm by accident without noticing
the problem, which caused problem for most of the DOCX
files, where serialization in footnotes.xml doesn't follow
the order of the footnotes.
Regression from commit 9b39ce0e66acfe812e1d50e530dc2ccdef3e1357
"tdf#76260 DOCX import: fix slow footnote import".
Follow-up to commit 09ae3c01940bbc25ffde51963683b04e3cb4bb6a
"tdf#152203 DOCX import: fix mixed footnotes/endnotes".
Change-Id: I0628d96e3b8ad4df38d26e9288b47d39b958c441
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149176
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf153255.docx | bin | 0 -> 14233 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 35 |
2 files changed, 35 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153255.docx b/sw/qa/extras/ooxmlexport/data/tdf153255.docx Binary files differnew file mode 100644 index 000000000000..e9f2892d5670 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf153255.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index ffb48ecad109..0fd98a48f759 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -1317,6 +1317,41 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152506) CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg5"), xLastButOne->getString().trim() ); } +CPPUNIT_TEST_FIXTURE(Test, testTdf153255) +{ + loadAndSave("tdf153255.docx"); + xmlDocUniquePtr pXml = parseExport("word/footnotes.xml"); + CPPUNIT_ASSERT(pXml); + + uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes(); + uno::Reference<text::XTextRange> xLastFootnote(xFootnotes->getByIndex(5), uno::UNO_QUERY); + // This was "Footnote for pg2" (replaced footnotes) + CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg 6"), xLastFootnote->getString().trim() ); + + uno::Reference<text::XTextRange> xLastButOne(xFootnotes->getByIndex(4), uno::UNO_QUERY); + // This was "Footnote for pg 6" (replaced footnotes) + CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg5"), xLastButOne->getString().trim() ); + + // check all the remaining footnotes + + uno::Reference<text::XTextRange> xFootnote1(xFootnotes->getByIndex(0), uno::UNO_QUERY); + // This was "Footnote for pg3" (replaced footnotes) + CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg1"), xFootnote1->getString().trim() ); + + uno::Reference<text::XTextRange> xFootnote2(xFootnotes->getByIndex(1), uno::UNO_QUERY); + // This was "Footnote for pg5" (replaced footnotes) + CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg2"), xFootnote2->getString().trim() ); + + uno::Reference<text::XTextRange> xFootnote3(xFootnotes->getByIndex(2), uno::UNO_QUERY); + // This was "Footnote for pg4." (replaced footnotes) + CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg3"), xFootnote3->getString().trim() ); + + uno::Reference<text::XTextRange> xFootnote4(xFootnotes->getByIndex(3), uno::UNO_QUERY); + // This was "Footnote for pg1" (replaced footnotes) + CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg4."), xFootnote4->getString().trim() ); +} + // skip test for macOS (missing fonts?) #if !defined(MACOSX) DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx") |