Commit 71bae3a1 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

new. (ms_object_attr_destroy) : handle expressions.

2002-01-17  Jody Goldberg <jody@gnome.org>

	* ms-obj.c (ms_object_attr_new_expr) : new.
	(ms_object_attr_destroy) : handle expressions.
	(ms_obj_read_biff8_obj) : use the expression parser for
	  GR_CHECKBOX_FORMULA.

	* ms-formula-read.c (getRefV7) : remove the pointless malloc/free.
	(getRefV8) : ditto.
	(make_inter_sheet_ref) : delete.
	(make_inter_sheet_ref_v7) : ditto.

	* ms-excel-read.c (ms_sheet_realize_obj) : add support for a
	  checkbox's link.  Needs to be done here, AFTER being assigned to a
	  sheet.
	(ms_excel_workboot_get_externsheets) : renamed from
	  biff_get_externsheet_name, and simplified.

2002-01-14  Jody Goldberg <jody@gnome.org>

	* ms-formula-read.c (ms_excel_parse_formula) : fix support for
	  importing local 3d references, external 3d is still not supported.

2002-01-17  Jody Goldberg <jody@gnome.org>

	* src/sheet-object-widget.c (sheet_widget_checkbox_get_ref) : handle
	  references without an explicit sheet.
	(sheet_widget_checkbox_set_link) : new.

2002-01-16  Jody Goldberg <jody@gnome.org>

	* src/item-cursor.c (item_cursor_draw) : fix some ancient Miggy
	  bugginess that was borking the gnome2 port.

2002-01-15  Jody Goldberg <jody@gnome.org>

	* src/workbook-control-gui.c (cb_tools_tabulate) : Pass the sheet in
	  directly.
parent 3aff8b30
2002-01-17 Jody Goldberg <jody@gnome.org>
* src/sheet-object-widget.c (sheet_widget_checkbox_get_ref) : handle
references without an explicit sheet.
(sheet_widget_checkbox_set_link) : new.
2002-01-16 Jody Goldberg <jody@gnome.org>
* src/item-cursor.c (item_cursor_draw) : fix some ancient Miggy
bugginess that was borking the gnome2 port.
2002-01-15 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_tools_tabulate) : Pass the sheet in
directly.
2002-01-16 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/datetime.c : change oem to eom
......
Gnumeric 1.0.3
Jody:
* More work on XL import for 3d references.
* Import checkbox links from XL.
Morten:
* New tabulation tool.
......
2002-01-17 Jody Goldberg <jody@gnome.org>
* src/sheet-object-widget.c (sheet_widget_checkbox_get_ref) : handle
references without an explicit sheet.
(sheet_widget_checkbox_set_link) : new.
2002-01-16 Jody Goldberg <jody@gnome.org>
* src/item-cursor.c (item_cursor_draw) : fix some ancient Miggy
bugginess that was borking the gnome2 port.
2002-01-15 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_tools_tabulate) : Pass the sheet in
directly.
2002-01-16 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/datetime.c : change oem to eom
......
2002-01-17 Jody Goldberg <jody@gnome.org>
* src/sheet-object-widget.c (sheet_widget_checkbox_get_ref) : handle
references without an explicit sheet.
(sheet_widget_checkbox_set_link) : new.
2002-01-16 Jody Goldberg <jody@gnome.org>
* src/item-cursor.c (item_cursor_draw) : fix some ancient Miggy
bugginess that was borking the gnome2 port.
2002-01-15 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_tools_tabulate) : Pass the sheet in
directly.
2002-01-16 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/datetime.c : change oem to eom
......
2002-01-17 Jody Goldberg <jody@gnome.org>
* src/sheet-object-widget.c (sheet_widget_checkbox_get_ref) : handle
references without an explicit sheet.
(sheet_widget_checkbox_set_link) : new.
2002-01-16 Jody Goldberg <jody@gnome.org>
* src/item-cursor.c (item_cursor_draw) : fix some ancient Miggy
bugginess that was borking the gnome2 port.
2002-01-15 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_tools_tabulate) : Pass the sheet in
directly.
2002-01-16 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/datetime.c : change oem to eom
......
2002-01-17 Jody Goldberg <jody@gnome.org>
* ms-obj.c (ms_object_attr_new_expr) : new.
(ms_object_attr_destroy) : handle expressions.
(ms_obj_read_biff8_obj) : use the expression parser for
GR_CHECKBOX_FORMULA.
* ms-formula-read.c (getRefV7) : remove the pointless malloc/free.
(getRefV8) : ditto.
(make_inter_sheet_ref) : delete.
(make_inter_sheet_ref_v7) : ditto.
* ms-excel-read.c (ms_sheet_realize_obj) : add support for a
checkbox's link. Needs to be done here, AFTER being assigned to a
sheet.
(ms_excel_workboot_get_externsheets) : renamed from
biff_get_externsheet_name, and simplified.
2002-01-14 Jody Goldberg <jody@gnome.org>
* ms-formula-read.c (ms_excel_parse_formula) : fix support for
importing local 3d references, external 3d is still not supported.
2002-01-15 Jody Goldberg <jody@gnome.org>
* Release 1.0.2
......
......@@ -2121,6 +2121,15 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
&anchor);
sheet_object_set_sheet (SHEET_OBJECT (obj->gnum_obj),
esheet->gnum_sheet);
/* can not be done until we have set the sheet */
if (obj->excel_type == 0x0B) {
MSObjAttr *link = ms_object_attr_bag_lookup (obj->attrs,
MS_OBJ_ATTR_CHECKBOX_LINK);
if (link != NULL)
sheet_widget_checkbox_set_link (SHEET_OBJECT (obj->gnum_obj),
link->v.v_expr);
}
}
return FALSE;
......@@ -4243,25 +4252,11 @@ ms_excel_read_sheet (BiffQuery *q, ExcelWorkbook *wb,
return FALSE;
}
Sheet *
biff_get_externsheet_name (ExcelWorkbook *wb, guint16 idx, gboolean get_first)
XLExternSheet const *
ms_excel_workboot_get_externsheets (ExcelWorkbook *wb, guint idx)
{
BiffExternSheetData *bed;
BiffBoundsheetData *bsd;
guint16 index;
if (idx>=wb->num_extern_sheets)
return NULL;
bed = &wb->extern_sheets[idx];
index = get_first ? bed->first_tab : bed->last_tab;
bsd = g_hash_table_lookup (wb->boundsheet_data_by_index, &index);
if (!bsd || !bsd->sheet) {
g_warning ("Duff sheet index %d\n", index);
return NULL;
}
return bsd->sheet->gnum_sheet;
g_return_val_if_fail (idx < wb->num_extern_sheets, NULL);
return &wb->extern_sheets [idx];
}
/*
......@@ -4374,12 +4369,12 @@ ms_excel_externsheet (BiffQuery const *q, ExcelWorkbook *wb, MsBiffBofData *ver)
ms_ole_dump (q->data, q->length);
#endif
wb->extern_sheets = g_new (BiffExternSheetData, numXTI + 1);
wb->extern_sheets = g_new (XLExternSheet, numXTI + 1);
for (cnt = 0; cnt < numXTI; cnt++) {
wb->extern_sheets[cnt].sup_idx = MS_OLE_GET_GUINT16 (q->data + 2 + cnt * 6 + 0);
wb->extern_sheets[cnt].first_tab = MS_OLE_GET_GUINT16 (q->data + 2 + cnt * 6 + 2);
wb->extern_sheets[cnt].last_tab = MS_OLE_GET_GUINT16 (q->data + 2 + cnt * 6 + 4);
wb->extern_sheets[cnt].sup_idx = MS_OLE_GET_GUINT16 (q->data + 2 + cnt * 6 + 0);
wb->extern_sheets[cnt].first_sheet = MS_OLE_GET_GUINT16 (q->data + 2 + cnt * 6 + 2);
wb->extern_sheets[cnt].last_sheet = MS_OLE_GET_GUINT16 (q->data + 2 + cnt * 6 + 4);
#if 0
printf ("SupBook: %d First sheet %d, Last sheet %d\n",
wb->extern_sheets[cnt].sup_idx,
......
......@@ -71,9 +71,9 @@ typedef struct _BiffFontData
typedef struct _BiffExternSheetData {
guint16 sup_idx;
guint16 first_tab;
guint16 last_tab;
} BiffExternSheetData;
guint16 first_sheet;
guint16 last_sheet;
} XLExternSheet;
typedef struct _BiffFormatData {
guint16 idx;
......@@ -92,7 +92,7 @@ typedef struct _ExcelWorkbook
GHashTable *format_data; /* leave as a hash */
GPtrArray *name_data;
int read_drawing_group;
BiffExternSheetData *extern_sheets;
XLExternSheet *extern_sheets;
guint16 num_extern_sheets;
ExcelPalette *palette;
char **global_strings;
......@@ -107,11 +107,11 @@ typedef struct _ExcelWorkbook
Workbook *gnum_wb;
} ExcelWorkbook;
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);
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);
ExcelSheet *ms_excel_workbook_get_sheet (ExcelWorkbook *wb, guint idx);
XLExternSheet const *ms_excel_workboot_get_externsheets (ExcelWorkbook *wb, guint idx);
MsBiffBofData * ms_biff_bof_data_new (BiffQuery * q);
void ms_biff_bof_data_destroy (MsBiffBofData * data);
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* ms-formula-read.c: MS Excel -> Gnumeric formula conversion
*
* Author:
* Michael Meeks (michael@ximian.com)
*
* (C) 1998-2001 Michael Meeks
* (C) 1998-2002 Michael Meeks
*/
#include <gnumeric-config.h>
#include <gnumeric.h>
......@@ -416,7 +417,7 @@ FormulaFuncData formula_func_data[FORMULA_FUNC_DATA_LEN] =
};
static ExprTree *
expr_tree_string (const char *str)
expr_tree_string (char const *str)
{
return expr_tree_new_constant (value_new_string (str));
}
......@@ -425,11 +426,11 @@ expr_tree_string (const char *str)
* A useful routine for extracting data from a common
* storage structure.
**/
static CellRef *
getRefV7 (guint8 col, guint16 gbitrw, int curcol, int currow,
static void
getRefV7 (CellRef *cr,
guint8 col, guint16 gbitrw, int curcol, int currow,
gboolean const shared)
{
CellRef *cr = g_new (CellRef, 1);
guint16 const row = (guint16)(gbitrw & 0x3fff);
#ifndef NO_DEBUG_EXCEL
......@@ -467,18 +468,17 @@ getRefV7 (guint8 col, guint16 gbitrw, int curcol, int currow,
cr->col = col - curcol;
} else
cr->col = col;
return cr;
}
/**
* A useful routine for extracting data from a common
* storage structure.
**/
static CellRef *
getRefV8 (guint16 row, guint16 gbitcl, int curcol, int currow,
static void
getRefV8 (CellRef *cr,
guint16 row, guint16 gbitcl, int curcol, int currow,
gboolean const shared)
{
CellRef *cr = g_new (CellRef, 1);
guint8 const col = (guint8)(gbitcl & 0xff);
#ifndef NO_DEBUG_EXCEL
......@@ -507,17 +507,15 @@ getRefV8 (guint16 row, guint16 gbitcl, int curcol, int currow,
cr->col = col - curcol;
} else
cr->col = col;
return cr;
}
static void
parse_list_push (ExprList **list, ExprTree *pd)
{
#ifndef NO_DEBUG_EXCEL
if (ms_excel_formula_debug > 5) {
printf ("Push 0x%x\n", (int)pd);
}
if (ms_excel_formula_debug > 5) {
printf ("Push 0x%x\n", (int)pd);
}
#endif
if (!pd)
printf ("FIXME: Pushing nothing onto excel function stack\n");
......@@ -570,46 +568,6 @@ parse_list_free (ExprList **list)
expr_tree_unref (parse_list_pop(list));
}
static void
make_inter_sheet_ref (ExcelWorkbook *wb, guint16 extn_idx, CellRef *a, CellRef *b)
{
g_return_if_fail (wb);
g_return_if_fail (a);
a->sheet = biff_get_externsheet_name (wb, extn_idx, 1);
if (b)
b->sheet = biff_get_externsheet_name (wb, extn_idx, 0);
}
static void
make_inter_sheet_ref_v7 (ExcelWorkbook *wb, guint16 extn_idx,
guint16 first, guint16 second, CellRef *a, CellRef *b)
{
ExcelSheet *sheet;
g_return_if_fail (wb);
g_return_if_fail (a);
if ((gint16)extn_idx > 0) {
printf ("FIXME: BIFF 7 ExternSheet 3D ref\n");
return;
}
g_return_if_fail (wb->excel_sheets);
g_return_if_fail (first<wb->excel_sheets->len);
sheet = g_ptr_array_index (wb->excel_sheets, first);
g_return_if_fail (sheet);
a->sheet = sheet->gnum_sheet;
if (b) {
g_return_if_fail (second < wb->excel_sheets->len);
sheet = g_ptr_array_index (wb->excel_sheets, second);
g_return_if_fail (sheet);
b->sheet = sheet->gnum_sheet;
}
}
static gboolean
make_function (ExprList **stack, int fn_idx, int numargs)
{
......@@ -1118,26 +1076,26 @@ ms_excel_parse_formula (ExcelSheet const *sheet, guint8 const *mem,
*/
if (eptg_type == 0x06 || /* eptgElfRwV, No, Value */
eptg_type == 0x07) { /* eptgElfColV, No, Value */
CellRef *ref = getRefV8 (MS_OLE_GET_GUINT16(cur + 1),
MS_OLE_GET_GUINT16(cur + 3),
fn_col, fn_row, shared);
if (ref) {
if (eptg_type == 0x07) { /* Column */
if (ref->row_relative)
ref->row = 0;
else
ref->row = fn_row;
} else { /* Row */
if (ref->col_relative)
ref->col = 0;
else
ref->col = fn_col;
}
parse_list_push (&stack, expr_tree_new_var (ref));
g_free (ref);
CellRef ref;
getRefV8 (&ref,
MS_OLE_GET_GUINT16(cur + 1),
MS_OLE_GET_GUINT16(cur + 3),
fn_col, fn_row, shared);
if (eptg_type == 0x07) { /* Column */
if (ref.row_relative)
ref.row = 0;
else
ref.row = fn_row;
} else { /* Row */
if (ref.col_relative)
ref.col = 0;
else
ref.col = fn_col;
}
parse_list_push (&stack, expr_tree_new_var (&ref));
} else {
printf ("-------------------\n");
printf ("XL : Extended ptg %x\n", eptg_type);
......@@ -1284,42 +1242,49 @@ ms_excel_parse_formula (ExcelSheet const *sheet, guint8 const *mem,
break;
case FORMULA_PTG_REF: case FORMULA_PTG_REFN: {
CellRef *ref=0;
CellRef ref;
if (ver >= MS_BIFF_V8) {
ref = getRefV8 (MS_OLE_GET_GUINT16(cur),
MS_OLE_GET_GUINT16(cur + 2),
fn_col, fn_row, shared);
getRefV8 (&ref,
MS_OLE_GET_GUINT16(cur),
MS_OLE_GET_GUINT16(cur + 2),
fn_col, fn_row, shared);
ptg_length = 4;
} else {
ref = getRefV7 (MS_OLE_GET_GUINT8(cur+2), MS_OLE_GET_GUINT16(cur),
fn_col, fn_row, shared);
getRefV7 (&ref,
MS_OLE_GET_GUINT8(cur+2),
MS_OLE_GET_GUINT16(cur),
fn_col, fn_row, shared);
ptg_length = 3;
}
parse_list_push (&stack, expr_tree_new_var (ref));
if (ref) g_free (ref);
parse_list_push (&stack, expr_tree_new_var (&ref));
break;
}
case FORMULA_PTG_AREA: case FORMULA_PTG_AREAN: {
CellRef *first=0, *last=0;
CellRef first, last;
if (ver >= MS_BIFF_V8) {
first = getRefV8 (MS_OLE_GET_GUINT16(cur+0),
MS_OLE_GET_GUINT16(cur+4),
fn_col, fn_row, shared);
last = getRefV8 (MS_OLE_GET_GUINT16(cur+2),
MS_OLE_GET_GUINT16(cur+6),
fn_col, fn_row, shared);
getRefV8 (&first,
MS_OLE_GET_GUINT16(cur+0),
MS_OLE_GET_GUINT16(cur+4),
fn_col, fn_row, shared);
getRefV8 (&last,
MS_OLE_GET_GUINT16(cur+2),
MS_OLE_GET_GUINT16(cur+6),
fn_col, fn_row, shared);
ptg_length = 8;
} else {
first = getRefV7(MS_OLE_GET_GUINT8(cur+4), MS_OLE_GET_GUINT16(cur+0), fn_col, fn_row, shared);
last = getRefV7(MS_OLE_GET_GUINT8(cur+5), MS_OLE_GET_GUINT16(cur+2), fn_col, fn_row, shared);
getRefV7 (&first,
MS_OLE_GET_GUINT8(cur+4),
MS_OLE_GET_GUINT16(cur+0),
fn_col, fn_row, shared);
getRefV7 (&last,
MS_OLE_GET_GUINT8(cur+5),
MS_OLE_GET_GUINT16(cur+2),
fn_col, fn_row, shared);
ptg_length = 6;
}
parse_list_push_raw (&stack, value_new_cellrange (first, last, fn_col, fn_row));
if (first) g_free (first);
if (last) g_free (last);
parse_list_push_raw (&stack, value_new_cellrange (&first, &last, fn_col, fn_row));
break;
}
......@@ -1345,64 +1310,109 @@ ms_excel_parse_formula (ExcelSheet const *sheet, guint8 const *mem,
break;
case FORMULA_PTG_REF_3D : { /* see S59E2B.HTM */
CellRef *ref=0;
CellRef first, last;
int last_index;
ExcelSheet *first_sheet;
ExcelWorkbook *wb = sheet->wb;
if (ver >= MS_BIFF_V8) {
guint16 extn_idx = MS_OLE_GET_GUINT16 (cur);
ref = getRefV8 (MS_OLE_GET_GUINT16 (cur + 2),
MS_OLE_GET_GUINT16 (cur + 4),
fn_col, fn_row, 0);
make_inter_sheet_ref (sheet->wb, extn_idx, ref, 0);
parse_list_push (&stack, expr_tree_new_var (ref));
XLExternSheet const *es = ms_excel_workboot_get_externsheets (sheet->wb,
MS_OLE_GET_GUINT16 (cur));
g_return_val_if_fail (es != NULL, NULL);
/* TODO : init wb from es record in case of
* external 3d references.
*/
first_sheet = ms_excel_workbook_get_sheet (wb, es->first_sheet);
last_index = es->last_sheet;
getRefV8 (&first,
MS_OLE_GET_GUINT16 (cur + 2),
MS_OLE_GET_GUINT16 (cur + 4),
fn_col, fn_row, 0);
ptg_length = 6;
} else {
guint16 extn_idx, first_idx, second_idx;
ref = getRefV7 (MS_OLE_GET_GUINT8 (cur + 16),
MS_OLE_GET_GUINT16 (cur + 14),
fn_col, fn_row, 0);
extn_idx = MS_OLE_GET_GUINT16 (cur);
first_idx = MS_OLE_GET_GUINT16 (cur + 10);
second_idx = MS_OLE_GET_GUINT16 (cur + 12);
make_inter_sheet_ref_v7 (sheet->wb, extn_idx, first_idx, second_idx, ref, 0);
parse_list_push (&stack, expr_tree_new_var (ref));
/* TODO : init wb from from the extn_idx in
* case of external 3d references.
*/
gint16 ixals = (gint16)MS_OLE_GET_GUINT16 (cur);
if (ixals > 0) {
g_warning ("EXCEL : external 3d references not supported.");
/* first_sheet will fall back to 0 */
}
first_sheet = ms_excel_workbook_get_sheet (sheet->wb,
MS_OLE_GET_GUINT16 (cur + 10));
last_index = MS_OLE_GET_GUINT16 (cur + 12);
getRefV7 (&first,
MS_OLE_GET_GUINT8 (cur + 16),
MS_OLE_GET_GUINT16 (cur + 14),
fn_col, fn_row, 0);
ptg_length = 17;
}
if (ref) g_free (ref);
last = first;
first.sheet = first_sheet->gnum_sheet;
first_sheet = ms_excel_workbook_get_sheet (first_sheet->wb, last_index);
last.sheet = first_sheet->gnum_sheet;
/* There does not appear to be a way to express a ref
* to another sheet without using a 3d ref. lets be smarter
*/
if (first.sheet != last.sheet)
parse_list_push_raw (&stack, value_new_cellrange (&first, &last, fn_col, fn_row));
else
parse_list_push (&stack, expr_tree_new_var (&first));
break;
}
case FORMULA_PTG_AREA_3D : { /* see S59E2B.HTM */
CellRef *first=0, *last=0;
/* See comments in FORMULA_PTG_REF_3D for correct handling of external references */
CellRef first, last;
int last_index;
ExcelSheet *first_sheet;
ExcelWorkbook *wb = sheet->wb;
if (ver >= MS_BIFF_V8) {
guint16 extn_idx = MS_OLE_GET_GUINT16(cur);
first = getRefV8 (MS_OLE_GET_GUINT16(cur+2),
MS_OLE_GET_GUINT16(cur+6),
fn_col, fn_row, 0);
last = getRefV8 (MS_OLE_GET_GUINT16(cur+4),
MS_OLE_GET_GUINT16(cur+8),
fn_col, fn_row, 0);
make_inter_sheet_ref (sheet->wb, extn_idx, first, last);
parse_list_push_raw (&stack, value_new_cellrange (first, last, fn_col, fn_row));
XLExternSheet const *es = ms_excel_workboot_get_externsheets (sheet->wb,
MS_OLE_GET_GUINT16 (cur));
g_return_val_if_fail (es != NULL, NULL);
first_sheet = ms_excel_workbook_get_sheet (wb, es->first_sheet);
last_index = es->last_sheet;
getRefV8 (&first,
MS_OLE_GET_GUINT16(cur+2),
MS_OLE_GET_GUINT16(cur+6),
fn_col, fn_row, 0);
getRefV8 (&last,
MS_OLE_GET_GUINT16(cur+4),
MS_OLE_GET_GUINT16(cur+8),
fn_col, fn_row, 0);
ptg_length = 10;
} else {
guint16 extn_idx, first_idx, second_idx;
first = getRefV7 (MS_OLE_GET_GUINT8(cur+18), MS_OLE_GET_GUINT16(cur+14),
fn_col, fn_row, 0);
last = getRefV7 (MS_OLE_GET_GUINT8(cur+19), MS_OLE_GET_GUINT16(cur+16),
fn_col, fn_row, 0);
extn_idx = MS_OLE_GET_GUINT16(cur);
first_idx = MS_OLE_GET_GUINT16(cur + 10);
second_idx = MS_OLE_GET_GUINT16(cur + 12);
make_inter_sheet_ref_v7 (sheet->wb, extn_idx, first_idx,
second_idx, first, last);
parse_list_push_raw (&stack, value_new_cellrange (first, last, fn_col, fn_row));
gint16 ixals = (gint16)MS_OLE_GET_GUINT16 (cur);
if (ixals > 0) {
g_warning ("EXCEL : external 3d references not supported.");
/* first_sheet will fall back to 0 */
}
first_sheet = ms_excel_workbook_get_sheet (sheet->wb,
MS_OLE_GET_GUINT16 (cur + 10));
last_index = MS_OLE_GET_GUINT16 (cur + 12);
getRefV7 (&first,
MS_OLE_GET_GUINT8(cur+18),
MS_OLE_GET_GUINT16(cur+14),
fn_col, fn_row, 0);
getRefV7 (&last,
MS_OLE_GET_GUINT8(cur+19),
MS_OLE_GET_GUINT16(cur+16),
fn_col, fn_row, 0);
ptg_length = 20;
}
if (first) g_free (first);
if (last) g_free (last);
first.sheet = first_sheet->gnum_sheet;
first_sheet = ms_excel_workbook_get_sheet (first_sheet->wb, last_index);
last.sheet = first_sheet->gnum_sheet;
parse_list_push_raw (&stack, value_new_cellrange (&first, &last, fn_col, fn_row));
break;
}
......
......@@ -25,6 +25,7 @@
#include <gnumeric-config.h>
#include <gnumeric.h>
#include <expr.h>
#include "boot.h"
#include "ms-obj.h"
......@@ -70,7 +71,7 @@ ms_object_attr_new_uint (MSObjAttrID id, guint32 val)
{
MSObjAttr *res = g_new (MSObjAttr, 1);
g_return_val_if_fail (!(id & MS_OBJ_ATTR_NEEDS_FREE_MASK), NULL);
g_return_val_if_fail ((id & MS_OBJ_ATTR_MASK) == MS_OBJ_ATTR_IS_INT_MASK, NULL);
/* be anal about constness */
*((MSObjAttrID *)&(res->id)) = id;
......@@ -82,7 +83,7 @@ ms_object_attr_new_ptr (MSObjAttrID id, gpointer val)
{
MSObjAttr *res = g_new (MSObjAttr, 1);
g_return_val_if_fail ((id & MS_OBJ_ATTR_NEEDS_FREE_MASK), NULL);
g_return_val_if_fail ((id & MS_OBJ_ATTR_MASK) == MS_OBJ_ATTR_NEEDS_FREE_MASK, NULL);
/* be anal about constness */
*((MSObjAttrID *)&(res->id)) = id;
......@@ -90,6 +91,19 @@ ms_object_attr_new_ptr (MSObjAttrID id, gpointer val)
return res;
}
MSObjAttr *
ms_object_attr_new_expr (MSObjAttrID id, ExprTree *expr)
{
MSObjAttr *res = g_new (MSObjAttr, 1);
g_return_val_if_fail ((id & MS_OBJ_ATTR_MASK) == MS_OBJ_ATTR_NEEDS_EXPR_UNREF, NULL);
/* be anal about constness */
*((MSObjAttrID *)&(res->id)) = id;
res->v.v_expr = expr;
return res;
}
void
ms_object_attr_destroy (MSObjAttr *attr)
{
......@@ -97,6 +111,9 @@ ms_object_attr_destroy (MSObjAttr *attr)
if ((attr->id & MS_OBJ_ATTR_NEEDS_FREE_MASK) &&
attr->v.v_ptr != NULL) {
g_free (attr->v.v_ptr);
} else if ((attr->id & MS_OBJ_ATTR_NEEDS_EXPR_UNREF) &&
attr->v.v_expr != NULL) {
expr_tree_unref (attr->v.v_expr);
}
g_free (attr);
}
......@@ -425,15 +442,13 @@ ms_obj_read_biff8_obj (BiffQuery *q, MSContainer *container, MSObj *obj)
break;
}
case GR_CHECKBOX_FORMULA :
{
guint16 const row = MS_OLE_GET_GUINT16(data+11);
guint16 const col = MS_OLE_GET_GUINT16(data+13) &0x3fff;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_object_debug > 0)
printf ("Checkbox linked to : %s%d\n", col_name(col), row+1);
case GR_CHECKBOX_FORMULA : {
guint16 const expr_len = MS_OLE_GET_GUINT16 (data+4);
ExprTree *ref = ms_container_parse_expr (container, data+10, expr_len);
if (ref != NULL)
ms_object_attr_bag_insert (obj->attrs,
ms_object_attr_new_expr (MS_OBJ_ATTR_CHECKBOX_LINK, ref));
ms_obj_dump (data, len, data_len_left, "CheckBoxFmla");
#endif
break;
}
......
......@@ -34,21 +34,29 @@ typedef enum {
/* Ptrs */
MS_OBJ_ATTR_NEEDS_FREE_MASK = 0x2000,
MS_OBJ_ATTR_ANCHOR
MS_OBJ_ATTR_ANCHOR,
/* Expressions */
MS_OBJ_ATTR_NEEDS_EXPR_UNREF = 0x4000,
MS_OBJ_ATTR_CHECKBOX_LINK,
MS_OBJ_ATTR_MASK = 0x7000
} MSObjAttrID;
typedef struct {
MSObjAttrID const id;
union {
gboolean v_boolean;
guint32 v_uint;
gpointer v_ptr;
gboolean v_boolean;
guint32 v_uint;
gpointer v_ptr;
ExprTree *v_expr;
} v;
} MSObjAttr;
MSObjAttr *ms_object_attr_new_flag (MSObjAttrID id);
MSObjAttr *ms_object_attr_new_uint (MSObjAttrID id, guint32 val);
MSObjAttr *ms_object_attr_new_ptr (MSObjAttrID id, gpointer val);
MSObjAttr *ms_object_attr_new_expr (MSObjAttrID id, ExprTree *expr);