Animations and Interactions
- Custom Slide Show
- Presentation Effects
- Slide Transition
- Animations and Interactions
In a Presentation, each shape of the draw and master page provides the com.sun.star.presentation.Shape service with a number of properties that describe the manner the shape is displayed or acting in a presentation.
There are two kinds of shape effects. The first kind of effects are visual changes, such as animations and dimming effects. The second kind of effects are OnClick
actions. All of these effects are controlled by the properties of a presentation shape:
Properties of com.sun.star.presentation.Shape | |
---|---|
OnClick | com.sun.star.presentation.ClickAction. Selects an action performed after the user clicks on this shape. Possible values are:
|
Bookmark | string - A generic URL for the property OnClick .
|
Verb | long - Valid only for OLE shapes. Specifies an "OLE2" verb for the ClickAction VERB in the property OnClick . For possible verbs, select the OLE shape, and point the cursor to Edit - Object. The order of appearance corresponds to the value needed for Verb .
|
DimPrevious | boolean - Only valid when Effect contains an AnimationEffect . If true , this shape is painted using DimColor on the next click after finishing the AnimationEffect .
|
DimHide | boolean - Only valid when Effect contains an AnimationEffect . If this property and the property DimPrevious are both true, the shape is hidden on the next click after the AnimationEffect has finished.
|
DimColor | long - Only valid when Effect contains an AnimationEffect . This color is used to paint the shape on the next click after the animation effect has finished. The property DimPrevious must be true and DimHide must be false for this property to work.
|
Effect | com.sun.star.presentation.AnimationEffect. Selects the animation effect of this shape. For possible values see the table below. |
PresentationOrder | long - This is the position of this shape in the order of the shapes that can be animated on its page. The animations are executed in the order given in PresentationOrder , starting at the shape with the PresentationOrder 1 . You can change the order by changing this number. Setting it to 1 makes this shape the first shape in the execution order for the animation effects.
|
SoundOn | boolean - If true, the sound file specified in Sound is played while the animation effect is executed.
|
Sound | string - This is the URL to a sound file that is played while the animation effect of this shape is running.
|
PlayFull | boolean - If true, the sound specified in the Sound property of this shape is played completely. If false, the sound stops after completing the AnimationEffect specified in Effect.
|
Speed | com.sun.star.presentation.AnimationSpeed This is the speed of the animation effect. Possible values: SLOW , MEDIUM , and FAST .
|
TextEffect | com.sun.star.presentation.AnimationEffect. This is the animation effect for the text inside this shape. For possible values, see the table below. |
IsEmptyPresentationObject | [readonly] boolean - If this is a default presentation object and if it is empty, this property is true.
|
IsPresentationObject | [readonly] boolean - If true, a shape is part of the current AutoLayout and is considered a presentation object. AutoLayouts are predefined page layouts consisting of shapes, such as a title box and an outline box.
|
The next table contains all available com.sun.star.presentation.AnimationEffect enums.
NONE | RANDOM | DISSOLVE |
APPEAR | HIDE | PATH |
FADE_FROM_LEFT FADE_FROM_RIGHT |
MOVE_FROM_LEFT MOVE_FROM_RIGHT |
ZOOM_IN_FROM_LEFT ZOOM_IN_FROM_RIGHT |
CLOCKWISE COUNTERCLOCKWISE |
CLOSE_VERTICAL CLOSE_HORIZONTAL |
OPEN_VERTICAL OPEN_HORIZONTAL |
LASER_FROM_LEFT LASER_FROM_RIGHT |
MOVE_TO_LEFT MOVE_TO_RIGHT |
MOVE_SHORT_TO_LEFT MOVE_SHORT_TO_RIGHT |
ZOOM_OUT_FROM_LEFT ZOOM_OUT_FROM_RIGHT |
STRETCH_FROM_LEFT STRETCH_FROM_RIGHT |
MOVE_SHORT_FROM_LEFT MOVE_SHORT_FROM_RIGHT |
WAVYLINE_FROM_LEFT WAVYLINE_FROM_RIGHT |
SPIRALIN_LEFT SPIRALIN_RIGHT |
FADE_FROM_CENTER FADE_TO_CENTER |
ZOOM_IN ZOOM_IN_SMALL |
ZOOM_OUT ZOOM_OUT_SMALL |
VERTICAL_LINES HORIZONTAL_LINES |
ZOOM_IN_FROM_CENTER ZOOM_OUT_FROM_CENTER |
VERTICAL_CHECKERBOARD HORIZONTAL_CHECKERBOARD |
VERTICAL_ROTATE HORIZONTAL_ROTATE |
HORIZONTAL_STRETCH VERTICAL_STRETCH |
The next example demonstrates how to set object effects and object interaction.
The example use a method createAndInsertShape()
from the ShapeHelper
class. It takes the drawing document, the XShapes
interface of the DrawPage
the shape is to be inserted in, the position and size of the new shape, and the service name of the required shape. It delegates shape creation to the helper method createShape()
and inserts the new shape into the given XShapes
container. Finally, it retrieves the XPropertySet
interface of the inserted shape and returns it to the caller.
public static XPropertySet createAndInsertShape( XComponent xDrawDoc, XShapes xShapes, Point aPos, Size aSize, String sShapeType) throws java.lang.Exception { XShape xShape = createShape(xDrawDoc, aPos, aSize, sShapeType); xShapes.add(xShape); XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xShape); return xPropSet; }
The following example shows animations and OnClick
actions for four shapes. On click, the first shape builds up in a wavy line from the bottom and is dimmed (painted) red afterwards. The second shape is hidden on click. Clicking the third shape makes the presentation jump to the first page, whereas clicking the fourth shape jumps to a bookmark. The bookmark contains the name of the second slide "page - two".
XShapes xShapes; XPropertySet xShapePropSet; XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier)UnoRuntime.queryInterface( XDrawPagesSupplier.class, xComponent); XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages(); // create pages, so that three are available while (xDrawPages.getCount() < 3) xDrawPages.insertNewByIndex(0); // get the shape container for page one xShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, xDrawPages.getByIndex(0)); // create a rectangle that is placed on the top left of the page xShapePropSet = ShapeHelper.createAndInsertShape( xComponent, xShapes, new Point(1000, 1000), new Size(5000, 5000), "com.sun.star.drawing.RectangleShape" ); // and now set an object animation xShapePropSet.setPropertyValue("Effect", com.sun.star.presentation.AnimationEffect.WAVYLINE_FROM_BOTTOM); /* the following three properties provoke that the shape is dimmed to red after the animation has been finished */ xShapePropSet.setPropertyValue("DimHide", new Boolean(false)); xShapePropSet.setPropertyValue("DimPrevious", new Boolean(true)); xShapePropSet.setPropertyValue("DimColor", new Integer(0xff0000)); // get the shape container for the second page xShapes = (XShapes)UnoRuntime.queryInterface(XShapes.class, xDrawPages.getByIndex(1)); // create an ellipse that is placed on the bottom right of second page xShapePropSet = ShapeHelper.createAndInsertShape( xComponent, xShapes, new Point(21000, 15000), new Size(5000, 5000), "com.sun.star.drawing.EllipseShape"); xShapePropSet.setPropertyValue("Effect", com.sun.star.presentation.AnimationEffect.HIDE); /* create two objects for the third page. clicking the first object lets the presentation jump to page one by using ClickAction.FIRSTPAGE, the second object lets the presentation jump to page two by using a ClickAction.BOOKMARK */ xShapes = (XShapes)UnoRuntime.queryInterface(XShapes.class, xDrawPages.getByIndex(2)); xShapePropSet = ShapeHelper.createAndInsertShape(xComponent, xShapes, new Point(1000, 8000), new Size(5000, 5000), "com.sun.star.drawing.EllipseShape" ); xShapePropSet.setPropertyValue("Effect", com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM ); xShapePropSet.setPropertyValue("OnClick", com.sun.star.presentation.ClickAction.FIRSTPAGE); xShapePropSet = ShapeHelper.createAndInsertShape(xComponent, xShapes, new Point(22000, 8000), new Size(5000, 5000), "com.sun.star.drawing.RectangleShape"); xShapePropSet.setPropertyValue("Effect", com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM); xShapePropSet.setPropertyValue( "OnClick", com.sun.star.presentation.ClickAction.BOOKMARK); // set the name of page two, and use it with the bookmark action XNamed xPageName = (Xnamed)UnoRuntime.queryInterface(XNamed.class, xDrawPages.getByIndex(1)); xPageName.setName("page - two"); xShapePropSet.setPropertyValue("Bookmark", xPageName.getName());
Content on this page is licensed under the Public Documentation License (PDL). |