Commit a5fbada7 authored by Michael Meeks's avatar Michael Meeks

More work on formula writing, doesn't work yet but its near.

Also, important bug fix in reading formulae.
parent db0c08f4
1999-07-01 Michael Meeks <michael@edenproject.org>
* ms-excel-read.c (ms_excel_read_formula): Fix silly
bug with broken formuale.
* ms-biff.c (ms_biff_put_var_seekto): Added seekto
API for fiddly biff types.
* ms-excel-write.c (biff_put_text): Made external
* ms-formeula-write.c: Created.
1999-06-30 Michael Meeks <michael@edenproject.org>
* ms-formula-read.c (ms_excel_parse_formula): Updated
Operation handling for new structure ( array ).
* ms-excel-read.c (biff_get_global_string): Removed.
* ms-formula-read.c: Updated func_data, and
formula_op_data for Miguel and correctness.
Cleaned FORMULA_NO_PRECEDENCE.
* excel.h: Move and rename FormulaFuncData.
* ms-excel-write.c: Moved structures to header.
Renamed all structures to make Miguel happy.
* Makefile.am: Added ms-formula-write.[ch]
1999-06-30 Michael Meeks <michael@edenproject.org>
* ms-formula-read.h: Split out types.
......
......@@ -25,6 +25,8 @@ libexcel_a_SOURCES = \
ms-excel-write.h \
ms-formula-read.c \
ms-formula-read.h \
ms-formula-write.c \
ms-formula-write.h \
ms-obj.c \
ms-obj.h \
ms-chart.h \
......
......@@ -31,8 +31,14 @@ extern EXCEL_PALETTE_ENTRY const excel_default_palette[];
extern char *excel_builtin_formats[];
#define EXCEL_BUILTIN_FORMAT_LEN 0x32
#endif
typedef struct
{
char *prefix ;
int num_args ; /* -1 for multi-arg */
/* -2 for unknown args */
} FormulaFuncData;
extern FormulaFuncData formula_func_data[];
#define FORMULA_FUNC_DATA_LEN 368
#endif
......@@ -10,7 +10,21 @@
#define FORMULA_PTG_MAX 0x7f
#define FORMULA_PTG_EXP 0x01
#define FORMULA_PTG_EXPR 0x01
#define FORMULA_PTG_ADD 0x03
#define FORMULA_PTG_SUB 0x04
#define FORMULA_PTG_MULT 0x05
#define FORMULA_PTG_DIV 0x06
#define FORMULA_PTG_EXP 0x07
#define FORMULA_PTG_CONCAT 0x08
#define FORMULA_PTG_LT 0x09
#define FORMULA_PTG_LTE 0x0a
#define FORMULA_PTG_EQUAL 0x0b
#define FORMULA_PTG_GTE 0x0c
#define FORMULA_PTG_GT 0x0d
#define FORMULA_PTG_NOT_EQUAL 0x0e
#define FORMULA_PTG_U_PLUS 0x12
#define FORMULA_PTG_U_MINUS 0x13
#define FORMULA_PTG_PAREN 0x15
......
......@@ -365,6 +365,7 @@ ms_biff_put_var_next (BIFF_PUT *bp, guint16 opcode)
bp->ls_op = (opcode & 0xff);
bp->padding = ms_bug_get_padding (opcode);
bp->num_merges = 0;
bp->curpos = 0;
bp->length = 0;
bp->data = 0;
bp->streamPos = bp->pos->tell (bp->pos);
......@@ -386,28 +387,42 @@ ms_biff_put_var_write (BIFF_PUT *bp, guint8 *data, guint32 len)
g_return_if_fail (bp->length+len < 0xf000);
bp->pos->write (bp->pos, data, len);
bp->length+= len;
bp->curpos+= len;
if (bp->curpos > bp->length)
bp->length = bp->curpos;
}
void
ms_biff_put_var_seekto (BIFF_PUT *bp, ms_ole_pos_t pos)
{
g_return_if_fail (bp);
g_return_if_fail (!bp->len_fixed);
g_return_if_fail (!bp->data);
bp->curpos = pos;
bp->pos->lseek (bp->pos, bp->streamPos + bp->curpos + 4, MS_OLE_SEEK_SET);
}
static void
ms_biff_put_var_commit (BIFF_PUT *bp)
{
guint8 tmp[4];
ms_ole_pos_t curpos;
ms_ole_pos_t endpos;
g_return_if_fail (bp);
g_return_if_fail (bp->pos);
g_return_if_fail (!bp->len_fixed);
g_return_if_fail (!bp->data);
curpos = bp->pos->tell (bp->pos);
endpos = bp->streamPos + bp->length + 4;
bp->pos->lseek (bp->pos, bp->streamPos, MS_OLE_SEEK_SET);
BIFF_SET_GUINT16 (tmp, (bp->ms_op<<8) + bp->ls_op);
BIFF_SET_GUINT16 (tmp+2, bp->length);
bp->pos->write (bp->pos, tmp, 4);
bp->pos->lseek (bp->pos, curpos, MS_OLE_SEEK_SET);
bp->streamPos = curpos;
bp->pos->lseek (bp->pos, endpos, MS_OLE_SEEK_SET);
bp->streamPos = endpos;
bp->curpos = 0;
}
static void
ms_biff_put_len_commit (BIFF_PUT *bp)
......@@ -420,7 +435,6 @@ ms_biff_put_len_commit (BIFF_PUT *bp)
g_return_if_fail (bp->length == 0 || bp->data);
g_return_if_fail (bp->length < MAX_LIKED_BIFF_LEN);
/* if (!bp->data_malloced) Unimplemented optimisation
bp->pos->lseek (bp->pos, bp->length, MS_OLE_SEEK_CUR);
else */
......@@ -431,7 +445,8 @@ ms_biff_put_len_commit (BIFF_PUT *bp)
g_free (bp->data);
bp->data = 0 ;
bp->streamPos = bp->pos->tell (bp->pos);
bp->streamPos = bp->pos->tell (bp->pos);
bp->curpos = 0;
}
void ms_biff_put_commit (BIFF_PUT *bp)
{
......
......@@ -85,6 +85,7 @@ typedef struct _BIFF_PUT
guint32 length; /* NB. can be extended by a continue opcode */
guint8 *data;
ms_ole_pos_t streamPos;
ms_ole_pos_t curpos; /* Curpos is offset from beggining of header */
guint16 num_merges;
gint16 padding;
int data_malloced;
......@@ -104,6 +105,8 @@ extern guint8 *ms_biff_put_len_next (BIFF_PUT *, guint16 opcode, guint3
/* For unknown length records */
extern void ms_biff_put_var_next (BIFF_PUT *, guint16 opcode);
extern void ms_biff_put_var_write (BIFF_PUT *, guint8 *, guint32 len);
/* Seeks to pos bytes after the beggining of the record */
extern void ms_biff_put_var_seekto (BIFF_PUT *, ms_ole_pos_t pos);
/* Must commit after each record */
extern void ms_biff_put_commit (BIFF_PUT *);
......
......@@ -196,17 +196,6 @@ biff_get_text (BYTE *pos, guint32 length, guint32* byte_length)
return ans;
}
static char *
biff_get_global_string(MS_EXCEL_SHEET *sheet, int number)
{
MS_EXCEL_WORKBOOK *wb = sheet->wb;
if (number >= wb->global_string_max)
return "Too Weird";
return wb->global_strings[number] ;
}
const char *
biff_get_error_text (const guint8 err)
{
......@@ -1329,6 +1318,7 @@ ms_excel_read_formula (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
printf ("FIXME: serious formula error: "
"supposed length 0x%x, real len 0x%x\n",
BIFF_GETWORD (q->data+20), q->length);
cell_set_text (cell, "Formula error");
return;
}
......@@ -2008,7 +1998,7 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
}
case BIFF_FORMULA: /* See: S59D8F.HTM */
ms_excel_read_formula (q, sheet) ;
break;
break;
case BIFF_LABELSST:
{
......
......@@ -30,42 +30,16 @@
#include "ms-biff.h"
#include "excel.h"
#include "ms-excel-write.h"
#include "ms-formula-write.h"
#define EXCEL_DEBUG 1
typedef struct _XF XF;
typedef struct _FONTS FONTS;
typedef struct _SHEET SHEET;
typedef struct _FORMATS FORMATS;
typedef struct _PALETTE PALETTE;
typedef struct _WORKBOOK WORKBOOK;
struct _SHEET {
WORKBOOK *wb;
Sheet *gnum_sheet;
GArray *dbcells;
ms_ole_pos_t streamPos;
guint32 boundsheetPos;
guint32 maxx;
guint32 maxy;
};
struct _WORKBOOK {
Workbook *gnum_wb;
GPtrArray *sheets;
eBiff_version ver;
PALETTE *pal;
FONTS *fonts;
FORMATS *formats;
ms_ole_pos_t streamPos;
};
/**
* This function writes simple strings...
* FIXME: see S59D47.HTM for full description
* it returns the length of the string.
**/
static int
int
biff_put_text (BIFF_PUT *bp, char *txt, eBiff_version ver, gboolean write_len)
{
#define BLK_LEN 16
......@@ -274,7 +248,7 @@ write_constants (BIFF_PUT *bp, eBiff_version ver)
}
static void
write_externsheets (BIFF_PUT *bp, WORKBOOK *wb, SHEET *ignore)
write_externsheets (BIFF_PUT *bp, ExcelWorkbook *wb, ExcelSheet *ignore)
{
guint32 num_sheets = wb->sheets->len;
guint8 *data;
......@@ -298,7 +272,7 @@ write_externsheets (BIFF_PUT *bp, WORKBOOK *wb, SHEET *ignore)
ms_biff_put_commit (bp);
for (lp=0;lp<num_sheets;lp++) {
SHEET *sheet = g_ptr_array_index (wb->sheets, lp);
ExcelSheet *sheet = g_ptr_array_index (wb->sheets, lp);
gint len = strlen (sheet->gnum_sheet->name);
guint8 data[8];
......@@ -450,17 +424,13 @@ biff_boundsheet_write_last (MS_OLE_STREAM *s, guint32 pos,
s->lseek (s, oldpos, MS_OLE_SEEK_SET);
}
struct _PALETTE {
GHashTable *col_to_idx;
};
#define PALETTE_WHITE 0
#define PALETTE_BLACK 1
static PALETTE *
write_palette (BIFF_PUT *bp, WORKBOOK *wb)
static Palette *
write_palette (BIFF_PUT *bp, ExcelWorkbook *wb)
{
PALETTE *pal = g_new (PALETTE, 1);
Palette *pal = g_new (Palette, 1);
guint8 r,g,b, data[8];
guint32 num, i;
pal->col_to_idx = g_hash_table_new (g_direct_hash,
......@@ -487,13 +457,13 @@ write_palette (BIFF_PUT *bp, WORKBOOK *wb)
/* To be used ... */
static guint32
palette_lookup (PALETTE *pal, StyleColor *col)
palette_lookup (Palette *pal, StyleColor *col)
{
return PALETTE_WHITE;
}
static void
palette_free (PALETTE *pal)
palette_free (Palette *pal)
{
if (pal) {
/* Leak need to free indexes too */
......@@ -504,15 +474,11 @@ palette_free (PALETTE *pal)
#define FONT_MAGIC 0
struct _FONTS {
GHashTable *StyleFont_to_idx;
};
/* See S59D8C.HTM */
static FONTS *
write_fonts (BIFF_PUT *bp, WORKBOOK *wb)
static Fonts *
write_fonts (BIFF_PUT *bp, ExcelWorkbook *wb)
{
FONTS *fonts = g_new (FONTS, 1);
Fonts *fonts = g_new (Fonts, 1);
guint8 data[64];
int lp;
......@@ -547,13 +513,13 @@ write_fonts (BIFF_PUT *bp, WORKBOOK *wb)
}
static guint32
fonts_get_index (FONTS *fonts, StyleFont *sf)
fonts_get_index (Fonts *fonts, StyleFont *sf)
{
return FONT_MAGIC;
}
static void
fonts_free (FONTS *fonts)
fonts_free (Fonts *fonts)
{
if (fonts) {
g_free (fonts->StyleFont_to_idx);
......@@ -563,15 +529,11 @@ fonts_free (FONTS *fonts)
#define FORMAT_MAGIC 0
struct _FORMATS {
GHashTable *StyleFormat_to_idx;
};
/* See S59D8E.HTM */
static FORMATS *
write_formats (BIFF_PUT *bp, WORKBOOK *wb)
static Formats *
write_formats (BIFF_PUT *bp, ExcelWorkbook *wb)
{
FORMATS *formats = g_new (FORMATS, 1);
Formats *formats = g_new (Formats, 1);
int magic_num[] = { 5, 6, 7, 8, 0x2a, 0x29, 0x2c, 0x2b };
char *magic[] = {
"\"\xa3\"#,##0;\\-\"\xa3\"#,##0",
......@@ -616,13 +578,13 @@ write_formats (BIFF_PUT *bp, WORKBOOK *wb)
}
static guint32
formats_get_index (FORMATS *formats, StyleFormat *sf)
formats_get_index (Formats *formats, StyleFormat *sf)
{
return FORMAT_MAGIC;
}
static void
formats_free (FORMATS *formats)
formats_free (Formats *formats)
{
if (formats) {
g_free (formats->StyleFormat_to_idx);
......@@ -687,12 +649,8 @@ write_xf_record (BIFF_PUT *bp, Style *style, eBiff_version ver, int hack)
ms_biff_put_commit (bp);
}
struct _XF {
GHashTable *Style_to_idx;
};
static XF *
write_xf (BIFF_PUT *bp, WORKBOOK *wb)
write_xf (BIFF_PUT *bp, ExcelWorkbook *wb)
{
int lp;
guint32 style_magic[6] = { 0xff038010, 0xff068011, 0xff048012, 0xff078013,
......@@ -824,26 +782,53 @@ write_value (BIFF_PUT *bp, Value *v, eBiff_version ver,
}
static void
write_cell (BIFF_PUT *bp, SHEET *sheet, Cell *cell)
write_cell (BIFF_PUT *bp, ExcelSheet *sheet, Cell *cell)
{
gint col, row;
g_return_if_fail (bp);
g_return_if_fail (cell);
col = cell->col->pos;
row = cell->row->pos;
if (cell->parsed_node)
#if EXCEL_DEBUG > 1
printf ("FIXME: Skipping function\n");
#else
;
#endif
else if (cell->value)
if (cell->parsed_node) {
guint8 data[22];
guint8 lendat[2];
guint32 len;
ms_biff_put_var_next (bp, BIFF_FORMULA);
EX_SETROW(data, row);
EX_SETCOL(data, col);
EX_SETXF (data, XF_MAGIC);
if (cell->value && VALUE_IS_NUMBER(cell->value))
BIFF_SETDOUBLE(data+6, value_get_as_float (cell->value));
else {
BIFF_SET_GUINT32 (data + 6, 0xffff);
BIFF_SET_GUINT32 (data + 10, 0xffff);
}
BIFF_SET_GUINT16 (data + 14, 0x3); /* Always calc & on load */
BIFF_SET_GUINT32 (data + 16, 0x0);
BIFF_SET_GUINT16 (data + 20, 0x0);
ms_biff_put_var_write (bp, data, 22);
ms_excel_write_formula (bp, sheet, cell->parsed_node,
col, row);
len = bp->length;
g_assert (len <= 0xffff);
ms_biff_put_var_seekto (bp, 20);
BIFF_SET_GUINT16 (lendat, len);
ms_biff_put_var_write (bp, lendat, 2);
ms_biff_put_commit (bp);
} else if (cell->value)
write_value (bp, cell->value, sheet->wb->ver,
cell->col->pos, cell->row->pos, XF_MAGIC);
col, row, XF_MAGIC);
}
#define MAGIC_BLANK_XF 0
static void
write_mulblank (BIFF_PUT *bp, SHEET *sheet, guint32 end_col, guint32 row, guint32 run)
write_mulblank (BIFF_PUT *bp, ExcelSheet *sheet, guint32 end_col, guint32 row, guint32 run)
{
g_return_if_fail (bp);
g_return_if_fail (run);
......@@ -876,7 +861,7 @@ write_mulblank (BIFF_PUT *bp, SHEET *sheet, guint32 end_col, guint32 row, guint3
}
static void
write_sheet_bools (BIFF_PUT *bp, SHEET *sheet)
write_sheet_bools (BIFF_PUT *bp, ExcelSheet *sheet)
{
guint8 *data;
/* eBiff_version ver = sheet->wb->ver; */
......@@ -1018,7 +1003,7 @@ write_sheet_bools (BIFF_PUT *bp, SHEET *sheet)
}
static void
write_sheet_tail (BIFF_PUT *bp, SHEET *sheet)
write_sheet_tail (BIFF_PUT *bp, ExcelSheet *sheet)
{
guint8 *data;
eBiff_version ver = sheet->wb->ver;
......@@ -1055,7 +1040,7 @@ write_sheet_tail (BIFF_PUT *bp, SHEET *sheet)
}
static void
write_index (MS_OLE_STREAM *s, SHEET *sheet, ms_ole_pos_t pos)
write_index (MS_OLE_STREAM *s, ExcelSheet *sheet, ms_ole_pos_t pos)
{
guint8 data[4];
ms_ole_pos_t oldpos;
......@@ -1106,7 +1091,7 @@ write_rowinfo (BIFF_PUT *bp, guint32 row, guint32 width)
}
static void
write_db_cell (BIFF_PUT *bp, SHEET *sheet, ms_ole_pos_t start)
write_db_cell (BIFF_PUT *bp, ExcelSheet *sheet, ms_ole_pos_t start)
{
/* See: 'Finding records in BIFF files': S59E28.HTM */
/* See: 'DBCELL': S59D6D.HTM */
......@@ -1127,7 +1112,7 @@ write_db_cell (BIFF_PUT *bp, SHEET *sheet, ms_ole_pos_t start)
/* See: 'Finding records in BIFF files': S59E28.HTM */
/* and S59D99.HTM */
static void
write_sheet (BIFF_PUT *bp, SHEET *sheet)
write_sheet (BIFF_PUT *bp, ExcelSheet *sheet)
{
guint32 x, y, maxx, maxy;
ms_ole_pos_t index_off;
......@@ -1192,9 +1177,9 @@ write_sheet (BIFF_PUT *bp, SHEET *sheet)
}
static void
new_sheet (WORKBOOK *wb, Sheet *value)
new_sheet (ExcelWorkbook *wb, Sheet *value)
{
SHEET *sheet = g_new (SHEET, 1);
ExcelSheet *sheet = g_new (ExcelSheet, 1);
g_return_if_fail (value);
g_return_if_fail (wb);
......@@ -1213,8 +1198,8 @@ new_sheet (WORKBOOK *wb, Sheet *value)
static void
write_workbook (BIFF_PUT *bp, Workbook *gwb, eBiff_version ver)
{
WORKBOOK *wb = g_new (WORKBOOK, 1);
SHEET *s = 0;
ExcelWorkbook *wb = g_new (ExcelWorkbook, 1);
ExcelSheet *s = 0;
int lp;
GList *sheets;
......@@ -1257,7 +1242,7 @@ write_workbook (BIFF_PUT *bp, Workbook *gwb, eBiff_version ver)
/* Finalise Workbook stuff */
for (lp=0;lp<wb->sheets->len;lp++) {
SHEET *s = g_ptr_array_index (wb->sheets, lp);
ExcelSheet *s = g_ptr_array_index (wb->sheets, lp);
biff_boundsheet_write_last (bp->pos, s->boundsheetPos,
s->streamPos);
}
......@@ -1321,4 +1306,3 @@ ms_excel_write_workbook (MS_OLE *file, Workbook *wb,
ms_ole_directory_destroy (dir);
return 1;
}
......@@ -11,7 +11,52 @@
#include "ms-biff.h"
#include "ms-excel-biff.h"
extern int ms_excel_write_workbook (MS_OLE *file, Workbook *wb,
typedef struct _ExcelSheet ExcelSheet;
typedef struct _ExcelWorkbook ExcelWorkbook;
typedef struct _XF XF;
typedef struct _Fonts Fonts;
typedef struct _Formats Formats;
typedef struct _Palette Palette;
struct _Palette {
GHashTable *col_to_idx;
};
struct _Fonts {
GHashTable *StyleFont_to_idx;
};
struct _Formats {
GHashTable *StyleFormat_to_idx;
};
struct _XF {
GHashTable *Style_to_idx;
};
struct _ExcelSheet {
ExcelWorkbook *wb;
Sheet *gnum_sheet;
GArray *dbcells;
ms_ole_pos_t streamPos;
guint32 boundsheetPos;
guint32 maxx;
guint32 maxy;
};
struct _ExcelWorkbook {
Workbook *gnum_wb;
GPtrArray *sheets;
eBiff_version ver;
Palette *pal;
Fonts *fonts;
Formats *formats;
ms_ole_pos_t streamPos;
};
extern int ms_excel_write_ExcelWorkbook (MS_OLE *file, ExcelWorkbook *wb,
eBiff_version ver);
extern int
biff_put_text (BIFF_PUT *bp, char *txt, eBiff_version ver, gboolean write_len);
#endif
......@@ -18,53 +18,40 @@
#include "excel.h"
#include "ms-biff.h"
#include "ms-formula-read.h"
#include "formula-types.h"
#define FORMULA_DEBUG 0
#define NO_PRECEDENCE 256
typedef struct _FORMULA_FUNC_DATA
{
char *prefix ;
int num_args ; /* -1 for multi-arg */
/* -2 for unknown args */
} FORMULA_FUNC_DATA ;
/**
* Various bits of data for operators
* see S59E2B.HTM for formula_ptg values
* formula PTG, prefix, middle, suffix, precedence
**/
typedef struct _FORMULA_OP_DATA
{
Operation op;
} FORMULA_OP_DATA ;
/* Binary operator tokens */
FORMULA_OP_DATA formula_op_data[] = {
{ OPER_ADD }, /* ptgAdd : Addition */
{ OPER_SUB }, /* ptgSub : Subtraction */
{ OPER_MULT }, /* ptgMul : Multiplication */
{ OPER_DIV }, /* ptgDiv : Division */
{ OPER_EXP }, /* ptgPower : Exponentiation */
{ OPER_CONCAT }, /* ptgConcat : Concatenation */
{ OPER_LT }, /* ptgLT : Less Than */
{ OPER_LTE }, /* ptgLTE : Less Than or Equal */
{ OPER_EQUAL }, /* ptgEQ : Equal */
{ OPER_GTE }, /* ptgGTE : Greater Than or Equal */
{ OPER_GT }, /* ptgGT : Greater Than */
{ OPER_NOT_EQUAL }, /* ptgNE : Not Equal */
Operation formula_op_data[] = {
OPER_ADD, /* ptgAdd : Addition */
OPER_SUB, /* ptgSub : Subtraction */
OPER_MULT, /* ptgMul : Multiplication */
OPER_DIV, /* ptgDiv : Division */
OPER_EXP, /* ptgPower : Exponentiation */
OPER_CONCAT, /* ptgConcat : Concatenation */
OPER_LT, /* ptgLT : Less Than */
OPER_LTE, /* ptgLTE : Less Than or Equal */
OPER_EQUAL, /* ptgEQ : Equal */
OPER_GTE, /* ptgGTE : Greater Than or Equal */
OPER_GT, /* ptgGT : Greater Than */
OPER_NOT_EQUAL, /* ptgNE : Not Equal */
/* FIXME: These need implementing ... */
{ OPER_ADD }, /* ptgIsect : Intersection */
{ OPER_ADD }, /* ptgUnion : Union */
{ OPER_ADD }, /* ptgRange : Range */
OPER_ADD, /* ptgIsect : Intersection */
OPER_ADD, /* ptgUnion : Union */
OPER_ADD, /* ptgRange : Range */
} ;
#define FORMULA_OP_DATA_LEN (sizeof(formula_op_data)/sizeof(FORMULA_OP_DATA))
#define FORMULA_OP_DATA_LEN 15
#define FORMULA_OP_START 0x03
/**
* Populate from xlcall.h
* Populated from xlcall.h
* Functions in order, zero based, with number of arguments or
* '-1' for vararg or with optional arguments.
* '-2' for unknown numbers or arguments.
......@@ -73,7 +60,7 @@ FORMULA_OP_DATA formula_op_data[] = {
* macrofun.hlp has info on them but supporting Excel4 macro sheets is not
* top priority.
**/
FORMULA_FUNC_DATA formula_func_data[] =
FormulaFuncData formula_func_data[FORMULA_FUNC_DATA_LEN] =
{
/* 0 */ { "COUNT", -1 },
/* 1 */ { "IF", -1 },
......@@ -445,8 +432,6 @@ FORMULA_FUNC_DATA formula_func_data[] =
/* 367 */ { "VARA", -1 }
};
#define FORMULA_FUNC_DATA_LEN (sizeof(formula_func_data)/sizeof(FORMULA_FUNC_DATA))
/**
* Helper functions.
**/
......@@ -473,7 +458,6 @@ expr_tree_string (const char *str)
static CellRef *
getRefV7(MS_EXCEL_SHEET *sheet, BYTE col, WORD gbitrw, int curcol, int currow, int shrfmla)
{
gint8 row_offset= 0, col_offset= 0;
CellRef *cr = (CellRef *)g_malloc(sizeof(CellRef)) ;
cr->col = col ;
cr->row = (gbitrw & 0x3fff) ;
......@@ -676,7 +660,7 @@ make_function (PARSE_LIST **stack, int fn_idx, int numargs)
return 1 ;
}
} else if (fn_idx >= 0 && fn_idx < FORMULA_FUNC_DATA_LEN) {
const FORMULA_FUNC_DATA *fd = &formula_func_data[fn_idx] ;
const FormulaFuncData *fd = &formula_func_data[fn_idx] ;
GList *args;
#if FORMULA_DEBUG > 0
......@@ -979,7 +963,7 @@ ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
} else
parse_list_push_raw (&stack, g_strdup(txt), NO_PRECEDENCE) ;
}*/
case FORMULA_PTG_EXP:
case FORMULA_PTG_EXPR:
{
int top_left_col = BIFF_GETWORD(cur+2) ;
int top_left_row = BIFF_GETWORD(cur+0) ;
......@@ -1147,12 +1131,11 @@ ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
{
/* printf ("Search %d records\n", (int)FORMULA_OP_DATA_LEN) ; */
if (ptgbase >= FORMULA_OP_START && ptgbase < FORMULA_OP_START+FORMULA_OP_DATA_LEN) {
FORMULA_OP_DATA *fd =
&formula_op_data[ptgbase - FORMULA_OP_START];
Operation op = formula_op_data[ptgbase - FORMULA_OP_START];
ExprTree *l, *r;
r = parse_list_pop (&stack);
l = parse_list_pop (&stack);
parse_list_push (&stack, expr_tree_new_binary (l, fd->op, r));
parse_list_push (&stack, expr_tree_new_binary (l, op, r));
} else {
#if FORMULA_DEBUG > 0
printf ("Unknown PTG 0x%x base %x\n", ptg, ptgbase);
......
......@@ -11,7 +11,6 @@
#include "ms-excel-read.h"
#include "ms-biff.h"
#include "formula-types.h"
ExprTree *
ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
......
/*
* ms-formula-write.c: MS Excel <- Gnumeric formula conversion
*
* Author:
* Michael Meeks (michael@imaginator.com)
*/
#include <fcntl.h>
#include <assert.h>
#include <config.h>
#include <stdio.h>
#include <gnome.h>
#include "gnumeric.h"
#include "func.h"
#include "utils.h"