org.odftoolkit.simple
public class PresentationDocument extends Document implements ChartContainer
Modifier and Type | Class and Description |
---|---|
static class |
PresentationDocument.OdfMediaType
This enum contains all possible media types of PresentationDocument
documents.
|
static class |
PresentationDocument.PresentationClass
It represents the defined values of presentation:class.
|
Document.ScriptType
OdfSchemaDocument.OdfXMLFile
OdfPackageDocument.Resource
mContentDom, mDocumentStyles, mMetaDom, mSettingsDom, mStylesDom
mDocumentMediaType, mDocumentPathInPackage, mPackage, ROOT_DOCUMENT_PATH
Modifier | Constructor and Description |
---|---|
protected |
PresentationDocument(OdfPackage pkg,
String internalPath,
PresentationDocument.OdfMediaType odfMediaType)
To avoid data duplication a new document is only created, if not already
opened.
|
Modifier and Type | Method and Description |
---|---|
void |
appendPresentation(PresentationDocument srcDoc)
Append all the slides of the specified presentation document to the
current document.
|
void |
changeMode(PresentationDocument.OdfMediaType type)
Switches this instance to the given type.
|
Slide |
copyForeignSlide(int destIndex,
PresentationDocument 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.
|
Slide |
copySlide(int source,
int dest,
String newName)
Make a copy of the slide at a specified position to another position in
this presentation.
|
Chart |
createChart(String title,
DataSet dataset,
Rectangle rect)
Creates a new Chart for this container.
|
Chart |
createChart(String title,
SpreadsheetDocument document,
CellRangeAddressList cellRangeAddr,
boolean firstRowAsLabel,
boolean firstColumnAsLabel,
boolean rowAsDataSeries,
Rectangle rect)
Creates a new Chart for this container.
|
Chart |
createChart(String title,
String[] labels,
String[] legends,
double[][] data,
Rectangle rect)
Creates a new Chart for this container.
|
void |
deleteChartById(String chartId)
Deletes chart by chart id.
|
void |
deleteChartByTitle(String title)
Deletes chart(s) by chart title.
|
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.
|
Chart |
getChartById(String chartId)
Gets chart with specified id.
|
List<Chart> |
getChartByTitle(String title)
Gets chart list with specified title.
|
int |
getChartCount()
Returns the chart count of this container
|
OfficePresentationElement |
getContentRoot()
Get the content root of a presentation document.
|
Notes.NotesBuilder |
getNotesBuilder()
Return the notes builder of this document.
|
Slide.SlideBuilder |
getSlideBuilder()
Return the slide builder of this document.
|
Slide |
getSlideByIndex(int index)
Return the slide at a specified position in this presentation.
|
Slide |
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<Slide> |
getSlides()
Return a list iterator containing all slides in this presentation.
|
OdfElement |
getTableContainerElement()
Get the ODF element which can have
|
static PresentationDocument |
loadDocument(File file)
Creates an PresentationDocument from the OpenDocument provided by a File.
|
static PresentationDocument |
loadDocument(InputStream inputStream)
Creates an PresentationDocument from the OpenDocument provided by a
resource Stream.
|
static PresentationDocument |
loadDocument(String documentPath)
Loads an PresentationDocument from the provided path.
|
void |
moveSlide(int source,
int dest)
Move the slide at a specified position to the destination position.
|
static PresentationDocument |
newPresentationDocument()
Creates an empty presentation document.
|
static PresentationDocument |
newPresentationTemplateDocument()
Creates an empty presentation template.
|
Slide |
newSlide(int index,
String name,
Slide.SlideLayout slideLayout)
New a slide at the specified position with the specified name, and use
the specified slide template.
|
addTable, addTable, close, getComponentMap, getContentRoot, getEmbeddedDocument, getEmbeddedDocuments, getEmbeddedDocuments, getLocale, getOdfMediaType, getOfficeMetadata, getScriptType, getSectionByName, getSectionIterator, getTableBuilder, getTableByName, getTableContainerImpl, getTableList, insertDocument, loadDocument, loadDocument, loadDocument, loadDocument, LoadTableTemplateFromForeignTable, loadTemplate, newImage, removeElementLinkedResource, save, save, save, setLocale, setLocale, setOdfMediaType, setPassword, 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, isExternalReference, isRootDocument, loadSubDocument, normalizeDocumentPath, removeDocument, save, setMediaTypeString
protected PresentationDocument(OdfPackage pkg, String internalPath, PresentationDocument.OdfMediaType odfMediaType)
public static PresentationDocument newPresentationDocument() throws Exception
Exception
- - if the document could not be createdpublic static PresentationDocument newPresentationTemplateDocument() throws Exception
Exception
- - if the template could not be createdpublic static PresentationDocument loadDocument(InputStream inputStream) throws Exception
Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by PresentationDocument, 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 PresentationDocument loadDocument(String documentPath) throws Exception
PresentationDocument relies on the file being available for read access over the whole lifecycle of PresentationDocument.
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 PresentationDocument loadDocument(File file) throws Exception
PresentationDocument relies on the file being available for read access over the whole lifecycle of PresentationDocument.
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 Document
Exception
- if the file DOM could not be created.public void changeMode(PresentationDocument.OdfMediaType type)
type
- the compatible ODF mediatype.public Slide.SlideBuilder getSlideBuilder()
public Notes.NotesBuilder getNotesBuilder()
public Slide getSlideByIndex(int index)
index
- the index of the slide to be returnedpublic int getSlideCount()
public Slide 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<Slide> 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 Slide 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(PresentationDocument srcDoc)
srcDoc
- the specified PresentationDocument
that need to
be appendedpublic Slide copyForeignSlide(int destIndex, PresentationDocument 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 Slide newSlide(int index, String name, Slide.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.
public Chart createChart(String title, DataSet dataset, Rectangle rect)
ChartContainer
createChart
in interface ChartContainer
title
- chart title.dataset
- chart data set.rect
- chart rectangle.public Chart createChart(String title, SpreadsheetDocument document, CellRangeAddressList cellRangeAddr, boolean firstRowAsLabel, boolean firstColumnAsLabel, boolean rowAsDataSeries, Rectangle rect)
ChartContainer
createChart
in interface ChartContainer
title
- chart title.document
- the data source spreadsheet document.cellRangeAddr
- the cell range address list which is used as chart data set.firstRowAsLabel
- whether uses first row as label.firstColumnAsLabel
- whether uses first column as label.rowAsDataSeries
- whether uses data as series.rect
- chart rectangle.public Chart createChart(String title, String[] labels, String[] legends, double[][] data, Rectangle rect)
ChartContainer
createChart
in interface ChartContainer
title
- chart rectangle.labels
- label stringslegends
- legend stringsdata
- chart data set.rect
- chart rectangle.public void deleteChartById(String chartId)
ChartContainer
deleteChartById
in interface ChartContainer
chartId
- the id of specified chart.public void deleteChartByTitle(String title)
ChartContainer
deleteChartByTitle
in interface ChartContainer
title
- the title of specified chart(s).public Chart getChartById(String chartId)
ChartContainer
getChartById
in interface ChartContainer
chartId
- the id of this chart.public List<Chart> getChartByTitle(String title)
ChartContainer
getChartByTitle
in interface ChartContainer
title
- the title of specified chart(s).public int getChartCount()
ChartContainer
getChartCount
in interface ChartContainer
public OdfElement getTableContainerElement()
TableContainer
getTableContainerElement
in interface TableContainer
Copyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.