Commit 47d649da authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

handle macros. (write_funcall) : ditto.

2003-11-25  Jody Goldberg <jody@gnome.org>

	* ms-formula-write.c (excel_write_prep_expr) : handle macros.
	(write_funcall) : ditto.

	* ms-formula-read.c : add specs for the text_B_ functions
	(excel_parse_formula) : improve debug info.
	  Fix unicode strings.

	* ms-excel-write.c (write_workbook) : unsigned does not go < 0
	(cb_enumerate_macros) : new.
	(cb_write_macro_NAME) : new.
	(excel_write_names) : new.

	* ms-excel-read.c (get_xtn_lens) : add a limiter on the rich text
	  warning.
	(excel_formula_shared) : add some debug.
	(excel_read_NAME) : register macro functions.
	(excel_read_ROW) : disable debug spew.
	(excel_read_CF) : ditto.
	(excel_read_DIMENSIONS) : ditto.
	(excel_read_GUTS) : ditto.
	(excel_read_HLINK) : target frame is first (according to
	  xls-export-crash.xls) and the docs.
	(excel_read_SUPBOOK) : handle external workbooks with unicode names.

	* ms-escher.c (ms_escher_parse) : return the property bag.

2003-11-20  Jody Goldberg <jody@gnome.org>

	* ms-chart.c (BC_R(radar)) : Add a note.

2003-11-20  Jody Goldberg <jody@gnome.org>

	* ms-formula-read.c (make_function) : Take a Workbook to allow for
	for book local function lookup.

2003-11-20  Jody Goldberg <jody@gnome.org>

	* ms-excel-write.c (excel_sheet_new) : Include row/col info in the
	  extent calculation.

	* ms-excel-write.c (excel_write_GUTS) : max col/row outline levels are
	  one based.


2003-11-24  Jody Goldberg <jody@gnome.org>

	* src/sheet.c (sheet_colrow_group_ungroup) : when adding a group
	  calculate the global max gutter, not just the max in the changed
	  region.

2003-11-23  Jody Goldberg <jody@gnome.org>

	* src/item-cursor.c (item_cursor_draw) : Use not xor.

2003-11-20  Jody Goldberg <jody@gnome.org>

	* src/colrow.c (colrow_is_empty) : new.

2003-11-19  Andreas J. Guelzow  <aguelzow@taliesin.ca>

	* src/print-info.c (print_info_new): don't read n_copies from
	  gnome_config
	(print_info_save): don't bother writing n_copies to gnome_config
	(print_info_set_n_copies): new
	* src/print-info.h: remove n_copies field from PrintInformation
	(print_info_set_n_copies): new
parent 2d33199c
......@@ -9,8 +9,10 @@ Release Critical
----------------
http://bugzilla.gnome.org/show_bug.cgi?id=127203 [x axis child pos]
: X axis label seperation
: warnings in billmrec.xls
: box colors and warnings in christ95.xls
: text in boxes for text-xls/pivot.xls is white ??
: X axis label seperation
: guia.xls complains of problems importing autofilter
Worries
......
2003-11-24 Jody Goldberg <jody@gnome.org>
* src/sheet.c (sheet_colrow_group_ungroup) : when adding a group
calculate the global max gutter, not just the max in the changed
region.
2003-11-23 Jody Goldberg <jody@gnome.org>
* src/item-cursor.c (item_cursor_draw) : Use not xor.
2003-11-20 Jody Goldberg <jody@gnome.org>
* src/colrow.c (colrow_is_empty) : new.
......
......@@ -112,6 +112,9 @@ Jody:
http://bugzilla.gnome.org/show_bug.cgi?id=64297
* Cosmetic tweak to keep cursor visible on dark backgrounds
* Fixed xls export of col/row groups
* Support workbook local functions
* Fix xls import of unicode in expressions
* Fix gutter resize when adding groups
Morten:
* Fix crash with STF import and gazillions of columns.
......
2003-11-24 Jody Goldberg <jody@gnome.org>
* src/sheet.c (sheet_colrow_group_ungroup) : when adding a group
calculate the global max gutter, not just the max in the changed
region.
2003-11-23 Jody Goldberg <jody@gnome.org>
* src/item-cursor.c (item_cursor_draw) : Use not xor.
2003-11-20 Jody Goldberg <jody@gnome.org>
* src/colrow.c (colrow_is_empty) : new.
......
2003-11-24 Jody Goldberg <jody@gnome.org>
* src/sheet.c (sheet_colrow_group_ungroup) : when adding a group
calculate the global max gutter, not just the max in the changed
region.
2003-11-23 Jody Goldberg <jody@gnome.org>
* src/item-cursor.c (item_cursor_draw) : Use not xor.
2003-11-20 Jody Goldberg <jody@gnome.org>
* src/colrow.c (colrow_is_empty) : new.
......
2003-11-25 Jody Goldberg <jody@gnome.org>
* ms-formula-write.c (excel_write_prep_expr) : handle macros.
(write_funcall) : ditto.
* ms-formula-read.c : add specs for the text_B_ functions
(excel_parse_formula) : improve debug info.
Fix unicode strings.
* ms-excel-write.c (write_workbook) : unsigned does not go < 0
(cb_enumerate_macros) : new.
(cb_write_macro_NAME) : new.
(excel_write_names) : new.
* ms-excel-read.c (get_xtn_lens) : add a limiter on the rich text
warning.
(excel_formula_shared) : add some debug.
(excel_read_NAME) : register macro functions.
(excel_read_ROW) : disable debug spew.
(excel_read_CF) : ditto.
(excel_read_DIMENSIONS) : ditto.
(excel_read_GUTS) : ditto.
(excel_read_HLINK) : target frame is first (according to
xls-export-crash.xls) and the docs.
(excel_read_SUPBOOK) : handle external workbooks with unicode names.
* ms-escher.c (ms_escher_parse) : return the property bag.
2003-11-20 Jody Goldberg <jody@gnome.org>
* ms-chart.c (BC_R(radar)) : Add a note.
2003-11-20 Jody Goldberg <jody@gnome.org>
* ms-formula-read.c (make_function) : Take a Workbook to allow for
for book local function lookup.
2003-11-20 Jody Goldberg <jody@gnome.org>
* ms-excel-write.c (excel_sheet_new) : Include row/col info in the
......
......@@ -54,7 +54,7 @@ gint ms_excel_escher_debug = 0;
/* Enables debugging mesgs while reading excel functions */
gint ms_excel_formula_debug = 0;
/* Enables debugging mesgs while reading excel charts */
gint ms_excel_chart_debug = 10;
gint ms_excel_chart_debug = 0;
/* Enables debugging mesgs while writing excel workbooks */
gint ms_excel_write_debug = 0;
/* Enables debugging mesgs while reading excel objects */
......
......@@ -94,6 +94,13 @@ typedef struct {
char type;
char const *known_args;
} ExcelFuncDesc;
typedef struct {
ExcelFuncDesc const *efunc;
char *macro_name;
int idx;
} ExcelFunc;
extern ExcelFuncDesc const excel_func_desc[];
extern int excel_func_desc_size;
......
......@@ -37,7 +37,7 @@
/*******************************************************************************/
void
dump_biff (BiffQuery *q)
ms_biff_query_dump (BiffQuery *q)
{
g_print ("Opcode 0x%x length %d malloced? %d\nData:\n", q->opcode, q->length, q->data_malloced);
if (q->length > 0)
......@@ -269,7 +269,7 @@ ms_biff_query_new (GsfInput *input)
q->is_encrypted = FALSE;
#if BIFF_DEBUG > 0
dump_biff (q);
ms_biff_query_dump (q);
#endif
return q;
}
......@@ -371,7 +371,7 @@ ms_biff_query_next (BiffQuery *q)
#if BIFF_DEBUG > 2
printf ("Biff read code 0x%x, length %d\n", q->opcode, q->length);
dump_biff (q);
ms_biff_query_dump (q);
#endif
return TRUE;
}
......
......@@ -58,6 +58,8 @@ gboolean ms_biff_query_set_decrypt (BiffQuery *q, MsBiffVersion version,
int ms_biff_query_next (BiffQuery *);
gboolean ms_biff_query_peek_next (BiffQuery *, guint16 *opcode);
void ms_biff_query_destroy (BiffQuery *);
void ms_biff_query_dump (BiffQuery *);
/*******************************************************************************/
/* Write Side */
......@@ -102,6 +104,5 @@ void ms_biff_put_var_seekto (BiffPut *bp, int pos);
void ms_biff_put_commit (BiffPut *bp);
unsigned ms_biff_max_record_len (BiffPut const *bp);
void dump_biff (BiffQuery *bq);
#endif /* GNUMERIC_BIFF_H */
......@@ -688,7 +688,7 @@ BC_R(clrtclient)(XLChartHandler const *handle,
XLChartReadState *s, BiffQuery *q)
{
fputs ("Undocumented BIFF : clrtclient", stderr);
dump_biff (q);
ms_biff_query_dump (q);
return FALSE;
}
/****************************************************************************/
......@@ -835,15 +835,21 @@ BC_R(frame)(XLChartHandler const *handle,
/****************************************************************************/
static gboolean
BC_R(gelframe)(XLChartHandler const *handle,
XLChartReadState *s, BiffQuery *q)
BC_R(gelframe) (XLChartHandler const *handle,
XLChartReadState *s, BiffQuery *q)
{
gint tmp = ms_excel_escher_debug;
ms_excel_escher_debug = 2;
ms_escher_parse (q, &s->container);
ms_excel_escher_debug = tmp;
MSObjAttrBag *attrs = ms_escher_parse (q, &s->container);
#if 0
MSObjAttr *crop_bottom_attr = ms_obj_attr_bag_lookup
(obj->attrs, MS_OBJ_ATTR_BLIP_CROP_BOTTOM);
MS_OBJ_ATTR_FILL_TYPE;
#endif
ms_obj_attr_bag_destroy (attrs);
return FALSE;
}
/****************************************************************************/
static gboolean
......@@ -1218,6 +1224,9 @@ static gboolean
BC_R(radar)(XLChartHandler const *handle,
XLChartReadState *s, BiffQuery *q)
{
g_return_val_if_fail (s->plot == NULL, TRUE);
s->plot = gog_plot_new_by_name ("GogRadialPlot UNIMPLEMENTED");
return FALSE;
}
......@@ -1227,6 +1236,9 @@ static gboolean
BC_R(radararea)(XLChartHandler const *handle,
XLChartReadState *s, BiffQuery *q)
{
g_return_val_if_fail (s->plot == NULL, TRUE);
s->plot = gog_plot_new_by_name ("GogFilledRadialPlot UNIMPLEMENTED");
return FALSE;
}
......@@ -1731,22 +1743,19 @@ BC_R(end)(XLChartHandler const *handle,
char const *type = G_OBJECT_TYPE_NAME (s->plot);
GogStyle const *style = s->default_plot_style;
if (type != NULL && 0 == strcmp (type, "GogXYPlot")) {
if (style->marker.mark != NULL)
g_object_set (G_OBJECT (s->plot),
"default-style-has-markers",
style->marker.mark->shape != GO_MARKER_NONE,
NULL);
if (type != NULL && style->marker.mark != NULL &&
(!strcmp (type, "GogXYPlot") ||
!strcmp (type, "GogLinePlot") ||
!strcmp (type, "GogRadialPlot")))
g_object_set (G_OBJECT (s->plot),
"default-style-has-markers",
style->marker.mark->shape != GO_MARKER_NONE,
NULL);
if (type != NULL && 0 == strcmp (type, "GogXYPlot"))
g_object_set (G_OBJECT (s->plot),
"default-style-has-lines", style->line.width >= 0,
NULL);
} else if (type != NULL && 0 == strcmp (type, "GogLinePlot")) {
if (style->marker.mark != NULL)
g_object_set (G_OBJECT (s->plot),
"default-style-has-markers",
style->marker.mark->shape != GO_MARKER_NONE,
NULL);
}
g_object_unref (s->default_plot_style);
s->default_plot_style = NULL;
}
......@@ -2016,7 +2025,7 @@ ms_excel_read_chart (BiffQuery *q, MSContainer *container, MsBiffVersion ver,
!chart_biff_handler [lsb] ||
chart_biff_handler [lsb]->opcode != q->opcode) {
d (0, { fprintf (stderr, "Unknown BIFF_CHART record\n");
dump_biff (q);});
ms_biff_query_dump (q);});
} else {
XLChartHandler const *const h =
chart_biff_handler [lsb];
......@@ -2069,7 +2078,7 @@ ms_excel_read_chart (BiffQuery *q, MSContainer *container, MsBiffVersion ver,
}
case BIFF_MS_O_DRAWING:
ms_escher_parse (q, &state.container);
ms_obj_attr_bag_destroy (ms_escher_parse (q, &state.container));
break;
case BIFF_EXTERNCOUNT: /* ignore */ break;
......
......@@ -1956,14 +1956,15 @@ ms_escher_read_container (MSEscherState *state, MSEscherHeader *container,
* This function parses an escher stream, and stores relevant data in the
* workbook.
*/
void
MSObjAttrBag *
ms_escher_parse (BiffQuery *q, MSContainer *container)
{
MSEscherState state;
MSEscherHeader fake_header;
MSObjAttrBag *attrs;
char const *drawing_record_name = "Unknown";
g_return_if_fail (q != NULL);
g_return_val_if_fail (q != NULL, NULL);
if (q->opcode == BIFF_MS_O_DRAWING)
drawing_record_name = "Drawing";
......@@ -1975,7 +1976,7 @@ ms_escher_parse (BiffQuery *q, MSContainer *container)
drawing_record_name = "Chart GelFrame";
else {
g_warning ("EXCEL : unexpected biff type %x;", q->opcode);
return;
return NULL;
}
state.container = container;
......@@ -1991,7 +1992,12 @@ ms_escher_parse (BiffQuery *q, MSContainer *container)
d (0, printf ("{ /* Escher '%s'*/\n", drawing_record_name););
ms_escher_read_container (&state, &fake_header, -COMMON_HEADER_LEN);
d (0, printf ("}; /* Escher '%s'*/\n", drawing_record_name););
attrs = fake_header.attrs;
fake_header.release_attrs = FALSE;
ms_escher_header_release (&fake_header);
return attrs;
}
/****************************************************************************/
......
......@@ -12,17 +12,17 @@
**/
#include "ms-excel-read.h"
#include "ms-container.h"
#include "ms-obj.h"
struct _MSEscherBlip
{
struct _MSEscherBlip {
char const *type;
guint8 *data;
guint32 data_len;
gboolean needs_free;
};
void ms_escher_parse (BiffQuery *q, MSContainer *container);
void ms_escher_blip_free (MSEscherBlip *blip);
MSObjAttrBag *ms_escher_parse (BiffQuery *q, MSContainer *container);
void ms_escher_blip_free (MSEscherBlip *blip);
#if 0
typedef struct _MSEscherWriter MSEscherWriter;
......
......@@ -631,10 +631,10 @@ excel_sheet_new (ExcelWorkbook *ewb, char const *sheet_name)
esheet->sheet = sheet;
esheet->freeze_panes = FALSE;
esheet->shared_formulae = g_hash_table_new_full (
(GHashFunc)&cellpos_hash, (GCompareFunc)&cellpos_cmp,
(GHashFunc)&cellpos_hash, (GCompareFunc)&cellpos_equal,
NULL, (GDestroyNotify) &excel_shared_formula_free);
esheet->tables = g_hash_table_new_full (
(GHashFunc)&cellpos_hash, (GCompareFunc)&cellpos_cmp,
(GHashFunc)&cellpos_hash, (GCompareFunc)&cellpos_equal,
NULL, (GDestroyNotify) &excel_data_table_free);
excel_init_margins (esheet);
......@@ -723,6 +723,7 @@ biff_string_get_flags (guint8 const *ptr,
static void
get_xtn_lens (guint32 *pre_len, guint32 *end_len, guint8 const *ptr, gboolean ext_str, gboolean rich_str)
{
static gboolean rich_warn = TRUE;
*end_len = 0;
*pre_len = 0;
......@@ -733,8 +734,11 @@ get_xtn_lens (guint32 *pre_len, guint32 *end_len, guint8 const *ptr, gboolean ex
(*pre_len) += 2;
ptr += 2;
fprintf (stderr,"rich string support unimplemented:"
"discarding %d runs\n", formatting_runs);
if (rich_warn) {
rich_warn = FALSE;
fprintf (stderr,"rich string support unimplemented:"
"discarding %d runs\n", formatting_runs);
}
}
if (ext_str) { /* NB this data always comes after the rich_str data */
guint32 len_ext_rst = GSF_LE_GET_GUINT32 (ptr); /* A byte length */
......@@ -2153,6 +2157,8 @@ excel_formula_shared (BiffQuery *q, ExcelReadSheet *esheet, GnmCell *cell)
ms_biff_query_next (q);
d (2, range_dump (&r, " <-- shared fmla in\n"););
is_array = (q->ls_op == BIFF_ARRAY);
r.start.row = GSF_LE_GET_GUINT16 (q->data + 0);
r.end.row = GSF_LE_GET_GUINT16 (q->data + 2);
......@@ -2987,9 +2993,7 @@ excel_read_NAME (BiffQuery *q, ExcelWorkbook *ewb, gboolean global)
if (name != NULL) {
Sheet *sheet = NULL;
d (1,
fprintf (stderr, "NAME : %s\n", name);
fprintf (stderr, "%hu\n", sheet_index););
d (1, fprintf (stderr, "NAME : %s, sheet_index = %hu", name, sheet_index););
if (sheet_index > 0) {
/* NOTE : the docs lie the index for biff7 is
* indeed a reference to the externsheet
......@@ -3002,7 +3006,7 @@ excel_read_NAME (BiffQuery *q, ExcelWorkbook *ewb, gboolean global)
sheet_index > 0)
sheet = g_ptr_array_index (ewb->boundsheet_sheet_by_index, sheet_index-1);
else
g_warning ("So much for that theory");
g_warning ("So much for that theory 2");
} else
sheet = excel_externsheet_v7 (&ewb->container, sheet_index);
}
......@@ -3024,6 +3028,10 @@ excel_read_NAME (BiffQuery *q, ExcelWorkbook *ewb, gboolean global)
if (nexpr->is_hidden && !strcmp (nexpr->name->str, "_FilterDatabase"))
excel_prepare_autofilter (ewb, nexpr);
/* g_warning ("flags = %hx, state = %s\n", flags, global ? "global" : "sheet"); */
if ((flags & 0xE) == 0xE) /* Function & VB-Proc & Proc */
gnm_func_add_placeholder (ewb->gnum_wb,
nexpr->name->str, "VBA", TRUE);
}
}
......@@ -3230,7 +3238,7 @@ excel_read_ROW (BiffQuery *q, ExcelReadSheet *esheet)
*/
gboolean const is_std_height = (height & 0x8000) != 0;
d (-1, {
d (1, {
fprintf (stderr,"Row %d height 0x%x, flags=0x%x;\n", row + 1, height,flags);
if (is_std_height)
puts ("Is Std Height");
......@@ -3509,11 +3517,11 @@ excel_read_GUTS (BiffQuery *q, ExcelReadSheet *esheet)
/* ignore the specification of how wide/tall the gutters are */
row_gut = GSF_LE_GET_GUINT16 (q->data + 4);
g_warning ("row_gut = %d", row_gut);
d (2, fprintf (stderr, "row_gut = %d", row_gut););
if (row_gut >= 1)
row_gut--;
col_gut = GSF_LE_GET_GUINT16 (q->data + 6);
g_warning ("col_gut = %d", row_gut);
d (2, fprintf (stderr, "col_gut = %d", col_gut););
if (col_gut >= 1)
col_gut--;
sheet_colrow_gutter (esheet->sheet, TRUE, col_gut);
......@@ -3709,7 +3717,7 @@ excel_read_DIMENSIONS (BiffQuery *q, ExcelWorkbook *ewb)
} else
excel_read_range (&r, q->data);
d (-1, fprintf (stderr,"Dimension = %s\n", range_name (&r)););
d (1, fprintf (stderr,"Dimension = %s\n", range_name (&r)););
}
static MSContainer *
......@@ -4017,10 +4025,10 @@ excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet)
pat_foregnd_col = swap;
}
fprintf (stderr,"fore = %d, back = %d, pattern = %d.\n",
d (1, fprintf (stderr,"fore = %d, back = %d, pattern = %d.\n",
pat_foregnd_col,
pat_backgnd_col,
fill_pattern_idx);
fill_pattern_idx););
offset += 4;
}
......@@ -4328,8 +4336,8 @@ excel_read_HLINK (BiffQuery *q, ExcelReadSheet *esheet)
data += len*2;
}
/* target */
if (options & 0x8) {
/* target frame */
if (options & 0x80) {
len = GSF_LE_GET_GUINT32 (data);
data += 4;
g_return_if_fail (len*2 + data - q->data <= (int)q->length);
......@@ -4370,6 +4378,18 @@ excel_read_HLINK (BiffQuery *q, ExcelReadSheet *esheet)
} else {
g_warning ("Unknown hlink type");
}
#if 0
/* target mark */
if (options & 0x8) {
len = GSF_LE_GET_GUINT32 (data);
data += 4;
g_return_if_fail (len*2 + data - q->data <= (int)q->length);
target = read_utf16_str (len, data);
data += len*2;
}
#endif
if (ms_biff_query_peek_next (q, &next_opcode) &&
next_opcode == BIFF_LINK_TIP) {
ms_biff_query_next (q);
......@@ -5018,7 +5038,7 @@ excel_read_sheet (BiffQuery *q, ExcelWorkbook *ewb,
case BIFF_MS_O_DRAWING:
case BIFF_MS_O_DRAWING_GROUP:
case BIFF_MS_O_DRAWING_SELECTION:
ms_escher_parse (q, sheet_container (esheet));
ms_obj_attr_bag_destroy (ms_escher_parse (q, sheet_container (esheet)));
break;
case BIFF_PHONETIC: break;
......@@ -5059,7 +5079,14 @@ excel_read_sheet (BiffQuery *q, ExcelWorkbook *ewb,
return FALSE;
}
/* see S59DEC.HTM */
/**
* NOTE : MS Docs are incorrect
*
* unsigned short num_tabs;
* unsigned short num_characters_in_book;
* unsigned char flag_for_unicode; 0 or 1
* var encoded string stored as 1 or 2 byte characters
**/
static void
excel_read_SUPBOOK (BiffQuery *q, ExcelWorkbook *ewb)
{
......@@ -5067,51 +5094,62 @@ excel_read_SUPBOOK (BiffQuery *q, ExcelWorkbook *ewb)
unsigned len = GSF_LE_GET_GUINT16 (q->data + 2);
unsigned i;
guint32 byte_length;
gboolean is_2byte = FALSE;
char *name;
guint8 encodeType, *data;
ExcelSupBook tmp;
ExcelSupBook *new_supbook;
d (2, fprintf (stderr,"supbook %d has %d\n", ewb->v8.supbook->len, numTabs););
tmp.externname = g_ptr_array_new ();
tmp.wb = NULL;
i = ewb->v8.supbook->len;
g_array_set_size (ewb->v8.supbook, i+1);
new_supbook = &g_array_index (ewb->v8.supbook, ExcelSupBook, i);
new_supbook->externname = g_ptr_array_new ();
new_supbook->wb = NULL;
/* undocumented guess */
if (q->length == 4 && len == 0x0401) {
d (2, fprintf (stderr,"\t is self referential\n"););
tmp.type = EXCEL_SUP_BOOK_SELFREF;
g_array_append_val (ewb->v8.supbook, tmp);
new_supbook->type = EXCEL_SUP_BOOK_SELFREF;
return;
}
if (q->length == 4 && len == 0x3A01) {
d (2, fprintf (stderr,"\t is a plugin\n"););
tmp.type = EXCEL_SUP_BOOK_PLUGIN;
g_array_append_val (ewb->v8.supbook, tmp);
new_supbook->type = EXCEL_SUP_BOOK_PLUGIN;
return;
}
tmp.type = EXCEL_SUP_BOOK_STD;
g_array_append_val (ewb->v8.supbook, tmp);
encodeType = GSF_LE_GET_GUINT8 (q->data + 4);
d (1, {
fprintf (stderr,"Supporting workbook with %d Tabs\n", numTabs);
fprintf (stderr,"--> SUPBOOK VirtPath encoding = ");
switch (encodeType) {
case 0x00: /* chEmpty */
puts ("chEmpty");
break;
case 0x01: /* chEncode */
puts ("chEncode");
break;
case 0x02: /* chSelf */
puts ("chSelf");
break;
default:
fprintf (stderr,"Unknown/Unencoded? (%x) %d\n",
encodeType, len);
};
});
new_supbook->type = EXCEL_SUP_BOOK_STD;
switch (GSF_LE_GET_GUINT8 (q->data + 4)) {
case 0 : break; /* 1 byte locale compressed unicode for book name */
case 1 : len *= 2; is_2byte = TRUE; break; /* 2 byte unicode */
default :
g_warning ("Invalid header on SUPBOOK record");
gsf_mem_dump (q->data, q->length);
return;
};
g_return_if_fail (len < q->length);
#warning create a workbook and sheets when we have a facility for merging things
encodeType = GSF_LE_GET_GUINT8 (q->data + 5);
d (1, fprintf (stderr,"Supporting workbook with %d Tabs\n", numTabs););
switch (encodeType) {
case 0x00:
d (0, fprintf (stderr,"--> SUPBOOK VirtPath encoding = chEmpty"););
break;
case 0x01:
d (0, fprintf (stderr,"--> SUPBOOK VirtPath encoding = chEncode"););
break;
case 0x02: /* chSelf */
break;
default:
fprintf (stderr,"Unknown/Unencoded? (%x) %d\n",
encodeType, len);
};
d (1, {
gsf_mem_dump (q->data + 4 + 1, len);
for (data = q->data + 4 + 1 + len, i = 0; i < numTabs ; i++) {
len = GSF_LE_GET_GUINT16 (data);
......@@ -5119,7 +5157,7 @@ excel_read_SUPBOOK (BiffQuery *q, ExcelWorkbook *ewb)
fprintf (stderr,"\t-> %s\n", name);
g_free (name);
data += byte_length + 2;
}
}});
}
/*
......@@ -5249,9 +5287,8 @@ excel_read_BOF (BiffQuery *q,
else
fprintf (stderr,"XLM Macrosheet.\n");
while (ms_biff_query_next (q) &&
q->opcode != BIFF_EOF)
;
while (ms_biff_query_next (q) && q->opcode != BIFF_EOF)
d (5, ms_biff_query_dump (q););
if (q->opcode != BIFF_EOF)
g_warning ("EXCEL: file format error. Missing BIFF_EOF");
} else if (ver->type == MS_BIFF_TYPE_Workspace) {
......@@ -5484,7 +5521,7 @@ excel_read_workbook (IOContext *context, WorkbookView *wb_view,
case BIFF_MS_O_DRAWING:
case BIFF_MS_O_DRAWING_GROUP:
case BIFF_MS_O_DRAWING_SELECTION:
ms_escher_parse (q, &ewb->container);
ms_obj_attr_bag_destroy (ms_escher_parse (q, &ewb->container));
break;
case BIFF_ADDMENU:
......
......@@ -27,6 +27,7 @@
#include "ms-excel-xf.h"
#include "ms-escher.h"
#include "ms-obj.h"
#include "formula-types.h"
#include <format.h>
#include <position.h>
......@@ -363,7 +364,7 @@ excel_write_externsheets_v7 (ExcelWriteState *ewb)
ms_biff_put_var_next (ewb->bp, BIFF_EXTERNSHEET);
len = excel_write_string_len (
esheet->gnum_sheet->name_unquoted, NULL);
esheet->gnum_sheet->name_unquoted, NULL);
GSF_LE_SET_GUINT8 (data, len);
GSF_LE_SET_GUINT8 (data + 1, 3); /* undocumented */
......@@ -878,14 +879,6 @@ excel_write_builtin_name (char const *ptr, MsBiffVersion version)
return -1;
}
static void
cb_enumerate_names (gpointer key, GnmNamedExpr *nexpr, ExcelWriteState *ewb)
{
ewb->tmp_counter++; /* pre increment to avoid 0 */
g_hash_table_insert (ewb->names, (gpointer)nexpr,
GUINT_TO_POINTER (ewb->tmp_counter));
}
static void
excel_write_NAME (G_GNUC_UNUSED gpointer key,
GnmNamedExpr *nexpr, ExcelWriteState *ewb)
......@@ -4018,13 +4011,71 @@ excel_foreach_name (ExcelWriteState *ewb, GHFunc func)
}
}
static void
cb_enumerate_names (gpointer key, GnmNamedExpr *nexpr, ExcelWriteState *ewb)
{
ewb->tmp_counter++; /* pre increment to avoid 0 */
g_hash_table_insert (ewb->names, (gpointer)nexpr,
GUINT_TO_POINTER (ewb->tmp_counter));
}
static void
cb_enumerate_macros (gpointer key, ExcelFunc *efunc, ExcelWriteState *ewb)
{
if (efunc->macro_name != NULL)
efunc->idx = ++ewb->tmp_counter;
}
static void
cb_write_macro_NAME (gpointer key, ExcelFunc *efunc, ExcelWriteState *ewb)
{
if (efunc->macro_name != NULL) {
guint8 data[14] = {
0xE, 0x0, /* flag vba macro */
0x0, /* key */
0x0, /* namelen <FILLIN> */
0x0, 0x0, /* no expr */
0x0, 0x0, /* not sheet local */
0x0, 0x0, /* not sheet local */
0x0, /* menu */
0x0, /* description */
0x0, /* help */
0x0 /* status */
};
unsigned len = excel_write_string_len (efunc->macro_name, NULL);
if (len > 255)
len = 255;
ms_biff_put_var_next (ewb->bp, BIFF_NAME);
GSF_LE_SET_GUINT8 (data+3, len);
ms_biff_put_var_write (ewb->bp, data, sizeof (data));
excel_write_string (ewb->bp, efunc->macro_name, STR_NO_LENGTH);
ms_biff_put_commit (ewb->bp);
g_free (efunc->macro_name); /* INVALIDATE THE NAME */
}
}
static void
excel_write_names (ExcelWriteState *ewb)
{
excel_foreach_name (ewb, (GHFunc)&cb_enumerate_names);
g_hash_table_foreach (ewb->function_map,
(GHFunc)cb_enumerate_macros, ewb);
excel_foreach_name (ewb, (GHFunc)&excel_write_NAME);