tdf#131098 oox import: apply fill properties to graphic
The fill properties picked up by oox import
were not being transferred to the final graphic.
For some reason, the shape didn't import at all
if I copied over the Fill*Name properties.
All these are importing (at least at a basic level):
- bitmap
- hatch
- solid color
- transparency (unit test)
make CppunitTest_sw_ooxmlexport21 \
CPPUNIT_TEST_NAME=testTdf131098_imageFill
Change-Id: Ia891db8059c33132a75bef2c4922205315b7ecaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168127
Reviewed-by: Justin Luth <jluth@mail.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/ooxmlexport/data/tdf131098_imageFill.docx b/sw/qa/extras/ooxmlexport/data/tdf131098_imageFill.docx
new file mode 100644
index 0000000..b663bdf
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf131098_imageFill.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index 1c55be3..901a0b1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -532,6 +532,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf126533_pageBitmap, "tdf126533_pageBitmap.docx")
"/rels:Relationships/rels:Relationship[@Target='media/image1.jpeg']"_ostr, 1);
}
DECLARE_OOXMLEXPORT_TEST(testTdf131098_imageFill, "tdf131098_imageFill.docx")
{
if (isExported())
return;
// given a document with an image background transparency (blue-white)
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT,
getProperty<drawing::FillStyle>(getShape(1), "FillStyle"));
CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), getProperty<Color>(getShape(1), "FillColor"));
}
DECLARE_OOXMLEXPORT_TEST(testTdf154369, "tdf154369.docx")
{
//Unit test for bug fix in tdf#154369
diff --git a/sw/source/writerfilter/dmapper/GraphicImport.cxx b/sw/source/writerfilter/dmapper/GraphicImport.cxx
index b7621f7..bab91d2 100644
--- a/sw/source/writerfilter/dmapper/GraphicImport.cxx
+++ b/sw/source/writerfilter/dmapper/GraphicImport.cxx
@@ -1953,8 +1953,56 @@ rtl::Reference<SwXTextGraphicObject> GraphicImport::createGraphicObject(uno::Ref
uno::Any(m_pImpl->m_eColorMode));
}
xGraphicObject->setPropertyValue(getPropertyName( PROP_BACK_COLOR ),
uno::Any( GraphicImport_Impl::nFillColor ));
// copy the image fill area properties
xGraphicObject->setPropertyValue("FillBackground",
xShapeProps->getPropertyValue("FillBackground"));
xGraphicObject->setPropertyValue("FillBitmap",
xShapeProps->getPropertyValue("FillBitmap"));
xGraphicObject->setPropertyValue(
"FillBitmapLogicalSize", xShapeProps->getPropertyValue("FillBitmapLogicalSize"));
xGraphicObject->setPropertyValue("FillBitmapMode",
xShapeProps->getPropertyValue("FillBitmapMode"));
xGraphicObject->setPropertyValue("FillBitmapOffsetX",
xShapeProps->getPropertyValue("FillBitmapOffsetX"));
xGraphicObject->setPropertyValue(
"FillBitmapPositionOffsetX",
xShapeProps->getPropertyValue("FillBitmapPositionOffsetX"));
xGraphicObject->setPropertyValue(
"FillBitmapPositionOffsetY",
xShapeProps->getPropertyValue("FillBitmapPositionOffsetY"));
xGraphicObject->setPropertyValue(
"FillBitmapRectanglePoint",
xShapeProps->getPropertyValue("FillBitmapRectanglePoint"));
xGraphicObject->setPropertyValue("FillBitmapSizeX",
xShapeProps->getPropertyValue("FillBitmapSizeX"));
xGraphicObject->setPropertyValue("FillBitmapSizeY",
xShapeProps->getPropertyValue("FillBitmapSizeY"));
xGraphicObject->setPropertyValue("FillBitmapStretch",
xShapeProps->getPropertyValue("FillBitmapStretch"));
xGraphicObject->setPropertyValue("FillBitmapTile",
xShapeProps->getPropertyValue("FillBitmapTile"));
xGraphicObject->setPropertyValue("FillBitmapURL",
xShapeProps->getPropertyValue("FillBitmapURL"));
xGraphicObject->setPropertyValue("FillColor",
xShapeProps->getPropertyValue("FillColor"));
xGraphicObject->setPropertyValue("FillColor2",
xShapeProps->getPropertyValue("FillColor2"));
xGraphicObject->setPropertyValue("FillComplexColor",
xShapeProps->getPropertyValue("FillComplexColor"));
xGraphicObject->setPropertyValue("FillGradient",
xShapeProps->getPropertyValue("FillGradient"));
xGraphicObject->setPropertyValue(
"FillGradientStepCount", xShapeProps->getPropertyValue("FillGradientStepCount"));
xGraphicObject->setPropertyValue("FillHatch",
xShapeProps->getPropertyValue("FillHatch"));
xGraphicObject->setPropertyValue("FillStyle",
xShapeProps->getPropertyValue("FillStyle"));
xGraphicObject->setPropertyValue("FillTransparence",
xShapeProps->getPropertyValue("FillTransparence"));
xGraphicObject->setPropertyValue(
"FillTransparenceGradient",
xShapeProps->getPropertyValue("FillTransparenceGradient"));
m_pImpl->applyZOrder(xGraphicObject);
//there seems to be no way to detect the original size via _real_ API