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.XAccessibleComponent; 5*cdf0e10cSrcweir 6*cdf0e10cSrcweir 7*cdf0e10cSrcweir class AccessibleComponentHandler 8*cdf0e10cSrcweir extends NodeHandler 9*cdf0e10cSrcweir { 10*cdf0e10cSrcweir 11*cdf0e10cSrcweir public NodeHandler createHandler (XAccessibleContext xContext) 12*cdf0e10cSrcweir { 13*cdf0e10cSrcweir XAccessibleComponent xComponent = 14*cdf0e10cSrcweir (XAccessibleComponent) UnoRuntime.queryInterface ( 15*cdf0e10cSrcweir XAccessibleComponent.class, xContext); 16*cdf0e10cSrcweir if (xComponent != null) 17*cdf0e10cSrcweir return new AccessibleComponentHandler (xComponent); 18*cdf0e10cSrcweir else 19*cdf0e10cSrcweir return null; 20*cdf0e10cSrcweir 21*cdf0e10cSrcweir } 22*cdf0e10cSrcweir 23*cdf0e10cSrcweir public AccessibleComponentHandler () 24*cdf0e10cSrcweir { 25*cdf0e10cSrcweir } 26*cdf0e10cSrcweir 27*cdf0e10cSrcweir public AccessibleComponentHandler (XAccessibleComponent xComponent) 28*cdf0e10cSrcweir { 29*cdf0e10cSrcweir if (xComponent != null) 30*cdf0e10cSrcweir maChildList.setSize (6); 31*cdf0e10cSrcweir } 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) 34*cdf0e10cSrcweir { 35*cdf0e10cSrcweir AccessibleTreeNode aChild = null; 36*cdf0e10cSrcweir if (aParent instanceof AccTreeNode) 37*cdf0e10cSrcweir { 38*cdf0e10cSrcweir XAccessibleComponent xComponent = 39*cdf0e10cSrcweir ((AccTreeNode)aParent).getComponent(); 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir if (xComponent != null) 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir int nColor; 44*cdf0e10cSrcweir switch (nIndex) 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir case 0: 47*cdf0e10cSrcweir com.sun.star.awt.Point aLocation = xComponent.getLocation(); 48*cdf0e10cSrcweir aChild = new StringNode ( 49*cdf0e10cSrcweir "Location: " + aLocation.X + ", " + aLocation.Y, 50*cdf0e10cSrcweir aParent); 51*cdf0e10cSrcweir break; 52*cdf0e10cSrcweir case 1: 53*cdf0e10cSrcweir com.sun.star.awt.Point aScreenLocation = xComponent.getLocationOnScreen(); 54*cdf0e10cSrcweir aChild = new StringNode ( 55*cdf0e10cSrcweir "Location on Screen: " + aScreenLocation.X + ", " + aScreenLocation.Y, 56*cdf0e10cSrcweir aParent); 57*cdf0e10cSrcweir break; 58*cdf0e10cSrcweir case 2: 59*cdf0e10cSrcweir com.sun.star.awt.Size aSize = xComponent.getSize(); 60*cdf0e10cSrcweir aChild = new StringNode ( 61*cdf0e10cSrcweir "Size: "+ aSize.Width + ", " + aSize.Height, 62*cdf0e10cSrcweir aParent); 63*cdf0e10cSrcweir break; 64*cdf0e10cSrcweir case 3: 65*cdf0e10cSrcweir com.sun.star.awt.Rectangle aBBox = xComponent.getBounds(); 66*cdf0e10cSrcweir aChild = new StringNode ( 67*cdf0e10cSrcweir "Bounding Box: "+ aBBox.X + ", " + aBBox.Y + "," 68*cdf0e10cSrcweir + aBBox.Width + ", " + aBBox.Height, 69*cdf0e10cSrcweir aParent); 70*cdf0e10cSrcweir break; 71*cdf0e10cSrcweir case 4: 72*cdf0e10cSrcweir nColor = xComponent.getForeground(); 73*cdf0e10cSrcweir aChild = new StringNode ("Foreground color: R" 74*cdf0e10cSrcweir + (nColor>>16&0xff) 75*cdf0e10cSrcweir + "G" + (nColor>>8&0xff) 76*cdf0e10cSrcweir + "B" + (nColor>>0&0xff) 77*cdf0e10cSrcweir + "A" + (nColor>>24&0xff), 78*cdf0e10cSrcweir aParent); 79*cdf0e10cSrcweir break; 80*cdf0e10cSrcweir case 5: 81*cdf0e10cSrcweir nColor = xComponent.getBackground(); 82*cdf0e10cSrcweir aChild = new StringNode ("Background color: R" 83*cdf0e10cSrcweir + (nColor>>16&0xff) 84*cdf0e10cSrcweir + "G" + (nColor>>8&0xff) 85*cdf0e10cSrcweir + "B" + (nColor>>0&0xff) 86*cdf0e10cSrcweir + "A" + (nColor>>24&0xff), 87*cdf0e10cSrcweir aParent); 88*cdf0e10cSrcweir break; 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir return aChild; 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir public void update (AccessibleTreeNode aNode) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir maChildList.clear(); 98*cdf0e10cSrcweir if (aNode instanceof AccTreeNode) 99*cdf0e10cSrcweir if (((AccTreeNode)aNode).getComponent() != null) 100*cdf0e10cSrcweir maChildList.setSize (4); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir } 103