summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2023-01-27 09:55:40 +0100
committerLászló Németh <nemeth@numbertext.org>2023-02-15 08:35:00 +0000
commitda725dfe07f2cf10349772d1667591c4d6a6fe8a (patch)
treed12c8daae8065a0e6b1162c472174342822c5735
parent7fb8b73ad320e32af130ceddec80a9ff08407eab (diff)
tdf#153179 ODP export regression: fix lost shape at missing object
If the object is missing, it's still possible to keep its shape by exporting its preview graphic, as before the regression. Regression from commit adc042f95d3dbd65b778260025d59283146916e5 "tdf#124333 PPTX import: fix Z-order of embedded OLE objects". See also commit 907da02bf8b33c080538731864225b3c44251328 "tdf#152436 PPTX export regression: fix lost shape at missing object" Change-Id: I614730435a857c6cdf01d4cdfc525fc452dffa29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146247 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sd/qa/unit/export-tests.cxx11
-rw-r--r--xmloff/source/draw/shapeexport.cxx45
2 files changed, 56 insertions, 0 deletions
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index a7915dcc4c23..1878bf11e706 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -103,6 +103,7 @@ public:
void testTdf112126();
void testCellProperties();
void testUserTableStyles();
+ void testTdf153179();
CPPUNIT_TEST_SUITE(SdExportTest);
@@ -156,6 +157,7 @@ public:
CPPUNIT_TEST(testTdf112126);
CPPUNIT_TEST(testCellProperties);
CPPUNIT_TEST(testUserTableStyles);
+ CPPUNIT_TEST(testTdf153179);
CPPUNIT_TEST_SUITE_END();
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -1861,6 +1863,15 @@ void SdExportTest::testUserTableStyles()
CPPUNIT_ASSERT(xTableStyle->isUserDefined());
}
+void SdExportTest::testTdf153179()
+{
+ createSdImpressDoc("pptx/ole-emf_min.pptx");
+ saveAndReload("impress8");
+
+ // Check number of shapes after export.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getPage(0)->getCount());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 3e0786e6ea77..f972c389a396 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -3011,6 +3011,51 @@ void XMLShapeExport::ImpExportOLE2Shape(
mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
}
+ else
+ {
+ // tdf#153179 Export the preview graphic of the object if the object is missing.
+ uno::Reference<graphic::XGraphic> xGraphic;
+ xPropSet->getPropertyValue("Graphic") >>= xGraphic;
+
+ if (xGraphic.is())
+ {
+ OUString aMimeType;
+ const OUString aHref = mrExport.AddEmbeddedXGraphic(xGraphic, aMimeType);
+
+ if (aMimeType.isEmpty())
+ mrExport.GetGraphicMimeTypeFromStream(xGraphic, aMimeType);
+
+ if (!aHref.isEmpty())
+ {
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aHref);
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED);
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD);
+ }
+
+ if (!aMimeType.isEmpty()
+ && GetExport().getSaneDefaultVersion() > SvtSaveOptions::ODFSVER_012)
+ { // ODF 1.3 OFFICE-3943
+ mrExport.AddAttribute(SvtSaveOptions::ODFSVER_013
+ <= GetExport().getSaneDefaultVersion()
+ ? XML_NAMESPACE_DRAW
+ : XML_NAMESPACE_LO_EXT,
+ "mime-type", aMimeType);
+ }
+
+ SvXMLElementExport aImageElem(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true,
+ true);
+
+ // optional office:binary-data
+ mrExport.AddEmbeddedXGraphicAsBase64(xGraphic);
+
+ ImpExportEvents(xShape);
+ ImpExportGluePoints(xShape);
+ ImpExportDescription(xShape);
+
+ return;
+ }
+ }
}
}