From 7774d01891df6787058677dee4bc449cd5841c59 Mon Sep 17 00:00:00 2001 From: Regényi Balázs Date: Mon, 26 Oct 2020 11:52:29 +0100 Subject: tdf#137765 DOCX VML shape import: fix rotation handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I78c89d4f795a67ff44ae9cef9daf44bf9f1d5c8a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104807 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh --- oox/source/vml/vmlshape.cxx | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'oox/source/vml') diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 43b54a658db6..a83cb6b2c76c 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -679,7 +679,8 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes awt::Rectangle aShapeRect(rShapeRect); std::optional oRotation; bool bFlipX = false, bFlipY = false; - if (!maTypeModel.maRotation.isEmpty()) + // tdf#137765: skip this rotation for line shapes + if (!maTypeModel.maRotation.isEmpty() && maService != "com.sun.star.drawing.LineShape") oRotation = ConversionHelper::decodeRotation(maTypeModel.maRotation); if (!maTypeModel.maFlip.isEmpty()) { @@ -1035,6 +1036,22 @@ namespace } } } + + void handleRotation(const ShapeTypeModel& rTypeModel, Reference& rxShape) + { + if (!rTypeModel.maRotation.isEmpty()) + { + if (SdrObject* pShape = GetSdrObjectFromXShape(rxShape)) + { + // -1 is required because the direction of MSO rotation is the opposite of ours + // 100 is required because in this part of the code the angle is in a hundredth of + // degrees. + auto nAngle = -1 * 100.0 * rTypeModel.maRotation.toDouble(); + double nHRad = nAngle * F_PI18000; + pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle, sin(nHRad), cos(nHRad)); + } + } + } } LineShape::LineShape(Drawing& rDrawing) @@ -1045,6 +1062,8 @@ LineShape::LineShape(Drawing& rDrawing) Reference LineShape::implConvertAndInsert(const Reference& rxShapes, const awt::Rectangle& rShapeRect) const { Reference xShape = SimpleShape::implConvertAndInsert(rxShapes, rShapeRect); + // tdf#137765 + handleRotation(maTypeModel, xShape); // tdf#97517 tdf#137678 // The MirroredX and MirroredY properties (in the CustomShapeGeometry property) are not // supported for the LineShape by UNO, so we have to make the mirroring here. @@ -1174,18 +1193,7 @@ Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes // tdf#105875 handle rotation // Note: must rotate before flip! - if (!maTypeModel.maRotation.isEmpty()) - { - if (SdrObject* pShape = GetSdrObjectFromXShape(xShape)) - { - // -1 is required because the direction of MSO rotation is the opposite of ours - // 100 is required because in this part of the code the angle is in a hundredth of - // degrees. - auto nAngle = -1 * 100.0 * maTypeModel.maRotation.toDouble(); - double nHRad = nAngle * F_PI18000; - pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle, sin(nHRad), cos(nHRad)); - } - } + handleRotation(maTypeModel, xShape); // Handle horizontal and vertical flip. handleMirroring(maTypeModel, xShape); -- cgit