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.XAccessibleImage; 5*cdf0e10cSrcweir 6*cdf0e10cSrcweir 7*cdf0e10cSrcweir class AccessibleImageHandler extends NodeHandler 8*cdf0e10cSrcweir { 9*cdf0e10cSrcweir public NodeHandler createHandler (XAccessibleContext xContext) 10*cdf0e10cSrcweir { 11*cdf0e10cSrcweir XAccessibleImage xImage = 12*cdf0e10cSrcweir (XAccessibleImage) UnoRuntime.queryInterface ( 13*cdf0e10cSrcweir XAccessibleImage.class, xContext); 14*cdf0e10cSrcweir if (xImage != null) 15*cdf0e10cSrcweir return new AccessibleImageHandler (xImage); 16*cdf0e10cSrcweir else 17*cdf0e10cSrcweir return null; 18*cdf0e10cSrcweir } 19*cdf0e10cSrcweir 20*cdf0e10cSrcweir public AccessibleImageHandler () 21*cdf0e10cSrcweir { 22*cdf0e10cSrcweir } 23*cdf0e10cSrcweir 24*cdf0e10cSrcweir public AccessibleImageHandler (XAccessibleImage xImage) 25*cdf0e10cSrcweir { 26*cdf0e10cSrcweir if (xImage != null) 27*cdf0e10cSrcweir maChildList.setSize (1); 28*cdf0e10cSrcweir } 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir protected static XAccessibleImage getImage (AccTreeNode aNode) 31*cdf0e10cSrcweir { 32*cdf0e10cSrcweir return (XAccessibleImage) UnoRuntime.queryInterface ( 33*cdf0e10cSrcweir XAccessibleImage.class, aNode.getContext()); 34*cdf0e10cSrcweir } 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) 37*cdf0e10cSrcweir { 38*cdf0e10cSrcweir if (aParent instanceof AccTreeNode) 39*cdf0e10cSrcweir { 40*cdf0e10cSrcweir XAccessibleImage xImage = getImage ((AccTreeNode)aParent); 41*cdf0e10cSrcweir if (xImage != null) 42*cdf0e10cSrcweir return new StringNode ( 43*cdf0e10cSrcweir "Image: " + 44*cdf0e10cSrcweir xImage.getAccessibleImageDescription() + " (" + 45*cdf0e10cSrcweir xImage.getAccessibleImageWidth() + "x" + 46*cdf0e10cSrcweir xImage.getAccessibleImageHeight() + ")", 47*cdf0e10cSrcweir aParent); 48*cdf0e10cSrcweir } 49*cdf0e10cSrcweir return null; 50*cdf0e10cSrcweir } 51*cdf0e10cSrcweir } 52