org.eclipse.actf.accservice.core.win32.ia2
Class IA2AccessibleText

java.lang.Object
  extended by org.eclipse.actf.accservice.core.win32.ia2.IA2AccessibleElement
      extended by org.eclipse.actf.accservice.core.win32.ia2.IA2AccessibleText
All Implemented Interfaces:
IAccessibleTextElement
Direct Known Subclasses:
IA2AccessibleHypertext

public class IA2AccessibleText
extends IA2AccessibleElement
implements IAccessibleTextElement

implementation of IAccessibleTextElement for GUI controls that implement IAccessible2/IBM interfaces.

This class is a wrapper for an IAccessible2 pointer, a pointer that Provides access to a native Windows object that provides assistive technologies (ATs) with properties of GUI components that allow the AT to offer an alternative interface to the control. This class relies upon JCAccessible.dll for most of its implementation. The documentation for the Microsoft COM library and, in particular, for IAccessible2/IBM will be helpful.

Author:
Mike Smith, Kavitha Teegala

Field Summary
 
Fields inherited from class org.eclipse.actf.accservice.core.win32.ia2.IA2AccessibleElement
errorCodeReturnMap, errString
 
Constructor Summary
IA2AccessibleText(int accRef, IA2Accessible parent)
          Constructor used to create an accessible text object
 
Method Summary
 boolean addSelection(int startOffset, int endOffset)
          Adds a text selection.
 Object getAttributes(long offset)
          get the attributes at the specified offset of the text
 long getCaretOffset()
          get the offset of the caret for the accessible text object
 Rectangle getCharacterBounds(int offset, int coordType)
          Returns the bounding box of the specified position.
 int getCharacterCount()
           
 IA2TextSegment getNewText()
           
 int getOffsetAtPoint(Point point, int coordType)
           
 IA2TextSegment getOldText()
           
 String getSelectedText(long index)
          get the text of the selected object
 long getSelectedTextEnd(long index)
          get the ending index of the selected text
 long getSelectedTextStart(long index)
          get the starting index of the selected text
 long getSelectionCount()
          get number of active non-contiguous selections
 String getText()
          get the text for the accessible text object
 IA2TextSegment getTextAfterOffset(int offset, int boundaryType)
           
 IA2TextSegment getTextAtOffset(int offset, int boundaryType)
           
 IA2TextSegment getTextBeforeOffset(int offset, int boundaryType)
           
 String getTextRange(int startOffset, int endOffset)
           
protected  boolean internalAddSelection(int startOffset, int endOffset)
           
protected  IA2TextSegment internalGetAttributes(long offset)
           
protected  long internalGetCaretOffset()
           
protected  int[] internalGetCharacterBounds(int offset, int coordType)
           
protected  int internalGetCharacterCount()
           
protected  IA2TextSegment internalGetNewText()
           
protected  int internalGetOffsetAtPoint(int x, int y, int coordType)
           
protected  IA2TextSegment internalGetOldText()
           
protected  String internalGetSelectedText(long index)
           
protected  long internalGetSelectedTextEnd(long index)
           
protected  long internalGetSelectedTextStart(long index)
           
protected  long internalGetSelectionCount()
           
protected  String internalGetText()
           
protected  IA2TextSegment internalGetTextAfterOffset(int offset, int boundaryType)
           
protected  IA2TextSegment internalGetTextAtOffset(int offset, int boundaryType)
           
protected  IA2TextSegment internalGetTextBeforeOffset(int offset, int boundaryType)
           
protected  String internalGetTextRange(int startOffset, int endOffset)
           
 int internalRef()
          used by native code only.
protected  boolean internalRemoveSelection(int selIndex)
           
protected  boolean internalScrollSubstringToPoint(int startOffset, int endOffset, int scrollType, int x, int y)
           
protected  boolean internalScrollToSubstring(int startOffset, int endOffset, int scrollType)
           
protected  boolean internalSetCaretOffset(int offset)
           
protected  boolean internalSetSelection(int sel, int startOffset, int endOffset)
           
 boolean removeSelection(int selIndex)
           
 boolean scrollSubstringToPoint(int startOffset, int endOffset, int scrollType, int x, int y)
           
 boolean scrollToSubstring(int startOffset, int endOffset, int scrollType)
           
 boolean setCaretOffset(int offset)
           
 boolean setSelection(int selIndex, int startOffset, int endOffset)
           
 
Methods inherited from class org.eclipse.actf.accservice.core.win32.ia2.IA2AccessibleElement
errorCodeMap, putErrorCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IA2AccessibleText

public IA2AccessibleText(int accRef,
                         IA2Accessible parent)
Constructor used to create an accessible text object

Parameters:
accRef - reference pointer to the IA2Accessible text object
parent - IA2Accessible parent of this object
Method Detail

internalRef

public int internalRef()
used by native code only. Clients should not call directly.

Returns:
ptr address for native object

getText

public String getText()
               throws InvalidComponentException
get the text for the accessible text object

Specified by:
getText in interface IAccessibleTextElement
Returns:
text or an empty string if no text is provided
Throws:
InvalidComponentException

internalGetText

protected String internalGetText()

getCaretOffset

public long getCaretOffset()
                    throws InvalidComponentException
get the offset of the caret for the accessible text object

Specified by:
getCaretOffset in interface IAccessibleTextElement
Returns:
caret offset
Throws:
InvalidComponentException

internalGetCaretOffset

protected long internalGetCaretOffset()

getAttributes

public Object getAttributes(long offset)
                     throws InvalidComponentException
get the attributes at the specified offset of the text

Specified by:
getAttributes in interface IAccessibleTextElement
Parameters:
offset - zero index of caret offset
Returns:
attributes or an empty string if no description is provided
Throws:
InvalidComponentException

internalGetAttributes

protected IA2TextSegment internalGetAttributes(long offset)

getSelectionCount

public long getSelectionCount()
                       throws InvalidComponentException
get number of active non-contiguous selections

Specified by:
getSelectionCount in interface IAccessibleTextElement
Returns:
the number of selections
Throws:
InvalidComponentException

internalGetSelectionCount

protected long internalGetSelectionCount()

getSelectedText

public String getSelectedText(long index)
                       throws InvalidComponentException
get the text of the selected object

Specified by:
getSelectedText in interface IAccessibleTextElement
Parameters:
index - zero index of selected text objects
Returns:
the number of selections or empty string if index is out of range
Throws:
InvalidComponentException

internalGetSelectedText

protected String internalGetSelectedText(long index)

getSelectedTextStart

public long getSelectedTextStart(long index)
                          throws InvalidComponentException
get the starting index of the selected text

Specified by:
getSelectedTextStart in interface IAccessibleTextElement
Parameters:
index - zero index of selected text objects
Returns:
the starting index of the selection
Throws:
InvalidComponentException

internalGetSelectedTextStart

protected long internalGetSelectedTextStart(long index)

getSelectedTextEnd

public long getSelectedTextEnd(long index)
                        throws InvalidComponentException
get the ending index of the selected text

Specified by:
getSelectedTextEnd in interface IAccessibleTextElement
Parameters:
index - zero index of selected text objects
Returns:
the ending index of the selection
Throws:
InvalidComponentException

internalGetSelectedTextEnd

protected long internalGetSelectedTextEnd(long index)

addSelection

public boolean addSelection(int startOffset,
                            int endOffset)
                     throws InvalidComponentException
Adds a text selection.

Parameters:
startOffset - -Starting offset ( 0-based).
endOffset - - Offset of first character after new selection (0-based).
Returns:
boolean
Throws:
InvalidComponentException

internalAddSelection

protected boolean internalAddSelection(int startOffset,
                                       int endOffset)

getCharacterBounds

public Rectangle getCharacterBounds(int offset,
                                    int coordType)
                             throws InvalidComponentException
Returns the bounding box of the specified position. The virtual character after the last character of the represented text, i.e. the one at position length is a special case. It represents the current input position and will therefore typically be queried by AT more often than other positions. Because it does not represent an existing character its bounding box is defined in relation to preceding characters. It should be roughly equivalent to the bounding box of some character when inserted at the end of the text. Its height typically being the maximal height of all the characters in the text or the height of the preceding character, its width being at least one pixel so that the bounding box is not degenerate.

Parameters:
offset - -Index of the character for which to return its bounding box. The valid range is 0..length.
coordType - -Specifies if the coordinates are relative to the screen or to the parent window.
Returns:
Rectangle -the bounding box of the specified position.
Throws:
InvalidComponentException

internalGetCharacterBounds

protected int[] internalGetCharacterBounds(int offset,
                                           int coordType)

getOffsetAtPoint

public int getOffsetAtPoint(Point point,
                            int coordType)
                     throws InvalidComponentException
Throws:
InvalidComponentException

internalGetOffsetAtPoint

protected int internalGetOffsetAtPoint(int x,
                                       int y,
                                       int coordType)

getTextRange

public String getTextRange(int startOffset,
                           int endOffset)
                    throws InvalidComponentException
Throws:
InvalidComponentException

internalGetTextRange

protected String internalGetTextRange(int startOffset,
                                      int endOffset)

getTextBeforeOffset

public IA2TextSegment getTextBeforeOffset(int offset,
                                          int boundaryType)
                                   throws InvalidComponentException
Throws:
InvalidComponentException

internalGetTextBeforeOffset

protected IA2TextSegment internalGetTextBeforeOffset(int offset,
                                                     int boundaryType)

getTextAfterOffset

public IA2TextSegment getTextAfterOffset(int offset,
                                         int boundaryType)
                                  throws InvalidComponentException
Throws:
InvalidComponentException

internalGetTextAfterOffset

protected IA2TextSegment internalGetTextAfterOffset(int offset,
                                                    int boundaryType)

getTextAtOffset

public IA2TextSegment getTextAtOffset(int offset,
                                      int boundaryType)
                               throws InvalidComponentException
Throws:
InvalidComponentException

internalGetTextAtOffset

protected IA2TextSegment internalGetTextAtOffset(int offset,
                                                 int boundaryType)

removeSelection

public boolean removeSelection(int selIndex)
                        throws InvalidComponentException
Throws:
InvalidComponentException

internalRemoveSelection

protected boolean internalRemoveSelection(int selIndex)

setCaretOffset

public boolean setCaretOffset(int offset)
                       throws InvalidComponentException
Throws:
InvalidComponentException

internalSetCaretOffset

protected boolean internalSetCaretOffset(int offset)

setSelection

public boolean setSelection(int selIndex,
                            int startOffset,
                            int endOffset)
                     throws InvalidComponentException
Throws:
InvalidComponentException

internalSetSelection

protected boolean internalSetSelection(int sel,
                                       int startOffset,
                                       int endOffset)

getCharacterCount

public int getCharacterCount()
                      throws InvalidComponentException
Throws:
InvalidComponentException

internalGetCharacterCount

protected int internalGetCharacterCount()

scrollToSubstring

public boolean scrollToSubstring(int startOffset,
                                 int endOffset,
                                 int scrollType)
                          throws InvalidComponentException
Throws:
InvalidComponentException

internalScrollToSubstring

protected boolean internalScrollToSubstring(int startOffset,
                                            int endOffset,
                                            int scrollType)

scrollSubstringToPoint

public boolean scrollSubstringToPoint(int startOffset,
                                      int endOffset,
                                      int scrollType,
                                      int x,
                                      int y)
                               throws InvalidComponentException
Throws:
InvalidComponentException

internalScrollSubstringToPoint

protected boolean internalScrollSubstringToPoint(int startOffset,
                                                 int endOffset,
                                                 int scrollType,
                                                 int x,
                                                 int y)

getNewText

public IA2TextSegment getNewText()
                          throws InvalidComponentException
Throws:
InvalidComponentException

internalGetNewText

protected IA2TextSegment internalGetNewText()

getOldText

public IA2TextSegment getOldText()
                          throws InvalidComponentException
Throws:
InvalidComponentException

internalGetOldText

protected IA2TextSegment internalGetOldText()