Commit 90113e73 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Use CellPos directly.

2001-06-15  Jody Goldberg <jgoldberg@home.com>

	* ms-excel-read.c (ms_excel_sheet_new) : Use CellPos directly.

	* ms-formula-read.c (ms_excel_parse_formula) : some cleanup.

2001-06-14  Jody Goldberg <jgoldberg@home.com>

	* src/sheet-control-gui.c (scg_colrow_select) : don't
	  discard input when selecting a range.

	* src/xml-io.c (xml_write_range) : Add some safety.
parent 4a3bcd3a
2001-06-14 Jody Goldberg <jgoldberg@home.com>
* src/sheet-control-gui.c (scg_colrow_select) : don't
discard input when selecting a range.
* src/xml-io.c (xml_write_range) : Add some safety.
2001-06-13 Jody Goldberg <jgoldberg@home.com>
* src/format.c (render_number) : improve rounding and cleanup.
......
2001-06-14 Jody Goldberg <jgoldberg@home.com>
* src/sheet-control-gui.c (scg_colrow_select) : don't
discard input when selecting a range.
* src/xml-io.c (xml_write_range) : Add some safety.
2001-06-13 Jody Goldberg <jgoldberg@home.com>
* src/format.c (render_number) : improve rounding and cleanup.
......
2001-06-14 Jody Goldberg <jgoldberg@home.com>
* src/sheet-control-gui.c (scg_colrow_select) : don't
discard input when selecting a range.
* src/xml-io.c (xml_write_range) : Add some safety.
2001-06-13 Jody Goldberg <jgoldberg@home.com>
* src/format.c (render_number) : improve rounding and cleanup.
......
2001-06-14 Jody Goldberg <jgoldberg@home.com>
* src/sheet-control-gui.c (scg_colrow_select) : don't
discard input when selecting a range.
* src/xml-io.c (xml_write_range) : Add some safety.
2001-06-13 Jody Goldberg <jgoldberg@home.com>
* src/format.c (render_number) : improve rounding and cleanup.
......
2001-06-14 Jody Goldberg <jgoldberg@home.com>
* src/sheet-control-gui.c (scg_colrow_select) : don't
discard input when selecting a range.
* src/xml-io.c (xml_write_range) : Add some safety.
2001-06-13 Jody Goldberg <jgoldberg@home.com>
* src/format.c (render_number) : improve rounding and cleanup.
......
2001-06-15 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_sheet_new) : Use CellPos directly.
* ms-formula-read.c (ms_excel_parse_formula) : some cleanup.
2001-06-11 Jody Goldberg <jgoldberg@home.com>
* ms-excel-write.c (write_setup) : new routine.
......
......@@ -10,49 +10,63 @@
* See S59E2B.HTM for the spec.
**/
#define FORMULA_PTG_MAX 0x7f
#define FORMULA_PTG_MAX 0x7f
#define FORMULA_PTG_EXPR 0x01
#define FORMULA_PTG_EXPR 0x01
#define FORMULA_PTG_TBL 0x02
#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_INTERSECT 0x0f
#define FORMULA_PTG_UNION 0x10
#define FORMULA_PTG_RANGE 0x11
#define FORMULA_PTG_U_PLUS 0x12
#define FORMULA_PTG_U_MINUS 0x13
#define FORMULA_PTG_PERCENT 0x14
#define FORMULA_PTG_PAREN 0x15
#define FORMULA_PTG_MISSARG 0x16
#define FORMULA_PTG_STR 0x17
#define FORMULA_PTG_EXTENDED 0x18
#define FORMULA_PTG_ATTR 0x19
#define FORMULA_PTG_SHEET 0x1A /* deprecated */
#define FORMULA_PTG_SHEET_END 0x1B /* deprecated */
#define FORMULA_PTG_ERR 0x1C
#define FORMULA_PTG_BOOL 0x1D
#define FORMULA_PTG_INT 0x1E
#define FORMULA_PTG_NUM 0x1F /* 8 byte IEEE floating point number */
#define FORMULA_PTG_ARRAY 0x20
#define FORMULA_PTG_FUNC 0x21
#define FORMULA_PTG_FUNC_VAR 0x22
#define FORMULA_PTG_NAME 0x23
#define FORMULA_PTG_REF 0x24
#define FORMULA_PTG_AREA 0x25
#define FORMULA_PTG_MEM_AREA 0x26
#define FORMULA_PTG_MEM_ERR 0x27
#define FORMULA_PTG_MEM_NO_MEM 0x28
#define FORMULA_PTG_MEM_FUNC 0x29
#define FORMULA_PTG_REF_ERR 0x2A
#define FORMULA_PTG_AREA_ERR 0x2B
#define FORMULA_PTG_REFN 0x2C
#define FORMULA_PTG_AREAN 0x2D
#define FORMULA_PTG_MEM_AREAN 0x2E
#define FORMULA_PTG_NO_MEMN 0x2F
/* nothing documented */
#define FORMULA_PTG_NAME_X 0x39
#define FORMULA_PTG_REF_3D 0x3A
#define FORMULA_PTG_AREA_3D 0x3B
#define FORMULA_PTG_REF_ERR_3D 0x3C
#define FORMULA_PTG_AREA_ERR_3D 0x3D
#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_PERCENT 0x14
#define FORMULA_PTG_PAREN 0x15
#define FORMULA_PTG_MISSARG 0x16
#define FORMULA_PTG_STR 0x17
#define FORMULA_PTG_EXTENDED 0x18
#define FORMULA_PTG_ATTR 0x19
#define FORMULA_PTG_ERR 0x1c
#define FORMULA_PTG_BOOL 0x1d
#define FORMULA_PTG_INT 0x1e
#define FORMULA_PTG_NUM 0x1f /* 8 byte IEEE floating point number */
#define FORMULA_PTG_ARRAY 0x20
#define FORMULA_PTG_FUNC 0x21
#define FORMULA_PTG_FUNC_VAR 0x22
#define FORMULA_PTG_NAME 0x23
#define FORMULA_PTG_REF 0x24
#define FORMULA_PTG_AREA 0x25
#define FORMULA_PTG_MEM_AREA 0x26
#define FORMULA_PTG_REFN 0x2c
#define FORMULA_PTG_AREAN 0x2d
#define FORMULA_PTG_MEM_AREAN 0x2e
#define FORMULA_PTG_NO_MEMN 0x2f
#define FORMULA_PTG_NAME_X 0x39
#define FORMULA_PTG_REF_3D 0x3a
#define FORMULA_PTG_AREA_3D 0x3b
#define FORMULA_PTG_FUNC_CEV 0x58
/*
* Classes of Formulae Values
......@@ -61,6 +75,6 @@
* operators
* simple values (integer, string ... ) [ string ? ]
*/
#define FORMULA_CLASS_REF 0x00
#define FORMULA_CLASS_VALUE 0x20
#define FORMULA_CLASS_ARRAY 0x40
#define FORMULA_CLASS_REF 0x00
#define FORMULA_CLASS_VALUE 0x20
#define FORMULA_CLASS_ARRAY 0x40
......@@ -811,7 +811,7 @@ biff_name_data_new (ExcelWorkbook *wb, char const *name,
}
ExprTree *
biff_name_data_get_name (ExcelSheet *sheet, int idx)
biff_name_data_get_name (ExcelSheet const *sheet, int idx)
{
BiffNameData *bnd;
GPtrArray *a;
......@@ -829,7 +829,7 @@ biff_name_data_get_name (ExcelSheet *sheet, int idx)
}
if (bnd->type == BNDStore && bnd->v.store.data) {
ExprTree *tree = ms_excel_parse_formula (sheet->wb, sheet,
ExprTree *tree = ms_excel_parse_formula (sheet,
bnd->v.store.data,
0, 0, FALSE,
bnd->v.store.len,
......@@ -1776,20 +1776,6 @@ ms_excel_sheet_insert (ExcelSheet *sheet, int xfidx,
}
}
/* Shared formula support functions */
static guint
biff_shared_formula_hash (const BiffSharedFormulaKey *d)
{
return (d->row<<16)+d->col;
}
static guint
biff_shared_formula_equal (const BiffSharedFormulaKey *a,
const BiffSharedFormulaKey *b)
{
return (a->col == b->col && a->row == b->row);
}
static gboolean
biff_shared_formula_destroy (gpointer key, BiffSharedFormula *sf,
gpointer userdata)
......@@ -1817,7 +1803,7 @@ ms_excel_formula_shared (BiffQuery *q, ExcelSheet *sheet, Cell *cell)
q->data + (is_array ? 14 : 10);
const guint16 data_len =
MS_OLE_GET_GUINT16 (q->data + (is_array ? 12 : 8));
ExprTree *expr = ms_excel_parse_formula (sheet->wb, sheet, data,
ExprTree *expr = ms_excel_parse_formula (sheet, data,
array_col_first,
array_row_first,
!is_array, data_len,
......@@ -1830,8 +1816,7 @@ ms_excel_formula_shared (BiffQuery *q, ExcelSheet *sheet, Cell *cell)
* flag the formula as shared until later.
* Use the location of the cell we are reading as the key.
*/
sf->key.col = cell->pos.col; /* array_col_first; */
sf->key.row = cell->pos.row; /* array_row_first; */
sf->key = cell->pos;
sf->is_array = is_array;
if (data_len > 0) {
sf->data = g_new (guint8, data_len);
......@@ -1974,7 +1959,7 @@ ms_excel_read_formula (BiffQuery *q, ExcelSheet *sheet)
};
}
expr = ms_excel_parse_formula (sheet->wb, sheet, (q->data + 22),
expr = ms_excel_parse_formula (sheet, (q->data + 22),
col, row,
FALSE, MS_OLE_GET_GUINT16 (q->data+20),
&array_elem);
......@@ -2066,17 +2051,14 @@ ms_excel_read_formula (BiffQuery *q, ExcelSheet *sheet)
}
BiffSharedFormula *
ms_excel_sheet_shared_formula (ExcelSheet *sheet, int const col, int const row)
ms_excel_sheet_shared_formula (ExcelSheet const *sheet,
CellPos const *key)
{
BiffSharedFormulaKey k;
k.col = col;
k.row = row;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 5)
printf ("FIND SHARED : %s%d\n", col_name (col), row+1);
printf ("FIND SHARED : %s\n", cell_pos_name (key));
#endif
return g_hash_table_lookup (sheet->shared_formulae, &k);
return g_hash_table_lookup (sheet->shared_formulae, key);
}
/**
......@@ -2256,7 +2238,7 @@ ms_sheet_parse_expr_internal (ExcelSheet *e_sheet, guint8 const *data, int lengt
sheet = e_sheet->gnum_sheet;
wb = (sheet == NULL) ? e_sheet->wb->gnum_wb : NULL;
expr = ms_excel_parse_formula (e_sheet->wb, e_sheet, data,
expr = ms_excel_parse_formula (e_sheet, data,
0, 0, FALSE, length, NULL);
tmp = expr_tree_as_string (expr, parse_pos_init (&pp, wb, sheet, 0, 0));
puts (tmp);
......@@ -2321,8 +2303,8 @@ ms_excel_sheet_new (ExcelWorkbook *wb, char const *sheet_name)
res->base_char_width = -1;
res->base_char_width_default = -1;
res->shared_formulae =
g_hash_table_new ((GHashFunc)biff_shared_formula_hash,
(GCompareFunc)biff_shared_formula_equal);
g_hash_table_new ((GHashFunc)&cellpos_hash,
(GCompareFunc)&cellpos_cmp);
ms_excel_init_margins (res);
ms_container_init (&res->container, &vtbl, &wb->container);
......
......@@ -35,20 +35,15 @@ typedef struct _BiffBoundsheetData
} BiffBoundsheetData;
typedef struct {
guint16 col;
guint16 row;
} BiffSharedFormulaKey;
typedef struct {
BiffSharedFormulaKey key;
CellPos key;
guint8 *data;
guint32 data_len;
gboolean is_array;
} BiffSharedFormula;
/* Use the upper left corner as the key to a collection of shared formulas */
extern BiffSharedFormula *
ms_excel_sheet_shared_formula (ExcelSheet *sheet, int const col, int const row);
BiffSharedFormula *ms_excel_sheet_shared_formula (ExcelSheet const *sheet,
CellPos const *key);
typedef struct _ExcelPalette
{
......@@ -110,24 +105,24 @@ typedef struct _ExcelWorkbook
Workbook *gnum_wb;
} ExcelWorkbook;
extern ExcelSheet * ms_excel_workbook_get_sheet (ExcelWorkbook *wb, guint idx);
extern Sheet* biff_get_externsheet_name (ExcelWorkbook *wb, guint16 idx, gboolean get_first);
extern char* biff_get_text (guint8 const *ptr, guint32 length, guint32 *byte_length);
extern const char* biff_get_error_text (const guint8 err);
extern ExprTree* biff_name_data_get_name (ExcelSheet *sheet, int idx);
ExcelSheet * ms_excel_workbook_get_sheet (ExcelWorkbook *wb, guint idx);
Sheet* biff_get_externsheet_name (ExcelWorkbook *wb, guint16 idx, gboolean get_first);
char* biff_get_text (guint8 const *ptr, guint32 length, guint32 *byte_length);
char const* biff_get_error_text (guint8 err);
ExprTree* biff_name_data_get_name (ExcelSheet const *sheet, int idx);
extern MsBiffBofData * ms_biff_bof_data_new (BiffQuery * q);
extern void ms_biff_bof_data_destroy (MsBiffBofData * data);
MsBiffBofData * ms_biff_bof_data_new (BiffQuery * q);
void ms_biff_bof_data_destroy (MsBiffBofData * data);
extern StyleFormat *biff_format_data_lookup (ExcelWorkbook *wb, guint16 idx);
extern StyleColor *ms_excel_palette_get (ExcelPalette const *pal, gint idx);
StyleFormat *biff_format_data_lookup (ExcelWorkbook *wb, guint16 idx);
StyleColor *ms_excel_palette_get (ExcelPalette const *pal, gint idx);
extern void ms_excel_read_imdata (BiffQuery *q);
void ms_excel_read_imdata (BiffQuery *q);
/* A utility routine to handle unexpected BIFF records */
extern void ms_excel_unexpected_biff (BiffQuery *q,
char const *state,
int debug_level);
void ms_excel_unexpected_biff (BiffQuery *q,
char const *state,
int debug_level);
void ms_excel_read_cleanup (void);
......
This diff is collapsed.
......@@ -15,10 +15,10 @@
#include "ms-biff.h"
ExprTree *
ms_excel_parse_formula (ExcelWorkbook *wb, ExcelSheet *sheet,
ms_excel_parse_formula (ExcelSheet const *sheet,
guint8 const *mem,
int fn_col, int fn_row,
gboolean const shared, guint16 length,
gboolean *const array_element) ;
gboolean shared, guint16 length,
gboolean *array_element) ;
#endif
......@@ -440,7 +440,7 @@ scg_colrow_select (SheetControlGUI *scg, gboolean is_cols,
gboolean const rangesel = wbcg_rangesel_possible (scg->wbcg);
if (!rangesel)
wbcg_edit_finish (scg->wbcg, FALSE);
wbcg_edit_finish (scg->wbcg, TRUE);
if (rangesel && !scg->rangesel.active)
scg_rangesel_start (scg, index, index);
......
......@@ -511,12 +511,14 @@ xml_read_range (xmlNodePtr tree, Range *r)
}
static void
xml_write_range (xmlNodePtr tree, const Range *value)
xml_write_range (xmlNodePtr tree, Range const *r)
{
xml_set_value_int (tree, "startCol", value->start.col);
xml_set_value_int (tree, "startRow", value->start.row);
xml_set_value_int (tree, "endCol", value->end.col);
xml_set_value_int (tree, "endRow", value->end.row);
g_return_if_fail (range_is_sane (r));
xml_set_value_int (tree, "startCol", r->start.col);
xml_set_value_int (tree, "startRow", r->start.row);
xml_set_value_int (tree, "endCol", r->end.col);
xml_set_value_int (tree, "endRow", r->end.row);
}
static void
......
Markdown is supported
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