oox/source/drawingml/fillproperties.cxx | 2 ++ oox/source/export/drawingml.cxx | 15 +++++++++++---- sw/qa/extras/uiwriter/uiwriter4.cxx | 10 +++++++--- 3 files changed, 20 insertions(+), 7 deletions(-)
New commits: commit b8925251e48534706c6960a54c320d3879317321 Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Mon Jan 17 15:00:13 2022 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Thu Feb 3 08:59:10 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 <nem...@numbertext.org> 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 09ca9c22915a..87bbe81bd88a 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1658,12 +1658,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" ) ) { @@ -1671,13 +1678,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 c1635b64ffad..29d31a0940b2 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -3681,7 +3681,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf143760WrapContourToOff) CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getShape(1), "SurroundContour")); } -CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf127989) +CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testHatchFill) { createSwDoc(); @@ -3695,16 +3695,20 @@ CPPUNIT_TEST_FIXTURE(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_FIXTURE(SwUiWriterTest4, testCaptionShape)