Commit 2fbc774b authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

see if there is a named expression that matches the selection. ditto. new.


2002-09-23  Jody Goldberg <jody@gnome.org>

	* src/sheet-view.c (sv_update) : see if there is a named expression that
	  matches the selection.
	* src/workbook-view.c (wb_view_selection_desc) : ditto.
	* src/expr-name.c (sheet_names_check) : new.

	* src/parse-util.c (cellref_a1_get) : add bound check for columns too.

	* src/func.c (function_call_with_list) : silence some pointless
	  warnings.
	* src/workbook-control-gui.c (workbook_menu_edit) : fix cut-n-paste-o.
	(cb_statusbox_focus) : Clear selection on focus out.  I'd like to
	  select everything on focus in, but gtkentry is not thrilled with
	  that.
	* src/workbook-control-gui.c (workbook_setup_edit_area) : connect
	  cb_status_box_focus.
parent deeda4d1
2002-09-23 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c (sv_update) : see if there is a named expression that
matches the selection.
* src/workbook-view.c (wb_view_selection_desc) : ditto.
* src/expr-name.c (sheet_names_check) : new.
* src/parse-util.c (cellref_a1_get) : add bound check for columns too.
* src/func.c (function_call_with_list) : silence some pointless
warnings.
* src/workbook-control-gui.c (workbook_menu_edit) : fix cut-n-paste-o.
(cb_statusbox_focus) : Clear selection on focus out. I'd like to
select everything on focus in, but gtkentry is not thrilled with
that.
* src/workbook-control-gui.c (workbook_setup_edit_area) : connect
cb_status_box_focus.
2002-09-22 Jon K Hellan <hellan@acm.org>
* src/func.c (function_dump_defs): Re-enable function doc dumping.
......
2002-09-23 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c (sv_update) : see if there is a named expression that
matches the selection.
* src/workbook-view.c (wb_view_selection_desc) : ditto.
* src/expr-name.c (sheet_names_check) : new.
* src/parse-util.c (cellref_a1_get) : add bound check for columns too.
* src/func.c (function_call_with_list) : silence some pointless
warnings.
* src/workbook-control-gui.c (workbook_menu_edit) : fix cut-n-paste-o.
(cb_statusbox_focus) : Clear selection on focus out. I'd like to
select everything on focus in, but gtkentry is not thrilled with
that.
* src/workbook-control-gui.c (workbook_setup_edit_area) : connect
cb_status_box_focus.
2002-09-22 Jon K Hellan <hellan@acm.org>
* src/func.c (function_dump_defs): Re-enable function doc dumping.
......
2002-09-23 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c (sv_update) : see if there is a named expression that
matches the selection.
* src/workbook-view.c (wb_view_selection_desc) : ditto.
* src/expr-name.c (sheet_names_check) : new.
* src/parse-util.c (cellref_a1_get) : add bound check for columns too.
* src/func.c (function_call_with_list) : silence some pointless
warnings.
* src/workbook-control-gui.c (workbook_menu_edit) : fix cut-n-paste-o.
(cb_statusbox_focus) : Clear selection on focus out. I'd like to
select everything on focus in, but gtkentry is not thrilled with
that.
* src/workbook-control-gui.c (workbook_setup_edit_area) : connect
cb_status_box_focus.
2002-09-22 Jon K Hellan <hellan@acm.org>
* src/func.c (function_dump_defs): Re-enable function doc dumping.
......
......@@ -292,7 +292,7 @@ name_guru_populate_list (NameGuruState *state)
gtk_list_clear_items (state->list, 0, -1);
g_list_free (state->expr_names);
state->expr_names = sheet_get_available_names (state->sheet);
state->expr_names = sheet_names_get_available (state->sheet);
list = GTK_CONTAINER (state->list);
for (names = state->expr_names ; names != NULL ; names = g_list_next (names)) {
......
......@@ -22,6 +22,7 @@
#include "expr-impl.h"
#include "str.h"
#include "sheet.h"
#include "ranges.h"
#include "sheet-style.h"
#include <gdk/gdkkeysyms.h>
......@@ -638,7 +639,7 @@ expr_name_shutdown (void)
/******************************************************************************/
/**
* sheet_get_available_names :
* sheet_names_get_available :
* A convenience routine to get the list of names associated with @sheet and its
* workbook.
*
......@@ -646,7 +647,7 @@ expr_name_shutdown (void)
* Names in the list do NOT have additional references added.
*/
GList *
sheet_get_available_names (Sheet const *sheet)
sheet_names_get_available (Sheet const *sheet)
{
GList *l = NULL;
......@@ -656,3 +657,61 @@ sheet_get_available_names (Sheet const *sheet)
return g_list_concat (l, g_list_copy (sheet->workbook->names));
}
static char const *
namelist_check (GList *ptr, Sheet const *sheet, Range const *r)
{
Value *v;
GnmNamedExpr *nexpr;
for (; ptr != NULL ; ptr = ptr->next) {
nexpr = ptr->data;
if (!nexpr->active || nexpr->builtin)
continue;
v = gnm_expr_get_range (nexpr->t.expr_tree);
if (v != NULL) {
if (v->type == VALUE_CELLRANGE) {
RangeRef const *ref = &v->v_range.cell;
if (!ref->a.col_relative &&
!ref->a.row_relative &&
!ref->b.col_relative &&
!ref->b.row_relative &&
eval_sheet (ref->a.sheet, sheet) == sheet &&
eval_sheet (ref->b.sheet, sheet) == sheet &&
MIN (ref->a.col, ref->b.col) == r->start.col &&
MAX (ref->a.col, ref->b.col) == r->end.col &&
MIN (ref->a.row, ref->b.row) == r->start.row &&
MAX (ref->a.row, ref->b.row) == r->end.row) {
value_release (v);
return nexpr->name->str;
}
}
value_release (v);
}
}
return NULL;
}
/**
* sheet_names_check :
* @sheet :
* @r :
*
* Returns a constant string if @sheet!@r is the target of a named range.
* Preference is given to workbook scope over sheet.
**/
char const *
sheet_names_check (Sheet const *sheet, Range const *r)
{
char const *res;
Range tmp;
g_return_val_if_fail (IS_SHEET (sheet), NULL);
g_return_val_if_fail (r != NULL, NULL);
tmp = *r;
range_normalize (&tmp);
res = namelist_check (sheet->workbook->names, sheet, &tmp);
if (res != NULL)
return res;
return namelist_check (sheet->names, sheet, &tmp);
}
......@@ -44,6 +44,7 @@ void expr_name_list_destroy (GList **names);
void expr_name_init (void);
void expr_name_shutdown (void);
GList *sheet_get_available_names (Sheet const *sheet);
GList *sheet_names_get_available (Sheet const *sheet);
char const *sheet_names_check (Sheet const *sheet, Range const *r);
#endif /* GNUMERIC_EXPR_NAME_H */
......@@ -739,9 +739,9 @@ function_call_with_list (FunctionEvalInfo *ei, GnmExprList *l,
GnmExprEvalFlags flags)
{
FunctionDefinition const *fn_def;
int argc, i, optional, iter_count, iter_width, iter_height;
int argc, i, optional, iter_count, iter_width = 0, iter_height = 0;
char arg_type;
Value *tmp, **args;
Value **args, *tmp = NULL;
GnmExpr *expr;
int *iter_item = NULL;
......
......@@ -261,6 +261,8 @@ cellref_a1_get (CellRef *out, char const *in, CellPos const *pos)
col = (col + 1) * ('Z' - 'A' + 1) + toupper (uc) - 'A';
in++;
}
if (col >= SHEET_MAX_COLS)
return NULL;
/* Try to parse a row */
if (*in == '$') {
......
......@@ -546,7 +546,10 @@ sv_update (SheetView *sv)
if (sv->edit_pos_changed.location) {
sv->edit_pos_changed.location = FALSE;
if (wb_view_cur_sheet_view (sv->wbv) == sv) {
char const *new_pos = cell_pos_name (&sv->edit_pos);
char const *new_pos = sheet_names_check (sv->sheet,
selection_first_range (sv, NULL, NULL));
if (new_pos == NULL)
new_pos = cell_pos_name (&sv->edit_pos);
SHEET_VIEW_FOREACH_CONTROL (sv, sc,
wb_control_selection_descr_set (sc_wbc (sc), new_pos););
}
......
......@@ -3057,7 +3057,8 @@ static GnomeUIInfo workbook_menu_edit [] = {
{ GNOME_APP_UI_ITEM, N_("_Goto cell..."),
N_("Jump to a specified cell"),
cb_edit_goto,
GNOME_APP_PIXMAP_STOCK, GTK_STOCK_JUMP_TO, 0, 0, GDK_F5, 0 },
NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GTK_STOCK_JUMP_TO, GDK_F5, 0 },
{ GNOME_APP_UI_ITEM, N_("Recalculate"),
N_("Recalculate the spreadsheet"),
......@@ -3795,11 +3796,21 @@ cb_editline_focus_in (GtkWidget *w, GdkEventFocus *event,
}
static void
wb_jump_to_cell (GtkEntry *entry, WorkbookControlGUI *wbcg)
cb_statusbox_activate (GtkEntry *entry, WorkbookControlGUI *wbcg)
{
wb_control_parse_and_jump (WORKBOOK_CONTROL (wbcg), gtk_entry_get_text (entry));
wb_control_parse_and_jump (WORKBOOK_CONTROL (wbcg),
gtk_entry_get_text (entry));
wbcg_focus_cur_scg (wbcg);
}
static gboolean
cb_statusbox_focus (GtkEntry *entry, GdkEventFocus *event,
WorkbookControlGUI *wbcg)
{
gtk_editable_select_region (GTK_EDITABLE (entry), 0, 0);
return FALSE;
}
/******************************************************************************/
static Value *
cb_share_a_cell (Sheet *sheet, int col, int row, Cell *cell, gpointer _es)
......@@ -3945,10 +3956,14 @@ workbook_setup_edit_area (WorkbookControlGUI *wbcg)
"focus-in-event",
G_CALLBACK (cb_editline_focus_in), wbcg);
/* Do signal setup for the status input line */
/* status box */
g_signal_connect (G_OBJECT (wbcg->selection_descriptor),
"activate",
G_CALLBACK (wb_jump_to_cell), wbcg);
G_CALLBACK (cb_statusbox_activate), wbcg);
g_signal_connect (G_OBJECT (wbcg->selection_descriptor),
"focus-out-event",
G_CALLBACK (cb_statusbox_focus), wbcg);
gtk_widget_show_all (box2);
}
......
......@@ -239,9 +239,11 @@ wb_view_selection_desc (WorkbookView *wbv, gboolean use_pos,
if (use_pos || range_is_singleton (r) ||
(NULL != (m = sheet_merge_is_corner (sv->sheet, &r->start)) &&
range_equal (r, m)))
sel_descr = cell_pos_name (&r->start);
else
range_equal (r, m))) {
sel_descr = sheet_names_check (sv->sheet, r);
if (sel_descr == NULL)
sel_descr = cell_pos_name (&r->start);
} else
snprintf (buffer, sizeof (buffer), _("%dR x %dC"),
r->end.row - r->start.row + 1,
r->end.col - r->start.col + 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment