Add atk-bridge
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_table.c
index 6cb3087..759418c 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
@@ -58,8 +59,14 @@ AccessibleTable_unref (AccessibleTable *obj)
 Accessible *
 AccessibleTable_getCaption (AccessibleTable *obj)
 {
-  return cspi_object_add (
-    Accessibility_Table__get_caption (CSPI_OBJREF (obj), cspi_ev ()));
+  Accessible *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+  retval =  cspi_object_add (
+                            Accessibility_Table__get_caption (CSPI_OBJREF (obj), cspi_ev ()));
+  cspi_return_val_if_ev ("getCaption", NULL);
+  return retval;
 }
 
 /**
@@ -74,8 +81,14 @@ AccessibleTable_getCaption (AccessibleTable *obj)
 Accessible *
 AccessibleTable_getSummary (AccessibleTable *obj)
 {
-  return cspi_object_add (
-    Accessibility_Table__get_summary (CSPI_OBJREF (obj), cspi_ev ()));
+  Accessible *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+retval = cspi_object_add (
+                         Accessibility_Table__get_summary (CSPI_OBJREF (obj), cspi_ev ()));
+ cspi_return_val_if_ev ("getSummary", NULL);
+ return retval;
 }
 
 /**
@@ -124,7 +137,7 @@ AccessibleTable_getNColumns (AccessibleTable *obj)
   retval =
     Accessibility_Table__get_nColumns (CSPI_OBJREF (obj), cspi_ev ());
          
-  cspi_return_val_if_ev ("", -1);
+  cspi_return_val_if_ev ("getNColumns", -1);
 
   return retval;
 }
@@ -146,10 +159,16 @@ AccessibleTable_getAccessibleAt (AccessibleTable *obj,
                                  long int row,
                                  long int column)
 {
-  return cspi_object_add (
-    Accessibility_Table_getAccessibleAt (
-      CSPI_OBJREF (obj), (CORBA_long) row,
-      (CORBA_long) column, cspi_ev ()));
+  Accessible *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+  retval = cspi_object_add (
+                           Accessibility_Table_getAccessibleAt (
+                                                                CSPI_OBJREF (obj), row,
+                                                                column, cspi_ev ()));
+  cspi_return_val_if_ev ("getAccessibleAt", NULL);
+ return retval;
 }
 
 /**
@@ -177,8 +196,8 @@ AccessibleTable_getIndexAt (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_getIndexAt (
-      CSPI_OBJREF (obj), (CORBA_long) row,
-      (CORBA_long) column, cspi_ev ());
+      CSPI_OBJREF (obj), row,
+      column, cspi_ev ());
          
   cspi_return_val_if_ev ("getIndexAt", -1);
 
@@ -207,9 +226,9 @@ AccessibleTable_getRowAtIndex (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_getRowAtIndex (CSPI_OBJREF (obj),
-                                      (CORBA_long) index, cspi_ev ());
+                                      index, cspi_ev ());
          
-  cspi_return_val_if_ev ("", -1);
+  cspi_return_val_if_ev ("getRowAtIndex", -1);
 
   return retval;
 }
@@ -236,7 +255,7 @@ AccessibleTable_getColumnAtIndex (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_getColumnAtIndex (CSPI_OBJREF (obj),
-                                         (CORBA_long) index, cspi_ev ());
+                                         index, cspi_ev ());
          
   cspi_return_val_if_ev ("getColumnAtIndex", -1);
 
@@ -263,7 +282,7 @@ AccessibleTable_getRowDescription (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_getRowDescription (CSPI_OBJREF (obj),
-                                          (CORBA_long) row, cspi_ev ());
+                                          row, cspi_ev ());
          
   cspi_return_val_if_ev ("getRowDescription", NULL);
 
@@ -290,7 +309,7 @@ AccessibleTable_getColumnDescription (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_getColumnDescription (CSPI_OBJREF (obj),
-                                             (CORBA_long) column, cspi_ev ());
+                                             column, cspi_ev ());
 
   cspi_return_val_if_ev ("getColumnDescription", NULL);
 
@@ -319,8 +338,8 @@ AccessibleTable_getRowExtentAt (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_getRowExtentAt (
-      CSPI_OBJREF (obj), (CORBA_long) row,
-      (CORBA_long) column, cspi_ev ());
+      CSPI_OBJREF (obj), row,
+      column, cspi_ev ());
          
   cspi_return_val_if_ev ("getRowExtentAt", -1);
 
@@ -349,8 +368,8 @@ AccessibleTable_getColumnExtentAt (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_getColumnExtentAt (
-      CSPI_OBJREF (obj), (CORBA_long) row,
-      (CORBA_long) column, cspi_ev ());
+      CSPI_OBJREF (obj), row,
+      column, cspi_ev ());
          
   cspi_return_val_if_ev ("getColumnExtentAt", -1);
 
@@ -371,9 +390,16 @@ Accessible *
 AccessibleTable_getRowHeader (AccessibleTable *obj,
                              long int         row)
 {
-  return cspi_object_add (
-    Accessibility_Table_getRowHeader (CSPI_OBJREF (obj),
-                                     (CORBA_long) row, cspi_ev ()));
+  Accessible *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+  retval = cspi_object_add (
+                           Accessibility_Table_getRowHeader (CSPI_OBJREF (obj),
+                                                             row, cspi_ev ()));
+  cspi_return_val_if_ev ("getRowHeader", NULL);
+
+ return retval;
 }
 
 /**
@@ -390,9 +416,16 @@ Accessible *
 AccessibleTable_getColumnHeader (AccessibleTable *obj,
                                 long int column)
 {
-  return cspi_object_add (
-    Accessibility_Table_getColumnHeader (CSPI_OBJREF (obj),
-                                     (CORBA_long) column, cspi_ev ()));
+  Accessible *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+  retval = cspi_object_add (
+                           Accessibility_Table_getColumnHeader (CSPI_OBJREF (obj),
+                                                                column, cspi_ev ()));
+  cspi_return_val_if_ev ("getColumnHeader", NULL);
+
+  return retval;
 }
 
 /**
@@ -422,7 +455,8 @@ AccessibleTable_getNSelectedRows (AccessibleTable *obj)
 static long
 cspi_long_seq_to_array (Accessibility_LongSeq *seq, long int **array)
 {
-  long *j, length, i;
+  long *j;
+  long length, i;
 
   if (!cspi_check_ev ("getSelectionItems"))
     {
@@ -466,6 +500,8 @@ AccessibleTable_getSelectedRows (AccessibleTable *obj,
 
   rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ());
 
+  cspi_return_val_if_ev ("getSelectedRows", -1);
+
   return cspi_long_seq_to_array (rows, selectedRows);
 }
 
@@ -473,7 +509,7 @@ AccessibleTable_getSelectedRows (AccessibleTable *obj,
  * AccessibleTable_getNSelectedColumns:
  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
  *
- * Query a table to find out how many columnss are currently selected.  Not all tables
+ * Query a table to find out how many columns are currently selected.  Not all tables
  *  support column selection.
  *
  * Returns: a long integer indicating the number of columns currently selected.
@@ -516,13 +552,14 @@ AccessibleTable_getSelectedColumns (AccessibleTable *obj,
 
   columns = Accessibility_Table_getSelectedColumns (CSPI_OBJREF (obj), cspi_ev ());
 
+  cspi_return_val_if_ev ("getSelectedColumns", -1);
   return cspi_long_seq_to_array (columns, selectedColumns);
 }
 
 /**
  * AccessibleTable_isRowSelected:
  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
- * @row:
+ * @row: the zero-indexed row number of the row being queried.
  *
  * Determine whether a table row is selected.  Not all tables support row selection.
  *
@@ -538,7 +575,7 @@ AccessibleTable_isRowSelected (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_isRowSelected (CSPI_OBJREF (obj),
-                                      (CORBA_long) row, cspi_ev ());
+                                      row, cspi_ev ());
 
   cspi_return_val_if_ev ("isRowSelected", FALSE);
 
@@ -548,7 +585,7 @@ AccessibleTable_isRowSelected (AccessibleTable *obj,
 /**
  * AccessibleTable_isColumnSelected:
  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
- * @column:
+ * @column: the zero-indexed column number of the column being queried.
  *
  * Determine whether specified table column is selected.
  * Not all tables support column selection.
@@ -565,7 +602,7 @@ AccessibleTable_isColumnSelected (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_isColumnSelected (CSPI_OBJREF (obj),
-                                         (CORBA_long) column, cspi_ev ());
+                                         column, cspi_ev ());
          
   cspi_return_val_if_ev ("isColumnSelected", FALSE);
 
@@ -575,7 +612,7 @@ AccessibleTable_isColumnSelected (AccessibleTable *obj,
 /**
  * AccessibleTable_addRowSelection:
  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
- * @row:
+ * @row: the zero-indexed row number of the row being selected.
  *
  * Select the specified row, adding it to the current row selection.
  * Not all tables support row selection.
@@ -592,7 +629,7 @@ AccessibleTable_addRowSelection (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_addRowSelection (CSPI_OBJREF (obj),
-                                        (CORBA_long) row, cspi_ev ());
+                                        row, cspi_ev ());
          
   cspi_return_val_if_ev ("addRowSelection", FALSE);
 
@@ -602,7 +639,7 @@ AccessibleTable_addRowSelection (AccessibleTable *obj,
 /**
  * AccessibleTable_addColumnSelection:
  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
- * @column:
+ * @column: the zero-indexed column number of the column being selected.
  *
  * Select the specified column, adding it to the current column selection.
  * Not all tables support column selection.
@@ -619,7 +656,7 @@ AccessibleTable_addColumnSelection (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_addColumnSelection (CSPI_OBJREF (obj),
-                                           (CORBA_long) column, cspi_ev ());
+                                           column, cspi_ev ());
          
   cspi_return_val_if_ev ("addColumnSelection", FALSE);
 
@@ -629,7 +666,7 @@ AccessibleTable_addColumnSelection (AccessibleTable *obj,
 /**
  * AccessibleTable_removeRowSelection:
  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
- * @row:
+ * @row: the zero-indexed number of the row being deselected.
  *
  * De-select the specified row, removing it to the current row selection.
  * Not all tables support row selection.
@@ -646,7 +683,7 @@ AccessibleTable_removeRowSelection (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_removeRowSelection (CSPI_OBJREF (obj),
-                                           (CORBA_long) row, cspi_ev ());
+                                           row, cspi_ev ());
          
   cspi_return_val_if_ev ("removeRowSelection", FALSE);
 
@@ -656,7 +693,7 @@ AccessibleTable_removeRowSelection (AccessibleTable *obj,
 /**
  * AccessibleTable_removeColumnSelection:
  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
- * @column:
+ * @column: the zero-indexed column number of the column being de-selected.
  *
  * De-select the specified column, removing it to the current column selection.
  * Not all tables support column selection.
@@ -673,7 +710,7 @@ AccessibleTable_removeColumnSelection (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_removeColumnSelection (CSPI_OBJREF (obj),
-                                              (CORBA_long) column, cspi_ev ());
+                                              column, cspi_ev ());
          
   cspi_return_val_if_ev ("removeColumnSelection", FALSE);
 
@@ -681,10 +718,93 @@ AccessibleTable_removeColumnSelection (AccessibleTable *obj,
 }
 
 /**
+ * AccessibleTable_getRowColumnExtentsAtIndex:
+ * @obj: a pointer to the #AccessibleTable implementor on which to operate.
+ * @index: the index of the Table child whose row/column 
+ * extents are requested.
+ * @row: back-filled with the first table row associated with
+ * the cell with child index \c index.
+ * @col: back-filled with the first table column associated 
+ * with the cell with child index \c index.
+ * @row_extents: back-filled with the number of table rows 
+ * across which child \c i extends.
+ * @col_extents: back-filled with the number of table columns
+ * across which child \c i extends.
+ * @is_selected: a boolean which is back-filled with \c True
+ * if the child at index \c i corresponds to a selected table cell,
+ * \c False otherwise.
+ *
+ * Given a child index, determine the row and column indices and 
+ * extents, and whether the cell is currently selected.  If
+ * the child at \c index is not a cell (for instance, if it is 
+ * a summary, caption, etc.), \c False is returned.
+ *
+ * Example:
+ * If the Table child at index '6' extends across columns 5 and 6 of
+ * row 2 of a Table instance, and is currently selected, then
+ * 
+ * retval = table::getRowColumnExtentsAtIndex (6, row, col, 
+ *                                             row_extents,
+ *                                             col_extents,
+ *                                             is_selected);
+ * 
+ * will return True, and after the call
+ * row, col, row_extents, col_extents,
+ * and \c is_selected will contain 2, 5, 1, 2, and 
+ * True, respectively.
+ *
+ * Returns: \c True if the index is associated with a valid table
+ * cell, \c False if the index does not correspond to a cell.  If 
+ * \c False is returned, the values of the out parameters are 
+ * undefined.
+ * 
+ * Since AT-SPI 1.7.0
+ **/
+SPIBoolean
+AccessibleTable_getRowColumnExtentsAtIndex (AccessibleTable *obj,
+                                           long int index, long int *row, long int *col, 
+                                           long int *row_extents, long int *col_extents, 
+                                           long int *is_selected){
+  SPIBoolean retval;
+  CORBA_long cRow,  cCol, cRow_extents, cCol_extents; 
+  CORBA_boolean cIs_selected;
+
+  cspi_return_val_if_fail (obj != NULL, FALSE);
+
+  retval = Accessibility_Table_getRowColumnExtentsAtIndex (CSPI_OBJREF (obj),
+                                                          index, &cRow, &cCol,
+                                                          &cRow_extents, &cCol_extents,
+                                                          &cIs_selected,
+                                                          cspi_ev ());
+
+  if (!cspi_check_ev ("getRowColumnExtentsAtIndex")){
+    
+    *row = 0;
+    *col = 0;
+    *row_extents = 0;
+    *col_extents = 0;
+    *is_selected = FALSE;
+    retval = FALSE;
+  }
+
+  else {
+    *row = cRow;
+    *col = cCol;
+    *row_extents = cRow_extents;;
+    *col_extents = cCol_extents;
+    *is_selected = cIs_selected;;
+  }
+  
+  return retval;
+
+}
+
+
+/**
  * AccessibleTable_isSelected:
  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
- * @row:
- * @column:
+ * @row: the zero-indexed row of the cell being queried.
+ * @column: the zero-indexed column of the cell being queried.
  *
  * Determine whether the cell at a specific row and column is selected.
  *
@@ -701,8 +821,8 @@ AccessibleTable_isSelected (AccessibleTable *obj,
 
   retval =
     Accessibility_Table_isSelected (CSPI_OBJREF (obj),
-                                   (CORBA_long) row,
-                                   (CORBA_long) column, cspi_ev ());
+                                   row,
+                                   column, cspi_ev ());
          
   cspi_return_val_if_ev ("isSelected", FALSE);