tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / toolkit / test / accessibility / AccessibleCellHandler.java
blob716e1374ef4a1955e48d6788cd82f78e9b49d867
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 @Override
28 public NodeHandler createHandler (XAccessibleContext xContext)
30 if (xContext == null)
31 return null;
33 AccessibleCellHandler aCellHandler = null;
34 XAccessible xParent = xContext.getAccessibleParent();
35 if (xParent != null)
37 XAccessibleTable xTable =
38 UnoRuntime.queryInterface (
39 XAccessibleTable.class, xParent.getAccessibleContext());
40 if (xTable != null)
41 aCellHandler = new AccessibleCellHandler (xTable);
43 return aCellHandler;
46 public AccessibleCellHandler ()
50 private AccessibleCellHandler (XAccessibleTable xTable)
52 if (xTable != null)
53 maChildList.setSize (8);
56 @Override
57 public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
59 AccessibleTreeNode aChild = null;
60 XAccessibleTable xTable = null;
61 XAccessibleContext xContext = null;
62 AccessibleTreeNode aGrandParent = aParent.getParent();
63 if (aGrandParent instanceof AccTreeNode)
65 xTable = ((AccTreeNode)aGrandParent).getTable();
66 xContext = ((AccTreeNode)aGrandParent).getContext();
68 if (aParent instanceof AccTreeNode)
70 xContext = ((AccTreeNode)aParent).getContext();
72 try
74 if( xTable != null && xContext != null )
76 switch( nIndex )
78 case 0:
80 long nChild = xContext.getAccessibleIndexInParent();
81 int nRow = xTable.getAccessibleRow( nChild );
83 aChild = new StringNode ("# table row: " + nRow, aParent);
85 break;
86 case 1:
88 long nChild = xContext.getAccessibleIndexInParent();
89 int nCol = xTable.getAccessibleColumn( nChild );
91 aChild = new StringNode ("# table column: " + nCol, aParent);
93 break;
94 case 2:
96 long nChild = xContext.getAccessibleIndexInParent();
97 int nRow = xTable.getAccessibleRow( nChild );
98 int nCol = xTable.getAccessibleColumn( nChild );
99 int nExt = xTable.getAccessibleRowExtentAt( nRow, nCol );
101 aChild = new StringNode ("# table row extend: " + nExt, aParent);
103 break;
104 case 3:
106 long nChild = xContext.getAccessibleIndexInParent();
107 int nRow = xTable.getAccessibleRow( nChild );
108 int nCol = xTable.getAccessibleColumn( nChild );
109 int nExt = xTable.getAccessibleColumnExtentAt( nRow, nCol );
111 aChild = new StringNode ("# table column extend: " + nExt, aParent);
113 break;
114 case 4:
116 long nChild = xContext.getAccessibleIndexInParent();
117 int nRow = xTable.getAccessibleRow( nChild );
118 int nCol = xTable.getAccessibleColumn( nChild );
119 XAccessible xChild =
120 xTable.getAccessibleCellAt( nRow, nCol );
122 aChild = new StringNode ("# cell name retrieved from table: " + xChild.getAccessibleContext().getAccessibleName(), aParent);
124 break;
125 case 5:
127 int nChild = xContext.getAccessibleIndexInParent();
128 int nRow = xTable.getAccessibleRow( nChild );
129 int nCol = xTable.getAccessibleColumn( nChild );
130 boolean bSelected =
131 xTable.isAccessibleSelected( nRow, nCol );
133 aChild = new StringNode ("cell is selected: " + bSelected, aParent);
135 break;
136 case 6:
138 long nChild = xContext.getAccessibleIndexInParent();
139 int nRow = xTable.getAccessibleRow( nChild );
140 boolean bSelected =
141 xTable.isAccessibleRowSelected( nRow );
143 aChild = new StringNode ("table row is selected: " + bSelected, aParent);
145 break;
146 case 7:
148 long nChild = xContext.getAccessibleIndexInParent();
149 int nCol = xTable.getAccessibleColumn( nChild );
150 boolean bSelected =
151 xTable.isAccessibleColumnSelected( nCol );
153 aChild = new StringNode ("table column is selected: " + bSelected, aParent);
155 break;
156 default:
157 aChild = new StringNode ("unknown child index " + nIndex, aParent);
161 catch (Exception e)
163 // Return empty child.
166 return aChild;