diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-26 09:33:56 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-26 09:35:50 +0000 |
commit | 6046062719f30849cd97161c6a89d27a0b0d2a20 (patch) | |
tree | 7fd48bb6b77a15c3c7904c29a3631d341ecb6f5b /writerfilter/source/rtftok/rtfsdrimport.cxx | |
parent | 5538066d349eac50c561c1e68cd8c8749c39dbb9 (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>
Diffstat (limited to 'writerfilter/source/rtftok/rtfsdrimport.cxx')
-rw-r--r-- | writerfilter/source/rtftok/rtfsdrimport.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 0c67801ec32e..626d2a4c3f5f 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()) |