* event.py (Event.__init__): Ref() the host_application attribute
[platform/core/uifw/at-spi2-atk.git] / libspi / table.c
index 629a75c..33290dd 100644 (file)
@@ -2,7 +2,8 @@
  * AT-SPI - Assistive Technology Service Provider Interface
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -171,7 +172,7 @@ impl_getRowDescription (PortableServer_Servant servant,
   const char *rv;
   AtkTable   *table = get_table_from_servant (servant);
 
-  g_return_val_if_fail (table != NULL, 0);
+  g_return_val_if_fail (table != NULL, NULL);
   
   rv = atk_table_get_row_description (table, row);
 
@@ -196,7 +197,7 @@ impl_getColumnDescription (PortableServer_Servant servant,
 
   g_return_val_if_fail (table != NULL, CORBA_string_dup (""));
   
-  rv = atk_table_get_row_description (table, column);
+  rv = atk_table_get_column_description (table, column);
 
   if (rv)
     {
@@ -268,12 +269,42 @@ impl_getColumnHeader (PortableServer_Servant servant,
   return spi_accessible_new_return (header, FALSE, ev);
 }
 
+static CORBA_long
+impl__get_nSelectedRows (PortableServer_Servant servant,
+                        CORBA_Environment     *ev)
+{
+  gint *selectedRows = NULL;
+  gint retval = 0;
+  AtkTable *table = get_table_from_servant (servant);
+
+  bonobo_return_val_if_fail (table != NULL, 0, ev);
+
+  retval = atk_table_get_selected_rows (table, &selectedRows);
+  if (selectedRows) g_free (selectedRows);
+  return retval;
+}
+
+
+static CORBA_long
+impl__get_nSelectedColumns (PortableServer_Servant servant,
+                           CORBA_Environment     *ev)
+{
+  gint *selectedColumns = NULL;
+  gint retval = 0;
+  AtkTable *table = get_table_from_servant (servant);
+
+  bonobo_return_val_if_fail (table != NULL, 0, ev);
+
+  retval = atk_table_get_selected_columns (table, &selectedColumns);
+  if (selectedColumns) g_free (selectedColumns);
+  return retval;
+}
 
 static Accessibility_LongSeq *
 impl_getSelectedRows (PortableServer_Servant servant,
                      CORBA_Environment     *ev)
 {
-  gint *selectedRows;
+  gint *selectedRows = NULL;
   gint length;
   Accessibility_LongSeq *retval;
   AtkTable *table = get_table_from_servant (servant);
@@ -282,7 +313,7 @@ impl_getSelectedRows (PortableServer_Servant servant,
 
   length = atk_table_get_selected_rows (table, &selectedRows);
 
-  bonobo_return_val_if_fail (length > 0, NULL, ev);
+  bonobo_return_val_if_fail (length >= 0, NULL, ev);
 
   retval = Accessibility_LongSeq__alloc ();
   retval->_maximum = retval->_length = length;
@@ -293,7 +324,7 @@ impl_getSelectedRows (PortableServer_Servant servant,
       retval->_buffer[length] = selectedRows[length];
     }
 
-  g_free (selectedRows);
+  if (selectedRows) g_free (selectedRows);
 
   return retval;
 }
@@ -303,7 +334,7 @@ static Accessibility_LongSeq *
 impl_getSelectedColumns (PortableServer_Servant servant,
                         CORBA_Environment     *ev)
 {
-  gint *selectedColumns;
+  gint *selectedColumns = NULL;
   gint length;
   Accessibility_LongSeq *retval;
   AtkTable *table = get_table_from_servant (servant);
@@ -323,7 +354,7 @@ impl_getSelectedColumns (PortableServer_Servant servant,
       retval->_buffer[length] = (CORBA_long) selectedColumns[length];
     }
 
-  g_free (selectedColumns);
+  if (selectedColumns) g_free (selectedColumns);
 
   return retval;
 }
@@ -407,6 +438,47 @@ impl_removeColumnSelection (PortableServer_Servant servant,
 
 
 static CORBA_boolean
+impl_getRowColumnExtentsAtIndex (PortableServer_Servant servant,
+                                const CORBA_long index,
+                                CORBA_long *row,
+                                CORBA_long *column,
+                                CORBA_long *row_extents,
+                                CORBA_long *col_extents,
+                                CORBA_boolean *is_selected,
+                                CORBA_Environment *ev)
+{
+
+  AtkObject *cell;
+  AtkRole role;
+  AtkTable *table = get_table_from_servant (servant);
+  gint intColumn, intRow, intRow_extents, intCol_extents;
+  gboolean boolIs_selected;
+
+  g_return_val_if_fail (table != NULL, FALSE);
+
+  intColumn = atk_table_get_column_at_index (table, index);
+  intRow = atk_table_get_row_at_index (table, index);
+  intRow_extents = atk_table_get_row_extent_at (table, intRow, intColumn);
+  intCol_extents = atk_table_get_column_extent_at (table, intRow, intColumn);
+  boolIs_selected = atk_table_is_selected (table, intRow, intColumn);
+
+  *column = intColumn;
+  *row = intRow;
+  *row_extents = intRow_extents;
+  *col_extents = intCol_extents;
+  *is_selected = boolIs_selected;
+
+  cell = atk_table_ref_at (table, intRow, intColumn);
+  role = atk_object_get_role (cell);
+
+  if (role == ATK_ROLE_TABLE_CELL)
+    return TRUE;
+  
+  return FALSE;
+
+}
+
+static CORBA_boolean
 impl_isSelected (PortableServer_Servant servant,
                 const CORBA_long       row,
                 const CORBA_long       column,
@@ -432,6 +504,8 @@ spi_table_class_init (SpiTableClass *klass)
   epv->_get_summary = impl__get_summary;
   epv->_get_nRows = impl__get_nRows;
   epv->_get_nColumns = impl__get_nColumns;
+  epv->_get_nSelectedRows = impl__get_nSelectedRows;
+  epv->_get_nSelectedColumns = impl__get_nSelectedColumns;
   epv->getAccessibleAt = impl_getAccessibleAt;
   epv->getIndexAt = impl_getIndexAt;
   epv->getRowAtIndex = impl_getRowAtIndex;
@@ -451,6 +525,7 @@ spi_table_class_init (SpiTableClass *klass)
   epv->removeRowSelection = impl_removeRowSelection;
   epv->removeColumnSelection = impl_removeColumnSelection;
   epv->isSelected = impl_isSelected;
+  epv->getRowColumnExtentsAtIndex = impl_getRowColumnExtentsAtIndex;
 }
 
 static void
@@ -461,4 +536,4 @@ spi_table_init (SpiTable *table)
 BONOBO_TYPE_FUNC_FULL (SpiTable,
                       Accessibility_Table,
                       SPI_TYPE_BASE,
-                      spi_table);
+                      spi_table)