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

Regényi Balázs (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 26 17:22:59 UTC 2020


 include/oox/vml/vmlshape.hxx                                          |    5 +
 oox/source/vml/vmlshape.cxx                                           |   35 ++++++++--
 sw/qa/extras/ooxmlexport/data/tdf97517_testVmlLineShapeMirroredX.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx                            |   15 ++++
 4 files changed, 49 insertions(+), 6 deletions(-)

New commits:
commit ed943c6afeb33b9fee0ef530df7db592aa152a73
Author:     Regényi Balázs <regenyi.balazs at nisz.hu>
AuthorDate: Thu Oct 22 13:36:25 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Oct 26 18:22:18 2020 +0100

    tdf#97517 DOCX VML shape import: fix missing vertical mirroring
    
    The MirroredX 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: I65a1f9a115a003c056ae31f4bc217206a0e6dcd8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104656
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx
index 119f711a4538..7703b311c757 100644
--- a/include/oox/vml/vmlshape.hxx
+++ b/include/oox/vml/vmlshape.hxx
@@ -360,6 +360,11 @@ class LineShape final : public SimpleShape
 {
 public:
     explicit            LineShape( Drawing& rDrawing );
+    virtual css::uno::Reference< css::drawing::XShape >
+                        implConvertAndInsert(
+                            const css::uno::Reference< css::drawing::XShapes >& rxShapes,
+                            const css::awt::Rectangle& rShapeRect ) const override;
+
 
 private:
     /** Returns the absolute shape rectangle. */
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index d70a9563e106..54f1fcec5ae6 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1004,11 +1004,39 @@ Reference< XShape > PolyLineShape::implConvertAndInsert( const Reference< XShape
     return xShape;
 }
 
+namespace
+{
+    void doMirrorX(SdrObject* pShape)
+    {
+        Point aCenter(pShape->GetSnapRect().Center());
+        Point aPoint2(aCenter);
+        aPoint2.setY(aPoint2.getY() + 1);
+        pShape->NbcMirror(aCenter, aPoint2);
+    }
+}
+
 LineShape::LineShape(Drawing& rDrawing)
     : SimpleShape(rDrawing, "com.sun.star.drawing.LineShape")
 {
 }
 
+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);
+        }
+    }
+    return xShape;
+}
+
 awt::Rectangle LineShape::getAbsRectangle() const
 {
     const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
@@ -1150,12 +1178,7 @@ Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes
         if (SdrObject* pShape = GetSdrObjectFromXShape(xShape))
         {
             if (maTypeModel.maFlip.startsWith("x"))
-            {
-                Point aCenter(pShape->GetSnapRect().Center());
-                Point aPoint2(aCenter);
-                aPoint2.setY(aPoint2.getY() + 1);
-                pShape->NbcMirror(aCenter, aPoint2);
-            }
+                doMirrorX(pShape);
             if (maTypeModel.maFlip.endsWith("y"))
             {
                 Point aCenter(pShape->GetSnapRect().Center());
diff --git a/sw/qa/extras/ooxmlexport/data/tdf97517_testVmlLineShapeMirroredX.docx b/sw/qa/extras/ooxmlexport/data/tdf97517_testVmlLineShapeMirroredX.docx
new file mode 100644
index 000000000000..75e9d8573bb3
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf97517_testVmlLineShapeMirroredX.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 3ac228db6cca..8fa7391abcc7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
 
 #include <comphelper/sequenceashashmap.hxx>
 #include <oox/drawingml/drawingmltypes.hxx>
@@ -40,6 +41,8 @@
 #include <editsh.hxx>
 #include <frmatr.hxx>
 
+using namespace com::sun::star;
+
 char const DATA_DIRECTORY[] = "/sw/qa/extras/ooxmlexport/data/";
 
 class Test : public SwModelTestBase
@@ -1284,6 +1287,18 @@ DECLARE_OOXMLEXPORT_TEST(testVmlShapeTextWordWrap, "tdf97618_testVmlShapeTextWor
     assertXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "width", "2500");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testVmlLineShapeMirroredX, "tdf97517_testVmlLineShapeMirroredX.docx")
+{
+    // tdf#97517 The "flip:x" 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:x") > 0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list