merged tag ooo/DEV300_m102
[LibreOffice.git] / toolkit / test / accessibility / AccessibleComponentHandler.java
blob38e5545d23aacbda3798159bddab8d8e86ee0f01
2 import com.sun.star.uno.UnoRuntime;
3 import com.sun.star.accessibility.XAccessibleContext;
4 import com.sun.star.accessibility.XAccessibleComponent;
7 class AccessibleComponentHandler
8 extends NodeHandler
11 public NodeHandler createHandler (XAccessibleContext xContext)
13 XAccessibleComponent xComponent =
14 (XAccessibleComponent) UnoRuntime.queryInterface (
15 XAccessibleComponent.class, xContext);
16 if (xComponent != null)
17 return new AccessibleComponentHandler (xComponent);
18 else
19 return null;
23 public AccessibleComponentHandler ()
27 public AccessibleComponentHandler (XAccessibleComponent xComponent)
29 if (xComponent != null)
30 maChildList.setSize (6);
33 public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
35 AccessibleTreeNode aChild = null;
36 if (aParent instanceof AccTreeNode)
38 XAccessibleComponent xComponent =
39 ((AccTreeNode)aParent).getComponent();
41 if (xComponent != null)
43 int nColor;
44 switch (nIndex)
46 case 0:
47 com.sun.star.awt.Point aLocation = xComponent.getLocation();
48 aChild = new StringNode (
49 "Location: " + aLocation.X + ", " + aLocation.Y,
50 aParent);
51 break;
52 case 1:
53 com.sun.star.awt.Point aScreenLocation = xComponent.getLocationOnScreen();
54 aChild = new StringNode (
55 "Location on Screen: " + aScreenLocation.X + ", " + aScreenLocation.Y,
56 aParent);
57 break;
58 case 2:
59 com.sun.star.awt.Size aSize = xComponent.getSize();
60 aChild = new StringNode (
61 "Size: "+ aSize.Width + ", " + aSize.Height,
62 aParent);
63 break;
64 case 3:
65 com.sun.star.awt.Rectangle aBBox = xComponent.getBounds();
66 aChild = new StringNode (
67 "Bounding Box: "+ aBBox.X + ", " + aBBox.Y + ","
68 + aBBox.Width + ", " + aBBox.Height,
69 aParent);
70 break;
71 case 4:
72 nColor = xComponent.getForeground();
73 aChild = new StringNode ("Foreground color: R"
74 + (nColor>>16&0xff)
75 + "G" + (nColor>>8&0xff)
76 + "B" + (nColor>>0&0xff)
77 + "A" + (nColor>>24&0xff),
78 aParent);
79 break;
80 case 5:
81 nColor = xComponent.getBackground();
82 aChild = new StringNode ("Background color: R"
83 + (nColor>>16&0xff)
84 + "G" + (nColor>>8&0xff)
85 + "B" + (nColor>>0&0xff)
86 + "A" + (nColor>>24&0xff),
87 aParent);
88 break;
92 return aChild;
95 public void update (AccessibleTreeNode aNode)
97 maChildList.clear();
98 if (aNode instanceof AccTreeNode)
99 if (((AccTreeNode)aNode).getComponent() != null)
100 maChildList.setSize (4);