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