oox/source/export/shapes.cxx          |   10 ++++++++++
 sd/qa/unit/data/pptx/ole-emf_min.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx    |   11 +++++++++++
 3 files changed, 21 insertions(+)

New commits:
commit 907da02bf8b33c080538731864225b3c44251328
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Tue Dec 13 11:08:52 2022 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Dec 19 11:47:09 2022 +0000

    tdf#152436 PPTX 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".
    
    Change-Id: Ib2fd00f53a80572cfc9acaefea55015780c57da8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144040
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 125ea39e2970..137c69fe7c33 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2538,6 +2538,16 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
     if (!xObj.is())
     {
         SAL_WARN("oox.shape", "ShapeExport::WriteOLE2Shape: no object");
+
+        // tdf#152436 Export the preview graphic of the object if the object 
is missing.
+        SdrObject* pSdrOLE2(SdrObject::getSdrObjectFromXShape(xShape));
+        if (auto pOle2Obj = dynamic_cast<SdrOle2Obj*>(pSdrOLE2))
+        {
+            const Graphic* pGraphic = pOle2Obj->GetGraphic();
+            if (pGraphic)
+                WriteGraphicObjectShapePart(xShape, pGraphic);
+        }
+
         return *this;
     }
 
diff --git a/sd/qa/unit/data/pptx/ole-emf_min.pptx 
b/sd/qa/unit/data/pptx/ole-emf_min.pptx
new file mode 100644
index 000000000000..0f97208fbebc
Binary files /dev/null and b/sd/qa/unit/data/pptx/ole-emf_min.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 2e6a600ec686..309709317821 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -130,6 +130,7 @@ public:
     void testTdf124333();
     void testAutofittedTextboxIndent();
     void testTdf151622_oleIcon();
+    void testTdf152436();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -221,6 +222,7 @@ public:
     CPPUNIT_TEST(testTdf124333);
     CPPUNIT_TEST(testAutofittedTextboxIndent);
     CPPUNIT_TEST(testTdf151622_oleIcon);
+    CPPUNIT_TEST(testTdf152436);
     CPPUNIT_TEST_SUITE_END();
 
     virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -2105,6 +2107,15 @@ void SdOOXMLExportTest3::testTdf151622_oleIcon()
     assertXPath(pXml, "//p:oleObj", "showAsIcon", "1");
 }
 
+void SdOOXMLExportTest3::testTdf152436()
+{
+    createSdImpressDoc("pptx/ole-emf_min.pptx");
+    saveAndReload("Impress Office Open XML");
+
+    // Check number of shapes after export.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getPage(0)->getCount());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3);
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to