oox/source/drawingml/fillproperties.cxx | 2 ++ oox/source/export/drawingml.cxx | 15 +++++++++++---- sw/qa/extras/uiwriter/uiwriter4.cxx | 14 +++++++++----- 3 files changed, 22 insertions(+), 9 deletions(-)
New commits: commit d036ea9651c05a2a50794bc5c0ee7ea54708ad6a Author: Tünde Tóth <[email protected]> AuthorDate: Mon Jan 17 15:00:13 2022 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Feb 3 12:22:55 2022 +0100 tdf#146822 OOXML: fix export of the transparency in hatch fill The transparency value of the hatch was not exported. Follow-up to commit 001afbed910b7e565f602c1b11b1b4538cd59442 "tdf#127989 OOXML: fix import of transparent hatching". Change-Id: I9b82a3422de8e4f85c534f861c45c0c097ceb02f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128504 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129396 diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 5d17c321d0f8..2b682bcd1b99 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -812,6 +812,8 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, { eFillStyle = FillStyle_HATCH; rPropMap.setProperty( ShapeProperty::FillHatch, createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( rGraphicHelper, nPhClr ) ) ); + if( aColor.hasTransparency() ) + rPropMap.setProperty( ShapeProperty::FillTransparency, aColor.getTransparency() ); // Set background color for hatch if(maPatternProps.maPattBgColor.isUsed()) diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index e1062795e3ae..0bcb8b4e1f92 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1599,12 +1599,19 @@ void DrawingML::WritePattFill(const Reference<XPropertySet>& rXPropSet, const cs { mpFS->startElementNS(XML_a, XML_pattFill, XML_prst, GetHatchPattern(rHatch)); + sal_Int32 nAlpha = MAX_PERCENT; + if (GetProperty(rXPropSet, "FillTransparence")) + { + sal_Int32 nTransparency = 0; + mAny >>= nTransparency; + nAlpha = (MAX_PERCENT - (PER_PERCENT * nTransparency)); + } + mpFS->startElementNS(XML_a, XML_fgClr); - WriteColor(::Color(ColorTransparency, rHatch.Color)); + WriteColor(::Color(ColorTransparency, rHatch.Color), nAlpha); mpFS->endElementNS( XML_a , XML_fgClr ); ::Color nColor = COL_WHITE; - sal_Int32 nAlpha = 0; if ( GetProperty( rXPropSet, "FillBackground" ) ) { @@ -1612,13 +1619,13 @@ void DrawingML::WritePattFill(const Reference<XPropertySet>& rXPropSet, const cs mAny >>= isBackgroundFilled; if( isBackgroundFilled ) { - nAlpha = MAX_PERCENT; - if( GetProperty( rXPropSet, "FillColor" ) ) { mAny >>= nColor; } } + else + nAlpha = 0; } mpFS->startElementNS(XML_a, XML_bgClr); diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 46d06d0985ae..090938240c63 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -287,7 +287,7 @@ public: void testTdf129270(); void testInsertPdf(); void testTdf143760WrapContourToOff(); - void testTdf127989(); + void testHatchFill(); CPPUNIT_TEST_SUITE(SwUiWriterTest4); CPPUNIT_TEST(testTdf96515); @@ -409,7 +409,7 @@ public: CPPUNIT_TEST(testTdf129270); CPPUNIT_TEST(testInsertPdf); CPPUNIT_TEST(testTdf143760WrapContourToOff); - CPPUNIT_TEST(testTdf127989); + CPPUNIT_TEST(testHatchFill); CPPUNIT_TEST_SUITE_END(); }; @@ -3878,7 +3878,7 @@ void SwUiWriterTest4::testTdf143760WrapContourToOff() CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getShape(1), "SurroundContour")); } -void SwUiWriterTest4::testTdf127989() +void SwUiWriterTest4::testHatchFill() { createSwDoc(); @@ -3892,16 +3892,20 @@ void SwUiWriterTest4::testTdf127989() xShapeProps->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_HATCH)); xShapeProps->setPropertyValue("FillHatchName", uno::makeAny(OUString("Black 0 Degrees"))); xShapeProps->setPropertyValue("FillBackground", uno::makeAny(false)); + xShapeProps->setPropertyValue("FillTransparence", uno::makeAny(sal_Int32(30))); 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"); + reload("Office Open XML Text", "hatchFill.docx"); CPPUNIT_ASSERT_EQUAL(1, getShapes()); - // Without fix this had failed, because the background of the hatch was not set as 'no background'. + // tdf#127989 Without fix this had failed, because the background of the hatch was not set as 'no background'. CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), "FillBackground")); + + // tdf#146822 Without fix this had failed, because the transparency value of the hatch was not exported. + CPPUNIT_ASSERT_EQUAL(sal_Int32(30), getProperty<sal_Int32>(getShape(1), "FillTransparence")); } CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest4);
