diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2019-10-22 09:43:29 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-11-05 15:55:34 +0100 |
commit | ef43ee69a355c0eda49d2f62540fbcf1299a59d2 (patch) | |
tree | 3067ce4b5a0ff0a01e1d53207c4207e8ffb65ce6 /oox | |
parent | 4200b2aad00125505cb09d9589360e47b92cf25e (diff) |
tdf#108065 tdf#128609 OOXML chart export: fix transparent color gradient
Linear and axial color gradients keep their solid or gradient
transparencies.
Change-Id: I37dfe016864bded49c767cea5c8c865455281de0
Reviewed-on: https://gerrit.libreoffice.org/81308
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/chartexport.cxx | 20 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 55 |
2 files changed, 53 insertions, 22 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 4eb82d71805e..c4bf38eff9ef 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1543,16 +1543,28 @@ void ChartExport::exportGradientFill( const Reference< XPropertySet >& xPropSet xPropSet->getPropertyValue("FillGradientName") >>= sFillGradientName; awt::Gradient aGradient; + awt::Gradient aTransparenceGradient; uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY ); try { uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY ); - uno::Any rValue = xGradient->getByName( sFillGradientName ); - if( rValue >>= aGradient ) + uno::Any rGradientValue = xGradient->getByName( sFillGradientName ); + if( rGradientValue >>= aGradient ) { mpFS->startElementNS(XML_a, XML_gradFill); - WriteGradientFill( aGradient ); - mpFS->endElementNS( XML_a, XML_gradFill ); + OUString sFillTransparenceGradientName; + if( (xPropSet->getPropertyValue("FillTransparenceGradientName") >>= sFillTransparenceGradientName) && !sFillTransparenceGradientName.isEmpty()) + { + uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY); + uno::Any rTransparenceValue = xTransparenceGradient->getByName(sFillTransparenceGradientName); + rTransparenceValue >>= aTransparenceGradient;; + WriteGradientFill(aGradient, aTransparenceGradient); + } + else + { + WriteGradientFill(aGradient, aTransparenceGradient, xPropSet); + } + mpFS->endElementNS(XML_a, XML_gradFill); } } catch (const uno::Exception &) diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index fb5f6ed7a4cd..a5c152dcf6d1 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -481,6 +481,7 @@ bool DrawingML::EqualGradients( awt::Gradient aGradient1, awt::Gradient aGradien void DrawingML::WriteGradientFill( const Reference< XPropertySet >& rXPropSet ) { awt::Gradient aGradient; + awt::Gradient aTransparenceGradient; if (GetProperty(rXPropSet, "FillGradient")) { aGradient = *o3tl::doAccess<awt::Gradient>(mAny); @@ -515,7 +516,9 @@ void DrawingML::WriteGradientFill( const Reference< XPropertySet >& rXPropSet ) else { mpFS->startElementNS(XML_a, XML_gradFill, XML_rotWithShape, "0"); - WriteGradientFill(aGradient, rXPropSet); + if( GetProperty(rXPropSet, "FillTransparenceGradient") ) + aTransparenceGradient = *o3tl::doAccess<awt::Gradient>(mAny); + WriteGradientFill(aGradient, aTransparenceGradient); mpFS->endElementNS( XML_a, XML_gradFill ); } } @@ -580,7 +583,7 @@ void DrawingML::WriteGrabBagGradientFill( const Sequence< PropertyValue >& aGrad } } -void DrawingML::WriteGradientFill(awt::Gradient rGradient, +void DrawingML::WriteGradientFill(awt::Gradient rGradient, awt::Gradient rTransparenceGradient, const uno::Reference<beans::XPropertySet>& rXPropSet) { switch( rGradient.Style ) @@ -588,21 +591,19 @@ void DrawingML::WriteGradientFill(awt::Gradient rGradient, default: case awt::GradientStyle_LINEAR: { - awt::Gradient aTransparenceGradient; - bool bTransparent = false; - if (rXPropSet.is() && GetProperty(rXPropSet, "FillTransparenceGradient")) + mpFS->startElementNS(XML_a, XML_gsLst); + sal_Int32 nStartAlpha; + sal_Int32 nEndAlpha; + if( rXPropSet.is() && GetProperty(rXPropSet, "FillTransparence") ) { - aTransparenceGradient = *o3tl::doAccess<awt::Gradient>(mAny); - bTransparent = true; + sal_Int32 nTransparency = 0; + mAny >>= nTransparency; + nStartAlpha = nEndAlpha = (MAX_PERCENT - (PER_PERCENT * nTransparency)); } - - mpFS->startElementNS(XML_a, XML_gsLst); - sal_Int32 nStartAlpha = MAX_PERCENT; - sal_Int32 nEndAlpha = MAX_PERCENT; - if (bTransparent) + else { - nStartAlpha = GetAlphaFromTransparenceGradient(aTransparenceGradient, true); - nEndAlpha = GetAlphaFromTransparenceGradient(aTransparenceGradient, false); + nStartAlpha = GetAlphaFromTransparenceGradient(rTransparenceGradient, true); + nEndAlpha = GetAlphaFromTransparenceGradient(rTransparenceGradient, false); } WriteGradientStop(0, ColorWithIntensity(rGradient.StartColor, rGradient.StartIntensity), nStartAlpha); @@ -616,15 +617,33 @@ void DrawingML::WriteGradientFill(awt::Gradient rGradient, } case awt::GradientStyle_AXIAL: + { mpFS->startElementNS(XML_a, XML_gsLst); - WriteGradientStop( 0, ColorWithIntensity( rGradient.EndColor, rGradient.EndIntensity ) ); - WriteGradientStop( 50, ColorWithIntensity( rGradient.StartColor, rGradient.StartIntensity ) ); - WriteGradientStop( 100, ColorWithIntensity( rGradient.EndColor, rGradient.EndIntensity ) ); - mpFS->endElementNS( XML_a, XML_gsLst ); + sal_Int32 nStartAlpha; + sal_Int32 nEndAlpha; + if (rXPropSet.is() && GetProperty(rXPropSet, "FillTransparence")) + { + sal_Int32 nTransparency = 0; + mAny >>= nTransparency; + nStartAlpha = nEndAlpha = (MAX_PERCENT - (PER_PERCENT * nTransparency)); + } + else + { + nStartAlpha = GetAlphaFromTransparenceGradient(rTransparenceGradient, true); + nEndAlpha = GetAlphaFromTransparenceGradient(rTransparenceGradient, false); + } + WriteGradientStop(0, ColorWithIntensity(rGradient.EndColor, rGradient.EndIntensity), + nEndAlpha); + WriteGradientStop(50, ColorWithIntensity(rGradient.StartColor, rGradient.StartIntensity), + nStartAlpha); + WriteGradientStop(100, ColorWithIntensity(rGradient.EndColor, rGradient.EndIntensity), + nEndAlpha); + mpFS->endElementNS(XML_a, XML_gsLst); mpFS->singleElementNS( XML_a, XML_lin, XML_ang, OString::number((((3600 - rGradient.Angle + 900) * 6000) % 21600000))); break; + } case awt::GradientStyle_RADIAL: { |