oox/inc/drawingml/customshapeproperties.hxx | 6 +++ oox/qa/unit/data/testTdf132557_footerCustomShapes.pptx |binary oox/qa/unit/drawingml.cxx | 29 +++++++++++++++++ oox/source/drawingml/customshapeproperties.cxx | 7 ++++ oox/source/drawingml/shape.cxx | 4 -- oox/source/ppt/pptshape.cxx | 15 ++++++++ 6 files changed, 58 insertions(+), 3 deletions(-)
New commits: commit 3a0140dac3017fa31bb9ef0824bb006729d56bf5 Author: Sarper Akdemir <[email protected]> AuthorDate: Mon Feb 14 07:33:56 2022 +0300 Commit: Andras Timar <[email protected]> CommitDate: Fri Apr 1 13:40:02 2022 +0200 tdf#132557: PPTX import: Workaround for slide footer shape presets It appears that placeholder shapes with service names: - com.sun.star.presentation.TitleTextShape - com.sun.star.presentation.DateTimeShape - com.sun.star.presentation.FooterShape - com.sun.star.presentation.SlideNumberShape ... Are unable to have custom shapes in Impress. (i.e. can't be ellipse, triangle etc.). These presets get specified in OOXML with <a:prstGeom prst="ellipse"/> inside spPr (shape properties). Therefore with similar results to the PPT import, a workaround is applied where slide footers which have non default shapes are imported with com.sun.star.drawing.CustomShapes service. The layout/master footers are left as is since if they were to be imported as CustomShapes they would appear on each slide even if the slide had those footers enabled or not. Change-Id: Ic8a8ab3f6dfb7367ecd2c619ce888bf77abef460 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129891 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Andras Timar <[email protected]> diff --git a/oox/inc/drawingml/customshapeproperties.hxx b/oox/inc/drawingml/customshapeproperties.hxx index 1dc0270614e0..5b1b01e97770 100644 --- a/oox/inc/drawingml/customshapeproperties.hxx +++ b/oox/inc/drawingml/customshapeproperties.hxx @@ -125,6 +125,12 @@ public: sal_Int32 getArcNum() { return mnArcNum++; } + /** + Returns whether or not the current CustomShapeProperties + represent a default shape preset that is rectangular. + */ + bool representsDefaultShape() const; + private: sal_Int32 mnShapePresetType; diff --git a/oox/qa/unit/data/testTdf132557_footerCustomShapes.pptx b/oox/qa/unit/data/testTdf132557_footerCustomShapes.pptx new file mode 100755 index 000000000000..4dbf3717d1fd Binary files /dev/null and b/oox/qa/unit/data/testTdf132557_footerCustomShapes.pptx differ diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx index 66c95e366460..363b58e3d36e 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -360,6 +360,35 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTableShadow) verify(getComponent()); } +CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTdf132557_footerCustomShapes) +{ + // slide with date, footer, slide number with custom shapes + OUString aURL + = m_directories.getURLFromSrc(DATA_DIRECTORY) + "testTdf132557_footerCustomShapes.pptx"; + // When importing the document: + load(aURL); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + + // Test if we were able to import the footer shapes with CustomShape service. + uno::Reference<drawing::XShape> xShapeDateTime(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), + xShapeDateTime->getShapeType()); + // Without the accompanying fix in place, this test would have failed with: + // An uncaught exception of type com.sun.star.lang.IndexOutOfBoundsException + // i.e. the shape wasn't on the slide there since it was imported as a property, not a shape. + + uno::Reference<drawing::XShape> xShapeFooter(xDrawPage->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), + xShapeFooter->getShapeType()); + + uno::Reference<drawing::XShape> xShapeSlideNum(xDrawPage->getByIndex(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.CustomShape"), + xShapeSlideNum->getShapeType()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index 4a6e3d9eae6d..0beb6a172b5f 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -89,6 +89,13 @@ sal_Int32 CustomShapeProperties::GetCustomShapeGuideValue( const std::vector< Cu return nIndex; } +bool CustomShapeProperties::representsDefaultShape() const +{ + return !((getShapePresetType() >= 0 || maPath2DList.size() > 0) && + getShapePresetType() != XML_Rect && + getShapePresetType() != XML_rect); +} + CustomShapeProperties::PresetDataMap CustomShapeProperties::maPresetDataMap; static OUString GetConnectorShapeType( sal_Int32 nType ) diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index fbf8c9c02eec..3f45859e818f 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -727,9 +727,7 @@ 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->getPath2DList().size() > 0) && - mpCustomShapePropertiesPtr->getShapePresetType() != XML_Rect && - mpCustomShapePropertiesPtr->getShapePresetType() != XML_rect); + !mpCustomShapePropertiesPtr->representsDefaultShape()); bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" || aServiceName == "com.sun.star.drawing.ConnectorShape" || bIsCroppedGraphic); diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 533b49ac8b6f..6208a7107f23 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -19,6 +19,7 @@ #include <oox/ppt/pptshape.hxx> #include <oox/core/xmlfilterbase.hxx> +#include <drawingml/customshapeproperties.hxx> #include <drawingml/textbody.hxx> #include <drawingml/textparagraph.hxx> #include <drawingml/textfield.hxx> @@ -142,6 +143,10 @@ bool PPTShape::IsPlaceHolderCandidate(const SlidePersist& rSlidePersist) const return false; if (rParagraphs.front()->getRuns().size() != 1) return false; + // If the placeholder has a shape other than rectangle, + // we have to place it in the slide as a CustomShape. + if (!mpCustomShapePropertiesPtr->representsDefaultShape()) + return false; return ShapeHasNoVisualPropertiesOnImport(*this); } @@ -320,6 +325,16 @@ void PPTShape::addShape( } } + // Since it is not possible to represent custom shaped placeholders in Impress + // Need to use service name css.drawing.CustomShape if they have a non default shape. + // This workaround has the drawback of them not really being processed as placeholders + // so it is only done for slide footers... + if ((mnSubType == XML_sldNum || mnSubType == XML_dt || mnSubType == XML_ftr) + && meShapeLocation == Slide && !mpCustomShapePropertiesPtr->representsDefaultShape()) + { + sServiceName = "com.sun.star.drawing.CustomShape"; + } + if (sServiceName != "com.sun.star.drawing.TableShape") { if (TextBodyPtr pTextBody = getTextBody())
