X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=cspi%2Fspi_table.c;h=00421e8d0a9bdbfb3f423a1b0283de37ce6a43b2;hb=3fd7452ac529990da31e6b56597f87e3f0d2bb37;hp=24ba32b3b376371a8c3ce688d0c7790a9ffa9c29;hpb=d35cd400a36b0f1393c17ce47015bf753327ccae;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/cspi/spi_table.c b/cspi/spi_table.c index 24ba32b..00421e8 100644 --- a/cspi/spi_table.c +++ b/cspi/spi_table.c @@ -1,3 +1,26 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * 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 + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #include /* for malloc */ #include @@ -6,9 +29,6 @@ * @obj: a pointer to the #AccessibleTable implementor on which to operate. * * Increment the reference count for an #AccessibleTable object. - * - * Returns: (no return code implemented yet). - * **/ void AccessibleTable_ref (AccessibleTable *obj) @@ -21,9 +41,6 @@ AccessibleTable_ref (AccessibleTable *obj) * @obj: a pointer to the #AccessibleTable implementor on which to operate. * * Decrement the reference count for an #AccessibleTable object. - * - * Returns: (no return code implemented yet). - * **/ void AccessibleTable_unref (AccessibleTable *obj) @@ -38,13 +55,18 @@ AccessibleTable_unref (AccessibleTable *obj) * Get an accessible representation of the caption for an #AccessibleTable. * * Returns: an #Accessible object that serves as the table's caption. - * **/ Accessible * AccessibleTable_getCaption (AccessibleTable *obj) { - return (Accessible *) - 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; } /** @@ -55,13 +77,18 @@ AccessibleTable_getCaption (AccessibleTable *obj) * * Returns: an #Accessible object that serves as the table's summary (often a * reduced #AccessibleTable). - * **/ Accessible * AccessibleTable_getSummary (AccessibleTable *obj) { - return (Accessible *) - 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; } /** @@ -73,13 +100,21 @@ AccessibleTable_getSummary (AccessibleTable *obj) * of rows that may be outside of the current scrolling window or viewport. * * Returns: a #long integer indicating the number of rows in the table. - * **/ long AccessibleTable_getNRows (AccessibleTable *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table__get_nRows (CSPI_OBJREF (obj), cspi_ev ()); + + cspi_return_val_if_ev ("getNRows", -1); + + return retval; + } /** @@ -91,13 +126,20 @@ AccessibleTable_getNRows (AccessibleTable *obj) * of columns that may be outside of the current scrolling window or viewport. * * Returns: a #long integer indicating the number of columns in the table. - * **/ long AccessibleTable_getNColumns (AccessibleTable *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table__get_nColumns (CSPI_OBJREF (obj), cspi_ev ()); + + cspi_return_val_if_ev ("getNColumns", -1); + + return retval; } /** @@ -111,16 +153,22 @@ AccessibleTable_getNColumns (AccessibleTable *obj) * use #Accessible_getAccessibleAtPoint (). * * Returns: an #Accessible object representing the specified table cell. - * **/ Accessible * AccessibleTable_getAccessibleAt (AccessibleTable *obj, long int row, long int column) { - return (Accessible *) - 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; } /** @@ -136,19 +184,25 @@ AccessibleTable_getAccessibleAt (AccessibleTable *obj, * * Returns: a long integer which serves as the index of a specified cell in the * table, in a form usable by #Accessible_getChildAtIndex(). - * **/ long AccessibleTable_getIndexAt (AccessibleTable *obj, long int row, long int column) { - return (long) - Accessibility_Table_getIndexAt (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); -} + long retval; + cspi_return_val_if_fail (obj != NULL, -1); + retval = + Accessibility_Table_getIndexAt ( + CSPI_OBJREF (obj), row, + column, cspi_ev ()); + + cspi_return_val_if_ev ("getIndexAt", -1); + + return retval; +} /** * AccessibleTable_getRowAtIndex: @@ -161,18 +215,23 @@ AccessibleTable_getIndexAt (AccessibleTable *obj, * * Returns: a long integer indicating the first row spanned by the child of a * table, at the specified 1-D (zero-offset) @index. - * **/ long AccessibleTable_getRowAtIndex (AccessibleTable *obj, long index) { - return (long) - Accessibility_Table_getRowAtIndex (CSPI_OBJREF (obj), - (CORBA_long) index, cspi_ev ()); -} + long retval; + cspi_return_val_if_fail (obj != NULL, -1); + retval = + Accessibility_Table_getRowAtIndex (CSPI_OBJREF (obj), + index, cspi_ev ()); + + cspi_return_val_if_ev ("getRowAtIndex", -1); + + return retval; +} /** * AccessibleTable_getColumnAtIndex: @@ -185,18 +244,23 @@ AccessibleTable_getRowAtIndex (AccessibleTable *obj, * * Returns: a long integer indicating the first column spanned by the child of a * table, at the specified 1-D (zero-offset) @index. - * **/ long AccessibleTable_getColumnAtIndex (AccessibleTable *obj, long index) { - return (long) - Accessibility_Table_getColumnAtIndex (CSPI_OBJREF (obj), - (CORBA_long) index, cspi_ev ()); -} + long retval; + cspi_return_val_if_fail (obj != NULL, -1); + retval = + Accessibility_Table_getColumnAtIndex (CSPI_OBJREF (obj), + index, cspi_ev ()); + + cspi_return_val_if_ev ("getColumnAtIndex", -1); + + return retval; +} /** * AccessibleTable_getRowDescription: @@ -207,18 +271,23 @@ AccessibleTable_getColumnAtIndex (AccessibleTable *obj, * AccessibleTable_getRowHeader, which returns an #Accessible. * * Returns: a UTF-8 string describing the specified table row, if available. - * **/ char * AccessibleTable_getRowDescription (AccessibleTable *obj, - long int row) + long int row) { - return (char *) - Accessibility_Table_getRowDescription (CSPI_OBJREF (obj), - (CORBA_long) row, cspi_ev ()); -} + char *retval; + + cspi_return_val_if_fail (obj != NULL, NULL); + retval = + Accessibility_Table_getRowDescription (CSPI_OBJREF (obj), + row, cspi_ev ()); + + cspi_return_val_if_ev ("getRowDescription", NULL); + return retval; +} /** * AccessibleTable_getColumnDescription: @@ -229,18 +298,23 @@ AccessibleTable_getRowDescription (AccessibleTable *obj, * AccessibleTable_getColumnHeader, which returns an #Accessible. * * Returns: a UTF-8 string describing the specified table column, if available. - * **/ char * AccessibleTable_getColumnDescription (AccessibleTable *obj, - long int column) + long int column) { - return (char *) + char *retval; + + cspi_return_val_if_fail (obj != NULL, NULL); + + retval = Accessibility_Table_getColumnDescription (CSPI_OBJREF (obj), - (CORBA_long) column, cspi_ev ()); -} + column, cspi_ev ()); + cspi_return_val_if_ev ("getColumnDescription", NULL); + return retval; +} /** * AccessibleTable_getRowExtentAt: @@ -252,19 +326,25 @@ AccessibleTable_getColumnDescription (AccessibleTable *obj, * (some tables can have cells which span multiple rows and/or columns). * * Returns: a long integer indicating the number of rows spanned by the specified cell. - * **/ long AccessibleTable_getRowExtentAt (AccessibleTable *obj, - long int row, - long int column) + long int row, + long int column) { - return (long) - Accessibility_Table_getRowExtentAt (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); -} + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + retval = + Accessibility_Table_getRowExtentAt ( + CSPI_OBJREF (obj), row, + column, cspi_ev ()); + + cspi_return_val_if_ev ("getRowExtentAt", -1); + return retval; +} /** * AccessibleTable_getColumnExtentAt: @@ -276,18 +356,25 @@ AccessibleTable_getRowExtentAt (AccessibleTable *obj, * (some tables can have cells which span multiple rows and/or columns). * * Returns: a long integer indicating the number of columns spanned by the specified cell. - * **/ long AccessibleTable_getColumnExtentAt (AccessibleTable *obj, - long int row, - long int column) + long int row, + long int column) { - return (long) - Accessibility_Table_getColumnExtentAt (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); -} + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = + Accessibility_Table_getColumnExtentAt ( + CSPI_OBJREF (obj), row, + column, cspi_ev ()); + + cspi_return_val_if_ev ("getColumnExtentAt", -1); + return retval; +} /** * AccessibleTable_getRowHeader: @@ -298,18 +385,22 @@ AccessibleTable_getColumnExtentAt (AccessibleTable *obj, * AccessibleTable_getRowDescription, which returns a string. * * Returns: a #Accessible representatin of the specified table row, if available. - * **/ Accessible * AccessibleTable_getRowHeader (AccessibleTable *obj, - long int row) + long int row) { - return (Accessible *) - 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; +} /** * AccessibleTable_getColumnHeader: @@ -320,17 +411,22 @@ AccessibleTable_getRowHeader (AccessibleTable *obj, * AccessibleTable_getColumnDescription, which returns a string. * * Returns: a #Accessible representatin of the specified table column, if available. - * **/ Accessible * AccessibleTable_getColumnHeader (AccessibleTable *obj, long int column) { - return (Accessible *) - 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; +} /** * AccessibleTable_getNSelectedRows: @@ -344,11 +440,43 @@ AccessibleTable_getColumnHeader (AccessibleTable *obj, long AccessibleTable_getNSelectedRows (AccessibleTable *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table__get_nSelectedRows (CSPI_OBJREF (obj), cspi_ev ()); + + cspi_return_val_if_ev ("getNSelectedRows", -1); + + return retval; } +static long +cspi_long_seq_to_array (Accessibility_LongSeq *seq, long int **array) +{ + long *j; + long length, i; + + if (!cspi_check_ev ("getSelectionItems")) + { + *array = NULL; + return 0; + } + + length = seq->_length; + + j = *array = malloc (sizeof (long) * length); + + for (i = 0; i < length; i++) + { + j[i] = seq->_buffer [i]; + } + + CORBA_free (seq); + return length; +} /** * AccessibleTable_getSelectedRows: @@ -362,32 +490,26 @@ AccessibleTable_getNSelectedRows (AccessibleTable *obj) **/ long AccessibleTable_getSelectedRows (AccessibleTable *obj, - long int **selectedRows) + long int **selectedRows) { - Accessibility_LongSeq *rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ()); - CORBA_long *i; - long *j; - long length; + Accessibility_LongSeq *rows; - i = rows->_buffer; - length = (long) rows->_length; - j = *selectedRows = (long *) malloc (sizeof(long)*length); - - while (length--) - *j++ = (CORBA_long) (*i++); + *selectedRows = NULL; - length = rows->_length; - CORBA_free (rows); - return length; -} + cspi_return_val_if_fail (obj != NULL, 0); + rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ()); + cspi_return_val_if_ev ("getSelectedRows", -1); + + return cspi_long_seq_to_array (rows, selectedRows); +} /** * 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. @@ -395,10 +517,17 @@ AccessibleTable_getSelectedRows (AccessibleTable *obj, long AccessibleTable_getNSelectedColumns (AccessibleTable *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table__get_nSelectedColumns (CSPI_OBJREF (obj), cspi_ev ()); -} + + cspi_return_val_if_ev ("getNSelectedColumns", -1); + return retval; +} /** * AccessibleTable_getSelectedColumns: @@ -413,25 +542,19 @@ AccessibleTable_getNSelectedColumns (AccessibleTable *obj) **/ long AccessibleTable_getSelectedColumns (AccessibleTable *obj, - long int **selectedColumns) + long int **selectedColumns) { - Accessibility_LongSeq *columns = Accessibility_Table_getSelectedColumns (CSPI_OBJREF (obj), cspi_ev ()); - CORBA_long *i; - long *j; - long length; + Accessibility_LongSeq *columns; - i = columns->_buffer; - length = (long) columns->_length; - j = *selectedColumns = (long *) malloc (sizeof(long)*length); - - while (length--) - *j++ = (CORBA_long) (*i++); + *selectedColumns = NULL; - length = columns->_length; - CORBA_free (columns); - return length; -} + cspi_return_val_if_fail (obj != NULL, 0); + 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: @@ -441,18 +564,23 @@ AccessibleTable_getSelectedColumns (AccessibleTable *obj, * Determine whether a table row is selected. Not all tables support row selection. * * Returns: #TRUE if the specified row is currently selected, #FALSE if not. - * **/ SPIBoolean AccessibleTable_isRowSelected (AccessibleTable *obj, - long int row) + long int row) { - return (SPIBoolean) + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = Accessibility_Table_isRowSelected (CSPI_OBJREF (obj), - (CORBA_long) row, cspi_ev ()); -} + row, cspi_ev ()); + cspi_return_val_if_ev ("isRowSelected", FALSE); + return retval; +} /** * AccessibleTable_isColumnSelected: @@ -463,18 +591,131 @@ AccessibleTable_isRowSelected (AccessibleTable *obj, * Not all tables support column selection. * * Returns: #TRUE if the specified column is currently selected, #FALSE if not. - * **/ SPIBoolean AccessibleTable_isColumnSelected (AccessibleTable *obj, - long int column) + long int column) { - return (SPIBoolean) + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = Accessibility_Table_isColumnSelected (CSPI_OBJREF (obj), - (CORBA_long) column, cspi_ev ()); + column, cspi_ev ()); + + cspi_return_val_if_ev ("isColumnSelected", FALSE); + + return retval; } +/** + * AccessibleTable_addRowSelection: + * @obj: a pointer to the #AccessibleTable implementor on which to operate. + * @row: + * + * Select the specified row, adding it to the current row selection. + * Not all tables support row selection. + * + * Returns: #TRUE if the specified row was successfully selected, #FALSE if not. + **/ +SPIBoolean +AccessibleTable_addRowSelection (AccessibleTable *obj, + long int row) +{ + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + retval = + Accessibility_Table_addRowSelection (CSPI_OBJREF (obj), + row, cspi_ev ()); + + cspi_return_val_if_ev ("addRowSelection", FALSE); + + return retval; +} + +/** + * AccessibleTable_addColumnSelection: + * @obj: a pointer to the #AccessibleTable implementor on which to operate. + * @column: + * + * Select the specified column, adding it to the current column selection. + * Not all tables support column selection. + * + * Returns: #TRUE if the specified column was successfully selected, #FALSE if not. + **/ +SPIBoolean +AccessibleTable_addColumnSelection (AccessibleTable *obj, + long int column) +{ + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = + Accessibility_Table_addColumnSelection (CSPI_OBJREF (obj), + column, cspi_ev ()); + + cspi_return_val_if_ev ("addColumnSelection", FALSE); + + return retval; +} + +/** + * AccessibleTable_removeRowSelection: + * @obj: a pointer to the #AccessibleTable implementor on which to operate. + * @row: + * + * De-select the specified row, removing it to the current row selection. + * Not all tables support row selection. + * + * Returns: #TRUE if the specified row was successfully de-selected, #FALSE if not. + **/ +SPIBoolean +AccessibleTable_removeRowSelection (AccessibleTable *obj, + long int row) +{ + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = + Accessibility_Table_removeRowSelection (CSPI_OBJREF (obj), + row, cspi_ev ()); + + cspi_return_val_if_ev ("removeRowSelection", FALSE); + + return retval; +} + +/** + * AccessibleTable_removeColumnSelection: + * @obj: a pointer to the #AccessibleTable implementor on which to operate. + * @column: + * + * De-select the specified column, removing it to the current column selection. + * Not all tables support column selection. + * + * Returns: #TRUE if the specified column was successfully de-selected, #FALSE if not. + **/ +SPIBoolean +AccessibleTable_removeColumnSelection (AccessibleTable *obj, + long int column) +{ + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = + Accessibility_Table_removeColumnSelection (CSPI_OBJREF (obj), + column, cspi_ev ()); + + cspi_return_val_if_ev ("removeColumnSelection", FALSE); + + return retval; +} /** * AccessibleTable_isSelected: @@ -485,15 +726,23 @@ AccessibleTable_isColumnSelected (AccessibleTable *obj, * Determine whether the cell at a specific row and column is selected. * * Returns: #TRUE if the specified cell is currently selected, #FALSE if not. - * **/ SPIBoolean AccessibleTable_isSelected (AccessibleTable *obj, long int row, long int column) { - return (SPIBoolean) - Accessibility_Table_isSelected (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = + Accessibility_Table_isSelected (CSPI_OBJREF (obj), + row, + column, cspi_ev ()); + + cspi_return_val_if_ev ("isSelected", FALSE); + + return retval; }