Difference between revisions of "Documentation/DevGuide/Accessibility/XAccessibleStateSet"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (1 revision(s))
m
Line 11: Line 11:
 
An accessible object can be in one or more states, which are available through the interface <idl>com.sun.star.accessibility.XAccessibleStateSet</idl>. An object that is currently focused will have the <idlm>com.sun.star.accessibility.AccessibleStateType:FOCUSED</idlm> state set. One that belongs to the selection of its parent has the <idlm>com.sun.star.accessibility.AccessibleStateType:SELECTED</idlm> state set. Independent of the current focus and selection, such an object would also have the states <idlm>com.sun.star.accessibility.AccessibleStateType:FOCUSABLE</idlm> and <idlm>com.sun.star.accessibility.AccessibleStateType:SELECTABLE</idlm> set to indicate that it may be focused and may be selected. All states are described in the <idl>com.sun.star.accessibility.AccessibleStateType</idl> constants collection.
 
An accessible object can be in one or more states, which are available through the interface <idl>com.sun.star.accessibility.XAccessibleStateSet</idl>. An object that is currently focused will have the <idlm>com.sun.star.accessibility.AccessibleStateType:FOCUSED</idlm> state set. One that belongs to the selection of its parent has the <idlm>com.sun.star.accessibility.AccessibleStateType:SELECTED</idlm> state set. Independent of the current focus and selection, such an object would also have the states <idlm>com.sun.star.accessibility.AccessibleStateType:FOCUSABLE</idlm> and <idlm>com.sun.star.accessibility.AccessibleStateType:SELECTABLE</idlm> set to indicate that it may be focused and may be selected. All states are described in the <idl>com.sun.star.accessibility.AccessibleStateType</idl> constants collection.
  
Call the [http://api.openoffice.org/docs/common/ref/com/sun/star/accessibility/XAccessibleStateSet.html#isEmpty com.sun.star.accessibility.XAccessibleStateSet: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 [http://api.openoffice.org/docs/common/ref/com/sun/star/accessibility/XAccessibleStateSet.html#contains com.sun.star.accessibility.XAccessibleStateSet:contains]() and [http://api.openoffice.org/docs/common/ref/com/sun/star/accessibility/XAccessibleStateSet.html#containsAll com.sun.star.accessibility.XAccessibleStateSet:containsAll]() functions respectively. A sequence containing all the set states is returned by the [http://api.openoffice.org/docs/common/ref/com/sun/star/accessibility/XAccessibleStateSet.html#getStates com.sun.star.accessibility.XAccessibleStateSet:getStates]() function.
+
Call the <idlml>com.sun.star.accessibility.XAccessibleStateSet:isEmpty</idlml>() 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 <idlml>com.sun.star.accessibility.XAccessibleStateSet:contains</idlml>() and <idlml>com.sun.star.accessibility.XAccessibleStateSet:containsAll</idlml>() functions respectively. A sequence containing all the set states is returned by the <idlml>com.sun.star.accessibility.XAccessibleStateSet:getStates</idlml>() function.
  
{{Documentation/Note|The state set returned by [http://api.openoffice.org/docs/common/ref/com/sun/star/accessibility/XAccessibleContext.html#getAccessibleStateSet com.sun.star.accessibility.XAccessibleContext: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 <idl>com.sun.star.accessibility.XAccessibleStateSet</idl> interface. States are set or reset indirectly by using the standard UNO interfaces or the GUI.}}
+
{{Documentation/Note|The state set returned by <idlml>com.sun.star.accessibility.XAccessibleContext:getAccessibleStateSet</idlml>() 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 <idl>com.sun.star.accessibility.XAccessibleStateSet</idl> interface. States are set or reset indirectly by using the standard UNO interfaces or the GUI.}}
  
  
Line 19: Line 19:
  
 
The <code>showStates()</code> method of the <code>TextualDisplay</code> 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 <idlm>com.sun.star.accessibility.XAccessibleStateSet:getStates</idlm>() method to convert the state set into an array of state IDs. It then iterates over all IDs and uses the <code>NameProvider</code> class to convert the numerical IDs into human readable strings.
 
The <code>showStates()</code> method of the <code>TextualDisplay</code> 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 <idlm>com.sun.star.accessibility.XAccessibleStateSet:getStates</idlm>() method to convert the state set into an array of state IDs. It then iterates over all IDs and uses the <code>NameProvider</code> class to convert the numerical IDs into human readable strings.
 
+
<source lang="java">
 
   private void showStates (XAccessibleContext xContext, String sIndentation) {
 
   private void showStates (XAccessibleContext xContext, String sIndentation) {
 
       // Get the state set object...
 
       // Get the state set object...
Line 35: Line 35:
 
       msTextContent += "\n";
 
       msTextContent += "\n";
 
   }
 
   }
 
+
</source>
 
{{PDL1}}
 
{{PDL1}}
 
[[Category: Accessibility]]
 
[[Category: Accessibility]]

Revision as of 20:01, 14 April 2008



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 <idlml>com.sun.star.accessibility.XAccessibleStateSet:isEmpty</idlml>() 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 <idlml>com.sun.star.accessibility.XAccessibleStateSet:contains</idlml>() and <idlml>com.sun.star.accessibility.XAccessibleStateSet:containsAll</idlml>() functions respectively. A sequence containing all the set states is returned by the <idlml>com.sun.star.accessibility.XAccessibleStateSet:getStates</idlml>() function.

Template:Documentation/Note


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