Custom Slide Show

From Apache OpenOffice Wiki
Jump to: navigation, search



Custom presentations are available at the com.sun.star.presentation.XCustomPresentationSupplier interface of the presentation document. It contains the method:

 com::sun::star::container::XNameContainer getCustomPresentations()

The method getCustomPresentations() returns a com.sun.star.presentation.CustomPresentationAccess service that consists of the interfaces com.sun.star.container.XNameContainer and com.sun.star.lang.XSingleServiceFactory. The standard API interface [IDL:com.sun.star.container.XNameContainer] derived from XNameContainer obtains existing Custom Presentations and to add new custom presentations by name. It introduces the methods:

 void replaceByName( [in] string aName, [in] any aElement)
 
 void insertByName( [in] string aName, [in] any aElement)
 void removeByName( [in] string Name)

To add a new CustomPresentation, create it using createInstance() at the XSingleServiceFactory interface of the CustomPresentationAccess.

Methods of com.sun.star.lang.XSingleServiceFactory:

 com::sun::star::uno::XInterface createInstance()
 com::sun::star::uno::XInterface createInstanceWithArguments( [in] sequence< any aArguments >)

The CustomPresentation is now created. Its content consists of a com.sun.star.presentation.CustomPresentation. From the API, it is a named container of selected presentation draw pages. Draw pages can be added to a custom presentation or removed using its interface com.sun.star.container.XIndexContainer. In addition to the methods of an XIndexAccess, this standard API interface supports the following operations:

Methods introduced by com.sun.star.container.XIndexContainer:

 void replaceByIndex( [in] long Index, [in] any Element)
 void insertByIndex( [in] long Index, [in] any Element)
 void removeByIndex( [in] long Index)

The name of a CustomPresentation is read and written using the interface com.sun.star.container.XNamed:

Methods of XNamed:

 string getName()
 void setName( [in] string aName)

A custom show is a collection of slides in a user-defined order that can be executed as a presentation. It is also possible to use a slide twice or skip slides. For instance, it is possible to create a short version of a presentation and a long version within the same document. The number of custom shows is unlimited.

The next example demonstrates how to create two custom shows and set one of them as an active presentation.

  XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier)UnoRuntime.queryInterface(
      XDrawPagesSupplier.class, xComponent);
  XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
  // take care that this document has ten pages
  while (xDrawPages.getCount() < 10)
      xDrawPages.insertNewByIndex(0);
  // assign a name to each page
  String aNameArray[] = {"Introduction", "page one", "page two", "page three", "page four",
                         "page five", "page six", "page seven", "page eight", "page nine"};
  int i;
  for (i = 0; i < 10; i++) {
      XNamed xPageName = (XNamed)UnoRuntime.queryInterface(XNamed.class, xDrawPages.getByIndex(i));
      xPageName.setName(aNameArray[i]);
  }
  /* create two custom shows, one will play slide 6 to 10 and is named "ShortVersion"
     the other one will play slide 2 til 10 and is named "LongVersion"
   */
  XCustomPresentationSupplier xCustPresSupplier = (XCustomPresentationSupplier)
      UnoRuntime.queryInterface(XCustomPresentationSupplier.class, xComponent);
  /* the following container is a container for further container
     which concludes the list of pages that are to play within a custom show
   */
  XNameContainer xNameContainer = xCustPresSupplier.getCustomPresentations();
  XSingleServiceFactory xFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
      XSingleServiceFactory.class, xNameContainer);
  Object xObj;
  XIndexContainer xContainer;
  /* instanciate an IndexContainer that will take
     a list of draw pages for the first custom show
   */
  xObj = xFactory.createInstance();
  xContainer = (XIndexContainer)
      UnoRuntime.queryInterface(XIndexContainer.class, xObj);
  for (i = 5; i < 10; i++)
      xContainer.insertByIndex(xContainer.getCount(), xDrawPages.getByIndex(i));
  xNameContainer.insertByName("ShortVersion", xContainer);
  /* instanciate an IndexContainer that will take
     a list of draw page for a second custom show
   */
  xObj = xFactory.createInstance();
  xContainer = (XindexContainer)UnoRuntime.queryInterface(XIndexContainer.class, xObj);
  for (i = 1; i < 10; i++)
      xContainer.insertByIndex(xContainer.getCount(), xDrawPages.getByIndex(i));
  xNameContainer.insertByName("LongVersion", xContainer);
  /* which custom show is to use
     can been set in the presentation settings
   */
  XPresentationSupplier xPresSupplier = (XPresentationSupplier)UnoRuntime.queryInterface(
      XPresentationSupplier.class, xComponent);
  XPresentation xPresentation = xPresSupplier.getPresentation();
  XPropertySet xPresPropSet = (XPropertySet)UnoRuntime.queryInterface(
      XPropertySet.class, xPresentation);
  xPresPropSet.setPropertyValue("CustomShow", "ShortVersion");
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages