diff options
author | László Németh <nemeth@numbertext.org> | 2021-08-10 13:05:48 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-08-11 13:58:26 +0200 |
commit | c46950fee11f5207fb8324947280cd565ae483e7 (patch) | |
tree | 7b0d819f4f917e2e3a2ede2fd322b8c995a7039c | |
parent | d39d87bbffe8e731bad92f2fe90526c3610689f5 (diff) |
tdf#143583 DOCX import: fix lost empty paragraphs of footnotes
Last empty paragraphs of footnotes were removed (except
in the case of the first footnote), related to the double
call of RemoveLastParagraph() during footnote load and
later during its copying.
Regression from commit 9b39ce0e66acfe812e1d50e530dc2ccdef3e1357
"tdf#76260 DOCX import: fix slow footnote import".
Change-Id: I61d9aa6765f3af1893451684dde12c199251d06b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120270
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf143583_emptyParaAtEndOfFootnote.docx | bin | 0 -> 8777 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 13 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 |
3 files changed, 16 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf143583_emptyParaAtEndOfFootnote.docx b/sw/qa/extras/ooxmlexport/data/tdf143583_emptyParaAtEndOfFootnote.docx Binary files differnew file mode 100644 index 000000000000..e8b42b840a93 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf143583_emptyParaAtEndOfFootnote.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index d783c8f448de..41a5f26acb8b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -1177,6 +1177,19 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf143399, "tdf143399.docx") assertXPathContent(pXml2, "/w:endnotes/w:endnote[3]/w:p/w:r[3]/w:t[1]", "Endnotes"); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf143583, "tdf143583_emptyParaAtEndOfFootnote.docx") +{ + xmlDocUniquePtr pXml = parseExport("word/footnotes.xml"); + CPPUNIT_ASSERT(pXml); + assertXPath(pXml, "/w:footnotes/w:footnote[3]/w:p", 2); + // This was 1 + assertXPath(pXml, "/w:footnotes/w:footnote[4]/w:p", 2); + // This was 2 + assertXPath(pXml, "/w:footnotes/w:footnote[5]/w:p", 3); + // This was 2 + assertXPath(pXml, "/w:footnotes/w:footnote[6]/w:p", 3); +} + DECLARE_OOXMLEXPORT_TEST(testContSectBreakHeaderFooter, "cont-sect-break-header-footer.docx") { // Load a document with a continuous section break on page 2. diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index c5bfed90ae1a..1249d45c82dd 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3210,6 +3210,7 @@ void DomainMapper_Impl::PopFootOrEndnote() // FIXME: add footnote IDs to handle possible differences in footnote serialization uno::Reference< text::XFootnotesSupplier> xFootnotesSupplier( GetTextDocument(), uno::UNO_QUERY ); uno::Reference< text::XEndnotesSupplier> xEndnotesSupplier( GetTextDocument(), uno::UNO_QUERY ); + bool bCopied = false; if ( IsInFootOrEndnote() && ( ( IsInFootnote() && GetFootnoteCount() > -1 && xFootnotesSupplier.is() ) || ( !IsInFootnote() && GetEndnoteCount() > -1 && xEndnotesSupplier.is() ) ) ) { @@ -3251,11 +3252,12 @@ void DomainMapper_Impl::PopFootOrEndnote() // remove temporary footnote xFootnoteFirst->getAnchor()->setString(""); + bCopied = true; } } } - if (!IsRTFImport()) + if (!IsRTFImport() && !bCopied) RemoveLastParagraph(); // In case the foot or endnote did not contain a tab. |