summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-04-29 19:55:35 +0200
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-04-30 16:46:09 +0200
commit5b3f88bfea3111e9b9fb26ef9d84f9018c11ab7e (patch)
tree69dfe147520c90eccf43f854431fa3619f830477 /oox
parentdddae1f0b950f1ce8ab4bcd24991f1917fa36aa6 (diff)
ooxml: Preserve soft edge effect on shapes.
Reused most of the code of outerShdw and innerShdw effects, but adding a new attribute "rad" and a flag to check if a color definition must be written inside the effect definition. Finally, modified an existing unit test to add a check for softEdge. Change-Id: I0d32714bde9a5b05c726acd47b85b1dea3c6a581
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/effectpropertiescontext.cxx10
-rw-r--r--oox/source/export/drawingml.cxx39
2 files changed, 41 insertions, 8 deletions
diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx
index 40f73187a655..90e70505187c 100644
--- a/oox/source/drawingml/effectpropertiescontext.cxx
+++ b/oox/source/drawingml/effectpropertiescontext.cxx
@@ -62,6 +62,9 @@ void EffectPropertiesContext::saveUnsupportedAttribs( const AttributeList& rAttr
if( rAttribs.hasAttribute( XML_sy ) )
mrEffectProperties.appendUnsupportedEffectAttrib( "sy",
makeAny( rAttribs.getInteger( XML_sy, 0 ) ) );
+ if( rAttribs.hasAttribute( XML_rad ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "rad",
+ makeAny( rAttribs.getInteger( XML_rad, 0 ) ) );
}
ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
@@ -88,6 +91,13 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement,
return new ColorContext( *this, mrEffectProperties.maShadow.moShadowColor );
}
break;
+ case A_TOKEN( softEdge ):
+ {
+ mrEffectProperties.msUnsupportedEffectName = "softEdge";
+ saveUnsupportedAttribs( rAttribs );
+ return new ColorContext( *this, mrEffectProperties.maShadow.moShadowColor );
+ }
+ break;
}
return 0;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index ece1fa28e778..e9b4b2b7f41a 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2092,6 +2092,7 @@ void DrawingML::WriteShapeEffects( Reference< XPropertySet > rXPropSet )
return;
OUString sSchemeClr;
+ bool bContainsColor = false;
sal_uInt32 nRgbClr = 0;
sal_Int32 nEffectToken = 0;
sal_Int32 nAlpha = MAX_PERCENT;
@@ -2099,11 +2100,24 @@ void DrawingML::WriteShapeEffects( Reference< XPropertySet > rXPropSet )
sax_fastparser::FastAttributeList *aOuterShdwAttrList = mpFS->createAttrList();
for( sal_Int32 i=0; i < aEffectProps.getLength(); ++i )
{
- if( aEffectProps[i].Name == "outerShdw" || aEffectProps[i].Name == "innerShdw" )
+ if( aEffectProps[i].Name == "outerShdw" || aEffectProps[i].Name == "innerShdw"
+ || aEffectProps[i].Name == "softEdge" )
{
- nEffectToken = ( aEffectProps[i].Name == "outerShdw") ?
- FSNS( XML_a, XML_outerShdw ) :
- FSNS( XML_a, XML_innerShdw );
+ // assign the proper tag and enable bContainsColor if necessary
+ if( aEffectProps[i].Name == "outerShdw" )
+ {
+ nEffectToken = FSNS( XML_a, XML_outerShdw );
+ bContainsColor = true;
+ }
+ else if( aEffectProps[i].Name == "innerShdw" )
+ {
+ nEffectToken = FSNS( XML_a, XML_innerShdw );
+ bContainsColor = true;
+ }
+ else if( aEffectProps[i].Name == "softEdge" )
+ nEffectToken = FSNS( XML_a, XML_softEdge );
+
+ // read tag attributes
uno::Sequence< beans::PropertyValue > aOuterShdwProps;
aEffectProps[i].Value >>= aOuterShdwProps;
for( sal_Int32 j=0; j < aOuterShdwProps.getLength(); ++j )
@@ -2162,6 +2176,12 @@ void DrawingML::WriteShapeEffects( Reference< XPropertySet > rXPropSet )
aOuterShdwProps[j].Value >>= nVal;
aOuterShdwAttrList->add( XML_sy, OString::number( nVal ).getStr() );
}
+ else if( aOuterShdwProps[j].Name == "rad" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_rad, OString::number( nVal ).getStr() );
+ }
}
}
else if(aEffectProps[i].Name == "ShadowRgbClr")
@@ -2189,10 +2209,13 @@ void DrawingML::WriteShapeEffects( Reference< XPropertySet > rXPropSet )
sax_fastparser::XFastAttributeListRef xAttrList( aOuterShdwAttrList );
mpFS->startElement( nEffectToken, xAttrList );
- if( sSchemeClr.isEmpty() )
- WriteColor( nRgbClr, nAlpha );
- else
- WriteColor( sSchemeClr, aTransformations );
+ if( bContainsColor )
+ {
+ if( sSchemeClr.isEmpty() )
+ WriteColor( nRgbClr, nAlpha );
+ else
+ WriteColor( sSchemeClr, aTransformations );
+ }
mpFS->endElement( nEffectToken );
mpFS->endElementNS(XML_a, XML_effectLst);