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
28 public NodeHandler
createHandler (XAccessibleContext xContext
)
33 AccessibleCellHandler aCellHandler
= null;
34 XAccessible xParent
= xContext
.getAccessibleParent();
37 XAccessibleTable xTable
=
38 UnoRuntime
.queryInterface (
39 XAccessibleTable
.class, xParent
.getAccessibleContext());
41 aCellHandler
= new AccessibleCellHandler (xTable
);
46 public AccessibleCellHandler ()
50 private AccessibleCellHandler (XAccessibleTable xTable
)
53 maChildList
.setSize (8);
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();
74 if( xTable
!= null && xContext
!= null )
80 long nChild
= xContext
.getAccessibleIndexInParent();
81 int nRow
= xTable
.getAccessibleRow( nChild
);
83 aChild
= new StringNode ("# table row: " + nRow
, aParent
);
88 long nChild
= xContext
.getAccessibleIndexInParent();
89 int nCol
= xTable
.getAccessibleColumn( nChild
);
91 aChild
= new StringNode ("# table column: " + nCol
, aParent
);
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
);
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
);
116 long nChild
= xContext
.getAccessibleIndexInParent();
117 int nRow
= xTable
.getAccessibleRow( nChild
);
118 int nCol
= xTable
.getAccessibleColumn( nChild
);
120 xTable
.getAccessibleCellAt( nRow
, nCol
);
122 aChild
= new StringNode ("# cell name retrieved from table: " + xChild
.getAccessibleContext().getAccessibleName(), aParent
);
127 int nChild
= xContext
.getAccessibleIndexInParent();
128 int nRow
= xTable
.getAccessibleRow( nChild
);
129 int nCol
= xTable
.getAccessibleColumn( nChild
);
131 xTable
.isAccessibleSelected( nRow
, nCol
);
133 aChild
= new StringNode ("cell is selected: " + bSelected
, aParent
);
138 long nChild
= xContext
.getAccessibleIndexInParent();
139 int nRow
= xTable
.getAccessibleRow( nChild
);
141 xTable
.isAccessibleRowSelected( nRow
);
143 aChild
= new StringNode ("table row is selected: " + bSelected
, aParent
);
148 long nChild
= xContext
.getAccessibleIndexInParent();
149 int nCol
= xTable
.getAccessibleColumn( nChild
);
151 xTable
.isAccessibleColumnSelected( nCol
);
153 aChild
= new StringNode ("table column is selected: " + bSelected
, aParent
);
157 aChild
= new StringNode ("unknown child index " + nIndex
, aParent
);
163 // Return empty child.