Commit 208fc52c authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

mark as needing a recalc, don't just assert it.

2001-12-24  Jody Goldberg <jody@gnome.org>

	* src/style-condition.c (style_condition_expr_eval) : mark as needing
	  a recalc, don't just assert it.

	* src/workbook-edit.c (wbcg_edit_validate) : handle accept/reject/reedit
	  Generate the title and msg here.  The goal is to move the gui
	  specific aspects out of here.
	(wbcg_edit_finish) : ditto.

	* src/gui-validation.c (validation_generate_msg) : disable for now.
	  It is a nice idea, but the implementation is in the wrong place
	  and blows goats.
parent f7c14db3
......@@ -8,7 +8,6 @@ Release Critical
----------------
- name refering to deleted sheet
- validation is not being stored in the cell format dialog
- research reports graph data guru crash
- Changing the summary info does not dirty a workbook.
......
2001-12-24 Jody Goldberg <jody@gnome.org>
* src/style-condition.c (style_condition_expr_eval) : mark as needing
a recalc, don't just assert it.
* src/workbook-edit.c (wbcg_edit_validate) : handle accept/reject/reedit
Generate the title and msg here. The goal is to move the gui
specific aspects out of here.
(wbcg_edit_finish) : ditto.
* src/gui-validation.c (validation_generate_msg) : disable for now.
It is a nice idea, but the implementation is in the wrong place
and blows goats.
2001-12-23 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_view_freeze_panes) : changing the
pane freeze state stops object editing.
* src/sheet-autofill.c (sheet_autofill_dir) : add some very special
purpose code to clip the bounds of autofilled arrays that are being
clipped when filling a non-integer multiple of the original block
......
......@@ -26,10 +26,11 @@ Jody:
* Partial fix for del col/row undo with dependent objects.
* Support some additional forms of #!REF in XL import.
* Fix importing of graphs with embedded graphs.
* Improve autofill handling of merges.
* Improve autofill handling of merges & arrays.
* Support pasting transposed merges.
* Ensure that cell sizes never violate absolute minima.
* Fix format leak (thanks Morten)
* Fix data validation.
Morten:
* Fix DATE.
......
2001-12-24 Jody Goldberg <jody@gnome.org>
* src/style-condition.c (style_condition_expr_eval) : mark as needing
a recalc, don't just assert it.
* src/workbook-edit.c (wbcg_edit_validate) : handle accept/reject/reedit
Generate the title and msg here. The goal is to move the gui
specific aspects out of here.
(wbcg_edit_finish) : ditto.
* src/gui-validation.c (validation_generate_msg) : disable for now.
It is a nice idea, but the implementation is in the wrong place
and blows goats.
2001-12-23 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_view_freeze_panes) : changing the
pane freeze state stops object editing.
* src/sheet-autofill.c (sheet_autofill_dir) : add some very special
purpose code to clip the bounds of autofilled arrays that are being
clipped when filling a non-integer multiple of the original block
......
2001-12-24 Jody Goldberg <jody@gnome.org>
* src/style-condition.c (style_condition_expr_eval) : mark as needing
a recalc, don't just assert it.
* src/workbook-edit.c (wbcg_edit_validate) : handle accept/reject/reedit
Generate the title and msg here. The goal is to move the gui
specific aspects out of here.
(wbcg_edit_finish) : ditto.
* src/gui-validation.c (validation_generate_msg) : disable for now.
It is a nice idea, but the implementation is in the wrong place
and blows goats.
2001-12-23 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_view_freeze_panes) : changing the
pane freeze state stops object editing.
* src/sheet-autofill.c (sheet_autofill_dir) : add some very special
purpose code to clip the bounds of autofilled arrays that are being
clipped when filling a non-integer multiple of the original block
......
2001-12-24 Jody Goldberg <jody@gnome.org>
* src/style-condition.c (style_condition_expr_eval) : mark as needing
a recalc, don't just assert it.
* src/workbook-edit.c (wbcg_edit_validate) : handle accept/reject/reedit
Generate the title and msg here. The goal is to move the gui
specific aspects out of here.
(wbcg_edit_finish) : ditto.
* src/gui-validation.c (validation_generate_msg) : disable for now.
It is a nice idea, but the implementation is in the wrong place
and blows goats.
2001-12-23 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_view_freeze_panes) : changing the
pane freeze state stops object editing.
* src/sheet-autofill.c (sheet_autofill_dir) : add some very special
purpose code to clip the bounds of autofilled arrays that are being
clipped when filling a non-integer multiple of the original block
......
......@@ -1085,6 +1085,11 @@ do_deps_destroy (Sheet *sheet, ExprRewriteInfo const *rwinfo)
deps->single_hash = NULL;
}
if (deps->names) {
g_hash_table_destroy (deps->names);
deps->names = NULL;
}
g_free (deps);
}
......@@ -1203,6 +1208,8 @@ dependency_data_new (void)
(SHEET_MAX_ROWS-1)/BUCKET_SIZE + 1);
deps->single_hash = g_hash_table_new (depsingle_hash,
depsingle_equal);
deps->names = g_hash_table_new (g_direct_hash,
g_direct_equal);
return deps;
}
......
......@@ -39,16 +39,18 @@ typedef enum {
struct _DependencyContainer {
Dependent *dependent_list;
/*
* Large ranges hashed on 'range' to accelerate duplicate
* culling. This is tranversed by g_hash_table_foreach mostly.
/* Large ranges hashed on 'range' to accelerate duplicate culling. This
* is tranversed by g_hash_table_foreach mostly.
*/
GHashTable **range_hash;
/*
* Single ranges, this maps an EvalPos * to a GSList of its
/* Single ranges, this maps an EvalPos * to a GSList of its
* dependencies.
*/
GHashTable *single_hash;
/* All of the ExprNames that refer to this sheet */
GHashTable *names;
};
typedef void (*DepFunc) (Dependent *dep, gpointer user);
......
......@@ -1085,6 +1085,11 @@ do_deps_destroy (Sheet *sheet, ExprRewriteInfo const *rwinfo)
deps->single_hash = NULL;
}
if (deps->names) {
g_hash_table_destroy (deps->names);
deps->names = NULL;
}
g_free (deps);
}
......@@ -1203,6 +1208,8 @@ dependency_data_new (void)
(SHEET_MAX_ROWS-1)/BUCKET_SIZE + 1);
deps->single_hash = g_hash_table_new (depsingle_hash,
depsingle_equal);
deps->names = g_hash_table_new (g_direct_hash,
g_direct_equal);
return deps;
}
......
......@@ -39,16 +39,18 @@ typedef enum {
struct _DependencyContainer {
Dependent *dependent_list;
/*
* Large ranges hashed on 'range' to accelerate duplicate
* culling. This is tranversed by g_hash_table_foreach mostly.
/* Large ranges hashed on 'range' to accelerate duplicate culling. This
* is tranversed by g_hash_table_foreach mostly.
*/
GHashTable **range_hash;
/*
* Single ranges, this maps an EvalPos * to a GSList of its
/* Single ranges, this maps an EvalPos * to a GSList of its
* dependencies.
*/
GHashTable *single_hash;
/* All of the ExprNames that refer to this sheet */
GHashTable *names;
};
typedef void (*DepFunc) (Dependent *dep, gpointer user);
......
......@@ -1693,6 +1693,76 @@ cellref_boundingbox (CellRef const *cr, Range *bound)
}
}
static GSList *
g_slist_insert_unique (GSList *list, gpointer data)
{
if (data != NULL && g_slist_find (list, data) == NULL)
return g_slist_prepend (list, data);
return list;
}
static GSList *
do_referenced_sheets (ExprTree const *expr, GSList *sheets)
{
switch (expr->any.oper) {
case OPER_ANY_BINARY:
return do_referenced_sheets (
expr->binary.value_b,
do_referenced_sheets (
expr->binary.value_b,
sheets));
case OPER_ANY_UNARY:
return do_referenced_sheets (expr->unary.value, sheets);
case OPER_FUNCALL: {
ExprList *l;
for (l = expr->func.arg_list; l; l = l->next)
sheets = do_referenced_sheets (l->data, sheets);
return sheets;
}
case OPER_NAME:
return sheets;
case OPER_VAR:
return g_slist_insert_unique (sheets, expr->var.ref.sheet);
case OPER_CONSTANT: {
Value const *v = expr->constant.value;
if (v->type != VALUE_CELLRANGE)
return sheets;
return g_slist_insert_unique (
g_slist_insert_unique (sheets,
v->v_range.cell.a.sheet),
v->v_range.cell.b.sheet);
}
case OPER_ARRAY:
g_warning ("An array in a NAME ?");
break;
default :
break;
}
return sheets;
}
/**
* expr_tree_referenced_sheets :
* @expr :
* @sheets : usually NULL.
*
* Generates a list of the sheets referenced by the supplied expression.
* Caller must free the list.
*/
GSList *
expr_tree_referenced_sheets (ExprTree const *expr)
{
g_return_val_if_fail (expr != NULL, NULL);
return do_referenced_sheets (expr, NULL);
}
/**
* expr_tree_boundingbox :
*
......
......@@ -212,6 +212,7 @@ FunctionDefinition *expr_tree_get_func_def (ExprTree const *expr);
Value *expr_tree_get_range (ExprTree const *expr) ;
ExprTree const *expr_tree_first_func (ExprTree const *expr);
void expr_tree_boundingbox (ExprTree const *expr, Range *bound);
GSList *expr_tree_referenced_sheets (ExprTree const *expr);
#define expr_list_append g_slist_append
#define expr_list_prepend g_slist_prepend
......
......@@ -26,11 +26,13 @@
#include "style-condition.h"
#include "validation.h"
#include "value.h"
#include "gui-util.h"
#include <libgnome/gnome-i18n.h>
#include <string.h>
#include <locale.h>
#if 0
static char *
validation_generate_msg (StyleCondition *sc)
{
......@@ -40,8 +42,9 @@ validation_generate_msg (StyleCondition *sc)
g_return_val_if_fail (sc != NULL, NULL);
s = g_string_new (_("The value you enter :\n"));
s = g_string_new (_("The value you entered :\n"));
/* FIXME : this should only complain about the contraints that fail, */
/*
* FIXME: Some things need to be done here once we implement
* the other validation types.
......@@ -66,7 +69,7 @@ validation_generate_msg (StyleCondition *sc)
* on the validation action to be taken.
* For "STOP" : "Must be"
* For "WARNING" : "Should be"
* For "INFORMATION" : "Had best be" ?
* For "INFORMATION" : "Are generally" ?
*/
for (sci = sc; sci != NULL; sci = sci->next) {
switch (sci->type) {
......@@ -120,70 +123,45 @@ validation_generate_msg (StyleCondition *sc)
g_string_free (s, FALSE);
return t;
}
#endif
gboolean
validation_get_accept (GtkWindow *parent, Validation const *v)
/**
* validation_get_accept :
* 1 : ignore invalid and accept result
* 0 : discard invalid and finish editing
* -1 : continue editing
*/
int
validation_get_accept (Validation const *v, char const *title, char const *msg,
WorkbookControlGUI *wbcg)
{
GnomeDialog *dialog;
const char *title = v->title ? v->title->str : NULL;
const char *msg = v->msg ? v->msg->str : NULL;
char *msg_auto = NULL;
int ret;
gboolean result = FALSE;
int res0, res1, button;
if (!msg || strlen (msg) == 0)
msg_auto = validation_generate_msg (v->sc);
GtkWidget *dialog;
switch (v->vs) {
case VALIDATION_STYLE_NONE :
result = TRUE;
break;
case VALIDATION_STYLE_STOP :
dialog = GNOME_DIALOG (
gnome_message_box_new (
msg_auto ? msg_auto : msg, GNOME_MESSAGE_BOX_ERROR,
_("Ok"), NULL));
gnome_dialog_set_parent (dialog, parent);
if (title)
gtk_window_set_title (GTK_WINDOW (dialog), title);
gnome_dialog_run (dialog);
result = FALSE;
res0 = -1; res1 = 0;
dialog = gnome_message_box_new ( msg, GNOME_MESSAGE_BOX_ERROR,
_("Re-Edit"), _("Discard"), NULL);
break;
case VALIDATION_STYLE_WARNING :
dialog = GNOME_DIALOG (
gnome_message_box_new (
msg_auto ? msg_auto : msg , GNOME_MESSAGE_BOX_WARNING,
_("Accept"), _("Discard"), NULL));
/* FIXME: This doesn't seem to have any effect */
gnome_dialog_set_default (dialog, 0);
gnome_dialog_set_parent (dialog, parent);
if (title)
gtk_window_set_title (GTK_WINDOW (dialog), title);
ret = gnome_dialog_run (dialog);
if (ret == 0)
result = TRUE;
else
result = FALSE;
res0 = 1; res1 = 0;
dialog = gnome_message_box_new (msg , GNOME_MESSAGE_BOX_WARNING,
_("Accept"), _("Discard"), NULL);
break;
case VALIDATION_STYLE_INFO :
dialog = GNOME_DIALOG (
gnome_message_box_new (
msg_auto ? msg_auto : msg, GNOME_MESSAGE_BOX_INFO,
_("Ok"), NULL));
gnome_dialog_set_parent (dialog, parent);
if (title)
gtk_window_set_title (GTK_WINDOW (dialog), title);
gnome_dialog_run (dialog);
result = TRUE;
res0 = res1 = 1;
dialog = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO,
_("Ok"), NULL);
break;
default :
g_warning ("Unknown validation handler");
result = FALSE;
default : g_return_val_if_fail (FALSE, 1);
}
if (msg_auto)
g_free (msg_auto);
if (title)
gtk_window_set_title (GTK_WINDOW (dialog), title);
gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
button = gnumeric_dialog_run (wbcg, GNOME_DIALOG (dialog));
return result;
return (button != 1) ? res0 : res1;
}
#ifndef GNUMERIC_GUI_VALIDATION_H
#define GNUMERIC_GUI_VALIDATION_H
#include "workbook-control-gui.h"
#include "mstyle.h"
#include "gui-gnumeric.h"
gboolean validation_get_accept (GtkWindow *parent, Validation const *v);
int validation_get_accept (Validation const *v,
char const *title, char const *msg,
WorkbookControlGUI *wbcg);
#endif /* GNUMERIC_GUI_VALIDATION_H */
......@@ -232,12 +232,8 @@ style_condition_expr_eval (StyleConditionExpr *sce, Value *val, StyleFormat *for
{
ValueCompare vc;
/*
* Apparantly no eval has been done yet, so
* we'll have to force it.
*/
if (sce->val == NULL) {
g_return_val_if_fail (dependent_needs_recalc (&sce->dep), FALSE);
sce->dep.flags |= DEPENDENT_NEEDS_RECALC;
dependent_eval (&sce->dep);
g_return_val_if_fail (sce->val != NULL, FALSE);
}
......
......@@ -31,6 +31,7 @@
#include "workbook-edit.h"
#include "workbook.h"
#include "sheet.h"
#include "sheet-merge.h"
#include "sheet-private.h"
#include "sheet-control-gui-priv.h"
#include "gnumeric-canvas.h"
......@@ -1907,6 +1908,7 @@ cb_view_freeze_panes (GtkWidget *widget, WorkbookControlGUI *wbcg)
Sheet *sheet = wb_control_cur_sheet (wbc);
SheetControlGUI *scg = wb_control_gui_cur_sheet (wbcg);
scg_mode_edit (SHEET_CONTROL (scg));
if (scg->active_panes == 1) {
CellPos frozen_tl, unfrozen_tl;
GnumericCanvas const *gcanvas = scg_pane (scg, 0);
......
......@@ -128,45 +128,49 @@ wbcg_edit_error_dialog (WorkbookControlGUI *wbcg, char *str)
/**
* wbcg_edit_validate:
*
* Either pass @tree or @val.
* Either pass @expr or @val.
* The parameters will be validated against the
* validation set in the MStyle if applicable.
*
* Return value: TRUE if the validation checks out ok, FALSE otherwise.
* Return value:
* 1 : things validate
* 0 : things do not validate and should be discarded
* -1 : things do not validate and editing should continue
**/
static gboolean
static int
wbcg_edit_validate (WorkbookControlGUI *wbcg, MStyle const *mstyle,
ExprTree const *tree, Value *val)
ExprTree const *expr, Value *val)
{
Validation *v;
StyleCondition *sc;
Sheet *sheet;
gboolean result = TRUE;
v = mstyle_get_validation (mstyle);
g_return_val_if_fail (mstyle_is_element_set (mstyle, MSTYLE_VALIDATION), TRUE);
Validation *v = mstyle_get_validation (mstyle);
int result = 1;
sc = v->sc;
sheet = wbcg->editing_sheet;
g_return_val_if_fail (v != NULL, 1);
if (sc) {
Value *valt;
Cell *cell = sheet_cell_get (sheet, sheet->edit_pos.col, sheet->edit_pos.row);
if (v->sc != NULL) {
Value *tmp;
Sheet *sheet = wbcg->editing_sheet;
Cell *cell = sheet_cell_get (sheet,
sheet->edit_pos.col, sheet->edit_pos.row);
if (!val) {
if (expr != NULL) {
EvalPos ep;
valt = expr_eval (tree, eval_pos_init (&ep, sheet, &sheet->edit_pos), 0);
tmp = expr_eval (expr, eval_pos_init_cell (&ep, cell),
EVAL_STRICT);
} else
valt = val;
g_return_val_if_fail (valt != NULL, FALSE);
result = style_condition_eval (sc, valt, cell ? cell->format : NULL);
if (!val)
value_release (valt);
tmp = val;
if (!style_condition_eval (v->sc, tmp, cell ? cell->format : NULL) &&
v->vs != VALIDATION_STYLE_NONE) {
char const *title = (v->title && v->title->str[0]) ? v->title->str
: _("Gnumeric : Validation");
char const *msg = (v->msg && v->msg->str[0]) ? v->msg->str
: _("That value is invalid.\n"
"Restrictions have been placed on this cell's content.");
result = validation_get_accept (v, title, msg, wbcg);
}
if (!result)
result = validation_get_accept (wbcg->toplevel, v);
if (tmp != val)
value_release (tmp);
}
return result;
......@@ -262,7 +266,14 @@ wbcg_edit_finish (WorkbookControlGUI *wbcg, gboolean accept)
}
if (mstyle_is_element_set (mstyle, MSTYLE_VALIDATION))
is_valid = wbcg_edit_validate (wbcg, mstyle, expr, value);
switch (wbcg_edit_validate (wbcg, mstyle, expr, value)) {
case 1 : is_valid = TRUE; break;
case 0 : is_valid = FALSE; break;
case -1 : gtk_window_set_focus (GTK_WINDOW (wbcg->toplevel),
GTK_WIDGET (wbcg_get_entry (wbcg)));
return FALSE;
};
if (value != NULL)
value_release (value);
if (expr != NULL)
......
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