|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.odftoolkit.odfdom.doc.OdfDocument
public abstract class OdfDocument
This abstract class is representing one of the possible ODF documents
| Nested Class Summary | |
|---|---|
static class |
OdfDocument.OdfMediaType
This enum contains all possible media types of OpenDocument documents. |
static class |
OdfDocument.OdfXMLFile
This enum contains all possible standardized XML ODF files of the OpenDocument document. |
protected static class |
OdfDocument.Resource
|
| Constructor Summary | |
|---|---|
OdfDocument()
|
|
| Method Summary | |
|---|---|
void |
close()
Close the OdfPackage and release all temporary created data. |
void |
embedDocument(java.lang.String pkgPathToChildDocument,
OdfDocument newOdfDocument)
Add an OdfDocument as an embedded OdfDocument to the current OdfDocument |
java.lang.String |
getBaseURI()
Get the URI, where this ODF document is stored. |
OdfFileDom |
getContentDom()
Return the ODF type-based content DOM of the current OdfDocument |
java.io.InputStream |
getContentStream()
Gets the ODF content.xml file as stream. |
java.lang.String |
getDocumentPackagePath()
Get the relative path for an embedded ODF document. |
OdfOfficeStyles |
getDocumentStyles()
|
OdfDocument |
getEmbeddedDocument(java.lang.String pathToObject)
Returns an embedded OdfDocument of the current OdfDocument matching to the internal package path given as an parameter. |
java.util.List<OdfDocument> |
getEmbeddedDocuments()
Method returns all embedded OdfDocuments, which match a valid OdfMediaType, of the current OdfDocument. |
java.util.List<OdfDocument> |
getEmbeddedDocuments(OdfDocument.OdfMediaType mediaType)
Method returns all embedded OdfDocuments of the current OdfDocument matching the according MediaType. |
java.lang.String |
getMediaType()
Get the media type from document |
OdfFileDom |
getMetaDom()
Return the ODF type-based content DOM of the meta.xml |
java.io.InputStream |
getMetaStream()
Gets the ODF metadata.xml file as stream. |
OdfOfficeBody |
getOfficeBody()
|
OdfOfficeMasterStyles |
getOfficeMasterStyles()
return the office:master-styles element of this document. |
OdfOfficeMeta |
getOfficeMetadata()
Get the meta data feature instance of the current document |
OdfOfficeStyles |
getOrCreateDocumentStyles()
|
OdfPackage |
getPackage()
Retreives the OdfPackage for this OdfDocument. |
protected OdfDocument |
getRootDocument()
Retreives the root OdfDocument that determines the mediatype of the package. |
java.io.InputStream |
getSettingsStream()
Gets the ODF settings.xml file as stream. |
OdfFileDom |
getStylesDom()
Return the ODF type-based content DOM of the current OdfDocument |
java.io.InputStream |
getStylesStream()
Gets the ODF style.xml file as stream. |
OdfTable |
getTableByName(java.lang.String name)
Return an instance of table feature with the specific table name. |
java.util.List<OdfTable> |
getTableList()
Return a list of table features in this document. |
protected java.lang.String |
getXMLFilePath(OdfDocument.OdfXMLFile file)
Get the relative path for an embedded ODF document including its file name. |
javax.xml.xpath.XPath |
getXPath()
Create an XPath instance to select one or more nodes from an ODF document. |
static OdfDocument |
loadDocument(java.io.File file)
Creates an OdfDocument from the OpenDocument provided by a File. |
static OdfDocument |
loadDocument(java.io.InputStream inStream)
Creates an OdfDocument from the OpenDocument provided by a resource Stream. |
static OdfDocument |
loadDocument(OdfPackage odfPackage)
Creates an OdfDocument from the OpenDocument provided by an ODF package. |
static OdfDocument |
loadDocument(java.lang.String path)
Loads an OdfDocument from the provided path. |
protected static OdfDocument |
loadTemplate(OdfDocument.Resource res)
Loads an OpenDocument from the given resource |
java.lang.String |
newImage(java.net.URI imageUri)
Insert an Image from the specified uri to the end of the OdfDocument. |
void |
RemoveEmbedDocument(java.lang.String pathToObject)
remove an embedded Document from the current OdfDocument |
void |
save(java.io.File file)
Save the document to given file. |
void |
save(java.io.OutputStream out)
Save the document to an OutputStream. |
void |
save(java.lang.String path)
Save the document to given path.Delegate to the root document and save possible embedded OdfDocuments. |
protected void |
setMediaType(OdfDocument.OdfMediaType odfMediaType)
Sets the media type of the OdfDocument |
protected void |
setPackage(OdfPackage pkg)
Sets the OdfPackage that contains this OdfDocument. |
protected void |
setRootDocument(OdfDocument root)
Sets the root OdfDocument that determines the mediatype of the package. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public OdfDocument()
| Method Detail |
|---|
protected static OdfDocument loadTemplate(OdfDocument.Resource res)
throws java.lang.Exception
res - a resource containing the document
java.lang.Exception - - if the document could not be created.
public static OdfDocument loadDocument(java.lang.String path)
throws java.lang.Exception
OdfDocument relies on the file being available for read access over the whole lifecycle of OdfDocument.
path - - the path from where the document can be loaded
java.lang.Exception - - if the document could not be created.
public static OdfDocument loadDocument(java.io.InputStream inStream)
throws java.lang.Exception
Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by OdfDocument, the InputStream is cached. This usually takes more time compared to the other loadDocument methods. An advantage of caching is that there are no problems overwriting an input file.
inStream - - the InputStream of the ODF document.
java.lang.Exception - - if the document could not be created.
public static OdfDocument loadDocument(java.io.File file)
throws java.lang.Exception
OdfDocument relies on the file being available for read access over the whole lifecycle of OdfDocument.
file - - a file representing the ODF document.
java.lang.Exception - - if the document could not be created.
public static OdfDocument loadDocument(OdfPackage odfPackage)
throws java.lang.Exception
odfPackage - - the ODF package containing the ODF document.
java.lang.Exception - - if the ODF document could not be created.protected void setRootDocument(OdfDocument root)
root - the OdfDocument that has its file on the root level of the packageprotected OdfDocument getRootDocument()
protected void setPackage(OdfPackage pkg)
pkg - the OdfPackage that contains this OdfDocumentpublic OdfPackage getPackage()
protected void setMediaType(OdfDocument.OdfMediaType odfMediaType)
odfMediaType - media type to be setpublic java.lang.String getDocumentPackagePath()
protected java.lang.String getXMLFilePath(OdfDocument.OdfXMLFile file)
file - represents one of the standardized XML ODF files.
public void embedDocument(java.lang.String pkgPathToChildDocument,
OdfDocument newOdfDocument)
pkgPathToChildDocument - path to the directory of the embedded ODF document (always relative to ODF package root).newOdfDocument - the OdfDocument to be embedded
public java.io.InputStream getContentStream()
throws java.lang.Exception
java.lang.Exception - - if the stream can not be extracted
public java.io.InputStream getStylesStream()
throws java.lang.Exception
java.lang.Exception - - if the stream can not be extracted
public java.io.InputStream getSettingsStream()
throws java.lang.Exception
java.lang.Exception - - if the stream can not be extracted
public java.io.InputStream getMetaStream()
throws java.lang.Exception
java.lang.Exception - - if the stream can not be extractedpublic java.lang.String getBaseURI()
public OdfDocument getEmbeddedDocument(java.lang.String pathToObject)
pathToObject - path to the directory of the embedded ODF document (relative to ODF package root).
public java.util.List<OdfDocument> getEmbeddedDocuments(OdfDocument.OdfMediaType mediaType)
mediaType - media type which is used as a filter
public java.util.List<OdfDocument> getEmbeddedDocuments()
public OdfOfficeStyles getDocumentStyles()
public OdfOfficeStyles getOrCreateDocumentStyles()
public javax.xml.xpath.XPath getXPath()
public OdfFileDom getContentDom()
throws java.lang.Exception
java.lang.Exception - if content DOM could not be initialized
public OdfFileDom getStylesDom()
throws java.lang.Exception
java.lang.Exception - if styles DOM could not be initialized
public OdfFileDom getMetaDom()
throws java.lang.Exception
java.lang.Exception - if meta DOM could not be initialized
public OdfOfficeMeta getOfficeMetadata()
throws java.lang.Exception
office:meta in the meta.xml
java.lang.Exception - if the file meta DOM could not be created.public java.lang.String getMediaType()
public void save(java.lang.String path)
throws java.lang.Exception
path - - the path to the file
java.lang.Exception - if the document could not be saved
public void save(java.io.File file)
throws java.lang.Exception
If the input file has been cached (this is the case when loading from an InputStream), the input file can be overwritten.
Otherwise it's allowed to overwrite the input file as long as the same path name is used that was used for loading (no symbolic link foo2.odt pointing to the loaded file foo1.odt, no network path X:\foo.odt pointing to the loaded file D:\foo.odt).
file - - the file to save the document
java.lang.Exception - if the document could not be saved
public void save(java.io.OutputStream out)
throws java.lang.Exception
If the input file has been cached (this is the case when loading from an InputStream), the input file can be overwritten.
If not, the OutputStream may not point to the input file! Otherwise this will result in unwanted behaviour and broken files.
out - - the OutputStream to write the file to
java.lang.Exception - if the document could not be savedpublic void close()
public OdfOfficeBody getOfficeBody()
public OdfOfficeMasterStyles getOfficeMasterStyles()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String newImage(java.net.URI imageUri)
imageUri - The URI of the image that will be added to the document,
add image stream to the package,
in the 'Pictures/' graphic directory with the same image file name as in the URI.
If the imageURI is relative first the user.dir is taken to make it absolute.
public void RemoveEmbedDocument(java.lang.String pathToObject)
pathToObject - path to the directory of the embedded ODF document (always relative to ODF package root).public OdfTable getTableByName(java.lang.String name)
name - of the table beeing searched for.
public java.util.List<OdfTable> getTableList()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||