[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - oox/qa oox/source

Regina Henschel (via logerrit) logerrit at kemper.freedesktop.org
Tue May 25 12:16:22 UTC 2021


 oox/qa/unit/data/tdf137314_vml_rotation_unit_fd.docx |binary
 oox/qa/unit/vml.cxx                                  |   23 +++++++++++++++++++
 oox/source/vml/vmlshape.cxx                          |    7 ++---
 3 files changed, 26 insertions(+), 4 deletions(-)

New commits:
commit 0cc664f82535eb33b811e23fa3229b10f2c2bf95
Author:     Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Mon May 24 23:25:58 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue May 25 14:15:47 2021 +0200

    tdf#137314 apply conversion from vml angle unit 'fd'
    
    Fixes wrong rotation in tdf#109129 and tdf#142432 too, but they have
    further, unrelated errors.
    
    Change-Id: I7bd56876bb42b261fe425f80cf9beb639c3ac276
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116078
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.henschel at t-online.de>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116094

diff --git a/oox/qa/unit/data/tdf137314_vml_rotation_unit_fd.docx b/oox/qa/unit/data/tdf137314_vml_rotation_unit_fd.docx
new file mode 100644
index 000000000000..17c8cabc0ce9
Binary files /dev/null and b/oox/qa/unit/data/tdf137314_vml_rotation_unit_fd.docx differ
diff --git a/oox/qa/unit/vml.cxx b/oox/qa/unit/vml.cxx
index ec64a08c3fcf..94e73459d995 100644
--- a/oox/qa/unit/vml.cxx
+++ b/oox/qa/unit/vml.cxx
@@ -12,6 +12,7 @@
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -55,6 +56,28 @@ void OoxVmlTest::load(const OUString& rFileName)
     mxComponent = loadFromDesktop(aURL);
 }
 
+CPPUNIT_TEST_FIXTURE(OoxVmlTest, tdf137314_vml_rotation_unit_fd)
+{
+    // Load a document with a 30deg rotated arc on a drawing canvas. Rotation is given
+    // as 1966080fd. Error was, that the vml angle unit "fd" was not converted to Degree100.
+    load(u"tdf137314_vml_rotation_unit_fd.docx");
+    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+                                                 uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xGroup(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<drawing::XShape> xShape(xGroup->getByIndex(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+    drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords;
+    xShapeProps->getPropertyValue("PolyPolygonBezier") >>= aPolyPolygonBezierCoords;
+    drawing::PointSequence aPolygon = aPolyPolygonBezierCoords.Coordinates[1];
+    // Without fix in place, the vector was -1441|1490.
+    // [1] and [2] are Bezier-curve control points.
+    sal_Int32 nDiffX = aPolygon[3].X - aPolygon[0].X;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1490), nDiffX);
+    sal_Int32 nDiffY = aPolygon[3].Y - aPolygon[0].Y;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1441), nDiffY);
+}
+
 CPPUNIT_TEST_FIXTURE(OoxVmlTest, testSpt202ShapeType)
 {
     // Load a document with a groupshape, 2nd child is a <v:shape>, its type has o:spt set to 202
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 5bceff932a24..4ce5ffb30a34 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1079,10 +1079,9 @@ namespace
         {
             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();
+                // The needed factor -1 for opposite direction and factor 100 for Degree100 is
+                // contained in method decodeRotation().
+                auto nAngle(ConversionHelper::decodeRotation(rTypeModel.maRotation));
                 double nHRad = nAngle * F_PI18000;
                 pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle, sin(nHRad), cos(nHRad));
             }


More information about the Libreoffice-commits mailing list