From Apache OpenOffice Wiki
Jump to: navigation, search

An accessible object can be in one or more states, which are available through the interface com.sun.star.accessibility.XAccessibleStateSet. An object that is currently focused will have the FOCUSED state set. One that belongs to the selection of its parent has the SELECTED state set. Independent of the current focus and selection, such an object would also have the states FOCUSABLE and SELECTABLE set to indicate that it may be focused and may be selected. All states are described in the com.sun.star.accessibility.AccessibleStateType constants collection.

Call the isEmpty() function to query whether a state set has no state set at all. To query a state set for one or more states, use the contains() and containsAll() functions respectively. A sequence containing all the set states is returned by the getStates() function.

Documentation note.png The state set returned by getAccessibleStateSet() returns a copy of the state set of an accessible object. Modifying that copy does not change the states of the object. Therefore, modifying a state set is not useful and consequently no modifying functions are supported by the com.sun.star.accessibility.XAccessibleStateSet interface. States are set or reset indirectly by using the standard UNO interfaces or the GUI.

List of states in the SSR

The showStates() method of the TextualDisplay class of the SSR first obtains a state set object from the given accessible context and prints a list of all the states contained therein by using the getStates() method to convert the state set into an array of state IDs. It then iterates over all IDs and uses the NameProvider class to convert the numerical IDs into human readable strings.

  private void showStates (XAccessibleContext xContext, String sIndentation) {
      // Get the state set object...
      XAccessibleStateSet xStateSet = xContext.getAccessibleStateSet();
      // ...and retrieve an array of numerical IDs.
      short aStates[] = xStateSet.getStates();
      // Iterate over the array and print the names of the states.
      msTextContent += sIndentation + "States : ";
      for (int i=0; i<aStates.length; i++) {
          if (i > 0)
              msTextContent += ", ";
          msTextContent += NameProvider.getStateName(aStates[i]);
      msTextContent += "\n";
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages