oox/source/drawingml/fillproperties.cxx | 5 +++-- sw/qa/extras/uiwriter/uiwriter4.cxx | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)
New commits: commit 001afbed910b7e565f602c1b11b1b4538cd59442 Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Wed Dec 8 11:13:24 2021 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Dec 21 16:00:54 2021 +0100 tdf#127989 OOXML: fix import of transparent hatching Set FillBackground property of hatching fill to false, if the alpha value is 0 in the <a:bgClr> element, i.e. if it's a transparent hatching. This way the previous non-transparent hatching is transparent now. Change-Id: I483d5c654be55e74c9073769b06f185526429635 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126550 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 12d2cd9ad2fd..6a60a685c84f 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -816,8 +816,9 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, // Set background color for hatch if(maPatternProps.maPattBgColor.isUsed()) { - rPropMap.setProperty( ShapeProperty::FillBackground, true ); - rPropMap.setProperty( ShapeProperty::FillColor, maPatternProps.maPattBgColor.getColor( rGraphicHelper, nPhClr ) ); + aColor = maPatternProps.maPattBgColor; + rPropMap.setProperty( ShapeProperty::FillBackground, aColor.getTransparency() != 100 ); + rPropMap.setProperty( ShapeProperty::FillColor, aColor.getColor( rGraphicHelper, nPhClr ) ); } } else if ( maPatternProps.maPattBgColor.isUsed() ) diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 726a939a55c9..fa9258949c07 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -289,6 +289,7 @@ public: void testTdf129270(); void testInsertPdf(); void testTdf143760WrapContourToOff(); + void testTdf127989(); CPPUNIT_TEST_SUITE(SwUiWriterTest4); CPPUNIT_TEST(testTdf96515); @@ -411,6 +412,7 @@ public: CPPUNIT_TEST(testTdf129270); CPPUNIT_TEST(testInsertPdf); CPPUNIT_TEST(testTdf143760WrapContourToOff); + CPPUNIT_TEST(testTdf127989); CPPUNIT_TEST_SUITE_END(); }; @@ -4039,6 +4041,32 @@ void SwUiWriterTest4::testTdf143760WrapContourToOff() CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getShape(1), "SurroundContour")); } +void SwUiWriterTest4::testTdf127989() +{ + createSwDoc(); + + // Add a rectangle shape to the document. + uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape( + xFactory->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); + xShape->setSize(awt::Size(10000, 10000)); + xShape->setPosition(awt::Point(1000, 1000)); + uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); + xShapeProps->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_HATCH)); + xShapeProps->setPropertyValue("FillHatchName", uno::makeAny(OUString("Black 0 Degrees"))); + xShapeProps->setPropertyValue("FillBackground", uno::makeAny(false)); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + xDrawPage->add(xShape); + + // Save it as DOCX and load it again. + reload("Office Open XML Text", "tdf127989.docx"); + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + // Without fix this had failed, because the background of the hatch was not set as 'no background'. + CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), "FillBackground")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest4); CPPUNIT_PLUGIN_IMPLEMENT();