1/************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28// MARKER(update_precomp.py): autogen include statement, do not remove 29#include "precompiled_vcl.hxx" 30 31#include "aqua/aqua11yfactory.h" 32 33#include "aqua11ytablewrapper.h" 34 35using namespace ::com::sun::star::accessibility; 36using namespace ::com::sun::star::awt; 37using namespace ::com::sun::star::uno; 38 39@implementation AquaA11yTableWrapper : AquaA11yWrapper 40 41+(id)childrenAttributeForElement:(AquaA11yTableWrapper *)wrapper 42{ 43 XAccessibleTable * accessibleTable = [ wrapper accessibleTable ]; 44 NSArray* pResult = nil; 45 if( accessibleTable ) 46 { 47 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; 48 try 49 { 50 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 51 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); 52 53 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) 54 { 55 // make all children visible to the hierarchy 56 for ( sal_Int32 rowCount = 0; rowCount < nRows; rowCount++ ) 57 { 58 for ( sal_Int32 columnCount = 0; columnCount < nCols; columnCount++ ) 59 { 60 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); 61 if ( rAccessibleCell.is() ) 62 { 63 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; 64 [ cells addObject: cell_wrapper ]; 65 [ cell_wrapper release ]; 66 } 67 } 68 } 69 } 70 else 71 { 72 XAccessibleComponent * accessibleComponent = [ wrapper accessibleComponent ]; 73 // find out which cells are actually visible by determining the top-left-cell and the bottom-right-cell 74 Size tableSize = accessibleComponent -> getSize(); 75 Point point; 76 point.X = 0; 77 point.Y = 0; 78 Reference < XAccessible > rAccessibleTopLeft = accessibleComponent -> getAccessibleAtPoint ( point ); 79 point.X = tableSize.Width - 1; 80 point.Y = tableSize.Height - 1; 81 Reference < XAccessible > rAccessibleBottomRight = accessibleComponent -> getAccessibleAtPoint ( point ); 82 if ( rAccessibleTopLeft.is() && rAccessibleBottomRight.is() ) 83 { 84 sal_Int32 idxTopLeft = rAccessibleTopLeft -> getAccessibleContext() -> getAccessibleIndexInParent(); 85 sal_Int32 idxBottomRight = rAccessibleBottomRight -> getAccessibleContext() -> getAccessibleIndexInParent(); 86 sal_Int32 rowTopLeft = accessibleTable -> getAccessibleRow ( idxTopLeft ); 87 sal_Int32 columnTopLeft = accessibleTable -> getAccessibleColumn ( idxTopLeft ); 88 sal_Int32 rowBottomRight = accessibleTable -> getAccessibleRow ( idxBottomRight ); 89 sal_Int32 columnBottomRight = accessibleTable -> getAccessibleColumn ( idxBottomRight ); 90 // create an array containing the visible cells 91 for ( sal_Int32 rowCount = rowTopLeft; rowCount <= rowBottomRight; rowCount++ ) 92 { 93 for ( sal_Int32 columnCount = columnTopLeft; columnCount <= columnBottomRight; columnCount++ ) 94 { 95 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); 96 if ( rAccessibleCell.is() ) 97 { 98 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; 99 [ cells addObject: cell_wrapper ]; 100 [ cell_wrapper release ]; 101 } 102 } 103 } 104 } 105 } 106 pResult = NSAccessibilityUnignoredChildren( cells ); 107 } 108 catch (const Exception &e) 109 { 110 } 111 [cells autorelease]; 112 } 113 114 return pResult; 115} 116 117+(void)addAttributeNamesTo: (NSMutableArray *)attributeNames object: (AquaA11yWrapper*)pObject 118{ 119 XAccessibleTable * accessibleTable = [ pObject accessibleTable ]; 120 if( accessibleTable ) 121 { 122 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 123 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); 124 125 126 if( nRows*nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) 127 { 128 [ attributeNames addObject: NSAccessibilityRowsAttribute ]; 129 [ attributeNames addObject: NSAccessibilityColumnsAttribute ]; 130 } 131 } 132} 133 134-(id)rowsAttribute 135{ 136 NSArray* pResult = nil; 137 138 XAccessibleTable * accessibleTable = [ self accessibleTable ]; 139 if( accessibleTable ) 140 { 141 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 142 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); 143 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) 144 { 145 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; 146 try 147 { 148 // find out number of rows 149 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 150 for( sal_Int32 n = 0; n < nRows; n++ ) 151 { 152 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( n, 0 ); 153 if ( rAccessibleCell.is() ) 154 { 155 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; 156 [ cells addObject: cell_wrapper ]; 157 [ cell_wrapper release ]; 158 } 159 } 160 pResult = NSAccessibilityUnignoredChildren( cells ); 161 } 162 catch (const Exception &e) 163 { 164 pResult = nil; 165 } 166 [ cells autorelease ]; 167 } 168 } 169 170 return pResult; 171} 172 173-(id)columnsAttribute 174{ 175 NSArray* pResult = nil; 176 177 XAccessibleTable * accessibleTable = [ self accessibleTable ]; 178 179 if( accessibleTable ) 180 { 181 sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); 182 sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); 183 if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) 184 { 185 NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; 186 try 187 { 188 // find out number of columns 189 for( sal_Int32 n = 0; n < nCols; n++ ) 190 { 191 Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( 0, n ); 192 if ( rAccessibleCell.is() ) 193 { 194 id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; 195 [ cells addObject: cell_wrapper ]; 196 [ cell_wrapper release ]; 197 } 198 } 199 pResult = NSAccessibilityUnignoredChildren( cells ); 200 } 201 catch (const Exception &e) 202 { 203 pResult = nil; 204 } 205 [ cells autorelease ]; 206 } 207 } 208 209 return pResult; 210} 211 212@end 213