[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sw/qa writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 3 10:06:26 UTC 2019


 sw/qa/extras/rtfimport/data/tdf128611.rtf   |   29 ++++++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx        |   18 +++++++++++++++++
 writerfilter/source/rtftok/rtfsdrimport.cxx |   19 ++++++++++++++++++
 3 files changed, 66 insertions(+)

New commits:
commit 888498cfc8822401d79d8a5e56e1bf502172eff7
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Nov 27 17:14:13 2019 +0100
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Dec 3 11:05:11 2019 +0100

    Related: tdf#128611 RTF import: handle vertical flip of line shapes
    
    UI uses SdrEditView::MirrorMarkedObjVertical() to flip a line shape
    vertically, handle it similarly at import time as well.
    
    Also note that this flips in-place, while the naive '*= -1' for the
    height would have an incorrect vertical position.
    
    (cherry picked from commit f9f421b7beaf117968c0dbfd84a2dad3dc85136a)
    
    Conflicts:
            sw/qa/extras/rtfimport/rtfimport.cxx
    
    Change-Id: I42b7feb5f799b99337ddec734dcf98dd1d553755
    Reviewed-on: https://gerrit.libreoffice.org/84230
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/qa/extras/rtfimport/data/tdf128611.rtf b/sw/qa/extras/rtfimport/data/tdf128611.rtf
new file mode 100644
index 000000000000..207252cd8d26
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf128611.rtf
@@ -0,0 +1,29 @@
+{\rtf1
+\paperw11906\paperh16838\margl1417\margr1417\margt1417\margb1417
+\pard\plain
+{\shp
+{\*\shpinst\shpleft-5\shptop248\shpright8933\shpbottom1838\shpfhdr0\shpbxmargin\shpbxignore\shpbymargin\shpbyignore\shpwr0\shpwrk0\shpfblwtxt0\shpz0\shplid1028
+{\sp
+{\sn shapeType}
+{\sv 20}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 1}
+}
+{\sp
+{\sn posrelh}
+{\sv 3}
+}
+}
+{\shprslt
+{\*\do\dobxmargin\dobymargin\dodhgt8192
+\dpline\dpptx8938\dppty0\dpptx0\dppty1590\dpx-5\dpy9248\dpxsize8938\dpysize1590\dplinew15\dplinecor0\dplinecog0\dplinecob0}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 334b48c80809..6fa57b6de4ce 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -857,6 +857,24 @@ DECLARE_RTFIMPORT_TEST(testOleInline, "ole-inline.rtf")
                          getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
 }
 
+DECLARE_RTFIMPORT_TEST(testTdf128611, "tdf128611.rtf")
+{
+    auto aPolyPolySequence
+        = getProperty<uno::Sequence<uno::Sequence<awt::Point>>>(getShape(1), "PolyPolygon");
+    CPPUNIT_ASSERT(aPolyPolySequence.hasElements());
+    uno::Sequence<awt::Point>& rPolygon = aPolyPolySequence[0];
+    CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(1), rPolygon.getLength());
+    sal_Int32 nY1 = rPolygon[0].Y;
+    sal_Int32 nY2 = rPolygon[1].Y;
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected greater than: 6242
+    // - Actual  : 3438
+    // i.e. the vertical flip was missing, and the y1 > y2 assert failed, because the line pointed
+    // from top left to bottom right, not bottom left to top right.
+    CPPUNIT_ASSERT_GREATER(nY2, nY1);
+}
+
 DECLARE_RTFIMPORT_TEST(testFdo80742, "fdo80742.rtf")
 {
     uno::Reference<beans::XPropertySet> xPropertySet(
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index b9e227439f4b..f543c5236659 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -44,6 +44,9 @@
 #include <oox/helper/propertyset.hxx>
 #include <boost/logic/tribool.hpp>
 #include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/unoapi.hxx>
+#include <svx/svdobj.hxx>
+
 #include <dmapper/GraphicZOrderHelper.hxx>
 #include "rtfdocumentimpl.hxx"
 
@@ -1036,6 +1039,22 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
                     "CustomShapeGeometry",
                     uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList()));
             }
+            else if (SdrObject* pObject = GetSdrObjectFromXShape(xShape))
+            {
+                Point aRef1 = pObject->GetSnapRect().Center();
+                Point aRef2(aRef1);
+                if (obFlipH == true)
+                {
+                    // Horizontal mirror means a vertical reference line.
+                    aRef2.AdjustY(1);
+                }
+                if (obFlipV == true)
+                {
+                    // Vertical mirror means a horizontal reference line.
+                    aRef2.AdjustX(1);
+                }
+                pObject->Mirror(aRef1, aRef2);
+            }
         }
 
         if (rShape.getHoriOrientRelation() != 0)


More information about the Libreoffice-commits mailing list