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

- Fake scale the sheet to make it les ugly until we figure out the real scale

  factors MS uses.
- Size the window better.
- Explicitly leak the memory associated with the comments in XL97.  Hopefully,
  someone will fix it.

2000-01-10  Jody Goldberg <jgoldberg@home.com>

	* ms-obj.c (ms_read_TXO) : Return the string generated rather than
	  leaking it.
	(ms_read_OBJ) : Don't warn about comments, they are not sheet objects
	  which breaks the whole function of this routine but they are not
	  unexpected.  If we can figur eout how to store the string associated
	  with the TXO nearby with this object and get that cleaned up on
	  time and referencable by obj-ID then we can fix comment import.

	* ms-excel-read.c (ms_excel_read_sheet) : Improve handling for
	  WINDOW1 and warn about more unsupported cases.  Tweak zoom factor
	  by 1.4 to be less ugly. (ICK !  HACK!)
	(ms_excel_read_workbook) : WINDOW2 is a sheet level
	  descriptor.  Add handle for WINDOW1.
	(ms_excel_sheet_new) : ICK!  hard code a scale
	  factor of 1.4 to get things to be less ugly.
parent f218f561
2000-01-10 Jody Goldberg <jgoldberg@home.com>
* ms-obj.c (ms_read_TXO) : Return the string generated rather than
leaking it.
(ms_read_OBJ) : Don't warn about comments, they are not sheet objects
which breaks the whole function of this routine but they are not
unexpected. If we can figur eout how to store the string associated
with the TXO nearby with this object and get that cleaned up on
time and referencable by obj-ID then we can fix comment import.
* ms-excel-read.c (ms_excel_read_sheet) : Improve handling for
WINDOW1 and warn about more unsupported cases. Tweak zoom factor
by 1.4 to be less ugly. (ICK ! HACK!)
(ms_excel_read_workbook) : WINDOW2 is a sheet level
descriptor. Add handle for WINDOW1.
(ms_excel_sheet_new) : ICK! hard code a scale
factor of 1.4 to get things to be less ugly.
2000-01-05 Jon K Hellan <hellan@acm.org>
* ms-excel-write.c (write_colinfos): Fix off by one error.
......
......@@ -1722,7 +1722,10 @@ ms_escher_read_ClientTextbox (MSEscherState * state, MSEscherHeader * h)
g_return_val_if_fail (opcode == BIFF_TXO, TRUE);
g_return_val_if_fail (ms_biff_query_next (state->q), TRUE);
ms_read_TXO (state->q, state->wb);
/* FIXME : Leaking memory. Get an object management framework into place
* so that there is somewhere to put the comment text.
*/
(void)ms_read_TXO (state->q, state->wb);
return FALSE;
}
......
......@@ -1930,6 +1930,11 @@ ms_excel_sheet_new (ExcelWorkbook *wb, const char *name)
ExcelSheet *ans = (ExcelSheet *) g_malloc (sizeof (ExcelSheet));
ans->gnum_sheet = sheet_new (wb->gnum_wb, name);
/* HACK HACK HACK : default zoom to 1.4 for now.
* See SCL for details.
*/
sheet_set_zoom_factor (ans->gnum_sheet, 1.4);
ans->wb = wb;
ans->obj_queue = NULL;
......@@ -3284,7 +3289,13 @@ ms_excel_read_sheet (ExcelSheet *sheet, BiffQuery *q, ExcelWorkbook *wb)
/* Zoom stored as an Egyptian fraction */
double const zoom = (double)MS_OLE_GET_GUINT16 (q->data) /
MS_OLE_GET_GUINT16 (q->data + 2);
sheet_set_zoom_factor (sheet->gnum_sheet, zoom);
/* FIXME : HACK HACK HACK
* MS stores sizes in pts but seems to scale
* the points -> pixels depending on the monitor size.
* Pick a quick scale factor to avoid looking really ugly.
*/
sheet_set_zoom_factor (sheet->gnum_sheet, zoom*1.4);
} else
g_warning ("Duff BIFF_SCL record");
break;
......@@ -3306,20 +3317,42 @@ ms_excel_read_sheet (ExcelSheet *sheet, BiffQuery *q, ExcelWorkbook *wb)
case BIFF_CODENAME :
break;
case BIFF_WINDOW2: /* FIXME: see S59E18.HTM */
case BIFF_WINDOW2:
if (q->length >= 10) {
guint16 const options = MS_OLE_GET_GUINT16(q->data + 0);
guint16 const top_row = MS_OLE_GET_GUINT16(q->data + 2);
guint16 const left_col = MS_OLE_GET_GUINT16(q->data + 4);
guint32 const grid_color = MS_OLE_GET_GUINT32(q->data + 6);
wb->gnum_wb->display_formulas = (options & 0x0001);
if (!(options & 0x0002))
printf ("Unsupported : no grid lines\n");
if (!(options & 0x0004))
printf ("Unsupported : hidden row & col headings\n");
#if 0
if (!(options & 0x0008))
printf ("Unsupported : frozen panes\n");
#endif
if (!(options & 0x0010))
printf ("Unsupported : we always display zeros\n");
#if 0
if (!(options & 0x0020)) {
guint32 const grid_color = MS_OLE_GET_GUINT32(q->data + 6);
/* This is quicky fake code to express the idea */
set_grid_and_header_color (get_color_from_index(grid_color));
#ifndef NO_DEBUG_EXCEL
if (ms_excel_color_debug > 2) {
printf ("Default grid & pattern color = 0x%hx\n",
grid_color);
}
#endif
}
#endif
#ifndef NO_DEBUG_EXCEL
if (ms_excel_read_debug > 0) {
if (options & 0x0001)
printf ("FIXME: Sheet display formulae\n");
if (options & 0x0200)
printf ("Sheet flag selected\n");
printf ("Default grid & pattern color = 0x%hx\n",
grid_color);
}
#endif
if (options & 0x0400) {
......@@ -3841,9 +3874,48 @@ ms_excel_read_workbook (Workbook *workbook, MsOle *file)
break;
case BIFF_WINDOW1 : /* 0 NOT 1 */
break;
if (q->length >= 16) {
int const screen_width = gdk_screen_width ();
int const screen_height = gdk_screen_height ();
#if 0
/* In 1/20ths of a point */
guint16 const xPos = MS_OLE_GET_GUINT16(q->data + 0);
guint16 const yPos = MS_OLE_GET_GUINT16(q->data + 2);
#endif
guint16 const width = MS_OLE_GET_GUINT16(q->data + 4);
guint16 const height = MS_OLE_GET_GUINT32(q->data + 6);
guint16 const options = MS_OLE_GET_GUINT32(q->data + 8);
#if 0
guint16 const selTab = MS_OLE_GET_GUINT32(q->data + 10);
guint16 const firstTab= MS_OLE_GET_GUINT32(q->data + 12);
guint16 const tabsSel = MS_OLE_GET_GUINT32(q->data + 14);
/* (width of tab)/(width of horizontal scroll bar) / 1000 */
guint16 const ratio = MS_OLE_GET_GUINT32(q->data + 16);
#endif
case (BIFF_WINDOW2 & 0xff) :
/* FIXME : MS quotes its measurments in 'pts' but scales that
* to the screen somehow. This is a crude approximation
* that assumes that it uses the resolution of the screen and
* scales relative to an 800x600 screen.
*/
gtk_window_set_default_size (GTK_WINDOW (wb->gnum_wb->toplevel),
MIN (screen_width - 64,
(screen_width * width)/(800 * 20)),
MIN (screen_height - 64,
(screen_height*height)/(600 * 20)));
if (options & 0x0001)
printf ("Unsupported : Hidden sheet\n");
if (options & 0x0002)
printf ("Unsupported : Iconic sheet\n");
if (!(options & 0x0008))
printf ("Unsupported : Hidden horizonal scroll bar\n");
if (!(options & 0x0010))
printf ("Unsupported : Hidden horizonal scroll bar\n");
if (!(options & 0x0020))
printf ("Unsupported : Hidden notbook tabs\n");
}
break;
case BIFF_SELECTION : /* 0, NOT 10 */
......
......@@ -103,6 +103,10 @@ ms_obj_realize (MSObj *obj, ExcelWorkbook *wb, ExcelSheet *sheet)
object_anchor_to_position (position, obj, sheet->gnum_sheet,
wb->ver);
/* Handle Comments */
if (wb->ver >= eBiffV8 && obj->excel_type == 0x19) {
}
switch (obj->gnumeric_type) {
case SHEET_OBJECT_BUTTON :
sheet_object_create_button (sheet->gnum_sheet,
......@@ -237,7 +241,7 @@ ms_parse_object_anchor (anchor_point anchor[4],
/*
* See: S59EOE.HTM
*/
void
char *
ms_read_TXO (BiffQuery *q, ExcelWorkbook * wb)
{
static char const * const orientations[] = {
......@@ -266,9 +270,9 @@ ms_read_TXO (BiffQuery *q, ExcelWorkbook * wb)
guchar const * ptr;
int i, increment = 1;
g_return_if_fail (orient <= 3);
g_return_if_fail (1 <= halign && halign <= 4);
g_return_if_fail (1 <= valign && valign <= 4);
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);
#if 0
/* TODO : figure this out. There seem to be strings with 0 formats too.
......@@ -310,6 +314,7 @@ ms_read_TXO (BiffQuery *q, ExcelWorkbook * wb)
printf ("}; /* TextObject */\n");
}
#endif
return text;
}
static void
......@@ -621,9 +626,13 @@ ms_read_OBJ (BiffQuery *q, ExcelWorkbook * wb, Sheet * sheet)
type = SHEET_OBJECT_BUTTON;
break;
case 0x19 : /* Comment */
type = -1; /* FIXME : Invalid */
break;
default :
g_warning ("EXCEL : unhandled excel object of type %s (0x%x) id = %d",
type_name, obj->excel_type, obj->id);
printf ("EXCEL : unhandled excel object of type %s (0x%x) id = %d\n",
type_name, obj->excel_type, obj->id);
g_free(obj);
return NULL;
}
......
......@@ -59,7 +59,6 @@ void ms_excel_sheet_destroy_objs (ExcelSheet *sheet);
MSObj *ms_read_OBJ (BiffQuery *q,
ExcelWorkbook * wb, Sheet * sheet);
void ms_read_TXO (BiffQuery *q, ExcelWorkbook * wb);
char *ms_read_TXO (BiffQuery *q, ExcelWorkbook * wb);
#endif /* GNUMERIC_MS_OBJ_H */
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