Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15

:: drafts :: com :: sun :: star :: accessibility ::

interface XAccessibleText
Base Hierarchy
::com::sun::star::uno::XInterface
 |
 +-XAccessibleText
Description
Implement this interface to give read-only access to a text.

The XAccessibleText interface should be implemented by all UNO components that present textual information on the display like buttons, text entry fields, or text portions of the document window. The interface provides access to the text's content, attributes, and spatial location. However, text can not be modified with this interface. That is the task of the XAccessibleEditableText interface.

The text length, i.e. the number of characters in the text, is returned by getCharacterCount . All methods that operate on particular characters (e.g. getCharacterAt ) use character indices from 0 to length-1. All methods that operate on character positions (e.g. getTextRange ) use indices from 0 to length.

Please note that accessible text does not necessarily support selection. In this case it should behave as if there where no selection. An empty selection is used for example to express the current cursor position.


Methods' Summary
getCaretPosition Return the position of the caret.
setCaretPosition Set the position of the caret.
getCharacter Return the character at the specified position.
getCharacterAttributes Get the attribute set for the specified position.
getCharacterBounds Return the bounding box of the specified position.
getCharacterCount Return the number of characters in the represented text.
getIndexAtPoint Return the text position for the specified screen position.
getSelectedText Return the selected text.
getSelectionStart Return the position of the start of the selection.
getSelectionEnd Return the position of the end of the selection.
setSelection Set a new selection.
getText Return the whole text.
getTextRange Return the specified text range.
getTextAtIndex Get a text portion around the given position.
getTextBeforeIndex Get a text portion before the given position.
getTextBehindIndex Get a text portion behind the given position.
copyText Copy the specified text into the clipboard.
Methods' Details
getCaretPosition
long
getCaretPosition();
 
 

Description
Return the position of the caret.

Returns the offset of the caret. The caret is often called text cursor. The caret is actually the position between two characters. Its position/offset is that of the character to the right of it.

Returns
The returned offset is relative to the text represented by this object.
setCaretPosition
boolean
setCaretPosition(
 
[in] long 

raises(

 
nIndex ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Set the position of the caret.

The caret is often called text cursor. The caret is actually the position between two characters. Its position/offset is that of the character to the right of it.

Setting the caret position may or may not alter the current selection. A change of the selection is notified to the accessibility event listeners with an AccessibleEventId::ACCESSIBLE_SELECTION_EVENT .

When the new caret position differs from the old one (which, of course, is the standard case) this is notified to the accessibility event listeners with an AccessibleEventId::ACCESSIBLE_CARET_EVENT .

Parameter nIndex
The new index of the caret. This caret is actually placed to the left side of the character with that index. An index of 0 places the caret so that the next insertion goes before the first character. An index of getCharacterCount leads to insertion after the last character.
Returns
Returns true if the caret has been moved and false otherwise. A true value does not necessarily mean that the caret has been positioned exactly at the required position. If that position lies inside a read-only area the caret is positioned before or behind it. Listen to the caret event to determine the new position.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the index is not valid.
getCharacter
char
getCharacter(
 
[in] long 

raises(

 
nIndex ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Return the character at the specified position.

Returns the character at the given index.

Parameter nIndex
The index of the character to return. The valid range is 0..length-1.
Returns
the character at the index nIndex.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the index is invalid
getCharacterAttributes
sequence< ::com::sun::star::beans::PropertyValue >
getCharacterAttributes(
 
[in] long 

raises(

 
nIndex ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Get the attribute set for the specified position.

Returns the attribute set for the character at the given index.

Parameter nIndex
The index of the character for which to return its attributes. The valid range is 0..length-1.
Returns
Returns the requested attributes of the specified character. Each attribute is represented by a ::com::sun::star::beans::::PropertyValue object.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the index is invalid
getCharacterBounds
::com::sun::star::awt::Rectangle
getCharacterBounds(
 
[in] long 

raises(

 
nIndex ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Return the bounding box of the specified position.

Returns the bounding box of the indexed character.

Parameter nIndex
Index of the character for which to return its bounding box. The valid range is 0..length-1.
Returns
The bounding box of the referenced character.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the index is invalid
getCharacterCount
long
getCharacterCount();
 
 

Description
Return the number of characters in the represented text.

Returns the number of characters in the text represented by this object or, in other words, the text length.

Returns
Returns the number of characters of this object's text. A zero value indicates an empty text.
getIndexAtPoint
long
getIndexAtPoint(
 
[in] ::com::sun::star::awt::Point
 
aPoint );

Description
Return the text position for the specified screen position.

Given a point in local coordinates, i.e. relative to the coordinate system of the object, return the zero-based index of the character under that point. The same functionality could be achieved by using the bounding boxes for each character as returned by XAccessibleText::getCharacterBounds . The method XAccessibleText::getIndexAtPoint , however, can be implemented in a more efficient way.

Parameter aPoint
The position for which to look up the index of the character that is rendered on to the display at that point.
Returns
Index of the character under the given point or -1 if the point is invalid or there is no character under the point.
getSelectedText
string
getSelectedText();
 
 

Description
Return the selected text.

Returns the portion of the text that is selected.

Returns
The returned text is the selected portion of the object's text. If no text is selected when this method is called or when selection is not supported an empty string is returned.
getSelectionStart
long
getSelectionStart();
 
 

Description
Return the position of the start of the selection.

Returns the index of the start of the selected text.

Returns
If there is no selection or selection is not supported the position of selection start and end will be the same undefined value.
getSelectionEnd
long
getSelectionEnd();
 
 

Description
Return the position of the end of the selection.

Returns the index of the end of the selected text.

Returns
If there is no selection or selection is not supported the position of selection start and end will be the same undefined value.
setSelection
boolean
setSelection(
 
[in] long
[in] long 

raises(

 
nStartIndex,
nEndIndex ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Set a new selection.

Sets the selected text portion according to the given indices. The old selection is replaced by the new selection.

The selection encompasses the same string of text that XAccessibleText::getTextRange would have selected. See there for details.

Setting the selection may or may not change the caret position. Typically the caret is moved to the position after the second argument. When the caret is moved this is notified to the accessibility event listeners with an AccessibleEventId::ACCESSIBLE_CARET_EVENT .

Parameter nStartIndex
The first character of the new selection. The valid range is 0..length. @parm nEndIndex The position after the last character of the new selection. The valid range is 0..length.
Returns
Returns true if the selection has been set successfully and false otherwise or when selection is not supported.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the indices are invalid
getText
string
getText();
 
 

Description
Return the whole text.

Returns the complete text. This is equivalent to a call to XAccessibleText::getTextRange with the arguments zero and getCharacterCount()-1 .

Returns
Returns a string that contains the complete text.
getTextRange
string
getTextRange(
 
[in] long
[in] long 

raises(

 
nStartIndex,
nEndIndex ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Return the specified text range.

Returns the substring between the two given indices.

The substring starts with the character at nStartIndex (inclusive) and up to the character at nEndIndex (exclusive), if nStartIndex is less or equal nEndIndex. If nEndIndex is lower than nStartIndex, the result is the same as a call with the two arguments being exchanged.

The whole text can be requested by passing the indices zero and getCharacterCount() . If both indices have the same value, an empty string is returned.

Parameter nStartIndex
Index of the first character to include in the returned string. The valid range is 0..length.
Parameter nEndIndex
Index of the last character to exclude in the returned string. The valid range is 0..length.
Returns
Returns the substring starting with the character at nStartIndex (inclusive) and up to the character at nEndIndex (exclusive), if nStartIndex is less or equal nEndIndex. If nEndIndex is lower than nStartIndex, the result is the same that a call with the two arguments being exchanges.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the indices are invalid
getTextAtIndex
string
getTextAtIndex(
 
[in] long
[in] short 

raises(

 
nIndex,
aTextType ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Get a text portion around the given position.

Returns the substring of the specified text type that contains the character at the given index, if any. For example, given the text type word, the word which contains the character at position nIndex is returned, or an empty string if no word is found at the that position.

Parameter nIndex
Index of the character whose containing text portion is to be returned. The valid range is 0..length. For the last index, an empty string must be returned.
Parameter aTextType
The type of the text portion to return. See AccessibleTextType for the complete list.
Returns
Returns the requested text portion or an empty string if the text type is invalid, or if no text portion of the given is found at the given position.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the index is invalid
getTextBeforeIndex
string
getTextBeforeIndex(
 
[in] long
[in] short 

raises(

 
nIndex,
aTextType ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Get a text portion before the given position.

Returns the substring of the specified text type that is located before the given character and does not include it. The result of this method should be same as a result for XAccessibleText::getTextAtIndex with a suitably decreased index value.

For example, if text type is word, then the complete word that is closest to and located before nIndex is returned.

If the index is valid, but no suitable word (or other text type) is found, an empty string is returned.

Parameter nIndex
Index of the character for which to return the text part before it. The index character will not be part of the returned string. The valid range is 0..length.
Parameter aTextType
The type of the text portion to return. See AccessibleTextType for the complete list.
Returns
Returns the requested text portion or an empty string if the text type is invalid or no appropriate text portion is found.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the index is invalid
getTextBehindIndex
string
getTextBehindIndex(
 
[in] long
[in] short 

raises(

 
nIndex,
aTextType ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Get a text portion behind the given position.

Returns the substring of the specified text type that is located after the given character and does not include it. The result of this method should be same as a result for XAccessibleText::getTextAtIndex with a suitably increased index value.

For example, if text type is word, then the complete word that is closest to and located behind nIndex is returned.

If the index is valid, but no suitable word (or other text type) is found, an empty string is returned.

Parameter nIndex
Index of the character for which to return the text part after it. The index character will be part of the returned string. The valid range is 0..length. For the last index, an empty string must be returned.
Parameter aTextType
The type of the text portion to return. See AccessibleTextType for the complete list.
Returns
Returns the requested text portion or an empty string if the text type is invalid or no appropriate text portion is found.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the index is invalid
copyText
boolean
copyText(
 
[in] long
[in] long 

raises(

 
nStartIndex,
nEndIndex ) 
::com::sun::star::lang::IndexOutOfBoundsException );

Description
Copy the specified text into the clipboard.

Copy the specified text into the clipboard. The text that is copied is the same text that would have been selected by the XAccessibleText::getTextRange method.

The other clipboard related methods XAccessibleEditableText::cutText and XAccessibleEditableText::deleteText can be found in the XAccessibleEditableText because of their destructive nature.

Parameter nStartIndex
Start index of the text to copied into the clipboard. The valid range is 0..length.
Parameter nEndIndex
End index of the text to copied into the clipboard. The valid range is 0..length.
Returns
Returns true if the specified text has been copied successfully into the clipboard.
Throws
::com::sun::star::lang::IndexOutOfBoundsException if the indices are invalid
Top of Page

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.