Commit 7eb4a25b authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Save the iteration preferences too. These are workbook level flags. I am

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

	* ms-excel-write.c (write_sheet_bools) : Save the iteration
	  preferences too.  These are workbook level flags.  I am unclear why
	  XL saves them at the sheet level.

	* ms-excel-read.c (ms_excel_read_calccount) : new function.
	(ms_excel_read_delta) : ditto.
	(ms_excel_read_iteration) : ditto.
	(ms_excel_read_sheet) : use them here.

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

	* src/cell.c (cell_eval_content) : Use the iteration prefs.

	* src/workbook.c (workbook_iteration_tolerance) : new function.
	(workbook_iteration_enabled) : ditto.
	(workbook_iteration_max_number) : ditto.
parent b700bcc6
2001-05-26 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_eval_content) : Use the iteration prefs.
* src/workbook.c (workbook_iteration_tolerance) : new function.
(workbook_iteration_enabled) : ditto.
(workbook_iteration_max_number) : ditto.
2001-05-26 Zbigniew Chyla <cyba@gnome.pl>
* src/gui-file.c (fill_save_menu): If recently used saver has been
......
......@@ -5,7 +5,9 @@ Almer:
Jody:
* Fix ctrl-enter filling.
* Reorganize the recalc queue
* Reorganize the recalc queue.
* Support iteration.
* Fix FV arguments.
Morten:
* Fix PV.
......
2001-05-26 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_eval_content) : Use the iteration prefs.
* src/workbook.c (workbook_iteration_tolerance) : new function.
(workbook_iteration_enabled) : ditto.
(workbook_iteration_max_number) : ditto.
2001-05-26 Zbigniew Chyla <cyba@gnome.pl>
* src/gui-file.c (fill_save_menu): If recently used saver has been
......
2001-05-26 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_eval_content) : Use the iteration prefs.
* src/workbook.c (workbook_iteration_tolerance) : new function.
(workbook_iteration_enabled) : ditto.
(workbook_iteration_max_number) : ditto.
2001-05-26 Zbigniew Chyla <cyba@gnome.pl>
* src/gui-file.c (fill_save_menu): If recently used saver has been
......
2001-05-26 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_eval_content) : Use the iteration prefs.
* src/workbook.c (workbook_iteration_tolerance) : new function.
(workbook_iteration_enabled) : ditto.
(workbook_iteration_max_number) : ditto.
2001-05-26 Zbigniew Chyla <cyba@gnome.pl>
* src/gui-file.c (fill_save_menu): If recently used saver has been
......
2001-05-26 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_eval_content) : Use the iteration prefs.
* src/workbook.c (workbook_iteration_tolerance) : new function.
(workbook_iteration_enabled) : ditto.
(workbook_iteration_max_number) : ditto.
2001-05-26 Zbigniew Chyla <cyba@gnome.pl>
* src/gui-file.c (fill_save_menu): If recently used saver has been
......
2001-05-26 Jody Goldberg <jgoldberg@home.com>
* ms-excel-write.c (write_sheet_bools) : Save the iteration
preferences too. These are workbook level flags. I am unclear why
XL saves them at the sheet level.
* ms-excel-read.c (ms_excel_read_calccount) : new function.
(ms_excel_read_delta) : ditto.
(ms_excel_read_iteration) : ditto.
(ms_excel_read_sheet) : use them here.
2001-05-18 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_read_formula) : Use cell_queue_recalc
......
......@@ -3490,6 +3490,39 @@ ms_excel_read_wsbool (BiffQuery *q, ExcelSheet *sheet)
sheet->gnum_sheet->display_outlines = 0 != (options & 0x600);
}
static void
ms_excel_read_calcount (BiffQuery *q, ExcelWorkbook *wb)
{
guint16 count;
g_return_if_fail (q->length == 2);
count = MS_OLE_GET_GUINT16 (q->data);
workbook_iteration_max_number (wb->gnum_wb, count);
}
static void
ms_excel_read_delta (BiffQuery *q, ExcelWorkbook *wb)
{
double tolerance;
g_return_if_fail (q->length == 8);
tolerance = gnumeric_get_le_double (q->data);
workbook_iteration_tolerance (wb->gnum_wb, tolerance);
}
static void
ms_excel_read_iteration (BiffQuery *q, ExcelWorkbook *wb)
{
guint16 enabled;
g_return_if_fail (q->length == 2);
enabled = MS_OLE_GET_GUINT16 (q->data);
workbook_iteration_enabled (wb->gnum_wb, enabled);
}
static gboolean
ms_excel_read_sheet (BiffQuery *q, ExcelWorkbook *wb, WorkbookView *wb_view,
ExcelSheet *sheet)
......@@ -3561,15 +3594,22 @@ ms_excel_read_sheet (BiffQuery *q, ExcelWorkbook *wb, WorkbookView *wb_view,
case BIFF_GRIDSET:
case BIFF_INDEX:
case BIFF_CALCMODE:
case BIFF_CALCCOUNT:
case BIFF_REFMODE:
case BIFF_ITERATION:
case BIFF_DELTA:
case BIFF_SAVERECALC:
case BIFF_PRINTHEADERS:
case BIFF_COUNTRY:
break;
case BIFF_CALCCOUNT:
ms_excel_read_calccount (q, wb);
break;
case BIFF_DELTA:
ms_excel_read_delta (q, wb);
break;
case BIFF_ITERATION:
ms_excel_read_iteration (q, wb);
break;
case BIFF_WSBOOL:
ms_excel_read_wsbool (q, sheet);
break;
......
......@@ -3055,6 +3055,7 @@ write_sheet_bools (BiffPut *bp, ExcelSheet *sheet)
guint8 *data;
PrintInformation *pi;
MsBiffVersion ver = sheet->wb->ver;
Workbook *wb = sheet->gnum_sheet->workbook;
g_return_if_fail (sheet != NULL);
g_return_if_fail (sheet->gnum_sheet != NULL);
......@@ -3069,7 +3070,7 @@ write_sheet_bools (BiffPut *bp, ExcelSheet *sheet)
/* See: S59D62.HTM */
data = ms_biff_put_len_next (bp, BIFF_CALCCOUNT, 2);
MS_OLE_SET_GUINT16 (data, 0x0064);
MS_OLE_SET_GUINT16 (data, wb->iteration.max_number);
ms_biff_put_commit (bp);
/* See: S59DD7.HTM */
......@@ -3079,13 +3080,12 @@ write_sheet_bools (BiffPut *bp, ExcelSheet *sheet)
/* See: S59D9C.HTM */
data = ms_biff_put_len_next (bp, BIFF_ITERATION, 2);
MS_OLE_SET_GUINT16 (data, 0x0000);
MS_OLE_SET_GUINT16 (data, wb->iteration.enabled ? 1 : 0);
ms_biff_put_commit (bp);
/* See: S59D75.HTM, FIXME: find what number this really is! */
/* See: S59D75.HTM */
data = ms_biff_put_len_next (bp, BIFF_DELTA, 8);
MS_OLE_SET_GUINT32 (data, 0xd2f1a9fc);
MS_OLE_SET_GUINT32 (data+4, 0x3f50624d);
gnumeric_set_le_double (data, wb->iteration.tolerance);
ms_biff_put_commit (bp);
/* See: S59DDD.HTM */
......
......@@ -9,6 +9,7 @@
#include "config.h"
#include "gnumeric.h"
#include "cell.h"
#include "workbook.h"
#include "sheet.h"
#include "expr.h"
#include "rendered-value.h"
......@@ -153,9 +154,7 @@ cell_eval_content (Cell *cell)
static Cell *iterating = NULL;
Value *v;
EvalPos pos;
/* This _must_ start as a positive number */
int max_iterate = 100;
int max_iteration;
if (!cell_has_expr (cell))
return TRUE;
......@@ -165,13 +164,16 @@ cell_eval_content (Cell *cell)
ParsePos pp;
char *str = expr_tree_as_string (cell->base.expression,
parse_pos_init_cell (&pp, cell));
printf ("{\nEvaluating(%d) %s: %s;\n", max_iterate, cell_name (cell), str);
printf ("{\nEvaluating %s: %s;\n", cell_name (cell), str);
g_free (str);
}
#endif
/* This is the bottom of a cycle */
if (cell->base.flags & DEPENDENT_BEING_CALCULATED) {
if (!cell->base.sheet->workbook->iteration.enabled)
return TRUE;
/* but not the first bottom */
if (cell->base.flags & CELL_BEING_ITERATED) {
#ifdef DEBUG_EVALUATION
......@@ -206,6 +208,7 @@ cell_eval_content (Cell *cell)
/* Prepare to calculate */
eval_pos_init_cell (&pos, cell);
cell->base.flags |= DEPENDENT_BEING_CALCULATED;
max_iteration = cell->base.sheet->workbook->iteration.max_number;
iterate :
v = eval_expr (&pos, cell->base.expression, EVAL_STRICT);
......@@ -217,7 +220,7 @@ iterate :
char *valtxt = v
? value_get_as_string (v)
: g_strdup ("NULL");
printf ("Evaluation(%d) %s := %s\n", max_iterate, cell_name (cell), valtxt);
printf ("Evaluation(%d) %s := %s\n", max_iteration, cell_name (cell), valtxt);
g_free (valtxt);
}
#endif
......@@ -227,10 +230,10 @@ iterate :
cell->base.flags &= ~CELL_BEING_ITERATED;
/* We just completed the last iteration, don't change things */
if (iterating && max_iterate-- > 0) {
if (iterating && max_iteration-- > 0) {
/* If we are within bounds make this the last round */
if (value_diff (cell->value, v) < 0.001)
max_iterate = 0;
if (value_diff (cell->value, v) < cell->base.sheet->workbook->iteration.tolerance)
max_iteration = 0;
else {
#ifdef DEBUG_EVALUATION
puts ("/* iterate == NULL */");
......
......@@ -47,6 +47,12 @@ struct _Workbook {
void *corba_server;
struct {
gboolean enabled;
int max_number;
double tolerance;
} iteration;
WorkbookPrivate *priv;
};
......@@ -112,10 +118,13 @@ Value *workbook_foreach_cell_in_range (EvalPos const *pos,
void *closure);
GPtrArray *workbook_cells (Workbook *wb, gboolean comments);
/* Calculation control */
void workbook_recalc (Workbook *wb);
void workbook_recalc_all (Workbook *wb);
gboolean workbook_enable_recursive_dirty (Workbook *wb, gboolean enable);
/* Calculation */
void workbook_recalc (Workbook *wb); /* in eval.c */
void workbook_recalc_all (Workbook *wb); /* in eval.c */
gboolean workbook_enable_recursive_dirty (Workbook *wb, gboolean enable);
void workbook_iteration_enabled (Workbook *wb, gboolean enable);
void workbook_iteration_max_number (Workbook *wb, int max_number);
void workbook_iteration_tolerance (Workbook *wb, double tolerance);
void workbook_calc_spans (Workbook *wb, SpanCalcFlags const flags);
......
......@@ -375,6 +375,11 @@ workbook_init (GtkObject *object)
/* Nothing to undo or redo */
wb->undo_commands = wb->redo_commands = NULL;
/* default to no iteration */
wb->iteration.enabled = FALSE;
wb->iteration.max_number = 100;
wb->iteration.tolerance = .001;
application_workbook_list_add (wb);
#if 0
......@@ -838,6 +843,30 @@ workbook_enable_recursive_dirty (Workbook *wb, gboolean enable)
return old;
}
void
workbook_iteration_enabled (Workbook *wb, gboolean enable)
{
g_return_if_fail (IS_WORKBOOK (wb));
wb->iteration.enabled = enable;
}
void
workbook_iteration_max_number (Workbook *wb, int max_number)
{
g_return_if_fail (IS_WORKBOOK (wb));
g_return_if_fail (max_number >= 0);
wb->iteration.max_number = max_number;
}
void
workbook_iteration_tolerance (Workbook *wb, double tolerance)
{
g_return_if_fail (IS_WORKBOOK (wb));
g_return_if_fail (tolerance >= 0);
wb->iteration.tolerance = tolerance;
}
void
workbook_attach_view (Workbook *wb, WorkbookView *wbv)
{
......
......@@ -47,6 +47,12 @@ struct _Workbook {
void *corba_server;
struct {
gboolean enabled;
int max_number;
double tolerance;
} iteration;
WorkbookPrivate *priv;
};
......@@ -112,10 +118,13 @@ Value *workbook_foreach_cell_in_range (EvalPos const *pos,
void *closure);
GPtrArray *workbook_cells (Workbook *wb, gboolean comments);
/* Calculation control */
void workbook_recalc (Workbook *wb);
void workbook_recalc_all (Workbook *wb);
gboolean workbook_enable_recursive_dirty (Workbook *wb, gboolean enable);
/* Calculation */
void workbook_recalc (Workbook *wb); /* in eval.c */
void workbook_recalc_all (Workbook *wb); /* in eval.c */
gboolean workbook_enable_recursive_dirty (Workbook *wb, gboolean enable);
void workbook_iteration_enabled (Workbook *wb, gboolean enable);
void workbook_iteration_max_number (Workbook *wb, int max_number);
void workbook_iteration_tolerance (Workbook *wb, double tolerance);
void workbook_calc_spans (Workbook *wb, SpanCalcFlags const flags);
......
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