summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2022-03-22 09:47:57 +0100
committerLászló Németh <nemeth@numbertext.org>2022-03-30 18:24:45 +0200
commitaea8043bc5f5187498fa450505d6de9d6986e2a6 (patch)
tree2047231de903ae94656848f14d31a3523d429fe8 /sd
parent94ace0e51744f82b58156392e53b4c4ad819e4bf (diff)
tdf#74670 tdf#91286 PPTX XLSX export: save image once
Impress and Calc used to dump the same image file as many times as it was featured in the document, resulting redundant, sometimes huge documents. Note: using only checksum to recognize image duplication is a regression, because checksum collision results image loss. This is a very unlikely event, and the following commits have got the same problem. The solution is comparing the images with the same checksum byte for byte. See also commit b484e9814c66d8d51cea974390963a6944bc9d73 "tdf#83227 oox: reuse RelId in DML/VML export for the same graphic" and commit 797fef38612fb2fd62d1f6591619b9361e526bca "tdf#118535 DOCX export: save header image once". Change-Id: I9f233d521941381746634cf4f9b5991da0dadda9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131928 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/odp/tdf74670.odpbin0 -> 11786 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml3.cxx26
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx2
3 files changed, 28 insertions, 0 deletions
diff --git a/sd/qa/unit/data/odp/tdf74670.odp b/sd/qa/unit/data/odp/tdf74670.odp
new file mode 100644
index 000000000000..98e223eb0725
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf74670.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx
index 776d436b7edf..3f4bec336ef1 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -106,6 +106,7 @@ public:
void testTdf147121();
void testTdf140912_PicturePlaceholder();
void testEnhancedPathViewBox();
+ void testTdf74670();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
@@ -182,6 +183,7 @@ public:
CPPUNIT_TEST(testTdf147121);
CPPUNIT_TEST(testTdf140912_PicturePlaceholder);
CPPUNIT_TEST(testEnhancedPathViewBox);
+ CPPUNIT_TEST(testTdf74670);
CPPUNIT_TEST_SUITE_END();
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -1893,6 +1895,30 @@ void SdOOXMLExportTest3::testEnhancedPathViewBox()
CPPUNIT_ASSERT_EQUAL(sal_Int32(2045), aBoundRectangle.Width);
}
+void SdOOXMLExportTest3::testTdf74670()
+{
+ ::sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf74670.odp"), ODP);
+ utl::TempFile tmpfile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tmpfile);
+ xDocShRef->DoClose();
+
+ uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
+ = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
+ tmpfile.GetURL());
+ const uno::Sequence<OUString> aNames(xNameAccess->getElementNames());
+ int nImageFiles = 0;
+ for (const auto& rElementName : aNames)
+ if (rElementName.startsWith("ppt/media/image"))
+ nImageFiles++;
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1
+ // - Actual : 2
+ // i.e. the embedded picture would have been saved twice.
+ CPPUNIT_ASSERT_EQUAL(1, nImageFiles);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 07be6521d678..8823cbd00d53 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -428,6 +428,7 @@ bool PowerPointExport::importDocument() noexcept
bool PowerPointExport::exportDocument()
{
DrawingML::ResetCounters();
+ DrawingML::PushExportGraphics();
maShapeMap.clear();
mXModel = getModel();
@@ -504,6 +505,7 @@ bool PowerPointExport::exportDocument()
commitStorage();
+ DrawingML::PopExportGraphics();
maShapeMap.clear();
maAuthors.clear();
maRelId.clear();