merge the formfield patch from ooo-build
[ooovba.git] / toolkit / test / accessibility / AccessibleActionHandler.java
blobd91923b2b7a2324b297de90c3d48b8340ef29ba7
2 import com.sun.star.uno.UnoRuntime;
3 import com.sun.star.accessibility.XAccessibleContext;
4 import com.sun.star.accessibility.XAccessibleAction;
5 import com.sun.star.lang.IndexOutOfBoundsException;
7 class AccessibleActionHandler
8 extends NodeHandler
10 public NodeHandler createHandler (XAccessibleContext xContext)
12 XAccessibleAction xEComponent =
13 (XAccessibleAction) UnoRuntime.queryInterface (
14 XAccessibleAction.class, xContext);
15 if (xEComponent != null)
16 return new AccessibleActionHandler (xEComponent);
17 else
18 return null;
21 public AccessibleActionHandler ()
25 public AccessibleActionHandler (XAccessibleAction xAction)
27 if (xAction != null)
28 maChildList.setSize (1 + xAction.getAccessibleActionCount());
31 protected static XAccessibleAction getAction (AccTreeNode aParent)
33 return (XAccessibleAction) UnoRuntime.queryInterface (
34 XAccessibleAction.class, aParent.getContext());
37 public AccessibleTreeNode createChild (
38 AccessibleTreeNode aParent,
39 int nIndex)
41 AccessibleTreeNode aChild = null;
43 if (aParent instanceof AccTreeNode)
45 XAccessibleAction xAction = getAction ((AccTreeNode)aParent);
46 if( xAction != null )
48 if (nIndex == 0)
49 aChild = new StringNode ("Number of actions: " + xAction.getAccessibleActionCount(),
50 aParent);
51 else
53 nIndex -= 1;
54 try
56 aChild = new AccessibleActionNode (
57 "Action " + nIndex + " : "
58 + xAction.getAccessibleActionDescription (nIndex),
59 aParent,
60 nIndex);
62 catch( IndexOutOfBoundsException e )
64 aChild = new StringNode ("ERROR", aParent);
70 return aChild;