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 /writerfilter | |
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 'writerfilter')
4 files changed, 11 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx index d2e64d23e143..433e30e37eeb 100644 --- a/writerfilter/source/dmapper/GraphicHelpers.cxx +++ b/writerfilter/source/dmapper/GraphicHelpers.cxx @@ -165,6 +165,14 @@ void PositionHandler::setPositionOffset(const OUString & sText, bool vertical) savedPositionOffsetH = ConversionHelper::convertEMUToMM100( sText.toInt32()); } +int PositionHandler::getPositionOffset(bool vertical) +{ + if (vertical) + return savedPositionOffsetV; + else + return savedPositionOffsetH; +} + void PositionHandler::setAlignH(const OUString & sText) { if( sText == "left") diff --git a/writerfilter/source/dmapper/GraphicHelpers.hxx b/writerfilter/source/dmapper/GraphicHelpers.hxx index e3e4be66a2d6..97b2652bed52 100644 --- a/writerfilter/source/dmapper/GraphicHelpers.hxx +++ b/writerfilter/source/dmapper/GraphicHelpers.hxx @@ -37,6 +37,7 @@ public: PositionHandler( bool vertical ); ~PositionHandler( ); static void setPositionOffset(const OUString & sText, bool vertical); + static int getPositionOffset(bool vertical); static void setAlignH(const OUString & sText); static void setAlignV(const OUString & sText); sal_Int16 orientation() const; diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 7c3de0075137..8d0d0cb6d975 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1000,7 +1000,6 @@ void GraphicImport::lcl_attribute(Id nName, Value & val) // This needs to be AT_PARAGRAPH and not AT_CHARACTER, otherwise shape will move when the user inserts a new paragraph. xShapeProps->setPropertyValue("AnchorType", uno::makeAny(text::TextContentAnchorType_AT_PARAGRAPH)); - m_xShape->setPosition(awt::Point(m_pImpl->nLeftPosition, m_pImpl->nTopPosition)); m_pImpl->applyMargins(xShapeProps); bool bOpaque = m_pImpl->bOpaque && !m_pImpl->rDomainMapper.IsInHeaderFooter(); if (!bOpaque) diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 9854d697ed4e..2b9be07b420e 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -2102,6 +2102,8 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t Element ) { if ( mrShapeContext.is() && !m_bShapeSent ) { + awt::Point aPosition(writerfilter::dmapper::PositionHandler::getPositionOffset(false), writerfilter::dmapper::PositionHandler::getPositionOffset(true)); + mrShapeContext->setPosition(aPosition); uno::Reference<drawing::XShape> xShape(mrShapeContext->getShape()); if (xShape.is()) { |