sw/qa/extras/ooxmlexport/data/tdf131098_imageFill.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 11 +++ sw/source/writerfilter/dmapper/GraphicImport.cxx | 52 ++++++++++++++++- 3 files changed, 61 insertions(+), 2 deletions(-)
New commits: commit 2862f1989591f4666ed0f7b994c80a0d0fd8ae52 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Mon May 27 16:48:04 2024 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Thu May 30 01:20:18 2024 +0200 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 <jl...@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 000000000000..b663bdf72ac4 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf131098_imageFill.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index 1c55be3df2cf..901a0b161d6a 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 b7621f776f4e..bab91d2b7fe0 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