fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / toolkit / test / accessibility / AccessibleCellHandler.java
blobc3a8ab91b689c8626231d979d783d7f4325dbe7b
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import com.sun.star.uno.UnoRuntime;
20 import com.sun.star.accessibility.XAccessibleContext;
21 import com.sun.star.accessibility.XAccessibleTable;
22 import com.sun.star.accessibility.XAccessible;
25 class AccessibleCellHandler extends NodeHandler
27 public NodeHandler createHandler (XAccessibleContext xContext)
29 AccessibleCellHandler aCellHandler = null;
30 if (xContext != null)
32 XAccessible xParent = xContext.getAccessibleParent();
33 if (xParent != null)
35 XAccessibleTable xTable =
36 UnoRuntime.queryInterface (
37 XAccessibleTable.class, xParent.getAccessibleContext());
38 if (xTable != null)
39 aCellHandler = new AccessibleCellHandler (xTable);
42 return aCellHandler;
46 public AccessibleCellHandler ()
50 public AccessibleCellHandler (XAccessibleTable xTable)
52 if (xTable != null)
53 maChildList.setSize (8);
56 protected static XAccessibleTable getTable(Object aObject)
58 return UnoRuntime.queryInterface (
59 XAccessibleTable.class, aObject);
62 public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
64 AccessibleTreeNode aChild = null;
65 XAccessibleTable xTable = null;
66 XAccessibleContext xContext = null;
67 AccessibleTreeNode aGrandParent = aParent.getParent();
68 if (aGrandParent instanceof AccTreeNode)
70 xTable = ((AccTreeNode)aGrandParent).getTable();
71 xContext = ((AccTreeNode)aGrandParent).getContext();
73 if (aParent instanceof AccTreeNode)
75 xContext = ((AccTreeNode)aParent).getContext();
77 try
79 if( xTable != null && xContext != null )
81 switch( nIndex )
83 case 0:
85 int nChild = xContext.getAccessibleIndexInParent();
86 int nRow = xTable.getAccessibleRow( nChild );
88 aChild = new StringNode ("# table row: " + nRow, aParent);
90 break;
91 case 1:
93 int nChild = xContext.getAccessibleIndexInParent();
94 int nCol = xTable.getAccessibleColumn( nChild );
96 aChild = new StringNode ("# table column: " + nCol, aParent);
98 break;
99 case 2:
101 int nChild = xContext.getAccessibleIndexInParent();
102 int nRow = xTable.getAccessibleRow( nChild );
103 int nCol = xTable.getAccessibleColumn( nChild );
104 int nExt = xTable.getAccessibleRowExtentAt( nRow, nCol );
106 aChild = new StringNode ("# table row extend: " + nExt, aParent);
108 break;
109 case 3:
111 int nChild = xContext.getAccessibleIndexInParent();
112 int nRow = xTable.getAccessibleRow( nChild );
113 int nCol = xTable.getAccessibleColumn( nChild );
114 int nExt = xTable.getAccessibleColumnExtentAt( nRow, nCol );
116 aChild = new StringNode ("# table column extend: " + nExt, aParent);
118 break;
119 case 4:
121 int nChild = xContext.getAccessibleIndexInParent();
122 int nRow = xTable.getAccessibleRow( nChild );
123 int nCol = xTable.getAccessibleColumn( nChild );
124 XAccessible xChild =
125 xTable.getAccessibleCellAt( nRow, nCol );
127 aChild = new StringNode ("# cell name retrieved from table: " + xChild.getAccessibleContext().getAccessibleName(), aParent);
129 break;
130 case 5:
132 int nChild = xContext.getAccessibleIndexInParent();
133 int nRow = xTable.getAccessibleRow( nChild );
134 int nCol = xTable.getAccessibleColumn( nChild );
135 boolean bSelected =
136 xTable.isAccessibleSelected( nRow, nCol );
138 aChild = new StringNode ("cell is selected: " + bSelected, aParent);
140 break;
141 case 6:
143 int nChild = xContext.getAccessibleIndexInParent();
144 int nRow = xTable.getAccessibleRow( nChild );
145 boolean bSelected =
146 xTable.isAccessibleRowSelected( nRow );
148 aChild = new StringNode ("table row is selected: " + bSelected, aParent);
150 break;
151 case 7:
153 int nChild = xContext.getAccessibleIndexInParent();
154 int nCol = xTable.getAccessibleColumn( nChild );
155 boolean bSelected =
156 xTable.isAccessibleColumnSelected( nCol );
158 aChild = new StringNode ("table column is selected: " + bSelected, aParent);
160 break;
161 default:
162 aChild = new StringNode ("unknown child index " + nIndex, aParent);
166 catch (Exception e)
168 // Return empty child.
171 return aChild;