Commit 100ac918 authored by Michael Meeks's avatar Michael Meeks

Major formula bug, and memory leak squashed.

Minor OLE updates
parent 85ca3e0a
1998-11-28 Michael Meeks <mejm2@cam.ac.uk>
* plugins/excel/ms-formula.c(ms_excel_parse_formula): Fixed serious
memory leaks on return values from cellref_name
* plugins/excel/ms-formula.c(getRefV7): Now sets CellRef->sheet properly
(getRefV8): same.
* plugins/excel/ms-ole.c: Several minor changes, moving seperate
structures back into the raw datastream with macros.
1998-11-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-11-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/gnumeric-util.c (gnumeric_notice): Do not use * src/gnumeric-util.c (gnumeric_notice): Do not use
......
1998-11-28 Michael Meeks <mejm2@cam.ac.uk>
* plugins/excel/ms-formula.c(ms_excel_parse_formula): Fixed serious
memory leaks on return values from cellref_name
* plugins/excel/ms-formula.c(getRefV7): Now sets CellRef->sheet properly
(getRefV8): same.
* plugins/excel/ms-ole.c: Several minor changes, moving seperate
structures back into the raw datastream with macros.
1998-11-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-11-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/gnumeric-util.c (gnumeric_notice): Do not use * src/gnumeric-util.c (gnumeric_notice): Do not use
......
1998-11-28 Michael Meeks <mejm2@cam.ac.uk>
* plugins/excel/ms-formula.c(ms_excel_parse_formula): Fixed serious
memory leaks on return values from cellref_name
* plugins/excel/ms-formula.c(getRefV7): Now sets CellRef->sheet properly
(getRefV8): same.
* plugins/excel/ms-ole.c: Several minor changes, moving seperate
structures back into the raw datastream with macros.
1998-11-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-11-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/gnumeric-util.c (gnumeric_notice): Do not use * src/gnumeric-util.c (gnumeric_notice): Do not use
......
1998-11-28 Michael Meeks <mejm2@cam.ac.uk>
* plugins/excel/ms-formula.c(ms_excel_parse_formula): Fixed serious
memory leaks on return values from cellref_name
* plugins/excel/ms-formula.c(getRefV7): Now sets CellRef->sheet properly
(getRefV8): same.
* plugins/excel/ms-ole.c: Several minor changes, moving seperate
structures back into the raw datastream with macros.
1998-11-28 Miguel de Icaza <miguel@nuclecu.unam.mx> 1998-11-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/gnumeric-util.c (gnumeric_notice): Do not use * src/gnumeric-util.c (gnumeric_notice): Do not use
......
...@@ -400,15 +400,15 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET * sheet, Cell * cell, BIFF_XF_DATA * xf) ...@@ -400,15 +400,15 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET * sheet, Cell * cell, BIFF_XF_DATA * xf)
fd->fontname[i] = tolower (fd->fontname[i]); fd->fontname[i] = tolower (fd->fontname[i]);
fd->fontname[i] = '\x0'; fd->fontname[i] = '\x0';
cell_set_font (cell, font_change_component (cell->style->font->font_name, 1, fd->fontname)); cell_set_font (cell, font_change_component (cell->style->font->font_name, 1, fd->fontname));
printf ("FoNt [-]: %s\n", cell->style->font->font_name); // printf ("FoNt [-]: %s\n", cell->style->font->font_name);
if (fd->italic) { if (fd->italic) {
cell_set_font (cell, font_get_italic_name (cell->style->font->font_name)); cell_set_font (cell, font_get_italic_name (cell->style->font->font_name));
printf ("FoNt [i]: %s\n", cell->style->font->font_name); // printf ("FoNt [i]: %s\n", cell->style->font->font_name);
cell->style->font->hint_is_italic = 1; cell->style->font->hint_is_italic = 1;
} }
if (fd->boldness == 0x2bc) { if (fd->boldness == 0x2bc) {
cell_set_font (cell, font_get_bold_name (cell->style->font->font_name)); cell_set_font (cell, font_get_bold_name (cell->style->font->font_name));
printf ("FoNt [b]: %s\n", cell->style->font->font_name); // printf ("FoNt [b]: %s\n", cell->style->font->font_name);
cell->style->font->hint_is_bold = 1; cell->style->font->hint_is_bold = 1;
} }
/* /*
...@@ -430,6 +430,9 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, int xfidx) ...@@ -430,6 +430,9 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, int xfidx)
{ {
GList *ptr; GList *ptr;
int cnt; int cnt;
BIFF_XF_DATA *xf ;
static int cache_xfidx = 0 ;
static BIFF_XF_DATA *cache_ptr = 0 ;
if (xfidx == 0) { if (xfidx == 0) {
printf ("Normal cell formatting\n"); printf ("Normal cell formatting\n");
...@@ -439,36 +442,50 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, int xfidx) ...@@ -439,36 +442,50 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, int xfidx)
printf ("Default cell formatting\n"); printf ("Default cell formatting\n");
return; return;
} }
/* xf = cache_ptr ;
* if (!cell->text) Crash if formatting and no text...
* cell_set_text_simple(cell, "") ;
*/
ptr = g_list_first (sheet->wb->XF_records);
/*
* printf ("Looking for %d\n", xfidx) ;
*/
cnt = 16 + 4; /*
* Magic number ... :-) FIXME - dodgy
*/
while (ptr) {
BIFF_XF_DATA *xf = ptr->data;
if (xf->xftype != eBiffXCell) { if (cache_xfidx != xfidx || !cache_ptr)
ptr = ptr->next; {
continue; cache_xfidx = xfidx ;
} cache_ptr = 0 ;
if (cnt == xfidx) { /* /*
* Well set it up then ! FIXME: hack ! * if (!cell->text) Crash if formatting and no text...
* cell_set_text_simple(cell, "") ;
*/
ptr = g_list_first (sheet->wb->XF_records);
/*
* printf ("Looking for %d\n", xfidx) ;
*/
cnt = 16 + 4; /*
* Magic number ... :-) FIXME - dodgy
*/ */
cell_set_alignment (cell, xf->halign, xf->valign, ORIENT_HORIZ, 1); while (ptr) {
ms_excel_set_cell_colors (sheet, cell, xf); xf = ptr->data ;
ms_excel_set_cell_font (sheet, cell, xf);
return; if (xf->xftype != eBiffXCell) {
ptr = ptr->next;
continue;
}
if (cnt == xfidx) {
cache_ptr = xf ;
break ;
}
cnt++;
ptr = ptr->next;
if (!ptr)
{
printf ("No XF record for %d out of %d found :-(\n", xfidx, cnt);
return ;
}
} }
cnt++;
ptr = ptr->next;
} }
printf ("No XF record for %d out of %d found :-(\n", xfidx, cnt);
/*
* Well set it up then ! FIXME: hack !
*/
cell_set_alignment (cell, xf->halign, xf->valign, ORIENT_HORIZ, 1);
ms_excel_set_cell_colors (sheet, cell, xf);
ms_excel_set_cell_font (sheet, cell, xf);
} }
/** /**
......
...@@ -400,15 +400,15 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET * sheet, Cell * cell, BIFF_XF_DATA * xf) ...@@ -400,15 +400,15 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET * sheet, Cell * cell, BIFF_XF_DATA * xf)
fd->fontname[i] = tolower (fd->fontname[i]); fd->fontname[i] = tolower (fd->fontname[i]);
fd->fontname[i] = '\x0'; fd->fontname[i] = '\x0';
cell_set_font (cell, font_change_component (cell->style->font->font_name, 1, fd->fontname)); cell_set_font (cell, font_change_component (cell->style->font->font_name, 1, fd->fontname));
printf ("FoNt [-]: %s\n", cell->style->font->font_name); // printf ("FoNt [-]: %s\n", cell->style->font->font_name);
if (fd->italic) { if (fd->italic) {
cell_set_font (cell, font_get_italic_name (cell->style->font->font_name)); cell_set_font (cell, font_get_italic_name (cell->style->font->font_name));
printf ("FoNt [i]: %s\n", cell->style->font->font_name); // printf ("FoNt [i]: %s\n", cell->style->font->font_name);
cell->style->font->hint_is_italic = 1; cell->style->font->hint_is_italic = 1;
} }
if (fd->boldness == 0x2bc) { if (fd->boldness == 0x2bc) {
cell_set_font (cell, font_get_bold_name (cell->style->font->font_name)); cell_set_font (cell, font_get_bold_name (cell->style->font->font_name));
printf ("FoNt [b]: %s\n", cell->style->font->font_name); // printf ("FoNt [b]: %s\n", cell->style->font->font_name);
cell->style->font->hint_is_bold = 1; cell->style->font->hint_is_bold = 1;
} }
/* /*
...@@ -430,6 +430,9 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, int xfidx) ...@@ -430,6 +430,9 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, int xfidx)
{ {
GList *ptr; GList *ptr;
int cnt; int cnt;
BIFF_XF_DATA *xf ;
static int cache_xfidx = 0 ;
static BIFF_XF_DATA *cache_ptr = 0 ;
if (xfidx == 0) { if (xfidx == 0) {
printf ("Normal cell formatting\n"); printf ("Normal cell formatting\n");
...@@ -439,36 +442,50 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, int xfidx) ...@@ -439,36 +442,50 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, int xfidx)
printf ("Default cell formatting\n"); printf ("Default cell formatting\n");
return; return;
} }
/* xf = cache_ptr ;
* if (!cell->text) Crash if formatting and no text...
* cell_set_text_simple(cell, "") ;
*/
ptr = g_list_first (sheet->wb->XF_records);
/*
* printf ("Looking for %d\n", xfidx) ;
*/
cnt = 16 + 4; /*
* Magic number ... :-) FIXME - dodgy
*/
while (ptr) {
BIFF_XF_DATA *xf = ptr->data;
if (xf->xftype != eBiffXCell) { if (cache_xfidx != xfidx || !cache_ptr)
ptr = ptr->next; {
continue; cache_xfidx = xfidx ;
} cache_ptr = 0 ;
if (cnt == xfidx) { /* /*
* Well set it up then ! FIXME: hack ! * if (!cell->text) Crash if formatting and no text...
* cell_set_text_simple(cell, "") ;
*/
ptr = g_list_first (sheet->wb->XF_records);
/*
* printf ("Looking for %d\n", xfidx) ;
*/
cnt = 16 + 4; /*
* Magic number ... :-) FIXME - dodgy
*/ */
cell_set_alignment (cell, xf->halign, xf->valign, ORIENT_HORIZ, 1); while (ptr) {
ms_excel_set_cell_colors (sheet, cell, xf); xf = ptr->data ;
ms_excel_set_cell_font (sheet, cell, xf);
return; if (xf->xftype != eBiffXCell) {
ptr = ptr->next;
continue;
}
if (cnt == xfidx) {
cache_ptr = xf ;
break ;
}
cnt++;
ptr = ptr->next;
if (!ptr)
{
printf ("No XF record for %d out of %d found :-(\n", xfidx, cnt);
return ;
}
} }
cnt++;
ptr = ptr->next;
} }
printf ("No XF record for %d out of %d found :-(\n", xfidx, cnt);
/*
* Well set it up then ! FIXME: hack !
*/
cell_set_alignment (cell, xf->halign, xf->valign, ORIENT_HORIZ, 1);
ms_excel_set_cell_colors (sheet, cell, xf);
ms_excel_set_cell_font (sheet, cell, xf);
} }
/** /**
......
...@@ -51,7 +51,7 @@ FORMULA_FUNC_DATA formula_func_data[] = ...@@ -51,7 +51,7 @@ FORMULA_FUNC_DATA formula_func_data[] =
* A useful routine for extracting data from a common * A useful routine for extracting data from a common
* storage structure. * storage structure.
**/ **/
static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow) static CellRef *getRefV7(MS_EXCEL_SHEET *sheet, BYTE col, WORD gbitrw, int curcol, int currow)
{ {
CellRef *cr = (CellRef *)malloc(sizeof(CellRef)) ; CellRef *cr = (CellRef *)malloc(sizeof(CellRef)) ;
cr->col = col ; cr->col = col ;
...@@ -62,6 +62,7 @@ static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow) ...@@ -62,6 +62,7 @@ static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow)
cr->row-= currow ; cr->row-= currow ;
if (cr->col_relative) if (cr->col_relative)
cr->col-= curcol ; cr->col-= curcol ;
cr->sheet = sheet->gnum_sheet ;
/* printf ("7Out : %d, %d at %d, %d\n", cr->col, cr->row, curcol, currow) ; */ /* printf ("7Out : %d, %d at %d, %d\n", cr->col, cr->row, curcol, currow) ; */
return cr ; return cr ;
} }
...@@ -69,7 +70,7 @@ static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow) ...@@ -69,7 +70,7 @@ static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow)
* A useful routine for extracting data from a common * A useful routine for extracting data from a common
* storage structure. * storage structure.
**/ **/
static CellRef *getRefV8(WORD row, WORD gbitcl, int curcol, int currow) static CellRef *getRefV8(MS_EXCEL_SHEET *sheet, WORD row, WORD gbitcl, int curcol, int currow)
{ {
CellRef *cr = (CellRef *)malloc(sizeof(CellRef)) ; CellRef *cr = (CellRef *)malloc(sizeof(CellRef)) ;
cr->row = row ; cr->row = row ;
...@@ -80,6 +81,7 @@ static CellRef *getRefV8(WORD row, WORD gbitcl, int curcol, int currow) ...@@ -80,6 +81,7 @@ static CellRef *getRefV8(WORD row, WORD gbitcl, int curcol, int currow)
cr->row-= currow ; cr->row-= currow ;
if (cr->col_relative) if (cr->col_relative)
cr->col-= curcol ; cr->col-= curcol ;
cr->sheet = sheet->gnum_sheet ;
/* printf ("8Out : %d, %d at %d, %d\n", cr->col, cr->row, curcol, currow) ; */ /* printf ("8Out : %d, %d at %d, %d\n", cr->col, cr->row, curcol, currow) ; */
return cr ; return cr ;
} }
...@@ -121,6 +123,7 @@ static PARSE_LIST *parse_list_new () ...@@ -121,6 +123,7 @@ static PARSE_LIST *parse_list_new ()
static void parse_list_push (PARSE_LIST *list, PARSE_DATA *pd) static void parse_list_push (PARSE_LIST *list, PARSE_DATA *pd)
{ {
/* printf ("Pushing '%s'\n", pd->name) ; */
list->data = g_list_append (list->data, pd) ; list->data = g_list_append (list->data, pd) ;
list->length++ ; list->length++ ;
} }
...@@ -306,16 +309,16 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q, ...@@ -306,16 +309,16 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
char *buffer ; char *buffer ;
if (sheet->ver == eBiffV8) if (sheet->ver == eBiffV8)
{ {
ref = getRefV8 (BIFF_GETWORD(cur), BIFF_GETWORD(cur + 2), fn_col, fn_row) ; ref = getRefV8 (sheet, BIFF_GETWORD(cur), BIFF_GETWORD(cur + 2), fn_col, fn_row) ;
ptg_length = 4 ; ptg_length = 4 ;
} }
else else
{ {
ref = getRefV7 (BIFF_GETBYTE(cur+2), BIFF_GETWORD(cur), fn_col, fn_row) ; ref = getRefV7 (sheet, BIFF_GETBYTE(cur+2), BIFF_GETWORD(cur), fn_col, fn_row) ;
ptg_length = 3 ; ptg_length = 3 ;
} }
buffer = cellref_name (ref, sheet->gnum_sheet, fn_col, fn_row) ; buffer = cellref_name (ref, sheet->gnum_sheet, fn_col, fn_row) ;
parse_list_push_raw(stack, strdup (buffer), NO_PRECEDENCE) ; parse_list_push_raw(stack, buffer, NO_PRECEDENCE) ;
printf ("%s\n", buffer) ; printf ("%s\n", buffer) ;
free (ref) ; free (ref) ;
} }
...@@ -323,22 +326,25 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q, ...@@ -323,22 +326,25 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
case FORMULA_PTG_AREA: case FORMULA_PTG_AREA:
{ {
CellRef *first, *last ; CellRef *first, *last ;
char buffer[128] ; char buffer[64] ;
char *ptr ;
if (sheet->ver == eBiffV8) if (sheet->ver == eBiffV8)
{ {
first = getRefV8(BIFF_GETBYTE(cur+0), BIFF_GETWORD(cur+4), fn_col, fn_row) ; first = getRefV8(sheet, BIFF_GETBYTE(cur+0), BIFF_GETWORD(cur+4), fn_col, fn_row) ;
last = getRefV8(BIFF_GETBYTE(cur+2), BIFF_GETWORD(cur+6), fn_col, fn_row) ; last = getRefV8(sheet, BIFF_GETBYTE(cur+2), BIFF_GETWORD(cur+6), fn_col, fn_row) ;
ptg_length = 8 ; ptg_length = 8 ;
} }
else else
{ {
first = getRefV7(BIFF_GETBYTE(cur+4), BIFF_GETWORD(cur+0), fn_col, fn_row) ; first = getRefV7(sheet, BIFF_GETBYTE(cur+4), BIFF_GETWORD(cur+0), fn_col, fn_row) ;
last = getRefV7(BIFF_GETBYTE(cur+5), BIFF_GETWORD(cur+2), fn_col, fn_row) ; last = getRefV7(sheet, BIFF_GETBYTE(cur+5), BIFF_GETWORD(cur+2), fn_col, fn_row) ;
ptg_length = 6 ; ptg_length = 6 ;
} }
strcpy (buffer, cellref_name (first, sheet->gnum_sheet, fn_col, fn_row)) ; strcpy (buffer, (ptr = cellref_name (first, sheet->gnum_sheet, fn_col, fn_row))) ;
free (ptr) ;
strcat (buffer, ":") ; strcat (buffer, ":") ;
strcat (buffer, cellref_name (last, sheet->gnum_sheet, fn_col, fn_row)) ; strcat (buffer, (ptr=cellref_name (last, sheet->gnum_sheet, fn_col, fn_row))) ;
free (ptr) ;
parse_list_push_raw(stack, strdup (buffer), NO_PRECEDENCE) ; parse_list_push_raw(stack, strdup (buffer), NO_PRECEDENCE) ;
printf ("%s\n", buffer) ; printf ("%s\n", buffer) ;
free (first) ; free (first) ;
......
...@@ -51,7 +51,7 @@ FORMULA_FUNC_DATA formula_func_data[] = ...@@ -51,7 +51,7 @@ FORMULA_FUNC_DATA formula_func_data[] =
* A useful routine for extracting data from a common * A useful routine for extracting data from a common
* storage structure. * storage structure.
**/ **/
static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow) static CellRef *getRefV7(MS_EXCEL_SHEET *sheet, BYTE col, WORD gbitrw, int curcol, int currow)
{ {
CellRef *cr = (CellRef *)malloc(sizeof(CellRef)) ; CellRef *cr = (CellRef *)malloc(sizeof(CellRef)) ;
cr->col = col ; cr->col = col ;
...@@ -62,6 +62,7 @@ static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow) ...@@ -62,6 +62,7 @@ static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow)
cr->row-= currow ; cr->row-= currow ;
if (cr->col_relative) if (cr->col_relative)
cr->col-= curcol ; cr->col-= curcol ;
cr->sheet = sheet->gnum_sheet ;
/* printf ("7Out : %d, %d at %d, %d\n", cr->col, cr->row, curcol, currow) ; */ /* printf ("7Out : %d, %d at %d, %d\n", cr->col, cr->row, curcol, currow) ; */
return cr ; return cr ;
} }
...@@ -69,7 +70,7 @@ static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow) ...@@ -69,7 +70,7 @@ static CellRef *getRefV7(BYTE col, WORD gbitrw, int curcol, int currow)
* A useful routine for extracting data from a common * A useful routine for extracting data from a common
* storage structure. * storage structure.
**/ **/
static CellRef *getRefV8(WORD row, WORD gbitcl, int curcol, int currow) static CellRef *getRefV8(MS_EXCEL_SHEET *sheet, WORD row, WORD gbitcl, int curcol, int currow)
{ {
CellRef *cr = (CellRef *)malloc(sizeof(CellRef)) ; CellRef *cr = (CellRef *)malloc(sizeof(CellRef)) ;
cr->row = row ; cr->row = row ;
...@@ -80,6 +81,7 @@ static CellRef *getRefV8(WORD row, WORD gbitcl, int curcol, int currow) ...@@ -80,6 +81,7 @@ static CellRef *getRefV8(WORD row, WORD gbitcl, int curcol, int currow)
cr->row-= currow ; cr->row-= currow ;
if (cr->col_relative) if (cr->col_relative)
cr->col-= curcol ; cr->col-= curcol ;
cr->sheet = sheet->gnum_sheet ;
/* printf ("8Out : %d, %d at %d, %d\n", cr->col, cr->row, curcol, currow) ; */ /* printf ("8Out : %d, %d at %d, %d\n", cr->col, cr->row, curcol, currow) ; */
return cr ; return cr ;
} }
...@@ -121,6 +123,7 @@ static PARSE_LIST *parse_list_new () ...@@ -121,6 +123,7 @@ static PARSE_LIST *parse_list_new ()
static void parse_list_push (PARSE_LIST *list, PARSE_DATA *pd) static void parse_list_push (PARSE_LIST *list, PARSE_DATA *pd)
{ {
/* printf ("Pushing '%s'\n", pd->name) ; */
list->data = g_list_append (list->data, pd) ; list->data = g_list_append (list->data, pd) ;
list->length++ ; list->length++ ;
} }
...@@ -306,16 +309,16 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q, ...@@ -306,16 +309,16 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
char *buffer ; char *buffer ;
if (sheet->ver == eBiffV8) if (sheet->ver == eBiffV8)
{ {
ref = getRefV8 (BIFF_GETWORD(cur), BIFF_GETWORD(cur + 2), fn_col, fn_row) ; ref = getRefV8 (sheet, BIFF_GETWORD(cur), BIFF_GETWORD(cur + 2), fn_col, fn_row) ;
ptg_length = 4 ; ptg_length = 4 ;
} }
else else
{ {
ref = getRefV7 (BIFF_GETBYTE(cur+2), BIFF_GETWORD(cur), fn_col, fn_row) ; ref = getRefV7 (sheet, BIFF_GETBYTE(cur+2), BIFF_GETWORD(cur), fn_col, fn_row) ;
ptg_length = 3 ; ptg_length = 3 ;
} }
buffer = cellref_name (ref, sheet->gnum_sheet, fn_col, fn_row) ; buffer = cellref_name (ref, sheet->gnum_sheet, fn_col, fn_row) ;
parse_list_push_raw(stack, strdup (buffer), NO_PRECEDENCE) ; parse_list_push_raw(stack, buffer, NO_PRECEDENCE) ;
printf ("%s\n", buffer) ; printf ("%s\n", buffer) ;
free (ref) ; free (ref) ;
} }
...@@ -323,22 +326,25 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q, ...@@ -323,22 +326,25 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
case FORMULA_PTG_AREA: case FORMULA_PTG_AREA:
{ {
CellRef *first, *last ; CellRef *first, *last ;
char buffer[128] ; char buffer[64] ;
char *ptr ;
if (sheet->ver == eBiffV8) if (sheet->ver == eBiffV8)
{ {
first = getRefV8(BIFF_GETBYTE(cur+0), BIFF_GETWORD(cur+4), fn_col, fn_row) ; first = getRefV8(sheet, BIFF_GETBYTE(cur+0), BIFF_GETWORD(cur+4), fn_col, fn_row) ;
last = getRefV8(BIFF_GETBYTE(cur+2), BIFF_GETWORD(cur+6), fn_col, fn_row) ; last = getRefV8(sheet, BIFF_GETBYTE(cur+2), BIFF_GETWORD(cur+6), fn_col, fn_row) ;
ptg_length = 8 ; ptg_length = 8 ;
} }
else else
{ {
first = getRefV7(BIFF_GETBYTE(cur+4), BIFF_GETWORD(cur+0), fn_col, fn_row) ; first = getRefV7(sheet, BIFF_GETBYTE(cur+4), BIFF_GETWORD(cur+0), fn_col, fn_row) ;
last = getRefV7(BIFF_GETBYTE(cur+5), BIFF_GETWORD(cur+2), fn_col, fn_row) ; last = getRefV7(sheet, BIFF_GETBYTE(cur+5), BIFF_GETWORD(cur+2), fn_col, fn_row) ;
ptg_length = 6 ; ptg_length = 6 ;
} }
strcpy (buffer, cellref_name (first, sheet->gnum_sheet, fn_col, fn_row)) ; strcpy (buffer, (ptr = cellref_name (first, sheet->gnum_sheet, fn_col, fn_row))) ;
free (ptr) ;
strcat (buffer, ":") ; strcat (buffer, ":") ;
strcat (buffer, cellref_name (last, sheet->gnum_sheet, fn_col, fn_row)) ; strcat (buffer, (ptr=cellref_name (last, sheet->gnum_sheet, fn_col, fn_row))) ;
free (ptr) ;
parse_list_push_raw(stack, strdup (buffer), NO_PRECEDENCE) ; parse_list_push_raw(stack, strdup (buffer), NO_PRECEDENCE) ;
printf ("%s\n", buffer) ; printf ("%s\n", buffer) ;
free (first) ; free (first) ;
......
...@@ -27,6 +27,15 @@ ...@@ -27,6 +27,15 @@
(*(p+2)<<16)+ \ (*(p+2)<<16)+ \
(*(p+3)<<24)) (*(p+3)<<24))
#define PUT_GUINT8(p,n) (*(p+0)=n)
#define PUT_GUINT16(p,n) ((*(p+0)=(n&0xff)), \
(*(p+1)=(n>>8)&0xff))
#define PUT_GUINT32(p,n) ((*(p+0)=n&0xff), \
(*(p+1)=(n>>8)&0xff), \
(*(p+2)=(n>>16)&0xff), \