diff options
-rw-r--r-- | oox/inc/drawingml/customshapeproperties.hxx | 6 | ||||
-rwxr-xr-x | oox/qa/unit/data/testTdf132557_footerCustomShapes.pptx | bin | 0 -> 20137 bytes | |||
-rw-r--r-- | oox/qa/unit/drawingml.cxx | 29 | ||||
-rw-r--r-- | oox/source/drawingml/customshapeproperties.cxx | 7 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 5 | ||||
-rw-r--r-- | oox/source/ppt/pptshape.cxx | 15 |
6 files changed, 59 insertions, 3 deletions
diff --git a/oox/inc/drawingml/customshapeproperties.hxx b/oox/inc/drawingml/customshapeproperties.hxx index a8f4c19b051b..153858fdaf45 100644 --- a/oox/inc/drawingml/customshapeproperties.hxx +++ b/oox/inc/drawingml/customshapeproperties.hxx @@ -124,6 +124,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 Binary files differnew file mode 100755 index 000000000000..4dbf3717d1fd --- /dev/null +++ b/oox/qa/unit/data/testTdf132557_footerCustomShapes.pptx diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx index 3362acb3c8c6..6d53c3ab7bd9 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -400,6 +400,35 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testChartThemeOverride) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x4472C4), nActual); } +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 1b4d6b4a59f6..29cfc0d1cd88 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -86,6 +86,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 16fdd04b3d76..1d45b481f407 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -746,9 +746,8 @@ 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()); + // ToDo: Why is ConnectorShape here treated as custom shape, but below with start and end point? bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" || aServiceName == "com.sun.star.drawing.ConnectorShape" || diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 7e294f197fe1..ca888e4c17c1 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> @@ -140,6 +141,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); } @@ -317,6 +322,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"; + } + SAL_INFO("oox.ppt","shape service: " << sServiceName); if (mnSubType && getSubTypeIndex().has() && meShapeLocation == Layout) |