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