Class odf.StyleParseUtils
Defined in: StyleParseUtils.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A collection of helper functions for parsing style attributes.
|
Method Attributes | Method Name and Description |
---|---|
<inner> |
getPropertiesElement(name, styleElement, previousPropertyElement)
Find a child element from the ODF style namespace with the given local
name.
|
<inner> |
parseAttributeList(text)
Split a space-separated attribute list into it's list items.
|
<inner> |
parseLength(val)
Convert a unit in a string to number of pixels at 96 dpi.
|
<inner> |
parsePercent(value)
Parse a percentage of the form -?([0-9]+(\.
|
<inner> |
parsePositiveLengthOrPercent(value, name, parent)
Parse a value that is a positive length or a percentage.
|
<inner> |
splitLength(length)
Returns the length split as value and unit, from an ODF attribute.
|
Method Detail
<inner>
{?Element}
getPropertiesElement(name, styleElement, previousPropertyElement)
Find a child element from the ODF style namespace with the given local
name.
The search is started after the given previousPropertyElement or, if
previousPropertyElement is not given, from the first child element.
- Parameters:
- {!string} name
- {!Element} styleElement
- {?Element=} previousPropertyElement
- Returns:
- {?Element}
<inner>
{!Array.}
parseAttributeList(text)
Split a space-separated attribute list into it's list items. Ignores leading & trailing
whitespace, and collapses excessive internal whitespace. If the input text is null, undefined
or pure whitespace, an empty array will be returned.
- Parameters:
- {?string|undefined} text
- Returns:
- {!Array.}
<inner>
{!number|undefined}
parseLength(val)
Convert a unit in a string to number of pixels at 96 dpi.
If the input value has unit 'px' or is a number, the number is taken as
is. Other allowed unit: cm, mm, pt, pc.
If the value cannot be parsed, the value undefined is returned.
- Parameters:
- {?string|undefined} val
- Returns:
- {!number|undefined}
<inner>
{!number|undefined}
parsePercent(value)
Parse a percentage of the form -?([0-9]+(\.[0-9]*)?|\.[0-9]+)%.
If parsing fails undefined is returned.
- Parameters:
- {?string|undefined} value
- Returns:
- {!number|undefined}
<inner>
{!number|undefined}
parsePositiveLengthOrPercent(value, name, parent)
Parse a value that is a positive length or a percentage.
If parsing fails undefined is returned.
- Parameters:
- {?string|undefined} value
- {!string} name
- {!odf.LazyStyleProperties|undefined} parent
- Returns:
- {!number|undefined}
<inner>
{?{value:!number|unit:!string}}
splitLength(length)
Returns the length split as value and unit, from an ODF attribute.
If the length does not match the regular expression, null is returned.
- Parameters:
- {?string|undefined} length
- Returns:
- {?{value:!number|unit:!string}}