diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-05-20 19:31:36 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2019-05-21 08:02:10 +0200 |
commit | 5e3a3e7d37aecd353ebab78f24e7b32a66a7df83 (patch) | |
tree | 96ec531c836ae7b4adf8e3ead027c7d7d155380c /oox | |
parent | 2b95e5bdf91204ecc03bcf98375c2620b71f1c3d (diff) |
tdf#125360: PPTX: Shape fill transparency is not exported
.. if the original shape fill is defined with a theme
Override the alpha value with the current value get from
FillTransparence API attirbute even if the color is defined
with a style or a color scheme.
Reviewed-on: https://gerrit.libreoffice.org/72596
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 259d01a34d27df2fbfd11c3bf6fe9dc508ff6ac2)
Change-Id: I09d26238a9c2b501279e6749687dc535e614bbd6
Reviewed-on: https://gerrit.libreoffice.org/72618
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/drawingml.cxx | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 23065ec67678..30f330226788 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -231,7 +231,7 @@ void DrawingML::WriteColor( ::Color nColor, sal_Int32 nAlpha ) } } -void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< PropertyValue >& aTransformations ) +void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha ) { // prevent writing a tag with empty val attribute if( sColorSchemeName.isEmpty() ) @@ -242,7 +242,15 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr mpFS->startElementNS( XML_a, XML_schemeClr, XML_val, USS( sColorSchemeName ), FSEND ); - WriteColorTransformations( aTransformations ); + WriteColorTransformations( aTransformations, nAlpha ); + mpFS->endElementNS( XML_a, XML_schemeClr ); + } + else if(nAlpha < MAX_PERCENT) + { + mpFS->startElementNS( XML_a, XML_schemeClr, + XML_val, USS( sColorSchemeName ), + FSEND ); + mpFS->singleElementNS(XML_a, XML_alpha, XML_val, OString::number(nAlpha), FSEND); mpFS->endElementNS( XML_a, XML_schemeClr ); } else @@ -253,15 +261,22 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr } } -void DrawingML::WriteColorTransformations( const Sequence< PropertyValue >& aTransformations ) +void DrawingML::WriteColorTransformations( const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha ) { for( sal_Int32 i = 0; i < aTransformations.getLength(); i++ ) { sal_Int32 nToken = Color::getColorTransformationToken( aTransformations[i].Name ); if( nToken != XML_TOKEN_INVALID && aTransformations[i].Value.hasValue() ) { - sal_Int32 nValue = aTransformations[i].Value.get<sal_Int32>(); - mpFS->singleElementNS( XML_a, nToken, XML_val, I32S( nValue ), FSEND ); + if(nToken == XML_alpha && nAlpha < MAX_PERCENT) + { + mpFS->singleElementNS( XML_a, nToken, XML_val, I32S( nAlpha ), FSEND ); + } + else + { + sal_Int32 nValue = aTransformations[i].Value.get<sal_Int32>(); + mpFS->singleElementNS( XML_a, nToken, XML_val, I32S( nValue ), FSEND ); + } } } } @@ -273,10 +288,10 @@ void DrawingML::WriteSolidFill( ::Color nColor, sal_Int32 nAlpha ) mpFS->endElementNS( XML_a, XML_solidFill ); } -void DrawingML::WriteSolidFill( const OUString& sSchemeName, const Sequence< PropertyValue >& aTransformations ) +void DrawingML::WriteSolidFill( const OUString& sSchemeName, const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha ) { mpFS->startElementNS( XML_a, XML_solidFill, FSEND ); - WriteColor( sSchemeName, aTransformations ); + WriteColor( sSchemeName, aTransformations, nAlpha ); mpFS->endElementNS( XML_a, XML_solidFill ); } @@ -326,22 +341,36 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) else if ( !sColorFillScheme.isEmpty() ) { // the shape had a scheme color and the user didn't change it - WriteSolidFill( sColorFillScheme, aTransformations ); + WriteSolidFill( sColorFillScheme, aTransformations, nAlpha ); } else if ( aStyleProperties.hasElements() ) { sal_uInt32 nThemeColor = 0; + sal_Int32 nThemeAlpha = MAX_PERCENT; for( sal_Int32 i=0; i < aStyleProperties.getLength(); ++i ) { if( aStyleProperties[i].Name == "Color" ) { aStyleProperties[i].Value >>= nThemeColor; - break; + } + else if(aStyleProperties[i].Name == "Transformations" ) + { + Sequence< PropertyValue > aStyleTransformations; + aStyleProperties[i].Value >>= aStyleTransformations; + for( sal_Int32 j = 0; j < aStyleTransformations.getLength(); j++ ) + { + if (aStyleTransformations[j].Name == "alpha" ) + { + aStyleTransformations[j].Value >>= nThemeAlpha; + break; + } + } } } - if ( nFillColor != nThemeColor ) + if ( nFillColor != nThemeColor || nAlpha != nThemeAlpha ) // the shape contains a theme but it wasn't being used WriteSolidFill( ::Color(nFillColor & 0xffffff), nAlpha ); + // in case the shape used the style color and the user didn't change it, // we must not write a <a: solidFill> tag. } |