summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-10-11 08:03:58 +0200
committerAndras Timar <andras.timar@collabora.com>2017-02-08 11:56:05 +0100
commit45ffc4296927dd4720fbca83b309dce7bd9f7376 (patch)
tree14f81e98b9fb068afd32cd312550a7ef76d00d17 /sw/qa/extras
parentb5cc11afa2517380a0ee6f59e6da25823fdac9fc (diff)
tdf#103001 DOCX export: fix RelId cache when switching streams
RelIds are used to refer to external streams, e.g. images. A RelId cache tries to avoid storing the same image more than once in the export result. RelIds are relative to an XML stream, so caching them across stream switches is problematic. There was code already to notify the cache after a header or footer was written, but: 1) It was only done after a switch, not before and 2) It cleared the whole cache, instead of stashing it away, and restoring it when the write of the special stream is done. Regression from commit b484e9814c66d8d51cea974390963a6944bc9d73 (tdf#83227 oox: reuse RelId in DML/VML export for the same graphic, 2015-09-07), this existing problem became more visible when caching started to include draw images, not just writer ones. Fix both problems by turning the cache into a stack that is pushed/popped around stream changes. (cherry picked from commit 3906d25a2e12123aee54654ad26699a2832389d4) Change-Id: If9ec168823eea5e272197e28f6125ba626605550 Reviewed-on: https://gerrit.libreoffice.org/29832 Reviewed-by: Tamás Zolnai <zolnaitamas2000@gmail.com> Tested-by: Tamás Zolnai <zolnaitamas2000@gmail.com> (cherry picked from commit 3f373500282c926031eed4f995ca8d51402ed187)
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf103001.docxbin0 -> 33883 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx13
2 files changed, 13 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf103001.docx b/sw/qa/extras/ooxmlexport/data/tdf103001.docx
new file mode 100644
index 000000000000..332d415698ba
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf103001.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 882c91e69a24..e6ce0b3cd272 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -946,6 +946,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf83227, "tdf83227.docx")
CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess->hasByName("word/media/image2.png")));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf103001, "tdf103001.docx")
+{
+ // The same image is featured in the header and in the body text, make sure
+ // the header relation is still written, even when caching is enabled.
+ if (!mbExported)
+ return;
+
+ uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL());
+ // This failed: header reused the RelId of the body text, even if RelIds
+ // are local to their stream.
+ CPPUNIT_ASSERT(xNameAccess->hasByName("word/_rels/header1.xml.rels"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf92521, "tdf92521.odt")
{
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))