Class odf.OdfUtilsImpl
Defined in: OdfUtils.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<inner> |
firstChild(node)
|
getAnnotationCreator(annotationElement)
Gets the creator of an annotation.
|
|
getHyperlinkElements(range)
Get all hyperlink elements that intersect the supplied range in document order
For example, given the following fragment, with the range starting at b, and ending at c:
|
|
getHyperlinkTarget(element)
Gets the href attribute of text:a element
|
|
getImageElements(range)
Get all image elements that fully contained within the supplied range in
document order.
|
|
getNormalizedFontFamilyName(fontFamilyName)
Normalize the font-family name as defined in
http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#propdef-font-family
(see there text behind: "There are two types of font family names:
|
|
<inner> |
getParagraphElement(node, offset)
Find the paragraph containing the specified node.
|
getParagraphElements(range)
Get all paragraph elements that intersect the supplied range in document
order.
|
|
<inner> |
getParentAnnotation(node, container)
|
<inner> |
getRightNode(container, offset)
Returns the node right after the given point.
|
<inner> |
getTextElements(range, includePartial, includeInsignificantWhitespace)
Get all character elements and text nodes fully contained within the
supplied range in document order.
|
<inner> |
getTextNodes(range, includePartial)
Returns a array of text nodes considered to be part of the supplied range.
|
<inner> |
hasNoODFContent(node)
Returns true if the supplied node contains no text-in-ODF, or ODF elements
|
<inner> |
Determine if the node is an 'as char' type of element,
i.e.
|
<inner> |
isAnnotation(e)
Determine if the node is an office:annotation element.
|
<inner> |
Determine if the node is an annotation wrapper element.
|
<inner> |
Determine if the node is a character element,
namely "s", "tab", or "line-break".
|
<inner> |
Determine if the node is a draw:frame element and has its text:anchor-type attribute set to 'as-char'.
|
Returns true if the supplied node is a downgradeable space element.
|
|
<inner> | |
<inner> |
Determine if the node is a grouping element.
|
<inner> |
isHyperlink(node)
Determine if the node is a text:a element.
|
<inner> |
isImage(e)
Determine if the node is a draw:image element.
|
<inner> |
isInlineRoot(e)
Determine if the node is an inline 'root' type,
i.e.
|
isLineBreak(e)
Determine if the node is a text:line-break element.
|
|
isListItem(e)
Determine if the node is a text:list-item element.
|
|
<inner> |
isODFNode(node)
Returns true if the given node is an odf node
|
<inner> |
isODFWhitespace(text)
Determine if the text consists entirely of whitespace characters.
|
<inner> |
isParagraph(e)
Determine if the node is a text:p or a text:h element.
|
<inner> |
isSignificantTextContent(textNode)
Returns true if the text node is within a paragraph and contains either non-whitespace characters, or
significant whitespace characters (as defined by the ODF standards).
|
<inner> |
isSignificantWhitespace(textNode, offset)
Takes a textNode and an offset, and returns true if the character
at that offset is a significant whitespace.
|
<inner> |
Determine if the node is a
|
<inner> |
Adapted from instructions on how to generate plain text from an ODT document.
|
isTextSpan(e)
Determine if the node is a text:span element.
|
|
<inner> |
isTrailingWhitespace(textnode, offset)
check if the node is part of the trailing whitespace
|
isWithinAnnotation(node, container)
|
|
<inner> |
lastChild(node)
|
<inner> |
lookLeftForCharacter(node)
Walk to the left along the DOM and return the type of the first
thing encountered.
|
<inner> |
lookRightForCharacter(node)
Look to the right along the DOM and return true if the first thing
encountered is either a non-whitespace character or a character
element.
|
<inner> |
nextNode(node)
|
<inner> |
parseFoFontSize(fontSize)
Returns the value and unit of the font size, in conformance with fo:font-size
constraints
|
<inner> |
parseFoLineHeight(lineHeight)
Returns the value and unit of the line height, in conformance with fo:line-height
constraints
|
<inner> |
parseLength(length)
Returns the length split as value and unit, from an ODF attribute
|
<inner> |
parseNonNegativeLength(length)
Returns the value and unit of the length, if it is non-negative ( >= 0)
|
<inner> |
parsePercentage(length)
Returns the value and unit(%) of the length, if it is specified in %age
|
<inner> |
parsePositiveLength(length)
Returns the value and unit of the length, if it is positive ( > 0)
|
<inner> |
prependParentContainers(startContainer, elements, filter)
Crawl parent nodes starting at the startContainer until a matching node is found,
or the first inline root is met.
|
<inner> |
previousNode(node)
|
<inner> |
removePartiallyContainedNodes(range, nodes)
Remove any nodes that aren't fully contained within the supplied range.
|
<inner> |
scanLeftForAnyCharacter(node)
Walk to the left along the DOM and return true if either a
non-whitespace character or a character element is encountered.
|
<inner> |
scanLeftForNonSpace(node)
Walk to the left along the DOM and return true if the first thing
encountered is either a non-whitespace text character or a non-space
character element (i.e.
|
<inner> |
scanRightForAnyCharacter(node)
Walk to the right along the DOM and return true if either a
non-whitespace character or a character element is encountered.
|
Method Detail
<inner>
{!Node}
firstChild(node)
- Parameters:
- {!Node} node
- Returns:
- {!Node}
{!string}
getAnnotationCreator(annotationElement)
Gets the creator of an annotation.
- Parameters:
- {!Element} annotationElement
- Returns:
- {!string}
{!Array.}
getHyperlinkElements(range)
Get all hyperlink elements that intersect the supplied range in document order
For example, given the following fragment, with the range starting at b, and ending at c:
ab cd
this function would return the following array:
[text:a{xlink:href="google"}, text:a{xlink:href="apple"}]
- Parameters:
- {!Range} range
- Returns:
- {!Array.
}
{!string}
getHyperlinkTarget(element)
Gets the href attribute of text:a element
- Parameters:
- {!Element} element
- Returns:
- {!string}
{!Array.}
getImageElements(range)
Get all image elements that fully contained within the supplied range in
document order.
- Parameters:
- {!Range} range
- Returns:
- {!Array.
}
{!string}
getNormalizedFontFamilyName(fontFamilyName)
Normalize the font-family name as defined in
http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#propdef-font-family
(see there text behind: "There are two types of font family names: ")
- Parameters:
- {!string} fontFamilyName
- Returns:
- {!string}
<inner>
{?Element}
getParagraphElement(node, offset)
Find the paragraph containing the specified node. If an offset is provided and
the node has a child at the specified offset, this will be included in the search
as well if the supplied node is not a paragraph itself.
- Parameters:
- {?Node} node
- {!number=} offset
- Returns:
- {?Element}
{!Array.}
getParagraphElements(range)
Get all paragraph elements that intersect the supplied range in document
order.
For example, given the following fragment, with the range starting at b,
and ending at c:
ab cd
this function would return the following array:
[text:p{id="A"}, text:p{id="B"}]
- Parameters:
- {!Range} range
- Returns:
- {!Array.}
<inner>
{?Element}
getParentAnnotation(node, container)
- Parameters:
- {?Node} node
- Node to start searching with
- {!Element} container
- Root container to stop searching at.
- Returns:
- {?Element}
<inner>
{!Node}
getRightNode(container, offset)
Returns the node right after the given point.
- Parameters:
- {!Node} container
- {!number} offset
- Returns:
- {!Node}
<inner>
{!Array.}
getTextElements(range, includePartial, includeInsignificantWhitespace)
Get all character elements and text nodes fully contained within the
supplied range in document order.
For example, given the following fragment, with the range starting at b,
and ending at c:
ab cd
this function would return the following array:
["b", text:s, "c"]
- Parameters:
- {!Range} range
- {!boolean} includePartial
- Include partially intersecting text & character nodes in the result.
- {!boolean} includeInsignificantWhitespace
- Include whitespace only nodes that are not considered significant text content. This includes whitespace only elements used in pretty-formatted xml as LibreOffice produces in flat ODT files.
- Returns:
- {!Array.}
<inner>
{!Array.}
getTextNodes(range, includePartial)
Returns a array of text nodes considered to be part of the supplied range.
This will exclude elements that are not part of the ODT main text body,
as well as insignificant whitespace text nodes.
- Parameters:
- {!Range} range
- Range to search for nodes within
- {boolean} includePartial
- Include partially intersecting text nodes in the result.
- Returns:
- {!Array.}
<inner>
{!boolean}
hasNoODFContent(node)
Returns true if the supplied node contains no text-in-ODF, or ODF elements
- Parameters:
- {!Node} node
- Returns:
- {!boolean}
<inner>
{!boolean}
isAnchoredAsCharacterElement(e)
Determine if the node is an 'as char' type of element,
i.e. any element which behaves like a character with
respect to it's surrounding positions, such as the
space/tab/line-break elements, draw:frames with
anchor type being 'as-char', or inline root elements
such as annotations.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{!boolean}
isAnnotation(e)
Determine if the node is an office:annotation element.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{!boolean}
isAnnotationWrapper(e)
Determine if the node is an annotation wrapper element.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{!boolean}
isCharacterElement(e)
Determine if the node is a character element,
namely "s", "tab", or "line-break".
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{!boolean}
isCharacterFrame(e)
Determine if the node is a draw:frame element and has its text:anchor-type attribute set to 'as-char'.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
{!boolean}
isDowngradableSpaceElement(node)
Returns true if the supplied node is a downgradeable space element.
As per http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#element-text_s
a downgradeable whitespace element is a space element that is immediately preceded by something other than a space
and has at least one non-space character after it
- Parameters:
- {!Node} node
- Returns:
- {!boolean}
<inner>
{!boolean}
isFieldElement(n)
- Parameters:
- {?Node} n
- Returns:
- {!boolean}
<inner>
{!boolean}
isGroupingElement(n)
Determine if the node is a grouping element.
- Parameters:
- {?Node} n
- Returns:
- {!boolean}
<inner>
{!boolean}
isHyperlink(node)
Determine if the node is a text:a element.
- Parameters:
- {?Node} node
- Returns:
- {!boolean}
<inner>
{!boolean}
isImage(e)
Determine if the node is a draw:image element.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{!boolean}
isInlineRoot(e)
Determine if the node is an inline 'root' type,
i.e. an office:annotation or a wrapper for an annotaiton.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
{!boolean}
isLineBreak(e)
Determine if the node is a text:line-break element.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
{!boolean}
isListItem(e)
Determine if the node is a text:list-item element.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{!boolean}
isODFNode(node)
Returns true if the given node is an odf node
- Parameters:
- {!Node} node
- Returns:
- {!boolean}
<inner>
{!boolean}
isODFWhitespace(text)
Determine if the text consists entirely of whitespace characters.
At least one whitespace is required.
- Parameters:
- {!string} text
- Returns:
- {!boolean}
<inner>
{!boolean}
isParagraph(e)
Determine if the node is a text:p or a text:h element.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{!boolean}
isSignificantTextContent(textNode)
Returns true if the text node is within a paragraph and contains either non-whitespace characters, or
significant whitespace characters (as defined by the ODF standards).
WARNING this method is likely to be quite slow, so should be used as little as possible
- Parameters:
- {!Text} textNode
- Returns:
- {!boolean}
<inner>
{!boolean}
isSignificantWhitespace(textNode, offset)
Takes a textNode and an offset, and returns true if the character
at that offset is a significant whitespace.
Significant whitespace is defined as:
- Not part of the leading whitespace block in a paragraph
- Not part of the trailing whitespace block in a paragraph
- The first whitespace character after a text node or character
All other whitespace elements are considered insignificant
- Parameters:
- {!Text} textNode
- {!number} offset
- Returns:
- {!boolean}
<inner>
{!boolean}
isSpaceElement(e)
Determine if the node is a character element.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{boolean}
isTextContentContainingNode(node)
Adapted from instructions on how to generate plain text from an ODT document.
See algorithm at http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415196_253892949
- Parameters:
- {!Node} node
- Returns:
- {boolean}
{!boolean}
isTextSpan(e)
Determine if the node is a text:span element.
- Parameters:
- {?Node} e
- Returns:
- {!boolean}
<inner>
{!boolean}
isTrailingWhitespace(textnode, offset)
check if the node is part of the trailing whitespace
- Parameters:
- {!Text} textnode
- {!number} offset
- Returns:
- {!boolean}
{!boolean}
isWithinAnnotation(node, container)
- Parameters:
- {?Node} node
- Node to start searching with
- {!Element} container
- Root container to stop searching at.
- Returns:
- {!boolean}
<inner>
{!Node}
lastChild(node)
- Parameters:
- {!Node} node
- Returns:
- {!Node}
<inner>
{!number}
lookLeftForCharacter(node)
Walk to the left along the DOM and return the type of the first
thing encountered.
0 none of the below
1 non-whitespace character or a character element
2 whitespace character that is preceded by a non-whitespace character
or a character element
- Parameters:
- {!Node} node
- the first node to scan
- Returns:
- {!number}
<inner>
{!boolean}
lookRightForCharacter(node)
Look to the right along the DOM and return true if the first thing
encountered is either a non-whitespace character or a character
element.
- Parameters:
- {?Node} node
- the first node to scan
- Returns:
- {!boolean}
<inner>
{?Node}
nextNode(node)
- Parameters:
- {!Node} node
- Returns:
- {?Node}
<inner>
{?{value:!number|unit:!string}}
parseFoFontSize(fontSize)
Returns the value and unit of the font size, in conformance with fo:font-size
constraints
- Parameters:
- {?string|undefined} fontSize
- Returns:
- {?{value:!number|unit:!string}}
<inner>
{?{value:!number|unit:!string}}
parseFoLineHeight(lineHeight)
Returns the value and unit of the line height, in conformance with fo:line-height
constraints
- Parameters:
- {?string|undefined} lineHeight
- Returns:
- {?{value:!number|unit:!string}}
<inner>
{?{value:!number|unit:!string}}
parseLength(length)
Returns the length split as value and unit, from an ODF attribute
- Parameters:
- {?string|undefined} length
- Returns:
- {?{value:!number|unit:!string}}
<inner>
{?{value:!number|unit:!string}}
parseNonNegativeLength(length)
Returns the value and unit of the length, if it is non-negative ( >= 0)
- Parameters:
- {?string|undefined} length
- Returns:
- {?{value:!number|unit:!string}}
<inner>
{?{value:!number|unit:!string}}
parsePercentage(length)
Returns the value and unit(%) of the length, if it is specified in %age
- Parameters:
- {?string|undefined} length
- Returns:
- {?{value:!number|unit:!string}}
<inner>
{?{value:!number|unit:!string}}
parsePositiveLength(length)
Returns the value and unit of the length, if it is positive ( > 0)
- Parameters:
- {?string|undefined} length
- Returns:
- {?{value:!number|unit:!string}}
<inner>
prependParentContainers(startContainer, elements, filter)
Crawl parent nodes starting at the startContainer until a matching node is found,
or the first inline root is met. If a node is accepted by the supplied filter, and is
not already the first element in the elements array, this node is prepended to the start
of the elements array.
- Parameters:
- {!Node} startContainer
- Container to start search from (inclusive)
- {!Array.} elements
- Existing elements already discovered
- {!function(!Node):!boolean} filter
<inner>
{?Node}
previousNode(node)
- Parameters:
- {!Node} node
- Returns:
- {?Node}
<inner>
{undefined}
removePartiallyContainedNodes(range, nodes)
Remove any nodes that aren't fully contained within the supplied range. This function assumes
the nodes appear in document order.
- Parameters:
- {!Range} range
- {!Array.} nodes
- Returns:
- {undefined}
<inner>
{!boolean}
scanLeftForAnyCharacter(node)
Walk to the left along the DOM and return true if either a
non-whitespace character or a character element is encountered.
- Parameters:
- {?Node} node
- the first node to scan
- Returns:
- {!boolean}
<inner>
{!boolean}
scanLeftForNonSpace(node)
Walk to the left along the DOM and return true if the first thing
encountered is either a non-whitespace text character or a non-space
character element (i.e., any character element other than ).
Walking goes through grouping elements.
- Parameters:
- {?Node} node
- the first node to scan
- Returns:
- {!boolean}
<inner>
{!boolean}
scanRightForAnyCharacter(node)
Walk to the right along the DOM and return true if either a
non-whitespace character or a character element is encountered.
- Parameters:
- {?Node} node
- the first node to scan
- Returns:
- {!boolean}