[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu May 28 02:27:30 PDT 2015


 sw/qa/extras/rtfimport/data/tdf91074.rtf       |    7 +++
 sw/qa/extras/rtfimport/rtfimport.cxx           |    7 +++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    6 ++-
 writerfilter/source/rtftok/rtfsdrimport.cxx    |   45 ++++++++++++++-----------
 writerfilter/source/rtftok/rtfsdrimport.hxx    |    2 +
 5 files changed, 47 insertions(+), 20 deletions(-)

New commits:
commit fe898641dd7f8ff3cc74804f01340fdade3e5ed7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon May 11 09:05:12 2015 +0200

    tdf#91074 RTF import: handle \dplineco* for text frames
    
    RTFSdrImport::resolve() already had the logic to use the relevant API
    depending on if the shape is a text frame or not -- extract that to a
    separate member function and use it from RTFDocumentImpl::popState(),
    too.
    
    (cherry picked from commit ec1a96e79e3e6225706151cb72eb3df763b0598d)
    
    Conflicts:
    	sw/qa/extras/rtfimport/rtfimport.cxx
    	writerfilter/source/rtftok/rtfsdrimport.cxx
    	writerfilter/source/rtftok/rtfsdrimport.hxx
    
    Change-Id: I663b372244f09f002447ece62587143b2a575795
    Reviewed-on: https://gerrit.libreoffice.org/15939
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/rtfimport/data/tdf91074.rtf b/sw/qa/extras/rtfimport/data/tdf91074.rtf
new file mode 100644
index 0000000..ff3fe9b
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf91074.rtf
@@ -0,0 +1,7 @@
+{\rtf1\ansi\ansicpg1252\deff0\deftab720
+{\*\do\dobxpage\dobypage\dodhgt8192\dptxbx
+{\dptxbxtext\pard\plain
+inner\par }
+\dpx674\dpy725\dpxsize1875\dpysize1020\dplinecor255\dplinecog0\dplinecob0\dplinew40\dpfillfgcr0\dpfillfgcg0\dpfillfgcb0\dpfillbgcr0\dpfillbgcg0\dpfillbgcb0\dpfillpat0}
+\par
+outer\par}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 6c52362..535687f 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2265,6 +2265,13 @@ DECLARE_RTFIMPORT_TEST(testTdf86182, "tdf86182.rtf")
     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>(getParagraph(1), "WritingMode"));
 }
 
+DECLARE_RTFIMPORT_TEST(testTdf91074, "tdf91074.rtf")
+{
+    // The file failed to load, as the border color was imported using the LineColor UNO property.
+    uno::Reference<drawing::XShape> xShape = getShape(1);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_LIGHTRED), getProperty<table::BorderLine2>(xShape, "TopBorder").Color);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index ad9954b..b039ede 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -5541,7 +5541,11 @@ int RTFDocumentImpl::popState()
             xShape->setSize(awt::Size(rDrawing.nRight, rDrawing.nBottom));
 
             if (rDrawing.bHasLineColor)
-                xPropertySet->setPropertyValue("LineColor", uno::makeAny(sal_uInt32((rDrawing.nLineColorR<<16) + (rDrawing.nLineColorG<<8) + rDrawing.nLineColorB)));
+            {
+                uno::Any aLineColor = uno::makeAny(sal_uInt32((rDrawing.nLineColorR<<16) + (rDrawing.nLineColorG<<8) + rDrawing.nLineColorB));
+                uno::Any aLineWidth;
+                RTFSdrImport::resolveLineColorAndWidth(bTextFrame, xPropertySet, aLineColor, aLineWidth);
+            }
             if (rDrawing.bHasFillColor)
                 xPropertySet->setPropertyValue("FillColor", uno::makeAny(sal_uInt32((rDrawing.nFillColorR<<16) + (rDrawing.nFillColorG<<8) + rDrawing.nFillColorB)));
             else if (!bTextFrame)
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 7969b0b..1ebaf46 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -128,6 +128,31 @@ void RTFSdrImport::resolveDhgt(uno::Reference<beans::XPropertySet> const& xPrope
     pHelper->addItem(xPropertySet, nZOrder);
 }
 
+void RTFSdrImport::resolveLineColorAndWidth(bool bTextFrame, const uno::Reference<beans::XPropertySet>& xPropertySet, uno::Any& rLineColor, uno::Any& rLineWidth)
+{
+    if (!bTextFrame)
+    {
+        xPropertySet->setPropertyValue("LineColor", rLineColor);
+        xPropertySet->setPropertyValue("LineWidth", rLineWidth);
+    }
+    else
+    {
+        static const char* aBorders[] =
+        {
+            "TopBorder", "LeftBorder", "BottomBorder", "RightBorder"
+        };
+        for (unsigned int i = 0; i < SAL_N_ELEMENTS(aBorders); ++i)
+        {
+            table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(OUString::createFromAscii(aBorders[i])).get<table::BorderLine2>();
+            if (rLineColor.hasValue())
+                aBorderLine.Color = rLineColor.get<sal_Int32>();
+            if (rLineWidth.hasValue())
+                aBorderLine.LineWidth = rLineWidth.get<sal_Int32>();
+            xPropertySet->setPropertyValue(OUString::createFromAscii(aBorders[i]), uno::makeAny(aBorderLine));
+        }
+    }
+}
+
 void RTFSdrImport::resolveFLine(uno::Reference<beans::XPropertySet> const& xPropertySet,
                                 sal_Int32 const nFLine)
 {
@@ -752,25 +777,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
 
     if (xPropertySet.is())
     {
-        if (!m_bTextFrame)
-        {
-            xPropertySet->setPropertyValue("LineColor", aLineColor);
-            xPropertySet->setPropertyValue("LineWidth", aLineWidth);
-        }
-        else
-        {
-            static const OUString aBorders[] =
-            {
-                OUString("TopBorder"), OUString("LeftBorder"), OUString("BottomBorder"), OUString("RightBorder")
-            };
-            for (unsigned int i = 0; i < SAL_N_ELEMENTS(aBorders); ++i)
-            {
-                table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(aBorders[i]).get<table::BorderLine2>();
-                aBorderLine.Color = aLineColor.get<sal_Int32>();
-                aBorderLine.LineWidth = aLineWidth.get<sal_Int32>();
-                xPropertySet->setPropertyValue(aBorders[i], uno::makeAny(aBorderLine));
-            }
-        }
+        resolveLineColorAndWidth(m_bTextFrame, xPropertySet, aLineColor, aLineWidth);
         if (rShape.oZ)
             resolveDhgt(xPropertySet, *rShape.oZ, /*bOldStyle=*/false);
         if (m_bTextFrame)
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx
index 8135ada..53da0ee 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -32,6 +32,8 @@ public:
     /// Append property on the current parent.
     void appendGroupProperty(const OUString& aKey, const OUString& aValue);
     void resolveDhgt(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, sal_Int32 nZOrder, bool bOldStyle);
+    /// Set line color and line width on the shape, using the relevant API depending on if the shape is a text frame or not.
+    static void resolveLineColorAndWidth(bool bTextFrame, const css::uno::Reference<css::beans::XPropertySet>& xPropertySet, css::uno::Any& rLineColor, css::uno::Any& rLineWidth);
     void resolveFLine(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, sal_Int32 nFLine);
     /**
      * These are the default in Word, but not in Writer.


More information about the Libreoffice-commits mailing list