sw/qa/extras/ooxmlexport/data/tdf153804.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 17 +++++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2 +- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-)
New commits: commit c93083d583e7b29a27bf8ff6e2664fe0613a6542 Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Jul 6 17:31:20 2023 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Sun Jul 9 21:42:53 2023 +0200 tdf#153804 DOCX import: fix lost footnotes in case of comments Incomplete handling of m_bIsFootnote had a conflict with XNote stream COMMENTS (i.e. not FOOTNOTES and ENDNOTES) since commit 96a856f87f16cca2e039c973c18d57c8b9dca362 in DomainMapper::lcl_checkId(), resulting lost (order or content) of footnotes, when were comments in the document. Regression from commit 96a856f87f16cca2e039c973c18d57c8b9dca362 "tdf#152206 DOCX import: fix mixed first footnote". Change-Id: I8d6901e8db1e183b959fecd350d6a263e79b5591 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154147 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit cca6ccf0f5e2f72c96f4f8879b8d894faea28b81) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154185 Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/tdf153804.docx b/sw/qa/extras/ooxmlexport/data/tdf153804.docx new file mode 100644 index 000000000000..65a1fdfa8e17 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153804.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 5edb4dcdcd11..a8beca7e6b0e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -1352,6 +1352,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153255) CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg4."), xFootnote4->getString().trim() ); } +CPPUNIT_TEST_FIXTURE(Test, testTdf153804) +{ + loadAndSave("tdf153804.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(1), uno::UNO_QUERY); + // This was empty + CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg 6"), xLastFootnote->getString().trim() ); + + uno::Reference<text::XTextRange> xLastButOne(xFootnotes->getByIndex(0), uno::UNO_QUERY); + // This was empty + CPPUNIT_ASSERT_EQUAL( OUString("Footnote for pg5"), xLastButOne->getString().trim() ); +} + // skip test for macOS (missing fonts?) #if !defined(MACOSX) DECLARE_OOXMLEXPORT_TEST(testTdf146346, "tdf146346.docx") diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 4e410c0b0be9..f849a5246bf4 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -4087,7 +4087,7 @@ void DomainMapper_Impl::PopFootOrEndnote() } m_aRedlines.pop(); m_eSkipFootnoteState = SkipFootnoteSeparator::OFF; - m_bInFootOrEndnote = false; + m_bInFootOrEndnote = m_bInFootnote = false; m_pFootnoteContext = nullptr; m_bFirstParagraphInCell = m_bSaveFirstParagraphInCell; } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 4668ebc8ac4c..55f3b671c836 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -863,7 +863,7 @@ public: void PushFootOrEndnote( bool bIsFootnote ); void PopFootOrEndnote(); bool IsInFootOrEndnote() const { return m_bInFootOrEndnote; } - bool IsInFootnote() const { return m_bInFootnote; } + bool IsInFootnote() const { return IsInFootOrEndnote() && m_bInFootnote; } void StartCustomFootnote(const PropertyMapPtr pContext); void EndCustomFootnote();