1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <osx/a11yfactory.h>
23 #include "a11ytablewrapper.h"
25 using namespace ::com::sun::star::accessibility;
26 using namespace ::com::sun::star::awt;
27 using namespace ::com::sun::star::uno;
29 @implementation AquaA11yTableWrapper : AquaA11yWrapper
31 +(id)childrenAttributeForElement:(AquaA11yTableWrapper *)wrapper
33 XAccessibleTable * accessibleTable = [ wrapper accessibleTable ];
34 NSArray* pResult = nil;
37 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ];
40 sal_Int32 nRows = accessibleTable->getAccessibleRowCount();
41 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount();
43 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS )
45 // make all children visible to the hierarchy
46 for ( sal_Int32 rowCount = 0; rowCount < nRows; rowCount++ )
48 for ( sal_Int32 columnCount = 0; columnCount < nCols; columnCount++ )
50 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount );
51 if ( rAccessibleCell.is() )
53 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ];
54 [ cells addObject: cell_wrapper ];
55 [ cell_wrapper release ];
62 XAccessibleComponent * accessibleComponent = [ wrapper accessibleComponent ];
63 // find out which cells are actually visible by determining the top-left-cell and the bottom-right-cell
64 Size tableSize = accessibleComponent -> getSize();
68 Reference < XAccessible > rAccessibleTopLeft = accessibleComponent -> getAccessibleAtPoint ( point );
69 point.X = tableSize.Width - 1;
70 point.Y = tableSize.Height - 1;
71 Reference < XAccessible > rAccessibleBottomRight = accessibleComponent -> getAccessibleAtPoint ( point );
72 if ( rAccessibleTopLeft.is() && rAccessibleBottomRight.is() )
74 sal_Int64 idxTopLeft = rAccessibleTopLeft -> getAccessibleContext() -> getAccessibleIndexInParent();
75 sal_Int64 idxBottomRight = rAccessibleBottomRight -> getAccessibleContext() -> getAccessibleIndexInParent();
76 sal_Int32 rowTopLeft = accessibleTable -> getAccessibleRow ( idxTopLeft );
77 sal_Int32 columnTopLeft = accessibleTable -> getAccessibleColumn ( idxTopLeft );
78 sal_Int32 rowBottomRight = accessibleTable -> getAccessibleRow ( idxBottomRight );
79 sal_Int32 columnBottomRight = accessibleTable -> getAccessibleColumn ( idxBottomRight );
80 // create an array containing the visible cells
81 for ( sal_Int32 rowCount = rowTopLeft; rowCount <= rowBottomRight; rowCount++ )
83 for ( sal_Int32 columnCount = columnTopLeft; columnCount <= columnBottomRight; columnCount++ )
85 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount );
86 if ( rAccessibleCell.is() )
88 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ];
89 [ cells addObject: cell_wrapper ];
90 [ cell_wrapper release ];
96 pResult = NSAccessibilityUnignoredChildren( cells );
98 catch (const Exception &)
107 +(void)addAttributeNamesTo: (NSMutableArray *)attributeNames object: (AquaA11yWrapper*)pObject
109 XAccessibleTable * accessibleTable = [ pObject accessibleTable ];
110 if( accessibleTable )
112 sal_Int32 nRows = accessibleTable->getAccessibleRowCount();
113 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount();
116 if( nRows*nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS )
118 [ attributeNames addObject: NSAccessibilityRowsAttribute ];
119 [ attributeNames addObject: NSAccessibilityColumnsAttribute ];
126 NSArray* pResult = nil;
128 XAccessibleTable * accessibleTable = [ self accessibleTable ];
129 if( accessibleTable )
131 sal_Int32 nRows = accessibleTable->getAccessibleRowCount();
132 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount();
133 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS )
135 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ];
138 for( sal_Int32 n = 0; n < nRows; n++ )
140 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( n, 0 );
141 if ( rAccessibleCell.is() )
143 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ];
144 [ cells addObject: cell_wrapper ];
145 [ cell_wrapper release ];
148 pResult = NSAccessibilityUnignoredChildren( cells );
150 catch (const Exception &)
154 [ cells autorelease ];
161 -(id)columnsAttribute
163 NSArray* pResult = nil;
165 XAccessibleTable * accessibleTable = [ self accessibleTable ];
167 if( accessibleTable )
169 sal_Int32 nRows = accessibleTable->getAccessibleRowCount();
170 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount();
171 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS )
173 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ];
176 // find out number of columns
177 for( sal_Int32 n = 0; n < nCols; n++ )
179 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( 0, n );
180 if ( rAccessibleCell.is() )
182 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ];
183 [ cells addObject: cell_wrapper ];
184 [ cell_wrapper release ];
187 pResult = NSAccessibilityUnignoredChildren( cells );
189 catch (const Exception &)
193 [ cells autorelease ];
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */