diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-21 11:44:22 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-21 12:37:15 +0100 |
commit | 6c4f737ec88a4f4dc5da8b2295ca5e7de2d4c24f (patch) | |
tree | 2c378201a71937f9e80deb795d8e4079e3087fdb /oox | |
parent | 6eac9deadd9fb6d0c547791e3a8ae4f9a4d33de4 (diff) |
DOCX drawingML shape import: fix position when CustomShapeGeometry is set
DOCX drawingML shapes had wrong position if they had their
CustomShapeGeometry set (e.g. flipped). This wasn't a problem for VML
shapes, as there the shape knows its position, and position was always
set in oox as well, not in writerfilter. However, in case of WPS shapes,
oox created the shape, and previously writerfilter set the position
after-the-fact. This leads to incorrect results if CustomShapeGeometry
is involved. Fix this by passing the position from writerfilter to oox,
and call setPosition() after creation, but before CustomShapeGeometry is
set.
The other problem was that normally writerfilter learns the position of
the shape when relevant token in GraphicImport::lcl_sprm() arrives, but
this happens after OOXMLFastContextHandlerShape::sendShape() needs that
information. Work around this by accessing the PositionHandler directly.
Change-Id: Iced35dc9467ef77c41f1897f124729f686bd045e
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/shape.cxx | 18 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.cxx | 11 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.hxx | 4 | ||||
-rw-r--r-- | oox/source/shape/WpsContext.cxx | 1 |
4 files changed, 34 insertions, 0 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 54db7bb73fb8..f93a4c4e980c 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -96,6 +96,7 @@ Shape::Shape( const sal_Char* pServiceName ) , mbHidden( false ) , mbHiddenMasterShape( false ) , mbLockedCanvas( false ) +, mbWps( false ) , maDiagramDoms( 0 ) { if ( pServiceName ) @@ -132,6 +133,7 @@ Shape::Shape( const ShapePtr& pSourceShape ) , mbHidden( pSourceShape->mbHidden ) , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape ) , mbLockedCanvas( pSourceShape->mbLockedCanvas ) +, mbWps( pSourceShape->mbWps ) , maDiagramDoms( pSourceShape->maDiagramDoms ) {} @@ -259,6 +261,16 @@ bool Shape::getLockedCanvas() return mbLockedCanvas; } +void Shape::setWps(bool bWps) +{ + mbWps = bWps; +} + +bool Shape::getWps() +{ + return mbWps; +} + void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText ) { SAL_INFO("oox", OSL_THIS_FUNC << "apply shape reference: " << rReferencedShape.msId << " to shape id: " << msId); @@ -607,6 +619,12 @@ Reference< XShape > Shape::createAndInsert( } } + // These can have a custom geometry, so position should be set here, + // after creation but before custom shape handling, using the position + // we got from the caller. + if (mbWps) + mxShape->setPosition(maPosition); + if( bIsCustomShape ) { if ( mbFlipH ) diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index 4af1ab04ff2f..bcf43c85542d 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -426,6 +426,7 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException) if (pShape) { basegfx::B2DHomMatrix aMatrix; + pShape->setPosition(maPosition); pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties()); xResult = pShape->getXShape(); mxWpsContext.clear(); @@ -512,6 +513,16 @@ void SAL_CALL ShapeContextHandler::setStartToken( ::sal_Int32 _starttoken ) thro } +awt::Point SAL_CALL ShapeContextHandler::getPosition() throw (uno::RuntimeException) +{ + return maPosition; +} + +void SAL_CALL ShapeContextHandler::setPosition(const awt::Point& rPosition) throw (uno::RuntimeException) +{ + maPosition = rPosition; +} + OUString ShapeContextHandler::getImplementationName() throw (css::uno::RuntimeException) { diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx index 11fdc0b5d6bb..0c213131fee4 100644 --- a/oox/source/shape/ShapeContextHandler.hxx +++ b/oox/source/shape/ShapeContextHandler.hxx @@ -134,11 +134,15 @@ public: virtual ::sal_Int32 SAL_CALL getStartToken() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setStartToken( ::sal_Int32 _starttoken ) throw (::com::sun::star::uno::RuntimeException); + virtual css::awt::Point SAL_CALL getPosition() throw (css::uno::RuntimeException); + virtual void SAL_CALL setPosition(const css::awt::Point& rPosition) throw (css::uno::RuntimeException); + private: ShapeContextHandler(ShapeContextHandler &); // not defined void operator =(ShapeContextHandler &); // not defined ::sal_uInt32 mnStartToken; + css::awt::Point maPosition; css::uno::Reference< css::uno::XComponentContext > m_xContext; drawingml::ShapePtr mpShape; diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index 8f4987ab09a0..92c1a088f237 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -19,6 +19,7 @@ WpsContext::WpsContext(ContextHandler2Helper& rParent) : ContextHandler2(rParent) { mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape")); + mpShape->setWps(true); } WpsContext::~WpsContext() |