diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-02-11 19:07:00 +0100 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-02-11 22:20:14 +0100 |
commit | 42e4d237692a10aaecabbc3499d14d3860d93478 (patch) | |
tree | 1adbd10e7fd6c52fcaa079f8ab1708a8af8b0d05 /oox | |
parent | b436bbf16a324439ad864465bfd9120c03a02f38 (diff) |
ooxml: Preserve color transformations for shape theme colors
Colors can have modifiers like in the following example:
<a:schemeClr val="accent6">
<a:lumMod val="40000"/>
<a:lumOff val="60000"/>
</a:schemeClr>
In the case of RGB colors, the transformations are merged within the
RGB color itself on import, so there's no need to preserve the
original transformations, but that's necessary in the case of scheme
colors.
Slightly modified an existing unit test to check this feature too.
Change-Id: I3a03a56f2b633f283c392e54842b326bd4df316b
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/shape.cxx | 17 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 27 |
2 files changed, 22 insertions, 22 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 99940ab790d4..fb17f5de4e93 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -782,22 +782,29 @@ Reference< XShape > Shape::createAndInsert( } // Store original fill and line colors of the shape and the theme color name to InteropGrabBag + Sequence< PropertyValue > aProperties( 6 ); //allocate the maximum possible number of slots sal_Int32 nSize = 2; - Sequence< PropertyValue > aProperties( nSize ); PUT_PROP( aProperties, 0, "OriginalSolidFillClr", aShapeProps[PROP_FillColor] ); PUT_PROP( aProperties, 1, "OriginalLnSolidFillClr", aShapeProps[PROP_LineColor] ); OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeName(); if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() ) { - aProperties.realloc( ++nSize ); - PUT_PROP( aProperties, nSize - 1, "SpPrSolidFillSchemeClr", sColorFillScheme ); + PUT_PROP( aProperties, nSize, "SpPrSolidFillSchemeClr", sColorFillScheme ); + nSize++; + PUT_PROP( aProperties, nSize, "SpPrSolidFillSchemeClrTransformations", + aFillProperties.maFillColor.getTransformations() ); + nSize++; } OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeName(); if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() ) { - aProperties.realloc( ++nSize ); - PUT_PROP( aProperties, nSize - 1, "SpPrLnSolidFillSchemeClr", sLnColorFillScheme ); + PUT_PROP( aProperties, nSize, "SpPrLnSolidFillSchemeClr", sLnColorFillScheme ); + nSize++; + PUT_PROP( aProperties, nSize, "SpPrLnSolidFillSchemeClrTransformations", + aLineProperties.maLineFill.maFillColor.getTransformations() ); + nSize++; } + aProperties.realloc( nSize ); //shrink the Sequence if we didn't use all the slots putPropertiesToGrabBag( aProperties ); // Store original gradient fill of the shape to InteropGrabBag diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 0058aa770772..0f95e7018c62 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -219,21 +219,10 @@ void DrawingML::WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha ) mpFS->endElementNS( XML_a, XML_solidFill ); } -void DrawingML::WriteSolidFill( OUString sSchemeName, sal_Int32 nAlpha ) +void DrawingML::WriteSolidFill( OUString sSchemeName, Sequence< PropertyValue > aTransformations ) { mpFS->startElementNS( XML_a, XML_solidFill, FSEND ); - if( nAlpha < MAX_PERCENT ) - { - Sequence< PropertyValue > aTransformations(1); - aTransformations[0].Name = "alpha"; - aTransformations[0].Value <<= nAlpha; - WriteColor( sSchemeName, aTransformations ); - } - else - { - Sequence< PropertyValue > aTransformations(0); - WriteColor( sSchemeName, aTransformations ); - } + WriteColor( sSchemeName, aTransformations ); mpFS->endElementNS( XML_a, XML_solidFill ); } @@ -247,7 +236,7 @@ void DrawingML::WriteSolidFill( Reference< XPropertySet > rXPropSet ) // get InteropGrabBag and search the relevant attributes OUString sColorFillScheme; sal_uInt32 nOriginalColor = 0; - Sequence< PropertyValue > aStyleProperties; + Sequence< PropertyValue > aStyleProperties, aTransformations; if ( GetProperty( rXPropSet, "InteropGrabBag" ) ) { Sequence< PropertyValue > aGrabBag; @@ -259,6 +248,8 @@ void DrawingML::WriteSolidFill( Reference< XPropertySet > rXPropSet ) aGrabBag[i].Value >>= nOriginalColor; else if( aGrabBag[i].Name == "StyleFillRef" ) aGrabBag[i].Value >>= aStyleProperties; + else if( aGrabBag[i].Name == "SpPrSolidFillSchemeClrTransformations" ) + aGrabBag[i].Value >>= aTransformations; } sal_Int32 nAlpha = MAX_PERCENT; @@ -276,7 +267,7 @@ void DrawingML::WriteSolidFill( Reference< XPropertySet > rXPropSet ) WriteSolidFill( nFillColor & 0xffffff, nAlpha ); else if ( !sColorFillScheme.isEmpty() ) // the shape had a scheme color and the user didn't change it - WriteSolidFill( sColorFillScheme, nAlpha ); + WriteSolidFill( sColorFillScheme, aTransformations ); else if ( aStyleProperties.hasElements() ) { sal_uInt32 nThemeColor = 0; @@ -529,7 +520,7 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) // get InteropGrabBag and search the relevant attributes OUString sColorFillScheme; sal_uInt32 nOriginalColor( 0 ), nStyleColor( 0 ), nStyleLineWidth( 0 ); - Sequence< PropertyValue > aStyleProperties; + Sequence< PropertyValue > aStyleProperties, aTransformations; drawing::LineStyle aStyleLineStyle( drawing::LineStyle_NONE ); drawing::LineJoint aStyleLineJoint( drawing::LineJoint_NONE ); if ( GetProperty( rXPropSet, "InteropGrabBag" ) ) @@ -543,6 +534,8 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) aGrabBag[i].Value >>= nOriginalColor; else if( aGrabBag[i].Name == "StyleLnRef" ) aGrabBag[i].Value >>= aStyleProperties; + else if( aGrabBag[i].Name == "SpPrLnSolidFillSchemeClrTransformations" ) + aGrabBag[i].Value >>= aTransformations; if( aStyleProperties.hasElements() ) { for( sal_Int32 i=0; i < aStyleProperties.getLength(); ++i ) @@ -596,7 +589,7 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) WriteSolidFill( nColor ); else if( !sColorFillScheme.isEmpty() ) // the line had a scheme color and the user didn't change it - WriteSolidFill( sColorFillScheme ); + WriteSolidFill( sColorFillScheme, aTransformations ); else if( aStyleProperties.hasElements() ) { if( nColor != nStyleColor ) |