Commit a2aa062a authored by Michael Meeks's avatar Michael Meeks

Optimised choose functions implemented,

Updated Name support, removed lots of annoying debug.
parent fe7e96e2
1999-04-15 Michael Meeks <michael@mejm2.dow.cam.ac.uk>
* ms-excel.c (ms_excelReadWorkbook): Put PRECISION
output conditional on debug.
Put escher_hack_get_drawing on condition of --debug
* ms-formula.c (ms_excel_parse_formula): Added
'Optimised Choose' functionality.
(formula_func_data): Inserted CHOOSE.
(ms_excel_parse_formula): Patch for broken MS files.
Updated 'Name' records.
1999-04-15 Michael Meeks <michael@mejm2.dow.cam.ac.uk>
* boot.c: Fixed includes to remove annoying warning.
......
......@@ -24,6 +24,7 @@
#include "color.h"
#include "sheet-object.h"
#include "style.h"
#include "main.h"
#include "ms-ole.h"
#include "ms-biff.h"
......@@ -1917,7 +1918,8 @@ ms_excel_read_sheet (MS_EXCEL_SHEET *sheet, BIFF_QUERY * q, MS_EXCEL_WORKBOOK *
break ;
}
case BIFF_MS_O_DRAWING: /* FIXME: See: ms-escher.c and S59DA4.HTM */
ms_escher_hack_get_drawing (q);
if (gnumeric_debugging>0)
ms_escher_hack_get_drawing (q);
break;
case BIFF_NOTE: /* See: S59DAB.HTM */
{
......@@ -2136,8 +2138,10 @@ ms_excelReadWorkbook (MS_OLE * file)
case BIFF_PRECISION: /*
* FIXME:
*/
printf ("Opcode : 0x%x, length 0x%x\n", q->opcode, q->length);
dump (q->data, q->length);
if (EXCEL_DEBUG>0) {
printf ("Opcode : 0x%x, length 0x%x\n", q->opcode, q->length);
dump (q->data, q->length);
}
break;
case BIFF_XF_OLD: /*
* FIXME: see S59E1E.HTM
......@@ -2185,8 +2189,10 @@ ms_excelReadWorkbook (MS_OLE * file)
/* Can be safely ignored on read side */
break;
case BIFF_MS_O_DRAWING_GROUP: /* FIXME: See: S59DA5.HTM */
printf ("FIXME: MS Drawing Group\n");
ms_escher_hack_get_drawing (q);
if (gnumeric_debugging>0) {
printf ("FIXME: MS Drawing Group\n");
ms_escher_hack_get_drawing (q);
}
break;
case BIFF_EXTERNSHEET:
{
......
......@@ -24,6 +24,7 @@
#include "color.h"
#include "sheet-object.h"
#include "style.h"
#include "main.h"
#include "ms-ole.h"
#include "ms-biff.h"
......@@ -1917,7 +1918,8 @@ ms_excel_read_sheet (MS_EXCEL_SHEET *sheet, BIFF_QUERY * q, MS_EXCEL_WORKBOOK *
break ;
}
case BIFF_MS_O_DRAWING: /* FIXME: See: ms-escher.c and S59DA4.HTM */
ms_escher_hack_get_drawing (q);
if (gnumeric_debugging>0)
ms_escher_hack_get_drawing (q);
break;
case BIFF_NOTE: /* See: S59DAB.HTM */
{
......@@ -2136,8 +2138,10 @@ ms_excelReadWorkbook (MS_OLE * file)
case BIFF_PRECISION: /*
* FIXME:
*/
printf ("Opcode : 0x%x, length 0x%x\n", q->opcode, q->length);
dump (q->data, q->length);
if (EXCEL_DEBUG>0) {
printf ("Opcode : 0x%x, length 0x%x\n", q->opcode, q->length);
dump (q->data, q->length);
}
break;
case BIFF_XF_OLD: /*
* FIXME: see S59E1E.HTM
......@@ -2185,8 +2189,10 @@ ms_excelReadWorkbook (MS_OLE * file)
/* Can be safely ignored on read side */
break;
case BIFF_MS_O_DRAWING_GROUP: /* FIXME: See: S59DA5.HTM */
printf ("FIXME: MS Drawing Group\n");
ms_escher_hack_get_drawing (q);
if (gnumeric_debugging>0) {
printf ("FIXME: MS Drawing Group\n");
ms_escher_hack_get_drawing (q);
}
break;
case BIFF_EXTERNSHEET:
{
......
......@@ -159,7 +159,7 @@ FORMULA_FUNC_DATA formula_func_data[] =
{ "ATAN2", 2 },
{ "ASIN", 1 },
{ "ACOS", 1 },
{ "0x64", 8 },
{ "CHOOSE", -1 },
{ "HLOOKUP", -1 },
{ "VLOOKUP", -1 },
{ "0x67", 8 },
......@@ -207,7 +207,7 @@ FORMULA_FUNC_DATA formula_func_data[] =
{ "0x91", 8 },
{ "0x92", 8 },
{ "0x93", 8 },
{ "0x94", 8 },
{ "INDIRECT", -1 },
{ "0x95", 8 },
{ "0x96", 8 },
{ "0x97", 8 },
......@@ -974,13 +974,18 @@ char *ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
case FORMULA_PTG_NAME:
{
guint16 name_idx ; /* 1 based */
char *txt;
if (sheet->ver == eBiffV8)
name_idx = BIFF_GETWORD(cur+2) ;
else
name_idx = BIFF_GETWORD(cur) ;
printf ("FIXME: Ptg Name: %d\n", name_idx) ;
dump(mem, length) ;
parse_list_push_raw (stack, g_strdup("Unknown name"), NO_PRECEDENCE) ;
txt = biff_name_data_get_name (sheet, name_idx);
if (!txt) {
printf ("FIXME: Ptg Name not found: %d\n", name_idx) ;
dump(mem, length) ;
parse_list_push_raw (stack, g_strdup("Unknown name"), NO_PRECEDENCE) ;
} else
parse_list_push_raw (stack, g_strdup(txt), NO_PRECEDENCE) ;
}
case FORMULA_PTG_EXP:
{
......@@ -992,7 +997,7 @@ char *ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
fn_col, fn_row) ;
txt[0] = ' ' ; /* Kill '=' */
parse_list_push_raw (stack, txt, NO_PRECEDENCE) ;
ptg_length = 4 ;
ptg_length = length; /* Force it to be the only token 4 ; */
break ;
}
case FORMULA_PTG_PAREN:
......@@ -1028,6 +1033,32 @@ char *ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
txt[0] = ' ' ; /* Kill the = */
parse_list_push_raw (stack, txt, NO_PRECEDENCE) ;
ptg_length += w ;
} else if (grbit & 0x04) { /* AttrChoose 'optimised' my foot. */
guint16 len, lp;
guint32 offset=0;
guint8 *data=cur+3;
char *txt;
if (FORMULA_DEBUG>1) {
printf ("'Optimised' choose\n");
dump (mem,length);
}
for (lp=0;lp<w;lp++) { /* w = wCases */
offset= BIFF_GETWORD(data);
len = BIFF_GETWORD(data+2) - offset;
if (FORMULA_DEBUG>1)
printf ("Get from %d len %d [ = 0x%x ]\n",
ptg_length+offset, len, *(cur+ptg_length+offset));
txt = ms_excel_parse_formula (sheet, cur+ptg_length+offset,
fn_col, fn_row, shared,
len);
txt[0] = ' ';
data+=2;
if (FORMULA_DEBUG>1)
printf ("Parsed to '%s'\n", txt);
parse_list_push_raw (stack, txt, NO_PRECEDENCE);
}
ptg_length+=BIFF_GETWORD(data);
} else if (grbit & 0x08) { /* AttrGoto */
if (FORMULA_DEBUG>2) {
printf ("Goto %d: cur = 0x%x\n", w, (int)(cur-mem)) ;
......
......@@ -159,7 +159,7 @@ FORMULA_FUNC_DATA formula_func_data[] =
{ "ATAN2", 2 },
{ "ASIN", 1 },
{ "ACOS", 1 },
{ "0x64", 8 },
{ "CHOOSE", -1 },
{ "HLOOKUP", -1 },
{ "VLOOKUP", -1 },
{ "0x67", 8 },
......@@ -207,7 +207,7 @@ FORMULA_FUNC_DATA formula_func_data[] =
{ "0x91", 8 },
{ "0x92", 8 },
{ "0x93", 8 },
{ "0x94", 8 },
{ "INDIRECT", -1 },
{ "0x95", 8 },
{ "0x96", 8 },
{ "0x97", 8 },
......@@ -974,13 +974,18 @@ char *ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
case FORMULA_PTG_NAME:
{
guint16 name_idx ; /* 1 based */
char *txt;
if (sheet->ver == eBiffV8)
name_idx = BIFF_GETWORD(cur+2) ;
else
name_idx = BIFF_GETWORD(cur) ;
printf ("FIXME: Ptg Name: %d\n", name_idx) ;
dump(mem, length) ;
parse_list_push_raw (stack, g_strdup("Unknown name"), NO_PRECEDENCE) ;
txt = biff_name_data_get_name (sheet, name_idx);
if (!txt) {
printf ("FIXME: Ptg Name not found: %d\n", name_idx) ;
dump(mem, length) ;
parse_list_push_raw (stack, g_strdup("Unknown name"), NO_PRECEDENCE) ;
} else
parse_list_push_raw (stack, g_strdup(txt), NO_PRECEDENCE) ;
}
case FORMULA_PTG_EXP:
{
......@@ -992,7 +997,7 @@ char *ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
fn_col, fn_row) ;
txt[0] = ' ' ; /* Kill '=' */
parse_list_push_raw (stack, txt, NO_PRECEDENCE) ;
ptg_length = 4 ;
ptg_length = length; /* Force it to be the only token 4 ; */
break ;
}
case FORMULA_PTG_PAREN:
......@@ -1028,6 +1033,32 @@ char *ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
txt[0] = ' ' ; /* Kill the = */
parse_list_push_raw (stack, txt, NO_PRECEDENCE) ;
ptg_length += w ;
} else if (grbit & 0x04) { /* AttrChoose 'optimised' my foot. */
guint16 len, lp;
guint32 offset=0;
guint8 *data=cur+3;
char *txt;
if (FORMULA_DEBUG>1) {
printf ("'Optimised' choose\n");
dump (mem,length);
}
for (lp=0;lp<w;lp++) { /* w = wCases */
offset= BIFF_GETWORD(data);
len = BIFF_GETWORD(data+2) - offset;
if (FORMULA_DEBUG>1)
printf ("Get from %d len %d [ = 0x%x ]\n",
ptg_length+offset, len, *(cur+ptg_length+offset));
txt = ms_excel_parse_formula (sheet, cur+ptg_length+offset,
fn_col, fn_row, shared,
len);
txt[0] = ' ';
data+=2;
if (FORMULA_DEBUG>1)
printf ("Parsed to '%s'\n", txt);
parse_list_push_raw (stack, txt, NO_PRECEDENCE);
}
ptg_length+=BIFF_GETWORD(data);
} else if (grbit & 0x08) { /* AttrGoto */
if (FORMULA_DEBUG>2) {
printf ("Goto %d: cur = 0x%x\n", w, (int)(cur-mem)) ;
......
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