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 import com.sun.star.accessibility.XAccessible; 23cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleContext; 24cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleStateSet; 25cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 26cdf0e10cSrcweir import com.sun.star.container.XIndexAccess; 27cdf0e10cSrcweir import java.util.HashMap; 28cdf0e10cSrcweir 29cdf0e10cSrcweir import tools.NameProvider; 30cdf0e10cSrcweir 31cdf0e10cSrcweir class AccessibleContextHandler 32cdf0e10cSrcweir extends NodeHandler 33cdf0e10cSrcweir { 34cdf0e10cSrcweir protected int nChildrenCount; 35cdf0e10cSrcweir createHandler(XAccessibleContext xContext)36cdf0e10cSrcweir public NodeHandler createHandler (XAccessibleContext xContext) 37cdf0e10cSrcweir { 38cdf0e10cSrcweir if (xContext != null) 39cdf0e10cSrcweir return new AccessibleContextHandler (xContext); 40cdf0e10cSrcweir else 41cdf0e10cSrcweir return null; 42cdf0e10cSrcweir } 43cdf0e10cSrcweir AccessibleContextHandler()44cdf0e10cSrcweir public AccessibleContextHandler () 45cdf0e10cSrcweir { 46cdf0e10cSrcweir super (); 47cdf0e10cSrcweir } 48cdf0e10cSrcweir AccessibleContextHandler(XAccessibleContext xContext)49cdf0e10cSrcweir public AccessibleContextHandler (XAccessibleContext xContext) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir super(); 52cdf0e10cSrcweir if (xContext != null) 53cdf0e10cSrcweir maChildList.setSize (4); 54cdf0e10cSrcweir } 55cdf0e10cSrcweir createChild(AccessibleTreeNode aParent, int nIndex)56cdf0e10cSrcweir public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir XAccessibleContext xContext = null; 59cdf0e10cSrcweir if (aParent instanceof AccTreeNode) 60cdf0e10cSrcweir xContext = ((AccTreeNode)aParent).getContext(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir String sChild = new String(); 63cdf0e10cSrcweir if (xContext != null) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir switch( nIndex ) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir case 0: 68cdf0e10cSrcweir sChild = "Description: " + 69cdf0e10cSrcweir xContext.getAccessibleDescription(); 70cdf0e10cSrcweir break; 71cdf0e10cSrcweir case 1: 72cdf0e10cSrcweir int nRole = xContext.getAccessibleRole(); 73cdf0e10cSrcweir sChild = "Role: " + nRole + " (" + NameProvider.getRoleName(nRole) + ")"; 74cdf0e10cSrcweir break; 75cdf0e10cSrcweir case 2: 76cdf0e10cSrcweir XAccessible xParent = xContext.getAccessibleParent(); 77cdf0e10cSrcweir sChild = "Has parent: " + (xParent!=null ? "yes" : "no"); 78cdf0e10cSrcweir /* if (xParent != ((AccTreeNode)aParent).getAccessible()) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir sChild += " but that is inconsistent" 81cdf0e10cSrcweir + "#" + xParent + " # " + ((AccTreeNode)aParent).getAccessible(); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir */ 84cdf0e10cSrcweir break; 85cdf0e10cSrcweir case 3: 86cdf0e10cSrcweir sChild = ""; 87cdf0e10cSrcweir XAccessibleStateSet xStateSet = 88cdf0e10cSrcweir xContext.getAccessibleStateSet(); 89cdf0e10cSrcweir if (xStateSet != null) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir for (short i=0; i<=30; i++) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir if (xStateSet.contains (i)) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir if (sChild.compareTo ("") != 0) 96cdf0e10cSrcweir sChild += ", "; 97cdf0e10cSrcweir sChild += NameProvider.getStateName(i); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir } 100cdf0e10cSrcweir } 101cdf0e10cSrcweir else 102cdf0e10cSrcweir sChild += "no state set"; 103cdf0e10cSrcweir sChild = "State set: " + sChild; 104cdf0e10cSrcweir 105cdf0e10cSrcweir /* case 3: 106cdf0e10cSrcweir sChild = "Child count: " + xContext.getAccessibleChildCount(); 107cdf0e10cSrcweir break;*/ 108cdf0e10cSrcweir } 109cdf0e10cSrcweir } 110cdf0e10cSrcweir return new StringNode (sChild, aParent); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir } 113