1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_vcl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "atkwrapper.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleTable.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #ifdef ENABLE_TRACING 36*cdf0e10cSrcweir #include <stdio.h> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir using namespace ::com::sun::star; 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir static inline AtkObject * 42*cdf0e10cSrcweir atk_object_wrapper_conditional_ref( const uno::Reference< accessibility::XAccessible >& rxAccessible ) 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir #ifdef ENABLE_TRACING 45*cdf0e10cSrcweir fprintf( stderr, ": %p\n", rxAccessible.get() ); 46*cdf0e10cSrcweir #endif 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir if( rxAccessible.is() ) 49*cdf0e10cSrcweir return atk_object_wrapper_ref( rxAccessible ); 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir return NULL; 52*cdf0e10cSrcweir } 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir /*****************************************************************************/ 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir // FIXME 57*cdf0e10cSrcweir static G_CONST_RETURN gchar * 58*cdf0e10cSrcweir getAsConst( rtl::OUString rString ) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir static const int nMax = 10; 61*cdf0e10cSrcweir static rtl::OString aUgly[nMax]; 62*cdf0e10cSrcweir static int nIdx = 0; 63*cdf0e10cSrcweir nIdx = (nIdx + 1) % nMax; 64*cdf0e10cSrcweir aUgly[nIdx] = rtl::OUStringToOString( rString, RTL_TEXTENCODING_UTF8 ); 65*cdf0e10cSrcweir return aUgly[ nIdx ]; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir /*****************************************************************************/ 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir static accessibility::XAccessibleTable* 71*cdf0e10cSrcweir getTable( AtkTable *pTable ) throw (uno::RuntimeException) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pTable ); 74*cdf0e10cSrcweir if( pWrap ) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir if( !pWrap->mpTable && pWrap->mpContext ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir uno::Any any = pWrap->mpContext->queryInterface( accessibility::XAccessibleTable::static_type(NULL) ); 79*cdf0e10cSrcweir pWrap->mpTable = reinterpret_cast< accessibility::XAccessibleTable * > (any.pReserved); 80*cdf0e10cSrcweir pWrap->mpTable->acquire(); 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir return pWrap->mpTable; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir return NULL; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir /*****************************************************************************/ 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir extern "C" { 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir static AtkObject* 94*cdf0e10cSrcweir table_wrapper_ref_at (AtkTable *table, 95*cdf0e10cSrcweir gint row, 96*cdf0e10cSrcweir gint column) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir try { 99*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir #ifdef ENABLE_TRACING 102*cdf0e10cSrcweir if( pTable ) 103*cdf0e10cSrcweir fprintf(stderr, "getAccessibleCellAt( %u, %u ) returns", row, column ); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir if( column >= 255 ) 106*cdf0e10cSrcweir fprintf(stderr, "getAccessibleCellAt( %u, %u ) returns", row, column ); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir #endif 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir if( pTable ) 111*cdf0e10cSrcweir return atk_object_wrapper_conditional_ref( pTable->getAccessibleCellAt( row, column ) ); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir catch(const uno::Exception& e) { 115*cdf0e10cSrcweir g_warning( "Exception in getAccessibleCellAt()" ); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir return NULL; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir /*****************************************************************************/ 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir static gint 124*cdf0e10cSrcweir table_wrapper_get_index_at (AtkTable *table, 125*cdf0e10cSrcweir gint row, 126*cdf0e10cSrcweir gint column) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir try { 129*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir #ifdef ENABLE_TRACING 132*cdf0e10cSrcweir if( pTable ) 133*cdf0e10cSrcweir fprintf(stderr, "getAccessibleIndex( %u, %u ) returns %u\n", 134*cdf0e10cSrcweir row, column, pTable->getAccessibleIndex( row, column ) ); 135*cdf0e10cSrcweir #endif 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir if( pTable ) 138*cdf0e10cSrcweir return pTable->getAccessibleIndex( row, column ); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir catch(const uno::Exception& e) { 141*cdf0e10cSrcweir g_warning( "Exception in getAccessibleIndex()" ); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir return -1; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir /*****************************************************************************/ 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir static gint 150*cdf0e10cSrcweir table_wrapper_get_column_at_index (AtkTable *table, 151*cdf0e10cSrcweir gint nIndex) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir try { 154*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir #ifdef ENABLE_TRACING 157*cdf0e10cSrcweir if( pTable ) 158*cdf0e10cSrcweir fprintf(stderr, "getAccessibleColumn( %u ) returns %u\n", 159*cdf0e10cSrcweir nIndex, pTable->getAccessibleColumn( nIndex ) ); 160*cdf0e10cSrcweir #endif 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir if( pTable ) 163*cdf0e10cSrcweir return pTable->getAccessibleColumn( nIndex ); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir catch(const uno::Exception& e) { 166*cdf0e10cSrcweir g_warning( "Exception in getAccessibleColumn()" ); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir return -1; 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir /*****************************************************************************/ 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir static gint 175*cdf0e10cSrcweir table_wrapper_get_row_at_index( AtkTable *table, 176*cdf0e10cSrcweir gint nIndex ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir try { 179*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir #ifdef ENABLE_TRACING 182*cdf0e10cSrcweir if( pTable ) 183*cdf0e10cSrcweir fprintf(stderr, "getAccessibleRow( %u ) returns %u\n", 184*cdf0e10cSrcweir nIndex, pTable->getAccessibleRow( nIndex ) ); 185*cdf0e10cSrcweir #endif 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir if( pTable ) 188*cdf0e10cSrcweir return pTable->getAccessibleRow( nIndex ); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir catch(const uno::Exception& e) { 191*cdf0e10cSrcweir g_warning( "Exception in getAccessibleRow()" ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir return -1; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir /*****************************************************************************/ 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir static gint 200*cdf0e10cSrcweir table_wrapper_get_n_columns( AtkTable *table ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir try { 203*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir #ifdef ENABLE_TRACING 206*cdf0e10cSrcweir if( pTable ) 207*cdf0e10cSrcweir fprintf(stderr, "XAccessibleTable::getAccessibleColumnCount returns %u\n", 208*cdf0e10cSrcweir pTable->getAccessibleColumnCount() ); 209*cdf0e10cSrcweir #endif 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir if( pTable ) 212*cdf0e10cSrcweir return pTable->getAccessibleColumnCount(); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir catch(const uno::Exception& e) { 215*cdf0e10cSrcweir g_warning( "Exception in getAccessibleColumnCount()" ); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir return -1; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir /*****************************************************************************/ 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir static gint 224*cdf0e10cSrcweir table_wrapper_get_n_rows( AtkTable *table ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir try { 227*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir #ifdef ENABLE_TRACING 230*cdf0e10cSrcweir if( pTable ) 231*cdf0e10cSrcweir fprintf(stderr, "getAccessibleRowCount() returns %u\n", 232*cdf0e10cSrcweir pTable->getAccessibleRowCount() ); 233*cdf0e10cSrcweir #endif 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir if( pTable ) 236*cdf0e10cSrcweir return pTable->getAccessibleRowCount(); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir catch(const uno::Exception& e) { 239*cdf0e10cSrcweir g_warning( "Exception in getAccessibleRowCount()" ); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir return -1; 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir /*****************************************************************************/ 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir static gint 248*cdf0e10cSrcweir table_wrapper_get_column_extent_at( AtkTable *table, 249*cdf0e10cSrcweir gint row, 250*cdf0e10cSrcweir gint column ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir try { 253*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir #ifdef ENABLE_TRACING 256*cdf0e10cSrcweir if( pTable ) 257*cdf0e10cSrcweir fprintf(stderr, "getAccessibleColumnExtentAt( %u, %u ) returns %u\n", 258*cdf0e10cSrcweir row, column, pTable->getAccessibleColumnExtentAt( row, column ) ); 259*cdf0e10cSrcweir #endif 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir if( pTable ) 262*cdf0e10cSrcweir return pTable->getAccessibleColumnExtentAt( row, column ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir catch(const uno::Exception& e) { 265*cdf0e10cSrcweir g_warning( "Exception in getAccessibleColumnExtentAt()" ); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir return -1; 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir /*****************************************************************************/ 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir static gint 274*cdf0e10cSrcweir table_wrapper_get_row_extent_at( AtkTable *table, 275*cdf0e10cSrcweir gint row, 276*cdf0e10cSrcweir gint column ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir try { 279*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir #ifdef ENABLE_TRACING 282*cdf0e10cSrcweir if( pTable ) 283*cdf0e10cSrcweir fprintf(stderr, "getAccessibleRowExtentAt( %u, %u ) returns %u\n", 284*cdf0e10cSrcweir row, column, pTable->getAccessibleRowExtentAt( row, column ) ); 285*cdf0e10cSrcweir #endif 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir if( pTable ) 288*cdf0e10cSrcweir return pTable->getAccessibleRowExtentAt( row, column ); 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir catch(const uno::Exception& e) { 291*cdf0e10cSrcweir g_warning( "Exception in getAccessibleRowExtentAt()" ); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir return -1; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir /*****************************************************************************/ 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir static AtkObject * 300*cdf0e10cSrcweir table_wrapper_get_caption( AtkTable *table ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir try { 303*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir #ifdef ENABLE_TRACING 306*cdf0e10cSrcweir if( pTable ) 307*cdf0e10cSrcweir fprintf(stderr, "getAccessibleCaption() returns" ); 308*cdf0e10cSrcweir #endif 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir if( pTable ) 311*cdf0e10cSrcweir return atk_object_wrapper_conditional_ref( pTable->getAccessibleCaption() ); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir catch(const uno::Exception& e) { 315*cdf0e10cSrcweir g_warning( "Exception in getAccessibleCaption()" ); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir return NULL; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir /*****************************************************************************/ 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir static G_CONST_RETURN gchar * 324*cdf0e10cSrcweir table_wrapper_get_row_description( AtkTable *table, 325*cdf0e10cSrcweir gint row ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir try { 328*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir #ifdef ENABLE_TRACING 331*cdf0e10cSrcweir if( pTable ) 332*cdf0e10cSrcweir fprintf(stderr, "getAccessibleRowDescription( %u ) returns %s\n", 333*cdf0e10cSrcweir row, getAsConst( pTable->getAccessibleRowDescription( row ) ) ); 334*cdf0e10cSrcweir #endif 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir if( pTable ) 337*cdf0e10cSrcweir return getAsConst( pTable->getAccessibleRowDescription( row ) ); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir catch(const uno::Exception& e) { 340*cdf0e10cSrcweir g_warning( "Exception in getAccessibleRowDescription()" ); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir return NULL; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir /*****************************************************************************/ 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir static G_CONST_RETURN gchar * 349*cdf0e10cSrcweir table_wrapper_get_column_description( AtkTable *table, 350*cdf0e10cSrcweir gint column ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir try { 353*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir #ifdef ENABLE_TRACING 356*cdf0e10cSrcweir if( pTable ) 357*cdf0e10cSrcweir fprintf(stderr, "getAccessibleColumnDescription( %u ) returns %s\n", 358*cdf0e10cSrcweir column, getAsConst( pTable->getAccessibleColumnDescription( column ) ) ); 359*cdf0e10cSrcweir #endif 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir if( pTable ) 362*cdf0e10cSrcweir return getAsConst( pTable->getAccessibleColumnDescription( column ) ); 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir catch(const uno::Exception& e) { 365*cdf0e10cSrcweir g_warning( "Exception in getAccessibleColumnDescription()" ); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir return NULL; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir /*****************************************************************************/ 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir static AtkObject * 374*cdf0e10cSrcweir table_wrapper_get_row_header( AtkTable *table, 375*cdf0e10cSrcweir gint row ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir try { 378*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 379*cdf0e10cSrcweir if( pTable ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleTable > xRowHeaders( pTable->getAccessibleRowHeaders() ); 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir #ifdef ENABLE_TRACING 384*cdf0e10cSrcweir if( xRowHeaders.is() ) 385*cdf0e10cSrcweir fprintf(stderr, "getAccessibleRowHeader( %u )->getAccessibleCellAt( 0, %u ) returns", 386*cdf0e10cSrcweir row, row ); 387*cdf0e10cSrcweir else 388*cdf0e10cSrcweir fprintf(stderr, "getAccessibleRowHeader( %u ) returns %p\n", row, xRowHeaders.get() ); 389*cdf0e10cSrcweir #endif 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir if( xRowHeaders.is() ) 392*cdf0e10cSrcweir return atk_object_wrapper_conditional_ref( xRowHeaders->getAccessibleCellAt( row, 0 ) ); 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir catch(const uno::Exception& e) { 396*cdf0e10cSrcweir g_warning( "Exception in getAccessibleRowHeaders()" ); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir return NULL; 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir /*****************************************************************************/ 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir static AtkObject * 405*cdf0e10cSrcweir table_wrapper_get_column_header( AtkTable *table, 406*cdf0e10cSrcweir gint column ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir try { 409*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir if( pTable ) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleTable > xColumnHeaders( pTable->getAccessibleColumnHeaders() ); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir #ifdef ENABLE_TRACING 416*cdf0e10cSrcweir if( xColumnHeaders.is() ) 417*cdf0e10cSrcweir fprintf(stderr, "getAccessibleColumnHeader( %u )->getAccessibleCellAt( 0, %u ) returns", 418*cdf0e10cSrcweir column, column ); 419*cdf0e10cSrcweir else 420*cdf0e10cSrcweir fprintf(stderr, "getAccessibleColumnHeader( %u ) returns %p\n", column, xColumnHeaders.get() ); 421*cdf0e10cSrcweir #endif 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir if( xColumnHeaders.is() ) 424*cdf0e10cSrcweir return atk_object_wrapper_conditional_ref( xColumnHeaders->getAccessibleCellAt( 0, column ) ); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir catch(const uno::Exception& e) { 428*cdf0e10cSrcweir g_warning( "Exception in getAccessibleColumnHeaders()" ); 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir return NULL; 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir /*****************************************************************************/ 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir static AtkObject * 437*cdf0e10cSrcweir table_wrapper_get_summary( AtkTable *table ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir try { 440*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir #ifdef ENABLE_TRACING 443*cdf0e10cSrcweir if( pTable ) 444*cdf0e10cSrcweir fprintf(stderr, "getAccessibleSummary() returns" ); 445*cdf0e10cSrcweir #endif 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir if( pTable ) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir // FIXME: Summary ?? 450*cdf0e10cSrcweir // AtkObject* summary; 451*cdf0e10cSrcweir return atk_object_wrapper_conditional_ref( pTable->getAccessibleSummary() ); 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir catch(const uno::Exception& e) { 455*cdf0e10cSrcweir g_warning( "Exception in getAccessibleSummary()" ); 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir return NULL; 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir /*****************************************************************************/ 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir static gint 464*cdf0e10cSrcweir convertToGIntArray( const uno::Sequence< ::sal_Int32 >& aSequence, gint **pSelected ) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir if( aSequence.getLength() ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir *pSelected = g_new( gint, aSequence.getLength() ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir for( sal_Int32 i = 0; i < aSequence.getLength(); i++ ) 471*cdf0e10cSrcweir (*pSelected) [i] = aSequence[i]; 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir return aSequence.getLength(); 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir /*****************************************************************************/ 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir static gint 480*cdf0e10cSrcweir table_wrapper_get_selected_columns( AtkTable *table, 481*cdf0e10cSrcweir gint **pSelected ) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir *pSelected = NULL; 484*cdf0e10cSrcweir try { 485*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir #ifdef ENABLE_TRACING 488*cdf0e10cSrcweir if( pTable ) 489*cdf0e10cSrcweir fprintf(stderr, "getSelectedAccessibleColumns() \n" ); 490*cdf0e10cSrcweir #endif 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir if( pTable ) 493*cdf0e10cSrcweir return convertToGIntArray( pTable->getSelectedAccessibleColumns(), pSelected ); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir catch(const uno::Exception& e) { 496*cdf0e10cSrcweir g_warning( "Exception in getSelectedAccessibleColumns()" ); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir return 0; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir /*****************************************************************************/ 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir static gint 505*cdf0e10cSrcweir table_wrapper_get_selected_rows( AtkTable *table, 506*cdf0e10cSrcweir gint **pSelected ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir *pSelected = NULL; 509*cdf0e10cSrcweir try { 510*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir #ifdef ENABLE_TRACING 513*cdf0e10cSrcweir if( pTable ) 514*cdf0e10cSrcweir fprintf(stderr, "getSelectedAccessibleRows() \n" ); 515*cdf0e10cSrcweir #endif 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir if( pTable ) 518*cdf0e10cSrcweir return convertToGIntArray( pTable->getSelectedAccessibleRows(), pSelected ); 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir catch(const uno::Exception& e) { 521*cdf0e10cSrcweir g_warning( "Exception in getSelectedAccessibleRows()" ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir return 0; 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir /*****************************************************************************/ 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir static gboolean 530*cdf0e10cSrcweir table_wrapper_is_column_selected( AtkTable *table, 531*cdf0e10cSrcweir gint column ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir try { 534*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir #ifdef ENABLE_TRACING 537*cdf0e10cSrcweir if( pTable ) 538*cdf0e10cSrcweir fprintf(stderr, "isAccessibleColumnSelected( %u ) returns %s\n", 539*cdf0e10cSrcweir column, pTable->isAccessibleColumnSelected( column ) ? "true" : "false" ); 540*cdf0e10cSrcweir #endif 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir if( pTable ) 543*cdf0e10cSrcweir return pTable->isAccessibleColumnSelected( column ); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir catch(const uno::Exception& e) { 546*cdf0e10cSrcweir g_warning( "Exception in isAccessibleColumnSelected()" ); 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir return 0; 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir /*****************************************************************************/ 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir static gboolean 555*cdf0e10cSrcweir table_wrapper_is_row_selected( AtkTable *table, 556*cdf0e10cSrcweir gint row ) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir try { 559*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir #ifdef ENABLE_TRACING 562*cdf0e10cSrcweir if( pTable ) 563*cdf0e10cSrcweir fprintf(stderr, "isAccessibleRowSelected( %u ) returns %s\n", 564*cdf0e10cSrcweir row, pTable->isAccessibleRowSelected( row ) ? "true" : "false" ); 565*cdf0e10cSrcweir #endif 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir if( pTable ) 568*cdf0e10cSrcweir return pTable->isAccessibleRowSelected( row ); 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir catch(const uno::Exception& e) { 571*cdf0e10cSrcweir g_warning( "Exception in isAccessibleRowSelected()" ); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir return FALSE; 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir /*****************************************************************************/ 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir static gboolean 580*cdf0e10cSrcweir table_wrapper_is_selected( AtkTable *table, 581*cdf0e10cSrcweir gint row, 582*cdf0e10cSrcweir gint column ) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir try { 585*cdf0e10cSrcweir accessibility::XAccessibleTable* pTable = getTable( table ); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir #ifdef ENABLE_TRACING 588*cdf0e10cSrcweir if( pTable ) 589*cdf0e10cSrcweir fprintf(stderr, "isAccessibleSelected( %u, %u ) returns %s\n", 590*cdf0e10cSrcweir row, column, pTable->isAccessibleSelected( row , column ) ? "true" : "false" ); 591*cdf0e10cSrcweir #endif 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir if( pTable ) 594*cdf0e10cSrcweir return pTable->isAccessibleSelected( row, column ); 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir catch(const uno::Exception& e) { 597*cdf0e10cSrcweir g_warning( "Exception in isAccessibleSelected()" ); 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir return FALSE; 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir /*****************************************************************************/ 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir static gboolean 606*cdf0e10cSrcweir table_wrapper_add_row_selection( AtkTable *, gint ) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir g_warning( "FIXME: no simple analogue for add_row_selection" ); 609*cdf0e10cSrcweir return 0; 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir /*****************************************************************************/ 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir static gboolean 615*cdf0e10cSrcweir table_wrapper_remove_row_selection( AtkTable *, gint ) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir g_warning( "FIXME: no simple analogue for remove_row_selection" ); 618*cdf0e10cSrcweir return 0; 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir /*****************************************************************************/ 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir static gboolean 624*cdf0e10cSrcweir table_wrapper_add_column_selection( AtkTable *, gint ) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir g_warning( "FIXME: no simple analogue for add_column_selection" ); 627*cdf0e10cSrcweir return 0; 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir /*****************************************************************************/ 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir static gboolean 633*cdf0e10cSrcweir table_wrapper_remove_column_selection( AtkTable *, gint ) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir g_warning( "FIXME: no simple analogue for remove_column_selection" ); 636*cdf0e10cSrcweir return 0; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir /*****************************************************************************/ 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir static void 642*cdf0e10cSrcweir table_wrapper_set_caption( AtkTable *, AtkObject * ) 643*cdf0e10cSrcweir { // meaningless helper 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir /*****************************************************************************/ 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir static void 649*cdf0e10cSrcweir table_wrapper_set_column_description( AtkTable *, gint, const gchar * ) 650*cdf0e10cSrcweir { // meaningless helper 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir /*****************************************************************************/ 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir static void 657*cdf0e10cSrcweir table_wrapper_set_column_header( AtkTable *, gint, AtkObject * ) 658*cdf0e10cSrcweir { // meaningless helper 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir /*****************************************************************************/ 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir static void 665*cdf0e10cSrcweir table_wrapper_set_row_description( AtkTable *, gint, const gchar * ) 666*cdf0e10cSrcweir { // meaningless helper 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir /*****************************************************************************/ 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir static void 672*cdf0e10cSrcweir table_wrapper_set_row_header( AtkTable *, gint, AtkObject * ) 673*cdf0e10cSrcweir { // meaningless helper 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir /*****************************************************************************/ 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir static void 679*cdf0e10cSrcweir table_wrapper_set_summary( AtkTable *, AtkObject * ) 680*cdf0e10cSrcweir { // meaningless helper 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir /*****************************************************************************/ 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir } // extern "C" 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir void 688*cdf0e10cSrcweir tableIfaceInit (AtkTableIface *iface) 689*cdf0e10cSrcweir { 690*cdf0e10cSrcweir g_return_if_fail (iface != NULL); 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir iface->ref_at = table_wrapper_ref_at; 693*cdf0e10cSrcweir iface->get_n_rows = table_wrapper_get_n_rows; 694*cdf0e10cSrcweir iface->get_n_columns = table_wrapper_get_n_columns; 695*cdf0e10cSrcweir iface->get_index_at = table_wrapper_get_index_at; 696*cdf0e10cSrcweir iface->get_column_at_index = table_wrapper_get_column_at_index; 697*cdf0e10cSrcweir iface->get_row_at_index = table_wrapper_get_row_at_index; 698*cdf0e10cSrcweir iface->is_row_selected = table_wrapper_is_row_selected; 699*cdf0e10cSrcweir iface->is_selected = table_wrapper_is_selected; 700*cdf0e10cSrcweir iface->get_selected_rows = table_wrapper_get_selected_rows; 701*cdf0e10cSrcweir iface->add_row_selection = table_wrapper_add_row_selection; 702*cdf0e10cSrcweir iface->remove_row_selection = table_wrapper_remove_row_selection; 703*cdf0e10cSrcweir iface->add_column_selection = table_wrapper_add_column_selection; 704*cdf0e10cSrcweir iface->remove_column_selection = table_wrapper_remove_column_selection; 705*cdf0e10cSrcweir iface->get_selected_columns = table_wrapper_get_selected_columns; 706*cdf0e10cSrcweir iface->is_column_selected = table_wrapper_is_column_selected; 707*cdf0e10cSrcweir iface->get_column_extent_at = table_wrapper_get_column_extent_at; 708*cdf0e10cSrcweir iface->get_row_extent_at = table_wrapper_get_row_extent_at; 709*cdf0e10cSrcweir iface->get_row_header = table_wrapper_get_row_header; 710*cdf0e10cSrcweir iface->set_row_header = table_wrapper_set_row_header; 711*cdf0e10cSrcweir iface->get_column_header = table_wrapper_get_column_header; 712*cdf0e10cSrcweir iface->set_column_header = table_wrapper_set_column_header; 713*cdf0e10cSrcweir iface->get_caption = table_wrapper_get_caption; 714*cdf0e10cSrcweir iface->set_caption = table_wrapper_set_caption; 715*cdf0e10cSrcweir iface->get_summary = table_wrapper_get_summary; 716*cdf0e10cSrcweir iface->set_summary = table_wrapper_set_summary; 717*cdf0e10cSrcweir iface->get_row_description = table_wrapper_get_row_description; 718*cdf0e10cSrcweir iface->set_row_description = table_wrapper_set_row_description; 719*cdf0e10cSrcweir iface->get_column_description = table_wrapper_get_column_description; 720*cdf0e10cSrcweir iface->set_column_description = table_wrapper_set_column_description; 721*cdf0e10cSrcweir } 722