sw/qa/extras/rtfimport/data/background.rtf | 39 +++++++++++++++++++++++++ sw/qa/extras/rtfimport/data/shpz-dhgt.rtf | 43 ++++++++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 16 ++++++++++ writerfilter/source/rtftok/rtfsdrimport.cxx | 11 +++++-- 4 files changed, 106 insertions(+), 3 deletions(-)
New commits: commit 3200e99c48897cf7965cc3acc58fadb686ee2437 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sun Dec 29 16:15:03 2013 +0100 fdo#41109 RTF shape import: handle fBehindDocument property Change-Id: I9bf24eb2d3087e855d54c0ee7aba4e98dc856cc2 (cherry picked from commit e8d10f215e9da65617988a9a471be18775afad00) diff --git a/sw/qa/extras/rtfimport/data/background.rtf b/sw/qa/extras/rtfimport/data/background.rtf new file mode 100644 index 0000000..2dbe9fe --- /dev/null +++ b/sw/qa/extras/rtfimport/data/background.rtf @@ -0,0 +1,39 @@ +{\rtf1 +{\shp +{\*\shpinst\shpleft2633\shptop-97\shpright4853\shpbottom893\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz1\shplid1027 +{\sp +{\sn shapeType} +{\sv 1} +} +{\sp +{\sn fillColor} +{\sv 5880731} +} +{\sp +{\sn fFilled} +{\sv 1} +} +{\sp +{\sn fBehindDocument} +{\sv 1} +} +} +} +{\shp +{\*\shpinst\shpleft488\shptop-97\shpright2003\shpbottom743\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026 +{\sp +{\sn shapeType} +{\sv 1} +} +{\sp +{\sn fillColor} +{\sv 5066944} +} +{\sp +{\sn fFilled} +{\sv 1} +} +} +} +First should be foreground, the second should be background.\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 130715d..19c80f7 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1400,6 +1400,13 @@ DECLARE_RTFIMPORT_TEST(testShpzDhgt, "shpz-dhgt.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00ff00), getProperty<sal_Int32>(getShape(2), "FillColor")); } +DECLARE_RTFIMPORT_TEST(testBackground, "background.rtf") +{ + // The first shape wasn't in the foreground. + CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(getShape(1), "Opaque"))); + CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "Opaque"))); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 84d541e..c13e104 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -239,6 +239,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose) oox::vml::FillModel aFillModel; // Gradient. oox::vml::ShadowModel aShadowModel; // Shadow. + bool bOpaque = true; + // The spec doesn't state what is the default for shapeType, Word seems to implement it as a rectangle. if (std::find_if(rShape.aProperties.begin(), rShape.aProperties.end(), @@ -535,6 +537,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose) oRelRight.reset(TWIP_TO_MM100(i->second.toInt32())); else if (i->first == "relBottom") oRelBottom.reset(TWIP_TO_MM100(i->second.toInt32())); + else if (i->first == "fBehindDocument") + bOpaque = !i->second.toInt32(); else SAL_INFO("writerfilter", "TODO handle shape property '" << i->first << "':'" << i->second << "'"); } @@ -669,6 +673,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose) oox::PropertySet(xShape).setProperties(aPropMap); } xPropertySet->setPropertyValue("AnchorType", uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); + xPropertySet->setPropertyValue("Opaque", uno::makeAny(bOpaque)); } if (m_rImport.isInBackground()) commit 851f933a03ed75d5938452832aa9198855847dc7 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sun Dec 29 15:21:51 2013 +0100 fdo#41109 RTF shape import: shpz has priority over dhgt And not the other way around, how 24ee3df385cf2aa95cd888581c84fdf90cc682dc (RTF import: fix priority handling of shpz vs dhgt, 2012-04-10) did, this time with a reproducer. Change-Id: I9412341c6b35ca2760e4490a18f11bc6a0e0b78a (cherry picked from commit ff7ac1a9b82bc20fe6e3d82322e53a7024edb84f) diff --git a/sw/qa/extras/rtfimport/data/shpz-dhgt.rtf b/sw/qa/extras/rtfimport/data/shpz-dhgt.rtf new file mode 100644 index 0000000..63df566 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/shpz-dhgt.rtf @@ -0,0 +1,43 @@ +{\rtf1 +{\shp +{\*\shpinst\shpleft1898\shptop1043\shpright4598\shpbottom2123\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz1\shplid1027 +{\sp +{\sn shapeType} +{\sv 1} +} +{\sp +{\sn fillColor} +{\sv 65280} +} +{\sp +{\sn fFilled} +{\sv 1} +} +{\sp +{\sn dhgt} +{\sv 5} +} +} +} +{\shp +{\*\shpinst\shpleft563\shptop518\shpright2243\shpbottom1448\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026 +{\sp +{\sn shapeType} +{\sv 1} +} +{\sp +{\sn fillColor} +{\sv 255} +} +{\sp +{\sn fFilled} +{\sv 1} +} +{\sp +{\sn dhgt} +{\sv 10} +} +} +} +\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index a8932c5..130715d 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1391,6 +1391,15 @@ DECLARE_RTFIMPORT_TEST(testFdo65090, "fdo65090.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength()); } +DECLARE_RTFIMPORT_TEST(testShpzDhgt, "shpz-dhgt.rtf") +{ + // Test that shpz has priority over dhght and not the other way around. + // Drawpage is sorted by ZOrder, so first should be red (back). + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), getProperty<sal_Int32>(getShape(1), "FillColor")); + // Second (front) should be green. + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00ff00), getProperty<sal_Int32>(getShape(2), "FillColor")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 3d9df8b..84d541e 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -450,9 +450,9 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose) aViewBox.Height = i->second.toInt32(); else if ( i->first == "dhgt" ) { - resolveDhgt(xPropertySet, i->second.toInt32()); - // dhgt is Word 2007, \shpz is Word 97-2003, the previous has priority. - rShape.oZ.reset(); + // dhgt is Word 2007, \shpz is Word 97-2003, the later has priority. + if (!rShape.oZ) + resolveDhgt(xPropertySet, i->second.toInt32()); } // These are in EMU, convert to mm100. else if (i->first == "dxTextLeft") _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits