diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-26 09:33:56 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-05-02 17:34:44 +0200 |
commit | 40be6ee10a64ea1546579cdef9241ddc0381fe0d (patch) | |
tree | a500ee62572ac42672aafee2974c066a90af24b3 /writerfilter | |
parent | 0380e89ca16906ae41219244ba7d419a9d126912 (diff) |
tdf#90097 RTF import: handle fRelFlipV property for line shapes
Can be extended later in every direction: fFlipV, fRelFlipH, non-line
shapes. See oox::drawingml::Shape::createAndInsert() on why the
convertMm100ToTwip() conversion is necessary.
Change-Id: Ifee401dd8dd392c2c9ff85cc871ca0169fcf930b
Reviewed-on: https://gerrit.libreoffice.org/24385
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 6046062719f30849cd97161c6a89d27a0b0d2a20)
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/Library_writerfilter.mk | 1 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfsdrimport.cxx | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk index c81ff5651e05..5ec43d2b0937 100644 --- a/writerfilter/Library_writerfilter.mk +++ b/writerfilter/Library_writerfilter.mk @@ -35,6 +35,7 @@ $(eval $(call gb_Library_add_defs,writerfilter,\ )) $(eval $(call gb_Library_use_libraries,writerfilter,\ + basegfx \ comphelper \ cppu \ cppuhelper \ diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index fcc20d4ee421..32846edd7c4b 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -33,6 +33,7 @@ #include <oox/drawingml/shapepropertymap.hxx> #include <oox/helper/propertyset.hxx> #include <boost/logic/tribool.hpp> +#include <basegfx/matrix/b2dhommatrix.hxx> using namespace com::sun::star; @@ -346,6 +347,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap boost::optional<sal_Int16> oRelativeWidth, oRelativeHeight; sal_Int16 nRelativeWidthRelation = text::RelOrientation::PAGE_FRAME; sal_Int16 nRelativeHeightRelation = text::RelOrientation::PAGE_FRAME; + boost::logic::tribool obRelFlipV(boost::logic::indeterminate); bool bCustom(false); int const nType = initShape(xShape, xPropertySet, bCustom, rShape, bClose, shapeOrPict); @@ -778,6 +780,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap while (nCharIndex >= 0); rShape.aWrapPolygonSprms = aPolygonSprms; } + else if (i->first == "fRelFlipV") + obRelFlipV = i->second.toInt32() == 1; else SAL_INFO("writerfilter", "TODO handle shape property '" << i->first << "':'" << i->second << "'"); } @@ -836,6 +840,33 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap } if (!aGeometry.empty() && xPropertySet.is() && !m_bTextFrame) xPropertySet->setPropertyValue("CustomShapeGeometry", uno::Any(comphelper::containerToSequence(aGeometry))); + if (!boost::logic::indeterminate(obRelFlipV) && xPropertySet.is()) + { + if (nType == ESCHER_ShpInst_Line) + { + // Line shape inside group shape: get the polygon sequence and transform it. + uno::Sequence< uno::Sequence<awt::Point> > aPolyPolySequence; + if ((xPropertySet->getPropertyValue("PolyPolygon") >>= aPolyPolySequence) && aPolyPolySequence.hasElements()) + { + uno::Sequence<awt::Point>& rPolygon = aPolyPolySequence[0]; + basegfx::B2DPolygon aPoly; + for (sal_Int32 i = 0; i < rPolygon.getLength(); ++i) + { + const awt::Point& rPoint = rPolygon[i]; + aPoly.insert(i, basegfx::B2DPoint(rPoint.X, rPoint.Y)); + } + basegfx::B2DHomMatrix aTransformation; + aTransformation.scale(1.0, obRelFlipV ? -1.0 : 1.0); + aPoly.transform(aTransformation); + for (sal_Int32 i = 0; i < rPolygon.getLength(); ++i) + { + basegfx::B2DPoint aPoint(aPoly.getB2DPoint(i)); + rPolygon[i] = awt::Point(static_cast<sal_Int32>(convertMm100ToTwip(aPoint.getX())), static_cast<sal_Int32>(convertMm100ToTwip(aPoint.getY()))); + } + xPropertySet->setPropertyValue("PolyPolygon", uno::makeAny(aPolyPolySequence)); + } + } + } // Set position and size if (xShape.is()) |