summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-07-20 09:51:47 +0200
committerLászló Németh <nemeth@numbertext.org>2021-07-20 15:59:26 +0200
commitf78a21df119603cd6db03f8544871c7a41f16864 (patch)
treed0716dfa4ef74195ae3f0fea7fb8f438eabfd1b5
parentae0c6da13c9b92757ff0f4ba360308ee50c701cf (diff)
tdf#143399 DOCX import: fix lost endnotes or footnotes
in a document containing both of them. Regression from commit 7dd8f8aace536a8e60e87e61ee1d90d61fba15eb "tdf#120351 DOCX import: fix slow endnote import". Change-Id: I0fe764f3b48dd2688afa4b7cf0ee6658737ef9fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119239 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 732b08b22eee2682351a9295be29188852fb0489) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119187 Tested-by: Jenkins
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf143399.docxbin0 -> 14354 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx17
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx15
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.hxx3
4 files changed, 27 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf143399.docx b/sw/qa/extras/ooxmlexport/data/tdf143399.docx
new file mode 100644
index 000000000000..191e46f36bb1
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf143399.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index e383984c1170..9944636960c0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1160,6 +1160,23 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf141548, "tdf141548.docx")
assertXPathContent(pXml, "/w:endnotes/w:endnote[4]/w:p/w:r[2]/w:t[2]", "new line");
}
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf143399, "tdf143399.docx")
+{
+ xmlDocUniquePtr pXml = parseExport("word/footnotes.xml");
+ CPPUNIT_ASSERT(pXml);
+ // These were 0 (lost text content of documents both with footnotes and endnotes)
+ assertXPath(pXml, "/w:footnotes/w:footnote[3]/w:p/w:r[3]/w:t", 1);
+ assertXPathContent(pXml, "/w:footnotes/w:footnote[3]/w:p/w:r[3]/w:t", "Footnotes_graphic2");
+ assertXPath(pXml, "/w:footnotes/w:footnote[4]/w:p/w:r[3]/w:t", 1);
+ assertXPathContent(pXml, "/w:footnotes/w:footnote[4]/w:p/w:r[3]/w:t", "Footnotes_grahic");
+
+ xmlDocUniquePtr pXml2 = parseExport("word/endnotes.xml");
+ CPPUNIT_ASSERT(pXml);
+ // This was 0 (lost text content of the run with endnoteRef)
+ assertXPath(pXml2, "/w:endnotes/w:endnote[3]/w:p/w:r[3]/w:t", 1);
+ assertXPathContent(pXml2, "/w:endnotes/w:endnote[3]/w:p/w:r[3]/w:t[1]", "Endnotes");
+}
+
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/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index 0331d3539508..9a666947d91f 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -52,7 +52,8 @@ namespace writerfilter::ooxml
OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t const & pStream, const uno::Reference<task::XStatusIndicator>& xStatusIndicator, bool bSkipImages, const uno::Sequence<beans::PropertyValue>& rDescriptor)
: mpStream(pStream)
, mxStatusIndicator(xStatusIndicator)
- , mpXNoteStream()
+ , mpXFootnoteStream()
+ , mpXEndnoteStream()
, mnXNoteId(0)
, mbIsSubstream(false)
, mbSkipImages(bSkipImages)
@@ -270,8 +271,8 @@ void OOXMLDocumentImpl::resolveFootnote(Stream & rStream,
Id aType,
const sal_Int32 nNoteId)
{
- if (!mpXNoteStream)
- mpXNoteStream = getXNoteStream(OOXMLStream::FOOTNOTES, nNoteId);
+ if (!mpXFootnoteStream)
+ mpXFootnoteStream = getXNoteStream(OOXMLStream::FOOTNOTES, nNoteId);
Id nId;
switch (aType)
@@ -285,15 +286,15 @@ void OOXMLDocumentImpl::resolveFootnote(Stream & rStream,
break;
}
- resolveFastSubStreamWithId(rStream, mpXNoteStream, nId);
+ resolveFastSubStreamWithId(rStream, mpXFootnoteStream, nId);
}
void OOXMLDocumentImpl::resolveEndnote(Stream & rStream,
Id aType,
const sal_Int32 nNoteId)
{
- if (!mpXNoteStream)
- mpXNoteStream = getXNoteStream(OOXMLStream::ENDNOTES, nNoteId);
+ if (!mpXEndnoteStream)
+ mpXEndnoteStream = getXNoteStream(OOXMLStream::ENDNOTES, nNoteId);
Id nId;
switch (aType)
@@ -307,7 +308,7 @@ void OOXMLDocumentImpl::resolveEndnote(Stream & rStream,
break;
}
- resolveFastSubStreamWithId(rStream, mpXNoteStream, nId);
+ resolveFastSubStreamWithId(rStream, mpXEndnoteStream, nId);
}
void OOXMLDocumentImpl::resolveCommentsExtendedStream(Stream& rStream)
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
index ed9db125cbe8..3b98cbac58ba 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
@@ -35,7 +35,8 @@ class OOXMLDocumentImpl : public OOXMLDocument
{
OOXMLStream::Pointer_t mpStream;
css::uno::Reference<css::task::XStatusIndicator> mxStatusIndicator;
- writerfilter::Reference<Stream>::Pointer_t mpXNoteStream;
+ writerfilter::Reference<Stream>::Pointer_t mpXFootnoteStream;
+ writerfilter::Reference<Stream>::Pointer_t mpXEndnoteStream;
sal_Int32 mnXNoteId;
css::uno::Reference<css::frame::XModel> mxModel;