Using the Accessibility API

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 11:57, 1 November 2007 by Jsc (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



When you are writing your own ATs and want to use the UNO accessibility API directly, you must first connect to OpenOffice.org. Connecting to OpenOffice.org is explained elsewhere in this document. Once a connection is established, the toolkit with its com.sun.star.awt.XExtendedToolkit interface can be used to retrieve a list of all currently open top-level windows. From these, you can then get the accessible root nodes of the accessibility object trees associated with the windows. When you register an com.sun.star.awt.XTopWindowListener you will then be informed about new top-level windows, as well as top-level windows that have disappeared.

With the top-level accessible objects at hand, you can use the Java version of the accessibility API as it is described in detail in the following sections. To be informed about focus changes - so that, for example, a screen reader can track the currently focused object and read it to the user - an AT has to register all non-transient objects of an accessibility tree.

The general operation of a simple AT consists of the following steps:

  1. Connect to OpenOffice.org.
  2. Retrieve the currently visible top-level windows and register as top window listener to keep the list up-to-date.
  3. Traverse the trees by getting their root elements from each window. See the description of the com.sun.star.accessibility.XAccessibleContext for a code example for this.
  4. Register each accessible object as com.sun.star.accessibility.XAccessibleEventListener.
  5. If called back with an com.sun.star.accessibility.AccessibleEventObject object, then process two kinds of events:
    • Events that denote a state change with either OldValue or NewValue containing the FOCUSED constant indicate that the source object of this event got either focused or unfocused.
    • When receiving events of type CHILD, register as listener at the object that is specified by the event, as well as all of the object's children.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools