diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-01-27 19:32:55 +0100 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-01-28 11:00:37 +0100 |
commit | 007f260e0ba31b2449debd0329487679a851cb12 (patch) | |
tree | 1eef9d35b345c75368b41aaf7f7755f24ba622e7 /oox | |
parent | f876c8a442977454a29377a703dc1cf630158d00 (diff) |
ooxml: Preserve color transformations in shape style definitions
Color tags like <a:schemeClr> can have children tags that modify the
specified color. These modifications were applied on import time in
the Color object, but they were not preserved.
We added a member to Color object to preserve the unaltered list of
transformations. The method getTransformations() returns that member,
and the methods getColorTransformationName and
getColorTransformationToken were added to transform the tokens into
strings that can be added to an InteropGrabBag and viceversa.
The transformations are added to the Shape InteropGrabBag in the
method Shape::createAndInsert, and they are written back on export
time at DrawingML::WriteStyleProperties.
The data files for some /sd/qa/ unit tests were updated to reflect
the new properties inside the Shape InteropGrabBag.
Change-Id: Ieb164268c3b79f2d9b7ed3a4954b5de3b7a5811c
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/color.cxx | 101 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 4 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 55 |
3 files changed, 140 insertions, 20 deletions
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index 52d5465d46a3..4a878273b30c 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -312,6 +312,10 @@ void Color::addTransformation( sal_Int32 nElement, sal_Int32 nValue ) case XML_alphaOff: lclOffValue( mnAlpha, nValue ); break; default: maTransforms.push_back( Transformation( nToken, nValue ) ); } + sal_Int32 nSize = maInteropTransformations.getLength(); + maInteropTransformations.realloc(nSize + 1); + maInteropTransformations[nSize].Name = getColorTransformationName( nToken ); + maInteropTransformations[nSize].Value = ::com::sun::star::uno::Any( nValue ); } void Color::addChartTintTransformation( double fTint ) @@ -332,9 +336,106 @@ void Color::addExcelTintTransformation( double fTint ) void Color::clearTransformations() { maTransforms.clear(); + maInteropTransformations.realloc(0); clearTransparence(); } +::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > Color::getTransformations() const +{ + return maInteropTransformations; +} + +OUString Color::getColorTransformationName( sal_Int32 nElement ) +{ + switch( nElement ) + { + case XML_red: return OUString( "red" ); + case XML_redMod: return OUString( "redMod" ); + case XML_redOff: return OUString( "redOff" ); + case XML_green: return OUString( "green" ); + case XML_greenMod: return OUString( "greenMod" ); + case XML_greenOff: return OUString( "greenOff" ); + case XML_blue: return OUString( "blue" ); + case XML_blueMod: return OUString( "blueMod" ); + case XML_blueOff: return OUString( "blueOff" ); + case XML_hue: return OUString( "hue" ); + case XML_hueMod: return OUString( "hueMod" ); + case XML_hueOff: return OUString( "hueOff" ); + case XML_sat: return OUString( "sat" ); + case XML_satMod: return OUString( "satMod" ); + case XML_satOff: return OUString( "satOff" ); + case XML_lum: return OUString( "lum" ); + case XML_lumMod: return OUString( "lumMod" ); + case XML_lumOff: return OUString( "lumOff" ); + case XML_shade: return OUString( "shade" ); + case XML_tint: return OUString( "tint" ); + case XML_gray: return OUString( "gray" ); + case XML_comp: return OUString( "comp" ); + case XML_inv: return OUString( "inv" ); + case XML_gamma: return OUString( "gamma" ); + case XML_invGamma: return OUString( "invGamma" ); + } + SAL_WARN( "oox.drawingml", "Color::getColorTransformationName - unexpected transformation type" ); + return OUString(); +} + +sal_Int32 Color::getColorTransformationToken( OUString sName ) +{ + if( sName == "red" ) + return XML_red; + else if( sName == "redMod" ) + return XML_redMod; + else if( sName == "redOff" ) + return XML_redOff; + else if( sName == "green" ) + return XML_green; + else if( sName == "greenMod" ) + return XML_greenMod; + else if( sName == "greenOff" ) + return XML_greenOff; + else if( sName == "blue" ) + return XML_blue; + else if( sName == "blueMod" ) + return XML_blueMod; + else if( sName == "blueOff" ) + return XML_blueOff; + else if( sName == "hue" ) + return XML_hue; + else if( sName == "hueMod" ) + return XML_hueMod; + else if( sName == "hueOff" ) + return XML_hueOff; + else if( sName == "sat" ) + return XML_sat; + else if( sName == "satMod" ) + return XML_satMod; + else if( sName == "satOff" ) + return XML_satOff; + else if( sName == "lum" ) + return XML_lum; + else if( sName == "lumMod" ) + return XML_lumMod; + else if( sName == "lumOff" ) + return XML_lumOff; + else if( sName == "shade" ) + return XML_shade; + else if( sName == "tint" ) + return XML_tint; + else if( sName == "gray" ) + return XML_gray; + else if( sName == "comp" ) + return XML_comp; + else if( sName == "inv" ) + return XML_inv; + else if( sName == "gamma" ) + return XML_gamma; + else if( sName == "invGamma" ) + return XML_invGamma; + + SAL_WARN( "oox.drawingml", "Color::getColorTransformationToken - unexpected transformation type" ); + return XML_TOKEN_INVALID; +} + void Color::clearTransparence() { mnAlpha = MAX_PERCENT; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 78b3f3540919..47e84d9c8527 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -565,13 +565,15 @@ Reference< XShape > Shape::createAndInsert( OUString sColorScheme = pFillRef->maPhClr.getSchemeName(); if( !sColorScheme.isEmpty() ) { - Sequence< PropertyValue > aProperties(3); + Sequence< PropertyValue > aProperties(4); aProperties[0].Name = "SchemeClr"; aProperties[0].Value = Any( sColorScheme ); aProperties[1].Name = "Idx"; aProperties[1].Value = Any( pFillRef->mnThemedIdx ); aProperties[2].Name = "Color"; aProperties[2].Value = Any( nFillPhClr ); + aProperties[3].Name = "Transformations"; + aProperties[3].Value = Any( pFillRef->maPhClr.getTransformations() ); PropertyValue pStyleFillRef; pStyleFillRef.Name = "StyleFillRef"; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index db050300cb69..dd165466b5e9 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -20,6 +20,7 @@ #include "oox/core/xmlfilterbase.hxx" #include "oox/export/drawingml.hxx" #include "oox/export/utils.hxx" +#include <oox/drawingml/color.hxx> #include <oox/token/tokens.hxx> #include <cstdio> @@ -1698,6 +1699,40 @@ void DrawingML::WriteFill( Reference< XPropertySet > xPropSet ) return; } +void DrawingML::WriteStyleProperties( sal_Int32 nTokenId, Sequence< PropertyValue > aProperties ) +{ + if( aProperties.getLength() > 0 ) + { + OUString sSchemeClr; + sal_uInt32 nIdx = 0; + Sequence< PropertyValue > aTransformations; + for( sal_Int32 i=0; i < aProperties.getLength(); ++i) + if( aProperties[i].Name == "SchemeClr" ) + aProperties[i].Value >>= sSchemeClr; + else if( aProperties[i].Name == "Idx" ) + aProperties[i].Value >>= nIdx; + else if( aProperties[i].Name == "Transformations" ) + aProperties[i].Value >>= aTransformations; + mpFS->startElementNS( XML_a, nTokenId, XML_idx, I32S( nIdx ), FSEND ); + mpFS->startElementNS( XML_a, XML_schemeClr, + XML_val, USS( sSchemeClr ), + FSEND ); + for( sal_Int32 i = 0; i < aTransformations.getLength(); i++ ) + { + sal_Int32 nValue; + aTransformations[i].Value >>= nValue; + mpFS->singleElementNS( XML_a, Color::getColorTransformationToken( aTransformations[i].Name ), + XML_val, I32S( nValue ), + FSEND ); + } + mpFS->endElementNS( XML_a, XML_schemeClr ); + mpFS->endElementNS( XML_a, nTokenId ); + } + else + // write mock <a:*Ref> tag + mpFS->singleElementNS( XML_a, nTokenId, XML_idx, I32S( 0 ), FSEND ); +} + void DrawingML::WriteShapeStyle( Reference< XPropertySet > xPropSet ) { // check existence of the grab bag @@ -1718,25 +1753,7 @@ void DrawingML::WriteShapeStyle( Reference< XPropertySet > xPropSet ) // write mock <a:lnRef> mpFS->singleElementNS( XML_a, XML_lnRef, XML_idx, I32S( 0 ), FSEND ); - // write <a:fillRef> - if( aFillRefProperties.getLength() > 0 ) - { - OUString sSchemeClr; - sal_uInt32 nIdx = 0; - for( sal_Int32 i=0; i < aFillRefProperties.getLength(); ++i) - if( aFillRefProperties[i].Name == "SchemeClr" ) - aFillRefProperties[i].Value >>= sSchemeClr; - else if( aFillRefProperties[i].Name == "Idx" ) - aFillRefProperties[i].Value >>= nIdx; - mpFS->startElementNS( XML_a, XML_fillRef, XML_idx, I32S( nIdx ), FSEND ); - mpFS->singleElementNS( XML_a, XML_schemeClr, XML_val, - OUStringToOString( sSchemeClr, RTL_TEXTENCODING_ASCII_US ).getStr(), - FSEND ); - mpFS->endElementNS( XML_a, XML_fillRef ); - } - else - // write mock <a:fillRef> - mpFS->singleElementNS( XML_a, XML_fillRef, XML_idx, I32S( 0 ), FSEND ); + WriteStyleProperties( XML_fillRef, aFillRefProperties ); // write mock <a:effectRef> mpFS->singleElementNS( XML_a, XML_effectRef, XML_idx, I32S( 0 ), FSEND ); |