merged tag ooo/DEV300_m102
[LibreOffice.git] / toolkit / test / accessibility / AccessibleTableHandler.java
blobc3883f649d5ec1fa466cc5048cf51ae1f8337b6e
2 import com.sun.star.uno.UnoRuntime;
3 import com.sun.star.accessibility.XAccessibleContext;
4 import com.sun.star.accessibility.XAccessibleTable;
7 class AccessibleTableHandler extends NodeHandler
9 public NodeHandler createHandler (XAccessibleContext xContext)
11 XAccessibleTable xTable =
12 (XAccessibleTable) UnoRuntime.queryInterface (
13 XAccessibleTable.class, xContext);
14 if (xTable != null)
15 return new AccessibleTableHandler (xTable);
16 else
17 return null;
20 public AccessibleTableHandler ()
24 public AccessibleTableHandler (XAccessibleTable xTable)
26 if (xTable != null)
27 maChildList.setSize (4);
30 protected static XAccessibleTable getTable(Object aObject)
32 return (XAccessibleTable) UnoRuntime.queryInterface (
33 XAccessibleTable.class, aObject);
36 public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
38 AccessibleTreeNode aChild = null;
39 XAccessibleTable xTable = null;
40 if (aParent instanceof AccTreeNode)
41 xTable = ((AccTreeNode)aParent).getTable();
42 try
44 if( xTable != null )
46 switch( nIndex )
48 case 0:
49 aChild = new StringNode ("# table rows: " + xTable.getAccessibleRowCount(), aParent);
50 break;
51 case 1:
52 aChild = new StringNode ("# table columns: " + xTable.getAccessibleColumnCount(), aParent);
53 break;
54 case 2:
56 String sText = "selected rows: ";
57 int[] aSelected = xTable.getSelectedAccessibleRows();
58 for( int i=0; i < aSelected.length; i++ )
60 sText += aSelected[i];
61 sText += " ";
63 aChild = new StringNode (sText, aParent);
65 break;
66 case 3:
68 String sText = "selected columns: ";
69 int[] aSelected = xTable.getSelectedAccessibleColumns();
70 for( int i=0; i < aSelected.length; i++ )
72 sText += aSelected[i];
73 sText += " ";
75 aChild = new StringNode (sText, aParent);
77 break;
78 default:
79 aChild = new StringNode ("unknown child index " + nIndex, aParent);
83 catch (Exception e)
85 // Return empty child.
88 return aChild;