Commit 75daada2 authored by Michael Meeks's avatar Michael Meeks

Overdue expr.c cleans adding default cases to switch statements with warnings.

Changed several IF trees to switches,
Fixed silly bug with excel cell comments.
Tentative excel array support back in.
parent b9d4510c
1999-05-08 Michael Meeks <michael@imaginator.com>
* src/sheet.h: Commented sheet_cell_get vs. _fetch.
* src/expr.c (do_expr_tree_unref, value_string, value_release),
(eval_cell_value, do_expr_tree_invalidate_references):
Clean: Added 'default' cases with warnings.
(value_get_as_double, value_get_as_int, value_get_bool): Changed
to safer / faster switch statement from if.
1999-05-07 Michael Meeks <michael@imaginator.com>
* src/corba-workbook.c (corba_sheet): Add CORBA_Environment
......
1999-05-08 Michael Meeks <michael@imaginator.com>
* src/sheet.h: Commented sheet_cell_get vs. _fetch.
* src/expr.c (do_expr_tree_unref, value_string, value_release),
(eval_cell_value, do_expr_tree_invalidate_references):
Clean: Added 'default' cases with warnings.
(value_get_as_double, value_get_as_int, value_get_bool): Changed
to safer / faster switch statement from if.
1999-05-07 Michael Meeks <michael@imaginator.com>
* src/corba-workbook.c (corba_sheet): Add CORBA_Environment
......
1999-05-08 Michael Meeks <michael@imaginator.com>
* src/sheet.h: Commented sheet_cell_get vs. _fetch.
* src/expr.c (do_expr_tree_unref, value_string, value_release),
(eval_cell_value, do_expr_tree_invalidate_references):
Clean: Added 'default' cases with warnings.
(value_get_as_double, value_get_as_int, value_get_bool): Changed
to safer / faster switch statement from if.
1999-05-07 Michael Meeks <michael@imaginator.com>
* src/corba-workbook.c (corba_sheet): Add CORBA_Environment
......
1999-05-08 Michael Meeks <michael@imaginator.com>
* src/sheet.h: Commented sheet_cell_get vs. _fetch.
* src/expr.c (do_expr_tree_unref, value_string, value_release),
(eval_cell_value, do_expr_tree_invalidate_references):
Clean: Added 'default' cases with warnings.
(value_get_as_double, value_get_as_int, value_get_bool): Changed
to safer / faster switch statement from if.
1999-05-07 Michael Meeks <michael@imaginator.com>
* src/corba-workbook.c (corba_sheet): Add CORBA_Environment
......
1999-05-08 Michael Meeks <michael@imaginator.com>
* ms-formula.c (ms_excel_parse_formula): Hack at ARRAY
functionality...
* ms-excel.c (ms_excel_sheet_set_comment): Fix for setting
comments on blank cells; was fatal.
1999-05-07 Michael Meeks <michael@imaginator.com>
* ms-formula.c (ms_excel_parse_formula): Fixed horrible bug
......
......@@ -1258,7 +1258,11 @@ ms_excel_sheet_set_comment (MS_EXCEL_SHEET * sheet, int col, int row, char *text
{
if (text)
{
Cell *cell = sheet_cell_fetch (sheet->gnum_sheet, col, row);
Cell *cell = sheet_cell_get (sheet->gnum_sheet, col, row);
if (!cell) {
cell = sheet_cell_fetch (sheet->gnum_sheet, col, row);
cell_set_text_simple (cell, "");
}
sheet->blank = 0 ;
cell_set_comment (cell, text);
}
......
......@@ -1258,7 +1258,11 @@ ms_excel_sheet_set_comment (MS_EXCEL_SHEET * sheet, int col, int row, char *text
{
if (text)
{
Cell *cell = sheet_cell_fetch (sheet->gnum_sheet, col, row);
Cell *cell = sheet_cell_get (sheet->gnum_sheet, col, row);
if (!cell) {
cell = sheet_cell_fetch (sheet->gnum_sheet, col, row);
cell_set_text_simple (cell, "");
}
sheet->blank = 0 ;
cell_set_comment (cell, text);
}
......
......@@ -815,15 +815,20 @@ ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
if (last) g_free (last) ;
break ;
}
/* case FORMULA_PTG_ARRAY:
case FORMULA_PTG_ARRAY:
{
Value *v;
guint16 cols=BIFF_GETBYTE(cur+0);
guint16 rows=BIFF_GETWORD(cur+1);
guint16 lpx,lpy;
guint8 *data=cur+3;
GString *ans = g_string_new ("{");
ptg_length = 3;
if (cols==0) cols=256;
v = value_array_new (cols, rows);
ptg_length = 3;
printf ("An Array how interesting: (%d,%d)\n", cols, rows);
dump (mem, length);
#ifdef 0
for (lpy=0;lpy<rows;lpy++) {
for (lpx=0;lpx<cols;lpx++) {
......@@ -849,11 +854,9 @@ ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
}
}
#endif
g_string_append (ans, "}");
parse_list_push_raw (&stack, ans->str, NO_PRECEDENCE);
g_string_free (ans, FALSE);
parse_list_push_raw (&stack, v);
break;
}*/
}
case FORMULA_PTG_FUNC:
{
if (!make_function (&stack, BIFF_GETWORD(cur), -1)) error = 1 ;
......
......@@ -815,15 +815,20 @@ ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
if (last) g_free (last) ;
break ;
}
/* case FORMULA_PTG_ARRAY:
case FORMULA_PTG_ARRAY:
{
Value *v;
guint16 cols=BIFF_GETBYTE(cur+0);
guint16 rows=BIFF_GETWORD(cur+1);
guint16 lpx,lpy;
guint8 *data=cur+3;
GString *ans = g_string_new ("{");
ptg_length = 3;
if (cols==0) cols=256;
v = value_array_new (cols, rows);
ptg_length = 3;
printf ("An Array how interesting: (%d,%d)\n", cols, rows);
dump (mem, length);
#ifdef 0
for (lpy=0;lpy<rows;lpy++) {
for (lpx=0;lpx<cols;lpx++) {
......@@ -849,11 +854,9 @@ ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
}
}
#endif
g_string_append (ans, "}");
parse_list_push_raw (&stack, ans->str, NO_PRECEDENCE);
g_string_free (ans, FALSE);
parse_list_push_raw (&stack, v);
break;
}*/
}
case FORMULA_PTG_FUNC:
{
if (!make_function (&stack, BIFF_GETWORD(cur), -1)) error = 1 ;
......
......@@ -104,6 +104,9 @@ do_expr_tree_unref (ExprTree *tree)
case OPER_ANY_UNARY:
do_expr_tree_unref (tree->u.value);
break;
default:
g_warning ("do_expr_tree_unref error\n");
break;
}
g_free (tree);
......@@ -145,6 +148,9 @@ value_string (const Value *value)
case VALUE_CELLRANGE:
break;
default:
g_warning ("value_string problem\n");
break;
}
return g_strdup ("Internal problem");
......@@ -181,6 +187,9 @@ value_release (Value *value)
case VALUE_CELLRANGE:
break;
default:
g_warning ("value_release problem\n");
break;
}
g_free (value);
}
......@@ -217,6 +226,9 @@ value_copy_to (Value *dest, const Value *source)
case VALUE_CELLRANGE:
dest->v.cell_range = source->v.cell_range;
break;
default:
g_warning ("value_copy_to problem\n");
break;
}
}
......@@ -307,68 +319,80 @@ value_get_bool (const Value *v, int *err)
{
*err = 0;
if (v->type == VALUE_STRING)
switch (v->type) {
case VALUE_STRING:
return atoi (v->v.str->str);
if (v->type == VALUE_CELLRANGE){
case VALUE_CELLRANGE:
*err = 1;
return 0;
}
if (v->type == VALUE_INTEGER)
case VALUE_INTEGER:
return v->v.v_int != 0;
if (v->type == VALUE_FLOAT)
case VALUE_FLOAT:
return v->v.v_float != 0.0;
if (v->type == VALUE_ARRAY)
case VALUE_ARRAY:
return 0;
g_warning ("Unhandled value in value_get_boolean");
default:
g_warning ("Unhandled value in value_get_boolean");
break;
}
return 0;
}
float_t
value_get_as_double (const Value *v)
{
if (v->type == VALUE_STRING){
switch (v->type)
{
case VALUE_STRING:
return atof (v->v.str->str);
}
if (v->type == VALUE_CELLRANGE){
case VALUE_CELLRANGE:
g_warning ("Getting range as a double: what to do?");
return 0.0;
}
if (v->type == VALUE_INTEGER)
case VALUE_INTEGER:
return (float_t) v->v.v_int;
if (v->type == VALUE_ARRAY)
case VALUE_ARRAY:
return 0.0;
return (float_t) v->v.v_float;
case VALUE_FLOAT:
return (float_t) v->v.v_float;
default:
g_warning ("value_get_as_double type error\n");
break;
}
return 0.0;
}
int
value_get_as_int (const Value *v)
{
if (v->type == VALUE_STRING){
switch (v->type)
{
case VALUE_STRING:
return atoi (v->v.str->str);
}
if (v->type == VALUE_CELLRANGE){
case VALUE_CELLRANGE:
g_warning ("Getting range as a double: what to do?");
return 0.0;
}
if (v->type == VALUE_INTEGER)
case VALUE_INTEGER:
return v->v.v_int;
if (v->type == VALUE_ARRAY)
case VALUE_ARRAY:
return 0.0;
return (int) v->v.v_float;
case VALUE_FLOAT:
return (int) v->v.v_float;
default:
g_warning ("value_get_as_int unknown type\n");
break;
}
}
Value *
......@@ -575,6 +599,9 @@ eval_cell_value (Sheet *sheet, Value *value)
case VALUE_CELLRANGE:
res->v.cell_range = value->v.cell_range;
break;
default:
g_warning ("eval_cell_value error\n");
break;
}
return res;
}
......@@ -1617,6 +1644,9 @@ do_expr_tree_invalidate_references (ExprTree *src, const struct expr_tree_frob_r
fprintf (stderr, "Reminder: FIXME in do_expr_tree_invalidate_references\n");
/* ??? */
return NULL;
default:
g_warning ("do_expr_tree_invalidate_references error\n");
break;
}
g_assert_not_reached ();
return NULL;
......
......@@ -253,7 +253,9 @@ int sheet_cell_foreach_range (Sheet *sheet, int only_existing,
int end_col, int end_row,
sheet_cell_foreach_callback callback,
void *closure);
/* Returns NULL if doesn't exist */
Cell *sheet_cell_get (Sheet *sheet, int col, int row);
/* Returns new Cell if doesn't exist */
Cell *sheet_cell_fetch (Sheet *sheet, int col, int row);
void sheet_cell_comment_link (Cell *cell);
void sheet_cell_comment_unlink (Cell *cell);
......
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