summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-04-22 20:30:24 +0200
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-04-23 14:50:59 +0200
commit71b4af858ea698f9c3fcffdfc61e3f70a7b10f63 (patch)
treed810a0d44fd352290577c582280a2bd4622dcc8e /oox
parent5d2826dacd073e3e99f668358060927751622d52 (diff)
ooxml: Preserve outer shadow effect on shapes.
The goal is preserving the shadow effect with all its attributes using the shape grab bag. This is the relevant piece of XML in the document: <a:effectLst> <a:outerShdw blurRad="50800" dist="38100" dir="2700000" algn="tl" rotWithShape="0"> <a:schemeClr val="accent1"> <a:alpha val="40000" /> </a:schemeClr> </a:outerShdw> </a:effectLst> In first place, we added members to the structure EffectProperties to store the effect name and attributes. Later, when we create the shape, we add them to the shape grab bag together with the shadow color (if it is a theme color we store its name and transformations like in other cases). Finally, we read back all these data from the shape grab bag and write them back to the document. I added a unit test for this shape property. Change-Id: Idda2d5e2970cb8563e2ed13a84b2fa2d4b99aa70
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/effectproperties.cxx30
-rw-r--r--oox/source/drawingml/effectpropertiescontext.cxx29
-rw-r--r--oox/source/drawingml/shape.cxx27
-rw-r--r--oox/source/export/drawingml.cxx118
-rw-r--r--oox/source/export/shapes.cxx1
5 files changed, 205 insertions, 0 deletions
diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx
index 7e89726abf14..be3b3d00cd18 100644
--- a/oox/source/drawingml/effectproperties.cxx
+++ b/oox/source/drawingml/effectproperties.cxx
@@ -30,6 +30,8 @@ void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourcePro
void EffectProperties::assignUsed( const EffectProperties& rSourceProps )
{
maShadow.assignUsed(rSourceProps.maShadow);
+ msUnsupportedEffectName.assignIfUsed( rSourceProps.msUnsupportedEffectName );
+ maUnsupportedEffectAttribs = rSourceProps.maUnsupportedEffectAttribs;
}
void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
@@ -51,6 +53,34 @@ void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
}
}
+void EffectProperties::appendUnsupportedEffectAttrib( const OUString& aKey, const css::uno::Any& aValue )
+{
+ css::beans::PropertyValue aProperty;
+ aProperty.Name = aKey;
+ aProperty.Value = aValue;
+ maUnsupportedEffectAttribs.push_back(aProperty);
+}
+
+css::beans::PropertyValue EffectProperties::getUnsupportedEffect()
+{
+ css::beans::PropertyValue pRet;
+ if(!msUnsupportedEffectName.has())
+ return pRet;
+
+ css::uno::Sequence<css::beans::PropertyValue> aSeq(maUnsupportedEffectAttribs.size());
+ css::beans::PropertyValue* pSeq = aSeq.getArray();
+ for (std::vector<css::beans::PropertyValue>::iterator i = maUnsupportedEffectAttribs.begin(); i != maUnsupportedEffectAttribs.end(); ++i)
+ *pSeq++ = *i;
+
+ pRet.Name = msUnsupportedEffectName.use();
+ pRet.Value = css::uno::Any( aSeq );
+
+ msUnsupportedEffectName.reset();
+ maUnsupportedEffectAttribs.clear();
+
+ return pRet;
+}
+
} // namespace drawingml
diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx
index 53997888e6aa..705adb046d18 100644
--- a/oox/source/drawingml/effectpropertiescontext.cxx
+++ b/oox/source/drawingml/effectpropertiescontext.cxx
@@ -39,6 +39,35 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement,
{
case A_TOKEN( outerShdw ):
{
+ mrEffectProperties.msUnsupportedEffectName = "outerShdw";
+ if( rAttribs.hasAttribute( XML_algn ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "algn",
+ makeAny( rAttribs.getString( XML_algn, "" ) ) );
+ if( rAttribs.hasAttribute( XML_blurRad ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "blurRad",
+ makeAny( rAttribs.getInteger( XML_blurRad, 0 ) ) );
+ if( rAttribs.hasAttribute( XML_dir ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "dir",
+ makeAny( rAttribs.getInteger( XML_dir, 0 ) ) );
+ if( rAttribs.hasAttribute( XML_dist ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "dist",
+ makeAny( rAttribs.getInteger( XML_dist, 0 ) ) );
+ if( rAttribs.hasAttribute( XML_kx ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "kx",
+ makeAny( rAttribs.getInteger( XML_kx, 0 ) ) );
+ if( rAttribs.hasAttribute( XML_ky ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "ky",
+ makeAny( rAttribs.getInteger( XML_ky, 0 ) ) );
+ if( rAttribs.hasAttribute( XML_rotWithShape ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "rotWithShape",
+ makeAny( rAttribs.getInteger( XML_rotWithShape, 0 ) ) );
+ if( rAttribs.hasAttribute( XML_sx ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "sx",
+ makeAny( rAttribs.getInteger( XML_sx, 0 ) ) );
+ if( rAttribs.hasAttribute( XML_sy ) )
+ mrEffectProperties.appendUnsupportedEffectAttrib( "sy",
+ makeAny( rAttribs.getInteger( XML_sy, 0 ) ) );
+
mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
return new ColorContext( *this, mrEffectProperties.maShadow.moShadowColor );
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 1d0d4525801f..d3964be2f862 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -893,6 +893,33 @@ Reference< XShape > Shape::createAndInsert(
putPropertyToGrabBag( "GradFillDefinition", Any( aGradientStops ) );
putPropertyToGrabBag( "OriginalGradFill", aShapeProps.getProperty(PROP_FillGradient) );
}
+
+ // store unsupported effect attributes in the grab bag
+ PropertyValue aEffect = aEffectProperties.getUnsupportedEffect();
+ if( aEffect.Name != "" )
+ {
+ Sequence< PropertyValue > aEffectsGrabBag( 3 );
+ PUT_PROP( aEffectsGrabBag, 0, aEffect.Name, aEffect.Value );
+
+ OUString sColorScheme = aEffectProperties.maShadow.moShadowColor.getSchemeName();
+ if( sColorScheme.isEmpty() )
+ {
+ // RGB color and transparency value
+ PUT_PROP( aEffectsGrabBag, 1, "ShadowRgbClr",
+ aEffectProperties.maShadow.moShadowColor.getColor( rGraphicHelper, nFillPhClr ) );
+ PUT_PROP( aEffectsGrabBag, 2, "ShadowRgbClrTransparency",
+ aEffectProperties.maShadow.moShadowColor.getTransparency() );
+ }
+ else
+ {
+ // scheme color with name and transformations
+ PUT_PROP( aEffectsGrabBag, 1, "ShadowColorSchemeClr", sColorScheme );
+ PUT_PROP( aEffectsGrabBag, 2, "ShadowColorTransformations",
+ aEffectProperties.maShadow.moShadowColor.getTransformations() );
+ }
+
+ putPropertyToGrabBag( "EffectProperties", Any( aEffectsGrabBag ) );
+ }
}
// These can have a custom geometry, so position should be set here,
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index fb0cd6a5df5b..a14cf72bc32d 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2076,6 +2076,124 @@ void DrawingML::WriteShapeStyle( Reference< XPropertySet > xPropSet )
mpFS->singleElementNS( XML_a, XML_fontRef, XML_idx, "minor", FSEND );
}
+void DrawingML::WriteShapeEffects( Reference< XPropertySet > rXPropSet )
+{
+ if( !GetProperty( rXPropSet, "InteropGrabBag" ) )
+ return;
+
+ Sequence< PropertyValue > aGrabBag, aEffectProps;
+ mAny >>= aGrabBag;
+ for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
+ {
+ if( aGrabBag[i].Name == "EffectProperties" )
+ aGrabBag[i].Value >>= aEffectProps;
+ }
+ if( aEffectProps.getLength() == 0 )
+ return;
+
+ OUString sSchemeClr;
+ sal_uInt32 nRgbClr = 0;
+ sal_Int32 nAlpha = MAX_PERCENT;
+ Sequence< PropertyValue > aTransformations;
+ sax_fastparser::FastAttributeList *aOuterShdwAttrList = mpFS->createAttrList();
+ for( sal_Int32 i=0; i < aEffectProps.getLength(); ++i )
+ {
+ if(aEffectProps[i].Name == "outerShdw")
+ {
+ uno::Sequence< beans::PropertyValue > aOuterShdwProps;
+ aEffectProps[0].Value >>= aOuterShdwProps;
+ for( sal_Int32 j=0; j < aOuterShdwProps.getLength(); ++j )
+ {
+ if( aOuterShdwProps[j].Name == "algn" )
+ {
+ OUString sVal;
+ aOuterShdwProps[j].Value >>= sVal;
+ aOuterShdwAttrList->add( XML_algn, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+ else if( aOuterShdwProps[j].Name == "blurRad" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_blurRad, OString::number( nVal ).getStr() );
+ }
+ else if( aOuterShdwProps[j].Name == "dir" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_dir, OString::number( nVal ).getStr() );
+ }
+ else if( aOuterShdwProps[j].Name == "dist" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_dist, OString::number( nVal ).getStr() );
+ }
+ else if( aOuterShdwProps[j].Name == "kx" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_kx, OString::number( nVal ).getStr() );
+ }
+ else if( aOuterShdwProps[j].Name == "ky" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_ky, OString::number( nVal ).getStr() );
+ }
+ else if( aOuterShdwProps[j].Name == "rotWithShape" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_rotWithShape, OString::number( nVal ).getStr() );
+ }
+ else if( aOuterShdwProps[j].Name == "sx" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_sx, OString::number( nVal ).getStr() );
+ }
+ else if( aOuterShdwProps[j].Name == "sy" )
+ {
+ sal_Int32 nVal = 0;
+ aOuterShdwProps[j].Value >>= nVal;
+ aOuterShdwAttrList->add( XML_sy, OString::number( nVal ).getStr() );
+ }
+ }
+ }
+ else if(aEffectProps[i].Name == "ShadowRgbClr")
+ {
+ aEffectProps[i].Value >>= nRgbClr;
+ }
+ else if(aEffectProps[i].Name == "ShadowRgbClrTransparency")
+ {
+ sal_Int32 nTransparency;
+ aEffectProps[i].Value >>= nTransparency;
+ // Calculate alpha value (see oox/source/drawingml/color.cxx : getTransparency())
+ nAlpha = MAX_PERCENT - ( PER_PERCENT * nTransparency );
+ }
+ else if(aEffectProps[i].Name == "ShadowColorSchemeClr")
+ {
+ aEffectProps[i].Value >>= sSchemeClr;
+ }
+ else if(aEffectProps[i].Name == "ShadowColorTransformations")
+ {
+ aEffectProps[i].Value >>= aTransformations;
+ }
+ }
+
+ mpFS->startElementNS(XML_a, XML_effectLst, FSEND);
+ sax_fastparser::XFastAttributeListRef xAttrList( aOuterShdwAttrList );
+ mpFS->startElementNS( XML_a, XML_outerShdw, xAttrList );
+
+ if( sSchemeClr.isEmpty() )
+ WriteColor( nRgbClr, nAlpha );
+ else
+ WriteColor( sSchemeClr, aTransformations );
+
+ mpFS->endElementNS( XML_a, XML_outerShdw );
+ mpFS->endElementNS(XML_a, XML_effectLst);
+}
+
}
}
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 28b01ab60fbd..49d1a4bf31e4 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -373,6 +373,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
{
WriteFill( rXPropSet );
WriteOutline( rXPropSet );
+ WriteShapeEffects( rXPropSet );
}
pFS->endElementNS( mnXmlNamespace, XML_spPr );