1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_vcl.hxx" 26 27#include "aqua/aqua11yfactory.h" 28 29#include "aqua11ytablewrapper.h" 30 31using namespace ::com::sun::star::accessibility; 32using namespace ::com::sun::star::awt; 33using namespace ::com::sun::star::uno; 34 35@implementation AquaA11yTableWrapper : AquaA11yWrapper 36 37+(id)childrenAttributeForElement:(AquaA11yTableWrapper *)wrapper 38{ 39 XAccessibleTable * accessibleTable = [ wrapper accessibleTable ]; 40 NSArray* pResult = nil; 41 if( accessibleTable ) 42 { 43 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; 44 try 45 { 46 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 47 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); 48 49 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) 50 { 51 // make all children visible to the hierarchy 52 for ( sal_Int32 rowCount = 0; rowCount < nRows; rowCount++ ) 53 { 54 for ( sal_Int32 columnCount = 0; columnCount < nCols; columnCount++ ) 55 { 56 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); 57 if ( rAccessibleCell.is() ) 58 { 59 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; 60 [ cells addObject: cell_wrapper ]; 61 [ cell_wrapper release ]; 62 } 63 } 64 } 65 } 66 else 67 { 68 XAccessibleComponent * accessibleComponent = [ wrapper accessibleComponent ]; 69 // find out which cells are actually visible by determining the top-left-cell and the bottom-right-cell 70 Size tableSize = accessibleComponent -> getSize(); 71 Point point; 72 point.X = 0; 73 point.Y = 0; 74 Reference < XAccessible > rAccessibleTopLeft = accessibleComponent -> getAccessibleAtPoint ( point ); 75 point.X = tableSize.Width - 1; 76 point.Y = tableSize.Height - 1; 77 Reference < XAccessible > rAccessibleBottomRight = accessibleComponent -> getAccessibleAtPoint ( point ); 78 if ( rAccessibleTopLeft.is() && rAccessibleBottomRight.is() ) 79 { 80 sal_Int32 idxTopLeft = rAccessibleTopLeft -> getAccessibleContext() -> getAccessibleIndexInParent(); 81 sal_Int32 idxBottomRight = rAccessibleBottomRight -> getAccessibleContext() -> getAccessibleIndexInParent(); 82 sal_Int32 rowTopLeft = accessibleTable -> getAccessibleRow ( idxTopLeft ); 83 sal_Int32 columnTopLeft = accessibleTable -> getAccessibleColumn ( idxTopLeft ); 84 sal_Int32 rowBottomRight = accessibleTable -> getAccessibleRow ( idxBottomRight ); 85 sal_Int32 columnBottomRight = accessibleTable -> getAccessibleColumn ( idxBottomRight ); 86 // create an array containing the visible cells 87 for ( sal_Int32 rowCount = rowTopLeft; rowCount <= rowBottomRight; rowCount++ ) 88 { 89 for ( sal_Int32 columnCount = columnTopLeft; columnCount <= columnBottomRight; columnCount++ ) 90 { 91 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); 92 if ( rAccessibleCell.is() ) 93 { 94 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; 95 [ cells addObject: cell_wrapper ]; 96 [ cell_wrapper release ]; 97 } 98 } 99 } 100 } 101 } 102 pResult = NSAccessibilityUnignoredChildren( cells ); 103 } 104 catch (const Exception &e) 105 { 106 } 107 [cells autorelease]; 108 } 109 110 return pResult; 111} 112 113+(void)addAttributeNamesTo: (NSMutableArray *)attributeNames object: (AquaA11yWrapper*)pObject 114{ 115 XAccessibleTable * accessibleTable = [ pObject accessibleTable ]; 116 if( accessibleTable ) 117 { 118 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 119 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); 120 121 122 if( nRows*nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) 123 { 124 [ attributeNames addObject: NSAccessibilityRowsAttribute ]; 125 [ attributeNames addObject: NSAccessibilityColumnsAttribute ]; 126 } 127 } 128} 129 130-(id)rowsAttribute 131{ 132 NSArray* pResult = nil; 133 134 XAccessibleTable * accessibleTable = [ self accessibleTable ]; 135 if( accessibleTable ) 136 { 137 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 138 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); 139 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) 140 { 141 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; 142 try 143 { 144 // find out number of rows 145 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 146 for( sal_Int32 n = 0; n < nRows; n++ ) 147 { 148 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( n, 0 ); 149 if ( rAccessibleCell.is() ) 150 { 151 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; 152 [ cells addObject: cell_wrapper ]; 153 [ cell_wrapper release ]; 154 } 155 } 156 pResult = NSAccessibilityUnignoredChildren( cells ); 157 } 158 catch (const Exception &e) 159 { 160 pResult = nil; 161 } 162 [ cells autorelease ]; 163 } 164 } 165 166 return pResult; 167} 168 169-(id)columnsAttribute 170{ 171 NSArray* pResult = nil; 172 173 XAccessibleTable * accessibleTable = [ self accessibleTable ]; 174 175 if( accessibleTable ) 176 { 177 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 178 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); 179 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) 180 { 181 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; 182 try 183 { 184 // find out number of columns 185 for( sal_Int32 n = 0; n < nCols; n++ ) 186 { 187 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( 0, n ); 188 if ( rAccessibleCell.is() ) 189 { 190 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; 191 [ cells addObject: cell_wrapper ]; 192 [ cell_wrapper release ]; 193 } 194 } 195 pResult = NSAccessibilityUnignoredChildren( cells ); 196 } 197 catch (const Exception &e) 198 { 199 pResult = nil; 200 } 201 [ cells autorelease ]; 202 } 203 } 204 205 return pResult; 206} 207 208@end 209