Working with Animation
Applies to: Excel 2010 | Office 2010 | PowerPoint 2010 | Word 2010
In this article
Animation in PresentationML
Open XML SDK 2.0 Animate Class
Working with the Animate Class
This topic discusses the Open XML SDK 2.0 Animate class and how it relates to the Open XML File Format PresentationML schema. For more information about the overall structure of the parts and elements that make up a PresentationML document, see Structure of a PresentationML Document.
Animation in PresentationML
The ISO/IEC 29500 specification describes the Animation section of the Open XML PresentationML framework as follows:
The Animation section of the PresentationML framework stores the movement and related information of objects. This schema is loosely based on the syntax and concepts from the Synchronized Multimedia Integration Language (SMIL), a W3C Recommendation for describing multimedia presentations using XML. The schema describes all the animations effects that reside on a slide and also the animation that occurs when going from slide to slide (slide transition). Animations on a slide are inherently time-based and consist of an animation effects on an object or text. Slide transitions however do not follow this concept and always appear before any animation on a slide. All elements described in this schema are contained within the slide XML file. More specifically they are in the <transition> and the <timing> element as shown below:
<p:sld>
<p:cSld> … </p:cSld>
<p:clrMapOvr> … </p:clrMapOvr>
<p:transition> … </p:transition>
<p:timing> … </p:timing>
</p:sld>
© ISO/IEC29500: 2008.
Animation consists of several behaviors, the most basic of which is the Animate behavior, represented by the <anim> element. The ISO/IEC 29500 specification describes the Open XML PresentationML <anim> element used to represent basic animation behavior in a PresentationML document as follows:
This element is a generic animation element that requires little or no semantic understanding of the attribute being animated. It can animate text within a shape or even the shape itself.[Example: Consider trying to emphasize text within a shape by changing the size of its font by 150%. The <anim> element should be used as follows:
<p:anim to="1.5" calcmode="lin" valueType="num">
<p:cBhvr override="childStyle">
<p:cTn id="1" dur="2000" fill="hold"/>
<p:tgtEl>
<p:spTgt spid="1">
<p:txEl>
<p:charRg st="1" end="4"/>
</p:txEl>
</p:spTgt>
</p:tgtEl>
<p:attrNameLst>
<p:attrName>style.fontSize</p:attrName>
</p:attrNameLst>
</p:cBhvr>
</p:anim>
end example]
© ISO/IEC29500: 2008.
The following table lists the child elements of the <anim> element used when working with animation and the Open XML SDK 2.0 classes that correspond to them.
PresentationML Element |
Open XML SDK 2.0 Class |
---|---|
<cBhvr> |
|
<tavLst> |
The following table from the ISO/IEC 29500 specification describes the attributes of the <anim> element.
Attributes |
Description |
---|---|
by |
This attribute specifies a relative offset value for the animation with respect to its position before the start of the animation. The possible values for this attribute are defined by the W3C XML Schema string data type. |
calcmode |
This attribute specifies the interpolation mode for the animation. The possible values for this attribute are defined by theST_TLAnimateBehaviorCalcMode simple type (§19.7.20). |
from |
This attribute specifies the starting value of the animation. The possible values for this attribute are defined by the W3C XML Schema string data type. |
to |
This attribute specifies the ending value for the animation as a percentage. The possible values for this attribute are defined by the W3C XML Schema string data type. |
valueType |
This attribute specifies the type of property value. The possible values for this attribute are defined by theST_TLAnimateBehaviorValueType simple type (§19.7.21). |
© ISO/IEC29500: 2008.
Open XML SDK 2.0 Animate Class
The OXML SDK Animate class represents the <anim> element defined in the Open XML File Format schema for PresentationML documents. Use the Animate class to manipulate individual <anim> elements in a PresentationML document.
Classes that represent child elements of the <anim> element and that are therefore commonly associated with the Animate class are shown in the following list.
CommonBehavior Class
The CommonBehavior class corresponds to the <cBhvr> element. The following information from the ISO/IEC 29500 specification introduces the <cBhvr>element:
This element describes the common behaviors of animations.
[Example: Consider trying to emphasize text within a shape by changing the size of its font. The <anim> element should be used as follows:
<p:anim to="1.5" calcmode="lin" valueType="num">
<p:cBhvr override="childStyle">
<p:cTn id="6" dur="2000" fill="hold"/>
<p:tgtEl>
<p:spTgt spid="3">
<p:txEl>
<p:charRg st="4294967295" end="4294967295"/>
</p:txEl>
</p:spTgt>
</p:tgtEl>
<p:attrNameLst>
<p:attrName>style.fontSize</p:attrName>
</p:attrNameLst>
</p:cBhvr>
</p:anim>
end example]
© ISO/IEC29500: 2008.
TimeAnimateValueList Class
The TimeAnimateValueList class corresponds to the <tavLst> element. The following information from the ISO/IEC 29500 specification introduces the <tavLst> element:
This element specifies a list of time animated value elements.
[Example: Consider a shape with a "fly-in" animation. The <tav> element should be used as follows:
<p:anim calcmode="lin" valueType="num">
<p:cBhvr additive="base"> … </p:cBhvr>
<p:tavLst>
<p:tav tm="0">
<p:val>
<p:strVal val="1+#ppt_h/2"/>
</p:val>
</p:tav>
<p:tav tm="100000">
<p:val>
<p:strVal val="#ppt_y"/>
</p:val>
</p:tav>
</p:tavLst>
</p:anim>
end example]
© ISO/IEC29500: 2008.
Working with the Animate Class
The Animate class, which represents the <anim> element, is therefore also associated with other classes that represent the child elements of the <anim> element, including the CommonBehavior class, which describes common animation behaviors, and the TimeAnimateValueList class, which specifies a list of time-animated value elements, as shown in the previous XML code. Other classes associated with the Animate class are the Timing class, which specifies timing information for all the animations on the slide, and the TargetElement class, which specifies the target child elements to which the animation effects are applied.
See Also
Concepts
About the Open XML SDK 2.0 for Microsoft Office
How to: Create a Presentation by Providing a File Name
How to: Insert a New Slide into a Presentation