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

Attila Bakos (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 27 09:30:39 UTC 2020


 oox/source/vml/vmlshape.cxx                       |    9 ++++-
 sw/qa/extras/ooxmlexport/data/tdf135653.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx        |   19 +++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   38 ++++++++++++++++------
 4 files changed, 55 insertions(+), 11 deletions(-)

New commits:
commit 636d16efe45a55c1a5a7a451c46fbb8618bf0393
Author:     Attila Bakos <bakos.attilakaroly at nisz.hu>
AuthorDate: Thu Aug 13 16:37:58 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Thu Aug 27 11:29:51 2020 +0200

    tdf#135653 OOXML import: fix OLE background color
    
    When importing a .docx file Writer used to ignore the 'filled' and
    'fillcolor' attributes in the 'shape' tag belonging to an OLE object.
    Now both these are imported and displayed correctly.
    
    Co-authored-by: Daniel Arato (NISZ)
    
    Change-Id: I2e6b880d88e4c46af6f3f2316ee966bac1a1f2e0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100922
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index f22a98576a16..362f02c7cabf 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -293,13 +293,18 @@ void ShapeBase::finalizeFragmentImport()
         aType = aType.copy(1);
     if( const ShapeType* pShapeType = mrDrawing.getShapes().getShapeTypeById( aType ) )
     {
-        // Make sure that the stroke props from maTypeModel have priority over the stroke props from
+        // Make sure that the props from maTypeModel have priority over the props from
         // the shape type.
         StrokeModel aMergedStrokeModel;
         aMergedStrokeModel.assignUsed(pShapeType->getTypeModel().maStrokeModel);
         aMergedStrokeModel.assignUsed(maTypeModel.maStrokeModel);
+        FillModel aMergedFillModel;
+        aMergedFillModel.assignUsed(pShapeType->getTypeModel().maFillModel);
+        aMergedFillModel.assignUsed(maTypeModel.maFillModel);
+
         maTypeModel.assignUsed( pShapeType->getTypeModel() );
         maTypeModel.maStrokeModel = aMergedStrokeModel;
+        maTypeModel.maFillModel = aMergedFillModel;
     }
     else {
         // Temporary fix, shapetype not found if referenced from different substream
@@ -1359,6 +1364,8 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
         oox::drawingml::ShapePropertyMap aPropMap(mrDrawing.getFilter().getModelObjectHelper());
         const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
         maTypeModel.maStrokeModel.pushToPropMap(aPropMap, rGraphicHelper);
+        //And, fill-color properties as well...
+        maTypeModel.maFillModel.pushToPropMap(aPropMap, rGraphicHelper);
         PropertySet(xShape).setProperties(aPropMap);
 
         return xShape;
diff --git a/sw/qa/extras/ooxmlexport/data/tdf135653.docx b/sw/qa/extras/ooxmlexport/data/tdf135653.docx
new file mode 100644
index 000000000000..b53777f81952
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135653.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index e78e7fba8179..818664f384f1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -9,6 +9,8 @@
 
 #include <swmodeltestbase.hxx>
 
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <tools/color.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
@@ -369,6 +371,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf134063, "tdf134063.docx")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(720), getXPath(pDump, "//page[1]/body/txt[1]/Text[3]", "nWidth").toInt32());
 }
 
+DECLARE_OOXMLIMPORT_TEST(TestTdf135653, "tdf135653.docx")
+{
+    uno::Reference<beans::XPropertySet> xOLEProps(getShape(1), uno::UNO_QUERY_THROW);
+    drawing::FillStyle nFillStyle = static_cast<drawing::FillStyle>(-1);
+    xOLEProps->getPropertyValue("FillStyle") >>= nFillStyle;
+    Color aFillColor(COL_AUTO);
+    xOLEProps->getPropertyValue("FillColor") >>= aFillColor;
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill style setting does not match!",
+                                 drawing::FillStyle::FillStyle_SOLID, nFillStyle);
+    Color aExpectedColor;
+    aExpectedColor.SetRed(255);
+    aExpectedColor.SetGreen(0);
+    aExpectedColor.SetBlue(0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("OLE bg color does not match!", aExpectedColor, aFillColor);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testAtPageShapeRelOrientation, "rotated_shape.fodt")
 {
     // invalid combination of at-page anchor and horizontal-rel="paragraph"
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index ce3fd3fbe3a8..1ddf7f941956 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -101,6 +101,7 @@
 #include <unotools/mediadescriptor.hxx>
 #include <tools/diagnose_ex.h>
 #include <sal/log.hxx>
+#include <com/sun/star/drawing/FillStyle.hpp>
 
 #include <unicode/errorcode.h>
 #include <unicode/regex.h>
@@ -2246,18 +2247,35 @@ void DomainMapper_Impl::appendOLE( const OUString& rStreamName, const std::share
         uno::Reference<beans::XPropertySet> xReplacementProperties(pOLEHandler->getShape(), uno::UNO_QUERY);
         if (xReplacementProperties.is())
         {
+            table::BorderLine2 aBorderProps;
+            xReplacementProperties->getPropertyValue("LineColor") >>= aBorderProps.Color;
+            xReplacementProperties->getPropertyValue("LineWidth") >>= aBorderProps.LineWidth;
+            xReplacementProperties->getPropertyValue("LineStyle") >>= aBorderProps.LineStyle;
+
+            xOLEProperties->setPropertyValue("RightBorder", uno::Any(aBorderProps));
+            xOLEProperties->setPropertyValue("TopBorder", uno::Any(aBorderProps));
+            xOLEProperties->setPropertyValue("LeftBorder", uno::Any(aBorderProps));
+            xOLEProperties->setPropertyValue("BottomBorder", uno::Any(aBorderProps));
+
             OUString pProperties[] = {
-                OUString("AnchorType"),
-                OUString("Surround"),
-                OUString("HoriOrient"),
-                OUString("HoriOrientPosition"),
-                OUString("VertOrient"),
-                OUString("VertOrientPosition"),
-                OUString("VertOrientRelation"),
-                OUString("HoriOrientRelation")
+                "AnchorType",
+                "Surround",
+                "HoriOrient",
+                "HoriOrientPosition",
+                "VertOrient",
+                "VertOrientPosition",
+                "VertOrientRelation",
+                "HoriOrientRelation",
+                "FillStyle",
+                "FillColor",
+                "FillColor2",
+                "LineStyle",
             };
-            for (const OUString & s : pProperties)
-                xOLEProperties->setPropertyValue(s, xReplacementProperties->getPropertyValue(s));
+            for (const OUString& s : pProperties)
+            {
+                const uno::Any aVal = xReplacementProperties->getPropertyValue(s);
+                xOLEProperties->setPropertyValue(s, aVal);
+            }
         }
         else
             // mimic the treatment of graphics here... it seems anchoring as character


More information about the Libreoffice-commits mailing list