summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs7
-rwxr-xr-xsd/qa/unit/data/odp/tdf115005_no_fallback_images.odpbin0 -> 21100 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx54
-rw-r--r--xmloff/source/draw/shapeexport.cxx4
-rw-r--r--xmloff/source/text/txtparae.cxx3
5 files changed, 67 insertions, 1 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 9463ff5b7861..bee6890c2da8 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -2340,6 +2340,13 @@
</constraints>
<value>1</value>
</prop>
+ <prop oor:name="AddReplacementImages" oor:type="xs:boolean" oor:nillable="false">
+ <info>
+ <desc>Export replacement objects as fallback images for vector graphics (True).</desc>
+ <label>Export replacement objects as fallback images for vector graphics</label>
+ </info>
+ <value>true</value>
+ </prop>
</group>
<group oor:name="URL">
<info>
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.
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index a670d6dad8ec..b0422e8fde8b 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -85,6 +85,7 @@
#include <comphelper/graphicmimetype.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/storagehelper.hxx>
+#include <officecfg/Office/Common.hxx>
#include <o3tl/any.hxx>
#include <o3tl/make_unique.hxx>
@@ -2438,7 +2439,8 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
//Resolves: fdo#62461 put preferred image first above, followed by
//fallback here
- if( !bIsEmptyPresObj )
+ const bool bAddReplacementImages = officecfg::Office::Common::Save::Graphic::AddReplacementImages::get();
+ if( !bIsEmptyPresObj && bAddReplacementImages)
{
uno::Reference<graphic::XGraphic> xReplacementGraphic;
xPropSet->getPropertyValue("ReplacementGraphic") >>= xReplacementGraphic;
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index c23ddb2bfa98..a9c5c35d56f2 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -117,6 +117,7 @@
#include <algorithm>
#include <iterator>
#include <comphelper/graphicmimetype.hxx>
+#include <officecfg/Office/Common.hxx>
using namespace ::std;
using namespace ::com::sun::star;
@@ -3153,6 +3154,8 @@ void XMLTextParagraphExport::_exportTextGraphic(
}
}
+ const bool bAddReplacementImages = officecfg::Office::Common::Save::Graphic::AddReplacementImages::get();
+ if (bAddReplacementImages)
{
// replacement graphic for backwards compatibility, but
// only for SVG and metafiles currently