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

Miklos Vajna vmiklos at suse.cz
Sat Jun 15 10:30:41 PDT 2013


 sw/qa/extras/rtfimport/data/posh-posv.rtf      |   24 +++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   12 ++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    2 +
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    2 +
 writerfilter/source/rtftok/rtfsdrimport.cxx    |   44 +++++++++++++++++++++++++
 5 files changed, 84 insertions(+)

New commits:
commit 9d640dc6ad0f0b58fa62b70f78478e2bc8796e69
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Jun 15 19:05:50 2013 +0200

    RTF filter: import posh/posv property of shapes
    
    Change-Id: I55eccccf7f9ed06bba1ada18574890b5bee296f4

diff --git a/sw/qa/extras/rtfimport/data/posh-posv.rtf b/sw/qa/extras/rtfimport/data/posh-posv.rtf
new file mode 100644
index 0000000..5ff1fe8
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/posh-posv.rtf
@@ -0,0 +1,24 @@
+{\rtf1
+{\shp
+{\*\shpinst\shpleft0\shptop0\shpright3727\shpbottom2212\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 202}
+}
+{\shptxt test}
+{\sp
+{\sn fFitShapeToText}
+{\sv 1}
+}
+{\sp
+{\sn posh}
+{\sv 2}
+}
+{\sp
+{\sn posv}
+{\sv 2}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index d39ff51..8247284 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -32,6 +32,8 @@
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/text/WrapTextMode.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
 
 #include <rtl/ustring.hxx>
@@ -139,6 +141,7 @@ public:
     void testFdo64671();
     void testPageBackground();
     void testFdo62044();
+    void testPoshPosv();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -267,6 +270,7 @@ void Test::run()
         {"fdo64671.rtf", &Test::testFdo64671},
         {"page-background.rtf", &Test::testPageBackground},
         {"fdo62044.rtf", &Test::testFdo62044},
+        {"posh-posv.rtf", &Test::testPoshPosv},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1271,6 +1275,14 @@ void Test::testFdo62044()
     CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(xPropertySet, "CharHeight")); // Was 18, i.e. reset back to original value.
 }
 
+void Test::testPoshPosv()
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(xDraws->getByIndex(0), "HoriOrient"));
+    CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrient"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 3606700..7559b72 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -4750,7 +4750,9 @@ RTFShape::RTFShape()
     nTop(0),
     nRight(0),
     nBottom(0),
+    nHoriOrient(0),
     nHoriOrientRelation(0),
+    nVertOrient(0),
     nVertOrientRelation(0),
     nWrap(-1)
 {
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 0ba51b6..2ad163e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -244,7 +244,9 @@ namespace writerfilter {
                 sal_Int32 nRight;
                 sal_Int32 nBottom;
                 boost::optional<sal_Int32> oZ; ///< Z-Order of the shape.
+                sal_Int16 nHoriOrient;
                 sal_Int16 nHoriOrientRelation;
+                sal_Int16 nVertOrient;
                 sal_Int16 nVertOrientRelation;
                 int nWrap;
         };
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 24d7ca1..af00d97 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -393,6 +393,46 @@ void RTFSdrImport::resolve(RTFShape& rShape)
         else if (i->first == "shadowOffsetX")
             // EMUs to points
             aShadowModel.moOffset.set(OUString::number(i->second.toDouble() / 12700) + "pt");
+        else if (i->first == "posh")
+        {
+            switch(i->second.toInt32())
+            {
+                case 1:
+                    rShape.nHoriOrient = text::HoriOrientation::LEFT;
+                    break;
+                case 2:
+                    rShape.nHoriOrient = text::HoriOrientation::CENTER;
+                    break;
+                case 3:
+                    rShape.nHoriOrient = text::HoriOrientation::RIGHT;
+                    break;
+                case 4:
+                    rShape.nHoriOrient = text::HoriOrientation::INSIDE;
+                    break;
+                case 5:
+                    rShape.nHoriOrient = text::HoriOrientation::OUTSIDE;
+                    break;
+                default:
+                    break;
+            }
+        }
+        else if (i->first == "posv")
+        {
+            switch(i->second.toInt32())
+            {
+                case 1:
+                    rShape.nVertOrient = text::VertOrientation::TOP;
+                    break;
+                case 2:
+                    rShape.nVertOrient = text::VertOrientation::CENTER;
+                    break;
+                case 3:
+                    rShape.nVertOrient = text::VertOrientation::BOTTOM;
+                    break;
+                default:
+                    break;
+            }
+        }
         else if (i->first == "posrelh")
         {
             switch (i->second.toInt32())
@@ -503,8 +543,12 @@ void RTFSdrImport::resolve(RTFShape& rShape)
         else
             xShape->setPosition(awt::Point(rShape.nLeft, rShape.nTop));
         xShape->setSize(awt::Size(rShape.nRight - rShape.nLeft, rShape.nBottom - rShape.nTop));
+        if (rShape.nHoriOrient != 0)
+            xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(rShape.nHoriOrient));
         if (rShape.nHoriOrientRelation != 0)
             xPropertySet->setPropertyValue("HoriOrientRelation", uno::makeAny(rShape.nHoriOrientRelation));
+        if (rShape.nVertOrient != 0)
+            xPropertySet->setPropertyValue("VertOrient", uno::makeAny(rShape.nVertOrient));
         if (rShape.nVertOrientRelation != 0)
             xPropertySet->setPropertyValue("VertOrientRelation", uno::makeAny(rShape.nVertOrientRelation));
         if (rShape.nWrap != -1)


More information about the Libreoffice-commits mailing list