Class odf.StyleCache
Defined in: StyleCache.js.
Constructor Attributes | Constructor Name and Description |
---|---|
odf.StyleCache(odfroot)
Fast and type-safe access to styling properties of an ODF document.
|
Method Attributes | Method Name and Description |
---|---|
<inner> |
addMasterPage(element)
|
<inner> |
appendClassNames(family, ns, element, chain)
|
<inner> |
createPropertiesChain(styleChain, propertiesName, defaultFamily)
|
getComputedGraphicStyle(element)
Return the paragraph style for the given content element.
|
|
getComputedParagraphStyle(element)
Return the paragraph style for the given content element.
|
|
getComputedTextStyle(element)
Return the text style for the given content element.
|
|
<inner> |
getGraphicStyleChain(element, chain)
|
<inner> |
getMasterPage(name)
|
<inner> |
getPageLayout(name)
|
<inner> |
getParagraphStyleChain(element, chain)
|
<inner> |
getPileFromElement(element)
|
<inner> |
getTextStyleChain(element, chain)
|
<inner> |
update()
|
Class Detail
odf.StyleCache(odfroot)
Fast and type-safe access to styling properties of an ODF document.
When the document changes, update() has to be called to update the
information.
This class gives access to computed styles. The term 'computed' is used
similarly to its use in the DOM function window.getComputedStyle().
In ODF, as in CSS but differently, the evaluation of styles is influenced by
the position of an element in a document. Specifically, the types and styles
of the ancestor elements determine properties of a style. This is explained
in chapter 16 of the ODF 1.2 specification.
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416272_253892949
Here is an example. Consider the following style and content:
...
...
...
...
...
...
...
...
...
...
...
hello
The style properties for the word 'hello' are looked for, in order, in this
list of styles:
text:T2
text:Bold
text:Standard
text:T1
text:Standard
text:C1
text:Standard
text:C2
text:Standard
paragraph:P1
paragraph:Standard
paragraph-document-default
paragraph-implementation-default
The style names can be concatenated into a key. The parent styles are not
needed in the key. For the above example, the key is:
text/T2/text/T1/text/C1/text/C2/paragraph/P1
StyleCache creates computed style objects on demand and caches them.
StyleCache also provides convenient access to page layout and master page
information.
Each property of the style objects has a valid value even if the underlying
XML element or attribute is missing or invalid.
- Parameters:
- {!odf.ODFDocumentElement} odfroot
Method Detail
<inner>
{undefined}
addMasterPage(element)
- Parameters:
- {!Element} element
- Returns:
- {undefined}
<inner>
{undefined}
appendClassNames(family, ns, element, chain)
- Parameters:
- {!string} family
- {!string} ns
- {!Element} element
- {!Array.} chain
- Returns:
- {undefined}
<inner>
{!Array.}
createPropertiesChain(styleChain, propertiesName, defaultFamily)
- Parameters:
- {!Array.} styleChain
- {!string} propertiesName
- {!string} defaultFamily
- Returns:
- {!Array.}
{!odf.ComputedGraphicStyle}
getComputedGraphicStyle(element)
Return the paragraph style for the given content element.
- Parameters:
- {!Element} element
- Returns:
- {!odf.ComputedGraphicStyle}
{!odf.ComputedParagraphStyle}
getComputedParagraphStyle(element)
Return the paragraph style for the given content element.
- Parameters:
- {!Element} element
- Returns:
- {!odf.ComputedParagraphStyle}
{!odf.ComputedTextStyle}
getComputedTextStyle(element)
Return the text style for the given content element.
- Parameters:
- {!Element} element
- Returns:
- {!odf.ComputedTextStyle}
{!odf.MasterPage}
getDefaultMasterPage()
- Returns:
- {!odf.MasterPage}
{!odf.PageLayout}
getDefaultPageLayout()
- Returns:
- {!odf.PageLayout}
<inner>
{!Array.}
getGraphicStyleChain(element, chain)
- Parameters:
- {!Element} element
- {!Array.} chain
- Returns:
- {!Array.}
<inner>
{?odf.MasterPage}
getMasterPage(name)
- Parameters:
- {!string} name
- Returns:
- {?odf.MasterPage}
<inner>
{!odf.PageLayout}
getPageLayout(name)
- Parameters:
- {!string} name
- Returns:
- {!odf.PageLayout}
<inner>
{!Array.}
getParagraphStyleChain(element, chain)
- Parameters:
- {!Element} element
- {!Array.} chain
- Returns:
- {!Array.}
<inner>
{!odf.StylePile|undefined}
getPileFromElement(element)
- Parameters:
- {!Element} element
- Returns:
- {!odf.StylePile|undefined}
<inner>
{!Array.}
getTextStyleChain(element, chain)
- Parameters:
- {!Element} element
- {!Array.} chain
- Returns:
- {!Array.}
<inner>
{undefined}
update()
- Returns:
- {undefined}