Index: src/validation.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/validation.c,v
retrieving revision 1.5.2.2
diff -u -p -r1.5.2.2 validation.c
--- src/validation.c 2002/02/15 20:25:49 1.5.2.2
+++ src/validation.c 2002/02/20 22:34:06
@@ -122,7 +122,7 @@ validation_eval (WorkbookControl *wbc, M
return VALIDATION_STATUS_VALID;
v = mstyle_get_validation (mstyle);
- g_return_val_if_fail (v != NULL, 1);
+ g_return_val_if_fail (v != NULL, VALIDATION_STATUS_VALID);
if (v->style == VALIDATION_TYPE_ANY)
return VALIDATION_STATUS_VALID;
@@ -141,6 +141,9 @@ validation_eval (WorkbookControl *wbc, M
Value *val = cell->value;
switch (v->type) {
+ case VALIDATION_TYPE_AS_DATE : /* What the hell does this do */
+ case VALIDATION_TYPE_AS_TIME : /* What the hell does this do */
+#warning TODO
case VALIDATION_TYPE_ANY :
return VALIDATION_STATUS_VALID;
@@ -154,29 +157,32 @@ validation_eval (WorkbookControl *wbc, M
}
}
- case VALIDATION_TYPE_AS_DATE : /* What the hell does this do */
- case VALIDATION_TYPE_AS_TIME : /* What the hell does this do */
case VALIDATION_TYPE_AS_NUMBER :
- if (val->type == VALUE_ERROR)
+ switch (val->type) {
+ case VALUE_ERROR:
msg = g_strdup_printf (_("'%s' is an error"),
val->v_err.mesg->str);
- else if (cell->value->type == VALUE_STRING) {
+ break;
+ case VALUE_STRING: {
Value *res = format_match_number (val->v_str.val->str, NULL, NULL);
if (res == NULL) {
char const *fmt;
- /* FIXME what else is needed */
- if (v->type == VALIDATION_TYPE_AS_DATE) {
- fmt = N_("'%s' is not a valid date");
- } else if (v->type == VALIDATION_TYPE_AS_TIME) {
- fmt = N_("'%s' is not a valid time");
- } else
- fmt = N_("'%s' is not a number");
+ fmt = N_("'%s' is not a number");
msg = g_strdup_printf (_(fmt), val->v_str.val->str);
} else
val_expr = expr_tree_new_constant (res);
- } else
+ break;
+ }
+ case VALUE_FLOAT:
+ case VALUE_INTEGER:
val_expr = expr_tree_new_constant (
value_duplicate (cell->value));
+ break;
+ default:
+ /* all others are errors */
+ msg = g_strdup_printf (_("Not a number."));
+ break;
+ }
break;
case VALIDATION_TYPE_IN_LIST :
@@ -200,7 +206,7 @@ validation_eval (WorkbookControl *wbc, M
break;
}
- if (msg == NULL && expr == NULL) {
+ if (msg == NULL && expr == NULL/*not custom*/) {
Operation op;
g_return_val_if_fail (val_expr != NULL, VALIDATION_STATUS_VALID);
@@ -244,8 +250,9 @@ validation_eval (WorkbookControl *wbc, M
return VALIDATION_STATUS_VALID;
}
- if (v->op == VALIDATION_OP_BETWEEN || v->op == VALIDATION_OP_NOT_BETWEEN) {
- g_return_val_if_fail (v->expr[1] != NULL, VALIDATION_STATUS_VALID);
+ if ((valid && v->op == VALIDATION_OP_BETWEEN) || v->op == VALIDATION_OP_NOT_BETWEEN) {
+ if (v->expr [1] == NULL)
+ return VALIDATION_STATUS_VALID;
expr_tree_ref (v->expr[1]);
expr = expr_tree_new_binary (val_expr,
@@ -259,10 +266,11 @@ validation_eval (WorkbookControl *wbc, M
return VALIDATION_STATUS_VALID;
}
}
+ /* condition was not valid. */
expr_str = expr_tree_as_string (expr,
parse_pos_init_evalpos (&pp, &ep));
- msg = g_strdup_printf (_("%s is not true."), expr_str);
+ msg = g_strdup_printf (_("The validation condition %s is not satified."), expr_str);
g_free (expr_str);
}
}
Index: src/dialogs/cell-format.glade
===================================================================
RCS file: /cvs/gnome/gnumeric/src/dialogs/cell-format.glade,v
retrieving revision 1.46.2.1
diff -u -p -r1.46.2.1 cell-format.glade
--- src/dialogs/cell-format.glade 2002/02/19 00:27:24 1.46.2.1
+++ src/dialogs/cell-format.glade 2002/02/20 22:34:06
@@ -3454,7 +3453,7 @@ Custom
validation_operator
True
min <= val <= max (between)
-val <= min || max <= val (not between)
+val < min or max < val (not between)
val == bound (equal to)
val != bound (not equal to)
val > bound (greater than)
Index: src/dialogs/dialog-cell-format.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/dialogs/dialog-cell-format.c,v
retrieving revision 1.195
diff -u -p -r1.195 dialog-cell-format.c
--- src/dialogs/dialog-cell-format.c 2002/01/12 08:07:01 1.195
+++ src/dialogs/dialog-cell-format.c 2002/02/20 22:34:06
@@ -2018,7 +2042,16 @@ validation_entry_from_expr (GnumericExpr
static ExprTree *
validation_entry_to_expr (Sheet *sheet, GnumericExprEntry *gee)
{
+ GnumericExprEntryFlags flags;
ParsePos pp;
+ /* The entry is not guaranteed to be focused upon before this
+ * function is called, thus cb_fmt_dialog_set_focus may not have
+ * been called and we need to set the expr_entry flags ourselves
+ * (in particular clearing GNUM_EE_SINGLE_RANGE). */
+ flags = GNUM_EE_ABS_ROW | GNUM_EE_ABS_COL | GNUM_EE_SHEET_OPTIONAL;
+ gnumeric_expr_entry_set_flags (gee,
+ flags, flags | GNUM_EE_SINGLE_RANGE);
+
return gnumeric_expr_entry_parse (gee,
parse_pos_init (&pp, sheet->workbook, sheet, 0, 0), FALSE);
}