Commit 57d5df3c authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

actually display the returned error.

2001-10-22  Jody Goldberg <jgoldberg@home.com>

	* dialog-define-names.c (cb_name_guru_add) : actually display the
	  returned error.

2001-10-22  Jody Goldberg <jgoldberg@home.com>

	* src/expr-name.c (name_refer_circular) : fix.
parent 26b8c5fe
2001-10-21 Jody Goldberg <jgoldberg@home.com>
2001-10-22 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (name_refer_circular) : fix.
* src/print.c (print_sheet_objects) : filter hidden objects.
......
2001-10-21 Jody Goldberg <jgoldberg@home.com>
2001-10-22 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (name_refer_circular) : fix.
* src/print.c (print_sheet_objects) : filter hidden objects.
......
2001-10-21 Jody Goldberg <jgoldberg@home.com>
2001-10-22 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (name_refer_circular) : fix.
* src/print.c (print_sheet_objects) : filter hidden objects.
......
2001-10-21 Jody Goldberg <jgoldberg@home.com>
2001-10-22 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (name_refer_circular) : fix.
* src/print.c (print_sheet_objects) : filter hidden objects.
......
2001-10-22 Jody Goldberg <jgoldberg@home.com>
* dialog-define-names.c (cb_name_guru_add) : actually display the
returned error.
2001-10-21 Jody Goldberg <jgoldberg@home.com>
* dialog-graph-guru.c (dialog_graph_guru) : Users are probably
......
......@@ -439,7 +439,6 @@ cb_name_guru_add (NameGuruState *state)
ParseError perr;
ExprTree *expr;
char const *name, *expr_text, *tmp;
gchar *error;
g_return_val_if_fail (state != NULL, FALSE);
......@@ -467,6 +466,7 @@ cb_name_guru_add (NameGuruState *state)
if (expr == NULL) {
gnumeric_notice (state->wbcg, GNOME_MESSAGE_BOX_ERROR, perr.message);
gtk_widget_grab_focus (GTK_WIDGET (state->expr_text));
parse_error_free (&perr);
return FALSE;
} else if (expr_name) {
if (!expr_name->builtin) {
......@@ -480,10 +480,18 @@ cb_name_guru_add (NameGuruState *state)
gnumeric_notice (state->wbcg, GNOME_MESSAGE_BOX_ERROR,
_("You cannot redefine a builtin name."));
} else {
char *error = NULL;
if (name_guru_scope_get (state) == NAME_GURU_SCOPE_WORKBOOK)
expr_name = expr_name_add (state->wb, NULL, name, expr, &error);
else
expr_name = expr_name_add (NULL, state->sheet, name, expr, &error);
if (expr_name == NULL) {
g_return_val_if_fail (error != NULL, FALSE);
gnumeric_notice (state->wbcg, GNOME_MESSAGE_BOX_ERROR, error);
gtk_widget_grab_focus (GTK_WIDGET (state->expr_text));
return FALSE;
}
}
g_return_val_if_fail (expr_name != NULL, FALSE);
......
......@@ -97,28 +97,22 @@ name_refer_circular (const char *name, ExprTree *expr)
switch (expr->any.oper) {
case OPER_ANY_BINARY:
if (!name_refer_circular (name, expr->binary.value_a))
return TRUE;
if (!name_refer_circular (name, expr->binary.value_b))
return TRUE;
break;
return (name_refer_circular (name, expr->binary.value_a) ||
name_refer_circular (name, expr->binary.value_b));
case OPER_ANY_UNARY:
if (!name_refer_circular (name, expr->unary.value))
return TRUE;
break;
case OPER_NAME:
{
const NamedExpression *expr_name = expr->name.name;
return name_refer_circular (name, expr->unary.value);
case OPER_NAME: {
NamedExpression const *expr_name = expr->name.name;
if (expr_name->builtin)
return FALSE;
if (!g_strcasecmp (expr_name->name->str, name))
return TRUE;
/* And look inside this name tree too */
if (!expr_name->builtin &&
!name_refer_circular (name, expr_name->t.expr_tree))
return TRUE;
break;
return name_refer_circular (name, expr_name->t.expr_tree);
}
case OPER_FUNCALL:
{
case OPER_FUNCALL: {
GList *l = expr->func.arg_list;
while (l) {
if (name_refer_circular (name, l->data))
......@@ -156,11 +150,11 @@ expr_name_add (Workbook *wb, Sheet *sheet, const char *name,
{
NamedExpression *expr_name;
g_return_val_if_fail (name != NULL, 0);
g_return_val_if_fail (expr != NULL, 0);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (expr != NULL, NULL);
/* sheet, workbook, or global. Pick only 1 */
g_return_val_if_fail (sheet == NULL || wb == NULL, 0);
g_return_val_if_fail (sheet == NULL || wb == NULL, NULL);
/* printf ("Adding name '%s' to %p %p\n", name, wb, sheet);*/
......
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