Commit 21d6000e authored by Jody Goldberg's avatar Jody Goldberg

- Supply a handler for unknown functions.

- Import previous values of expressions so we can format.
- Support a few undocumented biff types.
- More chart biff types imported.
parent e296f458
1999-06-30 Jody Goldberg <jgoldberg@home.com>
* biff-types.h : Add some undocumented BIFF types, move INDEX,
DEFAULTROWHEIGHT into lsb territory.
* ms-excel-read.c (ms_excel_palette_new) : Correct debug messages.
(ms_excel_palette_get) : Improve debug messages, and assume that
0, 64, 127 are all contrast states.
(ms_excel_set_cell_colors) : Tail merge with ms_excel_set_cell_xf,
handle special case of fill-pattern=0. Now all the color sheets
look OK !! Next step, patterns.
(ms_excel_read_formula, ms_excel_read_boolerr) : Read current values so
we can set styles. Empty strings are undocumented :-(
(ms_excel_read_cell) : Handle array formulas.
(ms_excel_read_sheet, ms_excel_read_workbook) : Add some unhandled
record types so that we can start to enable state checking.
(ms_excel_unexpected_biff) : New function for warning about state.
(biff_xf_data_new) : Don't map pattern types as if they were borders.
* ms-formula-read.c (make_function) : Generate a dummy handler for
unknown functions.
(unknownFunctionHandler) : A dummy handler returning NAME for unknown
functions.
* ms-chart.c : Use ms_excel_unexpected_biff, handle some
undocumented codes, and fill in more record types.
1999-06-30 Michael Meeks <michael@edenproject.org>
* ms-excel-write.c (write_sheet_bools): Updated
......
......@@ -21,6 +21,7 @@
#define BIFF_ROW 0x08 /* 2 */
#define BIFF_BOF 0x09 /* 8, NOT 10 */
#define BIFF_EOF 0x0a /* 0, NOT 10 */
#define BIFF_INDEX 0x0b /* 2, NOT 10 */
#define BIFF_CALCCOUNT 0x0c /* 0, NOT 10 */
#define BIFF_CALCMODE 0x0d /* 0, NOT 10 */
#define BIFF_PRECISION 0x0e /* 0 */
......@@ -43,6 +44,7 @@
#define BIFF_ARRAY 0x21 /* 2, NOT 10 */
#define BIFF_1904 0x22 /* 0, NOT 1,10 */
#define BIFF_EXTERNNAME 0x23 /* 2 */
#define BIFF_DEFAULTROWHEIGHT 0x25 /* 2, NOT 10 */
#define BIFF_LEFTMARGIN 0x26 /* 0, NOT 10 */
#define BIFF_RIGHTMARGIN 0x27 /* 0, NOT 10 */
#define BIFF_TOPMARGIN 0x28 /* 0 */
......@@ -51,14 +53,14 @@
#define BIFF_PRINTGRIDLINES 0x2b /* 0 */
#define BIFF_FILEPASS 0x2f /* 0 */
#define BIFF_FONT 0x31 /* 2 */
#define BIFF_PRINTSIZE 0x33 /* 0, Undocumented */
#define BIFF_CONTINUE 0x3c /* 0, NOT 10 */
#define BIFF_WINDOW1 0x3d /* 0, NOT 1,10 */
#define BIFF_BACKUP 0x40 /* 0, NOT 10 */
#define BIFF_PANE 0x41 /* 0, NOT 10 */
#define BIFF_CODENAME 0x42 /* DUPLICATE 42 */
#define BIFF_CODEPAGE 0x42 /* DUPLICATE 42 */
#define BIFF_XF_OLD 0x43 /* What is this ?, NOT 10 */
#define BIFF_PLS 0x4D /* 0 */
#define BIFF_PLS 0x4d /* 0 */
#define BIFF_DCON 0x50 /* 0, NOT 10 */
#define BIFF_DCONREF 0x51 /* 0, NOT 10 */
#define BIFF_DCONNAME 0x52 /* 0 */
......@@ -140,6 +142,7 @@
#define BIFF_INTERFACEHDR 0xe1 /* 0 */
#define BIFF_INTERFACEEND 0xe2 /* 0 */
#define BIFF_SXVX 0xe3 /* 0 */
#define BIFF_MERGECELLS 0xe5 /* Undocumented */
#define BIFF_TABIDCONF 0xea /* 0 */
#define BIFF_MS_O_DRAWING_GROUP 0xeb /* 0 */
#define BIFF_MS_O_DRAWING 0xec /* 0 */
......@@ -177,6 +180,7 @@
#define BIFF_TXO 0x1b6 /* ONLY 1 */
#define BIFF_REFRESHALL 0x1b7 /* ONLY 1 */
#define BIFF_HLINK 0x1b8 /* ONLY 1 */
#define BIFF_CODENAME 0x1ba /* ONLY 1, TYPO in MS Docs */
#define BIFF_SXFDBTYPE 0x1bb
#define BIFF_PROT4REVPASS 0x1bc /* ONLY 1 */
#define BIFF_DV 0x1be /* ONLY 1 */
......@@ -184,8 +188,6 @@
#define BIFF_BOOLERR 0x205 /* Why not as 05 */
#define BIFF_STRING 0x207 /* Why not as 07, NOT 10 */
#define BIFF_INDEX 0x20b /* Why not as 0b */
#define BIFF_DEFAULTROWHEIGHT 0x225 /* Why not as 25, NOT 10 */
#define BIFF_TABLE 0x236 /* Why not as 36 */
#define BIFF_WINDOW2 0x23e /* Why not as 3e, NOT 10 */
#define BIFF_STYLE 0x293 /* Why not as 93 */
......@@ -246,9 +248,9 @@
#define BIFF_CHART_alruns 0x1050
#define BIFF_CHART_ai 0x1051
#define BIFF_CHART_serauxerrbar 0x105b
#define BIFF_CHART_unknown105c 0x105c
#define BIFF_CHART_clrtclient 0x105c /* Undocumented */
#define BIFF_CHART_serfmt 0x105d
#define BIFF_CHART_unknown105f 0x105f
#define BIFF_CHART_3dbarshape 0x105f /* Undocumented */
#define BIFF_CHART_fbi 0x1060
#define BIFF_CHART_boppop 0x1061
#define BIFF_CHART_axcext 0x1062
......
......@@ -25,7 +25,7 @@ extern int ms_excel_write_workbook (MS_OLE *file, Workbook *wb,
typedef struct {
int b, g, r;
} EXCEL_PALETTE_ENTRY;
extern EXCEL_PALETTE_ENTRY excel_default_palette[];
extern EXCEL_PALETTE_ENTRY const excel_default_palette[];
#define EXCEL_DEF_PAL_LEN 56
extern char *excel_builtin_formats[];
......
This diff is collapsed.
......@@ -24,6 +24,7 @@
#include "sheet-object.h"
#include "style.h"
#include "main.h"
#include "utils.h"
#include "excel.h"
#include "ms-ole.h"
......@@ -45,6 +46,19 @@ static MS_EXCEL_SHEET *ms_excel_sheet_new (MS_EXCEL_WORKBOOK *wb,
static void ms_excel_workbook_attach (MS_EXCEL_WORKBOOK *wb,
MS_EXCEL_SHEET *ans) ;
void
ms_excel_unexpected_biff (BIFF_QUERY *q, char const * const state)
{
#if EXCEL_DEBUG > 0
printf ("Unexpected Opcode in %s : 0x%x, length 0x%x\n",
state, q->opcode, q->length);
#if EXCEL_DEBUG > 2
dump (q->data, q->length);
#endif
#endif
}
/**
* Generic 16 bit int index pointer functions.
**/
......@@ -560,7 +574,7 @@ char *excel_builtin_formats[EXCEL_BUILTIN_FORMAT_LEN] = {
static StyleFormat *
biff_format_data_lookup (MS_EXCEL_WORKBOOK *wb, guint16 idx)
{
char *ans;
char *ans = NULL;
if (idx <= 0x31) {
ans = excel_builtin_formats[idx];
if (!ans)
......@@ -639,7 +653,7 @@ biff_name_data_destroy (gpointer key, BIFF_NAME_DATA *bnd, gpointer userdata)
}
EXCEL_PALETTE_ENTRY excel_default_palette[EXCEL_DEF_PAL_LEN] = {
EXCEL_PALETTE_ENTRY const excel_default_palette[EXCEL_DEF_PAL_LEN] = {
/* These were generated by creating a sheet and
* modifying the 1st color cell and saving. This
* created a custom palette. I then loaded the sheet
......@@ -678,7 +692,7 @@ ms_excel_default_palette ()
if (!pal)
{
int entries = EXCEL_DEF_PAL_LEN;
#if EXCEL_DEBUG_COLOR > 1
#if EXCEL_DEBUG_COLOR > 3
printf ("Creating default pallete\n");
#endif
pal = (MS_EXCEL_PALETTE *) g_malloc (sizeof (MS_EXCEL_PALETTE));
......@@ -725,8 +739,8 @@ ms_excel_palette_new (BIFF_QUERY * q)
pal->blue[lp] = (num & 0x00ff0000) >> 16;
pal->green[lp] = (num & 0x0000ff00) >> 8;
pal->red[lp] = (num & 0x000000ff) >> 0;
#if EXCEL_DEBUG_COLOR > 2
printf ("Colour %d : 0x%8x (%d,%d,%d)\n", lp,
#if EXCEL_DEBUG_COLOR > 5
printf ("Colour %d : 0x%8x (%x,%x,%x)\n", lp,
num, pal->red[lp], pal->green[lp], pal->blue[lp]);
#endif
pal->gnum_cols[lp] = NULL ;
......@@ -737,48 +751,29 @@ ms_excel_palette_new (BIFF_QUERY * q)
static StyleColor *
ms_excel_palette_get (MS_EXCEL_PALETTE *pal, guint idx, StyleColor * contrast)
{
#if EXCEL_DEBUG_COLOR > 4
printf ("Color Index %d\n", idx);
#endif
g_assert (NULL != pal);
/* NOTE : not documented but seems close
* If you find a normative reference please forward it.
*
* The color index field seems to use
* 0 = Black
* 8-63 = Palette index 0-55
*
* 127, 64 = contrast ??
* 0, 64, 127 = contrast ??
* 65 = White ??
*
* Standard combos are
* - fore=64, back=65
* - fore=0-63, back=64
*
* Rethink this when we understand to relationships between
* automatic colors.
*/
/* FIXME FIXME FIXME : this should now be an assert */
if (!pal)
return NULL ;
if (idx == 0)
{
/* Just a guess but maybe this is constant black */
static StyleColor * black = NULL;
if (!black)
black = style_color_new (0, 0, 0);
return black;
}
else if (idx == 64 || idx ==127)
#if EXCEL_DEBUG_COLOR > 4
printf ("Color Index %d\n", idx);
#endif
if (idx == 0 || idx == 64 || idx ==127)
{
/* These seem to be some sort of automatic contract colors */
if (contrast)
{
/* FIXME FIXME FIXME : This is a BIG guess */
/* If the contrast colour closer to black or white based
* on this VERY loose metric. There is more to do.
/* Is the contrast colour closer to black or white based
* on this VERY loose metric.
*/
int const guess =
contrast->color.red +
......@@ -786,7 +781,7 @@ ms_excel_palette_get (MS_EXCEL_PALETTE *pal, guint idx, StyleColor * contrast)
contrast->color.blue;
#if EXCEL_DEBUG_COLOR > 1
printf ("Contrast : %d", guess);
printf ("Contrast : %d\n", guess);
#endif
if (guess <= (0x7fff + 0x8000 + 0x7fff))
{
......@@ -795,10 +790,10 @@ ms_excel_palette_get (MS_EXCEL_PALETTE *pal, guint idx, StyleColor * contrast)
#endif
return style_color_new (0xffff, 0xffff, 0xffff);
}
}
#if EXCEL_DEBUG_COLOR > 1
puts("Black");
puts("No contrast default to Black");
#endif
}
return style_color_new (0, 0, 0);
} else if (idx == 65)
{
......@@ -817,18 +812,16 @@ ms_excel_palette_get (MS_EXCEL_PALETTE *pal, guint idx, StyleColor * contrast)
g = (pal->green[idx] << 8) | pal->green[idx];
b = (pal->blue[idx] << 8) | pal->blue[idx];
#if EXCEL_DEBUG_COLOR > 1
printf ("New color in slot %d : RGB= %d,%d,%d\n",
r, g, b);
printf ("New color in slot %d : RGB= %x,%x,%x\n",
idx, r, g, b);
#endif
pal->gnum_cols[idx] = style_color_new (r, g, b);
g_return_val_if_fail (pal->gnum_cols[idx], NULL);
}
return pal->gnum_cols[idx];
}
{
return NULL;
}
}
static void
ms_excel_palette_destroy (MS_EXCEL_PALETTE * pal)
......@@ -873,55 +866,6 @@ typedef struct _BIFF_XF_DATA {
BYTE pat_backgnd_col;
} BIFF_XF_DATA;
static void
ms_excel_set_cell_colors (MS_EXCEL_SHEET * sheet, Cell * cell,
BIFF_XF_DATA * xf, StyleColor *basefore)
{
MS_EXCEL_PALETTE *p = sheet->wb->palette;
StyleColor *fore, *back;
int col;
if (!p || !xf) {
printf ("Internal Error: No palette !\n");
return;
}
/* Whack into cell.c(cell_draw):
printf ("Background %p (%d %d %d)\n", style->back_color, style->back_color->color.red,
style->back_color->color.green, style->back_color->color.blue) ; */
if (!basefore) {
#if EXCEL_DEBUG_COLOR > 2
printf ("Cell Color : '%s' : (%d, %d)\n",
cell_name (cell->col->pos, cell->row->pos),
xf->pat_foregnd_col, xf->pat_backgnd_col);
#endif
fore = ms_excel_palette_get (sheet->wb->palette,
xf->pat_foregnd_col, NULL);
back = ms_excel_palette_get (sheet->wb->palette,
xf->pat_backgnd_col, fore);
} else {
fore = basefore;
back = ms_excel_palette_get (sheet->wb->palette,
xf->pat_foregnd_col, NULL);
#if EXCEL_DEBUG_COLOR > 2
printf ("Cell Color : '%s' : (Fontcol, %d)\n",
cell_name (cell->col->pos, cell->row->pos),
xf->pat_foregnd_col);
#endif
}
if (fore && back) {
if (fore == back)
#if EXCEL_DEBUG > 0
printf ("FIXME: patterns need work\n")
#endif
;
else
cell_set_color_from_style (cell, fore, back);
}
else
printf ("Missing color\n");
}
/**
* Search for a font record from its index in the workbooks font table
......@@ -953,16 +897,12 @@ static void
ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, guint16 xfidx)
{
BIFF_XF_DATA *xf;
StyleColor *fore;
GPtrArray *p;
guint16 idx = xfidx - XF_MAGIC_OFFSET;
StyleColor *fore, *back, *basefore;
int back_index;
if (!cell->value) {
#if EXCEL_DEBUG > 0
printf ("FIXME: Error setting xf on cell\n");
#endif
return;
}
g_return_if_fail (cell->value);
if (xfidx == 0){
/* printf ("Normal cell formatting\n"); */
......@@ -986,11 +926,13 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, guint16 xfidx)
if (xf->xftype != eBiffXCell)
printf ("FIXME: Error looking up XF\n") ;
g_return_if_fail (xf);
/*
* Well set it up then ! FIXME: hack !
*/
cell_set_alignment (cell, xf->halign, xf->valign, ORIENT_HORIZ, 0);
fore = ms_excel_set_cell_font (sheet, cell, xf);
basefore = ms_excel_set_cell_font (sheet, cell, xf);
if (sheet->wb->palette)
{
int lp;
......@@ -1012,7 +954,39 @@ ms_excel_set_cell_xf (MS_EXCEL_SHEET * sheet, Cell * cell, guint16 xfidx)
cell_set_format_from_style (cell, xf->style_format) ;
}
}
ms_excel_set_cell_colors (sheet, cell, xf, fore);
#if EXCEL_DEBUG_COLOR > 0
printf ("%s : Pattern = %d\n",
cell_name (cell->col->pos, cell->row->pos),
xf->fill_pattern_idx);
#endif
if (!basefore) {
#if EXCEL_DEBUG_COLOR > 2
printf ("Cell Color : '%s' : (%d, %d)\n",
cell_name (cell->col->pos, cell->row->pos),
xf->pat_foregnd_col, xf->pat_backgnd_col);
#endif
fore = ms_excel_palette_get (sheet->wb->palette,
xf->pat_foregnd_col, NULL);
back_index = xf->pat_backgnd_col;
} else {
#if EXCEL_DEBUG_COLOR > 2
printf ("Cell Color : '%s' : (Fontcol, %d)\n",
cell_name (cell->col->pos, cell->row->pos),
xf->pat_foregnd_col);
#endif
fore = basefore;
back_index = xf->pat_foregnd_col;
}
/* Use contrasting colour for background if the fill pattern is
* 0 (transparent)
*/
if (xf->fill_pattern_idx == 0)
back_index = 0;
back = ms_excel_palette_get (sheet->wb->palette, back_index, fore);
g_return_if_fail (back && fore);
cell_set_color_from_style (cell, fore, back);
}
static StyleBorderType
......@@ -1216,7 +1190,7 @@ biff_xf_data_new (MS_EXCEL_WORKBOOK *wb, BIFF_QUERY * q, eBiff_version ver)
xf->border_color[STYLE_BOTTOM] = (subdata & 0x7f);
subdata = subdata >> 7;
xf->border_linestyle = biff_xf_map_border ((data & 0x01e00000) >> 21);
xf->fill_pattern_idx = biff_xf_map_border ((data & 0xfc000000) >> 26);
xf->fill_pattern_idx = (data & 0xfc000000) >> 26;
data = BIFF_GETWORD (q->data + 18);
xf->pat_foregnd_col = (data & 0x007f);
......@@ -1333,17 +1307,149 @@ ms_excel_sheet_insert (MS_EXCEL_SHEET * sheet, int xfidx,
ms_excel_set_cell_xf (sheet, cell, xfidx);
}
/*
* Handle FORMULA */
static void
ms_excel_sheet_insert_form (MS_EXCEL_SHEET * sheet, int xfidx,
int col, int row, ExprTree *tr)
ms_excel_read_formula (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
{
Cell *cell = sheet_cell_fetch (sheet->gnum_sheet, col, row);
if (tr) {
/* Pre-retrieve incase this is a string */
guint16 const xf_index = EX_GETXF (q);
Cell *cell = sheet_cell_fetch (sheet->gnum_sheet,
EX_GETCOL (q), EX_GETROW (q));
/* TODO TODO TODO : Wishlist
* We should make an array of minimum sizes for each BIFF type
* and have this checking done there.
*/
ExprTree *tr;
Value * val = NULL;
if (q->length < 22 ||
q->length < 22 + BIFF_GETWORD (q->data+20))
{
printf ("FIXME: serious formula error: "
"supposed length 0x%x, real len 0x%x\n",
BIFF_GETWORD (q->data+20), q->length);
return;
}
tr = ms_excel_parse_formula (sheet, (q->data + 22),
EX_GETCOL (q), EX_GETROW (q),
0, BIFF_GETWORD (q->data+20));
/* Error was flaged by parse_formula */
if (NULL == tr)
return;
/*
* FIXME FIXME FIXME : cell_set_formula_tree_simple queues things for
* recalc !! and puts them in the WRONG order !!
* This is doubly wrong, We should only recalc on load when the
* flag is set.
*/
sheet->blank = FALSE ;
cell_set_formula_tree_simple (cell, tr);
/* Set the current value so that we can format */
if (BIFF_GETWORD (q->data+12) != 0xffff) {
double const num = BIFF_GETDOUBLE(q->data+6);
val = value_new_float (num);
} else
cell_set_text_simple (cell, "") ;
ms_excel_set_cell_xf (sheet, cell, xfidx);
{
guint8 const val_type = BIFF_GETBYTE (q->data+6);
switch (val_type)
{
case 0 : /* String */
if (ms_biff_query_next (q) && q->opcode == BIFF_STRING)
{
char *v = biff_get_text (q->data + 2,
BIFF_GETWORD(q->data),
NULL) ;
if (v)
{
val = value_new_string (v);
g_free (v) ;
}
} else
{
/*
* Docs say that there should be a STRING
* record here
*/
g_error ("Excel import error, "
"missing STRING record");
}
break;
case 1 : /* Boolean */
{
guint8 const v = BIFF_GETBYTE (q->data+8);
val = value_new_bool (v ? TRUE : FALSE);
}
break;
case 2 : /* Error */
{
guint8 const v = BIFF_GETBYTE (q->data+8);
char const * const err_str =
biff_get_error_text (v);
/* FIXME FIXME FIXME : how to mark this as
* an ERROR ? */
val = value_new_string (err_str);
}
break;
case 3 : /* Empty String */
/* TODO TODO TODO
* This is undocumented and a big guess, but it seems
* accurate.
*/
#if EXCEL_DEBUG > 0
printf ("%s:%s : has type 3 contents. "
"Is it an empty string ?\n",
sheet->gnum_sheet->name,
cell_name (cell->col->pos, cell->row->pos));
dump (q->data+6, 8) ;
#endif
val = value_new_string ("");
break;
default :
printf ("Unknown type (%x) for cell's current val\n",
val_type);
};
}
if (val)
{
if (cell->value)
printf ("ERROR : How does cell already have value?\n");
else
cell->value = val;
ms_excel_set_cell_xf (sheet, cell, xf_index);
} else
printf ("Unable to set format for cell with no value.\n");
expr_tree_unref (tr);
}
static void
ms_excel_read_error (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
{
ExprTree *e;
guint8 const val = BIFF_GETBYTE(q->data + 6);
Value * v = NULL;
guint16 const xf_index = EX_GETXF (q);
Cell *cell = sheet_cell_fetch (sheet->gnum_sheet,
EX_GETCOL (q), EX_GETROW (q));
char const * const err_str = biff_get_error_text (val);
v = value_new_string (err_str);
e = expr_tree_new_error (err_str);
sheet->blank = FALSE ;
cell_set_formula_tree_simple (cell, e);
cell->value = v;
expr_tree_unref (e);
ms_excel_set_cell_xf (sheet, cell, xf_index);
}
static void
......@@ -1719,32 +1825,6 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
}
}
break;
case BIFF_HEADER: /* FIXME : S59D94 */
{
char *str ;
if (q->length)
{
#if EXCEL_DEBUG > 0
printf ("Header '%s'\n", (str=biff_get_text (q->data+1,
BIFF_GETBYTE(q->data), NULL))) ;
g_free(str) ;
#endif
}
break;
}
case BIFF_FOOTER: /* FIXME : S59D8D */
{
char *str ;
if (q->length)
{
#if EXCEL_DEBUG > 0
printf ("Footer '%s'\n", (str=biff_get_text (q->data+1,
BIFF_GETBYTE(q->data), NULL))) ;
g_free(str) ;
#endif
}
break;
}
case BIFF_RSTRING: /* See: S59DDC.HTM */
{
char *txt ;
......@@ -1901,56 +1981,35 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
int array_row_first, array_row_last ;
int xlp, ylp ;
BYTE *data ;
int data_len ;
int data_len, options ;
ExprTree *expr = NULL;
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) ;
sheet->blank = FALSE;
/* int options = BIFF_GETWORD(q->data + 6) ; not so useful */
#if 0
/* Not handled yet */
options = BIFF_GETWORD(q->data + 6) ;
#endif
data = q->data + 14 ;
data_len = BIFF_GETWORD(q->data + 12) ;
printf ("Array Formula of extent %d %d %d %d\n",
array_col_first, array_row_first, array_col_last, array_row_last) ;
for (xlp=array_col_first;xlp<=array_col_last;xlp++)
for (ylp=array_row_first;ylp<=array_row_last;ylp++)
{
ExprTree *tr = ms_excel_parse_formula (sheet, data,
xlp, ylp,
expr = ms_excel_parse_formula (sheet, data,
array_col_first, array_row_first,
0, data_len) ;
/* NB. This keeps the pre-set XF record */
if (tr) {
Cell *cell = sheet_cell_fetch (sheet->gnum_sheet, xlp, ylp);
if (cell)
cell_set_formula_tree_simple (cell, tr);
expr_tree_unref (tr);
}
}
cell_set_array_formula (sheet->gnum_sheet,
array_row_first, array_col_first,
array_row_last, array_col_last, expr);
expr_tree_unref (expr);
sheet->blank = FALSE;
break ;
}
case BIFF_FORMULA: /* See: S59D8F.HTM */
{
ExprTree *tr;
if (q->length < 22 ||
q->length < 22 + BIFF_GETWORD(q->data+20)) {
printf ("FIXME: serious formula error: "
"supposed length 0x%x, real len 0x%x\n",
BIFF_GETWORD(q->data+20), q->length);
ms_excel_read_formula (q, sheet) ;
break;
}
tr = ms_excel_parse_formula (sheet, (q->data + 22),
EX_GETCOL (q), EX_GETROW (q),
0, BIFF_GETWORD(q->data+20));
ms_excel_sheet_insert_form (sheet, EX_GETXF(q), EX_GETCOL(q),
EX_GETROW(q), tr) ;
if (tr)
expr_tree_unref (tr);
break;
}
case BIFF_LABELSST:
{
guint32 idx = BIFF_GETLONG (q->data + 6) ;
......@@ -1980,26 +2039,10 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
ms_excel_read_name (q);
break ;
case BIFF_STRING: /* FIXME: S59DE9.HTM */
{
char *txt ;
if (EXCEL_DEBUG>0)
{
printf ("This cell evaluated to '%s': so what ? data:\n",
(txt = biff_get_text (q->data + 2, BIFF_GETWORD(q->data), NULL))) ;
if (txt) g_free (txt) ;
}
break ;
}
case BIFF_BOOLERR: /* S59D5F.HTM */
{
if (BIFF_GETBYTE(q->data + 7)) {
/* Error */
ExprTree *e;
e = expr_tree_new_error (biff_get_error_text (BIFF_GETBYTE(q->data + 6)));
ms_excel_sheet_insert_form (sheet, EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), e);
expr_tree_unref (e);
ms_excel_read_error (q, sheet);
} else {
/* Boolean */
Value *v;
......@@ -2010,8 +2053,7 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
break;
}
default:
if (EXCEL_DEBUG>0)
printf ("Unrecognised opcode : 0x%x, length 0x%x\n", q->opcode, q->length);
ms_excel_unexpected_biff (q, "Cell");
break;
}
}
......@@ -2120,8 +2162,79 @@ ms_excel_read_sheet (MS_EXCEL_SHEET *sheet, BIFF_QUERY * q, MS_EXCEL_WORKBOOK *
}
break;
}
case BIFF_INDEX :
case BIFF_CALCMODE :
case BIFF_CALCCOUNT :
case BIFF_REFMODE :
case BIFF_ITERATION :
case BIFF_DELTA :
case BIFF_SAVERECALC :
case BIFF_PRINTHEADERS :
case BIFF_PRINTGRIDLINES :
case BIFF_GUTS :
case BIFF_DEFAULTROWHEIGHT :
case BIFF_GRIDSET :
case BIFF_COUNTRY :
case BIFF_WSBOOL :
break;
case BIFF_HEADER: /* FIXME : S59D94 */
{
if (q->length)
{
char * const str =
biff_get_text (q->data+1,
BIFF_GETBYTE(q->data),
NULL) ;
#if EXCEL_DEBUG > 0
printf ("Header '%s'\n", str);
#endif
g_free(str) ;
}
}