1*1b0aaa91SAndrew Rist /************************************************************** 2*1b0aaa91SAndrew Rist * 3*1b0aaa91SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1b0aaa91SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1b0aaa91SAndrew Rist * distributed with this work for additional information 6*1b0aaa91SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1b0aaa91SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1b0aaa91SAndrew Rist * "License"); you may not use this file except in compliance 9*1b0aaa91SAndrew Rist * with the License. You may obtain a copy of the License at 10*1b0aaa91SAndrew Rist * 11*1b0aaa91SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1b0aaa91SAndrew Rist * 13*1b0aaa91SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1b0aaa91SAndrew Rist * software distributed under the License is distributed on an 15*1b0aaa91SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1b0aaa91SAndrew Rist * KIND, either express or implied. See the License for the 17*1b0aaa91SAndrew Rist * specific language governing permissions and limitations 18*1b0aaa91SAndrew Rist * under the License. 19*1b0aaa91SAndrew Rist * 20*1b0aaa91SAndrew Rist *************************************************************/ 21*1b0aaa91SAndrew Rist 22cdf0e10cSrcweir 23cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 24cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleContext; 25cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleComponent; 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir class AccessibleComponentHandler 29cdf0e10cSrcweir extends NodeHandler 30cdf0e10cSrcweir { 31cdf0e10cSrcweir createHandler(XAccessibleContext xContext)32cdf0e10cSrcweir public NodeHandler createHandler (XAccessibleContext xContext) 33cdf0e10cSrcweir { 34cdf0e10cSrcweir XAccessibleComponent xComponent = 35cdf0e10cSrcweir (XAccessibleComponent) UnoRuntime.queryInterface ( 36cdf0e10cSrcweir XAccessibleComponent.class, xContext); 37cdf0e10cSrcweir if (xComponent != null) 38cdf0e10cSrcweir return new AccessibleComponentHandler (xComponent); 39cdf0e10cSrcweir else 40cdf0e10cSrcweir return null; 41cdf0e10cSrcweir 42cdf0e10cSrcweir } 43cdf0e10cSrcweir AccessibleComponentHandler()44cdf0e10cSrcweir public AccessibleComponentHandler () 45cdf0e10cSrcweir { 46cdf0e10cSrcweir } 47cdf0e10cSrcweir AccessibleComponentHandler(XAccessibleComponent xComponent)48cdf0e10cSrcweir public AccessibleComponentHandler (XAccessibleComponent xComponent) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir if (xComponent != null) 51cdf0e10cSrcweir maChildList.setSize (6); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir createChild(AccessibleTreeNode aParent, int nIndex)54cdf0e10cSrcweir public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir AccessibleTreeNode aChild = null; 57cdf0e10cSrcweir if (aParent instanceof AccTreeNode) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir XAccessibleComponent xComponent = 60cdf0e10cSrcweir ((AccTreeNode)aParent).getComponent(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir if (xComponent != null) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir int nColor; 65cdf0e10cSrcweir switch (nIndex) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir case 0: 68cdf0e10cSrcweir com.sun.star.awt.Point aLocation = xComponent.getLocation(); 69cdf0e10cSrcweir aChild = new StringNode ( 70cdf0e10cSrcweir "Location: " + aLocation.X + ", " + aLocation.Y, 71cdf0e10cSrcweir aParent); 72cdf0e10cSrcweir break; 73cdf0e10cSrcweir case 1: 74cdf0e10cSrcweir com.sun.star.awt.Point aScreenLocation = xComponent.getLocationOnScreen(); 75cdf0e10cSrcweir aChild = new StringNode ( 76cdf0e10cSrcweir "Location on Screen: " + aScreenLocation.X + ", " + aScreenLocation.Y, 77cdf0e10cSrcweir aParent); 78cdf0e10cSrcweir break; 79cdf0e10cSrcweir case 2: 80cdf0e10cSrcweir com.sun.star.awt.Size aSize = xComponent.getSize(); 81cdf0e10cSrcweir aChild = new StringNode ( 82cdf0e10cSrcweir "Size: "+ aSize.Width + ", " + aSize.Height, 83cdf0e10cSrcweir aParent); 84cdf0e10cSrcweir break; 85cdf0e10cSrcweir case 3: 86cdf0e10cSrcweir com.sun.star.awt.Rectangle aBBox = xComponent.getBounds(); 87cdf0e10cSrcweir aChild = new StringNode ( 88cdf0e10cSrcweir "Bounding Box: "+ aBBox.X + ", " + aBBox.Y + "," 89cdf0e10cSrcweir + aBBox.Width + ", " + aBBox.Height, 90cdf0e10cSrcweir aParent); 91cdf0e10cSrcweir break; 92cdf0e10cSrcweir case 4: 93cdf0e10cSrcweir nColor = xComponent.getForeground(); 94cdf0e10cSrcweir aChild = new StringNode ("Foreground color: R" 95cdf0e10cSrcweir + (nColor>>16&0xff) 96cdf0e10cSrcweir + "G" + (nColor>>8&0xff) 97cdf0e10cSrcweir + "B" + (nColor>>0&0xff) 98cdf0e10cSrcweir + "A" + (nColor>>24&0xff), 99cdf0e10cSrcweir aParent); 100cdf0e10cSrcweir break; 101cdf0e10cSrcweir case 5: 102cdf0e10cSrcweir nColor = xComponent.getBackground(); 103cdf0e10cSrcweir aChild = new StringNode ("Background color: R" 104cdf0e10cSrcweir + (nColor>>16&0xff) 105cdf0e10cSrcweir + "G" + (nColor>>8&0xff) 106cdf0e10cSrcweir + "B" + (nColor>>0&0xff) 107cdf0e10cSrcweir + "A" + (nColor>>24&0xff), 108cdf0e10cSrcweir aParent); 109cdf0e10cSrcweir break; 110cdf0e10cSrcweir } 111cdf0e10cSrcweir } 112cdf0e10cSrcweir } 113cdf0e10cSrcweir return aChild; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir update(AccessibleTreeNode aNode)116cdf0e10cSrcweir public void update (AccessibleTreeNode aNode) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir maChildList.clear(); 119cdf0e10cSrcweir if (aNode instanceof AccTreeNode) 120cdf0e10cSrcweir if (((AccTreeNode)aNode).getComponent() != null) 121cdf0e10cSrcweir maChildList.setSize (4); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir } 124