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 a468c85b44684ec4217566157323e064b5db9f96 Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Jul 6 17:31:20 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 12 09:18:02 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 6d153fa9f5277b7324885e18b0a63e1af830b6c5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154186 Tested-by: Jenkins (cherry picked from commit 1e9e2ff5316a6d934205f1c01a57f80ef4e8657d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154188 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Michael Weghorn <m.wegh...@posteo.de> 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 c6949b14e6bc..458235ca26aa 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -1342,6 +1342,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 7fb017154135..366f51a454b3 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3815,7 +3815,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 168f3bfb8b08..fab303cf3e3e 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -872,7 +872,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();