Commit f6ab8598 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

only read the amount of data in the imrecord. not all continues add


2002-07-18  Jody Goldberg <jody@gnome.org>

	* ms-excel-read.c (ms_excel_read_imdata) : only read the amount of
	  data in the imrecord.  not all continues add infinitum.  Fixes
	  guia.xls.

	* ms-obj.c (ms_read_TXO) : don't expect continue records if there is
	  no text.  Fixes guia2.xls.

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

	* ms-excel-read.c (ms_excel_read_sheet) : reorder 0x1xx entries to be
	  in increasing order and support hlinks.
	(ms_excel_read_hlink) : new.
parent 50631d1d
2002-07-18 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (ms_excel_read_imdata) : only read the amount of
data in the imrecord. not all continues add infinitum. Fixes
guia.xls.
* ms-obj.c (ms_read_TXO) : don't expect continue records if there is
no text. Fixes guia2.xls.
2002-07-16 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (ms_excel_read_sheet) : reorder 0x1xx entries to be
in increasing order and support hlinks.
(ms_excel_read_hlink) : new.
2002-07-14 Jody Goldberg <jody@gnome.org>
* ms-obj.c (ms_obj_read_pre_biff8_obj) : move the
......
......@@ -44,7 +44,7 @@ GNUMERIC_MODULE_PLUGIN_INFO_DECL;
/* Enables debugging mesgs while reading excel workbooks */
gint ms_excel_read_debug = 0;
/* Enables debugging mesgs while reading parsing escher streams */
gint ms_excel_escher_debug = 10;
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 */
......
......@@ -164,7 +164,7 @@ ms_escher_get_data (MSEscherState * state,
q->opcode != BIFF_MS_O_DRAWING_GROUP &&
q->opcode != BIFF_MS_O_DRAWING_SELECTION &&
q->opcode != BIFF_CONTINUE) {
g_warning ("Unexpected record type 0x%x len=0x%x;", q->opcode, q->length);
g_warning ("Unexpected record type 0x%x len=0x%x @ 0x%x;", q->opcode, q->length, q->streamPos);
return NULL;
}
......@@ -209,7 +209,7 @@ ms_escher_get_data (MSEscherState * state,
q->opcode != BIFF_MS_O_DRAWING_GROUP &&
q->opcode != BIFF_MS_O_DRAWING_SELECTION &&
q->opcode != BIFF_CONTINUE) {
g_warning ("Unexpected record type 0x%x;", q->opcode);
g_warning ("Unexpected record type 0x%x @ 0x%x;", q->opcode, q->streamPos);
return NULL;
}
......
......@@ -2978,12 +2978,12 @@ void
ms_excel_read_imdata (BiffQuery *q)
{
guint16 op;
guint32 image_len = GSF_LE_GET_GUINT32 (q->data + 4);
d (1,{
char const *from_name;
char const *format_name;
guint16 const format = GSF_LE_GET_GUINT16 (q->data);
guint16 const from_env = GSF_LE_GET_GUINT16 (q->data + 2);
guint16 const format = GSF_LE_GET_GUINT16 (q->data + 2);
switch (from_env) {
case 1: from_name = "Windows"; break;
......@@ -3004,8 +3004,14 @@ ms_excel_read_imdata (BiffQuery *q)
from_name, format_name);
});
while (ms_biff_query_peek_next (q, &op) && op == BIFF_CONTINUE)
image_len += 8;
while (image_len > q->length &&
ms_biff_query_peek_next (q, &op) && op == BIFF_CONTINUE) {
image_len -= q->length;
ms_biff_query_next (q);
}
g_return_if_fail (image_len == q->length);
}
/* S59DE2.HTM */
......@@ -3758,6 +3764,91 @@ ms_excel_read_dval (BiffQuery *q, ExcelSheet *esheet)
}
}
static void
ms_excel_read_hlink (BiffQuery *q, ExcelSheet *esheet)
{
static guint8 const stdlink_guid[] = {
0xd0, 0xc9, 0xea, 0x79, 0xf9, 0xba, 0xce, 0x11,
0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b,
/* unknown */
0x02, 0x00, 0x00, 0x00
};
static guint8 const url_guid[] = {
0xe0, 0xc9, 0xea, 0x79, 0xf9, 0xba, 0xce, 0x11,
0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b,
};
static guint8 const file_guid[] = {
0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
};
Range r;
guint32 options, len, i;
guint8 const *data = q->data;
guint8 *txt;
g_return_if_fail (q->length > 32);
r.start.row = GSF_LE_GET_GUINT16 (data + 0);
r.end.row = GSF_LE_GET_GUINT16 (data + 2);
r.start.col = GSF_LE_GET_GUINT16 (data + 4);
r.end.col = GSF_LE_GET_GUINT16 (data + 6);
options = GSF_LE_GET_GUINT32 (data + 28);
g_return_if_fail (!memcmp (data + 8, stdlink_guid, sizeof (stdlink_guid)));
data += 32;
/* description */
if (options & 0x14) {
gunichar2 *uni_text;
len = GSF_LE_GET_GUINT32 (data);
data += 4;
g_return_if_fail (data+len-q->data <= (int)q->length);
/* be wary about endianness */
uni_text = g_new (gunichar2, len);
for (i = 0 ; i < len ; i++)
uni_text [i] = GSF_LE_GET_GUINT16 (data + i*2);
txt = g_utf16_to_utf8 (uni_text, len, NULL, NULL, NULL);
printf ("desc %d = '%s'\n", len, txt);
g_free (uni_text);
data += len*2;
}
/* target frame */
if (options & 0x8) {
gunichar2 *uni_text;
len = GSF_LE_GET_GUINT32 (data);
data += 4;
g_return_if_fail (data+len-q->data <= (int)q->length);
/* be wary about endianness */
uni_text = g_new (gunichar2, len);
for (i = 0 ; i < len ; i++)
uni_text [i] = GSF_LE_GET_GUINT16 (data + i*2);
txt = g_utf16_to_utf8 (uni_text, -1, NULL, NULL, NULL);
printf ("frame %d = '%s'\n", len, txt);
g_free (uni_text);
data += len*2;
}
/* file with UNC */
if ((options & 0x1e3) == 0x003 && !memcmp (data, url_guid, sizeof (url_guid))) {
range_dump (&r, " <-- url\n");
} else if ((options & 0x1e1) == 0x001 && !memcmp (data, file_guid, sizeof (file_guid))) {
range_dump (&r, " <-- local file\n");
} else if ((options & 0x1e3) == 0x103) {
range_dump (&r, " <-- unc file\n");
} else if ((options & 0x1eb) == 0x008) {
range_dump (&r, " <-- current workbook\n");
} else {
g_warning ("Unknown hlink type");
}
}
static void
ms_excel_read_bg_pic (BiffQuery *q, ExcelSheet *esheet)
{
......@@ -3858,24 +3949,25 @@ ms_excel_read_sheet (BiffQuery *q, ExcelWorkbook *wb,
continue;
} else if (q->ms_op == 0x01) {
switch (q->opcode) {
case BIFF_CODENAME:
case BIFF_CONDFMT:
ms_excel_read_condfmt (q, esheet);
break;
case BIFF_CF:
g_warning ("Found a CF record without a CONDFMT ??");
ms_excel_read_cf (q, esheet);
break;
case BIFF_CONDFMT:
ms_excel_read_condfmt (q, esheet);
case BIFF_DVAL:
ms_excel_read_dval (q, esheet);
break;
case BIFF_HLINK:
ms_excel_read_hlink (q, esheet);
break;
case BIFF_CODENAME:
break;
case BIFF_DV:
g_warning ("Found a DV record without a DVal ??");
ms_excel_read_dv (q, esheet);
break;
case BIFF_DVAL:
ms_excel_read_dval (q, esheet);
break;
default:
ms_excel_unexpected_biff (q, "Sheet", ms_excel_read_debug);
};
......
......@@ -272,13 +272,17 @@ ms_read_TXO (BiffQuery *q)
/* guint16 const num_formats = GSF_LE_GET_GUINT16 (q->data + 12);*/
int const halign = (options >> 1) & 0x7;
int const valign = (options >> 4) & 0x7;
char *text = g_new (char, text_len + 1);
char *text;
guint16 peek_op;
if (text_len == 0)
return NULL;
g_return_val_if_fail (orient <= 3, NULL);
g_return_val_if_fail (1 <= halign && halign <= 4, NULL);
g_return_val_if_fail (1 <= valign && valign <= 4, NULL);
text = g_new (char, text_len + 1);
text [0] = '\0';
if (ms_biff_query_peek_next (q, &peek_op) &&
peek_op == BIFF_CONTINUE) {
......@@ -305,7 +309,7 @@ ms_read_TXO (BiffQuery *q)
peek_op == BIFF_CONTINUE)
ms_biff_query_next (q);
else
g_warning ("Unusual, TXO text with no formatting");
g_warning ("Unusual, TXO text with no formatting has 0x%x @ 0x%x", peek_op, q->streamPos);
} else if (text_len > 0)
g_warning ("TXO len of %d but no continue", text_len);
......
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