merged tag ooo/DEV300_m102
[LibreOffice.git] / toolkit / test / accessibility / AccessibleContextHandler.java
blobfd22bcd5367f6c959151fba16b5412fb8d7d5e1e
1 import com.sun.star.accessibility.XAccessible;
2 import com.sun.star.accessibility.XAccessibleContext;
3 import com.sun.star.accessibility.XAccessibleStateSet;
4 import com.sun.star.uno.UnoRuntime;
5 import com.sun.star.container.XIndexAccess;
6 import java.util.HashMap;
8 import tools.NameProvider;
10 class AccessibleContextHandler
11 extends NodeHandler
13 protected int nChildrenCount;
15 public NodeHandler createHandler (XAccessibleContext xContext)
17 if (xContext != null)
18 return new AccessibleContextHandler (xContext);
19 else
20 return null;
23 public AccessibleContextHandler ()
25 super ();
28 public AccessibleContextHandler (XAccessibleContext xContext)
30 super();
31 if (xContext != null)
32 maChildList.setSize (4);
35 public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
37 XAccessibleContext xContext = null;
38 if (aParent instanceof AccTreeNode)
39 xContext = ((AccTreeNode)aParent).getContext();
41 String sChild = new String();
42 if (xContext != null)
44 switch( nIndex )
46 case 0:
47 sChild = "Description: " +
48 xContext.getAccessibleDescription();
49 break;
50 case 1:
51 int nRole = xContext.getAccessibleRole();
52 sChild = "Role: " + nRole + " (" + NameProvider.getRoleName(nRole) + ")";
53 break;
54 case 2:
55 XAccessible xParent = xContext.getAccessibleParent();
56 sChild = "Has parent: " + (xParent!=null ? "yes" : "no");
57 /* if (xParent != ((AccTreeNode)aParent).getAccessible())
59 sChild += " but that is inconsistent"
60 + "#" + xParent + " # " + ((AccTreeNode)aParent).getAccessible();
63 break;
64 case 3:
65 sChild = "";
66 XAccessibleStateSet xStateSet =
67 xContext.getAccessibleStateSet();
68 if (xStateSet != null)
70 for (short i=0; i<=30; i++)
72 if (xStateSet.contains (i))
74 if (sChild.compareTo ("") != 0)
75 sChild += ", ";
76 sChild += NameProvider.getStateName(i);
80 else
81 sChild += "no state set";
82 sChild = "State set: " + sChild;
84 /* case 3:
85 sChild = "Child count: " + xContext.getAccessibleChildCount();
86 break;*/
89 return new StringNode (sChild, aParent);