summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorPaul Trojahn <paul.trojahn@gmail.com>2017-08-17 20:04:27 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2017-08-24 16:25:33 +0200
commit73ee631e58f392415f23e98460ff4b2f3a763d37 (patch)
treec1ae241bb6a8de62a88ab02b48643eaed747338b /oox
parentdffdc0b1995e2b24304ce0651ca886bbf9cf4f95 (diff)
tdf#111798 Fix deformed export of flipped custom shapes to pptx
Shapes were deformed because flipping wasn't considered when removing the rotation. Also WriteShapeTransformation needs information about flipping to convert the angle correctly. Change-Id: I7d485e93c00e02b9ec6c73ad6ae2876e5bc6360a Reviewed-on: https://gerrit.libreoffice.org/41462 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx15
-rw-r--r--oox/source/export/shapes.cxx6
2 files changed, 13 insertions, 8 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index aec1aaecc6a5..3d5a7ace8262 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1157,11 +1157,6 @@ void DrawingML::WriteStretch( const css::uno::Reference< css::beans::XPropertySe
void DrawingML::WriteTransformation( const tools::Rectangle& rRect,
sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, sal_Int32 nRotation )
{
- //OOXML flips shapes before rotating them.
- if(bFlipH)
- nRotation = nRotation * -1 + 60000*360;
- if(bFlipV)
- nRotation = nRotation * -1 + 60000*360;
mpFS->startElementNS( nXmlNamespace, XML_xfrm,
XML_flipH, bFlipH ? "1" : nullptr,
@@ -1183,7 +1178,7 @@ void DrawingML::WriteTransformation( const tools::Rectangle& rRect,
mpFS->endElementNS( nXmlNamespace, XML_xfrm );
}
-void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, bool bSuppressRotation )
+void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, bool bSuppressRotation, bool bSuppressFlipping )
{
SAL_INFO("oox.shape", "write shape transformation");
@@ -1220,6 +1215,14 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
if (xPropertySetInfo->hasPropertyByName("RotateAngle"))
xPropertySet->getPropertyValue("RotateAngle") >>= nRotation;
}
+
+ // OOXML flips shapes before rotating them.
+ if(bFlipH != bFlipV)
+ nRotation = nRotation * -1 + 36000;
+
+ if(bSuppressFlipping)
+ bFlipH = bFlipV = false;
+
WriteTransformation( tools::Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), nXmlNamespace, bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation) );
}
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index b5d4a450b94b..df34231a225b 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -823,7 +823,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
if (bHasHandles && bCustGeom && pShape)
{
- WriteShapeTransformation( xShape, XML_a ); // do not flip, polypolygon coordinates are flipped already
+ WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, false, true );// do not flip, polypolygon coordinates are flipped already
tools::PolyPolygon aPolyPolygon( pShape->GetLineGeometry(true) );
sal_Int32 nRotation = 0;
// The RotateAngle property's value is independent from any flipping, and that's exactly what we need here.
@@ -831,8 +831,10 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
if (xPropertySetInfo->hasPropertyByName("RotateAngle"))
xPropertySet->getPropertyValue("RotateAngle") >>= nRotation;
+ // Remove rotation
+ bool bInvertRotation = bFlipH != bFlipV;
if (nRotation != 0)
- aPolyPolygon.Rotate(Point(0,0), static_cast<sal_uInt16>(3600-nRotation/10));
+ aPolyPolygon.Rotate(Point(0,0), static_cast<sal_uInt16>(bInvertRotation ? nRotation/10 : 3600-nRotation/10));
WritePolyPolygon( aPolyPolygon );
}
else if (bCustGeom)