Class Component

java.lang.Object
org.odftoolkit.odfdom.changes.Component
Direct Known Subclasses:
Row, Table, TextContainer

public class Component extends Object
The component is a logical modular entity, to abstract from the implementation details of the XML.
Author:
svante.schubertATgmail.com
  • Field Details

  • Constructor Details

    • Component

      public Component(OdfElement componentElement)
      Only being used to create the root of all components, representing the document without a parent element
    • Component

      protected Component(OdfElement componentElement, Component parent)
  • Method Details

    • isComponentRoot

      public static boolean isComponentRoot(Element element)
      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

      public static boolean isComponentRoot(String uri, String localName)
      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

      public static boolean isComponentWrapper(Element element)
      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

      public static boolean isComponentWrapper(String uri, String localName)
      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

      public static boolean isTextComponentRoot(Node textContainer)
      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

      public static boolean isTextComponentRoot(String uri, String localName)
    • isRowComponentRoot

      public static boolean isRowComponentRoot(Node textContainer)
    • isRowComponentRoot

      public static boolean isRowComponentRoot(String uri, String localName)
    • isField

      public static boolean isField(String uri, String localName)
    • isDocumentRoot

      public static boolean isDocumentRoot(String uri, String localName)
      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

      public static boolean isHeaderRoot(String uri, String localName)
      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. <office:text>).
      Returns:
      true if the given element is the root of a header (i.e. style:header)
    • isFooterRoot

      public static boolean isFooterRoot(String uri, String localName)
      Tests if the given element is the start of a footer within a page style. The content of a footer is equal to the content of a usual ODT text file (ie. <office:text>).
      Returns:
      true if the given element is the root of a footer (i.e. style:footer)
    • isShapeElement

      public static boolean isShapeElement(String uri, String localName)
      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

      public static boolean isWhiteSpaceElement(String uri, String localName)
      Tests if the given element is a whitespace element
      Returns:
      true if the given element is an ODF whitespace element
    • isCoveredComponentRoot

      public static boolean isCoveredComponentRoot(String uri, String localName)
    • isTextSelection

      public static boolean isTextSelection(Node textSelection)
      Returns:
      true if the node is a text delimiter element
    • getParent

      public Component 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

      public Component getLastChild()
    • getOwnerDocument

      public Document getOwnerDocument()
    • getChildNode

      public Node getChildNode(int startPosition, int endPosition)
      Returns:
      the child starting from the given position and at cut at the endPosition
    • getChildNode

      public Node getChildNode(int position)
      Returns:
      the child at the given position
    • get

      public Component get(org.json.JSONArray position)
    • 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 component
      needParent - if true the parent of the given position is returned
      needFollowingSibling - if true the next sibling of the given position is returned (exclusive to getPositionsFollowingSibling)
    • getNextSiblingOf

      public Component getNextSiblingOf(org.json.JSONArray position)
      Get next sibling component of the given position. Counting start with 0.
    • getParentOf

      public Component getParentOf(org.json.JSONArray position)
      Get parent component of the given position
    • getRootComponent

      public Component getRootComponent()
    • getChildren

      public List<Component> getChildren()
    • getRootElement

      public OdfElement getRootElement()
      Returns:
      the root element of the component
    • createChildComponent

      public Component createChildComponent(OdfElement componentRoot)
      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

      public static Component createComponent(Component parentComponent, OdfElement newChildElement)
    • addChild

      public void addChild(int index, Component c)
      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

      public Node remove(int position)
      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

      protected String getPosition(Component c)
      Returns:
      the position as a slash separated string
    • getPositionString

      protected static String getPositionString(Component c)
      Returns:
      the position as a slash separated string
    • indexOf

      public int indexOf(Object o)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAllStyleGroupingIdProperties

      public static Map<String,OdfStylePropertiesSet> getAllStyleGroupingIdProperties(OdfStylableElement styleElement)
    • getAllStyleGroupingIdProperties

      public static Map<String,OdfStylePropertiesSet> getAllStyleGroupingIdProperties(OdfStyleFamily styleFamily)
    • getFamilyID

      public static String getFamilyID(OdfStylableElement styleElement)
    • getMainStyleGroupingId

      public static String getMainStyleGroupingId(OdfStylableElement styleElement)
    • getStyleNamePrefix

      public static String getStyleNamePrefix(OdfStylableElement styleElement)
    • getMainStyleGroupingId

      public static String getMainStyleGroupingId(OdfStyleFamily styleFamily)
    • getStyleNamePrefix

      public static String getStyleNamePrefix(OdfStyleFamily styleFamily)
    • getFamilyID

      public static String getFamilyID(OdfStyleFamily styleFamily)
    • getFamilyDisplayName

      public static String getFamilyDisplayName(OdfStyleFamily styleFamily)
    • getFamilyName

      public static String getFamilyName(String styleId)
      Returns:
      styleFamilyValue the String value * * * * * * * of StyleFamilyAttribute,
    • getFamily

      public static OdfStyleFamily getFamily(String styleId)
      Returns:
      styleFamily the OdfStyleFamily representation * * * of StyleFamilyAttribute,
    • repetition

      public int repetition()
      A multiple components can be represented by a single XML element
      Returns:
      the number of components the elements represents