[Libreoffice-commits] core.git: oox/source sw/qa

Regényi Balázs (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 27 13:06:35 UTC 2020


 oox/source/vml/vmlshape.cxx                                            |   53 +++++-----
 sw/qa/extras/ooxmlexport/data/tdf137678_testVmlLineShapeMirroredY.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx                             |   12 ++
 3 files changed, 39 insertions(+), 26 deletions(-)

New commits:
commit ca83804ffcd0d6f81fa7c32be990c4ceeb4a60b7
Author:     Regényi Balázs <regenyi.balazs at nisz.hu>
AuthorDate: Thu Oct 22 16:12:11 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Tue Oct 27 14:05:55 2020 +0100

    tdf#137678 DOCX VML shape import: fix missing horizontal mirroring
    
    The MirroredY property is set (in the CustomShapeGeometry property), but
    it is not supported for the LineShape by UNO, so we have to make the
    mirroring during importing.
    
    Change-Id: Iaa7e3a352598ad12c5e0d40b4fcd43fd197c4df9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104662
    Tested-by: Jenkins
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 54f1fcec5ae6..43b54a658db6 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1013,6 +1013,28 @@ namespace
         aPoint2.setY(aPoint2.getY() + 1);
         pShape->NbcMirror(aCenter, aPoint2);
     }
+
+    void doMirrorY(SdrObject* pShape)
+    {
+        Point aCenter(pShape->GetSnapRect().Center());
+        Point aPoint2(aCenter);
+        aPoint2.setX(aPoint2.getX() + 1);
+        pShape->NbcMirror(aCenter, aPoint2);
+    }
+
+    void handleMirroring(const ShapeTypeModel& rTypeModel, Reference<XShape>& rxShape)
+    {
+        if (!rTypeModel.maFlip.isEmpty())
+        {
+            if (SdrObject* pShape = GetSdrObjectFromXShape(rxShape))
+            {
+                if (rTypeModel.maFlip.startsWith("x"))
+                    doMirrorX(pShape);
+                if (rTypeModel.maFlip.endsWith("y"))
+                    doMirrorY(pShape);
+            }
+        }
+    }
 }
 
 LineShape::LineShape(Drawing& rDrawing)
@@ -1023,17 +1045,10 @@ LineShape::LineShape(Drawing& rDrawing)
 Reference<XShape> LineShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const awt::Rectangle& rShapeRect) const
 {
     Reference<XShape> xShape = SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
-    // Handle vertical flip.
-    // tdf#97517 The MirroredX property (in the CustomShapeGeometry property) is not supported for
-    // the LineShape by UNO, so we have to make the mirroring here
-    if (!maTypeModel.maFlip.isEmpty())
-    {
-        if (SdrObject* pShape = GetSdrObjectFromXShape(xShape))
-        {
-            if (maTypeModel.maFlip.startsWith("x"))
-                doMirrorX(pShape);
-        }
-    }
+    // 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.
+    handleMirroring(maTypeModel, xShape);
     return xShape;
 }
 
@@ -1173,21 +1188,7 @@ Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes
     }
 
     // Handle horizontal and vertical flip.
-    if (!maTypeModel.maFlip.isEmpty())
-    {
-        if (SdrObject* pShape = GetSdrObjectFromXShape(xShape))
-        {
-            if (maTypeModel.maFlip.startsWith("x"))
-                doMirrorX(pShape);
-            if (maTypeModel.maFlip.endsWith("y"))
-            {
-                Point aCenter(pShape->GetSnapRect().Center());
-                Point aPoint2(aCenter);
-                aPoint2.setX(aPoint2.getX() + 1);
-                pShape->NbcMirror(aCenter, aPoint2);
-            }
-        }
-    }
+    handleMirroring(maTypeModel, xShape);
 
     return xShape;
 }
diff --git a/sw/qa/extras/ooxmlexport/data/tdf137678_testVmlLineShapeMirroredY.docx b/sw/qa/extras/ooxmlexport/data/tdf137678_testVmlLineShapeMirroredY.docx
new file mode 100644
index 000000000000..1559358b562b
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf137678_testVmlLineShapeMirroredY.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 8fa7391abcc7..ba955f016cce 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1299,6 +1299,18 @@ DECLARE_OOXMLEXPORT_TEST(testVmlLineShapeMirroredX, "tdf97517_testVmlLineShapeMi
     CPPUNIT_ASSERT(sStyle.indexOf("flip:x") > 0);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testVmlLineShapeMirroredY, "tdf137678_testVmlLineShapeMirroredY.docx")
+{
+    // tdf#137678 The "flip:y" was not handled for VML line shapes.
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+        return;
+    OUString sStyle = getXPath(pXmlDoc,
+        "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:line",
+        "style");
+    CPPUNIT_ASSERT(sStyle.indexOf("flip:y") > 0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list