summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2018-03-27 12:25:40 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-03-28 08:56:10 +0200
commit1c1160967acf49cffae8921f3ab8361821bbaaaf (patch)
tree0bcc1f841d81625f86649c907ca344d729a45c87 /sd
parent1a43481a1d8913a2c5fcb0c2e4363deaf439caff (diff)
tdf#115005: New option to prevent adding fallback images
A new option AddReplacementImages was added to prevent addition of fallback images that could increase the file size of the package in several times. Added unit test. Change-Id: I50eebba51072d3c93bfe6bed59e9f007568810c0 Reviewed-on: https://gerrit.libreoffice.org/51939 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sd')
-rwxr-xr-xsd/qa/unit/data/odp/tdf115005_no_fallback_images.odpbin0 -> 21100 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx54
2 files changed, 54 insertions, 0 deletions
diff --git a/sd/qa/unit/data/odp/tdf115005_no_fallback_images.odp b/sd/qa/unit/data/odp/tdf115005_no_fallback_images.odp
new file mode 100755
index 000000000000..2f88282af5f8
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf115005_no_fallback_images.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 0cf675be8cf2..4840940274f2 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -134,6 +134,9 @@ public:
void testTdf115394Zero();
void testBulletsAsImage();
void testTdf115005();
+ int testTdf115005_FallBack_Images(bool bAddReplacementImages);
+ void testTdf115005_FallBack_Images_On();
+ void testTdf115005_FallBack_Images_Off();
void testTdf111789();
/// SmartArt animated elements
void testTdf104792();
@@ -199,6 +202,8 @@ public:
CPPUNIT_TEST(testTdf115394Zero);
CPPUNIT_TEST(testBulletsAsImage);
CPPUNIT_TEST(testTdf115005);
+ CPPUNIT_TEST(testTdf115005_FallBack_Images_On);
+ CPPUNIT_TEST(testTdf115005_FallBack_Images_Off);
CPPUNIT_TEST(testTdf111789);
CPPUNIT_TEST(testTdf104792);
CPPUNIT_TEST(testTdf90627);
@@ -1546,6 +1551,55 @@ void SdOOXMLExportTest2::testTdf115005()
CPPUNIT_ASSERT_EQUAL(3, nSVMFiles);
}
+int SdOOXMLExportTest2::testTdf115005_FallBack_Images(bool bAddReplacementImages)
+{
+ sd::DrawDocShellRef xDocShRefOriginal = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf115005_no_fallback_images.odp"), ODP);
+
+ // check if fallback images were not created if AddReplacementImages=true/false
+ // set AddReplacementImages
+ {
+ std::shared_ptr<comphelper::ConfigurationChanges> batch( comphelper::ConfigurationChanges::create() );
+ if ( !officecfg::Office::Common::Save::Graphic::AddReplacementImages::isReadOnly() )
+ officecfg::Office::Common::Save::Graphic::AddReplacementImages::set(bAddReplacementImages, batch);
+ batch->commit();
+ }
+
+ // save the file with already set options
+ utl::TempFile tempFile;
+ sd::DrawDocShellRef xDocShRefResaved = saveAndReload(xDocShRefOriginal.get(), ODP, &tempFile);
+
+ // additional checks of the output file
+ uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), tempFile.GetURL());
+
+ // check that the document contains original vector images
+ const uno::Sequence<OUString> names = xNameAccess->getElementNames();
+ int nSVMFiles = 0;
+ int nPNGFiles = 0;
+ for (int i=0; i<names.getLength(); i++)
+ {
+ if(names[i].endsWith(".svm"))
+ nSVMFiles++;
+ if(names[i].endsWith(".png"))
+ nPNGFiles++;
+ }
+
+ // check results
+ CPPUNIT_ASSERT_EQUAL(1, nSVMFiles);
+ return nPNGFiles;
+}
+
+void SdOOXMLExportTest2::testTdf115005_FallBack_Images_On()
+{
+ const int nPNGFiles = testTdf115005_FallBack_Images(true);
+ CPPUNIT_ASSERT_EQUAL(1, nPNGFiles);
+}
+
+void SdOOXMLExportTest2::testTdf115005_FallBack_Images_Off()
+{
+ const int nPNGFiles = testTdf115005_FallBack_Images(false);
+ CPPUNIT_ASSERT_EQUAL(0, nPNGFiles);
+}
+
void SdOOXMLExportTest2::testTdf111789()
{
// Shadow properties were not exported for text shapes.