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
13 protected int nChildrenCount
;
15 public NodeHandler
createHandler (XAccessibleContext xContext
)
18 return new AccessibleContextHandler (xContext
);
23 public AccessibleContextHandler ()
28 public AccessibleContextHandler (XAccessibleContext xContext
)
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();
47 sChild
= "Description: " +
48 xContext
.getAccessibleDescription();
51 int nRole
= xContext
.getAccessibleRole();
52 sChild
= "Role: " + nRole
+ " (" + NameProvider
.getRoleName(nRole
) + ")";
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();
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)
76 sChild
+= NameProvider
.getStateName(i
);
81 sChild
+= "no state set";
82 sChild
= "State set: " + sChild
;
85 sChild = "Child count: " + xContext.getAccessibleChildCount();
89 return new StringNode (sChild
, aParent
);