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

Miklos Vajna vmiklos at suse.cz
Fri Aug 9 07:12:43 PDT 2013


 sw/qa/extras/rtfimport/data/fdo53556.rtf    |   49 ++++++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx        |   16 +++++++++
 writerfilter/source/rtftok/rtfsdrimport.cxx |   36 ++++++++++++++------
 writerfilter/source/rtftok/rtfsdrimport.hxx |    2 +
 4 files changed, 92 insertions(+), 11 deletions(-)

New commits:
commit aa6959ba2c4ef1b718d8249fd47faaf677b16111
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Aug 9 16:00:04 2013 +0200

    fdo#53556 testcase
    
    Change-Id: If58376aec31ab00cab19221beed73e8275a834d2

diff --git a/sw/qa/extras/rtfimport/data/fdo53556.rtf b/sw/qa/extras/rtfimport/data/fdo53556.rtf
new file mode 100644
index 0000000..aafa11c
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo53556.rtf
@@ -0,0 +1,49 @@
+{\rtf1\ansi\deff0\viewkind1\paperw12240\paperh15840\marglsxn0\margrsxn0\margtsxn0\margbsxn0
+{\shp\shpbxpage\shpbypage\shpwr5\shpfhdr0\shpfblwtxt0\shpz3\shpleft1000\shpright12000\shptop1000\shpbottom1800
+{\sp
+{\sn fFilled}
+{\sv 0}
+}
+{\shpinst
+{\sp
+{\sn fLine}
+{\sv 0}
+}
+{\shptxt
+{\pard\cb1 \qc\sl367 \f0\fs32\b\cf2 ARL STATISTICS 2011-2012\line WORKSHEET\plain\par}
+}
+}
+}
+{\shp\shpbxpage\shpbypage\shpwr5\shpfhdr0\shpfblwtxt0\shpz18\shpleft1000\shpright4700\shptop900\shpbottom15040
+{\sp
+{\sn fFilled}
+{\sv 0}
+}
+{\shpinst
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn fLine}
+{\sv 0}
+}
+}
+}
+{\shp\shpbxpage\shpbypage\shpwr5\shpfhdr0\shpfblwtxt0\shpz2\shpleft1000\shpright12000\shptop2480\shpbottom3320
+{\sp
+{\sn fFilled}
+{\sv 0}
+}
+{\shpinst
+{\sp
+{\sn fLine}
+{\sv 0}
+}
+{\shptxt
+{\pard\cb1 \ql\sl252 \f0\fs22\cf2 This worksheet is designed to help you plan your submission for the 2011-2012 ARL Statistics. The figures on this worksheet should be similar to those in the Summary page of your web form, except in cases where data are unavailable. If an exact figure is unavailable, use NA/UA. If the appropriate answer is zero or none, use 0.\plain\par}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 5c7eb69..c258d7c 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -11,6 +11,7 @@
 #include <com/sun/star/document/XImporter.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/drawing/LineStyle.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/graphic/GraphicType.hpp>
@@ -160,6 +161,7 @@ public:
     void testFdo67365();
     void testFdo67498();
     void testFdo47440();
+    void testFdo53556();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -305,6 +307,7 @@ void Test::run()
         {"fdo67365.rtf", &Test::testFdo67365},
         {"fdo67498.rtf", &Test::testFdo67498},
         {"fdo47440.rtf", &Test::testFdo47440},
+        {"fdo53556.rtf", &Test::testFdo53556},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1489,6 +1492,19 @@ void Test::testFdo47440()
     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrientRelation"));
 }
 
+void Test::testFdo53556()
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible.
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xDraws->getByIndex(2), "FillStyle"));
+
+    // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc.
+    uno::Reference<beans::XPropertySet> xShapeProperties(xDraws->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xShapeProperties, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor->getShapeType());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 9f1f7199736e2ae07b34849ba66f61a1ef5782e8
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Aug 9 15:03:08 2013 +0200

    fdo#53556 RTF import: fix handling of default shapeType
    
    It was a customshape, but Word seems to handle the shape as a rectangle
    when shapeType is missing. This makes the text in the textboxes of the
    bugdoc wrap properly.
    
    Change-Id: I56e044f42ead348bbb79addc36fa13c82a7ffc29

diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index caa5896..147675e 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -231,6 +231,13 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
     oox::vml::FillModel aFillModel; // Gradient.
     oox::vml::ShadowModel aShadowModel; // Shadow.
 
+    // 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(),
+                boost::bind(&OUString::equals, boost::bind(&std::pair<OUString, OUString>::first, _1), OUString("shapeType")))
+            == rShape.aProperties.end())
+        rShape.aProperties.insert(rShape.aProperties.begin(), std::pair<OUString, OUString>("shapeType", OUString::number(ESCHER_ShpInst_Rectangle)));
+
     for (std::vector< std::pair<OUString, OUString> >::iterator i = rShape.aProperties.begin();
             i != rShape.aProperties.end(); ++i)
     {
commit 03f0cbd354646733977e4dec754c0113a5cbc3c9
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Aug 9 12:49:24 2013 +0200

    fdo#53556 RTF import of fFilled shape property for drwainglayer shapes
    
    The real change is in RTFSdrImport::applyProperty(), the rest is just
    refactoring to be able to read the "is textframe" property from that
    method.
    
    With this, the transparent big rectangle in the bugdoc no longer hides
    the text on the first page.
    
    Change-Id: I04cca3ade93a63edf608df047bef3bdccf8d3605

diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 3286c9d..caa5896 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -14,6 +14,7 @@
 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
@@ -44,7 +45,8 @@ namespace rtftok {
 
 RTFSdrImport::RTFSdrImport(RTFDocumentImpl& rDocument,
         uno::Reference<lang::XComponent> const& xDstDoc)
-    : m_rImport(rDocument)
+    : m_rImport(rDocument),
+    m_bTextFrame(false)
 {
     uno::Reference<drawing::XDrawPageSupplier> xDrawings(xDstDoc, uno::UNO_QUERY);
     if (xDrawings.is())
@@ -193,7 +195,12 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> xShape, OUStrin
         xPropertySet->setPropertyValue("FrameIsAutomaticHeight", uno::makeAny(*obFitShapeToText));
     }
     if (!bFilled)
-        xPropertySet->setPropertyValue("BackColorTransparency", uno::makeAny(sal_Int32(100)));
+    {
+        if (m_bTextFrame)
+            xPropertySet->setPropertyValue("BackColorTransparency", uno::makeAny(sal_Int32(100)));
+        else
+            xPropertySet->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_NONE));
+    }
 }
 
 void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
@@ -201,7 +208,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
     int nType = -1;
     bool bPib = false;
     bool bCustom = false;
-    bool bTextFrame = false;
+    m_bTextFrame = false;
 
     uno::Reference<drawing::XShape> xShape;
     uno::Reference<beans::XPropertySet> xPropertySet;
@@ -241,7 +248,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
                     if (!bClose && m_aParents.size() == 1)
                     {
                         createShape("com.sun.star.text.TextFrame", xShape, xPropertySet);
-                        bTextFrame = true;
+                        m_bTextFrame = true;
                         std::vector<beans::PropertyValue> aDefaults = getTextFrameDefaults(true);
                         for (size_t j = 0; j < aDefaults.size(); ++j)
                             xPropertySet->setPropertyValue(aDefaults[j].Name, aDefaults[j].Value);
@@ -256,12 +263,12 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
 
             // Defaults
             aAny <<= (sal_uInt32)0xffffff; // White in Word, kind of blue in Writer.
-            if (xPropertySet.is() && !bTextFrame)
+            if (xPropertySet.is() && !m_bTextFrame)
                 xPropertySet->setPropertyValue("FillColor", aAny);
         }
         else if ( i->first == "wzName" )
         {
-            if (bTextFrame)
+            if (m_bTextFrame)
             {
                 uno::Reference<container::XNamed> xNamed(xShape, uno::UNO_QUERY);
                 xNamed->setName(i->second);
@@ -279,7 +286,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
         else if (i->first == "fillColor" && xPropertySet.is())
         {
             aAny <<= msfilter::util::BGRToRGB(i->second.toInt32());
-            if (bTextFrame)
+            if (m_bTextFrame)
                 xPropertySet->setPropertyValue("BackColor", aAny);
             else
                 xPropertySet->setPropertyValue("FillColor", aAny);
@@ -524,7 +531,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
 
     if (xPropertySet.is())
     {
-        if (!bTextFrame)
+        if (!m_bTextFrame)
         {
             xPropertySet->setPropertyValue("LineColor", aLineColor);
             xPropertySet->setPropertyValue("LineWidth", aLineWidth);
@@ -544,7 +551,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
         }
         if (rShape.oZ)
             resolveDhgt(xPropertySet, *rShape.oZ);
-        if (bTextFrame)
+        if (m_bTextFrame)
             // Writer textframes implement text::WritingMode2, which is a different data type.
             xPropertySet->setPropertyValue("WritingMode", uno::makeAny(sal_Int16(eWritingMode)));
         else
@@ -558,7 +565,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
         return;
     }
 
-    if (m_aParents.size() && m_aParents.top().is() && !bTextFrame)
+    if (m_aParents.size() && m_aParents.top().is() && !m_bTextFrame)
         m_aParents.top()->add(xShape);
     if (bCustom && xShape.is())
     {
@@ -616,7 +623,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
             nTop = static_cast< sal_Int32 >( rShape.nTop + fHeightRatio * (*oRelTop - *oGroupTop) );
         }
 
-        if (bTextFrame)
+        if (m_bTextFrame)
         {
             xPropertySet->setPropertyValue("HoriOrientPosition", uno::makeAny(nLeft));
             xPropertySet->setPropertyValue("VertOrientPosition", uno::makeAny(nTop));
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx
index bb09b00..735f24b 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -45,6 +45,8 @@ namespace writerfilter {
                 RTFDocumentImpl& m_rImport;
                 std::stack< uno::Reference<drawing::XShapes> > m_aParents;
                 uno::Reference<drawing::XShape> m_xShape;
+                /// If m_xShape is imported as a Writer text frame (instead of a drawinglayer rectangle).
+                bool m_bTextFrame;
         };
     } // namespace rtftok
 } // namespace writerfilter


More information about the Libreoffice-commits mailing list