Commit 4064d5a6 authored by Michael Meeks's avatar Michael Meeks
Browse files

Array formulae fix, and column sizing.

parent e7d625e2
1999-03-09 Michael Meeks <michael@imaginator.com>
* ms-formula.c (ms_excel_parse_formula): Hacked out the
bad array formula support. Moved most of it to ms-excel.c
* ms-excel.c (ms_excel_read_cell): Updated BIFF_ARRAY and
BIFF_FORMULA cases; splitting and adding array loop.
BIFF_COLINFO, BIFF_ROW: Updated fudge factors in sizing
and implemented column sizing.
1999-03-07 Michael Meeks <michael@imaginator.com>
* ms-formula.c: Changed FORMULA_PTG_STR to cope with both
......
......@@ -1327,11 +1327,28 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
}
case BIFF_COLINFO: /* FIXME: See: S59D67.HTM */
{
int firstcol, lastcol, width, lp ;
guint16 cols_xf, options ;
int hidden, collapsed, outlining ;
firstcol = BIFF_GETWORD(q->data) ;
lastcol = BIFF_GETWORD(q->data+2) ;
width = BIFF_GETWORD(q->data+4) ;
cols_xf = BIFF_GETWORD(q->data+6) ;
options = BIFF_GETWORD(q->data+8) ;
hidden = (options & 0x0001) != 0 ;
collapsed = (options & 0x1000) != 0 ;
outlining = (options & 0x0700) >> 8 ;
if (EXCEL_DEBUG>0 && BIFF_GETBYTE(q->data+10) != 0)
printf ("Odd Colinfo\n") ;
printf ("Column Formatting from col %d to %d of width %f characters\n",
firstcol, lastcol, width/256.0) ;
for (lp=firstcol;lp<=lastcol;lp++)
sheet_col_set_width (sheet->gnum_sheet, lp, width/25) ;
break ;
}
case BIFF_RK: /*
* FIXME: S59DDA.HTM - test IEEE stuff on other endian platforms
*/
case BIFF_RK: /* See: S59DDA.HTM */
{
char buf[65];
......@@ -1376,21 +1393,32 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
case BIFF_ROW: /* FIXME: See: S59DDB.HTM */
{
guint16 height = BIFF_GETWORD(q->data+6) ;
printf ("Row %d formatting 0x%x\n", BIFF_GETWORD(q->data), height);
/* printf ("Row %d formatting 0x%x\n", BIFF_GETWORD(q->data), height); */
if ((height&0x8000) == 0) /* Fudge Factor */
sheet_row_set_height (sheet->gnum_sheet, BIFF_GETWORD(q->data), BIFF_GETWORD(q->data+6)/10, TRUE) ;
{
printf ("Row height : %f points\n", BIFF_GETWORD(q->data+6)/20.0) ;
sheet_row_set_height (sheet->gnum_sheet, BIFF_GETWORD(q->data), BIFF_GETWORD(q->data+6)/15, TRUE) ;
}
break;
}
case BIFF_ARRAY: /*
* FIXME: S59D57.HTM
*/
case BIFF_ARRAY: /* See: S59D57.HTM */
{
int array_col_first, array_col_last ;
int array_row_first, array_row_last ;
int xlp, ylp ;
array_row_first = BIFF_GETWORD(q->data + 0) ;
array_row_last = BIFF_GETWORD(q->data + 2) ;
array_col_first = BIFF_GETBYTE(q->data + 4) ;
array_col_last = BIFF_GETBYTE(q->data + 5) ;
printf ("Array Formula\n") ;
case BIFF_FORMULA: /*
* FIXME: S59D8F.HTM
*/
/*
* case BIFF_NAME FIXME: S59DA9.HTM
*/
for (xlp=array_col_first;xlp<=array_col_last;xlp++)
for (ylp=array_row_first;ylp<=array_row_last;ylp++)
ms_excel_parse_formula (sheet, q, xlp, ylp);
break ;
}
case BIFF_FORMULA: /* See: S59D8F.HTM */
ms_excel_parse_formula (sheet, q, EX_GETCOL (q), EX_GETROW (q));
break;
case BIFF_LABELSST:
......
......@@ -1327,11 +1327,28 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
}
case BIFF_COLINFO: /* FIXME: See: S59D67.HTM */
{
int firstcol, lastcol, width, lp ;
guint16 cols_xf, options ;
int hidden, collapsed, outlining ;
firstcol = BIFF_GETWORD(q->data) ;
lastcol = BIFF_GETWORD(q->data+2) ;
width = BIFF_GETWORD(q->data+4) ;
cols_xf = BIFF_GETWORD(q->data+6) ;
options = BIFF_GETWORD(q->data+8) ;
hidden = (options & 0x0001) != 0 ;
collapsed = (options & 0x1000) != 0 ;
outlining = (options & 0x0700) >> 8 ;
if (EXCEL_DEBUG>0 && BIFF_GETBYTE(q->data+10) != 0)
printf ("Odd Colinfo\n") ;
printf ("Column Formatting from col %d to %d of width %f characters\n",
firstcol, lastcol, width/256.0) ;
for (lp=firstcol;lp<=lastcol;lp++)
sheet_col_set_width (sheet->gnum_sheet, lp, width/25) ;
break ;
}
case BIFF_RK: /*
* FIXME: S59DDA.HTM - test IEEE stuff on other endian platforms
*/
case BIFF_RK: /* See: S59DDA.HTM */
{
char buf[65];
......@@ -1376,21 +1393,32 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
case BIFF_ROW: /* FIXME: See: S59DDB.HTM */
{
guint16 height = BIFF_GETWORD(q->data+6) ;
printf ("Row %d formatting 0x%x\n", BIFF_GETWORD(q->data), height);
/* printf ("Row %d formatting 0x%x\n", BIFF_GETWORD(q->data), height); */
if ((height&0x8000) == 0) /* Fudge Factor */
sheet_row_set_height (sheet->gnum_sheet, BIFF_GETWORD(q->data), BIFF_GETWORD(q->data+6)/10, TRUE) ;
{
printf ("Row height : %f points\n", BIFF_GETWORD(q->data+6)/20.0) ;
sheet_row_set_height (sheet->gnum_sheet, BIFF_GETWORD(q->data), BIFF_GETWORD(q->data+6)/15, TRUE) ;
}
break;
}
case BIFF_ARRAY: /*
* FIXME: S59D57.HTM
*/
case BIFF_ARRAY: /* See: S59D57.HTM */
{
int array_col_first, array_col_last ;
int array_row_first, array_row_last ;
int xlp, ylp ;
array_row_first = BIFF_GETWORD(q->data + 0) ;
array_row_last = BIFF_GETWORD(q->data + 2) ;
array_col_first = BIFF_GETBYTE(q->data + 4) ;
array_col_last = BIFF_GETBYTE(q->data + 5) ;
printf ("Array Formula\n") ;
case BIFF_FORMULA: /*
* FIXME: S59D8F.HTM
*/
/*
* case BIFF_NAME FIXME: S59DA9.HTM
*/
for (xlp=array_col_first;xlp<=array_col_last;xlp++)
for (ylp=array_row_first;ylp<=array_row_last;ylp++)
ms_excel_parse_formula (sheet, q, xlp, ylp);
break ;
}
case BIFF_FORMULA: /* See: S59D8F.HTM */
ms_excel_parse_formula (sheet, q, EX_GETCOL (q), EX_GETROW (q));
break;
case BIFF_LABELSST:
......
......@@ -400,42 +400,26 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
PARSE_LIST *stack ;
int error = 0 ;
char *ans ;
int array_col_first, array_col_last ;
int array_row_first, array_row_last ;
int fn_xf ;
if (q->ls_op == BIFF_FORMULA)
{
fn_xf = EX_GETXF(q) ;
/* printf ("Formula at [%d, %d] XF %d :\n", fn_col, fn_row, fn_xf) ;
printf ("formula data : \n") ;
dump (q->data +22, q->length-22) ; */
/* This will be safe when we collate continuation records in get_query */
length = BIFF_GETWORD(q->data + 20) ;
/* NB. the effective '+1' here is so that the offsets and lengths
are identical to those in the documentation */
cur = q->data + 22 + 1 ;
array_col_first = fn_col ;
array_col_last = fn_col ;
array_row_first = fn_row ;
array_row_last = fn_row ;
}
else
{
g_assert (q->ls_op == BIFF_ARRAY) ;
fn_xf = 0 ;
/* printf ("Array at [%d, %d] XF %d :\n", fn_col, fn_row, fn_xf) ;
printf ("Array data : \n") ;
dump (q->data +22, q->length-22) ; */
/* This will be safe when we collate continuation records in get_query */
length = BIFF_GETWORD(q->data + 12) ;
/* NB. the effective '+1' here is so that the offsets and lengths
are identical to those in the documentation */
cur = q->data + 14 + 1 ;
array_row_first = BIFF_GETWORD(q->data + 0) ;
array_row_last = BIFF_GETWORD(q->data + 2) ;
array_col_first = BIFF_GETBYTE(q->data + 4) ;
array_col_last = BIFF_GETBYTE(q->data + 5) ;
}
stack = parse_list_new() ;
......@@ -770,15 +754,11 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
}
if (error)
{
int xlp, ylp ;
printf ("Unknown Formula/Array at [%d, %d] XF %d :\n", fn_col, fn_row, fn_xf) ;
printf ("formula data : \n") ;
dump (q->data +22, q->length-22) ;
for (xlp=array_col_first;xlp<=array_col_last;xlp++)
for (ylp=array_row_first;ylp<=array_row_last;ylp++)
ms_excel_sheet_insert (sheet, fn_xf, xlp, ylp, "Unknown formula") ;
ms_excel_sheet_insert (sheet, fn_xf, fn_col, fn_row, "Unknown formula") ;
parse_list_free (stack) ;
return ;
}
......@@ -786,16 +766,11 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
ans = parse_list_to_equation (stack) ;
if (ans)
{
int xlp, ylp ;
for (xlp=array_col_first;xlp<=array_col_last;xlp++)
for (ylp=array_row_first;ylp<=array_row_last;ylp++)
{
cell = sheet_cell_fetch (sheet->gnum_sheet, EX_GETCOL(q), EX_GETROW(q)) ;
/* FIXME: this _should_ be a set_formula with the formula, and a
set_text_simple with the current value */
cell_set_text_simple (cell, ans) ;
ms_excel_set_cell_xf (sheet, cell, EX_GETXF(q)) ;
}
cell = sheet_cell_fetch (sheet->gnum_sheet, fn_col, fn_row) ;
/* FIXME: this _should_ be a set_formula with the formula, and a
set_text_simple with the current value */
cell_set_text_simple (cell, ans) ;
ms_excel_set_cell_xf (sheet, cell, fn_xf) ;
g_free (ans) ;
}
parse_list_free (stack) ;
......
......@@ -400,42 +400,26 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
PARSE_LIST *stack ;
int error = 0 ;
char *ans ;
int array_col_first, array_col_last ;
int array_row_first, array_row_last ;
int fn_xf ;
if (q->ls_op == BIFF_FORMULA)
{
fn_xf = EX_GETXF(q) ;
/* printf ("Formula at [%d, %d] XF %d :\n", fn_col, fn_row, fn_xf) ;
printf ("formula data : \n") ;
dump (q->data +22, q->length-22) ; */
/* This will be safe when we collate continuation records in get_query */
length = BIFF_GETWORD(q->data + 20) ;
/* NB. the effective '+1' here is so that the offsets and lengths
are identical to those in the documentation */
cur = q->data + 22 + 1 ;
array_col_first = fn_col ;
array_col_last = fn_col ;
array_row_first = fn_row ;
array_row_last = fn_row ;
}
else
{
g_assert (q->ls_op == BIFF_ARRAY) ;
fn_xf = 0 ;
/* printf ("Array at [%d, %d] XF %d :\n", fn_col, fn_row, fn_xf) ;
printf ("Array data : \n") ;
dump (q->data +22, q->length-22) ; */
/* This will be safe when we collate continuation records in get_query */
length = BIFF_GETWORD(q->data + 12) ;
/* NB. the effective '+1' here is so that the offsets and lengths
are identical to those in the documentation */
cur = q->data + 14 + 1 ;
array_row_first = BIFF_GETWORD(q->data + 0) ;
array_row_last = BIFF_GETWORD(q->data + 2) ;
array_col_first = BIFF_GETBYTE(q->data + 4) ;
array_col_last = BIFF_GETBYTE(q->data + 5) ;
}
stack = parse_list_new() ;
......@@ -770,15 +754,11 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
}
if (error)
{
int xlp, ylp ;
printf ("Unknown Formula/Array at [%d, %d] XF %d :\n", fn_col, fn_row, fn_xf) ;
printf ("formula data : \n") ;
dump (q->data +22, q->length-22) ;
for (xlp=array_col_first;xlp<=array_col_last;xlp++)
for (ylp=array_row_first;ylp<=array_row_last;ylp++)
ms_excel_sheet_insert (sheet, fn_xf, xlp, ylp, "Unknown formula") ;
ms_excel_sheet_insert (sheet, fn_xf, fn_col, fn_row, "Unknown formula") ;
parse_list_free (stack) ;
return ;
}
......@@ -786,16 +766,11 @@ void ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, BIFF_QUERY *q,
ans = parse_list_to_equation (stack) ;
if (ans)
{
int xlp, ylp ;
for (xlp=array_col_first;xlp<=array_col_last;xlp++)
for (ylp=array_row_first;ylp<=array_row_last;ylp++)
{
cell = sheet_cell_fetch (sheet->gnum_sheet, EX_GETCOL(q), EX_GETROW(q)) ;
/* FIXME: this _should_ be a set_formula with the formula, and a
set_text_simple with the current value */
cell_set_text_simple (cell, ans) ;
ms_excel_set_cell_xf (sheet, cell, EX_GETXF(q)) ;
}
cell = sheet_cell_fetch (sheet->gnum_sheet, fn_col, fn_row) ;
/* FIXME: this _should_ be a set_formula with the formula, and a
set_text_simple with the current value */
cell_set_text_simple (cell, ans) ;
ms_excel_set_cell_xf (sheet, cell, fn_xf) ;
g_free (ans) ;
}
parse_list_free (stack) ;
......
Supports Markdown
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