Commit e7b3aa33 authored by Michael Meeks's avatar Michael Meeks

Chart stuff from Jody,

function closure mis-feature nailed (?)
More Excel write-side work,
Daft OLE2 merge bug squashed.
parent d8af07cb
1999-06-21 Michael Meeks <michael@edenproject.org>
* src/func.c (iterate_cellrange_callback): Add case
of no cell text ( yet ).
1999-06-21 Morten Welinder <terra@diku.dk>
* src/fn-information.c (get_value_class): New function.
......
1999-06-21 Michael Meeks <michael@edenproject.org>
* src/func.c (iterate_cellrange_callback): Add case
of no cell text ( yet ).
1999-06-21 Morten Welinder <terra@diku.dk>
* src/fn-information.c (get_value_class): New function.
......
1999-06-21 Michael Meeks <michael@edenproject.org>
* src/func.c (iterate_cellrange_callback): Add case
of no cell text ( yet ).
1999-06-21 Morten Welinder <terra@diku.dk>
* src/fn-information.c (get_value_class): New function.
......
1999-06-21 Michael Meeks <michael@edenproject.org>
* src/func.c (iterate_cellrange_callback): Add case
of no cell text ( yet ).
1999-06-21 Morten Welinder <terra@diku.dk>
* src/fn-information.c (get_value_class): New function.
......
1999-06-21 Michael Meeks <michael@edenproject.org>
* ms-excel-read.c (ms_excel_read_cell): Remove Jody's
check against NULL pointers, insert_form handles them.
* ms-chart.c (BC_R): make call to dump_tree conditional
* ms-excel-write.c (write_sheet_bools): Various fixes.
(write_value): Change RSTRING -> LABEL
* README (TODO): Updated.
* ms-excel-write.c (write_externsheets): Fix for single sheet
workbooks.
(write_formats): Write the format index code!
(write_sheet_bools): Divide default col width by 16
* ms-excel-write.h (ms_excel_write_workbook): Cleaned and fixed
header.
1999-06-21 Jody Goldberg <jgoldberg@home.com>
* biff-types.h : Move NAME from 218 -> 18, rename Chart biff types to
lower case to facilitate decls.
* ms-biff.[ch] (dump_biff) : export.
* ms-excel-read.[ch] : (ms_biff_bof_data_new, ms_biff_bof_data_destroy)
export.
* ms-formula-read.c : Improve handling of array formulas.
* ms-obj.c : Adjust signatures, and split chart handling into its own
file.
* ole.c : Count BACKWARDS to allow BIFF types with high bytes to
override those with only low bytes specified.
* Makefile.am : Add ms-chart.
* ms-chart.[ch] : New files. No real functionality. 60% complete.
1999-06-17 Michael Meeks <michael@edenproject.org>
* ms-formula-read.c (formula_func_data): Fixed up, should work
......
......@@ -26,7 +26,8 @@ libexcel_a_SOURCES = \
ms-formula-read.c \
ms-formula-read.h \
ms-obj.c \
ms-obj.h
ms-obj.h \
ms-chart.c
noinst_PROGRAMS = \
ole
......
......@@ -34,5 +34,4 @@ or
TODO:
padding in BIFF records, implement properly.
biff_put etc. needs to be written.
sort out padding, do we need it ? where is the bug ?
......@@ -33,6 +33,7 @@
#define BIFF_FOOTER 0x15 /* 0, NOT 10 */
#define BIFF_EXTERNCOUNT 0x16 /* 0, NOT 10 */
#define BIFF_EXTERNSHEET 0x17 /* 0, NOT 10 */
#define BIFF_NAME 0x18 /* 2, NOT 10 */
#define BIFF_WINDOWPROTECT 0x19 /* 0, NOT 10 */
#define BIFF_VERTICALPAGEBREAKS 0x1a /* 0, NOT 10 */
#define BIFF_HORIZONTALPAGEBREAKS 0x1b /* 0, NOT 10 */
......@@ -180,74 +181,79 @@
#define BIFF_PROT4REVPASS 0x1bc /* ONLY 1 */
#define BIFF_DV 0x1be /* ONLY 1 */
#define BIFF_BOOLERR 0x205 /* Why not as 05 */
#define BIFF_STRING 0x207 /* Why not as 07, NOT 10 */
#define BIFF_INDEX 0x20b /* Why not as 0b */
#define BIFF_NAME 0x218 /* Why not as 18, NOT 10 */
#define BIFF_DEFAULTROWHEIGHT 0x225 /* Why not as 25, NOT 10 */
#define BIFF_TABLE 0x236 /* Why not as 36 */
#define BIFF_WINDOW2 0x23e /* Why not as 3e, NOT 10 */
#define BIFF_STYLE 0x293 /* Why not as 93 */
/* Chart Specific */
#define BIFF_CHART_UNITS 0x1001
#define BIFF_CHART_CHART 0x1002
#define BIFF_CHART_SERIES 0x1003
#define BIFF_CHART_DATAFORMAT 0x1006
#define BIFF_CHART_LINEFORMAT 0x1007
#define BIFF_CHART_MARKERFORMAT 0x1009
#define BIFF_CHART_AREAFORMAT 0x100a
#define BIFF_CHART_PIEFORMAT 0x100b
#define BIFF_CHART_ATTACHEDLABEL 0x100c
#define BIFF_CHART_SERIESTEXT 0x100d
#define BIFF_CHART_CHARTFORMAT 0x1014
#define BIFF_CHART_LEGEND 0x1015
#define BIFF_CHART_SERIESLIST 0x1016
#define BIFF_CHART_BAR 0x1017
#define BIFF_CHART_LINE 0x1018
#define BIFF_CHART_PIE 0x1019
#define BIFF_CHART_AREA 0x101a
#define BIFF_CHART_SCATTER 0x101b
#define BIFF_CHART_CHARTLINE 0x101c
#define BIFF_CHART_AXIS 0x101d
#define BIFF_CHART_TICK 0x101e
#define BIFF_CHART_VALUERANGE 0x101f
#define BIFF_CHART_CATSERRANGE 0x1020
#define BIFF_CHART_AXISLINEFORMAT 0x1021
#define BIFF_CHART_CHARTFORMATLINK 0x1022
#define BIFF_CHART_DEFAULTTEXT 0x1024
#define BIFF_CHART_TEXT 0x1025
#define BIFF_CHART_FONTX 0x1026
#define BIFF_CHART_OBJECTLINK 0x1027
#define BIFF_CHART_FRAME 0x1032
#define BIFF_CHART_BEGIN 0x1033
#define BIFF_CHART_END 0x1034
#define BIFF_CHART_PLOTAREA 0x1035
#define BIFF_CHART_3D 0x103a
#define BIFF_CHART_PICF 0x103c
#define BIFF_CHART_DROPBAR 0x103d
#define BIFF_CHART_RADAR 0x103e
#define BIFF_CHART_SURF 0x103f
#define BIFF_CHART_RADARAREA 0x1040
#define BIFF_CHART_AXISPARENT 0x1041
#define BIFF_CHART_LEGENDXN 0x1043
#define BIFF_CHART_SHTPROPS 0x1044
#define BIFF_CHART_SERTOCRT 0x1045
#define BIFF_CHART_AXESUSED 0x1046
#define BIFF_CHART_SBASEREF 0x1048
#define BIFF_CHART_SERPARENT 0x104a
#define BIFF_CHART_SERAUXTREND 0x104b
#define BIFF_CHART_IFMT 0x104e
#define BIFF_CHART_POS 0x104f
#define BIFF_CHART_ALRUNS 0x1050
#define BIFF_CHART_AI 0x1051
#define BIFF_CHART_SERAUXERRBAR 0x105b
#define BIFF_CHART_SERFMT 0x105d
#define BIFF_CHART_FBI 0x1060
#define BIFF_CHART_BOPPOP 0x1061
#define BIFF_CHART_AXCEXT 0x1062
#define BIFF_CHART_DAT 0x1063
#define BIFF_CHART_PLOTGROWTH 0x1064
#define BIFF_CHART_SIINDEX 0x1065
#define BIFF_CHART_GELFRAME 0x1066
#define BIFF_CHART_BOPPOPCUSTOM 0x1067
/* These must be here for the ole program to work, and the suffixes must be
* lower case for the macros in ms-chart.c to work
*/
#define BIFF_CHART_units 0x1001
#define BIFF_CHART_chart 0x1002
#define BIFF_CHART_series 0x1003
#define BIFF_CHART_dataformat 0x1006
#define BIFF_CHART_lineformat 0x1007
#define BIFF_CHART_markerformat 0x1009
#define BIFF_CHART_areaformat 0x100a
#define BIFF_CHART_pieformat 0x100b
#define BIFF_CHART_attachedlabel 0x100c
#define BIFF_CHART_seriestext 0x100d
#define BIFF_CHART_chartformat 0x1014
#define BIFF_CHART_legend 0x1015
#define BIFF_CHART_serieslist 0x1016
#define BIFF_CHART_bar 0x1017
#define BIFF_CHART_line 0x1018
#define BIFF_CHART_pie 0x1019
#define BIFF_CHART_area 0x101a
#define BIFF_CHART_scatter 0x101b
#define BIFF_CHART_chartline 0x101c
#define BIFF_CHART_axis 0x101d
#define BIFF_CHART_tick 0x101e
#define BIFF_CHART_valuerange 0x101f
#define BIFF_CHART_catserrange 0x1020
#define BIFF_CHART_axislineformat 0x1021
#define BIFF_CHART_chartformatlink 0x1022
#define BIFF_CHART_defaulttext 0x1024
#define BIFF_CHART_text 0x1025
#define BIFF_CHART_fontx 0x1026
#define BIFF_CHART_objectlink 0x1027
#define BIFF_CHART_frame 0x1032
#define BIFF_CHART_begin 0x1033
#define BIFF_CHART_end 0x1034
#define BIFF_CHART_plotarea 0x1035
#define BIFF_CHART_3d 0x103a
#define BIFF_CHART_picf 0x103c
#define BIFF_CHART_dropbar 0x103d
#define BIFF_CHART_radar 0x103e
#define BIFF_CHART_surf 0x103f
#define BIFF_CHART_radararea 0x1040
#define BIFF_CHART_axisparent 0x1041
#define BIFF_CHART_legendxn 0x1043
#define BIFF_CHART_shtprops 0x1044
#define BIFF_CHART_sertocrt 0x1045
#define BIFF_CHART_axesused 0x1046
#define BIFF_CHART_sbaseref 0x1048
#define BIFF_CHART_serparent 0x104a
#define BIFF_CHART_serauxtrend 0x104b
#define BIFF_CHART_ifmt 0x104e
#define BIFF_CHART_pos 0x104f
#define BIFF_CHART_alruns 0x1050
#define BIFF_CHART_ai 0x1051
#define BIFF_CHART_serauxerrbar 0x105b
#define BIFF_CHART_unknown105c 0x105c
#define BIFF_CHART_serfmt 0x105d
#define BIFF_CHART_unknown105f 0x105f
#define BIFF_CHART_fbi 0x1060
#define BIFF_CHART_boppop 0x1061
#define BIFF_CHART_axcext 0x1062
#define BIFF_CHART_dat 0x1063
#define BIFF_CHART_plotgrowth 0x1064
#define BIFF_CHART_siindex 0x1065
#define BIFF_CHART_gelframe 0x1066
#define BIFF_CHART_boppopcustom 0x1067
......@@ -8,6 +8,7 @@
#define GNUMERIC_EXCEL_H
#include "ms-ole.h"
#include "sheet.h"
typedef enum _eBiff_version { eBiffV2=2, eBiffV3=3,
eBiffV4=4,
......
1999-06-18 Michael Meeks <michael@edenproject.org>
* ms-ole.c (ms_ole_read_ptr_bb): Stupid bug detecting
contiguous blocks !
(ms_ole_read_ptr_sb): ditto.
1999-06-15 Morten Welinder <terra@diku.dk>
* ms-ole.c (ms_ole_destroy): Plug leak.
......
......@@ -1550,8 +1550,8 @@ ms_ole_read_ptr_bb (MS_OLE_STREAM *s, guint32 length)
len-=blklen;
blklen = BB_BLOCK_SIZE;
if (blockidx >= (s->blocks->len - 1) ||
(ms_array_index (s->blocks, BLP, blockidx)+1
!= ms_array_index (s->blocks, BLP, blockidx+1)))
(ms_array_index (s->blocks, BLP, blockidx) !=
blockidx + 1))
return 0;
blockidx++;
}
......@@ -1583,8 +1583,8 @@ ms_ole_read_ptr_sb (MS_OLE_STREAM *s, guint32 length)
len-=blklen;
blklen = SB_BLOCK_SIZE;
if (blockidx >= (s->blocks->len - 1) ||
(ms_array_index (s->blocks, BLP, blockidx)+1
!= ms_array_index (s->blocks, BLP, blockidx+1)))
(ms_array_index (s->blocks, BLP, blockidx) !=
blockidx + 1))
return 0;
blockidx++;
}
......
......@@ -60,7 +60,7 @@ void biff_setdouble (guint8 *p, double d)
}
#endif
static void
void
dump_biff (BIFF_QUERY *bq)
{
printf ("Opcode 0x%x length %d malloced? %d\nData:\n", bq->opcode, bq->length, bq->data_malloced);
......
......@@ -107,4 +107,5 @@ extern void ms_biff_put_var_write (BIFF_PUT *, guint8 *, guint32 len)
/* Must commit after each record */
extern void ms_biff_put_commit (BIFF_PUT *);
void dump_biff (BIFF_QUERY *bq);
#endif
This diff is collapsed.
#ifndef GNUMERIC_MS_CHART_H
#define GNUMERIC_MS_CHART_H
/**
* ms-chart.h: MS Excel Chart support for Gnumeric
*
* Author:
* Jody Goldberg (jgoldberg@home.com)
**/
#include <ms-excel-read.h>
extern void ms_excel_read_chart (MS_EXCEL_WORKBOOK * wb, BIFF_QUERY * q);
#endif /* GNUMERIC_MS_CHART_H */
......@@ -244,7 +244,7 @@ biff_shared_formula_equal (const BIFF_SHARED_FORMULA_KEY *a,
/**
* See S59D5D.HTM
**/
static BIFF_BOF_DATA *
BIFF_BOF_DATA *
ms_biff_bof_data_new (BIFF_QUERY * q)
{
BIFF_BOF_DATA *ans = g_new (BIFF_BOF_DATA, 1);
......@@ -333,7 +333,7 @@ ms_biff_bof_data_new (BIFF_QUERY * q)
return ans;
}
static void
void
ms_biff_bof_data_destroy (BIFF_BOF_DATA * data)
{
g_free (data);
......@@ -1413,12 +1413,10 @@ ms_excel_sheet_insert_form (MS_EXCEL_SHEET * sheet, int xfidx,
int col, int row, ExprTree *tr)
{
Cell *cell = sheet_cell_fetch (sheet->gnum_sheet, col, row);
if (tr)
{
if (tr) {
sheet->blank = 0 ;
cell_set_formula_tree_simple (cell, tr);
}
else
} else
cell_set_text_simple (cell, "") ;
ms_excel_set_cell_xf (sheet, cell, xfidx);
}
......@@ -2019,8 +2017,10 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
tr = ms_excel_parse_formula (sheet, (q->data + 22),
EX_GETCOL (q), EX_GETROW (q),
0, BIFF_GETWORD(q->data+20));
ms_excel_sheet_insert_form (sheet, EX_GETXF(q), EX_GETCOL(q), EX_GETROW(q), tr) ;
expr_tree_unref (tr);
ms_excel_sheet_insert_form (sheet, EX_GETXF(q), EX_GETCOL(q),
EX_GETROW(q), tr) ;
if (tr)
expr_tree_unref (tr);
break;
}
case BIFF_LABELSST:
......@@ -2110,7 +2110,7 @@ ms_excel_read_sheet (MS_EXCEL_SHEET *sheet, BIFF_QUERY * q, MS_EXCEL_WORKBOOK *
break;
case BIFF_OBJ: /* See: ms-obj.c and S59DAD.HTM */
ms_obj_read_obj (q);
ms_obj_read_obj (q, wb);
break;
case BIFF_SELECTION: /* S59DE2.HTM */
......@@ -2393,11 +2393,6 @@ ms_excel_read_workbook (MS_OLE * file)
if (EXCEL_DEBUG>5)
printf ("Opcode : 0x%x\n", q->opcode) ;
/* Catch Chart specific codes before primary */
if (0x10 == q->ms_op)
if (ms_chart_biff_read (wb, q))
continue;
/* Catch Oddballs
* The heuristic seems to be that 'version 1' BIFF types
* are unique and not versioned.
......@@ -2704,7 +2699,7 @@ ms_excel_read_workbook (MS_OLE * file)
break;
case BIFF_OBJ: /* See: ms-obj.c and S59DAD.HTM */
ms_obj_read_obj (q);
ms_obj_read_obj (q, wb);
break;
case BIFF_SCL :
......@@ -2720,7 +2715,7 @@ ms_excel_read_workbook (MS_OLE * file)
break;
}
/* NO Code here unless you modify the handling
* of Chart and Odd Balls Above the switch
* of Odd Balls Above the switch
*/
}
ms_biff_query_destroy (q);
......
......@@ -106,4 +106,7 @@ extern Sheet* biff_get_externsheet_name (MS_EXCEL_WORKBOOK *wb, guint16 idx, gbo
extern char* biff_get_text (BYTE *ptr, guint32 length, guint32 *byte_length);
extern const char* biff_get_error_text (const guint8 err);
extern char* biff_name_data_get_name (MS_EXCEL_SHEET *sheet, guint16 idx);
extern BIFF_BOF_DATA * ms_biff_bof_data_new (BIFF_QUERY * q);
extern void ms_biff_bof_data_destroy (BIFF_BOF_DATA * data);
#endif
......@@ -148,7 +148,8 @@ biff_bof_write (BIFF_PUT *bp, eBiff_version ver,
case eBiffV7:
case eBiffV8:
bp->ms_op = 8;
if (ver == eBiffV8)
if (ver == eBiffV8 || /* as per the spec. */
(ver == eBiffV7 && type == eBiffTWorksheet)) /* Wierd hey */
BIFF_SET_GUINT16 (data, 0x0600);
else
BIFF_SET_GUINT16 (data, 0x0500);
......@@ -268,10 +269,14 @@ write_externsheets (BIFF_PUT *bp, WORKBOOK *wb, SHEET *ignore)
return;
}
if (num_sheets == 1) /* Not enough sheets for extern records */
return;
if (ignore) /* Strangely needed */
num_sheets--;
g_assert (num_sheets < 0xffff);
data = ms_biff_put_len_next (bp, BIFF_EXTERNCOUNT, 2);
BIFF_SET_GUINT16(data, num_sheets);
ms_biff_put_commit (bp);
......@@ -314,10 +319,10 @@ write_bits (BIFF_PUT *bp, eBiff_version ver)
/* See: S59E17.HTM */
data = ms_biff_put_len_next (bp, BIFF_WINDOW1, 18);
BIFF_SET_GUINT16 (data+ 0, 0x01e0);
BIFF_SET_GUINT16 (data+ 2, 0x005a);
BIFF_SET_GUINT16 (data+ 4, 0x3fcf);
BIFF_SET_GUINT16 (data+ 6, 0x2a4e);
BIFF_SET_GUINT16 (data+ 0, 0x00f0);
BIFF_SET_GUINT16 (data+ 2, 0x0078);
BIFF_SET_GUINT16 (data+ 4, 0x378c);
BIFF_SET_GUINT16 (data+ 6, 0x2238);
BIFF_SET_GUINT16 (data+ 8, 0x0038); /* various flags */
BIFF_SET_GUINT16 (data+ 10, 0x0000); /* selected tab */
BIFF_SET_GUINT16 (data+ 12, 0x0000); /* displayed tab */
......@@ -325,8 +330,15 @@ write_bits (BIFF_PUT *bp, eBiff_version ver)
BIFF_SET_GUINT16 (data+ 16, 0x0258);
ms_biff_put_commit (bp);
/* See: S59DCA.HTM */
data = ms_biff_put_len_next (bp, BIFF_PANE, 2);
if (ver >= eBiffV8) {
/* See: S59DCA.HTM */
data = ms_biff_put_len_next (bp, BIFF_PANE, 2);
BIFF_SET_GUINT16 (data, 0x0);
ms_biff_put_commit (bp);
}
/* See: S59D5B.HTM */
data = ms_biff_put_len_next (bp, BIFF_BACKUP, 2);
BIFF_SET_GUINT16 (data, 0x0);
ms_biff_put_commit (bp);
......@@ -345,6 +357,11 @@ write_bits (BIFF_PUT *bp, eBiff_version ver)
BIFF_SET_GUINT16 (data, 0x0001);
ms_biff_put_commit (bp);
/* See: S59DD8.HTM */
data = ms_biff_put_len_next (bp, BIFF_REFRESHALL, 2);
BIFF_SET_GUINT16 (data, 0x0000);
ms_biff_put_commit (bp);
/* See: S59D5E.HTM */
data = ms_biff_put_len_next (bp, BIFF_BOOKBOOL, 2);
BIFF_SET_GUINT16 (data, 0x0);
......@@ -432,11 +449,11 @@ write_palette (BIFF_PUT *bp, WORKBOOK *wb)
BIFF_SET_GUINT16 (data, 2); /* Entries */
r = g = b = 0xff;
num = (r<<16) + (g<<8) + (b<<0);
num = (b<<16) + (g<<8) + (r<<0);
BIFF_SET_GUINT32 (data+2+PALETTE_WHITE*4, num);
r = g = b = 0x00;
num = (r<<16) + (g<<8) + (b<<0);
num = (b<<16) + (g<<8) + (r<<0);
BIFF_SET_GUINT32 (data+2+PALETTE_BLACK*4, num);
ms_biff_put_var_write (bp, data, 10);
......@@ -477,7 +494,7 @@ write_fonts (BIFF_PUT *bp, WORKBOOK *wb)
guint8 data[64];
int lp;
for (lp=0;lp<5;lp++) { /* FIXME: Magic minimum fonts */
for (lp=0;lp<4;lp++) { /* FIXME: Magic minimum fonts */
fonts->StyleFont_to_idx = g_hash_table_new (g_direct_hash,
g_direct_equal);
/* Kludge for now ... */
......@@ -488,15 +505,15 @@ write_fonts (BIFF_PUT *bp, WORKBOOK *wb)
/* BIFF_SET_GUINT16(data + 4, PALETTE_BLACK); */
BIFF_SET_GUINT16(data + 4, 0x7fff); /* Magic ! */
if (lp%1)
if (1)
BIFF_SET_GUINT16(data + 6, 0x190); /* Normal boldness */
else
BIFF_SET_GUINT16(data + 6, 0x2bc); /* Magic boldness */
BIFF_SET_GUINT16(data + 6, 0x2bc); /* Bold */
BIFF_SET_GUINT16(data + 8, 0); /* 0: Normal, 1; Super, 2: Sub script*/
BIFF_SET_GUINT16(data +10, 0); /* No underline */
BIFF_SET_GUINT16(data +12, 0); /* ? */
BIFF_SET_GUINT8 (data +13, 0xa5); /* Magic from StarOffice should be 0 ! */
BIFF_SET_GUINT16(data +12, 0); /* seems OK. */
BIFF_SET_GUINT8 (data +13, 0);
ms_biff_put_var_write (bp, data, 14);
biff_put_text (bp, "Arial", eBiffV7, TRUE);
......@@ -536,13 +553,15 @@ write_formats (BIFF_PUT *bp, WORKBOOK *wb)
guint8 data[64];
int lp;
for (lp=0;lp<5;lp++) { /* FIXME: Magic minimum fonts */
for (lp=0;lp<8;lp++) { /* FIXME: Magic minimum formats */
formats->StyleFormat_to_idx = g_hash_table_new (g_direct_hash,
g_direct_equal);
/* Kludge for now ... */
ms_biff_put_var_next (bp, BIFF_FORMAT);
BIFF_SET_GUINT16 (data, 0);
ms_biff_put_var_write (bp, data, 2);
biff_put_text (bp, "0", eBiffV7, TRUE);
ms_biff_put_commit (bp);
......@@ -566,7 +585,7 @@ formats_free (FORMATS *formats)
}
}
#define XF_MAGIC 0
#define XF_MAGIC 15
/* See S59E1E.HTM */
static void
......@@ -586,14 +605,14 @@ write_xf_record (BIFF_PUT *bp, Style *style, eBiff_version ver)
if (ver >= eBiffV8) {
BIFF_SET_GUINT16(data+0, fonts_get_index (0, 0));
BIFF_SET_GUINT16(data+2, formats_get_index (0, 0));
BIFF_SET_GUINT16(data+18, (PALETTE_WHITE<<7) + PALETTE_WHITE);
BIFF_SET_GUINT16(data+18, 0xc020); /* Color ! */
ms_biff_put_var_write (bp, data, 24);
} else {
BIFF_SET_GUINT16(data+0, fonts_get_index (0, 0));
BIFF_SET_GUINT16(data+2, formats_get_index (0, 0));
BIFF_SET_GUINT16(data+4, 0xfff5); /* FIXME: Magic */
BIFF_SET_GUINT16(data+6, 0xf420);
BIFF_SET_GUINT16(data+8, (PALETTE_WHITE<<7) + PALETTE_WHITE);
BIFF_SET_GUINT16(data+8, 0xc020); /* Color ! */
ms_biff_put_var_write (bp, data, 16);
}
ms_biff_put_commit (bp);
......@@ -607,15 +626,15 @@ static XF *
write_xf (BIFF_PUT *bp, WORKBOOK *wb)
{
int lp;
guint32 style_magic[6] = { 0xff038010, 0xff068011, 0xff058012, 0xff048013,
0xff008000, 0xff078014 };
guint32 style_magic[6] = { 0xff038010, 0xff068011, 0xff048012, 0xff078013,
0xff008000, 0xff058014 };
/* FIXME: Scan through all the Styles... */
XF *xf = g_new (XF, 1);
xf->Style_to_idx = g_hash_table_new (g_direct_hash,
g_direct_equal);
/* Need at least 16 apparently */
for (lp=0;lp<16;lp++)
for (lp=0;lp<21;lp++)
write_xf_record (bp, NULL, wb->ver);
/* See: S59DEA.HTM */
......@@ -675,7 +694,7 @@ write_value (BIFF_PUT *bp, Value *v, eBiff_version ver,
}
case VALUE_FLOAT:
{
if (ver >= eBiffV8) { /* See: S59DAC.HTM */
if (ver >= eBiffV7) { /* See: S59DAC.HTM */
guint8 *data =ms_biff_put_len_next (bp, BIFF_NUMBER, 14);
EX_SETROW(data, row);
EX_SETCOL(data, col);
......@@ -704,7 +723,7 @@ write_value (BIFF_PUT *bp, Value *v, eBiff_version ver,
if (ver >= eBiffV8); /* Use SST stuff in fulness of time */
/* See: S59DDC.HTM */
ms_biff_put_var_next (bp, BIFF_RSTRING);
ms_biff_put_var_next (bp, BIFF_LABEL);
EX_SETXF (data, xf);
EX_SETCOL(data, col);
EX_SETROW(data, row);
......@@ -788,12 +807,12 @@ write_sheet_bools (BIFF_PUT *bp, SHEET *sheet)
/* See: S59DCF.HTM */
data = ms_biff_put_len_next (bp, BIFF_PRINTGRIDLINES, 2);
BIFF_SET_GUINT16 (data, 0x0001);
BIFF_SET_GUINT16 (data, 0x0000);
ms_biff_put_commit (bp);
/* See: S59D91.HTM */
data = ms_biff_put_len_next (bp, BIFF_GRIDSET, 2);
BIFF_SET_GUINT16 (data, 0x0000);
BIFF_SET_GUINT16 (data, 0x0001);
ms_biff_put_commit (bp);
/* See: S59D92.HTM ( Gutters ) */
......@@ -809,7 +828,7 @@ write_sheet_bools (BIFF_PUT *bp, SHEET *sheet)
/* See: S59D6B.HTM */
data = ms_biff_put_len_next (bp, BIFF_COUNTRY, 4);
BIFF_SET_GUINT32 (data, 0x002f0001); /* Made in the USA */
BIFF_SET_GUINT32 (data, 0x002c0001); /* Made in the UK */
ms_biff_put_commit (bp);
/* See: S59E1C.HTM */
......@@ -854,49 +873,52 @@ write_sheet_bools (BIFF_PUT *bp, SHEET *sheet)
/* See: S59D73.HTM */
data = ms_biff_put_len_next (bp, BIFF_DEFCOLWIDTH, 2);
BIFF_SET_GUINT16 (data, 0x0080);
BIFF_SET_GUINT16 (data, 0x0008);
ms_biff_put_commit (bp);
/* See: S59D76.HTM */
if (sheet->wb->ver >= eBiffV8) {
data = ms_biff_put_len_next (bp, BIFF_DIMENSIONS, 14);
BIFF_SET_GUINT32 (data + 0, 0);
BIFF_SET_GUINT32 (data + 4, sheet->gnum_sheet->max_row_used+1);
BIFF_SET_GUINT32 (data + 4, sheet->gnum_sheet->max_row_used);
BIFF_SET_GUINT16 (data + 8, 0);
BIFF_SET_GUINT16 (data + 10, sheet->gnum_sheet->max_col_used+1);
BIFF_SET_GUINT16 (data + 12, 0x0000);
} else {
data = ms_biff_put_len_next (bp, BIFF_DIMENSIONS, 10);
BIFF_SET_GUINT16 (data + 0, 0);
BIFF_SET_GUINT16 (data + 2, sheet->gnum_sheet->max_row_used+1);
BIFF_SET_GUINT16 (data + 2, sheet->gnum_sheet->max_row_used);
BIFF_SET_GUINT16 (data + 4, 0);
BIFF_SET_GUINT16 (data + 6, sheet->gnum_sheet->max_col_used+1);
BIFF_SET_GUINT16 (data + 8, 0x0000);
}
ms_biff_put_commit (bp);
/* See: S59D67.HTM */
data = ms_biff_put_len_next (bp, BIFF_COLINFO, 11);
BIFF_SET_GUINT16 (data+ 0, 0x00); /* 1st col formatted */
BIFF_SET_GUINT16 (data+ 2, 0x00); /* last col formatted */
BIFF_SET_GUINT16 (data+ 4, 0x0b9b); /* width */
BIFF_SET_GUINT16 (data+ 6, 0x0f); /* XF index */
BIFF_SET_GUINT16 (data+ 8, 0x00); /* options */
BIFF_SET_GUINT8 (data+10, 0x00); /* zero */
ms_biff_put_commit (bp);
if (0) {
/* See: S59D67.HTM */
data = ms_biff_put_len_next (bp, BIFF_COLINFO, 11);
BIFF_SET_GUINT16 (data+ 0, 0x00); /* 1st col formatted */
BIFF_SET_GUINT16 (data+ 2, 0x00); /* last col formatted */
BIFF_SET_GUINT16 (data+ 4, 0x0b9b); /* width */
BIFF_SET_GUINT16 (data+ 6, 0x0f); /* XF index */
BIFF_SET_GUINT16 (data+ 8, 0x00); /* options */
BIFF_SET_GUINT8 (data+10, 0x00); /* zero */
ms_biff_put_commit (bp);
}
/* See: S59DDB.HTM */
data = ms_biff_put_len_next (bp, BIFF_ROW, 16);
BIFF_SET_GUINT16 (data + 0, 0); /* Row number */
BIFF_SET_GUINT16 (data + 2, 0); /* first def. col */
BIFF_SET_GUINT16 (data + 4, 0+1); /* last def. col */
BIFF_SET_GUINT16 (data + 6, 0xff); /* height */
BIFF_SET_GUINT16 (data + 8, 0x00); /* undocumented */
BIFF_SET_GUINT16 (data + 10, 0x00); /* reserved */
BIFF_SET_GUINT16 (data + 12, 0x0100); /* options */
BIFF_SET_GUINT16 (data + 14, 0x00f0); /* magic so far */
ms_biff_put_commit (bp);
if (0) {
/* See: S59DDB.HTM */
data = ms_biff_put_len_next (bp, BIFF_ROW, 16);
BIFF_SET_GUINT16 (data + 0, 0); /* Row number */
BIFF_SET_GUINT16 (data + 2, 0); /* first def. col */
BIFF_SET_GUINT16 (data + 4, 0+1); /* last def. col */
BIFF_SET_GUINT16 (data + 6, 0xff); /* height */
BIFF_SET_GUINT16 (data + 8, 0x00); /* undocumented */
BIFF_SET_GUINT16 (data + 10, 0x00); /* reserved */
BIFF_SET_GUINT16 (data + 12, 0x0100); /* options */
BIFF_SET_GUINT16 (data + 14, 0x00f0); /* magic so far */
ms_biff_put_commit (bp);
}
}
static void
......
......@@ -11,9 +11,7 @@
#include "ms-biff.h"
#include "ms-excel-biff.h"
typedef struct _MS_EXCEL_WORKBOOK
{
Workbook *gnum_wb;
} MS_EXCEL_WORKBOOK;
extern int ms_excel_write_workbook (MS_OLE *file, Workbook *wb,
eBiff_version ver);
#endif
......@@ -703,7 +703,7 @@ make_function (PARSE_LIST **stack, int fn_idx, int numargs)
/**
* Parse that RP Excel formula, see S59E2B.HTM
* Return a dynamicaly allocated string containing the formula, never NULL
* Return a dynamicly allocated ExprTree containing the formula, or NULL
**/
ExprTree *
ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
......@@ -960,7 +960,15 @@ ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
tr = ms_excel_sheet_shared_formula (sheet, top_left_col,
top_left_row,
fn_col, fn_row) ;
if (!tr) tr = expr_tree_string ("");
if (!tr)
return NULL;
#if 0
{
printf("Missing shared formula from [%d,%d] in [%d,%d]\n",
top_left_col, top_left_row, fn_col, fn_row) ;
tr = expr_tree_string ("");
}
#endif