summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-05-08 14:25:10 +0200
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-05-09 14:10:46 +0200
commit6566c218afec3cd8c4d36094777bc30b1970e9e4 (patch)
tree5982d9710abbe04199b34343e5afe1458c316678 /oox
parent0df9ec782efeb24c02f7c5baef53bf2fa75a4bc5 (diff)
ooxml: Preserve shape 3d effects: z, contour and extrusion
Shapes can contain 3D effects like in the following example: <a:sp3d z="488950" extrusionH="63500" contourW="50800"/> This patch preserves the a:sp3d tag and its attributes using the shape grab bag and modifies an existing unit test to add this check. Change-Id: Ice3cae39c71784be0f6c7f2700b07c21a5e1fb6e
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/scene3dcontext.cxx12
-rw-r--r--oox/source/drawingml/shape.cxx4
-rw-r--r--oox/source/drawingml/shape3dproperties.cxx26
-rw-r--r--oox/source/drawingml/shapepropertiescontext.cxx3
-rw-r--r--oox/source/export/drawingml.cxx30
5 files changed, 71 insertions, 4 deletions
diff --git a/oox/source/drawingml/scene3dcontext.cxx b/oox/source/drawingml/scene3dcontext.cxx
index 7d95b7370503..bbae7abedd10 100644
--- a/oox/source/drawingml/scene3dcontext.cxx
+++ b/oox/source/drawingml/scene3dcontext.cxx
@@ -68,6 +68,18 @@ ContextHandlerRef Scene3DPropertiesContext::onCreateContext( sal_Int32 aElementT
return 0;
}
+Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, Shape3DProperties& r3DProperties ) throw()
+: ContextHandler2( rParent )
+, mr3DProperties( r3DProperties )
+{
+ if( rAttribs.hasAttribute( XML_extrusionH ) )
+ mr3DProperties.mnExtrusionH = rAttribs.getInteger( XML_extrusionH, 0 );
+ if( rAttribs.hasAttribute( XML_contourW ) )
+ mr3DProperties.mnContourW = rAttribs.getInteger( XML_contourW, 0 );
+ if( rAttribs.hasAttribute( XML_z ) )
+ mr3DProperties.mnShapeZ = rAttribs.getInteger( XML_z, 0 );
+}
+
Scene3DRotationPropertiesContext::Scene3DRotationPropertiesContext( ContextHandler2Helper& rParent, RotationProperties& rRotationProperties ) throw()
: ContextHandler2( rParent )
, mrRotationProperties( rRotationProperties )
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 564f51bbd3a0..da125cfa4ab9 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -940,11 +940,13 @@ Reference< XShape > Shape::createAndInsert(
// add 3D effects if any
Sequence< PropertyValue > aCamera3DEffects = get3DProperties().getCameraAttributes();
Sequence< PropertyValue > aLightRig3DEffects = get3DProperties().getLightRigAttributes();
+ Sequence< PropertyValue > aShape3DEffects = get3DProperties().getShape3DAttributes();
if( aCamera3DEffects.getLength() > 0 || aLightRig3DEffects.getLength() > 0 )
{
- Sequence< PropertyValue > a3DEffectsGrabBag( 2 );
+ Sequence< PropertyValue > a3DEffectsGrabBag( 3 );
PUT_PROP( a3DEffectsGrabBag, 0, "Camera", Any( aCamera3DEffects ) );
PUT_PROP( a3DEffectsGrabBag, 1, "LightRig", Any( aLightRig3DEffects ) );
+ PUT_PROP( a3DEffectsGrabBag, 2, "Shape3D", Any( aShape3DEffects ) );
putPropertyToGrabBag( "3DEffectProperties", Any( a3DEffectsGrabBag ) );
}
}
diff --git a/oox/source/drawingml/shape3dproperties.cxx b/oox/source/drawingml/shape3dproperties.cxx
index 47346a963b1c..7da8a0b4d9f1 100644
--- a/oox/source/drawingml/shape3dproperties.cxx
+++ b/oox/source/drawingml/shape3dproperties.cxx
@@ -253,6 +253,32 @@ css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getLightRigAt
return aSeq;
}
+css::uno::Sequence< css::beans::PropertyValue > Shape3DProperties::getShape3DAttributes()
+{
+ css::uno::Sequence<css::beans::PropertyValue> aSeq(3);
+ sal_Int32 nSize = 0;
+ if( mnExtrusionH.has() )
+ {
+ aSeq[nSize].Name = "extrusionH";
+ aSeq[nSize].Value = css::uno::Any( mnExtrusionH.use() );
+ nSize++;
+ }
+ if( mnContourW.has() )
+ {
+ aSeq[nSize].Name = "contourW";
+ aSeq[nSize].Value = css::uno::Any( mnContourW.use() );
+ nSize++;
+ }
+ if( mnShapeZ.has() )
+ {
+ aSeq[nSize].Name = "z";
+ aSeq[nSize].Value = css::uno::Any( mnShapeZ.use() );
+ nSize++;
+ }
+ aSeq.realloc( nSize );
+ return aSeq;
+}
+
} // namespace drawingml
diff --git a/oox/source/drawingml/shapepropertiescontext.cxx b/oox/source/drawingml/shapepropertiescontext.cxx
index 0823e67240c7..daf87312402c 100644
--- a/oox/source/drawingml/shapepropertiescontext.cxx
+++ b/oox/source/drawingml/shapepropertiescontext.cxx
@@ -99,8 +99,9 @@ ContextHandlerRef ShapePropertiesContext::onCreateContext( sal_Int32 aElementTok
return new Scene3DPropertiesContext( *this, mrShape.get3DProperties() );
break;
- // todo
+ // todo not supported by core, only for preservation via grab bags
case A_TOKEN( sp3d ): // CT_Shape3D
+ return new Shape3DPropertiesContext( *this, rAttribs, mrShape.get3DProperties() );
break;
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index abe338b70bf4..0b437db8acb9 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2277,7 +2277,7 @@ void DrawingML::WriteShape3DEffects( Reference< XPropertySet > xPropSet )
return;
// extract the relevant properties from the grab bag
- Sequence< PropertyValue > aGrabBag, aEffectProps, aLightRigProps;
+ Sequence< PropertyValue > aGrabBag, aEffectProps, aLightRigProps, aShape3DProps;
mAny >>= aGrabBag;
for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i )
if( aGrabBag[i].Name == "3DEffectProperties" )
@@ -2290,10 +2290,12 @@ void DrawingML::WriteShape3DEffects( Reference< XPropertySet > xPropSet )
a3DEffectProps[j].Value >>= aEffectProps;
else if( a3DEffectProps[j].Name == "LightRig" )
a3DEffectProps[j].Value >>= aLightRigProps;
+ else if( a3DEffectProps[j].Name == "Shape3D" )
+ a3DEffectProps[j].Value >>= aShape3DProps;
}
break;
}
- if( aEffectProps.getLength() == 0 && aLightRigProps.getLength() == 0 )
+ if( aEffectProps.getLength() == 0 && aLightRigProps.getLength() == 0 && aShape3DProps.getLength() == 0 )
return;
bool bCameraRotationPresent = false;
@@ -2402,6 +2404,30 @@ void DrawingML::WriteShape3DEffects( Reference< XPropertySet > xPropSet )
mpFS->singleElementNS( XML_a, XML_lightRig, XML_rig, "threePt", XML_dir, "t", FSEND );
mpFS->endElementNS( XML_a, XML_scene3d );
+
+ if( aShape3DProps.getLength() == 0 )
+ return;
+
+ sax_fastparser::FastAttributeList *aShape3DAttrList = mpFS->createAttrList();
+ for( sal_Int32 i=0; i < aShape3DProps.getLength(); ++i )
+ {
+ if( aShape3DProps[i].Name == "extrusionH" || aShape3DProps[i].Name == "contourW" || aShape3DProps[i].Name == "z" )
+ {
+ sal_Int32 nVal = 0, nToken = XML_none;
+ aShape3DProps[i].Value >>= nVal;
+ if( aShape3DProps[i].Name == "extrusionH" )
+ nToken = XML_extrusionH;
+ else if( aShape3DProps[i].Name == "contourW" )
+ nToken = XML_contourW;
+ else if( aShape3DProps[i].Name == "z" )
+ nToken = XML_z;
+ aShape3DAttrList->add( nToken, OString::number( nVal ).getStr() );
+ }
+ }
+
+ sax_fastparser::XFastAttributeListRef xAttrList( aShape3DAttrList );
+ mpFS->startElementNS( XML_a, XML_sp3d, xAttrList );
+ mpFS->endElementNS( XML_a, XML_sp3d );
}
}