Commit 3392ee76 authored by Jody Goldberg's avatar Jody Goldberg

- Add support for F4 key while editing references.

- Add boundary checking for copy/autofill
- Correct handling of cut/paste relative references.

There are still problems with insert/del row/col and references to the
moved region.
parent 16fce830
1999-08-15 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : Don't free empty cells
in OPER_CONCAT.
1999-08-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_release) : Use the original
row/col to calculate offsets when pasting cells that relocate
references.
(clipboard_copy_cell_range) : Handle relocation.
* src/expr.c (do_expr_decode_tree) : Duplicate the error message
because someone is going to free it.
(expr_relocate) : New Function.
* src/cell.c (cell_relocate) : Use expr_relocate.
(cell_copy) : Don't NULL out the row/col/sheet
in the copied cell. It gets reset on entry and is useful
information.
(paste_cell) : Handle relocate.
(clipboard_copy_cell_range) : Ditto.
* cell.h : Differentiate CELL_COPY_TYPE_CELL into
CELL_COPY_TYPE_CELL_ABSOLUTE or CELL_COPY_TYPE_CELL_RELATIVE,
to deal with cut vs paste.
* src/sheet-autofill.c : Use cell_relocate to test for out of bounds.
1999-08-14 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (wb_edit_key_pressed) : Support F4 toggling
abs/relative.
* src/expr.h : Constify FunctionDefinition.
* src/fn-information.c : Use 'Red' instead of 'red' to match XL.
* src/func.c (function_get_category, fn_def_init,
function_add_nodes, function_add_args) : Constify.
1999-08-15 Morten Welinder <terra@diku.dk>
* src/fn-stat.c (gnumeric_frequency): Fix leak (bin_array). Fix
......
......@@ -25,10 +25,15 @@ Jody:
* Added EOMONTH, WORKDAY, NETWORKDAYS.
* Work on functions : ROW, COLUMN, ISLOGICAL, ISERR, ISBLANK,
DATEVALUE
* Support implict intersection 'feature' of XL for functions, not
operators.
* Support implict intersection 'feature' of XL for functions,
NOT operators.
* Support Ctrl-Arrow movement & selection. Make moving corner of
selection visible.
* Support F4 switching between absolute and relative addressing
modes
* Reworked internal handling of absolute/relative addressing.
* Fixed cut/copy/paste to relocate relative references to only
when copying not cuting.
Jay:
......
1999-08-15 Jody Goldberg <jgoldberg@home.com>
* src/expr.c (eval_expr_real) : Don't free empty cells
in OPER_CONCAT.
1999-08-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_release) : Use the original
row/col to calculate offsets when pasting cells that relocate
references.
(clipboard_copy_cell_range) : Handle relocation.
* src/expr.c (do_expr_decode_tree) : Duplicate the error message
because someone is going to free it.
(expr_relocate) : New Function.
* src/cell.c (cell_relocate) : Use expr_relocate.
(cell_copy) : Don't NULL out the row/col/sheet
in the copied cell. It gets reset on entry and is useful
information.
(paste_cell) : Handle relocate.
(clipboard_copy_cell_range) : Ditto.
* cell.h : Differentiate CELL_COPY_TYPE_CELL into
CELL_COPY_TYPE_CELL_ABSOLUTE or CELL_COPY_TYPE_CELL_RELATIVE,
to deal with cut vs paste.
* src/sheet-autofill.c : Use cell_relocate to test for out of bounds.
1999-08-14 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (wb_edit_key_pressed) : Support F4 toggling
abs/relative.
* src/expr.h : Constify FunctionDefinition.
* src/fn-information.c : Use 'Red' instead of 'red' to match XL.
* src/func.c (function_get_category, fn_def_init,
function_add_nodes, function_add_args) : Constify.
1999-08-15 Morten Welinder <terra@diku.dk>
* src/fn-stat.c (gnumeric_frequency): Fix leak (bin_array). Fix
......
......@@ -25,10 +25,6 @@ Gnumeric Spread Sheet task list
* Cell editing
* Pressing F4 when editing a cell formula, should switch a cell
reference in the following cycle:
A4 -> $A$4 -> $A4 -> A$4 -> A4
* Support for entering multiline cells, and <Alt-Enter> adding an
embedded newline.
......
1999-08-15 Jody Goldberg <jgoldberg@home.com>
* ms-excel-write.c (write_value) : Add support for VALUE_BOOLEAN,
VALUE_ERROR, VALUE_EMPTY.
(write_formula) : Ditto.
* ms-formula-write.c (write_node) : Ditto.
1999-08-15 Morten Welinder <terra@diku.dk>
* ms-excel-read.c (ms_excel_read_workbook): First use, then
......
......@@ -756,12 +756,60 @@ xf_free (XF *xf)
}
}
int
ms_excel_write_map_errcode (Value const * const v)
{
char const * const mesg = v->v.error.mesg->str;
if (!strcmp (gnumeric_err_NULL, mesg))
return 0;
if (!strcmp (gnumeric_err_DIV0, mesg))
return 7;
if (!strcmp (gnumeric_err_VALUE, mesg))
return 15;
if (!strcmp (gnumeric_err_REF, mesg))
return 23;
if (!strcmp (gnumeric_err_NAME, mesg))
return 29;
if (!strcmp (gnumeric_err_NUM, mesg))
return 36;
if (!strcmp (gnumeric_err_NA, mesg))
return 42;
/* Map non-excel errors to #!NAME */
return 29;
}
static void
write_value (BiffPut *bp, Value *v, eBiff_version ver,
guint32 col, guint32 row, guint16 xf)
{
switch (v->type) {
case VALUE_EMPTY:
{
guint8 *data = ms_biff_put_len_next (bp, (0x200 | BIFF_BLANK), 6);
EX_SETROW(data, row);
EX_SETCOL(data, col);
EX_SETXF (data, xf);
break;
}
case VALUE_BOOLEAN:
case VALUE_ERROR:
{
guint8 *data = ms_biff_put_len_next (bp, (0x200 | BIFF_BOOLERR), 8);
EX_SETROW(data, row);
EX_SETCOL(data, col);
EX_SETXF (data, xf);
if (v->type == VALUE_ERROR) {
MS_OLE_SET_GUINT8 (data + 6, ms_excel_write_map_errcode (v));
MS_OLE_SET_GUINT8 (data + 7, 1); /* Mark as a err */
} else {
MS_OLE_SET_GUINT8 (data + 6, v->v.v_bool ? 1 : 0);
MS_OLE_SET_GUINT8 (data + 7, 0); /* Mark as a bool */
}
ms_biff_put_commit (bp);
break;
}
case VALUE_INTEGER:
{
int_t vint = v->v.v_int;
......@@ -856,27 +904,56 @@ write_formula (BiffPut *bp, ExcelSheet *sheet, Cell *cell)
guint32 len;
gboolean string_result = FALSE;
gint col, row;
Value *v;
g_return_if_fail (bp);
g_return_if_fail (cell);
g_return_if_fail (sheet);
g_return_if_fail (cell->parsed_node);
g_return_if_fail (cell->value);
col = cell->col->pos;
row = cell->row->pos;
v = cell->value;
/* See: S59D8F.HTM */
ms_biff_put_var_next (bp, BIFF_FORMULA);
EX_SETROW (data, row);
EX_SETCOL (data, col);
EX_SETXF (data, XF_MAGIC);
if (cell->value && VALUE_IS_NUMBER (cell->value))
BIFF_SETDOUBLE (data + 6, value_get_as_float (cell->value));
else { /* FIXME: Need special cases for BOOLERR & BOOLEAN */
switch (v->type) {
case VALUE_INTEGER :
case VALUE_FLOAT :
BIFF_SETDOUBLE (data + 6, value_get_as_float (v));
break;
case VALUE_STRING :
MS_OLE_SET_GUINT32 (data + 6, 0x00000000);
MS_OLE_SET_GUINT32 (data + 10, 0xffff0000);
string_result = TRUE;
break;
case VALUE_BOOLEAN :
MS_OLE_SET_GUINT32 (data + 6,
(v->v.v_bool ? 0x100 : 0x0) | 0x00000001);
MS_OLE_SET_GUINT32 (data + 10, 0xffff0000);
break;
case VALUE_ERROR :
MS_OLE_SET_GUINT32 (data + 6,
0x00000002 | (ms_excel_write_map_errcode (v) << 8));
MS_OLE_SET_GUINT32 (data + 10, 0xffff0000);
break;
case VALUE_EMPTY :
MS_OLE_SET_GUINT32 (data + 6, 0x00000003);
MS_OLE_SET_GUINT32 (data + 10, 0xffff0000);
break;
default :
g_warning ("Unhandled value->type (%d) in excel::write_formula", v->type);
}
MS_OLE_SET_GUINT16 (data + 14, 0x0); /* Always calc & on load */
MS_OLE_SET_GUINT32 (data + 16, 0x0);
MS_OLE_SET_GUINT16 (data + 20, 0x0);
......@@ -892,10 +969,9 @@ write_formula (BiffPut *bp, ExcelSheet *sheet, Cell *cell)
if (string_result) {
gchar *str;
g_return_if_fail (cell->value);
ms_biff_put_var_next (bp, 0x200|BIFF_STRING);
str = value_get_as_string (cell->value);
str = value_get_as_string (v);
biff_put_text (bp, str, eBiffV7, TRUE, SIXTEEN_BIT);
g_free (str);
ms_biff_put_commit (bp);
......
......@@ -71,4 +71,7 @@ extern int
biff_put_text (BiffPut *bp, char *txt, eBiff_version ver,
gboolean write_len, PutType how);
extern int
ms_excel_write_map_errcode (Value const * const v);
#endif
......@@ -1122,10 +1122,10 @@ ms_excel_parse_formula (ExcelWorkbook *wb, ExcelSheet *sheet, guint8 const *mem,
/* FIXME : We need to revisit this when operator % is
* available */
ExprTree * hundred =
expr_tree_new_constant (value_new_int (100));
expr_tree_new_constant (value_new_float (.01));
parse_list_push (&stack,
expr_tree_new_binary (parse_list_pop (&stack),
OPER_DIV,
OPER_MULT,
hundred));
break;
}
......@@ -1135,8 +1135,8 @@ ms_excel_parse_formula (ExcelWorkbook *wb, ExcelSheet *sheet, guint8 const *mem,
ptg_length = 0 ;
break ;
case FORMULA_PTG_MISSARG: /* FIXME: Need Null Arg. type. */
parse_list_push_raw (&stack, value_new_string (""));
case FORMULA_PTG_MISSARG:
parse_list_push_raw (&stack, value_new_empty ());
ptg_length = 0 ;
break ;
......
......@@ -411,6 +411,31 @@ write_node (PolishData *pd, ExprTree *tree)
ms_biff_put_var_write (pd->bp, data, 9);
break;
}
case VALUE_BOOLEAN:
{
guint8 data[2];
MS_OLE_SET_GUINT8 (data, FORMULA_PTG_NUM);
MS_OLE_SET_GUINT8 (data+1, v->v.v_bool ? 1 : 0);
ms_biff_put_var_write (pd->bp, data, 2);
break;
}
case VALUE_ERROR:
{
guint8 data[2];
MS_OLE_SET_GUINT8 (data, FORMULA_PTG_ERR);
MS_OLE_SET_GUINT8 (data+1, ms_excel_write_map_errcode (v));
ms_biff_put_var_write (pd->bp, data, 2);
break;
}
case VALUE_EMPTY:
{
guint8 data = FORMULA_PTG_MISSARG;
ms_biff_put_var_write (pd->bp, &data, 1);
break;
}
case VALUE_STRING:
write_string (pd, v->v.str->str);
break;
......
......@@ -89,15 +89,15 @@ typedef struct {
char *output;
} translate_t;
static translate_t translate_table[] = {
{ "general", "G" },
{ "General", "G" },
{ "0", "F0" },
{ "#,##0", ",0" },
{ "0.00", "F2" },
{ "#,##0.00", ",2" },
{ "$#,##0_);($#,##0)", "C0" },
{ "$#,##0_);[red]($#,##0)", "C0-" },
{ "$#,##0_);[Red]($#,##0)", "C0-" },
{ "$#,##0.00_);($#,##0.00)", "C2" },
{ "$#,##0.00_);[red]($#,##0.00)", "C2-" },
{ "$#,##0.00_);[Red]($#,##0.00)", "C2-" },
{ "0%", "P0" },
{ "0.00%", "P2" },
{ "0.00e+00", "S2" },
......
msgid ""
msgstr ""
"POT-Creation-Date: 1999-08-16 00:59+0200\n"
"POT-Creation-Date: 1999-08-16 02:38-0400\n"
"Content-Type: text/plain; charset=iso8859-2\n"
"Date: 1998-09-30 00:38:13-0500\n"
"From: Petr Vyyhnalek <petr.vyhnalek@email.cz>\n"
......@@ -620,7 +620,7 @@ msgid "Left"
msgstr "Vlevo"
#: src/dialog-cell-format.c:362 src/dialog-cell-format.c:371
#: src/workbook.c:1118
#: src/workbook.c:1120
msgid "Center"
msgstr "Doprosed"
......@@ -731,7 +731,7 @@ msgstr ""
msgid "Need at least one clause"
msgstr ""
#: src/dialog-cell-sort.c:314 src/workbook.c:1393
#: src/dialog-cell-sort.c:314 src/workbook.c:1477
msgid "Selection must be a single range"
msgstr ""
......@@ -1027,11 +1027,11 @@ msgstr "Procenta"
msgid "bool"
msgstr ""
#: src/dialog-solver.c:41 src/workbook.c:1503
#: src/dialog-solver.c:41 src/workbook.c:1587
msgid "Max"
msgstr ""
#: src/dialog-solver.c:42 src/workbook.c:1502
#: src/dialog-solver.c:42 src/workbook.c:1586
msgid "Min"
msgstr ""
......@@ -1190,7 +1190,7 @@ msgstr "
msgid "Unknown operator"
msgstr "Neznm chyba pi vpotu"
#: src/expr.c:1130
#: src/expr.c:1132
msgid "Unknown evaluation error"
msgstr "Neznm chyba pi vpotu"
......@@ -4959,11 +4959,11 @@ msgstr ""
msgid "$#,##0.00_);[Red]($#,##0.00)"
msgstr "#,##0.00_);[red](#,##0.00)"
#: src/func.c:421
#: src/func.c:424
msgid "Function does not exist"
msgstr ""
#: src/func.c:423
#: src/func.c:426
msgid "Calling non-function"
msgstr ""
......@@ -5100,7 +5100,7 @@ msgid ""
"the contents in this region?"
msgstr ""
#: src/item-cursor.c:580 src/item-grid.c:600 src/workbook.c:1106
#: src/item-cursor.c:580 src/item-grid.c:600 src/workbook.c:1108
msgid "Copy"
msgstr "Kopie"
......@@ -5132,11 +5132,11 @@ msgstr "Posu
msgid "Shift cells right and move"
msgstr "Posu buky doprava a pesu"
#: src/item-grid.c:599 src/workbook.c:1103
#: src/item-grid.c:599 src/workbook.c:1105
msgid "Cut"
msgstr "Vyjmout"
#: src/item-grid.c:601 src/workbook.c:1109
#: src/item-grid.c:601 src/workbook.c:1111
msgid "Paste"
msgstr "Vloit"
......@@ -5346,17 +5346,17 @@ msgstr "Kopie"
msgid "cut"
msgstr "Vyjmout"
#: src/sheet.c:3058
#: src/sheet.c:3065
#, fuzzy
msgid "paste"
msgstr "Vloit"
#: src/sheet.c:4071
#: src/sheet.c:4078
#, c-format
msgid "I was not able to activate object %s"
msgstr ""
#: src/sheet.c:4083
#: src/sheet.c:4090
msgid "I was unable to the bind object"
msgstr ""
......@@ -5388,7 +5388,7 @@ msgstr ""
msgid "#N/A"
msgstr ""
#: src/widget-font-selector.c:118 src/workbook.c:1126
#: src/widget-font-selector.c:118 src/workbook.c:1128
msgid "Bold"
msgstr "Tun"
......@@ -5396,479 +5396,479 @@ msgstr "Tu
msgid "Bold italic"
msgstr ""
#: src/widget-font-selector.c:120 src/workbook.c:1129
#: src/widget-font-selector.c:120 src/workbook.c:1131
msgid "Italic"
msgstr "Kurzva"
#: src/workbook.c:443
#: src/workbook.c:445
msgid "Warning"
msgstr ""
#: src/workbook.c:451
#: src/workbook.c:453
#, c-format
msgid "Workbook %s has unsaved changes, save them?"
msgstr ""
#: src/workbook.c:454
#: src/workbook.c:456
msgid "Workbook has unsaved changes, save them?"
msgstr ""
#: src/workbook.c:653
#: src/workbook.c:655
#, fuzzy
msgid "Insert cols"
msgstr "Vlo buky"
#: src/workbook.c:672
#: src/workbook.c:674
msgid "Insert rows"
msgstr "Vlo dky"
#: src/workbook.c:768
#: src/workbook.c:770
msgid ">mm/dd/yyyy"
msgstr ""
#: src/workbook.c:787
#: src/workbook.c:789
msgid ">hh:mm"
msgstr ""
#: src/workbook.c:895
#: src/workbook.c:897
msgid "_New"
msgstr "_Nov"
#: src/workbook.c:895
#: src/workbook.c:897
#, fuzzy
msgid "Create a new spreadsheet"
msgstr "Vytvo nov list"
#: src/workbook.c:899
#: src/workbook.c:901
#, fuzzy
msgid "_Import"
msgstr "F_ormt"
#: src/workbook.c:899
#: src/workbook.c:901
#, fuzzy
msgid "Imports a file"
msgstr "Otevt soubor"
#: src/workbook.c:905
#: src/workbook.c:907
msgid "Su_mmary..."
msgstr ""
#: src/workbook.c:905
#: src/workbook.c:907
msgid "Summary information"
msgstr ""
#: src/workbook.c:910
#: src/workbook.c:912
msgid "Plu_g-ins..."
msgstr ""
#: src/workbook.c:910
#: src/workbook.c:912
#, fuzzy
msgid "Gnumeric plugins"
msgstr "Gnumeric"
#: src/workbook.c:931
#: src/workbook.c:933
msgid "_All"
msgstr "Ve"
#: src/workbook.c:932
#: src/workbook.c:934
msgid "Clear the selected cells' formats, comments, and contents"
msgstr ""
#: src/workbook.c:934
#: src/workbook.c:936
msgid "_Formats"
msgstr "_Formty"
#: src/workbook.c:935
#: src/workbook.c:937
msgid "Clear the selected cells' formats"
msgstr ""
#: src/workbook.c:936
#: src/workbook.c:938
msgid "_Comments"
msgstr ""
#: src/workbook.c:937
#: src/workbook.c:939
#, fuzzy
msgid "Clear the selected cells' comments"
msgstr "Vycentruje buku"
#: src/workbook.c:938
#: src/workbook.c:940
msgid "_Content"
msgstr ""
#: src/workbook.c:939
#: src/workbook.c:941
#, fuzzy
msgid "Clear the selected cells' contents"
msgstr "Vycentruje buku"
#: src/workbook.c:947
#: src/workbook.c:949
#, fuzzy
msgid "P_aste special..."
msgstr "Vloit jinak"
#: src/workbook.c:948
#: src/workbook.c:950
msgid "C_lear"
msgstr "Vymazat"
#: src/workbook.c:949
#: src/workbook.c:951
msgid "Clear the selected cell(s)"
msgstr ""
#: src/workbook.c:953
#: src/workbook.c:955
msgid "_Select All"
msgstr "Vybrat ve"
#: src/workbook.c:954
#: src/workbook.c:956
msgid "Select all cells in the spreadsheet"
msgstr ""
#: src/workbook.c:956
#: src/workbook.c:958
#, fuzzy
msgid "_Goto cell..."
msgstr "Jdi na buku.."
#: src/workbook.c:957
#: src/workbook.c:959
msgid "Jump to a specified cell"
msgstr ""
#: src/workbook.c:963
#: src/workbook.c:965
msgid "Insert object..."
msgstr ""
#: src/workbook.c:964
#: src/workbook.c:966
#, fuzzy
msgid "Inserts a Bonobo object"
msgstr "Vytvo ru"
#: src/workbook.c:971
#: src/workbook.c:973
#, fuzzy
msgid "_Define cell names"
msgstr "Smazn bunk"
#: src/workbook.c:975
#: src/workbook.c:977
#, fuzzy
msgid "_Recalculate"
msgstr "Pepotat"
#: src/workbook.c:976
#: src/workbook.c:978
msgid "Recalculate the spreadsheet"
msgstr ""
#: src/workbook.c:984
#: src/workbook.c:986
msgid "_Zoom..."
msgstr "Mtko..."
#: src/workbook.c:985
#: src/workbook.c:987
msgid "Zoom the spreadsheet in or out"
msgstr ""
#: src/workbook.c:992
#: src/workbook.c:994
#, fuzzy
msgid "Current _date"
msgstr "Dnen datum"
#: src/workbook.c:993
#: src/workbook.c:995
msgid "Insert the current data into the selected cell(s)"
msgstr ""
#: src/workbook.c:996
#: src/workbook.c:998
#, fuzzy
msgid "Current _time"
msgstr "Souasn as"
#: src/workbook.c:997
#: src/workbook.c:999
msgid "Insert the current time into the selected cell(s)"
msgstr ""
#: src/workbook.c:1004 src/workbook.c:1050
#: src/workbook.c:1006 src/workbook.c:1052
msgid "_Sheet"
msgstr "List"
#: src/workbook.c:1004
#: src/workbook.c:1006
#, fuzzy
msgid "Insert a new spreadsheet"
msgstr "Vytvo nov list"
#: src/workbook.c:1006 src/workbook.c:1044
#: src/workbook.c:1008 src/workbook.c:1046
msgid "_Cells..."
msgstr "Buky..."
#: src/workbook.c:1006
#: src/workbook.c:1008
#, fuzzy
msgid "Insert new cells"
msgstr "Vlo buky"
#: src/workbook.c:1008
#: src/workbook.c:1010
msgid "_Rows"
msgstr "dky"
#: src/workbook.c:1008
#: src/workbook.c:1010
#, fuzzy
msgid "Insert new rows"
msgstr "Vlo dky"
#: src/workbook.c:1010
#: src/workbook.c:1012
msgid "C_olumns"
msgstr "Sloupce"
#: src/workbook.c:1010
#: src/workbook.c:1012
#, fuzzy
msgid "Insert new columns"
msgstr "Vlo sloupec(e)"
#: src/workbook.c:1015
#: src/workbook.c:1017
msgid "_Add/modify comment..."
msgstr ""
#: src/workbook.c:1016
#: src/workbook.c:1018
msgid "Edit the selected cell's comment"
msgstr ""
#: src/workbook.c:1017
#: src/workbook.c:1019
#, fuzzy
msgid "_Special"
msgstr "Zvltnosti"
#: src/workbook.c:1026 src/workbook.c:1032
#: src/workbook.c:1028 src/workbook.c:1034
msgid "_Autoadjust"
msgstr ""
#: src/workbook.c:1027
#: src/workbook.c:1029
msgid "_Width"
msgstr "ka"
#: src/workbook.c:1033
#: src/workbook.c:1035
msgid "_Height"
msgstr "Dlka" </