Commit 4c9d6c53 authored by Jody Goldberg's avatar Jody Goldberg

- A PictOpt record in an OBJ record seems to indicate an IMDATA is the

  next BIFF record.  This fixes that last of the unknown errors importing
  the test files !!

- Improve debug messages.
parent a3457923
1999-10-08 Jody Goldberg <jgoldberg@home.com>
* ms-escher.c (ms_escher_get_data) : Use printf instead of
g_return_if_fail. It makes it easier to debug when the messages ar
in line.
* ms-obj.c (ms_read_OBJ) : Print the object type name whenever
possible.
(ms_obj_read_biff8_obj) : Looks like a PictOpt record in an object
signifies that the next BIFF record after the OBJ must be an IMDATA.
1999-10-08 Morten Welinder <terra@diku.dk>
* ms-formula-read.c (ms_excel_parse_formula): Plug leaks.
......
......@@ -29,11 +29,11 @@ Michael
* Implement R1C1 style references.
Jody
* Where do the anchor points for objects come from.
* Work on Escher to do just in time biff record merging.
* HEADER, FOOTER import.
* Check the record lengths on the biff records BEFORE use.
* More version size changes for NAME
* ExternSheet import for pre-biff8
* Save Array formulas
Frank
* Summary:
......
......@@ -115,10 +115,12 @@ ms_escher_get_data (MSEscherState * state,
return NULL;
}
g_return_val_if_fail (q->opcode == BIFF_MS_O_DRAWING ||
q->opcode == BIFF_MS_O_DRAWING_GROUP ||
q->opcode == BIFF_MS_O_DRAWING_SELECTION,
NULL);
if (q->opcode != BIFF_MS_O_DRAWING &&
q->opcode != BIFF_MS_O_DRAWING_GROUP &&
q->opcode != BIFF_MS_O_DRAWING_SELECTION) {
printf ("ESCHER : Unexpected record type 0x%x\n", q->opcode);
return NULL;
}
state->start_offset = state->end_offset;
state->end_offset += q->length;
......@@ -166,10 +168,12 @@ ms_escher_get_data (MSEscherState * state,
}
/* We should only see DRAW records now */
g_return_val_if_fail (q->opcode == BIFF_MS_O_DRAWING ||
q->opcode == BIFF_MS_O_DRAWING_GROUP ||
q->opcode == BIFF_MS_O_DRAWING_SELECTION,
NULL);
if (q->opcode != BIFF_MS_O_DRAWING &&
q->opcode != BIFF_MS_O_DRAWING_GROUP &&
q->opcode != BIFF_MS_O_DRAWING_SELECTION) {
printf ("ESCHER : Unexpected record type 0x%x\n", q->opcode);
return NULL;
}
state->start_offset = state->end_offset;
state->end_offset += q->length;
......
......@@ -327,6 +327,7 @@ ms_obj_read_biff8_obj (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet, MSObj *
guint8 *data;
gint32 data_len_left;
gboolean hit_end = FALSE;
gboolean next_biff_record_is_imdata = FALSE;
g_return_val_if_fail (q, TRUE);
g_return_val_if_fail (q->ls_op == BIFF_OBJ, TRUE);
......@@ -370,6 +371,8 @@ ms_obj_read_biff8_obj (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet, MSObj *
case GR_PICTURE_OPTIONS:
ms_obj_dump (data, len, "PictOpt");
next_biff_record_is_imdata = TRUE;
break;
case GR_PICTURE_FORMULA:
......@@ -470,6 +473,17 @@ ms_obj_read_biff8_obj (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet, MSObj *
/* The ftEnd record should have been the last */
g_return_val_if_fail (data_len_left == 0, TRUE);
if (next_biff_record_is_imdata) {
guint16 opcode;
/* Read the IMDATA. I am not sure that this record must follow
* a PictOpt. For now be very careful
*/
g_return_val_if_fail (ms_biff_query_peek_next (q, &opcode), TRUE);
g_return_val_if_fail (opcode == BIFF_IMDATA, TRUE);
g_return_val_if_fail (ms_biff_query_next (q), TRUE);
}
return FALSE;
}
......@@ -507,6 +521,7 @@ ms_read_OBJ (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet)
gboolean errors;
SheetObjectType type;
gchar const * type_name = NULL;
MSObj * obj = g_new(MSObj, 1);
obj->excel_type = (unsigned)-1; /* Set to undefined */
obj->id = -1;
......@@ -521,6 +536,11 @@ ms_read_OBJ (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet)
return NULL;
}
if (obj->excel_type < sizeof(object_type_names)/sizeof(char*))
type_name = object_type_names[obj->excel_type];
if (type_name == NULL)
type_name = "Unknown";
switch (obj->excel_type) {
case 0x05 : /* Chart */
type = SHEET_OBJECT_BOX;
......@@ -561,8 +581,8 @@ ms_read_OBJ (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet)
break;
default :
g_warning ("EXCEL : unhandled excel object of type 0x%x",
obj->excel_type);
g_warning ("EXCEL : unhandled excel object of type %s (0x%x) id = %d",
type_name, obj->excel_type, obj->id);
g_free(obj);
return NULL;
}
......@@ -570,13 +590,8 @@ ms_read_OBJ (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet)
obj->gnumeric_type = type;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0) {
char const * type_name = "Unknown";
if (obj->excel_type < sizeof(object_type_names)/sizeof(char*))
type_name = object_type_names[obj->excel_type];
if (ms_excel_read_debug > 0)
printf ("Object (%d) is a '%s'\n", obj->id, type_name);
}
#endif
return obj;
......
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