USER_OBJECT_ RGnumeric_getCellComment(USER_OBJECT_ scell) { Cell *cell; CellComment *comment; char const *tmp; USER_OBJECT_ ans; const char *slotNames[] = {"comment", "author"}; cell = RGnumeric_resolveCellReference(scell); if(!cell) { PROBLEM "cell is empty" ERROR; } comment = cell_has_comment(cell); if(comment == NULL) { return(NULL_USER_OBJECT); } PROTECT(ans = NEW_CHARACTER(2)); tmp = cell_comment_text_get(comment); if(tmp) { SET_STRING_ELT(ans, 0, COPY_TO_USER_STRING(tmp)); } tmp = cell_comment_author_get(comment); if(tmp) { SET_STRING_ELT(ans, 1, COPY_TO_USER_STRING(tmp)); } Internal_setNames(slotNames, 2, ans); UNPROTECT(1); return(ans); }
static void search_get_value (gint row, gint column, gpointer _dd, GValue *value) { DialogState *dd = (DialogState *)_dd; GnumericLazyList *ll = GNUMERIC_LAZY_LIST (gtk_tree_view_get_model (dd->matches_table)); GnmSearchFilterResult *item = g_ptr_array_index (dd->matches, row); GnmCell *cell; GnmComment *comment; if (item->locus == GNM_SRL_COMMENT) { cell = NULL; comment = sheet_get_comment (item->ep.sheet, &item->ep.eval); } else { cell = sheet_cell_get (item->ep.sheet, item->ep.eval.col, item->ep.eval.row); comment = NULL; } g_value_init (value, ll->column_headers[column]); #if 0 g_print ("col=%d,row=%d\n", column, row); #endif switch (column) { case COL_SHEET: g_value_set_string (value, item->ep.sheet->name_unquoted); return; case COL_CELL: g_value_set_string (value, cellpos_as_string (&item->ep.eval)); return; case COL_TYPE: switch (item->locus) { case GNM_SRL_COMMENT: g_value_set_static_string (value, _("Comment")); return; case GNM_SRL_VALUE: g_value_set_static_string (value, _("Result")); return; case GNM_SRL_CONTENTS: { GnmValue *v = cell ? cell->value : NULL; char const *type; gboolean is_expr = cell && gnm_cell_has_expr (cell); gboolean is_value = !is_expr && !gnm_cell_is_empty (cell) && v; if (!cell) type = _("Deleted"); else if (is_expr) type = _("Expression"); else if (is_value && VALUE_IS_STRING (v)) type = _("String"); else if (is_value && VALUE_IS_FLOAT (v)) type = _("Number"); else type = _("Other value"); g_value_set_static_string (value, type); return; } #ifndef DEBUG_SWITCH_ENUM default: g_assert_not_reached (); #endif } case COL_CONTENTS: switch (item->locus) { case GNM_SRL_COMMENT: if (comment) g_value_set_string (value, cell_comment_text_get (comment)); else g_value_set_static_string (value, _("Deleted")); return; case GNM_SRL_VALUE: if (cell && cell->value) g_value_take_string (value, value_get_as_string (cell->value)); else g_value_set_static_string (value, _("Deleted")); return; case GNM_SRL_CONTENTS: if (cell) g_value_take_string (value, gnm_cell_get_entered_text (cell)); else g_value_set_static_string (value, _("Deleted")); return; #ifndef DEBUG_SWITCH_ENUM default: g_assert_not_reached (); #endif } #ifndef DEBUG_SWITCH_ENUM default: g_assert_not_reached (); #endif } }