1 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; 6 7 class AccessibleActionHandler 8 extends NodeHandler 9 { 10 public NodeHandler createHandler (XAccessibleContext xContext) 11 { 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; 19 } 20 21 public AccessibleActionHandler () 22 { 23 } 24 25 public AccessibleActionHandler (XAccessibleAction xAction) 26 { 27 if (xAction != null) 28 maChildList.setSize (1 + xAction.getAccessibleActionCount()); 29 } 30 31 protected static XAccessibleAction getAction (AccTreeNode aParent) 32 { 33 return (XAccessibleAction) UnoRuntime.queryInterface ( 34 XAccessibleAction.class, aParent.getContext()); 35 } 36 37 public AccessibleTreeNode createChild ( 38 AccessibleTreeNode aParent, 39 int nIndex) 40 { 41 AccessibleTreeNode aChild = null; 42 43 if (aParent instanceof AccTreeNode) 44 { 45 XAccessibleAction xAction = getAction ((AccTreeNode)aParent); 46 if( xAction != null ) 47 { 48 if (nIndex == 0) 49 aChild = new StringNode ("Number of actions: " + xAction.getAccessibleActionCount(), 50 aParent); 51 else 52 { 53 nIndex -= 1; 54 try 55 { 56 aChild = new AccessibleActionNode ( 57 "Action " + nIndex + " : " 58 + xAction.getAccessibleActionDescription (nIndex), 59 aParent, 60 nIndex); 61 } 62 catch( IndexOutOfBoundsException e ) 63 { 64 aChild = new StringNode ("ERROR", aParent); 65 } 66 } 67 } 68 } 69 70 return aChild; 71 } 72 } 73