summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2023-07-06 17:31:20 +0200
committerLászló Németh <nemeth@numbertext.org>2023-07-09 14:31:26 +0200
commit6d153fa9f5277b7324885e18b0a63e1af830b6c5 (patch)
treed51fac14a37b2108fa9bf43e278bbe1ef38d9bcd
parent2c040dc9919e4c5aa5f582d58ca5717a6ec1e12b (diff)
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf153804.docxbin0 -> 8159 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx17
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx2
4 files changed, 19 insertions, 2 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf153804.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 4718837981cc..67fba9e9b114 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 e0820dfeccb2..1389b9cadc02 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4095,7 +4095,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 c6b38d6d62d0..b2fca78f45fe 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();