Package org.odftoolkit.odfdom.changes
Class Component
java.lang.Object
org.odftoolkit.odfdom.changes.Component
- Direct Known Subclasses:
Row,Table,TextContainer
The component is a logical modular entity, to abstract from the implementation details of the
XML.
- Author:
- svante.schubertATgmail.com
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionComponent(OdfElement componentElement) Only being used to create the root of all components, representing the document without a parent elementprotectedComponent(OdfElement componentElement, Component parent) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given component as new child component.static ComponentcreateChildComponent(int position, Component parentComponent, OdfElement newChildElement) Inserts a component at the given position as childcreateChildComponent(OdfElement componentRoot) Appending a child element to the componentstatic ComponentcreateComponent(Component parentComponent, OdfElement newChildElement) get(org.json.JSONArray position) protected Componentget(org.json.JSONArray position, boolean needParent, boolean needFollowingSibling, int depth) Get descendant component by its relative position to this component.static Map<String, OdfStylePropertiesSet> getAllStyleGroupingIdProperties(OdfStylableElement styleElement) static Map<String, OdfStylePropertiesSet> getAllStyleGroupingIdProperties(OdfStyleFamily styleFamily) getChildNode(int position) getChildNode(int startPosition, int endPosition) static OdfElementgetCorrectStartElementOfChild(OdfElement parentElement, OdfElement existingChildElement) Sometimes (e.g.static OdfStyleFamilystatic StringgetFamilyDisplayName(OdfStyleFamily styleFamily) static StringgetFamilyID(OdfStylableElement styleElement) static StringgetFamilyID(OdfStyleFamily styleFamily) static StringgetFamilyName(String styleId) static StringgetMainStyleGroupingId(OdfStylableElement styleElement) static StringgetMainStyleGroupingId(OdfStyleFamily styleFamily) getNextSiblingOf(org.json.JSONArray position) Get next sibling component of the given position.Returns the parent componentgetParentOf(org.json.JSONArray position) Get parent component of the given positionprotected Stringprotected static Stringstatic StringgetStyleNamePrefix(OdfStylableElement styleElement) static StringgetStyleNamePrefix(OdfStyleFamily styleFamily) booleanvoidhasRepeated(boolean hasRepeated) intstatic booleanisComponentRoot(String uri, String localName) Tests if the given element is the start of a componentstatic booleanisComponentRoot(Element element) Tests if the given element is the start of a componentstatic booleanisComponentWrapper(String uri, String localName) Tests if the given element is the wrapper around a descendant component root elementstatic booleanisComponentWrapper(Element element) Tests if the given element is the wrapper around a descendant component root elementstatic booleanisCoveredComponentRoot(String uri, String localName) static booleanisDocumentRoot(String uri, String localName) Tests if the given element is the start of a documentstatic booleanstatic booleanisFooterRoot(String uri, String localName) Tests if the given element is the start of a footer within a page style.static booleanisHeaderRoot(String uri, String localName) Tests if the given element is the start of a header within a page style.static booleanisRowComponentRoot(String uri, String localName) static booleanisRowComponentRoot(Node textContainer) static booleanisShapeElement(String uri, String localName) Tests if the given element is a shape element Shapes are in general those with elements with astatic booleanisTextComponentRoot(String uri, String localName) static booleanisTextComponentRoot(Node textContainer) Returns true if the Node is an TextPElement or TextHElement.static booleanisTextSelection(Node textSelection) static booleanisWhiteSpaceElement(String uri, String localName) Tests if the given element is a whitespace elementremove(int position) Only removes from the component list, not from the DOMintA multiple components can be represented by a single XML elementintsize()Returns the number of child componentstoString()
-
Field Details
-
mRootElement
-
-
Constructor Details
-
Component
Only being used to create the root of all components, representing the document without a parent element -
Component
-
-
Method Details
-
isComponentRoot
Tests if the given element is the start of a component- Returns:
- true if the given element is the root of an ODF component
-
isComponentRoot
Tests if the given element is the start of a component- Returns:
- true if the given element is the root of an ODF component
-
isComponentWrapper
Tests if the given element is the wrapper around a descendant component root element- Returns:
- true if the given element is a potential wrapper around an ODF component
-
isComponentWrapper
Tests if the given element is the wrapper around a descendant component root element- Returns:
- true if the given element is a potential wrapper around an ODF component
-
isTextComponentRoot
Returns true if the Node is an TextPElement or TextHElement. Both are the root elements of text containers. Text container have special handline of whitespace, see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#White-space_Characters -
isTextComponentRoot
-
isRowComponentRoot
-
isRowComponentRoot
-
isField
-
isDocumentRoot
Tests if the given element is the start of a document- Returns:
- true if the given element is the root of an ODF document (e.g. office:text)
-
isHeaderRoot
Tests if the given element is the start of a header within a page style. The content of a header is equal to the content of a usual ODT text file (ie. invalid input: '<'office:text>).- Returns:
- true if the given element is the root of a header (i.e. style:header)
-
isShapeElement
Tests if the given element is a shape element Shapes are in general those with elements with a- Returns:
- true if the given element is the root of an ODF shape element
-
isWhiteSpaceElement
Tests if the given element is a whitespace element- Returns:
- true if the given element is an ODF whitespace element
-
isCoveredComponentRoot
-
isTextSelection
- Returns:
- true if the node is a text delimiter element
-
getParent
Returns the parent component -
getCorrectStartElementOfChild
public static OdfElement getCorrectStartElementOfChild(OdfElement parentElement, OdfElement existingChildElement) Sometimes (e.g. if the child is a paragraph within list elements). The parent root element of the child component root element will not be directly children. It will be checked if there is a child element or list level 10 has reached. -
getLastChild
-
getOwnerDocument
-
getChildNode
- Returns:
- the child starting from the given position and at cut at the endPosition
-
getChildNode
- Returns:
- the child at the given position
-
get
-
get
protected Component get(org.json.JSONArray position, boolean needParent, boolean needFollowingSibling, int depth) Get descendant component by its relative position to this component. Counting starts with 0.- Parameters:
position- relative position of the desired component relative to the current componentneedParent- if true the parent of the given position is returnedneedFollowingSibling- if true the next sibling of the given position is returned (exclusive to getPositionsFollowingSibling)
-
getNextSiblingOf
Get next sibling component of the given position. Counting start with 0. -
getParentOf
Get parent component of the given position -
getRootComponent
-
getChildren
-
getRootElement
- Returns:
- the root element of the component
-
createChildComponent
Appending a child element to the component -
createChildComponent
public static Component createChildComponent(int position, Component parentComponent, OdfElement newChildElement) Inserts a component at the given position as child- Parameters:
position- of the component, a -1 is going to append the element
-
createComponent
-
addChild
Adds the given component as new child component. No XML elements are being changed!- Parameters:
index- starting with 0 representing the position of the child, if -1 the new child will be appended
-
remove
Only removes from the component list, not from the DOM -
size
public int size()Returns the number of child components -
hasRepeated
public void hasRepeated(boolean hasRepeated) -
hasRepeated
public boolean hasRepeated() -
getPosition
- Returns:
- the position as a slash separated string
-
getPositionString
- Returns:
- the position as a slash separated string
-
indexOf
- Returns:
- the position of the child component c or given Node within the parents children list. Returns -1 if it is not a child.
-
toString
-
getAllStyleGroupingIdProperties
public static Map<String,OdfStylePropertiesSet> getAllStyleGroupingIdProperties(OdfStylableElement styleElement) -
getAllStyleGroupingIdProperties
public static Map<String,OdfStylePropertiesSet> getAllStyleGroupingIdProperties(OdfStyleFamily styleFamily) -
getFamilyID
-
getMainStyleGroupingId
-
getStyleNamePrefix
-
getMainStyleGroupingId
-
getStyleNamePrefix
-
getFamilyID
-
getFamilyDisplayName
-
getFamilyName
- Returns:
- styleFamilyValue the
Stringvalue * * * * * * * ofStyleFamilyAttribute,
-
getFamily
- Returns:
- styleFamily the
OdfStyleFamilyrepresentation * * * ofStyleFamilyAttribute,
-
repetition
public int repetition()A multiple components can be represented by a single XML element- Returns:
- the number of components the elements represents
-