Class TextSelection
java.lang.Object
org.odftoolkit.odfdom.incubator.search.Selection
org.odftoolkit.odfdom.incubator.search.TextSelection
A TextSelection can describe a sub element in a mParagraph element or a mHeading element. it is
recognized by the container element(which type should be OdfTextParagraph or OdfTextHeadingt),
the start index of the text content of the container element and the text content of this
selection.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a hypertext reference to the selectionvoid
applyStyle
(OdfStyleBase style) Apply a style to the selection so that the text style of this selection will append the specified stylevoid
cut()
Delete the selection from the document the other matched selection in the same container element will be updated automatically because the start index of the following selections will be changed when the previous selection has been deletedGet the mParagraph element or mHeading element that contain this textGet the mParagraph element or mHeading element that contain this TextSelectionint
getIndex()
Get the start index of the text content of its container elementgetText()
Get the text content of this TextSelectionvoid
pasteAtEndOf
(Selection positionItem) Paste this selection just after a specific selection.void
pasteAtFrontOf
(Selection positionItem) Paste this selection just before a specific selection.protected void
refresh
(int offset) A quick method to update the mIndex of this selectionprotected void
refreshAfterFrontalDelete
(Selection deleteItem) when a selected item has been delete, the selections after this deleted selection should be refresh because these selections mIndex will be changedprotected void
refreshAfterFrontalInsert
(Selection pasteItem) when a selected item has been inserted, the selection after the inserted item should be refresh because these selections mIndex will be changedvoid
replaceWith
(String newText) Replace the text content of selection with a new stringtoString()
return a String Object representing this selection value the text content of the selection, start index in the container element and the text content of the container element will be provided
-
Method Details
-
getElement
Get the mParagraph element or mHeading element that contain this TextSelection- Overrides:
getElement
in classSelection
- Returns:
- OdfElement the container element
-
getContainerElement
Get the mParagraph element or mHeading element that contain this text- Returns:
- OdfElement
-
getIndex
public int getIndex()Get the start index of the text content of its container element -
getText
Get the text content of this TextSelection- Returns:
- text the text content
-
cut
Delete the selection from the document the other matched selection in the same container element will be updated automatically because the start index of the following selections will be changed when the previous selection has been deleted- Specified by:
cut
in classSelection
- Throws:
InvalidNavigationException
- if the selection is unavailable.
-
applyStyle
Apply a style to the selection so that the text style of this selection will append the specified style- Parameters:
style
- the style can be from the current document or user defined- Throws:
InvalidNavigationException
- if the selection is unavailable.
-
replaceWith
Replace the text content of selection with a new string- Parameters:
newText
- the replace text String- Throws:
InvalidNavigationException
- if the selection is unavailable.
-
pasteAtFrontOf
Paste this selection just before a specific selection.- Specified by:
pasteAtFrontOf
in classSelection
- Parameters:
positionItem
- a selection that is used to point out the position- Throws:
InvalidNavigationException
- if the selection is unavailable.
-
pasteAtEndOf
Paste this selection just after a specific selection.- Specified by:
pasteAtEndOf
in classSelection
- Parameters:
positionItem
- a selection that is used to point out the position- Throws:
InvalidNavigationException
- if the selection is unavailable.
-
addHref
Add a hypertext reference to the selection- Parameters:
url
- the url of the hypertext reference- Throws:
InvalidNavigationException
- if the selection is unavailable.
-
refreshAfterFrontalDelete
Description copied from class:Selection
when a selected item has been delete, the selections after this deleted selection should be refresh because these selections mIndex will be changed- Specified by:
refreshAfterFrontalDelete
in classSelection
- Parameters:
deleteItem
- the deleted selection
-
refreshAfterFrontalInsert
Description copied from class:Selection
when a selected item has been inserted, the selection after the inserted item should be refresh because these selections mIndex will be changed- Specified by:
refreshAfterFrontalInsert
in classSelection
- Parameters:
pasteItem
- the inserted selection
-
refresh
protected void refresh(int offset) Description copied from class:Selection
A quick method to update the mIndex of this selection -
toString
return a String Object representing this selection value the text content of the selection, start index in the container element and the text content of the container element will be provided
-