2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* table.c : implements the Table interface */
27 #include <bonobo/bonobo-exception.h>
28 #include <atk/atktable.h>
29 #include <libspi/accessible.h>
30 #include <libspi/table.h>
34 spi_table_interface_new (AtkObject *obj)
36 SpiTable *new_table = g_object_new (SPI_TABLE_TYPE, NULL);
38 spi_base_construct (SPI_BASE (new_table), obj);
45 get_table_from_servant (PortableServer_Servant servant)
47 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
54 return ATK_TABLE (object->atko);
58 static Accessibility_Accessible
59 impl__get_caption (PortableServer_Servant servant,
60 CORBA_Environment *ev)
62 AtkObject *atk_object;
63 AtkTable *table = get_table_from_servant (servant);
65 g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
67 atk_object = atk_table_get_caption (table);
69 return spi_accessible_new_return (atk_object, FALSE, ev);
73 static Accessibility_Accessible
74 impl__get_summary (PortableServer_Servant servant,
75 CORBA_Environment *ev)
77 AtkObject *atk_object;
78 AtkTable *table = get_table_from_servant (servant);
80 g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
82 atk_object = atk_table_get_summary (table);
84 return spi_accessible_new_return (atk_object, FALSE, ev);
89 impl__get_nRows (PortableServer_Servant servant,
90 CORBA_Environment *ev)
92 AtkTable *table = get_table_from_servant (servant);
94 g_return_val_if_fail (table != NULL, 0);
96 return (CORBA_long) atk_table_get_n_rows (table);
101 impl__get_nColumns (PortableServer_Servant servant,
102 CORBA_Environment *ev)
104 AtkTable *table = get_table_from_servant (servant);
106 g_return_val_if_fail (table != NULL, 0);
108 return (CORBA_long) atk_table_get_n_columns (table);
112 static Accessibility_Accessible
113 impl_getAccessibleAt (PortableServer_Servant servant,
114 const CORBA_long row,
115 const CORBA_long column,
116 CORBA_Environment *ev)
118 AtkObject *atk_object;
119 AtkTable *table = get_table_from_servant (servant);
121 g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
123 atk_object = atk_table_ref_at (table,
124 (gint) row, (gint) column);
126 return spi_accessible_new_return (atk_object, TRUE, ev);
131 impl_getIndexAt (PortableServer_Servant servant,
132 const CORBA_long row,
133 const CORBA_long column,
134 CORBA_Environment *ev)
136 AtkTable *table = get_table_from_servant (servant);
138 g_return_val_if_fail (table != NULL, 0);
141 atk_table_get_index_at (table, (gint) row, (gint) column);
146 impl_getRowAtIndex (PortableServer_Servant servant,
147 const CORBA_long index,
148 CORBA_Environment *ev)
150 AtkTable *table = get_table_from_servant (servant);
152 g_return_val_if_fail (table != NULL, 0);
155 atk_table_get_row_at_index (table, (gint) index);
160 impl_getColumnAtIndex (PortableServer_Servant servant,
161 const CORBA_long index,
162 CORBA_Environment *ev)
164 AtkTable *table = get_table_from_servant (servant);
166 g_return_val_if_fail (table != NULL, 0);
169 atk_table_get_column_at_index (table, (gint) index);
174 impl_getRowDescription (PortableServer_Servant servant,
175 const CORBA_long row,
176 CORBA_Environment *ev)
179 AtkTable *table = get_table_from_servant (servant);
181 g_return_val_if_fail (table != NULL, 0);
183 rv = atk_table_get_row_description (table, row);
187 return CORBA_string_dup (rv);
191 return CORBA_string_dup ("");
197 impl_getColumnDescription (PortableServer_Servant servant,
198 const CORBA_long column,
199 CORBA_Environment *ev)
202 AtkTable *table = get_table_from_servant (servant);
204 g_return_val_if_fail (table != NULL, CORBA_string_dup (""));
206 rv = atk_table_get_row_description (table, column);
210 return CORBA_string_dup (rv);
214 return CORBA_string_dup ("");
220 impl_getRowExtentAt (PortableServer_Servant servant,
221 const CORBA_long row,
222 const CORBA_long column,
223 CORBA_Environment *ev)
225 AtkTable *table = get_table_from_servant (servant);
227 g_return_val_if_fail (table != NULL, -1);
230 atk_table_get_row_extent_at (table,
231 (gint) row, (gint) column);
236 impl_getColumnExtentAt (PortableServer_Servant servant,
237 const CORBA_long row,
238 const CORBA_long column,
239 CORBA_Environment *ev)
241 AtkTable *table = get_table_from_servant (servant);
243 g_return_val_if_fail (table != NULL, -1);
246 atk_table_get_column_extent_at (table,
247 (gint) row, (gint) column);
251 static Accessibility_Table
252 impl_getRowHeader (PortableServer_Servant servant,
253 const CORBA_long row,
254 CORBA_Environment *ev)
257 AtkTable *table = get_table_from_servant (servant);
259 g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
261 header = atk_table_get_row_header (table, (gint) row);
263 return spi_accessible_new_return (header, FALSE, ev);
267 static Accessibility_Table
268 impl_getColumnHeader (PortableServer_Servant servant,
269 const CORBA_long column,
270 CORBA_Environment *ev)
273 AtkTable *table = get_table_from_servant (servant);
275 g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
277 header = atk_table_get_column_header (table, (gint) column);
279 return spi_accessible_new_return (header, FALSE, ev);
283 static Accessibility_LongSeq *
284 impl_getSelectedRows (PortableServer_Servant servant,
285 CORBA_Environment *ev)
289 Accessibility_LongSeq *retval;
290 AtkTable *table = get_table_from_servant (servant);
292 bonobo_return_val_if_fail (table != NULL, NULL, ev);
294 length = atk_table_get_selected_rows (table, &selectedRows);
296 bonobo_return_val_if_fail (length > 0, NULL, ev);
298 retval = Accessibility_LongSeq__alloc ();
299 retval->_maximum = retval->_length = (CORBA_long) length;
300 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
304 retval->_buffer[length] = (CORBA_long) selectedRows[length];
307 g_free ((gpointer) selectedRows);
313 static Accessibility_LongSeq *
314 impl_getSelectedColumns (PortableServer_Servant servant,
315 CORBA_Environment *ev)
317 gint *selectedColumns;
319 Accessibility_LongSeq *retval;
320 AtkTable *table = get_table_from_servant (servant);
322 bonobo_return_val_if_fail (table != NULL, NULL, ev);
324 length = atk_table_get_selected_columns (table, &selectedColumns);
326 bonobo_return_val_if_fail (length >= 0, NULL, ev);
328 retval = Accessibility_LongSeq__alloc ();
329 retval->_maximum = retval->_length = (CORBA_long) length;
330 retval->_buffer = Accessibility_LongSeq_allocbuf (length);
334 retval->_buffer[length] = (CORBA_long) selectedColumns[length];
337 g_free ((gpointer) selectedColumns);
344 impl_isRowSelected (PortableServer_Servant servant,
345 const CORBA_long row,
346 CORBA_Environment *ev)
348 AtkTable *table = get_table_from_servant (servant);
350 g_return_val_if_fail (table != NULL, FALSE);
352 return (CORBA_boolean) atk_table_is_row_selected (table, (gint) row);
357 impl_isColumnSelected (PortableServer_Servant servant,
358 const CORBA_long column,
359 CORBA_Environment *ev)
361 AtkTable *table = get_table_from_servant (servant);
363 g_return_val_if_fail (table != NULL, FALSE);
365 return (CORBA_boolean) atk_table_is_column_selected (table, (gint) column);
370 impl_isSelected (PortableServer_Servant servant,
371 const CORBA_long row,
372 const CORBA_long column,
373 CORBA_Environment *ev)
375 AtkTable *table = get_table_from_servant (servant);
377 g_return_val_if_fail (table != NULL, FALSE);
379 return (CORBA_boolean) atk_table_is_selected (table,
380 (gint) row, (gint) column);
385 spi_table_class_init (SpiTableClass *klass)
387 POA_Accessibility_Table__epv *epv = &klass->epv;
389 /* Initialize epv table */
391 epv->_get_caption = impl__get_caption;
392 epv->_get_summary = impl__get_summary;
393 epv->_get_nRows = impl__get_nRows;
394 epv->_get_nColumns = impl__get_nColumns;
395 epv->getAccessibleAt = impl_getAccessibleAt;
396 epv->getIndexAt = impl_getIndexAt;
397 epv->getRowAtIndex = impl_getRowAtIndex;
398 epv->getColumnAtIndex = impl_getColumnAtIndex;
399 epv->getRowDescription = impl_getRowDescription;
400 epv->getColumnDescription = impl_getColumnDescription;
401 epv->getRowExtentAt = impl_getRowExtentAt;
402 epv->getColumnExtentAt = impl_getColumnExtentAt;
403 epv->getRowHeader = impl_getRowHeader;
404 epv->getColumnHeader = impl_getColumnHeader;
405 epv->getSelectedRows = impl_getSelectedRows;
406 epv->getSelectedColumns = impl_getSelectedColumns;
407 epv->isRowSelected = impl_isRowSelected;
408 epv->isColumnSelected = impl_isColumnSelected;
409 epv->isSelected = impl_isSelected;
413 spi_table_init (SpiTable *table)
417 BONOBO_TYPE_FUNC_FULL (SpiTable,