summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Bakos <bakos.attilakaroly@nisz.hu>2020-08-13 16:37:58 +0200
committerLászló Németh <nemeth@numbertext.org>2020-08-27 11:29:51 +0200
commit636d16efe45a55c1a5a7a451c46fbb8618bf0393 (patch)
tree9556f58447b7bc14297277026e3dc67a27745695
parent894fddc5edf5aad6fc6d0e18a6c934bfa7f001e4 (diff)
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@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--oox/source/vml/vmlshape.cxx9
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf135653.docxbin0 -> 15117 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport15.cxx19
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx38
4 files changed, 55 insertions, 11 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf135653.docx
Binary files 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