Commit daeece83 authored by Michael Meeks's avatar Michael Meeks

Excel string writing back in some sort of shape.

parent e33da796
1999-07-08 Michael Meeks <michael@edenproject.org>
* src/func.c (function_iterate_do_value): Fix for NULL CellRef
Sheet *, fallback to EvalPosition's Sheet *
* src/fn-math.c (gnumeric_countif): ditto.
* src/fn-math.c (gnumeric_seriessum): Add check for NULL nodes
pointer.
1999-07-08 Jody Goldberg <jgoldberg@home.com>
* src/cell-draw.c (cell_split_text) : Honour embedded newlines.
......
1999-07-08 Michael Meeks <michael@edenproject.org>
* src/func.c (function_iterate_do_value): Fix for NULL CellRef
Sheet *, fallback to EvalPosition's Sheet *
* src/fn-math.c (gnumeric_countif): ditto.
* src/fn-math.c (gnumeric_seriessum): Add check for NULL nodes
pointer.
1999-07-08 Jody Goldberg <jgoldberg@home.com>
* src/cell-draw.c (cell_split_text) : Honour embedded newlines.
......
1999-07-08 Michael Meeks <michael@edenproject.org>
* src/func.c (function_iterate_do_value): Fix for NULL CellRef
Sheet *, fallback to EvalPosition's Sheet *
* src/fn-math.c (gnumeric_countif): ditto.
* src/fn-math.c (gnumeric_seriessum): Add check for NULL nodes
pointer.
1999-07-08 Jody Goldberg <jgoldberg@home.com>
* src/cell-draw.c (cell_split_text) : Honour embedded newlines.
......
1999-07-08 Michael Meeks <michael@edenproject.org>
* src/func.c (function_iterate_do_value): Fix for NULL CellRef
Sheet *, fallback to EvalPosition's Sheet *
* src/fn-math.c (gnumeric_countif): ditto.
* src/fn-math.c (gnumeric_seriessum): Add check for NULL nodes
pointer.
1999-07-08 Jody Goldberg <jgoldberg@home.com>
* src/cell-draw.c (cell_split_text) : Honour embedded newlines.
......
1999-07-08 Michael Meeks <michael@edenproject.org>
* ms-excel-read.c (ms_excel_read_formula): Turn error into
warning.
* ms-excel-write.c (biff_put_text): Fiddled, this needs serious
fixing ...
* ms-excel-read.c (biff_name_data_get_name): Removed daft
debug churning out.
1999-07-08 Michael Meeks <michael@edenproject.org>
* ms-excel-read.h (_ExcelWorkbook): Removed internal_names and
......
......@@ -627,7 +627,6 @@ biff_name_data_get_name (ExcelSheet *sheet, guint16 idx)
bnd->type = BNDName;
g_free (bnd->v.store.data);
bnd->v.name = NULL;
printf ("Serious error parsing '%s'\n", bnd->name);
} else {
bnd->type = BNDName;
g_free (bnd->v.store.data);
......@@ -1549,8 +1548,8 @@ ms_excel_read_formula (BiffQuery *q, ExcelSheet *sheet)
* Docs say that there should be a STRING
* record here
*/
g_error ("Excel import error, "
"missing STRING record");
g_warning ("Excel import error, "
"missing STRING record");
}
}
......
......@@ -49,62 +49,73 @@ biff_put_text (BiffPut *bp, char *txt, eBiff_version ver,
guint8 data[BLK_LEN];
guint32 chunks, pos, lpc, lp, len, ans;
gboolean sixteen_bit_len;
gboolean unicode;
guint32 off;
g_return_val_if_fail (bp, 0);
g_return_val_if_fail (txt, 0);
len = strlen (txt);
/* printf ("Write '%s' len = %d\n", txt, len); */
if (how == AS_PER_VER) {
if (ver >= eBiffV8) { /* Write header & word length*/
data[0] = 0;
if (write_len) {
BIFF_SET_GUINT16(data+1, len);
ms_biff_put_var_write (bp, data, 3);
ans = len + 3;
} else {
ms_biff_put_var_write (bp, data, 1);
ans = len;
}
} else { /* Byte length */
if (write_len) {
g_return_val_if_fail (len<256, 0);
BIFF_SET_GUINT8(data, len);
ms_biff_put_var_write (bp, data, 1);
ans = len + 1;
} else
ans = len;
if ((how == AS_PER_VER &&
ver >= eBiffV8) ||
how == SIXTEEN_BIT)
sixteen_bit_len = TRUE;
else
sixteen_bit_len = FALSE; /* 8 bit */
if (ver >= eBiffV8)
unicode = TRUE;
else
unicode = FALSE;
off = 0;
if (write_len)
if (sixteen_bit_len) {
BIFF_SET_GUINT16 (data, len);
off = 2;
} else {
g_return_val_if_fail (len<256, 0);
BIFF_SET_GUINT8 (data, len);
off = 1;
}
} else if (how == EIGHT_BIT) {
BIFF_SET_GUINT8(data, len);
ms_biff_put_var_write (bp, data, 1);
ans = len + 1;
} else if (how == SIXTEEN_BIT) {
BIFF_SET_GUINT16(data, len);
ms_biff_put_var_write (bp, data, 2);
ans = len + 2;
if (unicode) {
BIFF_SET_GUINT8 (data + off, 0x0);
off++;
}
ms_biff_put_var_write (bp, data, off);
/* You got it coming */
for (lp=0; lp<len;lp++) {
BIFF_SET_GUINT16 (data, txt[lp]);
ms_biff_put_var_write (bp, data, unicode?2:1);
}
return off + len*(unicode?2:1);
/* An attempt at efficiency */
chunks = len/BLK_LEN;
/* chunks = len/BLK_LEN;
pos = 0;
for (lpc=0;lpc<chunks;lpc++) {
for (lp=0;lp<BLK_LEN;lp++,pos++)
data[lp] = txt[pos];
/* data[BLK_LEN] = '\0';
printf ("Writing chunk '%s'\n", data); */
data[BLK_LEN] = '\0';
printf ("Writing chunk '%s'\n", data);
ms_biff_put_var_write (bp, data, BLK_LEN);
}
len = len-pos;
if (len > 0) {
for (lp=0;lp<len;lp++,pos++)
data[lp] = txt[pos];
/* data[lp] = '\0';
printf ("Writing chunk '%s'\n", data); */
data[lp] = '\0';
printf ("Writing chunk '%s'\n", data);
ms_biff_put_var_write (bp, data, lp);
}
/* ans is the length but do we need it ? */
ans is the length but do we need it ?
return ans;*/
#undef BLK_LEN
return ans;
}
/**
......
......@@ -493,6 +493,7 @@ gnumeric_countif (FunctionEvalInfo *ei, Value **argv)
{
Value *range = argv[0];
Value *tmpvalue = NULL;
Sheet *sheet;
math_criteria_t items;
int ret;
......@@ -515,8 +516,10 @@ gnumeric_countif (FunctionEvalInfo *ei, Value **argv)
tmpvalue = items.test_value;
}
if (!(sheet = range->v.cell_range.cell_a.sheet))
sheet = ei->pos.sheet;
ret = sheet_cell_foreach_range (
range->v.cell_range.cell_a.sheet, TRUE,
sheet, TRUE,
range->v.cell_range.cell_a.col,
range->v.cell_range.cell_a.row,
range->v.cell_range.cell_b.col,
......@@ -2274,7 +2277,10 @@ gnumeric_seriessum (FunctionEvalInfo *ei, GList *nodes)
n = value_get_as_int(val);
value_release (val);
nodes = nodes->next;
if (nodes == NULL)
return function_error (ei, gnumeric_err_NUM);
/* Get m */
tree = (ExprTree *) nodes->data;
......
......@@ -493,6 +493,7 @@ gnumeric_countif (FunctionEvalInfo *ei, Value **argv)
{
Value *range = argv[0];
Value *tmpvalue = NULL;
Sheet *sheet;
math_criteria_t items;
int ret;
......@@ -515,8 +516,10 @@ gnumeric_countif (FunctionEvalInfo *ei, Value **argv)
tmpvalue = items.test_value;
}
if (!(sheet = range->v.cell_range.cell_a.sheet))
sheet = ei->pos.sheet;
ret = sheet_cell_foreach_range (
range->v.cell_range.cell_a.sheet, TRUE,
sheet, TRUE,
range->v.cell_range.cell_a.col,
range->v.cell_range.cell_a.row,
range->v.cell_range.cell_b.col,
......@@ -2274,7 +2277,10 @@ gnumeric_seriessum (FunctionEvalInfo *ei, GList *nodes)
n = value_get_as_int(val);
value_release (val);
nodes = nodes->next;
if (nodes == NULL)
return function_error (ei, gnumeric_err_NUM);
/* Get m */
tree = (ExprTree *) nodes->data;
......
......@@ -76,22 +76,22 @@ iterate_cellrange_callback (Sheet *sheet, int col, int row, Cell *cell, void *us
* Helper routine for function_iterate_argument_values.
*/
int
function_iterate_do_value (const EvalPosition *fp,
function_iterate_do_value (const EvalPosition *ep,
FunctionIterateCallback callback,
void *closure,
Value *value,
ErrorMessage *error,
gboolean strict)
{
int eval_col = fp->eval_col;
int eval_row = fp->eval_row;
int eval_col = ep->eval_col;
int eval_row = ep->eval_row;
int ret = TRUE;
switch (value->type){
case VALUE_INTEGER:
case VALUE_FLOAT:
case VALUE_STRING:
ret = (*callback)(fp, value, error, closure);
ret = (*callback)(ep, value, error, closure);
break;
case VALUE_ARRAY:
......@@ -101,7 +101,7 @@ function_iterate_do_value (const EvalPosition *fp,
for (x = 0; x < value->v.array.x; x++) {
for (y = 0; y < value->v.array.y; y++) {
ret = function_iterate_do_value (
fp, callback, closure,
ep, callback, closure,
value->v.array.vals [x][y],
error, strict);
if (ret == FALSE)
......@@ -112,6 +112,7 @@ function_iterate_do_value (const EvalPosition *fp,
}
case VALUE_CELLRANGE: {
IterateCallbackClosure data;
Sheet *sheet;
int start_col, start_row, end_col, end_row;
data.callback = callback;
......@@ -127,8 +128,10 @@ function_iterate_do_value (const EvalPosition *fp,
eval_col, eval_row,
&end_col, &end_row);
if (!(sheet = value->v.cell_range.cell_a.sheet))
sheet = ep->sheet;
ret = sheet_cell_foreach_range (
value->v.cell_range.cell_a.sheet, TRUE,
sheet, TRUE,
start_col, start_row,
end_col, end_row,
iterate_cellrange_callback,
......
......@@ -493,6 +493,7 @@ gnumeric_countif (FunctionEvalInfo *ei, Value **argv)
{
Value *range = argv[0];
Value *tmpvalue = NULL;
Sheet *sheet;
math_criteria_t items;
int ret;
......@@ -515,8 +516,10 @@ gnumeric_countif (FunctionEvalInfo *ei, Value **argv)
tmpvalue = items.test_value;
}
if (!(sheet = range->v.cell_range.cell_a.sheet))
sheet = ei->pos.sheet;
ret = sheet_cell_foreach_range (
range->v.cell_range.cell_a.sheet, TRUE,
sheet, TRUE,
range->v.cell_range.cell_a.col,
range->v.cell_range.cell_a.row,
range->v.cell_range.cell_b.col,
......@@ -2274,7 +2277,10 @@ gnumeric_seriessum (FunctionEvalInfo *ei, GList *nodes)
n = value_get_as_int(val);
value_release (val);
nodes = nodes->next;
if (nodes == NULL)
return function_error (ei, gnumeric_err_NUM);
/* Get m */
tree = (ExprTree *) nodes->data;
......
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