org.odftoolkit.simple
Class ChartDocument

java.lang.Object
  extended by org.odftoolkit.odfdom.pkg.OdfPackageDocument
      extended by org.odftoolkit.odfdom.dom.OdfSchemaDocument
          extended by org.odftoolkit.simple.Document
              extended by org.odftoolkit.simple.ChartDocument
All Implemented Interfaces:
Closeable, TableContainer

public class ChartDocument
extends Document

This class represents an empty ODF document , which will be in general embedded in an existing ODF (Spreadsheet) document.


Nested Class Summary
static class ChartDocument.OdfMediaType
          This enum contains all possible media types of ChartDocument documents.
 
Nested classes/interfaces inherited from class org.odftoolkit.simple.Document
Document.ScriptType
 
Nested classes/interfaces inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument
OdfSchemaDocument.OdfXMLFile
 
Nested classes/interfaces inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument
OdfPackageDocument.Resource
 
Field Summary
 
Fields inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument
mContentDom, mDocumentStyles, mMetaDom, mSettingsDom, mStylesDom
 
Fields inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument
mDocumentMediaType, mDocumentPathInPackage, mPackage, ROOT_DOCUMENT_PATH
 
Constructor Summary
protected ChartDocument(OdfPackage pkg, String internalPath, ChartDocument.OdfMediaType odfMediaType)
          To avoid data duplication a new document is only created, if not already opened.
 
Method Summary
 void changeMode(ChartDocument.OdfMediaType mediaType)
          Changes the document to the given mediatype.
 OfficeChartElement getContentRoot()
          Get the content root of a chart document.
 OdfElement getTableContainerElement()
          Get the ODF element which can have as child element directly according to ODF specification.
static ChartDocument loadDocument(File file)
          Creates an ChartDocument from the OpenDocument provided by a File.
static ChartDocument loadDocument(InputStream inputStream)
          Creates an ChartDocument from the OpenDocument provided by a resource Stream.
static ChartDocument loadDocument(String documentPath)
          Loads an ChartDocument from the provided path.
static ChartDocument newChartDocument()
          Creates an empty charts document.
static ChartDocument newChartTemplateDocument()
          Creates an empty charts template.
 
Methods inherited from class org.odftoolkit.simple.Document
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
 
Methods inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument
getBaseURI, getBookmarkRDFMetadata, getContentDom, getContentStream, getDocumentStyles, getFileDom, getInContentMetadata, getInContentMetadataFromCache, getManifestRDFMetadata, getMasterPages, getMetaDom, getMetaStream, getOfficeMasterStyles, getOrCreateDocumentStyles, getRDFMetadata, getSettingsDom, getSettingsStream, getStylesDom, getStylesStream, getTables, getXMLFilePath
 
Methods inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument
flushDoms, getDocumentPath, getFileDom, getMediaTypeString, getPackage, getXMLFileMetadata, isExternalReference, isRootDocument, loadSubDocument, normalizeDocumentPath, removeDocument, save, setMediaTypeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChartDocument

protected ChartDocument(OdfPackage pkg,
                        String internalPath,
                        ChartDocument.OdfMediaType odfMediaType)
To avoid data duplication a new document is only created, if not already opened. A document is cached by this constructor using the internalpath as key.

Method Detail

newChartDocument

public static ChartDocument newChartDocument()
                                      throws Exception
Creates an empty charts document. *
Note: ODF Chart documents are (with OOo 3.0) only used as embedded document and not used stand-alone.

Returns:
ODF charts document based on a default template
Throws:
Exception - - if the document could not be created

newChartTemplateDocument

public static ChartDocument newChartTemplateDocument()
                                              throws Exception
Creates an empty charts template. *
Note: ODF Chart documents are (with OOo 3.0) only used as embedded document and not used stand-alone.

Returns:
ODF charts template based on a default template
Throws:
Exception - - if the template could not be created

loadDocument

public static ChartDocument loadDocument(InputStream inputStream)
                                  throws Exception
Creates an ChartDocument from the OpenDocument provided by a resource Stream.

Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by ChartDocument, 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 chart document, ClassCastException might be thrown.

Parameters:
inputStream - - the InputStream of the ODF chart document.
Returns:
the chart document created from the given InputStream
Throws:
Exception - - if the document could not be created.

loadDocument

public static ChartDocument loadDocument(String documentPath)
                                  throws Exception
Loads an ChartDocument from the provided path.

ChartDocument relies on the file being available for read access over the whole lifecycle of ChartDocument.

If the resource stream is not a ODF chart document, ClassCastException might be thrown.

Parameters:
documentPath - - the path from where the document can be loaded
Returns:
the chart document from the given path or NULL if the media type is not supported by SIMPLE.
Throws:
Exception - - if the document could not be created.

loadDocument

public static ChartDocument loadDocument(File file)
                                  throws Exception
Creates an ChartDocument from the OpenDocument provided by a File.

ChartDocument relies on the file being available for read access over the whole lifecycle of ChartDocument.

If the resource stream is not a ODF chart document, ClassCastException might be thrown.

Parameters:
file - - a file representing the ODF chart document.
Returns:
the chart document created from the given File
Throws:
Exception - - if the document could not be created.

getContentRoot

public OfficeChartElement getContentRoot()
                                  throws Exception
Get the content root of a chart document.

Overrides:
getContentRoot in class Document
Returns:
content root, representing the office:chart tag
Throws:
Exception - if the file DOM could not be created.

changeMode

public void changeMode(ChartDocument.OdfMediaType mediaType)
Changes the document to the given mediatype. This method can only be used to convert a document to a related mediatype, e.g. template.

Parameters:
mediaType - the related ODF mimetype

getTableContainerElement

public OdfElement getTableContainerElement()
Description copied from interface: TableContainer
Get the ODF element which can have as child element directly according to ODF specification. This Element will help to find the position to insert a new Table. For example, element is usable with element, so TextDocument will return OfficeTextElement. While Presentation Notes is an indirectly TableContainer, which holds Table with the help of its grand-child element , so for Notes, DrawTextBoxElement should be return.

Returns:
container element which can hold .


Copyright © 2010-2017 The Apache Software Foundation. All Rights Reserved.