Class OdfImageDocument
- java.lang.Object
-
- org.odftoolkit.odfdom.pkg.OdfPackageDocument
-
- org.odftoolkit.odfdom.dom.OdfSchemaDocument
-
- org.odftoolkit.odfdom.doc.OdfDocument
-
- org.odftoolkit.odfdom.doc.OdfImageDocument
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class OdfImageDocument extends OdfDocument
This class represents an ODF image document.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOdfImageDocument.OdfMediaTypeThis enum contains all possible media types of OdfImageDocument documents.-
Nested classes/interfaces inherited from class org.odftoolkit.odfdom.doc.OdfDocument
OdfDocument.UnicodeGroup
-
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.doc.OdfDocument
mHasCollaboration
-
Fields inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument
mContentDom, mJsonOperationQueue, mMetaDom, mSettingsDom, mStylesDom
-
Fields inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument
mDocumentMediaType, mDocumentPathInPackage, mPackage, ROOT_DOCUMENT_PATH
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedOdfImageDocument(OdfPackage pkg, String internalPath, OdfImageDocument.OdfMediaType odfMediaType)To avoid data duplication a new document is only created, if not already opened.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeMode(OdfImageDocument.OdfMediaType mediaType)Changes the document to the given mediatype.OfficeImageElementgetContentRoot()Get the content root of a image document.static OdfImageDocumentloadDocument(File file)Creates an OdfImageDocument from the OpenDocument provided by a File.static OdfImageDocumentloadDocument(InputStream inputStream)Creates an OdfImageDocument from the OpenDocument provided by a resource Stream.static OdfImageDocumentloadDocument(String documentPath)Loads an OdfImageDocument from the provided path.static OdfImageDocumentnewImageDocument()Creates an empty image document.static OdfImageDocumentnewImageTemplateDocument()Creates an empty image template.-
Methods inherited from class org.odftoolkit.odfdom.doc.OdfDocument
addAnnotation, close, getAnnotation, getFontNames, getLocale, getOdfMediaType, getOfficeMetadata, getTableByName, getTableList, getTableList, getUnicodeGroup, getUniqueAnnotationName, hasCollaboration, loadDocument, loadDocument, loadDocument, loadDocument, loadDocument, loadDocument, loadDocument, loadSubDocument, loadSubDocuments, loadSubDocuments, loadTemplate, loadTemplate, newImage, removeAnnotation, removeCachedView, save, save, setLocale, setOdfMediaType, toString, updateMetaData
-
Methods inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument
getBaseURI, getBookmarkRDFMetadata, getContentDom, getContentStream, getDocumentStyles, getFileDom, getInContentMetadata, getInContentMetadataFromCache, getJsonOperationQueue, getManifestRDFMetadata, getMasterPages, getMetaDom, getMetaStream, getOfficeMasterStyles, getOperations, getOrCreateDocumentStyles, getRDFMetadata, getRootComponent, getRootComponentElement, getSettingsDom, getSettingsStream, getStyleByDisplayName, getStyleByName, getStylesDom, getStylesStream, getTables, getTables, getXMLFilePath, setContentDom, setJsonOperationQueue, setMetaDom, setRootComponent, setSettingsDom, setStylesDom
-
Methods inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument
flushDoms, getAbsoluteFilePath, getCachedDom, getDocumentPath, getFileDom, getMediaTypeString, getPackage, getXMLFileMetadata, insertDocument, isExternalReference, isRootDocument, normalizeDocumentPath, removeDocument, save, setMediaTypeString
-
-
-
-
Constructor Detail
-
OdfImageDocument
protected OdfImageDocument(OdfPackage pkg, String internalPath, OdfImageDocument.OdfMediaType odfMediaType) throws SAXException
To avoid data duplication a new document is only created, if not already opened. A document is cached by this constructor using the internal path as key.- Throws:
SAXException
-
-
Method Detail
-
newImageDocument
public static OdfImageDocument newImageDocument() throws Exception
Creates an empty image document.- Returns:
- ODF image document based on a default template
- Throws:
Exception- - if the document could not be created
-
newImageTemplateDocument
public static OdfImageDocument newImageTemplateDocument() throws Exception
Creates an empty image template.- Returns:
- ODF image template based on a default
- Throws:
Exception- - if the template could not be created
-
loadDocument
public static OdfImageDocument loadDocument(InputStream inputStream) throws Exception
Creates an OdfImageDocument from the OpenDocument provided by a resource Stream.Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by OdfImageDocument, 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 image document, ClassCastException might be thrown.
- Parameters:
inputStream- - the InputStream of the ODF image document.- Returns:
- the image document created from the given InputStream
- Throws:
Exception- - if the document could not be created.
-
loadDocument
public static OdfImageDocument loadDocument(String documentPath) throws Exception
Loads an OdfImageDocument from the provided path.OdfImageDocument relies on the file being available for read access over the whole lifecycle of OdfImageDocument.
If the resource stream is not a ODF image document, ClassCastException might be thrown.
- Parameters:
documentPath- - the path from where the document can be loaded- Returns:
- the image document from the given path or NULL if the media type is not supported by ODFDOM.
- Throws:
Exception- - if the document could not be created.
-
loadDocument
public static OdfImageDocument loadDocument(File file) throws Exception
Creates an OdfImageDocument from the OpenDocument provided by a File.OdfImageDocument relies on the file being available for read access over the whole lifecycle of OdfImageDocument.
If the resource stream is not a ODF image document, ClassCastException might be thrown.
- Parameters:
file- - a file representing the ODF image document.- Returns:
- the image document created from the given File
- Throws:
Exception- - if the document could not be created.
-
getContentRoot
public OfficeImageElement getContentRoot() throws Exception
Get the content root of a image document.- Overrides:
getContentRootin classOdfDocument- Returns:
- content root, representing the office:drawing tag
- Throws:
Exception- if the file DOM could not be created.
-
changeMode
public void changeMode(OdfImageDocument.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
-
-