Class OdfElement

All Implemented Interfaces:
Serializable, Cloneable, Element, ElementTraversal, EventTarget, Node, NodeList, TypeInfo
Direct Known Subclasses:
AlgorithmElement, AnimAnimateColorElement, AnimAnimateElement, AnimAnimateMotionElement, AnimAnimateTransformElement, AnimAudioElement, AnimCommandElement, AnimIterateElement, AnimParamElement, AnimParElement, AnimSeqElement, AnimSetElement, AnimTransitionFilterElement, ChartCategoriesElement, ChartDataLabelElement, ChartDomainElement, ChartEquationElement, ChartLabelSeparatorElement, ChartSymbolImageElement, ConfigConfigItemElement, ConfigConfigItemMapEntryElement, ConfigConfigItemMapIndexedElement, ConfigConfigItemMapNamedElement, ConfigConfigItemSetElement, DataStyleElement, DbApplicationConnectionSettingsElement, DbAutoIncrementElement, DbCharacterSetElement, DbColumnDefinitionElement, DbColumnDefinitionsElement, DbColumnElement, DbColumnsElement, DbComponentCollectionElement, DbComponentElement, DbConnectionDataElement, DbConnectionResourceElement, DbDatabaseDescriptionElement, DbDataSourceElement, DbDataSourceSettingElement, DbDataSourceSettingsElement, DbDataSourceSettingValueElement, DbDelimiterElement, DbDriverSettingsElement, DbFileBasedDatabaseElement, DbFilterStatementElement, DbFormsElement, DbIndexColumnElement, DbIndexColumnsElement, DbIndexElement, DbIndicesElement, DbKeyColumnElement, DbKeyColumnsElement, DbKeyElement, DbKeysElement, DbLoginElement, DbOrderStatementElement, DbQueriesElement, DbQueryCollectionElement, DbQueryElement, DbReportsElement, DbSchemaDefinitionElement, DbServerDatabaseElement, DbTableDefinitionElement, DbTableDefinitionsElement, DbTableExcludeFilterElement, DbTableFilterElement, DbTableFilterPatternElement, DbTableIncludeFilterElement, DbTableRepresentationElement, DbTableRepresentationsElement, DbTableSettingElement, DbTableSettingsElement, DbTableTypeElement, DbTableTypeFilterElement, DbUpdateTableElement, DcCreatorElement, DcDateElement, DcDescriptionElement, DcLanguageElement, DcSubjectElement, DcTitleElement, DocumentSignaturesElement, Dr3dLightElement, DrawAElement, DrawAppletElement, DrawAreaCircleElement, DrawAreaPolygonElement, DrawAreaRectangleElement, DrawContourPathElement, DrawContourPolygonElement, DrawEnhancedGeometryElement, DrawEquationElement, DrawFillImageElement, DrawFloatingFrameElement, DrawGluePointElement, DrawGradientElement, DrawHandleElement, DrawHatchElement, DrawImageElement, DrawImageMapElement, DrawLayerElement, DrawLayerSetElement, DrawMarkerElement, DrawObjectElement, DrawObjectOleElement, DrawOpacityElement, DrawParamElement, DrawPluginElement, DrawStrokeDashElement, DrawTextBoxElement, EncryptionDataElement, FileEntryElement, FormButtonElement, FormCheckboxElement, FormColumnElement, FormComboboxElement, FormConnectionResourceElement, FormDateElement, FormFileElement, FormFixedTextElement, FormFormattedTextElement, FormFormElement, FormFrameElement, FormGenericControlElement, FormGridElement, FormHiddenElement, FormImageElement, FormImageFrameElement, FormItemElement, FormListboxElement, FormListPropertyElement, FormListValueElement, FormNumberElement, FormOptionElement, FormPasswordElement, FormPropertiesElement, FormPropertyElement, FormRadioElement, FormTextareaElement, FormTextElement, FormTimeElement, FormValueRangeElement, KeyDerivationElement, ManifestElement, MathMathElement, MetaAutoReloadElement, MetaCreationDateElement, MetaDateStringElement, MetaDocumentStatisticElement, MetaEditingCyclesElement, MetaEditingDurationElement, MetaGeneratorElement, MetaHyperlinkBehaviourElement, MetaInitialCreatorElement, MetaKeywordElement, MetaPrintDateElement, MetaPrintedByElement, MetaTemplateElement, MetaUserDefinedElement, NumberAmPmElement, NumberBooleanElement, NumberCurrencySymbolElement, NumberDayElement, NumberDayOfWeekElement, NumberEmbeddedTextElement, NumberEraElement, NumberFractionElement, NumberHoursElement, NumberMinutesElement, NumberMonthElement, NumberNumberElement, NumberQuarterElement, NumberScientificNumberElement, NumberSecondsElement, NumberTextContentElement, NumberTextElement, NumberWeekOfYearElement, NumberYearElement, OdfAlienElement, OdfContainerElementBase, OdfStylableElement, OdfStylePropertiesBase, OfficeAnnotationEndElement, OfficeBinaryDataElement, OfficeBodyElement, OfficeChangeInfoElement, OfficeChartElement, OfficeDatabaseElement, OfficeDdeSourceElement, OfficeDocumentContentElement, OfficeDocumentElement, OfficeDocumentMetaElement, OfficeDocumentSettingsElement, OfficeDocumentStylesElement, OfficeDrawingElement, OfficeEventListenersElement, OfficeFontFaceDeclsElement, OfficeFormsElement, OfficeImageElement, OfficeMetaElement, OfficePresentationElement, OfficeScriptElement, OfficeScriptsElement, OfficeSettingsElement, OfficeSpreadsheetElement, OfficeTextElement, PresentationAnimationGroupElement, PresentationAnimationsElement, PresentationDateTimeDeclElement, PresentationDateTimeElement, PresentationDimElement, PresentationEventListenerElement, PresentationFooterDeclElement, PresentationFooterElement, PresentationHeaderDeclElement, PresentationHeaderElement, PresentationHideShapeElement, PresentationHideTextElement, PresentationPlaceholderElement, PresentationPlayElement, PresentationSettingsElement, PresentationShowElement, PresentationShowShapeElement, PresentationShowTextElement, PresentationSoundElement, ScriptEventListenerElement, SignatureElement, StartKeyGenerationElement, StyleBackgroundImageElement, StyleColumnElement, StyleColumnsElement, StyleColumnSepElement, StyleDefaultPageLayoutElement, StyleFontFaceElement, StyleFooterElement, StyleFooterLeftElement, StyleFooterStyleElement, StyleFootnoteSepElement, StyleHeaderElement, StyleHeaderLeftElement, StyleHeaderStyleElement, StyleListLevelLabelAlignmentElement, StyleMapElement, StylePresentationPageLayoutElement, StyleRegionCenterElement, StyleRegionLeftElement, StyleRegionRightElement, StyleTabStopElement, StyleTabStopsElement, SvgDefinitionSrcElement, SvgDescElement, SvgFontFaceFormatElement, SvgFontFaceNameElement, SvgFontFaceSrcElement, SvgFontFaceUriElement, SvgLinearGradientElement, SvgRadialGradientElement, SvgStopElement, SvgTitleElement, TableBackgroundElement, TableCalculationSettingsElement, TableCellAddressElement, TableCellContentChangeElement, TableCellContentDeletionElement, TableCellRangeSourceElement, TableChangeDeletionElement, TableChangeTrackTableCellElement, TableConsolidationElement, TableContentValidationElement, TableContentValidationsElement, TableCutOffsElement, TableDatabaseRangeElement, TableDatabaseRangesElement, TableDatabaseSourceQueryElement, TableDatabaseSourceSqlElement, TableDatabaseSourceTableElement, TableDataPilotDisplayInfoElement, TableDataPilotFieldElement, TableDataPilotFieldReferenceElement, TableDataPilotGroupElement, TableDataPilotGroupMemberElement, TableDataPilotGroupsElement, TableDataPilotLayoutInfoElement, TableDataPilotLevelElement, TableDataPilotMemberElement, TableDataPilotMembersElement, TableDataPilotSortInfoElement, TableDataPilotSubtotalElement, TableDataPilotSubtotalsElement, TableDataPilotTableElement, TableDataPilotTablesElement, TableDdeLinkElement, TableDdeLinksElement, TableDeletionElement, TableDeletionsElement, TableDependenciesElement, TableDependencyElement, TableDescElement, TableDetectiveElement, TableErrorMacroElement, TableErrorMessageElement, TableFilterAndElement, TableFilterConditionElement, TableFilterElement, TableFilterOrElement, TableFilterSetItemElement, TableHelpMessageElement, TableHighlightedRangeElement, TableInsertionCutOffElement, TableInsertionElement, TableIterationElement, TableLabelRangeElement, TableLabelRangesElement, TableMovementCutOffElement, TableMovementElement, TableNamedExpressionElement, TableNamedExpressionsElement, TableNamedRangeElement, TableNullDateElement, TableOperationElement, TablePreviousElement, TableScenarioElement, TableShapesElement, TableSortByElement, TableSortElement, TableSortGroupsElement, TableSourceCellRangeElement, TableSourceRangeAddressElement, TableSourceServiceElement, TableSubtotalFieldElement, TableSubtotalRuleElement, TableSubtotalRulesElement, TableTableColumnGroupElement, TableTableColumnsElement, TableTableHeaderColumnsElement, TableTableHeaderRowsElement, TableTableRowGroupElement, TableTableRowsElement, TableTableSourceElement, TableTableTemplateElement, TableTargetRangeAddressElement, TableTitleElement, TableTrackedChangesElement, TextAlphabeticalIndexAutoMarkFileElement, TextAlphabeticalIndexMarkElement, TextAlphabeticalIndexMarkEndElement, TextAlphabeticalIndexMarkStartElement, TextAlphabeticalIndexSourceElement, TextAuthorInitialsElement, TextAuthorNameElement, TextBibliographyConfigurationElement, TextBibliographyMarkElement, TextBibliographySourceElement, TextBookmarkElement, TextBookmarkEndElement, TextBookmarkRefElement, TextBookmarkStartElement, TextChangedRegionElement, TextChangeElement, TextChangeEndElement, TextChangeStartElement, TextChapterElement, TextCharacterCountElement, TextConditionalTextElement, TextCreationDateElement, TextCreationTimeElement, TextCreatorElement, TextDatabaseDisplayElement, TextDatabaseNameElement, TextDatabaseNextElement, TextDatabaseRowNumberElement, TextDatabaseRowSelectElement, TextDateElement, TextDdeConnectionDeclElement, TextDdeConnectionDeclsElement, TextDdeConnectionElement, TextDeletionElement, TextDescriptionElement, TextEditingCyclesElement, TextEditingDurationElement, TextExecuteMacroElement, TextExpressionElement, TextFileNameElement, TextFormatChangeElement, TextHiddenParagraphElement, TextHiddenTextElement, TextIllustrationIndexSourceElement, TextImageCountElement, TextIndexBodyElement, TextIndexSourceStylesElement, TextInitialCreatorElement, TextInsertionElement, TextKeywordsElement, TextLineBreakElement, TextLinenumberingSeparatorElement, TextListElement, TextListHeaderElement, TextListItemElement, TextMeasureElement, TextMetaElement, TextMetaFieldElement, TextModificationDateElement, TextModificationTimeElement, TextNoteBodyElement, TextNoteCitationElement, TextNoteContinuationNoticeBackwardElement, TextNoteContinuationNoticeForwardElement, TextNoteElement, TextNoteRefElement, TextNotesConfigurationElement, TextNumberElement, TextObjectCountElement, TextObjectIndexSourceElement, TextOutlineStyleElement, TextPageContinuationElement, TextPageCountElement, TextPageElement, TextPageNumberElement, TextPageSequenceElement, TextPageVariableGetElement, TextPageVariableSetElement, TextParagraphCountElement, TextPlaceholderElement, TextPrintDateElement, TextPrintedByElement, TextPrintTimeElement, TextReferenceMarkElement, TextReferenceMarkEndElement, TextReferenceMarkStartElement, TextReferenceRefElement, TextRubyBaseElement, TextScriptElement, TextSectionSourceElement, TextSElement, TextSenderCityElement, TextSenderCompanyElement, TextSenderCountryElement, TextSenderEmailElement, TextSenderFaxElement, TextSenderFirstnameElement, TextSenderInitialsElement, TextSenderLastnameElement, TextSenderPhonePrivateElement, TextSenderPhoneWorkElement, TextSenderPositionElement, TextSenderPostalCodeElement, TextSenderStateOrProvinceElement, TextSenderStreetElement, TextSenderTitleElement, TextSequenceDeclElement, TextSequenceDeclsElement, TextSequenceElement, TextSequenceRefElement, TextSheetNameElement, TextSoftPageBreakElement, TextSortKeyElement, TextSubjectElement, TextTabElement, TextTableCountElement, TextTableFormulaElement, TextTableIndexSourceElement, TextTableOfContentSourceElement, TextTemplateNameElement, TextTextInputElement, TextTimeElement, TextTitleElement, TextTocMarkElement, TextTocMarkEndElement, TextTocMarkStartElement, TextTrackedChangesElement, TextUserDefinedElement, TextUserFieldDeclElement, TextUserFieldDeclsElement, TextUserFieldGetElement, TextUserFieldInputElement, TextUserIndexMarkElement, TextUserIndexMarkEndElement, TextUserIndexMarkStartElement, TextUserIndexSourceElement, TextVariableDeclElement, TextVariableDeclsElement, TextVariableGetElement, TextVariableInputElement, TextVariableSetElement, TextWordCountElement, XformsModelElement

public abstract class OdfElement extends ElementNSImpl
See Also:
  • Constructor Details

  • Method Details

    • getOdfName

      public abstract OdfName getOdfName()
    • getParentAs

      protected <T extends OdfElement> T getParentAs(Class<T> clazz)
    • getAncestorAs

      protected <T extends OdfElement> T getAncestorAs(Class<T> clazz)
    • hasAncestor

      public boolean hasAncestor(Node potentialParent)
    • toString

      public String toString()
      Overrides:
      toString in class NodeImpl
    • setOdfAttributeValue

      public void setOdfAttributeValue(OdfName name, String value)
      Set the value of an ODF attribute by OdfName.
      Parameters:
      name - The qualified name of the ODF attribute.
      value - The value to be set in String form
    • setOdfAttribute

      public void setOdfAttribute(OdfAttribute attribute)
      Set an ODF attribute to this element
      Parameters:
      attribute - the attribute to be set
    • setOdfAttribute

      public void setOdfAttribute(String name, String value)
      Set an ODF attribute to this element
      Parameters:
      name - name of the attribute to be set
      value -
    • getOdfAttributeValue

      public String getOdfAttributeValue(OdfName name)
      Retrieves a value of an ODF attribute by OdfName.
      Parameters:
      name - The qualified name of the ODF attribute.
      Returns:
      The value of the attribute as String or null if the attribute does not exist.
    • getOdfAttribute

      public OdfAttribute getOdfAttribute(OdfName name)
      Retrieves an ODF attribute by OdfName.
      Parameters:
      name - The qualified name of the ODF attribute.
      Returns:
      The OdfAttribute or null if the attribute does not exist.
    • getOdfAttribute

      public OdfAttribute getOdfAttribute(NamespaceName namespace, String localname)
      Retrieves an ODF attribute by NamespaceName, and local name.
      Parameters:
      namespace - The namespace of the ODF attribute.
      localname - The local name of the ODF attribute.
      Returns:
      The OdfAttribute or null if the attribute does not exist.
    • getOdfAttribute

      public OdfAttribute getOdfAttribute(String localname)
      Retrieves an ODF attribute by local name.
      Parameters:
      localname - The local name of the ODF attribute.
      Returns:
      The OdfAttribute or null if the attribute does not exist.
    • hasOdfAttribute

      public boolean hasOdfAttribute(OdfName name)
      Determines if an ODF attribute exists.
      Parameters:
      name - The qualified name of the ODF attribute.
      Returns:
      True if the attribute exists.
    • findFirstChildNode

      public static <T extends OdfElement> T findFirstChildNode(Class<T> clazz, Node parentNode)
      returns the first child node that implements the given class.
      Type Parameters:
      T - The type of the ODF element to be found.
      Parameters:
      clazz - is a class that extends OdfElement.
      parentNode - is the parent O of the children to be found.
      Returns:
      the first child node of the given parentNode that is a clazz or null if none is found.
    • findNextChildNode

      public static <T extends OdfElement> T findNextChildNode(Class<T> clazz, Node refNode)
      returns the first sibling after the given reference node that implements the given class.
      Type Parameters:
      T - The type of the ODF element to be found.
      Parameters:
      clazz - is a class that extends OdfElement.
      refNode - the reference node of the siblings to be found.
      Returns:
      the first sibling of the given reference node that is a class or null if none is found.
    • findPreviousChildNode

      public static <T extends OdfElement> T findPreviousChildNode(Class<T> clazz, Node refNode)
      returns the first previous sibling before the given reference node that implements the given class.
      Parameters:
      clazz - is a class that extends OdfElement.
      refNode - the reference node which siblings are to be searched.
      Returns:
      the first previous sibling of the given reference node that is a class or null if none is found.
    • cloneElement

      public OdfElement cloneElement()
      Clones this complete element with all descendants.
      Returns:
      the cloned element
    • cloneOdfElement

      protected OdfElement cloneOdfElement()
      Overwritten by AlienElement class, which represents XML elements of various names
    • cloneNode

      public Node cloneNode(boolean deep)
      Specified by:
      cloneNode in interface Node
      Overrides:
      cloneNode in class ElementImpl
    • cloneNode

      public Node cloneNode(int depth)
      Parameters:
      depth - how many levels of children should be considered
      Returns:
      the cloned node (element)
    • cloneNode

      public static OdfElement cloneNode(OdfElement source, OdfElement target, boolean deep)
      Clones the content of the source element including attributes even xml:id to the target element. Helpful when changing a <text:h> to a <text:p> and vice versa, when outline attribute changes.
      Parameters:
      source - the element to copy the content & attributes from.
      target - the element to copy the content & attributes into.
      deep - if a deep copy should happen. If false only the source element attributes will be copied, otherwise all descendants.
      Returns:
      the target element with all new nodes
    • appendChild

      public Node appendChild(Node node)
      Specified by:
      appendChild in interface Node
      Overrides:
      appendChild in class NodeImpl
    • componentSize

      public int componentSize()
      Recursive traverse the text container and count the size of the content
    • equals

      public boolean equals(Object obj)
      indicates if some other object is equal to this one.
      Overrides:
      equals in class Object
      Parameters:
      obj - - the reference object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • onRemoveNode

      protected void onRemoveNode(Node node)
    • onInsertNode

      protected void onInsertNode(Node node)
    • onRemoveNode

      protected void onRemoveNode()
    • onInsertNode

      protected void onInsertNode()
    • insertBefore

      public Node insertBefore(Node newChild, Node refChild) throws DOMException
      Specified by:
      insertBefore in interface Node
      Overrides:
      insertBefore in class ParentNode
      Throws:
      DOMException
    • removeSingleElement

      public static Element removeSingleElement(Element oldElement) throws DOMException
      Throws:
      DOMException
    • removeChild

      public Node removeChild(Node oldChild) throws DOMException
      Specified by:
      removeChild in interface Node
      Overrides:
      removeChild in class ParentNode
      Throws:
      DOMException
    • isRepeatable

      public boolean isRepeatable()
      Returns:
      true if the element does represent multiple instances. (only applicable for some elements as cell or row).
    • getRepetition

      public int getRepetition()
      Returns:
      the repetition the element represents, by default it is 1
    • removeContent

      public void removeContent()
      Removes all the content from the element
    • replaceChild

      public Node replaceChild(Node newChild, Node oldChild) throws DOMException
      Specified by:
      replaceChild in interface Node
      Overrides:
      replaceChild in class ParentNode
      Throws:
      DOMException
    • accept

      public void accept(ElementVisitor visitor)
      Accept an visitor instance to allow the visitor to do some operations. Refer to visitor design pattern to get a better understanding.
      Parameters:
      visitor - an instance of DefaultElementVisitor
    • getComponentRoot

      public OdfElement getComponentRoot()
      Returns the component reference
    • markAsComponentRoot

      public void markAsComponentRoot(boolean isRoot)
    • getComponent

      public Component getComponent()
    • setComponent

      public void setComponent(Component component)
    • isComponentRoot

      public boolean isComponentRoot()
    • selfAndDescendantTextIgnoredAsComponent

      public boolean selfAndDescendantTextIgnoredAsComponent()
      Returns:
      true if the text should not count as for component path nor the element root itself. This might occur for nested paragraphs or ignored text element (e.g. text:note-citation).
    • ignoredComponent

      public void ignoredComponent(boolean isIngoredComponent)
      Parameters:
      isIngoredComponent - true if the text should not count as for component path nor the element root itself. This might occur for nested paragraphs or ignored text element (e.g. text:note-citation). For instance called by a SAX Component parser, * * * * * * * see org.odftoolkit.odfdom.component.OdfFileSaxHandler
    • appendUsingWhitespaceHandling

      protected static void appendUsingWhitespaceHandling(Node precedingNode, OdfElement parent, Node followingNode, String newString)
      If the string is inserted into a text:p/text:h element and it will be inserted in the start/end all spaces are replaced by <text:s/> element(s). tabulator and linefeeds are being removed.

      If both the previous text node ends with a space and newString starts with a space, we would need to encode the single leading space as an element, otherwise it would be stripped. Same occurs for the next text node and an ending space. For Example: text <text:s c="7"/> text2 <== SAVE when starting ending a span as well with space element independent of preceding

    • split

      public OdfElement split(int posStart)
      Splitting the element at the given position into two halves
      Parameters:
      posStart - The logical position of the first character (or other paragraph child component) that will be moved to the beginning of the new paragraph. Counting starts with 0.
      Returns:
      the new created second text container
    • receiveNode

      public Node receiveNode(int textPosStart)
      Receives node from this text container element.
      Parameters:
      textPosStart - The start delimiter for the child
      Returns:
      the child node might be text or element
    • receiveNode

      public Node receiveNode(int textPosStart, int textPosEnd)
      Receives node from this text container element.
      Parameters:
      textPosStart - The start delimiter for the child
      Returns:
      the child node might be text or element
    • markText

      public void markText(int textPosStart, int textPosEnd, org.json.JSONObject formatChanges)
      Parameters:
      textPosStart - the first text level component to be marked, start counting with 0
      textPosEnd - the last text level component to be marked, start counting with 0
      formatChanges - the changes to be applied to the text
    • countDescendantComponents

      public int countDescendantComponents()
      Counts the number of descendant components
    • countChildComponents

      public int countChildComponents(Boolean hasTextComponents)
      Counts the number of child components
    • moveChildrenTo

      public void moveChildrenTo(Element newParent)
    • insert

      public void insert(String newString, int textPosStart)
      Insert text to a certain position. The text will be appended to the previous position text, so the span of the previous character will be expanded
      Parameters:
      newString - string to be inserted
      textPosStart - text index of the new string
    • insert

      public void insert(Node newNode, int textPosStart)
    • delete

      public void delete(int textPosStart, int textPosEnd)
      Deletes text from this paragraph element.
      Parameters:
      textPosStart - Counting starts with 0, which is the first character of the paragraph.
      textPosEnd - The end delimiter for the deletion. To delete text to the end of the paragraph, as represent for the end of the paragraph Integer.MAX_VALUE can be used.
    • copyAttributes

      public static void copyAttributes(OdfElement from, OdfElement to)
      Copy attributes from one element to another, existing attributes will be overwritten
    • getChildElement

      public Element getChildElement(String uri, String localName)
      Returns:
      the first child element of a given parent
    • getChildElement

      public Element getChildElement(String uri, String localName, int position)
      Returns:
      the child element of a given parent from a given position (starting with 0)
    • isIgnoredElement

      public static boolean isIgnoredElement(Element element)
    • isIgnoredElement

      public static boolean isIgnoredElement(String uri, String localName)
      ToDo: Move away to parser, as it is application logic not ODF relevant! Elements that blocks the creation of operations due to implementation issues
    • getNextSiblingElement

      public static OdfElement getNextSiblingElement(Node node)
    • getPreviousSiblingElement

      public static OdfElement getPreviousSiblingElement(Node node)
    • getFirstChildElement

      public OdfElement getFirstChildElement()
    • getLastChildElement

      public OdfElement getLastChildElement()
    • countPrecedingSiblingElements

      public int countPrecedingSiblingElements()
    • setRepetition

      public void setRepetition(int repetition)
    • getTextContent

      public String getTextContent()
      Specified by:
      getTextContent in interface Node
      Overrides:
      getTextContent in class ParentNode
      Returns:
      the concatenated text contained by itself and all descendants (subtree). Does not take into account indented XML, as ODF whitespace handling require to neglect preceeding text content