Commit 9580c0d9 authored by Michael Meeks's avatar Michael Meeks

Advanced the Excel name stuff...

parent 30aba17e
1999-07-06 Michael Meeks <michael@edenproject.org>
* ms-formula-read.c (ms_excel_parse_formula): PTG_NAME:
use biff_name_data_get_name; fixups: Jody don't do this, this
was all on the Names branch !
* ms-excel-read.c (biff_name_data_new): Changed to take Workbook
not sheet, updated to use GPtrArray.
(biff_name_data_get_name): Changed to return ExprTree.
(biff_name_data_destroy): Updated.
(ms_excel_workbook_destroy): Remove old name hash table stuff.
(ms_excel_read_name): Fix memory leak before Morten gets there :)
use biff_name_data_new.
(ms_excel_read_name): Allocate name.
(ms_excel_get_name): Culled.
* ms-excel-read.h (_ExcelWorkbook): Changed name_data to GPtrArray
Changed _name_get_data to return ExprTree.
* ms-formula-read.c (getRefV7): Removed ExcelSheet * parameter.
cleaned function indenting.
(getRefV8): Ditto. + update all references.
s/cell_name(/cell_name (
s/sheet->wb/wb/
* ms-chart.c (BC_R): Updated parse_formula.
* ms-formula-read.c (ms_excel_parse_formula): s/sheet->ver/wb->ver/
updated all calls to itself to add 'wb'.
* ms-excel-read.c (ms_excel_workbook_new): Setup 'ver'
(ms_excel_read_workbook): Update call.
* ms-excel-read.h (_ExcelWorkbook): Add 'ver' field.
* ms-excel-read.c: Updated all ms_excel_parse_formulae: this
isn't as balmy as it seems... we should only be using the sheet
data where we need to as Names have no associated sheet.
* ms-formula-read.c (ms_excel_parse_formula): Add workbook.
* ms-formula-read.h (ms_excel_parse_formula): ditto.
1999-07-06 Jody Goldberg <jgoldberg@home.com>
* ms-excel-biff.h : remove _eBiff_wrap.
......
......@@ -161,7 +161,7 @@ BC_R(ai)(ExcelChartHandler const *handle,
sheet.shared_formulae = NULL;
if (length > 0) {
expr = ms_excel_parse_formula (&sheet, q->data+8, 0, 0,
expr = ms_excel_parse_formula (s->wb, &sheet, q->data+8, 0, 0,
FALSE, length, NULL);
if (ms_excel_chart_debug > 2)
expr_dump_tree (expr);
......
......@@ -27,8 +27,6 @@
#include "utils.h"
#include "excel.h"
#include "ms-ole.h"
#include "ms-biff.h"
#include "ms-formula-read.h"
#include "ms-excel-read.h"
#include "ms-obj.h"
......@@ -569,49 +567,76 @@ biff_format_data_destroy (gpointer key, BiffFormatData *d, gpointer userdata)
}
typedef struct {
guint16 idx;
char *name;
char *name;
ExprTree *formula;
guint8 *data;
guint16 len;
} BiffNameData;
static int externsheet = 0;
static void
biff_name_data_new (ExcelSheet *sheet, char *name,
biff_name_data_new (ExcelWorkbook *wb, char *name,
guint8 *formula, guint16 const len)
{
BiffNameData *bnd = g_new (BiffNameData, 1);
bnd->idx = g_hash_table_size (sheet->wb->name_data) + 1;
bnd->name = name;
bnd->formula = ms_excel_parse_formula (sheet, formula, 0, 0,
FALSE, len, NULL);
g_hash_table_insert (sheet->wb->name_data, &bnd->idx, bnd);
bnd->name = name;
bnd->formula = NULL; /* parse it late */
if (formula) {
bnd->data = g_malloc (len);
memcpy (bnd->data, formula, len);
bnd->len = len;
} else {
bnd->data = NULL;
bnd->len = 0;
}
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug>1) {
printf ("EXTERNNAME : %x %x '%s'\n", externsheet,
bnd->idx, bnd->name);
wb->name_data->len, bnd->name);
}
#endif
g_ptr_array_add (wb->name_data, bnd);
}
char *
ExprTree *
biff_name_data_get_name (ExcelSheet *sheet, guint16 idx)
{
BiffNameData *ptr = g_hash_table_lookup (sheet->wb->name_data, &idx);
if (ptr)
return ptr->name;
else
return 0;
BiffNameData *bnd;
GPtrArray *a;
g_return_val_if_fail (sheet, NULL);
g_return_val_if_fail (sheet->wb, NULL);
a = sheet->wb->name_data;
if (a && idx < a->len && (bnd = g_ptr_array_index (a, idx))) {
/* if (!bnd->formula) .... wait for it.
bnd->formula = ms_excel_parse_formula (sheet->wb, sheet, bnd->data, 0, 0,
FALSE, bnd->len, NULL);
return bnd->formula;*/
return expr_tree_new_constant (value_new_string (bnd->name));
} else
return expr_tree_new_constant (value_new_string("Unknown name"));
}
static gboolean
biff_name_data_destroy (gpointer key, BiffNameData *bnd, gpointer userdata)
static void
biff_name_data_destroy (BiffNameData *bnd)
{
g_free (bnd->name);
g_free (bnd->formula);
g_return_if_fail (bnd);
if (bnd->name)
g_free (bnd->name);
bnd->name = NULL;
if (bnd->formula)
expr_tree_unref (bnd->formula);
bnd->formula = NULL;
if (bnd->data)
g_free (bnd->data);
bnd->data = NULL;
bnd->len = 0;
g_free (bnd);
return 1;
}
......@@ -1321,7 +1346,7 @@ ms_excel_formula_shared (BiffQuery *q, ExcelSheet *sheet, Cell *cell)
q->data + (is_array ? 14 : 10);
guint16 const data_len =
BIFF_GET_GUINT16(q->data + (is_array ? 12 : 8));
ExprTree *expr = ms_excel_parse_formula (sheet, data,
ExprTree *expr = ms_excel_parse_formula (sheet->wb, sheet, data,
array_col_first,
array_row_first,
!is_array, data_len,
......@@ -1453,7 +1478,7 @@ ms_excel_read_formula (BiffQuery *q, ExcelSheet *sheet)
}
/* Now try to parse the formula */
expr = ms_excel_parse_formula (sheet, (q->data + 22),
expr = ms_excel_parse_formula (sheet->wb, sheet, (q->data + 22),
EX_GETCOL (q), EX_GETROW (q),
FALSE, BIFF_GET_GUINT16 (q->data+20),
&array_elem);
......@@ -1619,7 +1644,7 @@ ms_excel_sheet_destroy (ExcelSheet *sheet)
}
static ExcelWorkbook *
ms_excel_workbook_new (void)
ms_excel_workbook_new (eBiff_version ver)
{
ExcelWorkbook *ans = (ExcelWorkbook *) g_malloc (sizeof (ExcelWorkbook));
......@@ -1635,12 +1660,12 @@ ms_excel_workbook_new (void)
ans->excel_sheets = g_ptr_array_new ();
ans->XF_style_records = g_ptr_array_new ();
ans->XF_cell_records = g_ptr_array_new ();
ans->name_data = g_ptr_array_new ();
ans->format_data = g_hash_table_new ((GHashFunc)biff_guint16_hash,
(GCompareFunc)biff_guint16_equal);
ans->name_data = g_hash_table_new ((GHashFunc)biff_guint16_hash,
(GCompareFunc)biff_guint16_equal);
ans->internal_names = g_ptr_array_new ();
ans->palette = ms_excel_default_palette ();
ans->ver = ver;
ans->global_strings = NULL;
ans->global_string_max = 0;
ans->read_drawing_group = 0;
......@@ -1704,6 +1729,11 @@ ms_excel_workbook_destroy (ExcelWorkbook *wb)
biff_xf_data_destroy (g_ptr_array_index (wb->XF_cell_records, lp));
g_ptr_array_free (wb->XF_cell_records, TRUE);
if (wb->name_data)
for (lp=0;lp<wb->name_data->len;lp++)
biff_name_data_destroy (g_ptr_array_index (wb->name_data, lp));
g_ptr_array_free (wb->name_data, TRUE);
g_hash_table_foreach_remove (wb->font_data,
(GHRFunc)biff_font_data_destroy,
wb);
......@@ -1714,11 +1744,6 @@ ms_excel_workbook_destroy (ExcelWorkbook *wb)
wb);
g_hash_table_destroy (wb->format_data);
g_hash_table_foreach_remove (wb->name_data,
(GHRFunc)biff_name_data_destroy,
wb);
g_hash_table_destroy (wb->name_data);
if (wb->internal_names)
g_ptr_array_free (wb->internal_names, TRUE);
......@@ -1780,22 +1805,6 @@ biff_get_rk (guint8 *ptr)
while (1) abort ();
}
/*
* FIXME FIXME FIXME
* This will need to be rethought when the distinction between sheet local and
* workbook global names gets clarified. We need to work out the numbering
* scheme do the indicies reset when we go to a new work book ?
* There also seems to be a a high bit that signifies something ???
*/
char const *
ms_excel_get_name (ExcelWorkbook *wb, int name_idx)
{
--name_idx;
if (name_idx < 0 || name_idx >= wb->internal_names->len)
return NULL;
return (char const *)g_ptr_array_index (wb->internal_names, name_idx);
}
/* FIXME: S59DA9.HTM */
static void
ms_excel_read_name (BiffQuery *q, ExcelSheet *sheet)
......@@ -1818,14 +1827,11 @@ ms_excel_read_name (BiffQuery *q, ExcelSheet *sheet)
guint8 status_txt_len = BIFF_GET_GUINT8 (q->data + 13);
char *name, *menu_txt, *descr_txt, *help_txt, *status_txt;
guint8 *ptr;
ExprTree *tree;
/* g_assert (ixals==sheet_idx); */
ptr = q->data + 14;
if (name_len == 1 && *ptr <= 0x0c)
/* FIXME FIXME FIXME */
/* Be sure to new these when we actually use the result */
switch(*ptr)
if (name_len == 1 && *ptr <= 0x0c) {
switch (*ptr)
{
case 0x00 : name = "Consolidate_Area"; break;
case 0x01 : name = "Auto_Open"; break;
......@@ -1843,7 +1849,8 @@ ms_excel_read_name (BiffQuery *q, ExcelSheet *sheet)
default :
name = "ERROR ERROR ERROR. This is impossible";
}
else
name = g_strdup (name);
} else
name = biff_get_text (ptr, name_len, NULL);
ptr+= name_len + name_def_len;
menu_txt = biff_get_text (ptr, menu_txt_len, NULL);
......@@ -1880,15 +1887,23 @@ ms_excel_read_name (BiffQuery *q, ExcelSheet *sheet)
printf (" BinData");
printf ("\n");
g_ptr_array_add (sheet->wb->internal_names, name);
/* g_ptr_array_add (wb->internal_names, name); */
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug>1) {
printf ("NAME %d : %s\n", sheet->wb->internal_names->len, name);
}
#endif
tree = ms_excel_parse_formula (sheet, name_def_data,
0, 0, FALSE, name_def_len, NULL);
biff_name_data_new (sheet->wb, name, name_def_data, name_def_len);
if (menu_txt)
g_free (menu_txt);
if (descr_txt)
g_free (descr_txt);
if (help_txt)
g_free (help_txt);
if (status_txt)
g_free (status_txt);
}
/* S59D7E.HTM */
......@@ -1922,7 +1937,7 @@ ms_excel_externname(BiffQuery *q,
BIFF_GET_GUINT8(q->data), NULL);
}
biff_name_data_new (sheet, externname, defn, defnlen);
biff_name_data_new (sheet->wb, externname, defn, defnlen);
}
/**
......@@ -2577,7 +2592,7 @@ ms_excel_read_workbook (MsOle *file)
ver->version = vv;
if (ver->type == eBiffTWorkbook) {
wb = ms_excel_workbook_new ();
wb = ms_excel_workbook_new (ver->version);
wb->gnum_wb = workbook_new ();
if (ver->version >= eBiffV8)
printf ("Excel 97 +\n");
......
......@@ -7,7 +7,6 @@
#ifndef GNUMERIC_MS_EXCEL_H
#define GNUMERIC_MS_EXCEL_H
#include "ms-ole.h"
#include "ms-biff.h"
#include "ms-excel-biff.h"
......@@ -88,7 +87,7 @@ typedef struct _ExcelWorkbook
GPtrArray *XF_style_records;
GHashTable *font_data;
GHashTable *format_data;
GHashTable *name_data; /* Seems to be for external names */
GPtrArray *name_data; /* Seems to be for external names */
GPtrArray *internal_names; /* For internal names */
int read_drawing_group;
GPtrArray *excel_sheets;
......@@ -97,6 +96,7 @@ typedef struct _ExcelWorkbook
ExcelPalette *palette;
char **global_strings;
int global_string_max;
eBiff_version ver;
/**
* Gnumeric parallel workbook
......@@ -107,8 +107,7 @@ typedef struct _ExcelWorkbook
extern Sheet* biff_get_externsheet_name (ExcelWorkbook *wb, guint16 idx, gboolean get_first);
extern char* biff_get_text (guint8 *ptr, guint32 length, guint32 *byte_length);
extern const char* biff_get_error_text (const guint8 err);
extern char* biff_name_data_get_name (ExcelSheet *sheet, guint16 idx);
extern char const * ms_excel_get_name (ExcelWorkbook *wb, int name_idx);
extern ExprTree* biff_name_data_get_name (ExcelSheet *sheet, guint16 idx);
extern BIFF_BOF_DATA * ms_biff_bof_data_new (BiffQuery * q);
extern void ms_biff_bof_data_destroy (BIFF_BOF_DATA * data);
......
......@@ -446,79 +446,81 @@ expr_tree_string (const char *str)
* storage structure.
**/
static CellRef *
getRefV7(ExcelSheet *sheet, guint8 col, guint16 gbitrw, int curcol, int currow,
gboolean const shared)
getRefV7 (guint8 col, guint16 gbitrw, int curcol, int currow,
gboolean const shared)
{
CellRef *cr = (CellRef *)g_malloc(sizeof(CellRef)) ;
cr->col = col ;
cr->row = (gbitrw & 0x3fff) ;
cr->row_relative = (gbitrw & 0x8000)==0x8000 ;
cr->col_relative = (gbitrw & 0x4000)==0x4000 ;
cr->sheet = sheet->gnum_sheet;
CellRef *cr = (CellRef *)g_malloc(sizeof(CellRef));
cr->col = col;
cr->row = (gbitrw & 0x3fff);
cr->row_relative = (gbitrw & 0x8000) == 0x8000;
cr->col_relative = (gbitrw & 0x4000) == 0x4000;
cr->sheet = NULL; /* Current Sheet */
#ifndef NO_DEBUG_EXCEL
if (ms_excel_formula_debug > 2) {
printf ("7In : 0x%x, 0x%x at %s%s\n", col, gbitrw,
cell_name(curcol, currow), (shared?" (shared)":"")) ;
cell_name (curcol, currow), (shared?" (shared)":"")) ;
}
#endif
if (shared && cr->row_relative) {
gint8 t = (cr->row&0x00ff);
cr->row = currow+t ;
gint8 t = (cr->row & 0x00ff);
cr->row = currow+t;
}
if (shared && cr->col_relative) {
gint8 t = (cr->col&0x00ff);
cr->col = curcol+t ;
gint8 t = (cr->col & 0x00ff);
cr->col = curcol+t;
}
if (cr->row_relative)
cr->row-= currow ;
cr->row-= currow;
if (cr->col_relative)
cr->col-= curcol ;
cr->col-= curcol;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_formula_debug > 2){
if (ms_excel_formula_debug > 2) {
printf ("Returns : %s%s%s%d\n",
(cr->col_relative ? "":"$"), col_name(cr->col + curcol),
(cr->col_relative ? "":"$"), col_name (cr->col + curcol),
(cr->row_relative ? "":"$"), cr->row + currow + 1);
}
#endif
return cr ;
return cr;
}
/**
* A useful routine for extracting data from a common
* storage structure.
**/
static CellRef *
getRefV8 (ExcelSheet *sheet, guint16 row, guint16 gbitcl, int curcol, int currow,
getRefV8 (guint16 row, guint16 gbitcl, int curcol, int currow,
gboolean const shared)
{
CellRef *cr = (CellRef *)g_malloc(sizeof(CellRef)) ;
cr->sheet = sheet->gnum_sheet;
CellRef *cr = (CellRef *)g_malloc(sizeof(CellRef));
#ifndef NO_DEBUG_EXCEL
if (ms_excel_formula_debug > 2) {
printf ("8In : 0x%x, 0x%x at %s%s\n", row, gbitcl,
cell_name(curcol, currow), (shared?" (shared)":"")) ;
cell_name (curcol, currow), (shared?" (shared)":""));
}
#endif
cr->row = row ;
cr->col = (gbitcl & 0x3fff) ;
cr->row_relative = (gbitcl & 0x8000)==0x8000 ;
cr->col_relative = (gbitcl & 0x4000)==0x4000 ;
cr->row = row;
cr->col = (gbitcl & 0x3fff);
cr->row_relative = (gbitcl & 0x8000) == 0x8000;
cr->col_relative = (gbitcl & 0x4000) == 0x4000;
cr->sheet = NULL;
if (shared && cr->row_relative) { /* Should be correct now -- NJL */
gint8 t = (cr->row&0x00ff);
cr->row = currow+t ;
gint8 t = (cr->row & 0x00ff);
cr->row = currow + t;
}
if (shared && cr->col_relative) { /* Should be correct now -- NJL */
gint8 t = (cr->col&0x00ff);
cr->col = curcol+t ;
gint8 t = (cr->col & 0x00ff);
cr->col = curcol + t;
}
if (cr->row_relative)
cr->row-= currow ;
cr->row-= currow;
if (cr->col_relative)
cr->col-= curcol ;
cr->col-= curcol;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_formula_debug > 2) {
printf ("Returns : %s%s%s%d\n",
(cr->col_relative ? "":"$"), col_name(cr->col + curcol),
(cr->col_relative ? "":"$"), col_name (cr->col + curcol),
(cr->row_relative ? "":"$"), cr->row + currow + 1);
}
#endif
......@@ -748,7 +750,7 @@ make_function (PARSE_LIST **stack, int fn_idx, int numargs)
* Return a dynamicly allocated ExprTree containing the formula, or NULL
**/
ExprTree *
ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
ms_excel_parse_formula (ExcelWorkbook *wb, ExcelSheet *sheet, guint8 *mem,
int fn_col, int fn_row, gboolean const shared,
guint16 length,
gboolean *const array_element)
......@@ -769,7 +771,7 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
if (ms_excel_formula_debug > 1) {
printf ("\n\n%s:%s%s\n", (sheet->gnum_sheet
? sheet->gnum_sheet->name : ""),
cell_name(fn_col,fn_row), (shared?" (shared)":""));
cell_name (fn_col,fn_row), (shared?" (shared)":""));
}
#endif
......@@ -795,16 +797,16 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
case FORMULA_PTG_REF:
{
CellRef *ref=0;
if (sheet->ver >= eBiffV8)
if (wb->ver >= eBiffV8)
{
ref = getRefV8 (sheet, BIFF_GET_GUINT16(cur),
ref = getRefV8 (BIFF_GET_GUINT16(cur),
BIFF_GET_GUINT16(cur + 2),
fn_col, fn_row, shared) ;
ptg_length = 4 ;
}
else
{
ref = getRefV7 (sheet, BIFF_GET_GUINT8(cur+2), BIFF_GET_GUINT16(cur),
ref = getRefV7 (BIFF_GET_GUINT8(cur+2), BIFF_GET_GUINT16(cur),
fn_col, fn_row, shared) ;
ptg_length = 3 ;
}
......@@ -814,10 +816,10 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
}
case FORMULA_PTG_NAME_X: /* FIXME: Not using sheet_idx at all ... */
{
char *txt ;
ExprTree *tree ;
guint16 extn_sheet_idx, extn_name_idx ;
if (sheet->ver == eBiffV8) {
if (wb->ver == eBiffV8) {
extn_sheet_idx = BIFF_GET_GUINT16(cur) ;
extn_name_idx = BIFF_GET_GUINT16(cur+2) ;
/* printf ("FIXME: v8 NameX : %d %d\n", extn_sheet_idx, extn_name_idx) ; */
......@@ -828,33 +830,31 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
/* printf ("FIXME: v7 NameX : %d %d\n", extn_sheet_idx, extn_name_idx) ; */
ptg_length = 24 ;
}
if ((txt = biff_name_data_get_name (sheet, extn_name_idx)))
parse_list_push_raw (&stack, value_new_string (txt));
else
parse_list_push_raw (&stack, value_new_string ("DuffName"));
tree = biff_name_data_get_name (sheet, extn_name_idx);
parse_list_push (&stack, tree);
}
break;
case FORMULA_PTG_REF_3D: /* see S59E2B.HTM */
{
CellRef *ref=0;
if (sheet->ver >= eBiffV8) {
if (wb->ver >= eBiffV8) {
guint16 extn_idx = BIFF_GET_GUINT16(cur) ;
ref = getRefV8 (sheet, BIFF_GET_GUINT16(cur+2),
ref = getRefV8 (BIFF_GET_GUINT16(cur+2),
BIFF_GET_GUINT16(cur + 4),
fn_col, fn_row, 0) ;
make_inter_sheet_ref (sheet->wb, extn_idx, ref, 0) ;
make_inter_sheet_ref (wb, extn_idx, ref, 0) ;
parse_list_push (&stack, expr_tree_new_var (ref));
ptg_length = 6 ;
} else {
guint16 extn_idx, first_idx, second_idx;
ref = getRefV7 (sheet, BIFF_GET_GUINT8(cur+16), BIFF_GET_GUINT16(cur+14),
ref = getRefV7 (BIFF_GET_GUINT8(cur+16), BIFF_GET_GUINT16(cur+14),
fn_col, fn_row, 0) ;
extn_idx = BIFF_GET_GUINT16(cur);
first_idx = BIFF_GET_GUINT16(cur + 10);
second_idx = BIFF_GET_GUINT16(cur + 12);
make_inter_sheet_ref_v7 (sheet->wb, extn_idx, first_idx, second_idx, ref, 0) ;
make_inter_sheet_ref_v7 (wb, extn_idx, first_idx, second_idx, ref, 0) ;
parse_list_push (&stack, expr_tree_new_var (ref));
ptg_length = 17 ;
}
......@@ -865,30 +865,30 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
{
CellRef *first=0, *last=0 ;
if (sheet->ver >= eBiffV8) {
if (wb->ver >= eBiffV8) {
guint16 extn_idx = BIFF_GET_GUINT16(cur) ;
first = getRefV8(sheet, BIFF_GET_GUINT8(cur+2),
BIFF_GET_GUINT16(cur+6),
fn_col, fn_row, 0) ;
last = getRefV8(sheet, BIFF_GET_GUINT8(cur+4),
BIFF_GET_GUINT16(cur+8),
fn_col, fn_row, 0) ;
first = getRefV8 (BIFF_GET_GUINT8(cur+2),
BIFF_GET_GUINT16(cur+6),
fn_col, fn_row, 0) ;
last = getRefV8 (BIFF_GET_GUINT8(cur+4),
BIFF_GET_GUINT16(cur+8),
fn_col, fn_row, 0) ;
make_inter_sheet_ref (sheet->wb, extn_idx, first, last) ;
make_inter_sheet_ref (wb, extn_idx, first, last) ;
parse_list_push_raw (&stack, value_new_cellrange (first, last));
ptg_length = 10 ;
} else {
guint16 extn_idx, first_idx, second_idx;
first = getRefV7 (sheet, BIFF_GET_GUINT8(cur+18), BIFF_GET_GUINT16(cur+14),
first = getRefV7 (BIFF_GET_GUINT8(cur+18), BIFF_GET_GUINT16(cur+14),
fn_col, fn_row, 0) ;
last = getRefV7 (sheet, BIFF_GET_GUINT8(cur+19), BIFF_GET_GUINT16(cur+16),
last = getRefV7 (BIFF_GET_GUINT8(cur+19), BIFF_GET_GUINT16(cur+16),
fn_col, fn_row, 0) ;
extn_idx = BIFF_GET_GUINT16(cur);
first_idx = BIFF_GET_GUINT16(cur + 10);
second_idx = BIFF_GET_GUINT16(cur + 12);
make_inter_sheet_ref_v7 (sheet->wb, extn_idx, first_idx,
make_inter_sheet_ref_v7 (wb, extn_idx, first_idx,
second_idx, first, last) ;
parse_list_push_raw (&stack, value_new_cellrange (first, last));
ptg_length = 20 ;
......@@ -901,17 +901,17 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
case FORMULA_PTG_AREA:
{
CellRef *first=0, *last=0 ;
if (sheet->ver >= eBiffV8) {
first = getRefV8(sheet, BIFF_GET_GUINT8(cur+0),
BIFF_GET_GUINT16(cur+4),
fn_col, fn_row, shared) ;
last = getRefV8(sheet, BIFF_GET_GUINT8(cur+2),
BIFF_GET_GUINT16(cur+6),
fn_col, fn_row, shared) ;
if (wb->ver >= eBiffV8) {
first = getRefV8 (BIFF_GET_GUINT8(cur+0),
BIFF_GET_GUINT16(cur+4),
fn_col, fn_row, shared) ;
last = getRefV8 (BIFF_GET_GUINT8(cur+2),
BIFF_GET_GUINT16(cur+6),
fn_col, fn_row, shared) ;
ptg_length = 8 ;
} else {
first = getRefV7(sheet, BIFF_GET_GUINT8(cur+4), BIFF_GET_GUINT16(cur+0), fn_col, fn_row, shared) ;
last = getRefV7(sheet, BIFF_GET_GUINT8(cur+5), BIFF_GET_GUINT16(cur+2), fn_col, fn_row, shared) ;
first = getRefV7(BIFF_GET_GUINT8(cur+4), BIFF_GET_GUINT16(cur+0), fn_col, fn_row, shared) ;
last = getRefV7(BIFF_GET_GUINT8(cur+5), BIFF_GET_GUINT16(cur+2), fn_col, fn_row, shared) ;
ptg_length = 6 ;
}
......@@ -953,7 +953,7 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
guint32 len;
char *str;
if (sheet->ver >= eBiffV8) { /* Cunningly not mentioned in spec. ! */
if (wb->ver >= eBiffV8) { /* Cunningly not mentioned in spec. ! */
str = biff_get_text (array_data+3,
BIFF_GET_GUINT16(array_data+1),
&len);
......@@ -1013,23 +1013,22 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
}
case FORMULA_PTG_NAME:
{
/*
* NOTE : The docs seem wrong for Biff8.
* The record has only 4 bytes, and ilbl is at offset 0.
*/
guint16 name_idx ; /* 1 based */
char const *txt;
name_idx = BIFF_GET_GUINT16(cur) ;
txt = ms_excel_get_name (sheet->wb, name_idx);
if (!txt){
txt = "Unknown name";
printf ("FIXME: PTG Name '%d' not found\n",
name_idx) ;
dump(mem, length) ;
gint32 name_idx ; /* 1 based */
if (wb->ver >= eBiffV8) {
name_idx = BIFF_GET_GUINT16 (cur) - 1;
ptg_length = 4; /* Docs are wrong (?) +2 */
} else {
name_idx = BIFF_GET_GUINT16 (cur) - 1;
ptg_length = 4; /* Docs are wrong (?) */
}
parse_list_push_raw (&stack, value_new_string (txt)) ;
ptg_length = (sheet->ver >= eBiffV8) ? 4 : 14;
if (name_idx < 0)
printf ("FIXME: how odd; negative name calling is bad!\n");
#if FORMULA_DEBUG > 0
printf ("Name idx %d\n", name_idx);
#endif
parse_list_push (&stack,
biff_name_data_get_name (sheet, name_idx));
}
break;
......@@ -1052,7 +1051,7 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
(sheet->gnum_sheet
? sheet->gnum_sheet->name
: ""),
cell_name(fn_col, fn_row)) ;
cell_name (fn_col, fn_row)) ;
}
#endif
return NULL;
......@@ -1072,7 +1071,7 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
printf ("Parse shared formula\n");
}
#endif
expr = ms_excel_parse_formula (sheet, sf->data,
expr = ms_excel_parse_formula (wb, sheet, sf->data,
fn_col, fn_row, TRUE,
sf->data_len,
array_element);
......@@ -1135,9 +1134,9 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
#endif
if (w)
{
tr = ms_excel_parse_formula (sheet, cur+ptg_length,
fn_col, fn_row, shared,
w, NULL);
tr = ms_excel_parse_formula (wb, sheet, cur+ptg_length,
fn_col, fn_row, shared,
w, NULL);
} else
tr = expr_tree_string ("");
parse_list_push (&stack, tr);
......@@ -1164,7 +1163,7 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
*(cur+ptg_length+offset));
}
#endif
tr = ms_excel_parse_formula (sheet, cur+ptg_length+offset,
tr = ms_excel_parse_formula (wb, sheet, cur+ptg_length+offset,
fn_col, fn_row, shared,
len, NULL);
data+=2;
......@@ -1241,7 +1240,7 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,
char *str;
guint32 len;
/* dump (mem, length) ;*/
if (sheet->ver >= eBiffV8)
if (wb->ver >= eBiffV8)
{
str = biff_get_text (cur+2, BIFF_GET_GUINT16(cur), &len) ;
ptg_length = 2 + len ;
......@@ -1349,7 +1348,7 @@ ms_excel_parse_formula (ExcelSheet *sheet, guint8 *mem,