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

Miklos Vajna vmiklos at suse.cz
Fri Jun 28 00:06:19 PDT 2013


 sw/qa/extras/rtfimport/data/n823655.rtf     |   48 ++++++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx        |   26 +++++++++++++++
 writerfilter/source/rtftok/rtfsdrimport.cxx |   14 ++++----
 3 files changed, 81 insertions(+), 7 deletions(-)

New commits:
commit 22ae9ec4cdfdd2e449f00c74c7317084e7080129
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jun 24 14:13:39 2013 +0200

    bnc#823655 fix RTF import of freeform shape coordinates
    
    E.g. 0,1 was imported as 1,0, as we did not differentiate between not
    having the coordinate yet and having it as zero.
    
    Change-Id: Ia5fbbcc791dc9c6866ffd4c146793690661d81b4
    (cherry picked from commit ddddfe8d6ffa05c467bddb3480e43d7043a3d3c9)
    Reviewed-on: https://gerrit.libreoffice.org/4483
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/sw/qa/extras/rtfimport/data/n823655.rtf b/sw/qa/extras/rtfimport/data/n823655.rtf
new file mode 100644
index 0000000..94e73ed
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/n823655.rtf
@@ -0,0 +1,48 @@
+{\rtf1
+foo
+{\shp
+{\*\shpinst\shpleft450\shptop1904\shpright11595\shpbottom2190\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 0}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn geoRight}
+{\sv 11145}
+}
+{\sp
+{\sn geoBottom}
+{\sv 286}
+}
+{\sp
+{\sn pVerticies}
+{\sv 8;4;(0,286);(11145,286);(11145,1);(0,1)}
+}
+{\sp
+{\sn pSegmentInfo}
+{\sv 2;5;16384;1;1;1;32768}
+}
+{\sp
+{\sn fFillOK}
+{\sv 1}
+}
+{\sp
+{\sn fillColor}
+{\sv 15000804}
+}
+{\sp
+{\sn fFilled}
+{\sv 1}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index bbfadcd..76967db 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -8,6 +8,7 @@
 
 #include <com/sun/star/document/XFilter.hpp>
 #include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
 #include <com/sun/star/drawing/LineStyle.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
@@ -140,6 +141,7 @@ public:
     void testFdo62044();
     void testN825305();
     void testParaBottomMargin();
+    void testN823655();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -269,6 +271,7 @@ void Test::run()
         {"fdo62044.rtf", &Test::testFdo62044},
         {"n825305.rtf", &Test::testN825305},
         {"para-bottom-margin.rtf", &Test::testParaBottomMargin},
+        {"n823655.rtf", &Test::testN823655},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1284,6 +1287,29 @@ void Test::testParaBottomMargin()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
 }
 
+void Test::testN823655()
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xDraws->getByIndex(0), "CustomShapeGeometry");
+    uno::Sequence<beans::PropertyValue> aPathProps;
+    for (int i = 0; i < aProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aProps[i];
+        if (rProp.Name == "Path")
+            aPathProps = rProp.Value.get< uno::Sequence<beans::PropertyValue> >();
+    }
+    uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates;
+    for (int i = 0; i < aPathProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aPathProps[i];
+        if (rProp.Name == "Coordinates")
+            aCoordinates = rProp.Value.get< uno::Sequence<drawing::EnhancedCustomShapeParameterPair> >();
+    }
+    // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates[0].Second.Value.get<sal_Int32>());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index a984431f..07913b1 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -251,19 +251,19 @@ void RTFSdrImport::resolve(RTFShape& rShape)
                     // The coordinates are in an (x,y) form.
                     aToken = aToken.copy(1, aToken.getLength() - 2);
                     sal_Int32 nI = 0;
-                    sal_Int32 nX = 0;
-                    sal_Int32 nY = 0;
+                    boost::optional<sal_Int32> oX;
+                    boost::optional<sal_Int32> oY;
                     do
                     {
                         OUString aPoint = aToken.getToken(0, ',', nI);
-                        if (!nX)
-                            nX = aPoint.toInt32();
+                        if (!oX)
+                            oX.reset(aPoint.toInt32());
                         else
-                            nY = aPoint.toInt32();
+                            oY.reset(aPoint.toInt32());
                     }
                     while (nI >= 0);
-                    aCoordinates[nIndex].First.Value <<= nX;
-                    aCoordinates[nIndex].Second.Value <<= nY;
+                    aCoordinates[nIndex].First.Value <<= *oX;
+                    aCoordinates[nIndex].Second.Value <<= *oY;
                     nIndex++;
                 }
             }


More information about the Libreoffice-commits mailing list