sw/qa/extras/rtfimport/data/fdo60722.rtf | 13 ++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 21 +++++++++++++++++++ writerfilter/source/dmapper/GraphicHelpers.cxx | 3 +- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 3 ++ writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 + writerfilter/source/rtftok/rtfsdrimport.cxx | 27 ++++++++++++++----------- 6 files changed, 57 insertions(+), 12 deletions(-)
New commits: commit ea66024d4da38a619f44c941b65e6a28b74214b9 Author: Miklos Vajna <[email protected]> Date: Wed Mar 6 16:23:22 2013 +0100 fdo#60722 testcase Change-Id: Ib6097c844b2bc929c6ece31bcec62f27bfbf386c diff --git a/sw/qa/extras/rtfimport/data/fdo60722.rtf b/sw/qa/extras/rtfimport/data/fdo60722.rtf new file mode 100644 index 0000000..498df01 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo60722.rtf @@ -0,0 +1,13 @@ +{\rtf1\ansi\deff0 +{\fonttbl +{\f0\fnil\fcharset204\fprq0\cpg1251 Arial;} +{\f1\fnil\fcharset204\fprq0\cpg1251 Times New Roman;} +{\f2\fnil\fcharset204\fprq0\cpg1251 Courier New;} +} +{\*\viewkind1}{\*\viewscale100}\margl0\margr0\margt0\margb0 +\paperw11905\paperh16837 +{\shp{\*\shpinst\shpleft10480\shptop840\shpright11320\shpbottom840\shpfhdr0\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt1\shpz0{\sp{\sn shapeType}{\sv 20}}}} +{\shp{\*\shpinst\shpleft8900\shptop11940\shpright10360\shpbottom12320\shpfhdr0\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt1\shpz0{\sp{\sn shapeType}{\sv 1}}{\sp{\sn fFilled}{\sv 0}}{\sp{\sn wzDescription}{\sv smaller}}}} +{\shp{\*\shpinst\shpleft7920\shptop11040\shpright11320\shpbottom13440\shpfhdr0\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt1\shpz0{\sp{\sn shapeType}{\sv 1}}{\sp{\sn fFilled}{\sv 0}}{\sp{\sn wzDescription}{\sv larger}}}} +{\par\plain\par +}} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index e577f42..819625f 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -144,6 +144,7 @@ public: void testFdo58076_2(); void testFdo59953(); void testFdo59638(); + void testFdo60722(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -260,6 +261,7 @@ void Test::run() {"fdo58076-2.rtf", &Test::testFdo58076_2}, {"fdo59953.rtf", &Test::testFdo59953}, {"fdo59638.rtf", &Test::testFdo59638}, + {"fdo60722.rtf", &Test::testFdo60722}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1145,6 +1147,25 @@ void Test::testFdo59638() CPPUNIT_FAIL("no BulletChar property"); } +void Test::testFdo60722() +{ + // The problem was that the larger shape was over the smaller one, and not the other way around. + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShape(xDraws->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xShape, "ZOrder")); + CPPUNIT_ASSERT_EQUAL(OUString("larger"), getProperty<OUString>(xShape, "Description")); + + xShape.set(xDraws->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(xShape, "ZOrder")); + CPPUNIT_ASSERT_EQUAL(OUString("smaller"), getProperty<OUString>(xShape, "Description")); + + // Color of the line was blue, and it had zero width. + xShape.set(xDraws->getByIndex(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty<sal_uInt32>(xShape, "LineWidth")); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty<sal_uInt32>(xShape, "LineColor")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit 1eaab77c718ffa254068ae6032862dfb5a03db67 Author: Miklos Vajna <[email protected]> Date: Wed Mar 6 15:57:22 2013 +0100 fdo#60722 import RTF_SHPZ Change-Id: I6c572d44d93f812d50376ec05ae94bdabadb3f1e diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx index 4d190e5..4564f3a 100644 --- a/writerfilter/source/dmapper/GraphicHelpers.cxx +++ b/writerfilter/source/dmapper/GraphicHelpers.cxx @@ -251,7 +251,8 @@ sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight ) while( it != items.end()) { // std::map is iterated sorted by key - if( it->first > relativeHeight ) + // if there is an item that has the same z-order, we belong under it + if( it->first >= relativeHeight ) break; // this is the first one higher, we belong right before it else ++it; diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 0e05b75..eda06d3 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3187,6 +3187,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case RTF_SHPBOTTOM: m_aStates.top().aShape.nBottom = TWIP_TO_MM100(nParam); break; + case RTF_SHPZ: + m_aStates.top().aShape.oZ.reset(nParam); + break; case RTF_FFTYPE: switch (nParam) { diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index c7affd7..5ced019 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -31,6 +31,7 @@ #include <stack> #include <queue> +#include <boost/optional.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -259,6 +260,7 @@ namespace writerfilter { sal_Int32 nTop; sal_Int32 nRight; sal_Int32 nBottom; + boost::optional<sal_Int32> oZ; ///< Z-Order of the shape. sal_Int16 nHoriOrientRelation; sal_Int16 nVertOrientRelation; int nWrap; diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 5744d97..864a8bd 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -298,6 +298,8 @@ void RTFSdrImport::resolve(RTFShape& rShape) { xPropertySet->setPropertyValue("LineColor", aLineColor); xPropertySet->setPropertyValue("LineWidth", aLineWidth); + if (rShape.oZ) + resolveDhgt(xPropertySet, *rShape.oZ); } if (nType == ESCHER_ShpInst_PictureFrame) // picture frame commit cf2a1277acd4a29492f056a626b13e903d391027 Author: Miklos Vajna <[email protected]> Date: Wed Mar 6 12:01:49 2013 +0100 fdo#60722 RTF import: fix line width default Change-Id: I6e6ca4bcd66fca60d305bb21d71018c88d854289 diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 346fc67..5744d97 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -102,6 +102,8 @@ void RTFSdrImport::resolve(RTFShape& rShape) std::vector<beans::PropertyValue> aPathPropVec; // Default line color is black in Word, blue in Writer. uno::Any aLineColor = uno::makeAny(COL_BLACK); + // Default line width is 0.75 pt (26 mm100) in Word, 0 in Writer. + uno::Any aLineWidth = uno::makeAny(sal_Int32(26)); for (std::vector< std::pair<rtl::OUString, rtl::OUString> >::iterator i = rShape.aProperties.begin(); i != rShape.aProperties.end(); ++i) @@ -165,12 +167,8 @@ void RTFSdrImport::resolve(RTFShape& rShape) aAny <<= i->second.toInt32()*100/65536; xPropertySet->setPropertyValue("RotateAngle", aAny); } - else if (i->first == "lineWidth" && xPropertySet.is()) - { - - aAny <<= i->second.toInt32()/360; - xPropertySet->setPropertyValue("LineWidth", aAny); - } + else if (i->first == "lineWidth") + aLineWidth <<= i->second.toInt32()/360; else if ( i->first == "pVerticies" ) { uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates; @@ -297,7 +295,10 @@ void RTFSdrImport::resolve(RTFShape& rShape) } if (xPropertySet.is()) + { xPropertySet->setPropertyValue("LineColor", aLineColor); + xPropertySet->setPropertyValue("LineWidth", aLineWidth); + } if (nType == ESCHER_ShpInst_PictureFrame) // picture frame { commit 9c7dbd9e1d2a131402a80e377630fe1ab5381a47 Author: Miklos Vajna <[email protected]> Date: Wed Mar 6 11:45:15 2013 +0100 fdo#60722 RTF import: fix line color default Change-Id: Ic100837dd69498e97d940e5dfb4053c02fc7daa0 diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 641fa973..346fc67 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -100,6 +100,8 @@ void RTFSdrImport::resolve(RTFShape& rShape) beans::PropertyValue aPropertyValue; awt::Rectangle aViewBox; std::vector<beans::PropertyValue> aPathPropVec; + // Default line color is black in Word, blue in Writer. + uno::Any aLineColor = uno::makeAny(COL_BLACK); for (std::vector< std::pair<rtl::OUString, rtl::OUString> >::iterator i = rShape.aProperties.begin(); i != rShape.aProperties.end(); ++i) @@ -138,11 +140,8 @@ void RTFSdrImport::resolve(RTFShape& rShape) } else if ( i->first == "fillBackColor" ) ; // Ignore: complementer of fillColor - else if (i->first == "lineColor" && xPropertySet.is()) - { - aAny <<= msfilter::util::BGRToRGB(i->second.toInt32()); - xPropertySet->setPropertyValue("LineColor", aAny); - } + else if (i->first == "lineColor") + aLineColor <<= msfilter::util::BGRToRGB(i->second.toInt32()); else if ( i->first == "lineBackColor" ) ; // Ignore: complementer of lineColor else if (i->first == "txflTextFlow" && xPropertySet.is()) @@ -297,6 +296,9 @@ void RTFSdrImport::resolve(RTFShape& rShape) OUStringToOString( i->second, RTL_TEXTENCODING_UTF8 ).getStr() << "'"); } + if (xPropertySet.is()) + xPropertySet->setPropertyValue("LineColor", aLineColor); + if (nType == ESCHER_ShpInst_PictureFrame) // picture frame { if (bPib) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
