Package org.odftoolkit.odfdom.dom
Class OdfSchemaDocument
- java.lang.Object
-
- org.odftoolkit.odfdom.pkg.OdfPackageDocument
-
- org.odftoolkit.odfdom.dom.OdfSchemaDocument
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
OdfDocument
public abstract class OdfSchemaDocument extends OdfPackageDocument
A document in ODF is from the package view a directory with a media type. If the media type represents a document described by the ODF 1.2 Schema, certain files are assumed within: content.xml, styles.xml, metadata.xml and settings.xml.The class represents such a document, providing easier access to its XML files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OdfSchemaDocument.OdfXMLFile
This enum contains all possible standardized XML ODF files of the OpenDocument document.-
Nested classes/interfaces inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument
OdfPackageDocument.Resource
-
-
Field Summary
Fields Modifier and Type Field Description protected OdfContentDom
mContentDom
protected JsonOperationProducer
mJsonOperationQueue
protected OdfMetaDom
mMetaDom
protected OdfSettingsDom
mSettingsDom
protected OdfStylesDom
mStylesDom
-
Fields inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument
mDocumentMediaType, mDocumentPathInPackage, mPackage, ROOT_DOCUMENT_PATH, SLASH
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OdfSchemaDocument(OdfPackage pkg, String internalPath, String mediaTypeString)
Creates a new OdfSchemaDocument.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Close the OdfPackage and release all temporary created data.String
getBaseURI()
Get the URI, where this ODF document is stored.org.apache.jena.rdf.model.Model
getBookmarkRDFMetadata()
Get in-content metadata model of bookmarksOdfContentDom
getContentDom()
Return the ODF type-based content DOM of the content.xmlInputStream
getContentStream()
Gets the ODF content.xml file as stream.OdfOfficeStyles
getDocumentStyles()
OdfFileDom
getFileDom(OdfSchemaDocument.OdfXMLFile file)
org.apache.jena.rdf.model.Model
getInContentMetadata()
Get In Content RDF Metadata through GRDDL XSLT http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415070_253892949org.apache.jena.rdf.model.Model
getInContentMetadataFromCache()
Get in-content metadata cache modelJsonOperationProducer
getJsonOperationQueue()
org.apache.jena.rdf.model.Model
getManifestRDFMetadata()
Get RDF metadata from manifest.rdf and those rdf files registered in the manifest.xml as "application/rdf+xml" through GRDDL XSLT http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415072_253892949Map<String,StyleMasterPageElement>
getMasterPages()
Deprecated.This method will be moved to the generated sources as soon code generation was improved!OdfMetaDom
getMetaDom()
Return the ODF type-based metadata DOM of the meta.xmlInputStream
getMetaStream()
Gets the ODF metadata.xml file as stream.OdfOfficeMasterStyles
getOfficeMasterStyles()
return the office:master-styles element of this document.org.json.JSONObject
getOperations(CollabTextDocument operationDoc)
OdfOfficeStyles
getOrCreateDocumentStyles()
org.apache.jena.rdf.model.Model
getRDFMetadata()
Get all two types of RDF Metadata through GRDDL XSLT: http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415068_253892949Component
getRootComponent()
Returns the component tree of the document.OdfElement
getRootComponentElement(String masterStyleName, PageArea pageArea, boolean createIfNotExisting)
Returns the component tree of the document.OdfSettingsDom
getSettingsDom()
Return the ODF type-based settings DOM of the settings.xmlInputStream
getSettingsStream()
Gets the ODF settings.xml file as stream.OdfStyle
getStyleByDisplayName(OdfStyleFamily styleFamily, String styleDisplayName)
OdfStyle
getStyleByName(OdfStyleFamily styleFamily, String styleName)
OdfStylesDom
getStylesDom()
Return the ODF type-based styles DOM of the styles.xmlInputStream
getStylesStream()
Gets the ODF style.xml file as stream.List<TableTableElement>
getTables()
Deprecated.List<TableTableElement>
getTables(boolean deepSearch)
Return a list of table features in this document.protected String
getXMLFilePath(OdfSchemaDocument.OdfXMLFile file)
Get the relative path for an embedded ODF document including its file name.void
setContentDom(OdfContentDom contentDom)
Sets the ODF type-based content DOM of the content.xmlvoid
setJsonOperationQueue(JsonOperationProducer queue)
void
setMetaDom(OdfMetaDom metaDom)
Sets the ODF type-based meta DOM of the meta.xmlvoid
setRootComponent(Component rootComponent)
For instance, header and footer have their own component trees aside the main document.void
setSettingsDom(OdfSettingsDom settingsDom)
Sets the ODF type-based settings DOM of the settings.xmlvoid
setStylesDom(OdfStylesDom stylesDom)
Sets the ODF type-based styles DOM of the styles.xml-
Methods inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument
flushDoms, getAbsoluteFilePath, getCachedDom, getDocumentPath, getFileDom, getMediaTypeString, getPackage, getXMLFileMetadata, insertDocument, isExternalReference, isRootDocument, loadDocument, loadSubDocument, normalizeDocumentPath, removeDocument, save, save, setMediaTypeString
-
-
-
-
Field Detail
-
mContentDom
protected OdfContentDom mContentDom
-
mStylesDom
protected OdfStylesDom mStylesDom
-
mMetaDom
protected OdfMetaDom mMetaDom
-
mSettingsDom
protected OdfSettingsDom mSettingsDom
-
mJsonOperationQueue
protected JsonOperationProducer mJsonOperationQueue
-
-
Constructor Detail
-
OdfSchemaDocument
protected OdfSchemaDocument(OdfPackage pkg, String internalPath, String mediaTypeString)
Creates a new OdfSchemaDocument.- Parameters:
pkg
- - the ODF Package that contains the document. A baseURL is being generated based on its location.internalPath
- - the directory path within the package from where the document should be loaded.mediaTypeString
- - media type of stream. If unknown null can be used.
-
-
Method Detail
-
getJsonOperationQueue
public JsonOperationProducer getJsonOperationQueue()
- Returns:
- JSONObject of operations
-
setJsonOperationQueue
public void setJsonOperationQueue(JsonOperationProducer queue)
-
getOperations
public org.json.JSONObject getOperations(CollabTextDocument operationDoc) throws SAXException, org.json.JSONException, IOException
- Throws:
SAXException
org.json.JSONException
IOException
-
getRootComponent
public Component getRootComponent()
Returns the component tree of the document. The component tree is a high level abstraction of components (table, paragraph, character, etc.) from the XML implementation details of the document.The DOM of the content.xml will be created if not done before.
-
getRootComponentElement
public OdfElement getRootComponentElement(String masterStyleName, PageArea pageArea, boolean createIfNotExisting)
Returns the component tree of the document. The component tree is a high level abstraction of components (table, paragraph, character, etc.) from the XML implementation details of the document.The DOM of the content.xml will be created if not done before.
- Parameters:
masterStyleName
- the name of the master stylelocalName
- the local name of the header or footer XML element- Returns:
- the header or footer element belonging to the given master page style
-
setRootComponent
public void setRootComponent(Component rootComponent)
For instance, header and footer have their own component trees aside the main document. Therefore in a text document may exist three root components.
-
getContentStream
public InputStream getContentStream() throws Exception
Gets the ODF content.xml file as stream.- Returns:
- - a stream of the ODF content 'content.xml' file
- Throws:
Exception
- - if the stream can not be extracted
-
getStylesStream
public InputStream getStylesStream() throws Exception
Gets the ODF style.xml file as stream.- Returns:
- - a stream of the ODF style 'styles.xml' file
- Throws:
Exception
- - if the stream can not be extracted
-
getSettingsStream
public InputStream getSettingsStream() throws Exception
Gets the ODF settings.xml file as stream.- Returns:
- - a stream of the ODF settings 'setting.xml' file
- Throws:
Exception
- - if the stream can not be extracted
-
getMetaStream
public InputStream getMetaStream() throws Exception
Gets the ODF metadata.xml file as stream.- Returns:
- - a stream of the ODF metadata 'meta.xml' file
- Throws:
Exception
- - if the stream can not be extracted
-
getXMLFilePath
protected String getXMLFilePath(OdfSchemaDocument.OdfXMLFile file)
Get the relative path for an embedded ODF document including its file name.- Parameters:
file
- represents one of the standardized XML ODF files.- Returns:
- path to embedded ODF XML file relative to ODF package root.
-
getBaseURI
public String getBaseURI()
Get the URI, where this ODF document is stored.- Returns:
- the URI to the ODF document. Returns null if document is not stored yet.
-
getContentDom
public OdfContentDom getContentDom() throws SAXException, IOException
Return the ODF type-based content DOM of the content.xml- Returns:
- ODF type-based content DOM or null if no content.xml exists.
- Throws:
Exception
- if content DOM could not be initializedSAXException
IOException
-
getStylesDom
public OdfStylesDom getStylesDom() throws SAXException, IOException
Return the ODF type-based styles DOM of the styles.xml- Returns:
- ODF type-based styles DOM or null if no styles.xml exists.
- Throws:
Exception
- if styles DOM could not be initializedSAXException
IOException
-
getMetaDom
public OdfMetaDom getMetaDom() throws SAXException, IOException
Return the ODF type-based metadata DOM of the meta.xml- Returns:
- ODF type-based meta DOM or null if no meta.xml exists.
- Throws:
Exception
- if meta DOM could not be initializedSAXException
IOException
-
getSettingsDom
public OdfSettingsDom getSettingsDom() throws SAXException, IOException
Return the ODF type-based settings DOM of the settings.xml- Returns:
- ODF type-based settings DOM or null if no settings.xml exists.
- Throws:
Exception
- if settings DOM could not be initializedSAXException
IOException
-
setContentDom
public void setContentDom(OdfContentDom contentDom)
Sets the ODF type-based content DOM of the content.xml- Parameters:
contentDom
- ODF type-based content DOM or null if no content.xml exists.
-
setStylesDom
public void setStylesDom(OdfStylesDom stylesDom)
Sets the ODF type-based styles DOM of the styles.xml- Parameters:
stylesDom
- ODF type-based styles DOM or null if no styles.xml exists.
-
setMetaDom
public void setMetaDom(OdfMetaDom metaDom)
Sets the ODF type-based meta DOM of the meta.xml- Parameters:
metaDom
- ODF type-based meta DOM or null if no meta.xml exists.
-
setSettingsDom
public void setSettingsDom(OdfSettingsDom settingsDom)
Sets the ODF type-based settings DOM of the settings.xml- Parameters:
settingsDom
- ODF type-based settings DOM or null if no settings.xml exists.
-
getDocumentStyles
public OdfOfficeStyles getDocumentStyles()
- Returns:
- the office:styles element from the styles dom
-
getOfficeMasterStyles
public OdfOfficeMasterStyles getOfficeMasterStyles()
return the office:master-styles element of this document.- Returns:
- the office:master-styles element
-
getOrCreateDocumentStyles
public OdfOfficeStyles getOrCreateDocumentStyles()
- Returns:
- the office:styles element from the styles dom. If there is not yet such an element, it is created.
-
getStyleByName
public OdfStyle getStyleByName(OdfStyleFamily styleFamily, String styleName) throws SAXException, IOException
- Throws:
SAXException
IOException
-
getStyleByDisplayName
public OdfStyle getStyleByDisplayName(OdfStyleFamily styleFamily, String styleDisplayName) throws SAXException, IOException
- Throws:
SAXException
IOException
-
getTables
@Deprecated(since="explicit state whether the search should be recursive") public List<TableTableElement> getTables()
Deprecated.Return a list of table features in this document.- Returns:
- a list of table features in this document.
-
getTables
public List<TableTableElement> getTables(boolean deepSearch)
Return a list of table features in this document.- Parameters:
deepSearch
- Go through the whole document in search for tables (including master pages, headers, and footers), or search only at root level for ODS documents.- Returns:
- a list of table features in this document.
-
getMasterPages
@Deprecated public Map<String,StyleMasterPageElement> getMasterPages() throws Exception
Deprecated.This method will be moved to the generated sources as soon code generation was improved!ToDo: Instead of adding all elements using an index to the document, we might add a pattern to the code generation to create a HashMap either on demand (whenever such a structure is required from the user) or by default- Throws:
Exception
-
close
public void close()
Close the OdfPackage and release all temporary created data. After execution of this method, this class is no longer usable. Do this as the last action to free resources. Closing an already closed document has no effect. Note that this will not close any cached documents.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOdfPackageDocument
-
getFileDom
public OdfFileDom getFileDom(OdfSchemaDocument.OdfXMLFile file) throws SAXException, IOException
- Throws:
SAXException
IOException
-
getRDFMetadata
public org.apache.jena.rdf.model.Model getRDFMetadata() throws Exception
Get all two types of RDF Metadata through GRDDL XSLT: http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415068_253892949- Throws:
Exception
-
getInContentMetadata
public org.apache.jena.rdf.model.Model getInContentMetadata() throws Exception
Get In Content RDF Metadata through GRDDL XSLT http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415070_253892949- Throws:
Exception
-
getInContentMetadataFromCache
public org.apache.jena.rdf.model.Model getInContentMetadataFromCache() throws Exception
Get in-content metadata cache model- Returns:
- The in-content metadata cache model
- Throws:
Exception
-
getManifestRDFMetadata
public org.apache.jena.rdf.model.Model getManifestRDFMetadata() throws Exception
Get RDF metadata from manifest.rdf and those rdf files registered in the manifest.xml as "application/rdf+xml" through GRDDL XSLT http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415072_253892949- Throws:
Exception
-
-