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