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

Miklos Vajna vmiklos at collabora.co.uk
Tue Dec 6 09:11:58 UTC 2016


 sw/qa/extras/rtfimport/data/tdf104317.rtf   |   39 ++++++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx        |    8 +++++
 writerfilter/source/rtftok/rtfsdrimport.cxx |   18 +++++++-----
 3 files changed, 58 insertions(+), 7 deletions(-)

New commits:
commit c2e070d9a8192e7aceed64a63c716c7317843747
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Dec 6 09:22:53 2016 +0100

    tdf#104317 RTF import: avoid setting CustomShapeGeometry on a line shape
    
    Even Santa Claus knows it has no such property.
    
    Change-Id: I46e27868c62fabd10c6447956e40e55962ee284b
    Reviewed-on: https://gerrit.libreoffice.org/31668
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/rtfimport/data/tdf104317.rtf b/sw/qa/extras/rtfimport/data/tdf104317.rtf
new file mode 100644
index 0000000..3f80f3f
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf104317.rtf
@@ -0,0 +1,39 @@
+{\rtf1\ansi\ansicpg1251\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1049\deflangfe1049
+{\shp
+{\*\shpinst\shpleft5940\shptop8200\shpright5940\shpbottom8480\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz37\shplid1064
+{\sp
+{\sn shapeType}
+{\sv 20}
+}
+{\sp
+{\sn fFlipV}
+{\sv 1}
+}
+{\sp
+{\sn fShadow}
+{\sv 0}
+}
+{\sp
+{\sn posrelh}
+{\sv 1}
+}
+{\sp
+{\sn posrelv}
+{\sv 1}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 0}
+}
+{\sp
+{\sn fBehindDocument}
+{\sv 1}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 0}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 344a3a4..2f554e1 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2713,6 +2713,14 @@ DECLARE_RTFIMPORT_TEST(testTdf90697, "tdf90697.rtf")
     CPPUNIT_ASSERT_EQUAL(1, getPages());
 }
 
+DECLARE_RTFIMPORT_TEST(testTdf104317, "tdf104317.rtf")
+{
+    // This failed to load, we tried to set CustomShapeGeometry on a line shape.
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDrawPage->getCount());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 61cde99..fa05c83 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -941,13 +941,17 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
 
         if (obFlipH == true || obFlipV == true)
         {
-            // This has to be set after position and size is set, otherwise flip will affect the position.
-            comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
-            if (obFlipH == true)
-                aCustomShapeGeometry["MirroredX"] <<= true;
-            if (obFlipV == true)
-                aCustomShapeGeometry["MirroredY"] <<= true;
-            xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList()));
+            // Line shapes have no CustomShapeGeometry.
+            if (nType != ESCHER_ShpInst_Line)
+            {
+                // This has to be set after position and size is set, otherwise flip will affect the position.
+                comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
+                if (obFlipH == true)
+                    aCustomShapeGeometry["MirroredX"] <<= true;
+                if (obFlipV == true)
+                    aCustomShapeGeometry["MirroredY"] <<= true;
+                xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList()));
+            }
         }
 
         if (rShape.nHoriOrientRelation != 0)


More information about the Libreoffice-commits mailing list