From eea9c8069cbd1deeca5af6866090984f28892ac8 Mon Sep 17 00:00:00 2001 From: Gülşah Köse Date: Mon, 22 Mar 2021 23:39:17 +0300 Subject: tdf#140714 Import graphics cropped into custom geometry as custom shapes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2054d24ce41c9f0d6cc1675f461274067c3b2898 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112943 Tested-by: Jenkins Reviewed-by: Jan Holesovsky Reviewed-by: Gülşah Köse Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113003 Tested-by: Jenkins CollaboraOffice --- oox/source/drawingml/shape.cxx | 6 ++++-- sd/qa/unit/data/pptx/tdf140714.pptx | Bin 0 -> 28384 bytes sd/qa/unit/export-tests.cxx | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 sd/qa/unit/data/pptx/tdf140714.pptx diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 9e324ef69ed1..803e130b349a 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -726,8 +726,10 @@ Reference< XShape > const & Shape::createAndInsert( } // Use custom shape instead of GraphicObjectShape if the image is cropped to // shape. Except rectangle, which does not require further cropping - bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" && mpCustomShapePropertiesPtr->getShapePresetType() >= 0 - && mpCustomShapePropertiesPtr->getShapePresetType() != XML_Rect && mpCustomShapePropertiesPtr->getShapePresetType() != XML_rect); + bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" && + (mpCustomShapePropertiesPtr->getShapePresetType() >= 0 || mpCustomShapePropertiesPtr->getPath2DList().size() > 0) && + mpCustomShapePropertiesPtr->getShapePresetType() != XML_Rect && + mpCustomShapePropertiesPtr->getShapePresetType() != XML_rect); bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" || aServiceName == "com.sun.star.drawing.ConnectorShape" || bIsCroppedGraphic); diff --git a/sd/qa/unit/data/pptx/tdf140714.pptx b/sd/qa/unit/data/pptx/tdf140714.pptx new file mode 100644 index 000000000000..6f5e98ec66f1 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf140714.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index f1d5f65c36ac..fdad324b216a 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -72,6 +72,7 @@ public: void testTdf123557(); void testTdf113822(); void testTdf126761(); + void testTdf140714(); CPPUNIT_TEST_SUITE(SdExportTest); @@ -105,6 +106,7 @@ public: CPPUNIT_TEST(testTdf123557); CPPUNIT_TEST(testTdf113822); CPPUNIT_TEST(testTdf126761); + CPPUNIT_TEST(testTdf140714); CPPUNIT_TEST_SUITE_END(); @@ -1213,6 +1215,20 @@ void SdExportTest::testTdf126761() xDocShRef->DoClose(); } +void SdExportTest::testTdf140714() +{ + //Without the fix in place, shape will be imported as GraphicObjectShape instead of CustomShape. + + auto xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf140714.pptx"), PPTX); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + + uno::Reference xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString{"com.sun.star.drawing.CustomShape"}, xShape->getShapeType()); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit