oox/source/export/shapes.cxx | 10 ++++++++++ sd/qa/unit/data/pptx/ole-emf_min.pptx |binary sd/qa/unit/export-tests-ooxml3.cxx | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+)
New commits: commit 77e050e785cc7bdeff8c3b7746737499f0e0b381 Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Tue Dec 13 11:08:52 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Dec 21 07:23:38 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> (cherry picked from commit 907da02bf8b33c080538731864225b3c44251328) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144486 Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144578 diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index d8717acb9c06..6e2484279ac1 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -2511,6 +2511,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 b1d66cdbed94..5f4928b669e2 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -122,6 +122,7 @@ public: void testTdf94122_autoColor(); void testTdf124333(); void testAutofittedTextboxIndent(); + void testTdf152436(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest3); @@ -210,6 +211,7 @@ public: CPPUNIT_TEST(testTdf94122_autoColor); CPPUNIT_TEST(testTdf124333); CPPUNIT_TEST(testAutofittedTextboxIndent); + CPPUNIT_TEST(testTdf152436); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -2239,6 +2241,23 @@ void SdOOXMLExportTest3::testAutofittedTextboxIndent() "691200"); } +void SdOOXMLExportTest3::testTdf152436() +{ + ::sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/ole-emf_min.pptx"), PPTX); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("number of shapes is incorrect", sal_Int32(1), + getPage(0, xDocShRef)->getCount()); + + xDocShRef = saveAndReload(xDocShRef.get(), PPTX); + + // Check number of shapes after export. + CPPUNIT_ASSERT_EQUAL_MESSAGE("number of shapes is incorrect after export", sal_Int32(1), + getPage(0, xDocShRef)->getCount()); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3); CPPUNIT_PLUGIN_IMPLEMENT();