public class OdfPresentationDocument extends OdfDocument
Modifier and Type | Class and Description |
---|---|
static class |
OdfPresentationDocument.OdfMediaType
This enum contains all possible media types of OdfPresentationDocument documents.
|
OdfDocument.UnicodeGroup
OdfSchemaDocument.OdfXMLFile
OdfPackageDocument.Resource
mContentDom, mDocumentStyles, mMetaDom, mSettingsDom, mStylesDom
mDocumentMediaType, mDocumentPathInPackage, mPackage, ROOT_DOCUMENT_PATH
Modifier | Constructor and Description |
---|---|
protected |
OdfPresentationDocument(OdfPackage pkg,
String internalPath,
OdfPresentationDocument.OdfMediaType odfMediaType)
To avoid data duplication a new document is only created, if not already opened.
|
Modifier and Type | Method and Description |
---|---|
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.
|
Node |
cloneForeignElement(Node element,
OdfFileDom dom,
boolean deep)
Make a content copy of the specified element, and the returned element should have the
specified ownerDocument.
|
OdfSlide |
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.
|
OdfSlide |
copySlide(int source,
int dest,
String newName)
Make a copy of the slide at a specified position to another position in this presentation.
|
boolean |
deleteSlideByIndex(int index)
Delete the slide at a specified position in this presentation.
|
boolean |
deleteSlideByName(String name)
Delete all the slides with a specified name in this presentation.
|
OfficePresentationElement |
getContentRoot()
Get the content root of a presentation document.
|
OdfSlide |
getSlideByIndex(int index)
Return the slide at a specified position in this presentation.
|
OdfSlide |
getSlideByName(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.
|
Iterator<OdfSlide> |
getSlides()
Return a list iterator containing all slides in this presentation.
|
static OdfPresentationDocument |
loadDocument(File file)
Creates an OdfPresentationDocument from the OpenDocument provided by a File.
|
static OdfPresentationDocument |
loadDocument(InputStream inputStream)
Creates an OdfPresentationDocument from the OpenDocument provided by a resource Stream.
|
static OdfPresentationDocument |
loadDocument(String documentPath)
Loads an OdfPresentationDocument from the provided path.
|
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.
|
OdfSlide |
newSlide(int index,
String name,
OdfSlide.SlideLayout slideLayout)
New a slide at the specified position with the specified name, and use the specified slide
template.
|
close, getLocale, getOdfMediaType, getOfficeMetadata, getTableByName, getTableList, getUnicodeGroup, loadDocument, loadDocument, loadSubDocument, loadSubDocuments, loadSubDocuments, loadTemplate, newImage, save, save, setLocale, setOdfMediaType, toString
getBaseURI, getBookmarkRDFMetadata, getContentDom, getContentStream, getDocumentStyles, getFileDom, getInContentMetadata, getInContentMetadataFromCache, getManifestRDFMetadata, getMasterPages, getMetaDom, getMetaStream, getOfficeMasterStyles, getOrCreateDocumentStyles, getRDFMetadata, getSettingsDom, getSettingsStream, getStylesDom, getStylesStream, getTables, getXMLFilePath
flushDoms, getDocumentPath, getFileDom, getMediaTypeString, getPackage, getXMLFileMetadata, insertDocument, isExternalReference, isRootDocument, normalizeDocumentPath, removeDocument, save, setMediaTypeString
protected OdfPresentationDocument(OdfPackage pkg, String internalPath, OdfPresentationDocument.OdfMediaType odfMediaType) throws SAXException
SAXException
public static OdfPresentationDocument newPresentationDocument() throws Exception
Exception
- - if the document could not be createdpublic static OdfPresentationDocument newPresentationTemplateDocument() throws Exception
Exception
- - if the template could not be createdpublic static OdfPresentationDocument loadDocument(InputStream inputStream) throws Exception
Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by OdfPresentationDocument, the InputStream is cached. This usually takes more time compared to the other createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.
If the resource stream is not a ODF presentation document, ClassCastException might be thrown.
inputStream
- - the InputStream of the ODF presentation document.Exception
- - if the document could not be created.public static OdfPresentationDocument loadDocument(String documentPath) throws Exception
OdfPresentationDocument relies on the file being available for read access over the whole lifecycle of OdfPresentationDocument.
If the resource stream is not a ODF presentation document, ClassCastException might be thrown.
documentPath
- - the path from where the document can be loadedException
- - if the document could not be created.public static OdfPresentationDocument loadDocument(File file) throws Exception
OdfPresentationDocument relies on the file being available for read access over the whole lifecycle of OdfPresentationDocument.
If the resource stream is not a ODF presentation document, ClassCastException might be thrown.
file
- - a file representing the ODF presentation document.Exception
- - if the document could not be created.public OfficePresentationElement getContentRoot() throws Exception
getContentRoot
in class OdfDocument
Exception
- if the file DOM could not be created.public void changeMode(OdfPresentationDocument.OdfMediaType type)
type
- the compatible ODF mediatype.public OdfSlide getSlideByIndex(int index)
index
- the index of the slide to be returnedpublic int getSlideCount()
public OdfSlide getSlideByName(String name)
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.
name
- the specified slide namepublic Iterator<OdfSlide> getSlides()
public boolean deleteSlideByIndex(int index)
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.
public boolean deleteSlideByName(String name)
name
- the name of the slide that need to be deletepublic OdfSlide copySlide(int source, int dest, String newName)
source
- the source position of the slide need to be copieddest
- the destination position of the slide need to be copiednewName
- the new name of the copied slideThrow 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.
public void moveSlide(int source, int dest)
source
- the current index of the slide that need to be moveddest
- The index of the destination position before the move action
Throw IndexOutOfBoundsException if the slide index is out of the presentation document slide count.
public void appendPresentation(OdfPresentationDocument srcDoc)
srcDoc
- the specified OdfPresentationDocument
that need to be appendedpublic OdfSlide copyForeignSlide(int destIndex, OdfPresentationDocument srcDoc, int srcIndex)
destIndex
- the new position of the copied slide in the current documentsrcDoc
- the source document of the copied slidesrcIndex
- the slide index of the source document that need to be copiedThrow 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.
public Node cloneForeignElement(Node element, OdfFileDom dom, boolean deep)
element
- The element that need to be copieddom
- The specified DOM tree that the returned element belong todeep
- If true, recursively clone the subtree under the element, false, only clone the
element itselfpublic OdfSlide newSlide(int index, String name, OdfSlide.SlideLayout slideLayout)
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.
index
- the new slide positionname
- the new slide nameslideLayout
- the new slide templateThrow IndexOutOfBoundsException if index is out of the presentation document slide count.
Copyright © 2008–2018 Apache Software Foundation; Copyright © 2018–2020 The Document Foundation. All rights reserved.