summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-03-06 11:45:15 +0100
committerFridrich Strba <fridrich@documentfoundation.org>2013-03-07 08:30:50 +0000
commita6f8721768eb3318245893eced3b89522fc87383 (patch)
tree36e3661accce6934854b986408dc784ffc9503ee
parent202d4d32d481ce7e2d1f9933186b30f9ae77497a (diff)
fdo#60722 RTF filter: shape import fixes
- fix line color default - fix line width default - fix z-order of shapes (cherry picked from commits 9c7dbd9e1d2a131402a80e377630fe1ab5381a47, cf2a1277acd4a29492f056a626b13e903d391027, 1eaab77c718ffa254068ae6032862dfb5a03db67 and ea66024d4da38a619f44c941b65e6a28b74214b9) Change-Id: Ib6097c844b2bc929c6ece31bcec62f27bfbf386c Reviewed-on: https://gerrit.libreoffice.org/2569 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo60722.rtf13
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx21
-rw-r--r--writerfilter/source/dmapper/GraphicHelpers.cxx3
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx3
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx27
6 files changed, 57 insertions, 12 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo60722.rtf b/sw/qa/extras/rtfimport/data/fdo60722.rtf
new file mode 100644
index 000000000000..498df01fceb9
--- /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 b55aad92fd99..3d3cbe6827ce 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -140,6 +140,7 @@ public:
void testFdo58646line();
void testFdo59953();
void testFdo59638();
+ void testFdo60722();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -230,6 +231,7 @@ void Test::run()
{"fdo58646line.rtf", &Test::testFdo58646line},
{"fdo59953.rtf", &Test::testFdo59953},
{"fdo59638.rtf", &Test::testFdo59638},
+ {"fdo60722.rtf", &Test::testFdo60722},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
@@ -1110,6 +1112,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();
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index 4d190e54a912..4564f3aede14 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 c35b0d90e185..401ebb783f9e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3186,6 +3186,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 c7affd7fe032..5ced0196b916 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 641fa973e39b..864a8bda7962 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -100,6 +100,10 @@ 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);
+ // 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)
@@ -138,11 +142,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())
@@ -166,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,6 +294,14 @@ void RTFSdrImport::resolve(RTFShape& rShape)
OUStringToOString( i->second, RTL_TEXTENCODING_UTF8 ).getStr() << "'");
}
+ if (xPropertySet.is())
+ {
+ xPropertySet->setPropertyValue("LineColor", aLineColor);
+ xPropertySet->setPropertyValue("LineWidth", aLineWidth);
+ if (rShape.oZ)
+ resolveDhgt(xPropertySet, *rShape.oZ);
+ }
+
if (nType == ESCHER_ShpInst_PictureFrame) // picture frame
{
if (bPib)