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:

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 pageswhile(xDrawPages.getCount()<10)
xDrawPages.insertNewByIndex(0);// assign a name to each pageString 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");