summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2016-12-11 21:22:10 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-12-12 10:05:12 +0000
commitdd747c0669f6e31462c39fe104d2f2c0acc4de0a (patch)
treedc98cf2cfad60d393376dc9fb6b5891afa83bb42
parent71b1e3ff6374c23e65200d3bcafca387d29af04f (diff)
tdf#99227: use correct serializer when exporting drawing
Failing to do that leads to write-past-end-of-document, drawing loss and SAXParseException if the drawing is part of a footnote. A unit test is included. Change-Id: Ie7d8263dc72dfef1e9827cc0579a5eaaf5819410 Reviewed-on: https://gerrit.libreoffice.org/31871 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf99227.docxbin0 -> 15636 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx13
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx2
3 files changed, 15 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf99227.docx b/sw/qa/extras/ooxmlexport/data/tdf99227.docx
new file mode 100644
index 000000000000..27ec4eb383b0
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf99227.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 807e73e252b8..606510fa7fe4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -166,6 +166,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103651, "tdf103651.docx")
CPPUNIT_ASSERT_EQUAL( sal_Int32( -1 ) , sContent.indexOf( sal_Unicode( 0xf04a ) ));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf99227, "tdf99227.docx")
+{
+ // A drawing anchored as character to a footnote caused write past end of document.xml at export to docx.
+ // After that, importing after export failed with
+ // SAXParseException: '[word/document.xml line 2]: Extra content at the end of the document', Stream 'word / document.xml',
+ // and before commit ebf767eeb2a169ba533e1b2ffccf16f41d95df35, the drawing was silently lost.
+ xmlDocPtr pXmlDoc = parseExport("word/footnotes.xml");
+ if (!pXmlDoc)
+ return;
+
+ assertXPath(pXmlDoc, "//w:footnote[3]/w:p/w:r[5]/w:drawing", 1);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8686052ae616..c3ebd97d479d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4269,6 +4269,8 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
CharGrabBag(*pGrabBag);
}
+ // tdf#99227: to be sure that we write to the right stream
+ m_rExport.SdrExporter().setSerializer(m_pSerializer);
m_rExport.SdrExporter().startDMLAnchorInline(pFrameFormat, rSize);
// picture description (used for pic:cNvPr later too)