Animations and Interactions

From Apache OpenOffice Wiki
Jump to: navigation, search



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:
  • NONE - no action is performed on click
  • PREVPAGE - the presentation jumps to the previous page
  • NEXTPAGE - the presentation jumps to the next page
  • FIRSTPAGE - the presentation continues with the first page
  • LASTPAGE - the presentation continues with the last page
  • BOOKMARK - the presentation jumps to the bookmark URL defined in the shape property Bookmark
  • DOCUMENT - the presentation jumps to the document given in Bookmark. It selects the object whose name is given after a # in the Bookmark URL.
  • INVISIBLE - the object renders itself invisible after a click
  • SOUND - the sound specified in Sound is played after a click
  • VERB - the OLE verb specified in the shape property Verb is performed on this object
  • VANISH - the object vanishes with the effect specified in the property Effect
  • PROGRAM - the program specified in Bookmark is executed after a click
  • MACRO - the OpenOffice.org Basic macro specified in Bookmark is executed after the click. For the syntax of Basic macro URLs, refer to the chapter OpenOffice.org Basic.
  • STOPPRESENTATION - the presentation is stopped after the click
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
FADE_FROM_TOP
FADE_FROM_BOTTOM
FADE_FROM_UPPERLEFT
FADE_FROM_UPPERRIGHT
FADE_FROM_LOWERLEFT
FADE_FROM_LOWERRIGHT

MOVE_FROM_LEFT

MOVE_FROM_RIGHT
MOVE_FROM_TOP
MOVE_FROM_BOTTOM
MOVE_FROM_UPPERLEFT
MOVE_FROM_UPPERRIGHT
MOVE_FROM_LOWERRIGHT
MOVE_FROM_LOWERLEFT

ZOOM_IN_FROM_LEFT

ZOOM_IN_FROM_RIGHT
ZOOM_IN_FROM_TOP
ZOOM_IN_FROM_BOTTOM
ZOOM_IN_FROM_UPPERLEFT
ZOOM_IN_FROM_UPPERRIGHT
ZOOM_IN_FROM_LOWERRIGHT
ZOOM_IN_FROM_LOWERLEFT

CLOCKWISE

COUNTERCLOCKWISE

CLOSE_VERTICAL

CLOSE_HORIZONTAL

OPEN_VERTICAL

OPEN_HORIZONTAL

LASER_FROM_LEFT

LASER_FROM_RIGHT
LASER_FROM_TOP
LASER_FROM_BOTTOM
LASER_FROM_UPPERLEFT
LASER_FROM_UPPERRIGHT
LASER_FROM_LOWERLEFT
LASER_FROM_LOWERRIGHT

MOVE_TO_LEFT

MOVE_TO_RIGHT
MOVE_TO_TOP
MOVE_TO_BOTTOM
MOVE_TO_UPPERLEFT
MOVE_TO_UPPERRIGHT
MOVE_TO_LOWERRIGHT
MOVE_TO_LOWERLEFT

MOVE_SHORT_TO_LEFT

MOVE_SHORT_TO_RIGHT
MOVE_SHORT_TO_TOP
MOVE_SHORT_TO_BOTTOM
MOVE_SHORT_TO_UPPERLEFT
MOVE_SHORT_TO_UPPERRIGHT
MOVE_SHORT_TO_LOWERRIGHT
MOVE_SHORT_TO_LOWERLEFT

ZOOM_OUT_FROM_LEFT

ZOOM_OUT_FROM_RIGHT
ZOOM_OUT_FROM_TOP
ZOOM_OUT_FROM_BOTTOM
ZOOM_OUT_FROM_UPPERLEFT
ZOOM_OUT_FROM_UPPERRIGHT
ZOOM_OUT_FROM_LOWERRIGHT
ZOOM_OUT_FROM_LOWERLEFT

STRETCH_FROM_LEFT

STRETCH_FROM_RIGHT
STRETCH_FROM_TOP
STRETCH_FROM_BOTTOM
STRETCH_FROM_UPPERLEFT
STRETCH_FROM_UPPERRIGHT
STRETCH_FROM_LOWERRIGHT
STRETCH_FROM_LOWERLEFT

MOVE_SHORT_FROM_LEFT

MOVE_SHORT_FROM_RIGHT
MOVE_SHORT_FROM_TOP
MOVE_SHORT_FROM_BOTTOM
MOVE_SHORT_FROM_UPPERLEFT
MOVE_SHORT_FROM_UPPERRIGHT
MOVE_SHORT_FROM_LOWERRIGHT
MOVE_SHORT_FROM_LOWERLEFT

WAVYLINE_FROM_LEFT

WAVYLINE_FROM_RIGHT
WAVYLINE_FROM_TOP
WAVYLINE_FROM_BOTTOM

SPIRALIN_LEFT

SPIRALIN_RIGHT
SPIRALOUT_LEFT
SPIRALOUT_RIGHT

FADE_FROM_CENTER

FADE_TO_CENTER
VERTICAL_STRIPES
HORIZONTAL_STRIPES

ZOOM_IN

ZOOM_IN_SMALL
ZOOM_IN_SPIRAL

ZOOM_OUT

ZOOM_OUT_SMALL
ZOOM_OUT_SPIRAL

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).
Personal tools
In other languages