1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef __com_sun_star_accessibility_XAccessibleText_idl__
29 #define __com_sun_star_accessibility_XAccessibleText_idl__
31 #ifndef __com_sun_star_accessibility_AccessibleTextType_idl__
32 #include
<com
/sun
/star
/accessibility
/AccessibleTextType.idl
>
35 #ifndef __com_sun_star_uno_XInterface_idl__
36 #include
<com
/sun
/star
/uno
/XInterface.idl
>
38 #ifndef __com_sun_star_awt_Point_idl__
39 #include
<com
/sun
/star
/awt
/Point.idl
>
41 #ifndef __com_sun_star_awt_Rectangle_idl__
42 #include
<com
/sun
/star
/awt
/Rectangle.idl
>
44 #ifndef __com_sun_star_lang_IndexOutOfBoundsException_idl__
45 #include
<com
/sun
/star
/lang
/IndexOutOfBoundsException.idl
>
47 #ifndef __com_sun_star_lang_IllegalArgumentException_idl__
48 #include
<com
/sun
/star
/lang
/IllegalArgumentException.idl
>
50 #ifndef __com_sun_star_beans_PropertyValue_idl__
51 #include
<com
/sun
/star
/beans
/PropertyValue.idl
>
53 #ifndef __com_sun_star_accessibility_TextSegment_idl__
54 #include
<com
/sun
/star
/accessibility
/TextSegment.idl
>
57 module com
{ module sun
{ module star
{ module accessibility
{
59 /** Implement this interface to give read-only access to a text.
61 <p>The <type>XAccessibleText</type> interface should be implemented by
62 all UNO components that present textual information on the display like
63 buttons, text entry fields, or text portions of the document window.
64 The interface provides access to the text's content, attributes, and
65 spatial location. However, text can not be modified with this
66 interface. That is the task of the <type>XAccessibleEditableText</type>
69 <p>The text length, i.e. the number of characters in the text, is
70 returned by <member>XAccessibleText::getCharacterCount</member>.
71 All methods that operate on particular characters (e.g.
72 <member>XAccessibleText::getCharacterAt</member>) use character
73 indices from 0 to length-1. All methods that operate on character
74 positions (e.g. <member>XAccessibleText::getTextRange</member>)
75 use indices from 0 to length.</p>
77 <p>Please note that accessible text does not necessarily support
78 selection. In this case it should behave as if there where no
79 selection. An empty selection is used for example to express the
80 current cursor position.</p>
84 published
interface XAccessibleText
: ::com
::sun
::star
::uno
::XInterface
86 /** Return the position of the caret.
88 <p>Returns the offset of the caret. The caret is often called text
89 cursor. The caret is actually the position between two characters.
90 Its position/offset is that of the character to the right of it.</p>
93 The returned offset is relative to the text represented by this
96 long getCaretPosition
();
98 /** Set the position of the caret.
100 <p>The caret is often called text cursor. The caret is actually the
101 position between two characters. Its position/offset is that of the
102 character to the right of it.</p>
104 <p>Setting the caret position may or may not alter the current
105 selection. A change of the selection is notified to the
106 accessibility event listeners with an
107 <const>AccessibleEventId::ACCESSIBLE_SELECTION_EVENT</const>.</p>
109 <p>When the new caret position differs from the old one (which, of
110 course, is the standard case) this is notified to the accessibility
111 event listeners with an
112 <const>AccessibleEventId::ACCESSIBLE_CARET_EVENT</const>.</p>
115 The new index of the caret. This caret is actually placed to
116 the left side of the character with that index. An index of 0
117 places the caret so that the next insertion goes before the
118 first character. An index of <member>getCharacterCount</member>
119 leads to insertion after the last character.
122 Returns <TRUE/> if the caret has been moved and <FALSE/>
123 otherwise. A <TRUE/> value does not necessarily mean that the
124 caret has been positioned exactly at the required position.
125 If that position lies inside a read-only area the caret is
126 positioned before or behind it. Listen to the caret event to
127 determine the new position.
129 @throws ::com::sun::star::lang::IndexOutOfBoundsException
130 if the index is not valid.
132 boolean setCaretPosition
([in] long nIndex
)
133 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
);
135 /** Return the character at the specified position.
137 <p>Returns the character at the given index.</p>
140 The index of the character to return.
141 The valid range is 0..length-1.
144 the character at the index nIndex.
146 @throws ::com::sun::star::lang::IndexOutOfBoundsException
147 if the index is invalid
149 char getCharacter
([in] long nIndex
)
150 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
);
152 /** Get the attribute set for the specified position.
154 <p>Returns a set of attributes that are associated for the character
155 at the given index. To prevent the method from returning possibly
156 large sets of attributes that the caller is not interested in the
157 caller has to provide a list of attributes that he wants to be
161 The index of the character for which to return its attributes.
162 The valid range is 0..length-1.
164 @param aRequestedAttributes
165 This string sequence defines the set of attributes that the
166 caller is interested in. When there are attributes defined that
167 are not listed in the sequence then they are not returned. When
168 there are requested attributes that are not defined for the
169 character then they are ignored, too.
171 <p>An empty sequence signals the callers interest in all the
172 attributes. This is usefull in two cases: a) Simply as a way to
173 avoid passing a potentially large array to the called object or
174 b) when the caller does not know what attributes the called
175 objects supports but is interested in all of them
179 Returns the explicitly or implicitly (empty
180 <arg>aRequestedAttributes</arg> argument) requested attributes
181 of the specified character. Each attribute is represented by a
182 <type scope="::com::sun::star::beans">PropertyValue</type>
183 object. The returned list of attribute descriptions contains
184 all attributes that are both members of the sequence of
185 requested attributes and are defined for the character at the
188 @throws ::com::sun::star::lang::IndexOutOfBoundsException
189 if the index is invalid
191 sequence
<::com
::sun
::star
::beans
::PropertyValue
>
192 getCharacterAttributes
(
194 [in] sequence
<string> aRequestedAttributes
)
195 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
);
198 /** Return the bounding box of the specified position.
200 <p>Returns the bounding box of the indexed character.</p>
202 <p>The virtual character after the last character of the represented
203 text, i.e. the one at position length is a special case. It
204 represents the current input position and will therefore typically
205 be queried by AT more often than other positions. Because it does
206 not represent an existing character its bounding box is defined in
207 relation to preceding characters. It should be rougly equivalent to
208 the bounding box of some character when inserted at the end of the
209 text. Its height typically being the maximal height of all the
210 characters in the text or the height of the preceding character, its
211 width being at least one pixel so that the bounding box is not
213 Note that the index 'length' is not always valid. Whether it is
214 or not is implementation dependent. It typically is when text is
215 editable or otherwise when on the screen the caret can be placed
216 behind the text. You can be sure that the index is valid after you
217 have received a <const scope="AccessibleEventId">CARET</const> event
220 Index of the character for which to return its bounding box.
221 The valid range is 0..length.
224 The bounding box of the referenced character. The bounding box
225 of the virtual character at position length has to have
226 non-empty dimensions.
228 @throws ::com::sun::star::lang::IndexOutOfBoundsException
229 if the index is invalid
231 ::com
::sun
::star
::awt
::Rectangle getCharacterBounds
([in] long nIndex
)
232 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
);
235 /** Return the number of characters in the represented text.
237 <p>Returns the number of characters in the text represented by this
238 object or, in other words, the text length.</p>
241 Returns the number of characters of this object's text. A zero
242 value indicates an empty text.
244 long getCharacterCount
();
247 /** Return the text position for the specified screen position.
249 <p>Given a point in local coordinates, i.e. relative to the
250 coordinate system of the object, return the zero-based index of
251 the character under that point. The same functionality could be
252 achieved by using the bounding boxes for each character as returned
253 by <member>XAccessibleText::getCharacterBounds</member>. The method
254 <member>XAccessibleText::getIndexAtPoint</member>, however, can be
255 implemented in a more efficient way.</p>
258 The position for which to look up the index of the character
259 that is rendered on to the display at that point.
262 Index of the character under the given point or -1 if the point
263 is invalid or there is no character under the point.
265 long getIndexAtPoint
([in] ::com
::sun
::star
::awt
::Point aPoint
);
267 /** Return the selected text.
269 <p>Returns the portion of the text that is selected.</p>
272 The returned text is the selected portion of the object's text.
273 If no text is selected when this method is called or when
274 selection is not supported an empty string is returned.
276 string getSelectedText
();
278 /** Return the position of the start of the selection.
280 <p>Returns the index of the start of the selected text.</p>
283 If there is no selection or selection is not supported the
284 position of selection start and end will be the same undefined
287 long getSelectionStart
();
289 /** Return the position of the end of the selection.
291 <p>Returns the index of the end of the selected text.</p>
294 If there is no selection or selection is not supported the
295 position of selection start and end will be the same undefined
298 long getSelectionEnd
();
300 /** Set a new selection.
302 <p>Sets the selected text portion according to the given indices.
303 The old selection is replaced by the new selection.</p>
305 <p>The selection encompasses the same string of text that
306 <member>XAccessibleText::getTextRange</member> would have
307 selected. See there for details.</p>
309 <p>Setting the selection may or may not change the caret position.
310 Typically the caret is moved to the position after the second
311 argument. When the caret is moved this is notified to the
312 accessibility event listeners with an
313 <const>AccessibleEventId::ACCESSIBLE_CARET_EVENT</const>.</p>
316 The first character of the new selection.
317 The valid range is 0..length.
320 The position after the last character of the new selection.
321 The valid range is 0..length.
324 Returns <TRUE/> if the selection has been set successfully and
325 <FALSE/> otherwise or when selection is not supported.
327 @throws ::com::sun::star::lang::IndexOutOfBoundsException
328 if the indices are invalid
330 boolean setSelection
([in] long nStartIndex
, [in] long nEndIndex
)
331 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
);
333 /** Return the whole text.
335 <p>Returns the complete text. This is equivalent to a call to
336 <member>XAccessibleText::getTextRange</member> with the arguments
337 zero and <code>getCharacterCount()-1</code>.</p>
340 Returns a string that contains the complete text.
344 /** Return the specified text range.
346 <p>Returns the substring between the two given indices.</p>
348 <p>The substring starts with the character at nStartIndex
349 (inclusive) and up to the character at nEndIndex (exclusive),
350 if nStartIndex is less or equal nEndIndex. If nEndIndex is
351 lower than nStartIndex, the result is the same as a call with
352 the two arguments being exchanged.</p>
354 <p>The whole text can be requested by passing the indices zero and
355 <code>getCharacterCount()</code>. If both indices have the same
356 value, an empty string is returned.</p>
359 Index of the first character to include in the returned string.
360 The valid range is 0..length.
363 Index of the last character to exclude in the returned string.
364 The valid range is 0..length.
367 Returns the substring starting with the character at nStartIndex
368 (inclusive) and up to the character at nEndIndex (exclusive), if
369 nStartIndex is less than or equal to nEndIndex.
371 @throws ::com::sun::star::lang::IndexOutOfBoundsException
372 if the indices are invalid
374 string getTextRange
([in] long nStartIndex
, [in] long nEndIndex
)
375 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
);
377 /** Get a text portion around the given position.
379 <p>Returns the substring of the specified text type that contains
380 the character at the given index, if any. For example, given the
381 text type <const scope="AccessibleTextType">WORD</type>, the word
382 which contains the character at position nIndex is returned, or an
383 empty string if no word is found at the that position.</p>
386 Index of the character whose containing text portion is to be
388 The valid range is 0..length.
391 The type of the text portion to return. See
392 <type>AccessibleTextType</type> for the complete list.
395 Returns the requested text portion. This portion may be empty
396 or invalid when no appropriate text portion is found or text
399 @throws ::com::sun::star::lang::IndexOutOfBoundsException
400 if the index is invalid
401 @throws ::com::sun::star::lang::InvalidArgumentException
402 if the given text type is not valid.
404 TextSegment getTextAtIndex
([in] long nIndex
, [in] short nTextType
)
405 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
,
406 ::com
::sun
::star
::lang
::IllegalArgumentException
);
408 /** Get a text portion before the given position.
410 <p>Returns the substring of the specified text type that is
411 located before the given character and does not include
412 it. The result of this method should be same as a result for
413 <member>XAccessibleText::getTextAtIndex</member> with a
414 suitably decreased index value.</p>
416 <p>For example, if text type is <const
417 scope="AccessibleTextType">WORD</type>, then the complete word
418 that is closest to and located before nIndex is returned.</p>
420 <p>If the index is valid, but no suitable word (or other text
421 type) is found, an empty text segment is returned.</p>
424 Index of the character for which to return the text part before
425 it. The index character will not be part of the returned
427 The valid range is 0..length.
430 The type of the text portion to return. See
431 <type>AccessibleTextType</type> for the complete list.
434 Returns the requested text portion. This portion may be empty
435 or invalid when no appropriate text portion is found or text
438 @throws ::com::sun::star::lang::IndexOutOfBoundsException
439 if the index is invalid.
440 @throws ::com::sun::star::lang::InvalidArgumentException
441 if the given text type is not valid.
443 TextSegment getTextBeforeIndex
([in] long nIndex
, [in] short nTextType
)
444 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
,
445 ::com
::sun
::star
::lang
::IllegalArgumentException
);
447 /** Get a text portion behind the given position.
449 <p>Returns the substring of the specified text type that is
450 located after the given character and does not include
451 it. The result of this method should be same as a result for
452 <member>XAccessibleText::getTextAtIndex</member> with a
453 suitably increased index value.</p>
455 <p>For example, if text type is <const
456 scope="AccessibleTextType">WORD</type>, then the complete word
457 that is closest to and located behind nIndex is returned.</p>
459 <p>If the index is valid, but no suitable word (or other text
460 type) is found, an empty string is returned.</p>
463 Index of the character for which to return the text part after
464 it. The index character will be part of the returned string.
465 The valid range is 0..length.
468 The type of the text portion to return. See
469 <type>AccessibleTextType</type> for the complete list.
472 Returns the requested text portion. This portion may be empty
473 or invalid when no appropriate text portion is found or text
476 @throws ::com::sun::star::lang::IndexOutOfBoundsException
477 if the index is invalid
478 @throws ::com::sun::star::lang::InvalidArgumentException
479 if the given text type is not valid.
481 TextSegment getTextBehindIndex
([in] long nIndex
, [in] short nTextType
)
482 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
,
483 ::com
::sun
::star
::lang
::IllegalArgumentException
);
485 /** Copy the specified text into the clipboard.
487 <p>Copy the specified text into the clipboard. The text that is
488 copied is the same text that would have been selected by the
489 <member>XAccessibleText::getTextRange</member> method. </p>
491 <p>The other clipboard related methods
492 <member>XAccessibleEditableText::cutText</member> and
493 <member>XAccessibleEditableText::deleteText</member> can be found in
494 the <type>XAccessibleEditableText</type> because of their
495 destructive nature.</p>
498 Start index of the text to copied into the clipboard.
499 The valid range is 0..length.
502 End index of the text to copied into the clipboard.
503 The valid range is 0..length.
506 Returns <true/> if the specified text has been copied
507 successfully into the clipboard.
509 @throws ::com::sun::star::lang::IndexOutOfBoundsException
510 if the indices are invalid
512 boolean copyText
([in] long nStartIndex
, [in] long nEndIndex
)
513 raises
(::com
::sun
::star
::lang
::IndexOutOfBoundsException
);