Commit f86b3d74 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Switch the BIFF_WINDOW2 0x23e -> 0x3e (write_names) : fix biff type.

2001-05-27  Jody Goldberg <jgoldberg@home.com>

	* ms-excel-write.c (write_window2) :
	  Switch the BIFF_WINDOW2 0x23e -> 0x3e
	(write_names) : fix biff type.

	* ms-excel-read.c (ms_excel_read_formula) : cleanup some old
	  inconsistentcies.  keep as many of the BIFF_* using their major
	  types.
	  Switch the BIFF_STRING 0x207 -> 0x07
	  Switch the BIFF_BOOLERR 0x205 -> 0x05
	(ms_excel_read_window2) : split this out into a neater bundle.

2001-05-27  Jody Goldberg <jgoldberg@home.com>

	* src/eval.c (sheet_region_queue_recalc) : Queue the dependents in the
	  region not just those that depend on it.
	(cell_queue_recalc) : no need to queue non expression cells.

2001-05-27  Jody Goldberg <jgoldberg@home.com>

	* src/expr.c (eval_expr_real) : recurse for arrays too.
	(expr_tree_array_corner) : rename from expr_tree_array_formula_corner,
	  and return the corner, not the expression in the corner.

	* src/eval.c (cb_range_hash_invalidate) : invalidate and free things
	  in place.
	(cb_single_hash_invalidate) : ditto.
	(do_deps_destroy) : simplify.

	* src/workbook-control-gui.c (wbcg_sheet_rename) : Use the table not
	  the container.
parent f0ded15a
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/eval.c (sheet_region_queue_recalc) : Queue the dependents in the
region not just those that depend on it.
(cell_queue_recalc) : no need to queue non expression cells.
2001-05-27 Nathan Cullen <furyu@fuse.net>
* src/history.c (history_menu_insert_separator): Fixed keyboard
......@@ -7,6 +13,15 @@
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : recurse for arrays too.
(expr_tree_array_corner) : rename from expr_tree_array_formula_corner,
and return the corner, not the expression in the corner.
* src/eval.c (cb_range_hash_invalidate) : invalidate and free things
in place.
(cb_single_hash_invalidate) : ditto.
(do_deps_destroy) : simplify.
* src/workbook-control-gui.c (wbcg_sheet_rename) : Use the table not
the container.
......
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/eval.c (sheet_region_queue_recalc) : Queue the dependents in the
region not just those that depend on it.
(cell_queue_recalc) : no need to queue non expression cells.
2001-05-27 Nathan Cullen <furyu@fuse.net>
* src/history.c (history_menu_insert_separator): Fixed keyboard
......@@ -7,6 +13,15 @@
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : recurse for arrays too.
(expr_tree_array_corner) : rename from expr_tree_array_formula_corner,
and return the corner, not the expression in the corner.
* src/eval.c (cb_range_hash_invalidate) : invalidate and free things
in place.
(cb_single_hash_invalidate) : ditto.
(do_deps_destroy) : simplify.
* src/workbook-control-gui.c (wbcg_sheet_rename) : Use the table not
the container.
......
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/eval.c (sheet_region_queue_recalc) : Queue the dependents in the
region not just those that depend on it.
(cell_queue_recalc) : no need to queue non expression cells.
2001-05-27 Nathan Cullen <furyu@fuse.net>
* src/history.c (history_menu_insert_separator): Fixed keyboard
......@@ -7,6 +13,15 @@
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : recurse for arrays too.
(expr_tree_array_corner) : rename from expr_tree_array_formula_corner,
and return the corner, not the expression in the corner.
* src/eval.c (cb_range_hash_invalidate) : invalidate and free things
in place.
(cb_single_hash_invalidate) : ditto.
(do_deps_destroy) : simplify.
* src/workbook-control-gui.c (wbcg_sheet_rename) : Use the table not
the container.
......
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/eval.c (sheet_region_queue_recalc) : Queue the dependents in the
region not just those that depend on it.
(cell_queue_recalc) : no need to queue non expression cells.
2001-05-27 Nathan Cullen <furyu@fuse.net>
* src/history.c (history_menu_insert_separator): Fixed keyboard
......@@ -7,6 +13,15 @@
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : recurse for arrays too.
(expr_tree_array_corner) : rename from expr_tree_array_formula_corner,
and return the corner, not the expression in the corner.
* src/eval.c (cb_range_hash_invalidate) : invalidate and free things
in place.
(cb_single_hash_invalidate) : ditto.
(do_deps_destroy) : simplify.
* src/workbook-control-gui.c (wbcg_sheet_rename) : Use the table not
the container.
......
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/eval.c (sheet_region_queue_recalc) : Queue the dependents in the
region not just those that depend on it.
(cell_queue_recalc) : no need to queue non expression cells.
2001-05-27 Nathan Cullen <furyu@fuse.net>
* src/history.c (history_menu_insert_separator): Fixed keyboard
......@@ -7,6 +13,15 @@
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : recurse for arrays too.
(expr_tree_array_corner) : rename from expr_tree_array_formula_corner,
and return the corner, not the expression in the corner.
* src/eval.c (cb_range_hash_invalidate) : invalidate and free things
in place.
(cb_single_hash_invalidate) : ditto.
(do_deps_destroy) : simplify.
* src/workbook-control-gui.c (wbcg_sheet_rename) : Use the table not
the container.
......
2001-05-27 Jody Goldberg <jgoldberg@home.com>
* ms-excel-write.c (write_window2) :
Switch the BIFF_WINDOW2 0x23e -> 0x3e
(write_names) : fix biff type.
* ms-excel-read.c (ms_excel_read_formula) : cleanup some old
inconsistentcies. keep as many of the BIFF_* using their major
types.
Switch the BIFF_STRING 0x207 -> 0x07
Switch the BIFF_BOOLERR 0x205 -> 0x05
(ms_excel_read_window2) : split this out into a neater bundle.
2001-05-26 Jody Goldberg <jgoldberg@home.com>
* ms-excel-write.c (write_sheet_bools) : Save the iteration
......
......@@ -19,7 +19,9 @@
#define BIFF_BLANK 0x01 /* 2, NOT 10 */
#define BIFF_NUMBER 0x03 /* 2, NOT 1,10 */
#define BIFF_LABEL 0x04 /* 2 */
#define BIFF_BOOLERR 0x05 /* 2, NOT 10 */
#define BIFF_FORMULA 0x06 /* 4, NOT 10 */
#define BIFF_STRING 0x07 /* 2 */
#define BIFF_ROW 0x08 /* 2 */
#define BIFF_BOF 0x09 /* 8, NOT 10 */
#define BIFF_EOF 0x0a /* 0, NOT 10 */
......@@ -56,8 +58,10 @@
#define BIFF_FILEPASS 0x2f /* 0 */
#define BIFF_FONT 0x31 /* 2 */
#define BIFF_PRINTSIZE 0x33 /* 0, Undocumented */
#define BIFF_TABLE 0x36 /* 2 */
#define BIFF_CONTINUE 0x3c /* 0, NOT 10 */
#define BIFF_WINDOW1 0x3d /* 0, NOT 1,10 */
#define BIFF_WINDOW2 0x3e /* 2, NOT 10 */
#define BIFF_BACKUP 0x40 /* 0, NOT 10 */
#define BIFF_PANE 0x41 /* 0, NOT 10 */
#define BIFF_CODEPAGE 0x42 /* DUPLICATE 42 */
......@@ -94,6 +98,7 @@
#define BIFF_SORT 0x90 /* 0 */
#define BIFF_SUB 0x91 /* 0 */
#define BIFF_PALETTE 0x92 /* 0 */
#define BIFF_STYLE 0x93 /* 2 */
#define BIFF_LHRECORD 0x94 /* 0 */
#define BIFF_LHNGRAPH 0x95 /* 0 */
#define BIFF_SOUND 0x96 /* 0 */
......@@ -186,13 +191,7 @@
#define BIFF_SXFDBTYPE 0x1bb
#define BIFF_PROT4REVPASS 0x1bc /* ONLY 1 */
#define BIFF_DV 0x1be /* ONLY 1 */
#define BIFF_BOOLERR 0x205 /* Why not as 05 */
#define BIFF_STRING 0x207 /* Why not as 07, NOT 10 */
#define BIFF_TABLE 0x236 /* Why not as 36 */
#define BIFF_WINDOW2 0x23e /* Why not as 3e, NOT 10 */
#define BIFF_STYLE 0x293 /* Why not as 93 */
#define BIFF_UNKNOWN_1 0x810 /* what this is */
/* Chart Specific */
/* These must be here for the ole program to work, and the suffixes must be
......
......@@ -1983,7 +1983,7 @@ ms_excel_read_formula (BiffQuery *q, ExcelSheet *sheet)
if (is_string) {
guint16 code;
if (ms_biff_query_peek_next (q, &code) && code == BIFF_STRING) {
if (ms_biff_query_peek_next (q, &code) && (0xff & code) == BIFF_STRING) {
char *v = NULL;
if (ms_biff_query_next (q)) {
/*
......@@ -3031,8 +3031,7 @@ ms_excel_read_cell (BiffQuery *q, ExcelSheet *sheet)
}
switch (q->ls_op) {
case BIFF_BLANK:
{
case BIFF_BLANK: {
const guint16 xf = EX_GETXF (q);
const guint16 col = EX_GETCOL (q);
const guint16 row = EX_GETROW (q);
......@@ -3044,6 +3043,46 @@ ms_excel_read_cell (BiffQuery *q, ExcelSheet *sheet)
break;
}
case BIFF_NUMBER: { /* S59DAC.HTM */
Value *v = value_new_float (gnumeric_get_le_double (q->data + 6));
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 2) {
printf ("Read number %g\n",
gnumeric_get_le_double (q->data + 6));
}
#endif
ms_excel_sheet_insert_val (sheet, EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), v);
break;
}
case BIFF_LABEL: { /* See: S59D9D.HTM */
char *label;
ms_excel_sheet_insert (sheet, EX_GETXF (q), EX_GETCOL (q), EX_GETROW (q),
(label = biff_get_text (q->data + 8, EX_GETSTRLEN (q), NULL)));
g_free (label);
break;
}
case BIFF_BOOLERR: { /* S59D5F.HTM */
Value *v;
const guint8 val = MS_OLE_GET_GUINT8 (q->data + 6);
if (MS_OLE_GET_GUINT8 (q->data + 7)) {
/* FIXME : Init EvalPos */
v = value_new_error (NULL,
biff_get_error_text (val));
} else
v = value_new_bool (val);
ms_excel_sheet_insert_val (sheet,
EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), v);
break;
}
case BIFF_FORMULA: /* See: S59D8F.HTM */
ms_excel_read_formula (q, sheet);
break;
case BIFF_MULBLANK:
{
/* S59DA7.HTM is extremely unclear, this is an educated guess */
......@@ -3117,21 +3156,6 @@ ms_excel_read_cell (BiffQuery *q, ExcelSheet *sheet)
/* Can be ignored on read side */
break;
/* S59DAC.HTM */
case BIFF_NUMBER:
{
Value *v = value_new_float (gnumeric_get_le_double (q->data + 6));
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 2) {
printf ("Read number %g\n",
gnumeric_get_le_double (q->data + 6));
}
#endif
ms_excel_sheet_insert_val (sheet, EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), v);
break;
}
case BIFF_ROW:
ms_excel_read_row (q, sheet);
break;
......@@ -3181,19 +3205,6 @@ ms_excel_read_cell (BiffQuery *q, ExcelSheet *sheet)
}
break;
}
/* See: S59D9D.HTM */
case BIFF_LABEL:
{
char *label;
ms_excel_sheet_insert (sheet, EX_GETXF (q), EX_GETCOL (q), EX_GETROW (q),
(label = biff_get_text (q->data + 8, EX_GETSTRLEN (q), NULL)));
g_free (label);
break;
}
case BIFF_FORMULA: /* See: S59D8F.HTM */
ms_excel_read_formula (q, sheet);
break;
case BIFF_LABELSST: /* See: S59D9E.HTM */
{
......@@ -3223,21 +3234,6 @@ ms_excel_read_cell (BiffQuery *q, ExcelSheet *sheet)
default:
switch (q->opcode) {
case BIFF_BOOLERR: /* S59D5F.HTM */
{
Value *v;
const guint8 val = MS_OLE_GET_GUINT8 (q->data + 6);
if (MS_OLE_GET_GUINT8 (q->data + 7)) {
/* FIXME : Init EvalPos */
v = value_new_error (NULL,
biff_get_error_text (val));
} else
v = value_new_bool (val);
ms_excel_sheet_insert_val (sheet,
EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), v);
break;
}
default:
ms_excel_unexpected_biff (q, "Cell", ms_excel_read_debug);
break;
......@@ -3505,6 +3501,10 @@ ms_excel_read_delta (BiffQuery *q, ExcelWorkbook *wb)
{
double tolerance;
/* samples/excel/dbfuns.xls has as sample of this record */
if (q->opcode == BIFF_UNKNOWN_1)
return;
g_return_if_fail (q->length == 8);
tolerance = gnumeric_get_le_double (q->data);
......@@ -3522,6 +3522,68 @@ ms_excel_read_iteration (BiffQuery *q, ExcelWorkbook *wb)
workbook_iteration_enabled (wb->gnum_wb, enabled);
}
static void
ms_excel_read_window2 (BiffQuery *q, ExcelSheet *sheet, WorkbookView *wb_view)
{
if (q->length >= 10) {
const guint16 options = MS_OLE_GET_GUINT16 (q->data + 0);
guint16 top_row = MS_OLE_GET_GUINT16 (q->data + 2);
guint16 left_col = MS_OLE_GET_GUINT16 (q->data + 4);
sheet->gnum_sheet->display_formulas = (options & 0x0001);
sheet->gnum_sheet->hide_zero = !(options & 0x0010);
sheet->gnum_sheet->hide_grid = !(options & 0x0002);
sheet->gnum_sheet->hide_col_header =
sheet->gnum_sheet->hide_row_header = !(options & 0x0004);
/* The docs are unclear whether or not the counters
* are 0 or 1 based. I'll assume 1 based but make the
* checks conditional just in case I'm wrong.
*/
if (top_row > 0)
--top_row;
if (left_col > 0)
--left_col;
sheet_make_cell_visible (sheet->gnum_sheet, left_col, top_row);
#if 0
if (!(options & 0x0008))
printf ("Unsupported : frozen panes\n");
if (!(options & 0x0020)) {
guint32 const grid_color = MS_OLE_GET_GUINT32 (q->data + 6);
/* This is quicky fake code to express the idea */
set_grid_and_header_color (get_color_from_index (grid_color));
#ifndef NO_DEBUG_EXCEL
if (ms_excel_color_debug > 2) {
printf ("Default grid & pattern color = 0x%hx\n",
grid_color);
}
#endif
}
#endif
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0) {
if (options & 0x0200)
printf ("Sheet flag selected\n");
}
#endif
if (options & 0x0400)
wb_view_sheet_focus (wb_view,
sheet->gnum_sheet);
}
#ifndef NO_DEBUG_EXCEL
if (q->length >= 14) {
const guint16 pageBreakZoom = MS_OLE_GET_GUINT16 (q->data + 10);
const guint16 normalZoom = MS_OLE_GET_GUINT16 (q->data + 12);
if (ms_excel_read_debug > 2)
printf ("%hx %hx\n", normalZoom, pageBreakZoom);
}
#endif
}
static gboolean
ms_excel_read_sheet (BiffQuery *q, ExcelWorkbook *wb, WorkbookView *wb_view,
ExcelSheet *sheet)
......@@ -3565,6 +3627,10 @@ ms_excel_read_sheet (BiffQuery *q, ExcelWorkbook *wb, WorkbookView *wb_view,
}
switch (q->ls_op) {
case BIFF_DIMENSIONS: /* 2, NOT 1,10 */
ms_excel_biff_dimensions (q, wb);
break;
case BIFF_EOF:
return TRUE;
......@@ -3763,10 +3829,6 @@ ms_excel_read_sheet (BiffQuery *q, ExcelWorkbook *wb, WorkbookView *wb_view,
g_warning ("Duff BIFF_SCL record");
break;
case BIFF_DIMENSIONS: /* 2, NOT 1,10 */
ms_excel_biff_dimensions (q, wb);
break;
case BIFF_SCENMAN:
case BIFF_SCENARIO:
break;
......@@ -3778,72 +3840,19 @@ ms_excel_read_sheet (BiffQuery *q, ExcelWorkbook *wb, WorkbookView *wb_view,
case BIFF_EXTERNNAME:
ms_excel_externname (q, sheet->wb, sheet);
break;
case (BIFF_NAME & 0xff) : /* Why here and not as 18 */
case BIFF_NAME :
ms_excel_read_name (q, sheet->wb, sheet);
break;
case BIFF_WINDOW2:
ms_excel_read_window2 (q, sheet, wb_view);
break;
default:
switch (q->opcode) {
case BIFF_CODENAME :
break;
case BIFF_WINDOW2:
if (q->length >= 10) {
const guint16 options = MS_OLE_GET_GUINT16 (q->data + 0);
guint16 top_row = MS_OLE_GET_GUINT16 (q->data + 2);
guint16 left_col = MS_OLE_GET_GUINT16 (q->data + 4);
sheet->gnum_sheet->display_formulas = (options & 0x0001);
sheet->gnum_sheet->hide_zero = !(options & 0x0010);
sheet->gnum_sheet->hide_grid = !(options & 0x0002);
sheet->gnum_sheet->hide_col_header =
sheet->gnum_sheet->hide_row_header = !(options & 0x0004);
/* The docs are unclear whether or not the counters
* are 0 or 1 based. I'll assume 1 based but make the
* checks conditional just in case I'm wrong.
*/
if (top_row > 0) --top_row;
if (left_col > 0) --left_col;
sheet_make_cell_visible (sheet->gnum_sheet,
left_col, top_row);
#if 0
if (!(options & 0x0008))
printf ("Unsupported : frozen panes\n");
if (!(options & 0x0020)) {
guint32 const grid_color = MS_OLE_GET_GUINT32 (q->data + 6);
/* This is quicky fake code to express the idea */
set_grid_and_header_color (get_color_from_index (grid_color));
#ifndef NO_DEBUG_EXCEL
if (ms_excel_color_debug > 2) {
printf ("Default grid & pattern color = 0x%hx\n",
grid_color);
}
#endif
}
#endif
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0) {
if (options & 0x0200)
printf ("Sheet flag selected\n");
}
#endif
if (options & 0x0400)
wb_view_sheet_focus (wb_view,
sheet->gnum_sheet);
}
#ifndef NO_DEBUG_EXCEL
if (q->length >= 14) {
const guint16 pageBreakZoom = MS_OLE_GET_GUINT16 (q->data + 10);
const guint16 normalZoom = MS_OLE_GET_GUINT16 (q->data + 12);
if (ms_excel_read_debug > 2)
printf ("%hx %hx\n", normalZoom, pageBreakZoom);
#endif
}
break;
default:
ms_excel_read_cell (q, sheet);
break;
......@@ -4073,8 +4082,7 @@ ms_excel_read_workbook (IOContext *context, WorkbookView *wb_view,
case BIFF_PROT4REVPASS :
break;
case BIFF_CODENAME :
/* TODO : What to do with this name ? */
case BIFF_CODENAME : /* TODO : What to do with this name ? */
break;
case BIFF_SUPBOOK:
......@@ -4308,7 +4316,7 @@ ms_excel_read_workbook (IOContext *context, WorkbookView *wb_view,
problem_loading = g_strdup (_("Password protected workbooks are not supported yet."));
break;
case (BIFF_STYLE & 0xff) : /* Why here and not as 93 */
case BIFF_STYLE :
break;
case BIFF_WINDOWPROTECT :
......@@ -4318,7 +4326,7 @@ ms_excel_read_workbook (IOContext *context, WorkbookView *wb_view,
ms_excel_externname (q, wb, NULL);
break;
case (BIFF_NAME & 0xff) : /* Why here and not as 18 */
case BIFF_NAME :
ms_excel_read_name (q, wb, NULL);
break;
......
......@@ -398,14 +398,14 @@ write_window2 (BiffPut *bp, MsBiffVersion ver, ExcelSheet *sheet)
options |= 0x600; /* assume selected if it is current */
if (ver <= MS_BIFF_V7) {
data = ms_biff_put_len_next (bp, BIFF_WINDOW2, 10);
data = ms_biff_put_len_next (bp, 0x200|BIFF_WINDOW2, 10);
MS_OLE_SET_GUINT16 (data + 0, options);
MS_OLE_SET_GUINT16 (data + 2, 0x0); /* top row */
MS_OLE_SET_GUINT16 (data + 4, 0x0); /* left col */
MS_OLE_SET_GUINT32 (data + 6, 0x40); /* grid color index (0x40 == auto) */
} else {
data = ms_biff_put_len_next (bp, BIFF_WINDOW2, 18);
data = ms_biff_put_len_next (bp, 0x200|BIFF_WINDOW2, 18);
MS_OLE_SET_GUINT16 (data + 0, options);
MS_OLE_SET_GUINT16 (data + 2, 0x0); /* top row */
......@@ -2283,7 +2283,7 @@ write_xf (BiffPut *bp, ExcelWorkbook *wb)
/* See: S59DEA.HTM */
for (lp = 0; lp < 6; lp++) {
guint8 *data = ms_biff_put_len_next (bp, BIFF_STYLE, 4);
guint8 *data = ms_biff_put_len_next (bp, 0x200|BIFF_STYLE, 4);
MS_OLE_SET_GUINT32 (data, style_magic[lp]); /* cop out */
ms_biff_put_commit (bp);
}
......@@ -2321,7 +2321,7 @@ write_names (BiffPut *bp, ExcelWorkbook *wb)
for (i = 0; i < 20; i++) data[i] = 0;
text = expr_name->name->str;
ms_biff_put_var_next (bp, BIFF_NAME);
ms_biff_put_var_next (bp, 0x200|BIFF_NAME);
name_len = strlen (expr_name->name->str);
MS_OLE_SET_GUINT8 (data + 3, name_len); /* name_len */
......
......@@ -98,7 +98,6 @@ dependent_set_expr (Dependent *dep, ExprTree *expr)
* replacing the corner of an array.
*/
cell_set_expr_unsafe (DEP_TO_CELL (dep), expr, NULL);
#warning Check to see what recalc assumptions the callers make
} else {
DependentClass *klass = g_ptr_array_index (dep_classes, t);
......@@ -439,14 +438,12 @@ drop_range_dep (DependencyData *deps, Dependent *dependent,
#endif
}
static gboolean
dependency_single_destroy (gpointer key, gpointer value, gpointer closure)
static void
depsingle_dtor (DependencySingle *single)
{
DependencySingle *single = value;
g_list_free (single->dependent_list);
single->dependent_list = NULL;
g_free (value);
return TRUE;
single->dependent_list = NULL; /* poison it */
g_free (single);
}
static void
......@@ -466,14 +463,12 @@ deprange_init (DependencyRange *range, CellPos const *pos,
g_warning ("FIXME: 3D references need work");
}
static gboolean
deprange_dtor (gpointer key, gpointer value, gpointer closure)
static void
deprange_dtor (DependencyRange *deprange)
{
DependencyRange *deprange = value;
g_list_free (deprange->dependent_list);
deprange->dependent_list = NULL;
g_free (value);
return TRUE;
deprange->dependent_list = NULL; /* poison it */
g_free (deprange);
}
/*
......@@ -797,7 +792,8 @@ void
cell_queue_recalc (Cell const *cell)
{
if (!cell_needs_recalc (cell)) {
dependent_queue_recalc (CELL_TO_DEP (cell));
if (cell_has_expr (cell))
dependent_queue_recalc (CELL_TO_DEP (cell));
cell_foreach_dep (cell, cb_dependent_queue_recalc, NULL);
}
}
......@@ -921,20 +917,30 @@ cb_single_recalc_all_depends (gpointer key, gpointer value, gpointer ignore)
/**
* sheet_region_queue_recalc :
* Queue dependencies of the region for recalc.
*
* @sheet : The sheet.
* @range : Optionally NULL range.
*
* Queues things that depend on @sheet!@range for recalc.
*
* If @range is NULL the entire sheet is used.
*/
void
sheet_region_queue_recalc (Sheet const *sheet, Range const *range)
sheet_region_queue_recalc (Sheet const *sheet, Range const *r)
{
GList *l;
Dependent *dep;
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (sheet->deps != NULL);
if (range == NULL) {
if (r == NULL) {
for (l = sheet->workbook->dependents; l; l = l->next) {
dep = l->data;
if (dep->sheet == sheet)
dependent_queue_recalc (dep);
}
/* Find anything that depends on a range in this sheet */
g_hash_table_foreach (sheet->deps->range_hash,
&cb_range_recalc_all_depends, NULL);
......@@ -944,19 +950,29 @@ sheet_region_queue_recalc (Sheet const *sheet, Range const *range)
&cb_single_recalc_all_depends, NULL);
} else {
int ix, iy, end_col, end_row;
Cell *cell;
for (l = sheet->workbook->dependents; l; l = l->next) {
dep = l->data;
cell = DEP_TO_CELL (dep);
if (dep->sheet == sheet &&
((dep->flags & DEPENDENT_TYPE_MASK) == DEPENDENT_CELL) &&
range_contains (r, cell->pos.col, cell->pos.row))
dependent_queue_recalc (dep);
}
g_hash_table_foreach (sheet->deps->range_hash,
&cb_region_contained_depend,
(gpointer)range);
(gpointer)r);
/* TODO : Why not use sheet_foreach_cell ?
* We would need to be more careful about queueing
* things that depends on blanks, but that is not too hard.
*/
end_col = MIN (range->end.col, sheet->cols.max_used);
end_row = MIN (range->end.row, sheet->rows.max_used);
for (ix = range->start.col; ix <= end_col; ix++)
for (iy = range->start.row; iy <= end_row; iy++)
end_col = MIN (r->end.col, sheet->cols.max_used);
end_row = MIN (r->end.row, sheet->rows.max_used);
for (ix = r->start.col; ix <= end_col; ix++)
for (iy = r->start.row; iy <= end_row; iy++)
cell_foreach_single_dep (sheet, ix, iy,
cb_dependent_queue_recalc, NULL);
}
......@@ -964,70 +980,87 @@ sheet_region_queue_recalc (Sheet const *sheet, Range const *range)
/*******************************************************************/
typedef struct {
ExprRewriteInfo const *rwinfo;
GSList *dependent_list;
} destroy_closure_t;
static void
cb_range_hash_to_list (gpointer key, gpointer value, gpointer closure)
invalidate_refs (Dependent *dep, ExprRewriteInfo const *rwinfo)
{
destroy_closure_t *c = closure;
GList *l;
DependencyRange *dep = value;
for (l = dep->dependent_list; l; l = l->next) {
Dependent *dependent = l->data;
if (c->rwinfo->type == EXPR_REWRITE_SHEET &&
dependent->sheet != c->rwinfo->u.sheet)
ExprTree *newtree;
c->dependent_list = g_slist_prepend (c->dependent_list, l->data);
newtree = expr_rewrite (dep->expression, rwinfo);
else if (c->rwinfo->type == EXPR_REWRITE_WORKBOOK &&
dependent->sheet->workbook != c->rwinfo->u.workbook)
/*
* We are told this dependent depends on this region, hence if newtree
* is null then either we did not depend on it ( ie. serious breakage )
* or we had a duplicate reference and we have already removed it.
*/
g_return_if_fail (newtree != NULL);
c->dependent_list = g_slist_prepend (c->dependent_list, l->data);
}
dependent_set_expr (dep, newtree);
}
/*
* WARNING : Hash is pointing to freed memory once this is complete
* This is tightly coupled with do_deps_destroy.
*/
static void
cb_single_hash_to_list (gpointer key, gpointer value, gpointer closure)
cb_range_hash_invalidate (gpointer key, gpointer value, gpointer closure)
{
destroy_closure_t *c = closure;
ExprRewriteInfo const *rwinfo = closure;
GList *l;
DependencySingle *dep = value;
for (l = dep->dependent_list; l; l = l->next) {
Dependent *dependent = l->data;
if (c->rwinfo->type == EXPR_REWRITE_SHEET &&
dependent->sheet != c->rwinfo->u.sheet)
c->dependent_list = g_slist_prepend (c->dependent_list, l->data);
DependencyRange *deprange = value;
Dependent *dependent;
else if (c->rwinfo->type == EXPR_REWRITE_WORKBOOK &&