1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski import com.sun.star.uno.UnoRuntime; 24*b1cdbd2cSJim Jagielski import com.sun.star.accessibility.XAccessibleContext; 25*b1cdbd2cSJim Jagielski import com.sun.star.accessibility.XAccessibleTable; 26*b1cdbd2cSJim Jagielski import com.sun.star.accessibility.XAccessible; 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski class AccessibleCellHandler extends NodeHandler 30*b1cdbd2cSJim Jagielski { createHandler(XAccessibleContext xContext)31*b1cdbd2cSJim Jagielski public NodeHandler createHandler (XAccessibleContext xContext) 32*b1cdbd2cSJim Jagielski { 33*b1cdbd2cSJim Jagielski AccessibleCellHandler aCellHandler = null; 34*b1cdbd2cSJim Jagielski if (xContext != null) 35*b1cdbd2cSJim Jagielski { 36*b1cdbd2cSJim Jagielski XAccessible xParent = xContext.getAccessibleParent(); 37*b1cdbd2cSJim Jagielski if (xParent != null) 38*b1cdbd2cSJim Jagielski { 39*b1cdbd2cSJim Jagielski XAccessibleTable xTable = 40*b1cdbd2cSJim Jagielski (XAccessibleTable) UnoRuntime.queryInterface ( 41*b1cdbd2cSJim Jagielski XAccessibleTable.class, xParent.getAccessibleContext()); 42*b1cdbd2cSJim Jagielski if (xTable != null) 43*b1cdbd2cSJim Jagielski aCellHandler = new AccessibleCellHandler (xTable); 44*b1cdbd2cSJim Jagielski } 45*b1cdbd2cSJim Jagielski } 46*b1cdbd2cSJim Jagielski return aCellHandler; 47*b1cdbd2cSJim Jagielski 48*b1cdbd2cSJim Jagielski } 49*b1cdbd2cSJim Jagielski AccessibleCellHandler()50*b1cdbd2cSJim Jagielski public AccessibleCellHandler () 51*b1cdbd2cSJim Jagielski { 52*b1cdbd2cSJim Jagielski } 53*b1cdbd2cSJim Jagielski AccessibleCellHandler(XAccessibleTable xTable)54*b1cdbd2cSJim Jagielski public AccessibleCellHandler (XAccessibleTable xTable) 55*b1cdbd2cSJim Jagielski { 56*b1cdbd2cSJim Jagielski if (xTable != null) 57*b1cdbd2cSJim Jagielski maChildList.setSize (8); 58*b1cdbd2cSJim Jagielski } 59*b1cdbd2cSJim Jagielski getTable(Object aObject)60*b1cdbd2cSJim Jagielski protected static XAccessibleTable getTable(Object aObject) 61*b1cdbd2cSJim Jagielski { 62*b1cdbd2cSJim Jagielski return (XAccessibleTable) UnoRuntime.queryInterface ( 63*b1cdbd2cSJim Jagielski XAccessibleTable.class, aObject); 64*b1cdbd2cSJim Jagielski } 65*b1cdbd2cSJim Jagielski createChild(AccessibleTreeNode aParent, int nIndex)66*b1cdbd2cSJim Jagielski public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) 67*b1cdbd2cSJim Jagielski { 68*b1cdbd2cSJim Jagielski AccessibleTreeNode aChild = null; 69*b1cdbd2cSJim Jagielski XAccessibleTable xTable = null; 70*b1cdbd2cSJim Jagielski XAccessibleContext xContext = null; 71*b1cdbd2cSJim Jagielski AccessibleTreeNode aGrandParent = aParent.getParent(); 72*b1cdbd2cSJim Jagielski if (aGrandParent instanceof AccTreeNode) 73*b1cdbd2cSJim Jagielski { 74*b1cdbd2cSJim Jagielski xTable = ((AccTreeNode)aGrandParent).getTable(); 75*b1cdbd2cSJim Jagielski xContext = ((AccTreeNode)aGrandParent).getContext(); 76*b1cdbd2cSJim Jagielski } 77*b1cdbd2cSJim Jagielski if (aParent instanceof AccTreeNode) 78*b1cdbd2cSJim Jagielski { 79*b1cdbd2cSJim Jagielski xContext = ((AccTreeNode)aParent).getContext(); 80*b1cdbd2cSJim Jagielski } 81*b1cdbd2cSJim Jagielski try 82*b1cdbd2cSJim Jagielski { 83*b1cdbd2cSJim Jagielski if( xTable != null && xContext != null ) 84*b1cdbd2cSJim Jagielski { 85*b1cdbd2cSJim Jagielski switch( nIndex ) 86*b1cdbd2cSJim Jagielski { 87*b1cdbd2cSJim Jagielski case 0: 88*b1cdbd2cSJim Jagielski { 89*b1cdbd2cSJim Jagielski int nChild = xContext.getAccessibleIndexInParent(); 90*b1cdbd2cSJim Jagielski int nRow = xTable.getAccessibleRow( nChild ); 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski aChild = new StringNode ("# table row: " + nRow, aParent); 93*b1cdbd2cSJim Jagielski } 94*b1cdbd2cSJim Jagielski break; 95*b1cdbd2cSJim Jagielski case 1: 96*b1cdbd2cSJim Jagielski { 97*b1cdbd2cSJim Jagielski int nChild = xContext.getAccessibleIndexInParent(); 98*b1cdbd2cSJim Jagielski int nCol = xTable.getAccessibleColumn( nChild ); 99*b1cdbd2cSJim Jagielski 100*b1cdbd2cSJim Jagielski aChild = new StringNode ("# table column: " + nCol, aParent); 101*b1cdbd2cSJim Jagielski } 102*b1cdbd2cSJim Jagielski break; 103*b1cdbd2cSJim Jagielski case 2: 104*b1cdbd2cSJim Jagielski { 105*b1cdbd2cSJim Jagielski int nChild = xContext.getAccessibleIndexInParent(); 106*b1cdbd2cSJim Jagielski int nRow = xTable.getAccessibleRow( nChild ); 107*b1cdbd2cSJim Jagielski int nCol = xTable.getAccessibleColumn( nChild ); 108*b1cdbd2cSJim Jagielski int nExt = xTable.getAccessibleRowExtentAt( nRow, nCol ); 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski aChild = new StringNode ("# table row extend: " + nExt, aParent); 111*b1cdbd2cSJim Jagielski } 112*b1cdbd2cSJim Jagielski break; 113*b1cdbd2cSJim Jagielski case 3: 114*b1cdbd2cSJim Jagielski { 115*b1cdbd2cSJim Jagielski int nChild = xContext.getAccessibleIndexInParent(); 116*b1cdbd2cSJim Jagielski int nRow = xTable.getAccessibleRow( nChild ); 117*b1cdbd2cSJim Jagielski int nCol = xTable.getAccessibleColumn( nChild ); 118*b1cdbd2cSJim Jagielski int nExt = xTable.getAccessibleColumnExtentAt( nRow, nCol ); 119*b1cdbd2cSJim Jagielski 120*b1cdbd2cSJim Jagielski aChild = new StringNode ("# table column extend: " + nExt, aParent); 121*b1cdbd2cSJim Jagielski } 122*b1cdbd2cSJim Jagielski break; 123*b1cdbd2cSJim Jagielski case 4: 124*b1cdbd2cSJim Jagielski { 125*b1cdbd2cSJim Jagielski int nChild = xContext.getAccessibleIndexInParent(); 126*b1cdbd2cSJim Jagielski int nRow = xTable.getAccessibleRow( nChild ); 127*b1cdbd2cSJim Jagielski int nCol = xTable.getAccessibleColumn( nChild ); 128*b1cdbd2cSJim Jagielski XAccessible xChild = 129*b1cdbd2cSJim Jagielski xTable.getAccessibleCellAt( nRow, nCol ); 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim Jagielski aChild = new StringNode ("# cell name retrieved from table: " + xChild.getAccessibleContext().getAccessibleName(), aParent); 132*b1cdbd2cSJim Jagielski } 133*b1cdbd2cSJim Jagielski break; 134*b1cdbd2cSJim Jagielski case 5: 135*b1cdbd2cSJim Jagielski { 136*b1cdbd2cSJim Jagielski int nChild = xContext.getAccessibleIndexInParent(); 137*b1cdbd2cSJim Jagielski int nRow = xTable.getAccessibleRow( nChild ); 138*b1cdbd2cSJim Jagielski int nCol = xTable.getAccessibleColumn( nChild ); 139*b1cdbd2cSJim Jagielski boolean bSelected = 140*b1cdbd2cSJim Jagielski xTable.isAccessibleSelected( nRow, nCol ); 141*b1cdbd2cSJim Jagielski 142*b1cdbd2cSJim Jagielski aChild = new StringNode ("cell is selected: " + bSelected, aParent); 143*b1cdbd2cSJim Jagielski } 144*b1cdbd2cSJim Jagielski break; 145*b1cdbd2cSJim Jagielski case 6: 146*b1cdbd2cSJim Jagielski { 147*b1cdbd2cSJim Jagielski int nChild = xContext.getAccessibleIndexInParent(); 148*b1cdbd2cSJim Jagielski int nRow = xTable.getAccessibleRow( nChild ); 149*b1cdbd2cSJim Jagielski boolean bSelected = 150*b1cdbd2cSJim Jagielski xTable.isAccessibleRowSelected( nRow ); 151*b1cdbd2cSJim Jagielski 152*b1cdbd2cSJim Jagielski aChild = new StringNode ("table row is selected: " + bSelected, aParent); 153*b1cdbd2cSJim Jagielski } 154*b1cdbd2cSJim Jagielski break; 155*b1cdbd2cSJim Jagielski case 7: 156*b1cdbd2cSJim Jagielski { 157*b1cdbd2cSJim Jagielski int nChild = xContext.getAccessibleIndexInParent(); 158*b1cdbd2cSJim Jagielski int nCol = xTable.getAccessibleColumn( nChild ); 159*b1cdbd2cSJim Jagielski boolean bSelected = 160*b1cdbd2cSJim Jagielski xTable.isAccessibleColumnSelected( nCol ); 161*b1cdbd2cSJim Jagielski 162*b1cdbd2cSJim Jagielski aChild = new StringNode ("table column is selected: " + bSelected, aParent); 163*b1cdbd2cSJim Jagielski } 164*b1cdbd2cSJim Jagielski break; 165*b1cdbd2cSJim Jagielski default: 166*b1cdbd2cSJim Jagielski aChild = new StringNode ("unknown child index " + nIndex, aParent); 167*b1cdbd2cSJim Jagielski } 168*b1cdbd2cSJim Jagielski } 169*b1cdbd2cSJim Jagielski } 170*b1cdbd2cSJim Jagielski catch (Exception e) 171*b1cdbd2cSJim Jagielski { 172*b1cdbd2cSJim Jagielski // Return empty child. 173*b1cdbd2cSJim Jagielski } 174*b1cdbd2cSJim Jagielski 175*b1cdbd2cSJim Jagielski return aChild; 176*b1cdbd2cSJim Jagielski } 177*b1cdbd2cSJim Jagielski } 178