Commit 9b636fcb authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder
Browse files

Make auto-format work for sheet-relative cellrefs like "=sum(a1:a10)".


2000-04-09  Morten Welinder  <terra@diku.dk>

	* src/sheet.h (ParsePositions): Add sheet.

	* src/expr.c (parse_pos_init): New arg sheet.  All callers changed.

	* src/parser.y (gnumeric_expr_parser): Use pp->sheet.
parent 9013226d
2000-04-09 Morten Welinder <terra@diku.dk>
* src/sheet.h (ParsePositions): Add sheet.
* src/expr.c (parse_pos_init): New arg sheet. All callers changed.
* src/parser.y (gnumeric_expr_parser): Use pp->sheet.
2000-04-08 Jon K Hellan <hellan@acm.org>
(sheet_name_quote): Quote embedded quotes.
......@@ -6,6 +14,8 @@
* src/xml-io.c (xml_read_solver): Plug leak.
* src/functions/fn-financial.c (gnumeric_xnpv): Plug leak.
2000-04-08 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c
......
2000-04-09 Morten Welinder <terra@diku.dk>
* src/sheet.h (ParsePositions): Add sheet.
* src/expr.c (parse_pos_init): New arg sheet. All callers changed.
* src/parser.y (gnumeric_expr_parser): Use pp->sheet.
2000-04-08 Jon K Hellan <hellan@acm.org>
(sheet_name_quote): Quote embedded quotes.
......@@ -6,6 +14,8 @@
* src/xml-io.c (xml_read_solver): Plug leak.
* src/functions/fn-financial.c (gnumeric_xnpv): Plug leak.
2000-04-08 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c
......
2000-04-09 Morten Welinder <terra@diku.dk>
* src/sheet.h (ParsePositions): Add sheet.
* src/expr.c (parse_pos_init): New arg sheet. All callers changed.
* src/parser.y (gnumeric_expr_parser): Use pp->sheet.
2000-04-08 Jon K Hellan <hellan@acm.org>
(sheet_name_quote): Quote embedded quotes.
......@@ -6,6 +14,8 @@
* src/xml-io.c (xml_read_solver): Plug leak.
* src/functions/fn-financial.c (gnumeric_xnpv): Plug leak.
2000-04-08 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c
......
2000-04-09 Morten Welinder <terra@diku.dk>
* src/sheet.h (ParsePositions): Add sheet.
* src/expr.c (parse_pos_init): New arg sheet. All callers changed.
* src/parser.y (gnumeric_expr_parser): Use pp->sheet.
2000-04-08 Jon K Hellan <hellan@acm.org>
(sheet_name_quote): Quote embedded quotes.
......@@ -6,6 +14,8 @@
* src/xml-io.c (xml_read_solver): Plug leak.
* src/functions/fn-financial.c (gnumeric_xnpv): Plug leak.
2000-04-08 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c
......
2000-04-09 Morten Welinder <terra@diku.dk>
* src/sheet.h (ParsePositions): Add sheet.
* src/expr.c (parse_pos_init): New arg sheet. All callers changed.
* src/parser.y (gnumeric_expr_parser): Use pp->sheet.
2000-04-08 Jon K Hellan <hellan@acm.org>
(sheet_name_quote): Quote embedded quotes.
......@@ -6,6 +14,8 @@
* src/xml-io.c (xml_read_solver): Plug leak.
* src/functions/fn-financial.c (gnumeric_xnpv): Plug leak.
2000-04-08 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c
......
2000-04-09 Morten Welinder <terra@diku.dk>
* src/sheet.h (ParsePositions): Add sheet.
* src/expr.c (parse_pos_init): New arg sheet. All callers changed.
* src/parser.y (gnumeric_expr_parser): Use pp->sheet.
2000-04-08 Jon K Hellan <hellan@acm.org>
(sheet_name_quote): Quote embedded quotes.
......@@ -6,6 +14,8 @@
* src/xml-io.c (xml_read_solver): Plug leak.
* src/functions/fn-financial.c (gnumeric_xnpv): Plug leak.
2000-04-08 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c
......
2000-04-09 Morten Welinder <terra@diku.dk>
* src/sheet.h (ParsePositions): Add sheet.
* src/expr.c (parse_pos_init): New arg sheet. All callers changed.
* src/parser.y (gnumeric_expr_parser): Use pp->sheet.
2000-04-08 Jon K Hellan <hellan@acm.org>
(sheet_name_quote): Quote embedded quotes.
......@@ -6,6 +14,8 @@
* src/xml-io.c (xml_read_solver): Plug leak.
* src/functions/fn-financial.c (gnumeric_xnpv): Plug leak.
2000-04-08 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c
......
2000-04-09 Morten Welinder <terra@diku.dk>
* ms-ole.c: Include <string.h> for memset.
2000-04-01 Michael Meeks <michael@helixcode.com>
* ms-ole-summary.c (ms_ole_summary_open_stream): update for docs.
......
......@@ -18,6 +18,7 @@
#include <assert.h>
#include <ctype.h>
#include <glib.h>
#include <string.h>
#include "ms-ole.h"
......
......@@ -706,7 +706,7 @@ biff_name_data_get_name (ExcelSheet *sheet, int idx)
#ifndef NO_DEBUG_EXCEL
else if (ms_excel_read_debug > 1) {
ParsePosition ep;
parse_pos_init (&ep, sheet->wb->gnum_wb, 0, 0);
parse_pos_init (&ep, NULL, sheet->gnum_sheet, 0, 0);
printf ("Parsed name : '%s' = '%s'\n",
bnd->name, tree
? expr_decode_tree (tree, &ep)
......
......@@ -2431,7 +2431,8 @@ write_cell (BiffPut *bp, ExcelSheet *sheet, const ExcelCell *cell)
(gnum_cell->parsed_node ?
expr_decode_tree (gnum_cell->parsed_node,
parse_pos_init (&tmp,
sheet->wb->gnum_wb,
NULL,
sheet->gnum_sheet,
col, row)) :
"none"),
(gnum_cell->value ?
......
......@@ -644,7 +644,7 @@ gnumeric_nominal (FunctionEvalInfo *ei, Value **argv)
nper = value_get_as_int (argv[1]);
/* Rate or number of periods cannot be negative */
if ( (rate < 0) || (nper <= 0) )
if (rate < 0 || nper <= 0)
return value_new_error (ei->pos, _("nominal - domain error"));
return value_new_float ( nper * ( pow ( 1 + rate, 1.0/nper ) - 1 ) );
......@@ -718,7 +718,7 @@ gnumeric_db (FunctionEvalInfo *ei, Value **argv)
period = value_get_as_float (argv[3]);
month = argv[4] ? value_get_as_float (argv[4]) : 12;
if((cost == 0) || (life <= 0))
if (cost == 0 || life <= 0)
return value_new_error (ei->pos, gnumeric_err_NUM);
rate = 1 - pow ((salvage / cost), (1 / life));
......@@ -1504,8 +1504,10 @@ gnumeric_xnpv (FunctionEvalInfo *ei, Value **argv)
if (result)
goto out;
if (p_n != d_n)
return value_new_error (ei->pos, gnumeric_err_NUM);
if (p_n != d_n) {
result = value_new_error (ei->pos, gnumeric_err_NUM);
goto out;
}
for (i = 0; i < p_n; i++)
sum += payments[i] / pow (1 + rate, (dates[i] - dates[0]) / 365.0);
......
......@@ -816,7 +816,8 @@ gnumeric_expression (FunctionEvalInfo *ei, Value **args)
char * expr_string =
expr_decode_tree (cell->parsed_node,
parse_pos_init (&pos,
ei->pos->sheet->workbook,
NULL,
ei->pos->sheet,
ei->pos->eval.col,
ei->pos->eval.row));
Value * res = value_new_string (expr_string);
......
......@@ -480,7 +480,7 @@ cmd_area_set_text_redo (GnumericCommand *cmd, CommandContext *context)
char *error_string = NULL;
ParsePosition pp;
expr = expr_parse_string (me->text + 1,
parse_pos_init (&pp, me->sheet->workbook,
parse_pos_init (&pp, NULL, me->sheet,
r->start.col, r->start.row),
NULL, &error_string);
......
......@@ -358,7 +358,7 @@ fill_corba_value (GNOME_Gnumeric_Value *value, Sheet *sheet, CORBA_long col, COR
g_assert (value != NULL);
g_assert (sheet != NULL);
parse_pos_init (&pp, sheet->workbook, col, row);
parse_pos_init (&pp, NULL, sheet, col, row);
cell = sheet_cell_get (sheet, col, row);
if (cell && cell->value) {
switch (cell->value->type) {
......
......@@ -224,6 +224,7 @@ expr_name_create (Workbook *wb, Sheet *sheet, const char *name,
tree = expr_parse_string (value,
parse_pos_init (&pp,
get_real_wb (wb, sheet),
sheet,
0, 0),
NULL, error_msg);
......@@ -333,8 +334,10 @@ expr_name_value (const ExprName *expr_name)
ParsePosition pp;
if (!expr_name->builtin) {
parse_pos_init (&pp, get_real_wb (expr_name->wb,
expr_name->sheet),
parse_pos_init (&pp,
get_real_wb (expr_name->wb,
expr_name->sheet),
expr_name->sheet,
0, 0);
val = expr_decode_tree (expr_name->t.expr_tree, &pp);
} else
......
......@@ -33,13 +33,18 @@ eval_pos_init (EvalPosition *eval_pos, Sheet *sheet, int col, int row)
return eval_pos;
}
/*
* Supply either a sheet (preferred) or a workbook.
*/
ParsePosition *
parse_pos_init (ParsePosition *pp, Workbook *wb, int col, int row)
parse_pos_init (ParsePosition *pp, Workbook *wb, Sheet *sheet, int col, int row)
{
g_return_val_if_fail (wb != NULL, NULL);
g_return_val_if_fail (wb || sheet, NULL);
g_return_val_if_fail (pp != NULL, NULL);
pp->wb = wb;
pp->sheet = sheet;
pp->wb = sheet ? sheet->workbook : wb;
pp->col = col;
pp->row = row;
......@@ -72,7 +77,8 @@ parse_pos_cell (ParsePosition *pp, Cell *cell)
return parse_pos_init (
pp,
cell->sheet->workbook,
NULL,
cell->sheet,
cell->col->pos,
cell->row->pos);
}
......
......@@ -114,7 +114,7 @@ struct _FunctionEvalInfo {
/* Transition functions */
EvalPosition *eval_pos_init (EvalPosition *, Sheet *s, int col, int row);
EvalPosition *eval_pos_cell (EvalPosition *, Cell *);
ParsePosition *parse_pos_init (ParsePosition *, Workbook *wb, int col, int row);
ParsePosition *parse_pos_init (ParsePosition *, Workbook *wb, Sheet *sheet, int col, int row);
ParsePosition *parse_pos_cell (ParsePosition *, Cell *);
/*
......
......@@ -644,7 +644,7 @@ gnumeric_nominal (FunctionEvalInfo *ei, Value **argv)
nper = value_get_as_int (argv[1]);
/* Rate or number of periods cannot be negative */
if ( (rate < 0) || (nper <= 0) )
if (rate < 0 || nper <= 0)
return value_new_error (ei->pos, _("nominal - domain error"));
return value_new_float ( nper * ( pow ( 1 + rate, 1.0/nper ) - 1 ) );
......@@ -718,7 +718,7 @@ gnumeric_db (FunctionEvalInfo *ei, Value **argv)
period = value_get_as_float (argv[3]);
month = argv[4] ? value_get_as_float (argv[4]) : 12;
if((cost == 0) || (life <= 0))
if (cost == 0 || life <= 0)
return value_new_error (ei->pos, gnumeric_err_NUM);
rate = 1 - pow ((salvage / cost), (1 / life));
......@@ -1504,8 +1504,10 @@ gnumeric_xnpv (FunctionEvalInfo *ei, Value **argv)
if (result)
goto out;
if (p_n != d_n)
return value_new_error (ei->pos, gnumeric_err_NUM);
if (p_n != d_n) {
result = value_new_error (ei->pos, gnumeric_err_NUM);
goto out;
}
for (i = 0; i < p_n; i++)
sum += payments[i] / pow (1 + rate, (dates[i] - dates[0]) / 365.0);
......
......@@ -816,7 +816,8 @@ gnumeric_expression (FunctionEvalInfo *ei, Value **args)
char * expr_string =
expr_decode_tree (cell->parsed_node,
parse_pos_init (&pos,
ei->pos->sheet->workbook,
NULL,
ei->pos->sheet,
ei->pos->eval.col,
ei->pos->eval.row));
Value * res = value_new_string (expr_string);
......
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