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;
32 XAccessible xParent
= xContext
.getAccessibleParent();
35 XAccessibleTable xTable
=
36 UnoRuntime
.queryInterface (
37 XAccessibleTable
.class, xParent
.getAccessibleContext());
39 aCellHandler
= new AccessibleCellHandler (xTable
);
46 public AccessibleCellHandler ()
50 public AccessibleCellHandler (XAccessibleTable xTable
)
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();
79 if( xTable
!= null && xContext
!= null )
85 int nChild
= xContext
.getAccessibleIndexInParent();
86 int nRow
= xTable
.getAccessibleRow( nChild
);
88 aChild
= new StringNode ("# table row: " + nRow
, aParent
);
93 int nChild
= xContext
.getAccessibleIndexInParent();
94 int nCol
= xTable
.getAccessibleColumn( nChild
);
96 aChild
= new StringNode ("# table column: " + nCol
, aParent
);
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
);
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
);
121 int nChild
= xContext
.getAccessibleIndexInParent();
122 int nRow
= xTable
.getAccessibleRow( nChild
);
123 int nCol
= xTable
.getAccessibleColumn( nChild
);
125 xTable
.getAccessibleCellAt( nRow
, nCol
);
127 aChild
= new StringNode ("# cell name retrieved from table: " + xChild
.getAccessibleContext().getAccessibleName(), aParent
);
132 int nChild
= xContext
.getAccessibleIndexInParent();
133 int nRow
= xTable
.getAccessibleRow( nChild
);
134 int nCol
= xTable
.getAccessibleColumn( nChild
);
136 xTable
.isAccessibleSelected( nRow
, nCol
);
138 aChild
= new StringNode ("cell is selected: " + bSelected
, aParent
);
143 int nChild
= xContext
.getAccessibleIndexInParent();
144 int nRow
= xTable
.getAccessibleRow( nChild
);
146 xTable
.isAccessibleRowSelected( nRow
);
148 aChild
= new StringNode ("table row is selected: " + bSelected
, aParent
);
153 int nChild
= xContext
.getAccessibleIndexInParent();
154 int nCol
= xTable
.getAccessibleColumn( nChild
);
156 xTable
.isAccessibleColumnSelected( nCol
);
158 aChild
= new StringNode ("table column is selected: " + bSelected
, aParent
);
162 aChild
= new StringNode ("unknown child index " + nIndex
, aParent
);
168 // Return empty child.