diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-08-18 17:43:57 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-08-18 21:51:22 +0200 |
commit | b2d834d6727626f070bb4dde3e1c65da1169f729 (patch) | |
tree | 7fdce9d90a25aef9530357aec30556a719a27235 /oox | |
parent | 54691ea52a91491ae251473c83b61f9adaf0b581 (diff) |
tdf#132555 PPTX VML import: handle stroke properties of image shapes
ComplexShape::implConvertAndInsert() returns early in the graphic object
shape case, so stroke model is not applied at all.
Also fix a problem in ShapeBase::finalizeFragmentImport(), where the
shape type had no stroke, but the shape itself had, and the later should
win.
The warning in OleObjectGraphicDataContext::onCreateContext() now points
out that <mc:AlternateContent> is ignored as a child of <a:graphicData>,
which probably should be addressed at some stage, but it's not required
to fix the missing stroke.
Change-Id: I4ab43b4c6d40d9f43caad22b85f5b885fa8b4ef1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100952
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r-- | oox/qa/unit/data/graphic-stroke.pptx | bin | 0 -> 29396 bytes | |||
-rw-r--r-- | oox/qa/unit/vml.cxx | 32 | ||||
-rw-r--r-- | oox/source/drawingml/graphicshapecontext.cxx | 2 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 15 |
4 files changed, 49 insertions, 0 deletions
diff --git a/oox/qa/unit/data/graphic-stroke.pptx b/oox/qa/unit/data/graphic-stroke.pptx Binary files differnew file mode 100644 index 000000000000..f4465476fcc6 --- /dev/null +++ b/oox/qa/unit/data/graphic-stroke.pptx diff --git a/oox/qa/unit/vml.cxx b/oox/qa/unit/vml.cxx index 089d61085b74..d43d2d5645ae 100644 --- a/oox/qa/unit/vml.cxx +++ b/oox/qa/unit/vml.cxx @@ -11,8 +11,10 @@ #include <unotest/macros_test.hxx> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/text/WritingMode2.hpp> using namespace ::com::sun::star; @@ -109,6 +111,36 @@ CPPUNIT_TEST_FIXTURE(OoxVmlTest, testShapeNonAutosizeWithText) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5398), xShape->getSize().Width); } +CPPUNIT_TEST_FIXTURE(OoxVmlTest, testGraphicStroke) +{ + load("graphic-stroke.pptx"); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + + uno::Reference<beans::XPropertySet> xShape; + for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i) + { + uno::Reference<lang::XServiceInfo> xInfo(xDrawPage->getByIndex(i), uno::UNO_QUERY); + if (!xInfo->supportsService("com.sun.star.drawing.GraphicObjectShape")) + { + continue; + } + + xShape.set(xInfo, uno::UNO_QUERY); + break; + } + CPPUNIT_ASSERT(xShape.is()); + + drawing::LineStyle eLineStyle{}; + xShape->getPropertyValue("LineStyle") >>= eLineStyle; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // i.e. line style was NONE, not SOLID. + CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, eLineStyle); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx index 39a090bf43c4..61d96b583c67 100644 --- a/oox/source/drawingml/graphicshapecontext.cxx +++ b/oox/source/drawingml/graphicshapecontext.cxx @@ -226,6 +226,8 @@ ContextHandlerRef OleObjectGraphicDataContext::onCreateContext( sal_Int32 nEleme return new GraphicShapeContext( *this, mpMasterShapePtr, mpShapePtr ); break; } + SAL_WARN("oox", "OleObjectGraphicDataContext::onCreateContext: unhandled element: " + << getBaseToken(nElement)); return nullptr; } diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index b6fe01b08347..f22a98576a16 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -292,7 +292,15 @@ void ShapeBase::finalizeFragmentImport() if (aType[ 0 ] == '#') aType = aType.copy(1); if( const ShapeType* pShapeType = mrDrawing.getShapes().getShapeTypeById( aType ) ) + { + // Make sure that the stroke props from maTypeModel have priority over the stroke props from + // the shape type. + StrokeModel aMergedStrokeModel; + aMergedStrokeModel.assignUsed(pShapeType->getTypeModel().maStrokeModel); + aMergedStrokeModel.assignUsed(maTypeModel.maStrokeModel); maTypeModel.assignUsed( pShapeType->getTypeModel() ); + maTypeModel.maStrokeModel = aMergedStrokeModel; + } else { // Temporary fix, shapetype not found if referenced from different substream // FIXME: extend scope of ShapeContainer to store all shapetypes from the document @@ -1346,6 +1354,13 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes // AS_CHARACTER shape: vertical orientation default is bottom, MSO default is top. if ( maTypeModel.maPosition != "absolute" && maTypeModel.maPosition != "relative" ) PropertySet( xShape ).setAnyProperty( PROP_VertOrient, makeAny(text::VertOrientation::TOP)); + + // Apply stroke props from the type model. + oox::drawingml::ShapePropertyMap aPropMap(mrDrawing.getFilter().getModelObjectHelper()); + const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); + maTypeModel.maStrokeModel.pushToPropMap(aPropMap, rGraphicHelper); + PropertySet(xShape).setProperties(aPropMap); + return xShape; } |