Sunday, August 15, 2010

STLPropertySet and Effects in Impress

The STLPropertySet class is currently only used for two things :
1) CustomAnimationPane results
2) SfxAnimationItem created for this project :)
As I explain what it does, you will find that it could be used in other places around Impress code and that it shouldn't be forgotten deep down in the UI code
As a part of this project the code for the STLPropertySet was moved from the CustomAnimationPane files, to an independent file. Later on we realized how applicable it really is (and also had problems compiling ;) ) so it was moved to sd/source/core and the header now resides in sd/inc.
STLPropertySet is basically a map of items describing an effect. The key of the item is a so-called handle, which is just an int constant representing what that map entry describes. The Value in the map can be whatever, so the uno::Any is used as a type for the value. When you want to put an item into the STLPropertySet, you will have to use uno::makeAny on the value, and one of the integers defined in the STLPropertySet.hxx as a key.
There are ~30-40 handles, but a few properties are very important to represent the effect
- Preset ID
- Effect duration
Using these two fields, you can create an effect and put it into the MainSequence.

MainSequence is the thing you see in the CustomAnimationPane on the right hand side - a list of all the effects for that particular slide. Every slide (SdPage) has its own MainSequence. When adding/removing elements from the MainSequence, you have to use a mutex, and rebuild it afterwards. The rebuilding makes sure that the effects are triggered in a proper order.

Presets (CustomAnimationPreset) can be divided in several groups (or internally called "Classes") - and you can intuitively understand this if you look at the 'Add Effect' dialog - Entrance, Exit, Emphasis, Motion Paths, Misc...
Presets are not actually effects, but they are something we would intuitively call an animation. They can be used to make an effect, but for a proper effect you have some more options to set.
The smallest group of options to make an effect are
- Preset ID
- Effect duration.
Using these, you can create an XAnimationNode, and initialize the actual effect.
To make a real effect, you have to have an instance of the Main Sequence at hand.
This was a tricky part for this project - as mentioned above, the MainSequence is specific to a page. When applying an effect to all members of a Stylesheet, we have no idea how many objects there are, on which pages they are, etc. That's why we had to keep the information as a PresetId + duration

What gives you exactly that information, is the CustomAnimationCreateDialog. The Custom Animation tab in the Edit Style dialog is nothing but a cleverly remade CustomAnimationCreateDialog.
Preset ID and the duration can be safely stored in an STLPropertySet, and then wrapped into an SfxAnimationItem, and that can be put into a SfxItemPool, and that's exactly what a stylesheet is...can you see the puzzle pieces connecting? :)

No comments:

Post a Comment