diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-12 11:46:50 +0200 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-13 10:28:54 +0200 |
commit | e8679367c9020c22a787f441c4d5a43647986e0f (patch) | |
tree | 347698f62e231a5dc69ba42bec0869a02eb60ade /oox | |
parent | ac9f7c8d1abffe882093f93ea70dc5e31d28a7a2 (diff) |
ooxml: Preserve shape 3d effects: material
Shapes 3D effects can specify a material like in the following example:
<a:sp3d prstMaterial="metal" z="488950" />
This patch preserves the prstMaterial attribute in the sp3d tag using
the shape grab bag and modifies an existing unit test to add this
check.
Change-Id: I7be2dbbcc7e599d5f0fb8fa53ec1d180c18d8ebd
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/scene3dcontext.cxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/shape3dproperties.cxx | 33 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 8 |
3 files changed, 41 insertions, 2 deletions
diff --git a/oox/source/drawingml/scene3dcontext.cxx b/oox/source/drawingml/scene3dcontext.cxx index 124a74183f48..ec9204b94a25 100644 --- a/oox/source/drawingml/scene3dcontext.cxx +++ b/oox/source/drawingml/scene3dcontext.cxx @@ -78,6 +78,8 @@ Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper& rPare mr3DProperties.mnContourW = rAttribs.getInteger( XML_contourW, 0 ); if( rAttribs.hasAttribute( XML_z ) ) mr3DProperties.mnShapeZ = rAttribs.getInteger( XML_z, 0 ); + if( rAttribs.hasAttribute( XML_prstMaterial ) ) + mr3DProperties.mnMaterial = rAttribs.getToken( XML_prstMaterial, XML_none ); } ContextHandlerRef Shape3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) diff --git a/oox/source/drawingml/shape3dproperties.cxx b/oox/source/drawingml/shape3dproperties.cxx index 28d907922b31..9bb434ab3718 100644 --- a/oox/source/drawingml/shape3dproperties.cxx +++ b/oox/source/drawingml/shape3dproperties.cxx @@ -192,6 +192,31 @@ OUString Shape3DProperties::getBevelPresetTypeString( sal_Int32 nType ) return OUString(); } +OUString Shape3DProperties::getPresetMaterialTypeString( sal_Int32 nType ) +{ + switch (nType) + { + case XML_legacyMatte: return OUString("legacyMatte"); + case XML_legacyPlastic: return OUString("legacyPlastic"); + case XML_legacyMetal: return OUString("legacyMetal"); + case XML_legacyWireframe: return OUString("legacyWireframe"); + case XML_matte: return OUString("matte"); + case XML_plastic: return OUString("plastic"); + case XML_metal: return OUString("metal"); + case XML_warmMatte: return OUString("warmMatte"); + case XML_translucentPowder: return OUString("translucentPowder"); + case XML_powder: return OUString("powder"); + case XML_dkEdge: return OUString("dkEdge"); + case XML_softEdge: return OUString("softEdge"); + case XML_clear: return OUString("clear"); + case XML_flat: return OUString("flat"); + case XML_softmetal: return OUString("softmetal"); + case XML_none: return OUString("none"); + } + SAL_WARN( "oox.drawingml", "Shape3DProperties::getPresetMaterialTypeString - unexpected token" ); + return OUString(); +} + css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getCameraAttributes() { css::uno::Sequence<css::beans::PropertyValue> aSeq(6); @@ -302,7 +327,7 @@ css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getBevelAttri css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getShape3DAttributes() { - css::uno::Sequence<css::beans::PropertyValue> aSeq(5); + css::uno::Sequence<css::beans::PropertyValue> aSeq(6); sal_Int32 nSize = 0; if( mnExtrusionH.has() ) { @@ -322,6 +347,12 @@ css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getShape3DAtt aSeq[nSize].Value = css::uno::Any( mnShapeZ.use() ); nSize++; } + if( mnMaterial.has() ) + { + aSeq[nSize].Name = "prstMaterial"; + aSeq[nSize].Value = css::uno::Any( getPresetMaterialTypeString( mnMaterial.use() ) ); + nSize++; + } if( maTopBevelProperties.has() ) { aSeq[nSize].Name = "bevelT"; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 90000a1b78ea..17d22737dce9 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2426,7 +2426,13 @@ void DrawingML::WriteShape3DEffects( Reference< XPropertySet > xPropSet ) nToken = XML_z; aShape3DAttrList->add( nToken, OString::number( nVal ).getStr() ); } - if( aShape3DProps[i].Name == "bevelT" || aShape3DProps[i].Name == "bevelB" ) + else if( aShape3DProps[i].Name == "prstMaterial" ) + { + OUString sVal; + aShape3DProps[i].Value >>= sVal; + aShape3DAttrList->add( XML_prstMaterial, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + else if( aShape3DProps[i].Name == "bevelT" || aShape3DProps[i].Name == "bevelB" ) { Sequence< PropertyValue > aBevelProps; aShape3DProps[i].Value >>= aBevelProps; |