Class odf.OdfContainer
Defined in: OdfContainer.js.
Constructor Attributes | Constructor Name and Description |
---|---|
odf.OdfContainer(urlOrType, onstatereadychange)
The OdfContainer class manages the various parts that constitues an ODF
document.
|
Field Attributes | Field Name and Description |
---|---|
<static> |
odf.OdfContainer.DocumentType
|
Method Attributes | Method Name and Description |
---|---|
<inner> |
cloneFontFaceDeclsUsedInStyles(fontFaceDeclsRootElement, stylesRootElementList)
Creates a clone of the font face declaration tree containing only
those declarations which are referenced in the passed styles.
|
<inner> |
cloneStylesInScope(stylesRootElement, scope)
Creates a clone of the styles tree containing only styles tagged
with the given scope, or with no specified scope.
|
<inner> |
createByteArray(successCallback, errorCallback)
Create a bytearray from the zipfile.
|
<inner> |
createDocumentElement(name)
|
<inner> |
createElement(type)
|
<inner> |
createEmptyDocument(type, isTemplate)
|
<inner> |
createManifestEntry(fullPath, mediaType)
Creates a manifest:file-entry node
|
<inner> |
fillZip()
Fill the zip with current data.
|
<static> |
odf.OdfContainer.getContainer(url)
|
Gets the document type as 'text', 'presentation', or 'spreadsheet'.
|
|
<inner> |
Returns the meta element.
|
<inner> |
getMetadata(metadataNs, metadataLocalName)
|
getPart(partname)
Open file and parse it.
|
|
getPartData(url, callback)
|
|
getUrl()
|
|
<inner> |
handleContentXml(xmldoc)
|
<inner> |
handleFlatXml(xmldoc)
|
<inner> |
handleManifestXml(xmldoc)
|
<inner> |
handleMetaXml(xmldoc)
|
<inner> |
handleSettingsXml(xmldoc)
|
<inner> |
handleStylesXml(xmldoc)
|
<inner> |
importRootNode(xmldoc)
Import the document elementnode into the DOM of OdfContainer.
|
Increment the number of times the document has been edited.
|
|
Returns whether the document is a template.
|
|
<inner> |
linkAnnotationStartAndEndElements(rootElement)
Iterates through the subtree of rootElement and adds annotation-end
elements as direct properties of the corresponding annotation elements.
|
<inner> | |
<inner> |
loadFromXML(url, callback)
|
<inner> |
loadNextComponent(remainingComponents)
|
<inner> |
mapByFontFaceName(fontFaceDecls)
Returns a map with the fontface declaration elements, with font-face name as key.
|
<inner> |
mergeFontFaceDecls(targetFontFaceDeclsRootElement, sourceFontFaceDeclsRootElement)
Merges all style:font-face elements from the source into the target.
|
removeBlob(filename)
|
|
<inner> |
removeDangerousAttributes(element)
Remove all attributes that have no namespace and that have
localname like 'on.
|
<inner> |
removeDangerousElements(xmldoc)
Remove any HTML tags from the DOM.
|
<inner> |
removeElements(xmldoc, localName, allowedNamespaces)
|
<inner> |
removeProcessingInstructions(element)
|
save(callback)
|
|
<inner> |
saveAs(newurl, callback)
|
<inner> | |
<inner> | |
<inner> | |
<inner> | |
<inner> | |
<inner> |
setAutomaticStylesScope(stylesRootElement, scope)
Tags all styles with an attribute noting their scope.
|
setBlob(filename, mimetype, content)
Add a new blob or overwrite any existing blob which has the same filename.
|
|
setIsTemplate(isTemplate)
Sets whether the document is a template or not.
|
|
<inner> |
setMetadata(setProperties, removedPropertyNames)
Sets the metadata fields from the given properties map.
|
<inner> |
setRootElement(root)
|
<inner> |
setState(state)
|
<inner> |
unusedKey(key, map1, map2)
Returns key with a number postfix or none, as key unused both in map1 and map2.
|
<inner> |
Write pre-saving metadata to the DOM
|
Class Detail
odf.OdfContainer(urlOrType, onstatereadychange)
The OdfContainer class manages the various parts that constitues an ODF
document.
The constructor takes a url or a type. If urlOrType is a type, an empty
document of that type is created. Otherwise, urlOrType is interpreted as
a url and loaded from that url.
- Parameters:
- {!string|!odf.OdfContainer.DocumentType} urlOrType
- {?function(!odf.OdfContainer)=} onstatereadychange
- Returns:
- {?}
Field Detail
<static>
odf.OdfContainer.DocumentType
Method Detail
<inner>
{?Element}
cloneFontFaceDeclsUsedInStyles(fontFaceDeclsRootElement, stylesRootElementList)
Creates a clone of the font face declaration tree containing only
those declarations which are referenced in the passed styles.
- Parameters:
- {?Element} fontFaceDeclsRootElement
- {!Array.} stylesRootElementList
- Returns:
- {?Element}
<inner>
{?Element}
cloneStylesInScope(stylesRootElement, scope)
Creates a clone of the styles tree containing only styles tagged
with the given scope, or with no specified scope.
Helper function for the primitive complete backwriting of
the automatic styles.
- Parameters:
- {?Element} stylesRootElement
- {!string} scope
- Returns:
- {?Element}
<inner>
{undefined}
createByteArray(successCallback, errorCallback)
Create a bytearray from the zipfile.
- Parameters:
- {!function(!Uint8Array):undefined} successCallback
- receiving zip as bytearray
- {!function(?string):undefined} errorCallback
- receiving possible err
- Returns:
- {undefined}
<inner>
{!string}
createDocumentElement(name)
- Parameters:
- {!string} name
- Returns:
- {!string}
<inner>
{!Element}
createElement(type)
- Parameters:
- {!{Type:function(new:Object)|namespaceURI:string|localName:string}} type
- Returns:
- {!Element}
<inner>
{!core.Zip}
createEmptyDocument(type, isTemplate)
- Parameters:
- {!string} type
- {!boolean=} isTemplate
- Default value is false.
- Returns:
- {!core.Zip}
<inner>
{!Node}
createManifestEntry(fullPath, mediaType)
Creates a manifest:file-entry node
- Parameters:
- {!string} fullPath
- Full-path attribute value for the file-entry
- {!string} mediaType
- Media-type attribute value for the file-entry
- Returns:
- {!Node}
<inner>
{undefined}
fillZip()
Fill the zip with current data.
- Returns:
- {undefined}
<static>
{!odf.OdfContainer}
odf.OdfContainer.getContainer(url)
- Parameters:
- {!string} url
- Returns:
- {!odf.OdfContainer}
{!Element}
getContentElement()
- Returns:
- {!Element}
{!string}
getDocumentType()
Gets the document type as 'text', 'presentation', or 'spreadsheet'.
- Returns:
- {!string}
<inner>
{!Element}
getEnsuredMetaElement()
Returns the meta element. If it did not exist before, it will be created.
- Returns:
- {!Element}
<inner>
{?string}
getMetadata(metadataNs, metadataLocalName)
- Parameters:
- {!string} metadataNs
- {!string} metadataLocalName
- Returns:
- {?string}
{!odf.OdfPart}
getPart(partname)
Open file and parse it. Return the XML Node. Return the root node of
the file or null if this is not possible.
For 'content.xml', 'styles.xml', 'meta.xml', and 'settings.xml', the
elements 'document-content', 'document-styles', 'document-meta', or
'document-settings' will be returned respectively.
- Parameters:
- {string} partname
- Returns:
- {!odf.OdfPart}
{undefined}
getPartData(url, callback)
- Parameters:
- {string} url
- {function(?string|?Uint8Array)} callback
- receiving err and data
- Returns:
- {undefined}
{!string}
getUrl()
- Returns:
- {!string}
<inner>
{undefined}
handleContentXml(xmldoc)
- Parameters:
- {Document} xmldoc
- Returns:
- {undefined}
<inner>
{undefined}
handleFlatXml(xmldoc)
- Parameters:
- {Document|undefined} xmldoc
- Returns:
- {undefined}
<inner>
{undefined}
handleManifestXml(xmldoc)
- Parameters:
- {Document} xmldoc
- Returns:
- {undefined}
<inner>
{undefined}
handleMetaXml(xmldoc)
- Parameters:
- {Document} xmldoc
- Returns:
- {undefined}
<inner>
{undefined}
handleSettingsXml(xmldoc)
- Parameters:
- {Document} xmldoc
- Returns:
- {undefined}
<inner>
{undefined}
handleStylesXml(xmldoc)
- Parameters:
- {Document} xmldoc
- Returns:
- {undefined}
<inner>
{!Element|undefined}
importRootNode(xmldoc)
Import the document elementnode into the DOM of OdfContainer.
Any processing instructions are removed, since importing them
gives an exception.
- Parameters:
- {Document|undefined} xmldoc
- Returns:
- {!Element|undefined}
{!number}
incrementEditingCycles()
Increment the number of times the document has been edited.
- Returns:
- {!number} new number of editing cycles
{!boolean}
isTemplate()
Returns whether the document is a template.
- Returns:
- {!boolean}
<inner>
{undefined}
linkAnnotationStartAndEndElements(rootElement)
Iterates through the subtree of rootElement and adds annotation-end
elements as direct properties of the corresponding annotation elements.
Expects properly used annotation elements, does not try
to do heuristic fixes or drop broken elements.
- Parameters:
- {!Element} rootElement
- Returns:
- {undefined}
<inner>
{undefined}
loadComponents()
- Returns:
- {undefined}
<inner>
{undefined}
loadFromXML(url, callback)
- Parameters:
- {!string} url
- {!function((string)):undefined} callback
- Returns:
- {undefined}
<inner>
{undefined}
loadNextComponent(remainingComponents)
- Parameters:
- {!Array.} remainingComponents
- Returns:
- {undefined}
<inner>
{!Object.}
mapByFontFaceName(fontFaceDecls)
Returns a map with the fontface declaration elements, with font-face name as key.
- Parameters:
- {!Element} fontFaceDecls
- Returns:
- {!Object.}
<inner>
{!Object.}
mergeFontFaceDecls(targetFontFaceDeclsRootElement, sourceFontFaceDeclsRootElement)
Merges all style:font-face elements from the source into the target.
Skips elements equal to one already in the target.
Elements with the same style:name but different properties get a new
value for style:name. Any name changes are logged and returned as a map
with the old names as keys.
- Parameters:
- {!Element} targetFontFaceDeclsRootElement
- {!Element} sourceFontFaceDeclsRootElement
- Returns:
- {!Object.} mapping of old font-face name to new
removeBlob(filename)
- Parameters:
- {!string} filename
<inner>
{undefined}
removeDangerousAttributes(element)
Remove all attributes that have no namespace and that have
localname like 'on....', the event handler attributes.
- Parameters:
- {!Element} element
- Returns:
- {undefined}
<inner>
{undefined}
removeDangerousElements(xmldoc)
Remove any HTML tags from the DOM.
The tags need to be removed, because otherwise they would be executed
when the dom is inserted into the document.
To be safe, all elements with localName "script" are removed, unless
they are in a known, allowed namespace.
- Parameters:
- {!Document} xmldoc
- Returns:
- {undefined}
<inner>
{undefined}
removeElements(xmldoc, localName, allowedNamespaces)
- Parameters:
- {!Document} xmldoc
- {!string} localName
- {!Object.} allowedNamespaces
- Returns:
- {undefined}
<inner>
{undefined}
removeProcessingInstructions(element)
- Parameters:
- {!Element} element
- Returns:
- {undefined}
{undefined}
save(callback)
- Parameters:
- {function(?string):undefined} callback
- Returns:
- {undefined}
<inner>
{undefined}
saveAs(newurl, callback)
- Parameters:
- {!string} newurl
- {function(?string):undefined} callback
- Returns:
- {undefined}
<inner>
{!string}
serializeContentXml()
- Returns:
- {!string}
<inner>
{string}
serializeManifestXml()
- Returns:
- {string}
<inner>
{!string}
serializeMetaXml()
- Returns:
- {!string}
<inner>
{!string}
serializeSettingsXml()
- Returns:
- {!string}
<inner>
{!string}
serializeStylesXml()
- Returns:
- {!string}
<inner>
{undefined}
setAutomaticStylesScope(stylesRootElement, scope)
Tags all styles with an attribute noting their scope.
Helper function for the primitive complete backwriting of
the automatic styles.
- Parameters:
- {?Element} stylesRootElement
- {!string} scope
- Returns:
- {undefined}
setBlob(filename, mimetype, content)
Add a new blob or overwrite any existing blob which has the same filename.
- Parameters:
- {!string} filename
- {!string} mimetype
- {!string} content
- base64 encoded string
{undefined}
setIsTemplate(isTemplate)
Sets whether the document is a template or not.
- Parameters:
- {!boolean} isTemplate
- Returns:
- {undefined}
<inner>
{undefined}
setMetadata(setProperties, removedPropertyNames)
Sets the metadata fields from the given properties map.
- Parameters:
- {?Object.} setProperties
- A flat object that is a string->string map of field name -> value.
- {?Array.} removedPropertyNames
- An array of metadata field names (prefixed).
- Returns:
- {undefined}
<inner>
{undefined}
setRootElement(root)
- Parameters:
- {!Element} root
- Returns:
- {undefined}
<inner>
{undefined}
setState(state)
- Parameters:
- {!number} state
- Returns:
- {undefined}
<inner>
{!string}
unusedKey(key, map1, map2)
Returns key with a number postfix or none, as key unused both in map1 and map2.
- Parameters:
- {!string} key
- {!Object} map1
- {!Object} map2
- Returns:
- {!string}
<inner>
{undefined}
updateMetadataForSaving()
Write pre-saving metadata to the DOM
- Returns:
- {undefined}