|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.odftoolkit.odfdom.pkg.OdfPackageDocument
org.odftoolkit.odfdom.dom.OdfSchemaDocument
org.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.UnicodeGroup
Unicode characters are in general divided by office applications into three different groups. |
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 |
OdfDocument(OdfPackage pkg,
String internalPath,
OdfDocument.OdfMediaType mediaType)
|
Method Summary | |
---|---|
void |
close()
Close the OdfPackage and release all temporary created data. |
OdfElement |
getContentRoot()
Get the content root of a document. |
Locale |
getLocale(OdfDocument.UnicodeGroup unicodeGroup)
This method will return Locale, which presents the default language and country information settings in this document |
protected OdfDocument.OdfMediaType |
getOdfMediaType()
Gets the media type of the OdfDocument |
OdfOfficeMeta |
getOfficeMetadata()
Get the meta data feature instance of the current document |
OdfTable |
getTableByName(String name)
Return an instance of table feature with the specific table name. |
List<OdfTable> |
getTableList()
Return a list of table features in this document. |
static OdfDocument.UnicodeGroup |
getUnicodeGroup(Locale locale)
Similar to OpenOffice.org, ODFDOM assumes that every Locale is related to one of the three Unicodes Groups, either CJK, CTL or Western. |
static OdfDocument |
loadDocument(File file)
Loads the ODF root document from the ODF package provided as a File. |
static OdfDocument |
loadDocument(InputStream inStream)
Loads the ODF root document from the ODF package provided by a Stream. |
static OdfDocument |
loadDocument(OdfPackage odfPackage)
Loads the ODF root document from the ODF package. |
static OdfDocument |
loadDocument(OdfPackage odfPackage,
String internalPath)
Creates an OdfDocument from the OpenDocument provided by an ODF package. |
static OdfDocument |
loadDocument(String documentPath)
Loads the ODF root document from the ODF package provided by its path. |
OdfDocument |
loadSubDocument(String documentPath)
Returns an embedded OdfPackageDocument from the given package path. |
Map<String,OdfDocument> |
loadSubDocuments()
Method returns all embedded OdfPackageDocuments, which match a valid OdfMediaType, of the current OdfPackageDocument. |
Map<String,OdfDocument> |
loadSubDocuments(OdfDocument.OdfMediaType desiredMediaType)
Method returns all embedded OdfPackageDocuments of sthe current OdfPackageDocument matching the according MediaType. |
protected static OdfDocument |
loadTemplate(OdfPackageDocument.Resource res,
OdfDocument.OdfMediaType odfMediaType)
Loads the ODF root document from the given Resource. |
String |
newImage(URI imageUri)
Insert an Image from the specified uri to the end of the OdfDocument. |
void |
save(File file)
Save the document to a given file. |
void |
save(OutputStream out)
Save the document to an OutputStream. |
void |
setLocale(Locale locale)
Set a locale information. |
protected void |
setOdfMediaType(OdfDocument.OdfMediaType odfMediaType)
Sets the media type of the OdfDocument |
String |
toString()
|
Methods inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument |
---|
getBaseURI, getContentDom, getContentStream, getDocumentStyles, getFileDom, getMasterPages, getMetaDom, getMetaStream, getOfficeMasterStyles, getOrCreateDocumentStyles, getSettingsDom, getSettingsStream, getStylesDom, getStylesStream, getTables, getXMLFilePath |
Methods inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument |
---|
flushDoms, getDocumentPath, getFileDom, getMediaTypeString, getPackage, insertDocument, isExternalReference, isRootDocument, normalizeDocumentPath, removeDocument, save, setMediaTypeString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected OdfDocument(OdfPackage pkg, String internalPath, OdfDocument.OdfMediaType mediaType) throws SAXException
SAXException
Method Detail |
---|
protected static OdfDocument loadTemplate(OdfPackageDocument.Resource res, OdfDocument.OdfMediaType odfMediaType) throws Exception
res
- a resource containing a package with a root documentodfMediaType
- the media type of the root document
Exception
- - if the document could not be created.public static OdfDocument loadDocument(String documentPath) throws Exception
OdfDocument relies on the file being available for read access over the whole lifecycle of OdfDocument.
documentPath
- - the path from where the document can be loaded
Exception
- - if the document could not be created.public static OdfDocument loadDocument(InputStream inStream) throws 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 createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.
inStream
- - the InputStream of the ODF document.
Exception
- - if the document could not be created.public static OdfDocument loadDocument(File file) throws Exception
file
- - a file representing the ODF document.
Exception
- - if the document could not be created.public static OdfDocument loadDocument(OdfPackage odfPackage) throws Exception
odfPackage
- - the ODF package containing the ODF document.
Exception
- - if the ODF document could not be created.public static OdfDocument loadDocument(OdfPackage odfPackage, String internalPath) throws Exception
odfPackage
- - the ODF package containing the ODF document.internalPath
- - the path to the ODF document relative to the package root, or an empty String for the root document.
Exception
- - if the ODF document could not be created.public OdfDocument loadSubDocument(String documentPath)
loadSubDocument
in class OdfPackageDocument
documentPath
- to the ODF document within the package. The path is relative the current ODF document path.
public Map<String,OdfDocument> loadSubDocuments()
public Map<String,OdfDocument> loadSubDocuments(OdfDocument.OdfMediaType desiredMediaType)
desiredMediaType
- media type of the documents to be returned (used as a filter).
protected void setOdfMediaType(OdfDocument.OdfMediaType odfMediaType)
odfMediaType
- media type to be setprotected OdfDocument.OdfMediaType getOdfMediaType()
public OdfOfficeMeta getOfficeMetadata()
office:meta
in the meta.xmlpublic void save(OutputStream out) throws 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.
When save the embedded document to a stand alone document, all the file entries of the embedded document will be copied to a new document package. If the embedded document is outside of the current document directory, you have to embed it to the sub directory and refresh the link of the embedded document. you should reload it from the stream to get the saved embedded document.
out
- - the OutputStream to write the file to
Exception
- if the document could not be savedpublic void save(File file) throws 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).
When saving the embedded document to a stand alone document, all files of the embedded document will be copied to a new document package. If the embedded document is outside of the current document directory, you have to embed it to the sub directory and refresh the link of the embedded document. You should reload it from the given file to get the saved embedded document.
save
in class OdfPackageDocument
file
- - the file to save the document
Exception
- if the document could not be savedpublic void close()
close
in interface Closeable
close
in class OdfSchemaDocument
public OdfElement getContentRoot() throws Exception
Exception
- if the file DOM could not be created.public String toString()
toString
in class Object
public String newImage(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 OdfTable getTableByName(String name)
name
- of the table beeing searched for.
public List<OdfTable> getTableList()
public void setLocale(Locale locale)
Set a locale information.
The locale information will affect the language and country setting of the document. Thus the font settings, the spell checkings and etc will be affected.
locale
- - an instance of Localepublic static OdfDocument.UnicodeGroup getUnicodeGroup(Locale locale)
locale
- the UnicodeGroup is requested for
public Locale getLocale(OdfDocument.UnicodeGroup unicodeGroup)
ODF allows to set a Locale for each of the three UnicodeGroups. Therefore there might be three different Locale for the document.
unicodeGroup
- - One of the three (CJK, CTL or Western).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |