sd/qa/unit/export-tests.cxx        |   11 +++++++++
 xmloff/source/draw/shapeexport.cxx |   45 +++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

New commits:
commit 134df0c64da6392648b8d4f7020d95e337307e67
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Fri Jan 27 09:55:40 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Feb 16 08:41:46 2023 +0000

    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 <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit da725dfe07f2cf10349772d1667591c4d6a6fe8a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146990
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 9b5c73bd43f3..029ee7267054 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -102,6 +102,7 @@ public:
     void testTdf112126();
     void testCellProperties();
     void testUserTableStyles();
+    void testTdf153179();
 
     CPPUNIT_TEST_SUITE(SdExportTest);
 
@@ -154,6 +155,7 @@ public:
     CPPUNIT_TEST(testTdf112126);
     CPPUNIT_TEST(testCellProperties);
     CPPUNIT_TEST(testUserTableStyles);
+    CPPUNIT_TEST(testTdf153179);
     CPPUNIT_TEST_SUITE_END();
 
     virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -1847,6 +1849,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 6e687e746ba4..c8d513d4e724 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;
+                    }
+                }
             }
         }
 

Reply via email to