oox/source/vml/vmlshape.cxx                                          |   34 
++++++----
 sw/qa/extras/ooxmlexport/data/tdf137765_testVmlLineShapeRotated.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx                           |   16 
++++
 3 files changed, 37 insertions(+), 13 deletions(-)

New commits:
commit 7774d01891df6787058677dee4bc449cd5841c59
Author:     Regényi Balázs <regenyi.bal...@nisz.hu>
AuthorDate: Mon Oct 26 11:52:29 2020 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Thu Oct 29 15:18:22 2020 +0100

    tdf#137765 DOCX VML shape import: fix rotation handling
    
    Change-Id: I78c89d4f795a67ff44ae9cef9daf44bf9f1d5c8a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104807
    Tested-by: Jenkins
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

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<sal_Int32> 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<XShape>& 
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<XShape> LineShape::implConvertAndInsert(const Reference<XShapes>& 
rxShapes, const awt::Rectangle& rShapeRect) const
 {
     Reference<XShape> 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);
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf137765_testVmlLineShapeRotated.docx 
b/sw/qa/extras/ooxmlexport/data/tdf137765_testVmlLineShapeRotated.docx
new file mode 100644
index 000000000000..d411d7cda6fe
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf137765_testVmlLineShapeRotated.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index d38b5cfcd605..d7d76898c86a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1313,6 +1313,22 @@ DECLARE_OOXMLEXPORT_TEST(testVmlLineShapeMirroredY, 
"tdf137678_testVmlLineShapeM
     CPPUNIT_ASSERT(sStyle.indexOf("flip:y") > 0);
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testVmlLineShapeRotated, 
"tdf137765_testVmlLineShapeRotated.docx")
+{
+    // tdf#137765 The "rotation" (in style attribute) was not handled 
correctly for VML line shapes.
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    // it was 1.55pt,279.5pt
+    assertXPath(pXmlDoc,
+        
"/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:line",
+        "from",
+        "-9pt,296.75pt");
+    // it was 25.5pt,317.8pt
+    assertXPath(pXmlDoc,
+        
"/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:line",
+        "to",
+        "36.05pt,300.55pt");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to