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

Miklos Vajna vmiklos at collabora.co.uk
Thu Jun 16 08:32:50 UTC 2016


 sw/qa/extras/rtfimport/data/flip.rtf        |   96 ++++++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx        |   20 +++++
 writerfilter/source/rtftok/rtfsdrimport.cxx |   17 ++++
 3 files changed, 133 insertions(+)

New commits:
commit 63965d7dc571c7dce999980737f9d57a7c5151da
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jun 16 09:13:04 2016 +0200

    tdf#91684 RTF import: handle fFlipH and fFlipV shape props
    
    Change-Id: I930f99647de00c2e43ef94b1ac0320daa440eae9
    Reviewed-on: https://gerrit.libreoffice.org/26349
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/rtfimport/data/flip.rtf b/sw/qa/extras/rtfimport/data/flip.rtf
new file mode 100644
index 0000000..84e9c2c
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/flip.rtf
@@ -0,0 +1,96 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0
+\f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid12721412
+{\shp
+{\*\shpinst\shpleft537\shptop201\shpright2361\shpbottom1136\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 6}
+}
+{\sp
+{\sn fFlipH}
+{\sv 1}
+}
+{\sp
+{\sn fFlipV}
+{\sv 1}
+}
+{\sp
+{\sn wzName}
+{\sv h-and-v}
+}
+}
+{\shprslt
+}
+}
+{\shp
+{\*\shpinst\shpleft537\shptop1201\shpright2361\shpbottom2136\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 6}
+}
+{\sp
+{\sn fFlipH}
+{\sv 1}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn wzName}
+{\sv h-only}
+}
+}
+{\shprslt
+}
+}
+{\shp
+{\*\shpinst\shpleft537\shptop2201\shpright2361\shpbottom3136\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 6}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 1}
+}
+{\sp
+{\sn wzName}
+{\sv v-only}
+}
+}
+{\shprslt
+}
+}
+{\shp
+{\*\shpinst\shpleft537\shptop3201\shpright2361\shpbottom4136\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 6}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn wzName}
+{\sv neither-h-nor-v}
+}
+}
+{\shprslt
+}
+}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid13321744
+\par }
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 6bc62c7..73096c8 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2641,6 +2641,26 @@ DECLARE_RTFIMPORT_TEST(testTdf91684, "tdf91684.rtf")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1337), getShape(1)->getSize().Height);
 }
 
+DECLARE_RTFIMPORT_TEST(testFlip, "flip.rtf")
+{
+    comphelper::SequenceAsHashMap aMap = getProperty< uno::Sequence<beans::PropertyValue> >(getShapeByName("h-and-v"), "CustomShapeGeometry");
+    // This resulted in a uno::RuntimeException, as MirroredX wasn't set at all, so could not extract void to boolean.
+    CPPUNIT_ASSERT_EQUAL(true, aMap["MirroredX"].get<bool>());
+    CPPUNIT_ASSERT_EQUAL(true, aMap["MirroredY"].get<bool>());
+
+    aMap = getProperty< uno::Sequence<beans::PropertyValue> >(getShapeByName("h-only"), "CustomShapeGeometry");
+    CPPUNIT_ASSERT_EQUAL(true, aMap["MirroredX"].get<bool>());
+    CPPUNIT_ASSERT(!aMap["MirroredY"].hasValue());
+
+    aMap = getProperty< uno::Sequence<beans::PropertyValue> >(getShapeByName("v-only"), "CustomShapeGeometry");
+    CPPUNIT_ASSERT(!aMap["MirroredX"].hasValue());
+    CPPUNIT_ASSERT_EQUAL(true, aMap["MirroredY"].get<bool>());
+
+    aMap = getProperty< uno::Sequence<beans::PropertyValue> >(getShapeByName("neither-h-nor-v"), "CustomShapeGeometry");
+    CPPUNIT_ASSERT(!aMap["MirroredX"].hasValue());
+    CPPUNIT_ASSERT(!aMap["MirroredY"].hasValue());
+}
+
 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 d9d99fb..c70050f 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -351,6 +351,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
     sal_Int16 nRelativeWidthRelation = text::RelOrientation::PAGE_FRAME;
     sal_Int16 nRelativeHeightRelation = text::RelOrientation::PAGE_FRAME;
     boost::logic::tribool obRelFlipV(boost::logic::indeterminate);
+    boost::logic::tribool obFlipH(boost::logic::indeterminate);
+    boost::logic::tribool obFlipV(boost::logic::indeterminate);
 
     bool bCustom(false);
     int const nType = initShape(xShape, xPropertySet, bCustom, rShape, bClose, shapeOrPict);
@@ -783,6 +785,10 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
         }
         else if (rProperty.first == "fRelFlipV")
             obRelFlipV = rProperty.second.toInt32() == 1;
+        else if (rProperty.first == "fFlipH")
+            obFlipH = rProperty.second.toInt32() == 1;
+        else if (rProperty.first == "fFlipV")
+            obFlipV = rProperty.second.toInt32() == 1;
         else
             SAL_INFO("writerfilter", "TODO handle shape property '" << rProperty.first << "':'" << rProperty.second << "'");
     }
@@ -908,6 +914,17 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
         else
             xShape->setSize(awt::Size(rShape.nRight - rShape.nLeft, rShape.nBottom - rShape.nTop));
 
+        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()));
+        }
+
         if (rShape.nHoriOrientRelation != 0)
             xPropertySet->setPropertyValue("HoriOrientRelation", uno::makeAny(rShape.nHoriOrientRelation));
         if (rShape.nVertOrientRelation != 0)


More information about the Libreoffice-commits mailing list