org.odftoolkit.odfdom.doc
Class OdfPresentationDocument

java.lang.Object
  extended by org.odftoolkit.odfdom.doc.OdfDocument
      extended by org.odftoolkit.odfdom.doc.OdfPresentationDocument

public class OdfPresentationDocument
extends OdfDocument

This class represents an empty ODF presentation.


Nested Class Summary
static class OdfPresentationDocument.OdfMediaType
          This enum contains all possible media types of OdfPresentationDocument documents.
 
Nested classes/interfaces inherited from class org.odftoolkit.odfdom.doc.OdfDocument
OdfDocument.OdfXMLFile, OdfDocument.Resource
 
Constructor Summary
protected OdfPresentationDocument()
           
 
Method Summary
 void appendPresentation(OdfPresentationDocument srcDoc)
          Append all the slides of the specified presentation document to the current document.
 void changeMode(OdfPresentationDocument.OdfMediaType type)
          Switches this instance to the given type.
 org.w3c.dom.Node cloneForeignElement(org.w3c.dom.Node element, OdfFileDom dom, boolean deep)
          Make a content copy of the specified element, and the returned element should have the specified ownerDocument.
 OdfDrawPage copyForeignSlide(int destIndex, OdfPresentationDocument srcDoc, int srcIndex)
          Make a copy of slide which locates at the specified position of the source presentation document and insert it to the current presentation document at the new position.
 OdfDrawPage copySlide(int source, int dest, java.lang.String newName)
          Make a copy of the slide at a specified position to another position in this presentation.
 void deleteSlideByIndex(int index)
          Delete the slide at a specified position in this presentation.
 void deleteSlideByName(java.lang.String name)
          Delete all the slides with a specified name in this presentation.
 OfficePresentationElement getContentRoot()
          Get the content root of a presentation document.
 OdfDrawPage getSlideByIndex(int index)
          Return the slide at a specified position in this presentation.
 OdfDrawPage getSlideByName(java.lang.String name)
          Return the slide which have a specified slide name in this presentation.
 int getSlideCount()
          Get the number of the slides in this presentation.
 java.util.Iterator<OdfDrawPage> getSlides()
          Return a list iterator containing all slides in this presentation.
 void moveSlide(int source, int dest)
          Move the slide at a specified position to the destination position.
static OdfPresentationDocument newPresentationDocument()
          Creates an empty presentation document.
static OdfPresentationDocument newPresentationTemplateDocument()
          Creates an empty presentation template.
 OdfDrawPage newSlide(int index, java.lang.String name, OdfDrawPage.SlideLayout slideLayout)
          New a slide at the specified position with the specified name, and use the specified slide template.
 
Methods inherited from class org.odftoolkit.odfdom.doc.OdfDocument
close, embedDocument, getBaseURI, getContentDom, getContentStream, getDocumentPackagePath, getDocumentStyles, getEmbeddedDocument, getEmbeddedDocuments, getEmbeddedDocuments, getMediaType, getMetaDom, getMetaStream, getOfficeBody, getOfficeMasterStyles, getOfficeMetadata, getOrCreateDocumentStyles, getPackage, getRootDocument, getSettingsStream, getStylesDom, getStylesStream, getTableByName, getTableList, getXMLFilePath, getXPath, loadDocument, loadDocument, loadDocument, loadDocument, loadTemplate, newImage, RemoveEmbedDocument, save, save, save, setMediaType, setPackage, setRootDocument, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OdfPresentationDocument

protected OdfPresentationDocument()
Method Detail

newPresentationDocument

public static OdfPresentationDocument newPresentationDocument()
                                                       throws java.lang.Exception
Creates an empty presentation document.

Returns:
ODF presentation document based on a default template
Throws:
java.lang.Exception - - if the document could not be created

newPresentationTemplateDocument

public static OdfPresentationDocument newPresentationTemplateDocument()
                                                               throws java.lang.Exception
Creates an empty presentation template.

Returns:
ODF presentation template based on a default
Throws:
java.lang.Exception - - if the template could not be created

getContentRoot

public OfficePresentationElement getContentRoot()
                                         throws java.lang.Exception
Get the content root of a presentation document.

Returns:
content root, representing the office:presentation tag
Throws:
java.lang.Exception - if the file DOM could not be created.

changeMode

public void changeMode(OdfPresentationDocument.OdfMediaType type)
Switches this instance to the given type. This method can be used to e.g. convert a document instance to a template and vice versa. If the type is not supported by the concrete document instance an IllegalArgumentException is raised.

Parameters:
type -

getSlideByIndex

public OdfDrawPage getSlideByIndex(int index)
Return the slide at a specified position in this presentation. Return null if the index is out of range.

Parameters:
index - the index of the slide to be returned
Returns:
a draw slide at the specified position

getSlideCount

public int getSlideCount()
Get the number of the slides in this presentation.

Returns:
the number of slides

getSlideByName

public OdfDrawPage getSlideByName(java.lang.String name)
Return the slide which have a specified slide name in this presentation.

According to the odf specification "The draw:name attribute specifies a name by which this element can be referenced. It is optional but if present, must be unique within the document instance. If not present, an application may generate a unique name."

If the name is null, then return null because all the slide must has its own unique name.

Parameters:
name - the specified slide name
Returns:
the slide whose name equals to the specified name

getSlides

public java.util.Iterator<OdfDrawPage> getSlides()
Return a list iterator containing all slides in this presentation.

Returns:
a list iterator containing all slides in this presentation

deleteSlideByIndex

public void deleteSlideByIndex(int index)
Delete the slide at a specified position in this presentation.

Parameters:
index - the index of the slide that need to be delete

Throw IndexOutOfBoundsException if the slide index is out of the presentation document slide count.


deleteSlideByName

public void deleteSlideByName(java.lang.String name)
Delete all the slides with a specified name in this presentation.

Parameters:
name - the name of the slide that need to be delete

copySlide

public OdfDrawPage copySlide(int source,
                             int dest,
                             java.lang.String newName)
Make a copy of the slide at a specified position to another position in this presentation. The original slide which at the dest index and after the dest index will move after.

Parameters:
source - the source position of the slide need to be copied
dest - the destination position of the slide need to be copied
newName - the new name of the copied slide
Returns:
the new slide at the destination position with the specified name, and it has the same content with the slide at the source position.

Throw IndexOutOfBoundsException if the slide index is out of the presentation document slide count. If copy the slide at the end of document, destIndex should set the same value with the slide count.


moveSlide

public void moveSlide(int source,
                      int dest)
Move the slide at a specified position to the destination position.

Parameters:
source - the current index of the slide that need to be moved
dest - The index of the destination position before the move action

Throw IndexOutOfBoundsException if the slide index is out of the presentation document slide count.


appendPresentation

public void appendPresentation(OdfPresentationDocument srcDoc)
Append all the slides of the specified presentation document to the current document.

Parameters:
srcDoc - the specified OdfPresentationDocument that need to be appended

copyForeignSlide

public OdfDrawPage copyForeignSlide(int destIndex,
                                    OdfPresentationDocument srcDoc,
                                    int srcIndex)
Make a copy of slide which locates at the specified position of the source presentation document and insert it to the current presentation document at the new position. The original slide which at the dest index and after the dest index will move after.

Parameters:
destIndex - the new position of the copied slide in the current document
srcDoc - the source document of the copied slide
srcIndex - the slide index of the source document that need to be copied
Returns:
the new slide which has the same content with the source slide

Throw IndexOutOfBoundsException if the slide index is out of the presentation document slide count If insert the foreign slide at the end of document, destIndex should set the same value with the slide count of the current presentation document.


cloneForeignElement

public org.w3c.dom.Node cloneForeignElement(org.w3c.dom.Node element,
                                            OdfFileDom dom,
                                            boolean deep)
Make a content copy of the specified element, and the returned element should have the specified ownerDocument.

Parameters:
element - The element that need to be copied
dom - The specified DOM tree that the returned element belong to
deep - If true, recursively clone the subtree under the element, false, only clone the element itself
Returns:
Returns a duplicated element which is not in the DOM tree with the specified element

newSlide

public OdfDrawPage newSlide(int index,
                            java.lang.String name,
                            OdfDrawPage.SlideLayout slideLayout)
New a slide at the specified position with the specified name, and use the specified slide template. See OdfDrawPage.SlideLayout.

If index is invalid, such as larger than the current document slide number or is negative, then append the new slide at the end of the document.

The slide name can be null.

Parameters:
index - the new slide position
name - the new slide name
slideLayout - the new slide template
Returns:
the new slide which locate at the specified position with the specified name and apply the specified slide template. If slideLayout is null, then use the default slide template which is a blank slide.

Throw IndexOutOfBoundsException if index is out of the presentation document slide count.



Copyright © 2008-2010 ODF Toolkit Project. All Rights Reserved.