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 000000000000..5ff1fe8e7128 --- /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 d39ff516e398..8247284c3a95 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -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(xPropertySet, "CharHeight")); // Was 18, i.e. reset back to original value. } +void Test::testPoshPosv() +{ + uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty(xDraws->getByIndex(0), "HoriOrient")); + CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty(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 36067006e9d5..7559b72294a3 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 0ba51b6bfadf..2ad163ea4fc9 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 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 24d7ca1aa6f4..af00d979a0b3 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)