1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "atkwrapper.hxx"
22 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
23 #include <comphelper/sequence.hxx>
25 using namespace ::com::sun::star
;
28 atk_object_wrapper_conditional_ref( const uno::Reference
< accessibility::XAccessible
>& rxAccessible
)
30 if( rxAccessible
.is() )
31 return atk_object_wrapper_ref( rxAccessible
);
36 /*****************************************************************************/
40 getAsConst( const OUString
& rString
)
42 static const int nMax
= 10;
43 static OString aUgly
[nMax
];
45 nIdx
= (nIdx
+ 1) % nMax
;
46 aUgly
[nIdx
] = OUStringToOString( rString
, RTL_TEXTENCODING_UTF8
);
47 return aUgly
[ nIdx
].getStr();
50 /*****************************************************************************/
52 /// @throws uno::RuntimeException
53 static css::uno::Reference
<css::accessibility::XAccessibleTable
>
54 getTable( AtkTable
*pTable
)
56 AtkObjectWrapper
*pWrap
= ATK_OBJECT_WRAPPER( pTable
);
59 if( !pWrap
->mpTable
.is() )
61 pWrap
->mpTable
.set(pWrap
->mpContext
, css::uno::UNO_QUERY
);
64 return pWrap
->mpTable
;
67 return css::uno::Reference
<css::accessibility::XAccessibleTable
>();
70 /*****************************************************************************/
75 table_wrapper_ref_at (AtkTable
*table
,
80 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
= getTable( table
);
82 return atk_object_wrapper_conditional_ref( pTable
->getAccessibleCellAt( row
, column
) );
85 catch(const uno::Exception
&) {
86 g_warning( "Exception in getAccessibleCellAt()" );
92 /*****************************************************************************/
95 table_wrapper_get_index_at (AtkTable
*table
,
100 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
103 return pTable
->getAccessibleIndex( row
, column
);
105 catch(const uno::Exception
&) {
106 g_warning( "Exception in getAccessibleIndex()" );
112 /*****************************************************************************/
115 table_wrapper_get_column_at_index (AtkTable
*table
,
119 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
122 return pTable
->getAccessibleColumn( nIndex
);
124 catch(const uno::Exception
&) {
125 g_warning( "Exception in getAccessibleColumn()" );
131 /*****************************************************************************/
134 table_wrapper_get_row_at_index( AtkTable
*table
,
138 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
141 return pTable
->getAccessibleRow( nIndex
);
143 catch(const uno::Exception
&) {
144 g_warning( "Exception in getAccessibleRow()" );
150 /*****************************************************************************/
153 table_wrapper_get_n_columns( AtkTable
*table
)
156 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
159 return pTable
->getAccessibleColumnCount();
161 catch(const uno::Exception
&) {
162 g_warning( "Exception in getAccessibleColumnCount()" );
168 /*****************************************************************************/
171 table_wrapper_get_n_rows( AtkTable
*table
)
174 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
177 return pTable
->getAccessibleRowCount();
179 catch(const uno::Exception
&) {
180 g_warning( "Exception in getAccessibleRowCount()" );
186 /*****************************************************************************/
189 table_wrapper_get_column_extent_at( AtkTable
*table
,
194 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
197 return pTable
->getAccessibleColumnExtentAt( row
, column
);
199 catch(const uno::Exception
&) {
200 g_warning( "Exception in getAccessibleColumnExtentAt()" );
206 /*****************************************************************************/
209 table_wrapper_get_row_extent_at( AtkTable
*table
,
214 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
217 return pTable
->getAccessibleRowExtentAt( row
, column
);
219 catch(const uno::Exception
&) {
220 g_warning( "Exception in getAccessibleRowExtentAt()" );
226 /*****************************************************************************/
229 table_wrapper_get_caption( AtkTable
*table
)
232 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
235 return atk_object_wrapper_conditional_ref( pTable
->getAccessibleCaption() );
238 catch(const uno::Exception
&) {
239 g_warning( "Exception in getAccessibleCaption()" );
245 /*****************************************************************************/
248 table_wrapper_get_row_description( AtkTable
*table
,
252 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
255 return getAsConst( pTable
->getAccessibleRowDescription( row
) );
257 catch(const uno::Exception
&) {
258 g_warning( "Exception in getAccessibleRowDescription()" );
264 /*****************************************************************************/
267 table_wrapper_get_column_description( AtkTable
*table
,
271 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
274 return getAsConst( pTable
->getAccessibleColumnDescription( column
) );
276 catch(const uno::Exception
&) {
277 g_warning( "Exception in getAccessibleColumnDescription()" );
283 /*****************************************************************************/
286 table_wrapper_get_row_header( AtkTable
*table
,
290 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
294 uno::Reference
< accessibility::XAccessibleTable
> xRowHeaders( pTable
->getAccessibleRowHeaders() );
295 if( xRowHeaders
.is() )
296 return atk_object_wrapper_conditional_ref( xRowHeaders
->getAccessibleCellAt( row
, 0 ) );
299 catch(const uno::Exception
&) {
300 g_warning( "Exception in getAccessibleRowHeaders()" );
306 /*****************************************************************************/
309 table_wrapper_get_column_header( AtkTable
*table
,
313 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
317 uno::Reference
< accessibility::XAccessibleTable
> xColumnHeaders( pTable
->getAccessibleColumnHeaders() );
318 if( xColumnHeaders
.is() )
319 return atk_object_wrapper_conditional_ref( xColumnHeaders
->getAccessibleCellAt( 0, column
) );
322 catch(const uno::Exception
&) {
323 g_warning( "Exception in getAccessibleColumnHeaders()" );
329 /*****************************************************************************/
332 table_wrapper_get_summary( AtkTable
*table
)
335 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
339 return atk_object_wrapper_conditional_ref( pTable
->getAccessibleSummary() );
342 catch(const uno::Exception
&) {
343 g_warning( "Exception in getAccessibleSummary()" );
349 /*****************************************************************************/
352 convertToGIntArray( const uno::Sequence
< ::sal_Int32
>& aSequence
, gint
**pSelected
)
354 if( aSequence
.hasElements() )
356 *pSelected
= g_new( gint
, aSequence
.getLength() );
358 *pSelected
= comphelper::sequenceToArray(*pSelected
, aSequence
);
361 return aSequence
.getLength();
364 /*****************************************************************************/
367 table_wrapper_get_selected_columns( AtkTable
*table
,
370 *pSelected
= nullptr;
372 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
375 return convertToGIntArray( pTable
->getSelectedAccessibleColumns(), pSelected
);
377 catch(const uno::Exception
&) {
378 g_warning( "Exception in getSelectedAccessibleColumns()" );
384 /*****************************************************************************/
387 table_wrapper_get_selected_rows( AtkTable
*table
,
390 *pSelected
= nullptr;
392 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
395 return convertToGIntArray( pTable
->getSelectedAccessibleRows(), pSelected
);
397 catch(const uno::Exception
&) {
398 g_warning( "Exception in getSelectedAccessibleRows()" );
404 /*****************************************************************************/
407 table_wrapper_is_column_selected( AtkTable
*table
,
411 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
414 return pTable
->isAccessibleColumnSelected( column
);
416 catch(const uno::Exception
&) {
417 g_warning( "Exception in isAccessibleColumnSelected()" );
423 /*****************************************************************************/
426 table_wrapper_is_row_selected( AtkTable
*table
,
430 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
433 return pTable
->isAccessibleRowSelected( row
);
435 catch(const uno::Exception
&) {
436 g_warning( "Exception in isAccessibleRowSelected()" );
442 /*****************************************************************************/
445 table_wrapper_is_selected( AtkTable
*table
,
450 css::uno::Reference
<css::accessibility::XAccessibleTable
> pTable
453 return pTable
->isAccessibleSelected( row
, column
);
455 catch(const uno::Exception
&) {
456 g_warning( "Exception in isAccessibleSelected()" );
462 /*****************************************************************************/
465 table_wrapper_add_row_selection( AtkTable
*, gint
)
467 g_warning( "FIXME: no simple analogue for add_row_selection" );
471 /*****************************************************************************/
474 table_wrapper_remove_row_selection( AtkTable
*, gint
)
476 g_warning( "FIXME: no simple analogue for remove_row_selection" );
480 /*****************************************************************************/
483 table_wrapper_add_column_selection( AtkTable
*, gint
)
485 g_warning( "FIXME: no simple analogue for add_column_selection" );
489 /*****************************************************************************/
492 table_wrapper_remove_column_selection( AtkTable
*, gint
)
494 g_warning( "FIXME: no simple analogue for remove_column_selection" );
498 /*****************************************************************************/
501 table_wrapper_set_caption( AtkTable
*, AtkObject
* )
502 { // meaningless helper
505 /*****************************************************************************/
508 table_wrapper_set_column_description( AtkTable
*, gint
, const gchar
* )
509 { // meaningless helper
512 /*****************************************************************************/
515 table_wrapper_set_column_header( AtkTable
*, gint
, AtkObject
* )
516 { // meaningless helper
519 /*****************************************************************************/
522 table_wrapper_set_row_description( AtkTable
*, gint
, const gchar
* )
523 { // meaningless helper
526 /*****************************************************************************/
529 table_wrapper_set_row_header( AtkTable
*, gint
, AtkObject
* )
530 { // meaningless helper
533 /*****************************************************************************/
536 table_wrapper_set_summary( AtkTable
*, AtkObject
* )
537 { // meaningless helper
540 /*****************************************************************************/
545 tableIfaceInit (AtkTableIface
*iface
)
547 g_return_if_fail (iface
!= nullptr);
549 iface
->ref_at
= table_wrapper_ref_at
;
550 iface
->get_n_rows
= table_wrapper_get_n_rows
;
551 iface
->get_n_columns
= table_wrapper_get_n_columns
;
552 iface
->get_index_at
= table_wrapper_get_index_at
;
553 iface
->get_column_at_index
= table_wrapper_get_column_at_index
;
554 iface
->get_row_at_index
= table_wrapper_get_row_at_index
;
555 iface
->is_row_selected
= table_wrapper_is_row_selected
;
556 iface
->is_selected
= table_wrapper_is_selected
;
557 iface
->get_selected_rows
= table_wrapper_get_selected_rows
;
558 iface
->add_row_selection
= table_wrapper_add_row_selection
;
559 iface
->remove_row_selection
= table_wrapper_remove_row_selection
;
560 iface
->add_column_selection
= table_wrapper_add_column_selection
;
561 iface
->remove_column_selection
= table_wrapper_remove_column_selection
;
562 iface
->get_selected_columns
= table_wrapper_get_selected_columns
;
563 iface
->is_column_selected
= table_wrapper_is_column_selected
;
564 iface
->get_column_extent_at
= table_wrapper_get_column_extent_at
;
565 iface
->get_row_extent_at
= table_wrapper_get_row_extent_at
;
566 iface
->get_row_header
= table_wrapper_get_row_header
;
567 iface
->set_row_header
= table_wrapper_set_row_header
;
568 iface
->get_column_header
= table_wrapper_get_column_header
;
569 iface
->set_column_header
= table_wrapper_set_column_header
;
570 iface
->get_caption
= table_wrapper_get_caption
;
571 iface
->set_caption
= table_wrapper_set_caption
;
572 iface
->get_summary
= table_wrapper_get_summary
;
573 iface
->set_summary
= table_wrapper_set_summary
;
574 iface
->get_row_description
= table_wrapper_get_row_description
;
575 iface
->set_row_description
= table_wrapper_set_row_description
;
576 iface
->get_column_description
= table_wrapper_get_column_description
;
577 iface
->set_column_description
= table_wrapper_set_column_description
;
580 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */