Commit 2779b474 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

A few delayed patches.

These optimize paste, exit, sheet deletetion,
and start the process for fixing a few things.

2000-05-17  Jody Goldberg <jgoldberg@home.com>

	* src/clipboard.c (clipboard_copy_cell_range) : Adjust signature to
	  take a range.
	(sheet_paste_selection) : Export in preparation for adding undo.

	* src/commands.c (cmd_paste_copy) : Some initial work.  Not used or
	  complete.

	* src/parse-util.c (parse_text_value_or_expr) : Start passing in the
	  current format so that we can eventually attempt to match it before
	  trying all the others.

	* src/sheet.c (sheet_formulas_unlink) : New function.
	(sheet_destroy_contents) : Optimize.

	* src/dialogs/dialog-plugin-manager.c : Make a bit prettier.
	* src/dialogs/plugin-manager.glade : Ditto.

2000-05-16  Jody Goldberg <jgoldberg@home.com>

	* plugins/*/*.c : Rationalize the naming scheme.

2000-05-15  Jody Goldberg <jgoldberg@home.com>

	* src/eval.[ch] : Rename
	  cell_queue_recalc      -> eval_queue_cell
	  cell_queue_recalc_list -> eval_queue_list
	  cell_unqueue_recalc    -> eval_unqueue_cell
	(eval_unqueue_sheet) : New function.

	* src/sheet.c (sheet_cell_remove_simple) : Add precautionary removal
	  of cells from recalc list.  We should not need this in most
	  instances, but the check is inexpensive so I'll play it safe.
	(sheet_destroy_contents) : Batch cleanups rather than doing it cell by
	  cell.

	* src/cell.c (cell_make_value) : Fill in the implementation.

	* src/clipboard.c (paste_cell_flags) : Remove some dead code.
	  Merged in paste_cell and fixed handling of paste by value.

2000-05-14  Jody Goldberg <jgoldberg@home.com>

	* src/clipboard.c (paste_cell) : No need to call cell_content_changed
	  we can queue the recalc for the entire region later.  It is
	  sufficent to make the cell as changed with sheet_cell_changed.
	(paste_cell) : It is premature to redraw, we have no yet calculated
	  spans.  Redraw and respan at the range level, not the cell.
parent e000ba73
2000-05-17 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_cell_range) : Adjust signature to
take a range.
(sheet_paste_selection) : Export in preparation for adding undo.
* src/commands.c (cmd_paste_copy) : Some initial work. Not used or
complete.
* src/parse-util.c (parse_text_value_or_expr) : Start passing in the
current format so that we can eventually attempt to match it before
trying all the others.
* src/sheet.c (sheet_formulas_unlink) : New function.
(sheet_destroy_contents) : Optimize.
* src/dialogs/dialog-plugin-manager.c : Make a bit prettier.
* src/dialogs/plugin-manager.glade : Ditto.
2000-05-16 Jody Goldberg <jgoldberg@home.com>
* plugins/*/*.c : Rationalize the naming scheme.
2000-05-15 Jody Goldberg <jgoldberg@home.com>
* src/eval.[ch] : Rename
cell_queue_recalc -> eval_queue_cell
cell_queue_recalc_list -> eval_queue_list
cell_unqueue_recalc -> eval_unqueue_cell
(eval_unqueue_sheet) : New function.
* src/sheet.c (sheet_cell_remove_simple) : Add precautionary removal
of cells from recalc list. We should not need this in most
instances, but the check is inexpensive so I'll play it safe.
(sheet_destroy_contents) : Batch cleanups rather than doing it cell by
cell.
* src/cell.c (cell_make_value) : Fill in the implementation.
* src/clipboard.c (paste_cell_flags) : Remove some dead code.
Merged in paste_cell and fixed handling of paste by value.
2000-05-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (paste_cell) : No need to call cell_content_changed
we can queue the recalc for the entire region later. It is
sufficent to make the cell as changed with sheet_cell_changed.
(paste_cell) : It is premature to redraw, we have no yet calculated
spans. Redraw and respan at the range level, not the cell.
2000-05-20 Jody Goldberg <jgoldberg@home.com> 2000-05-20 Jody Goldberg <jgoldberg@home.com>
* Release 0.54 * Release 0.54
......
2000-05-17 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_cell_range) : Adjust signature to
take a range.
(sheet_paste_selection) : Export in preparation for adding undo.
* src/commands.c (cmd_paste_copy) : Some initial work. Not used or
complete.
* src/parse-util.c (parse_text_value_or_expr) : Start passing in the
current format so that we can eventually attempt to match it before
trying all the others.
* src/sheet.c (sheet_formulas_unlink) : New function.
(sheet_destroy_contents) : Optimize.
* src/dialogs/dialog-plugin-manager.c : Make a bit prettier.
* src/dialogs/plugin-manager.glade : Ditto.
2000-05-16 Jody Goldberg <jgoldberg@home.com>
* plugins/*/*.c : Rationalize the naming scheme.
2000-05-15 Jody Goldberg <jgoldberg@home.com>
* src/eval.[ch] : Rename
cell_queue_recalc -> eval_queue_cell
cell_queue_recalc_list -> eval_queue_list
cell_unqueue_recalc -> eval_unqueue_cell
(eval_unqueue_sheet) : New function.
* src/sheet.c (sheet_cell_remove_simple) : Add precautionary removal
of cells from recalc list. We should not need this in most
instances, but the check is inexpensive so I'll play it safe.
(sheet_destroy_contents) : Batch cleanups rather than doing it cell by
cell.
* src/cell.c (cell_make_value) : Fill in the implementation.
* src/clipboard.c (paste_cell_flags) : Remove some dead code.
Merged in paste_cell and fixed handling of paste by value.
2000-05-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (paste_cell) : No need to call cell_content_changed
we can queue the recalc for the entire region later. It is
sufficent to make the cell as changed with sheet_cell_changed.
(paste_cell) : It is premature to redraw, we have no yet calculated
spans. Redraw and respan at the range level, not the cell.
2000-05-20 Jody Goldberg <jgoldberg@home.com> 2000-05-20 Jody Goldberg <jgoldberg@home.com>
* Release 0.54 * Release 0.54
......
2000-05-17 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_cell_range) : Adjust signature to
take a range.
(sheet_paste_selection) : Export in preparation for adding undo.
* src/commands.c (cmd_paste_copy) : Some initial work. Not used or
complete.
* src/parse-util.c (parse_text_value_or_expr) : Start passing in the
current format so that we can eventually attempt to match it before
trying all the others.
* src/sheet.c (sheet_formulas_unlink) : New function.
(sheet_destroy_contents) : Optimize.
* src/dialogs/dialog-plugin-manager.c : Make a bit prettier.
* src/dialogs/plugin-manager.glade : Ditto.
2000-05-16 Jody Goldberg <jgoldberg@home.com>
* plugins/*/*.c : Rationalize the naming scheme.
2000-05-15 Jody Goldberg <jgoldberg@home.com>
* src/eval.[ch] : Rename
cell_queue_recalc -> eval_queue_cell
cell_queue_recalc_list -> eval_queue_list
cell_unqueue_recalc -> eval_unqueue_cell
(eval_unqueue_sheet) : New function.
* src/sheet.c (sheet_cell_remove_simple) : Add precautionary removal
of cells from recalc list. We should not need this in most
instances, but the check is inexpensive so I'll play it safe.
(sheet_destroy_contents) : Batch cleanups rather than doing it cell by
cell.
* src/cell.c (cell_make_value) : Fill in the implementation.
* src/clipboard.c (paste_cell_flags) : Remove some dead code.
Merged in paste_cell and fixed handling of paste by value.
2000-05-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (paste_cell) : No need to call cell_content_changed
we can queue the recalc for the entire region later. It is
sufficent to make the cell as changed with sheet_cell_changed.
(paste_cell) : It is premature to redraw, we have no yet calculated
spans. Redraw and respan at the range level, not the cell.
2000-05-20 Jody Goldberg <jgoldberg@home.com> 2000-05-20 Jody Goldberg <jgoldberg@home.com>
* Release 0.54 * Release 0.54
......
2000-05-17 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_cell_range) : Adjust signature to
take a range.
(sheet_paste_selection) : Export in preparation for adding undo.
* src/commands.c (cmd_paste_copy) : Some initial work. Not used or
complete.
* src/parse-util.c (parse_text_value_or_expr) : Start passing in the
current format so that we can eventually attempt to match it before
trying all the others.
* src/sheet.c (sheet_formulas_unlink) : New function.
(sheet_destroy_contents) : Optimize.
* src/dialogs/dialog-plugin-manager.c : Make a bit prettier.
* src/dialogs/plugin-manager.glade : Ditto.
2000-05-16 Jody Goldberg <jgoldberg@home.com>
* plugins/*/*.c : Rationalize the naming scheme.
2000-05-15 Jody Goldberg <jgoldberg@home.com>
* src/eval.[ch] : Rename
cell_queue_recalc -> eval_queue_cell
cell_queue_recalc_list -> eval_queue_list
cell_unqueue_recalc -> eval_unqueue_cell
(eval_unqueue_sheet) : New function.
* src/sheet.c (sheet_cell_remove_simple) : Add precautionary removal
of cells from recalc list. We should not need this in most
instances, but the check is inexpensive so I'll play it safe.
(sheet_destroy_contents) : Batch cleanups rather than doing it cell by
cell.
* src/cell.c (cell_make_value) : Fill in the implementation.
* src/clipboard.c (paste_cell_flags) : Remove some dead code.
Merged in paste_cell and fixed handling of paste by value.
2000-05-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (paste_cell) : No need to call cell_content_changed
we can queue the recalc for the entire region later. It is
sufficent to make the cell as changed with sheet_cell_changed.
(paste_cell) : It is premature to redraw, we have no yet calculated
spans. Redraw and respan at the range level, not the cell.
2000-05-20 Jody Goldberg <jgoldberg@home.com> 2000-05-20 Jody Goldberg <jgoldberg@home.com>
* Release 0.54 * Release 0.54
......
2000-05-17 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_cell_range) : Adjust signature to
take a range.
(sheet_paste_selection) : Export in preparation for adding undo.
* src/commands.c (cmd_paste_copy) : Some initial work. Not used or
complete.
* src/parse-util.c (parse_text_value_or_expr) : Start passing in the
current format so that we can eventually attempt to match it before
trying all the others.
* src/sheet.c (sheet_formulas_unlink) : New function.
(sheet_destroy_contents) : Optimize.
* src/dialogs/dialog-plugin-manager.c : Make a bit prettier.
* src/dialogs/plugin-manager.glade : Ditto.
2000-05-16 Jody Goldberg <jgoldberg@home.com>
* plugins/*/*.c : Rationalize the naming scheme.
2000-05-15 Jody Goldberg <jgoldberg@home.com>
* src/eval.[ch] : Rename
cell_queue_recalc -> eval_queue_cell
cell_queue_recalc_list -> eval_queue_list
cell_unqueue_recalc -> eval_unqueue_cell
(eval_unqueue_sheet) : New function.
* src/sheet.c (sheet_cell_remove_simple) : Add precautionary removal
of cells from recalc list. We should not need this in most
instances, but the check is inexpensive so I'll play it safe.
(sheet_destroy_contents) : Batch cleanups rather than doing it cell by
cell.
* src/cell.c (cell_make_value) : Fill in the implementation.
* src/clipboard.c (paste_cell_flags) : Remove some dead code.
Merged in paste_cell and fixed handling of paste by value.
2000-05-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (paste_cell) : No need to call cell_content_changed
we can queue the recalc for the entire region later. It is
sufficent to make the cell as changed with sheet_cell_changed.
(paste_cell) : It is premature to redraw, we have no yet calculated
spans. Redraw and respan at the range level, not the cell.
2000-05-20 Jody Goldberg <jgoldberg@home.com> 2000-05-20 Jody Goldberg <jgoldberg@home.com>
* Release 0.54 * Release 0.54
......
2000-05-17 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_cell_range) : Adjust signature to
take a range.
(sheet_paste_selection) : Export in preparation for adding undo.
* src/commands.c (cmd_paste_copy) : Some initial work. Not used or
complete.
* src/parse-util.c (parse_text_value_or_expr) : Start passing in the
current format so that we can eventually attempt to match it before
trying all the others.
* src/sheet.c (sheet_formulas_unlink) : New function.
(sheet_destroy_contents) : Optimize.
* src/dialogs/dialog-plugin-manager.c : Make a bit prettier.
* src/dialogs/plugin-manager.glade : Ditto.
2000-05-16 Jody Goldberg <jgoldberg@home.com>
* plugins/*/*.c : Rationalize the naming scheme.
2000-05-15 Jody Goldberg <jgoldberg@home.com>
* src/eval.[ch] : Rename
cell_queue_recalc -> eval_queue_cell
cell_queue_recalc_list -> eval_queue_list
cell_unqueue_recalc -> eval_unqueue_cell
(eval_unqueue_sheet) : New function.
* src/sheet.c (sheet_cell_remove_simple) : Add precautionary removal
of cells from recalc list. We should not need this in most
instances, but the check is inexpensive so I'll play it safe.
(sheet_destroy_contents) : Batch cleanups rather than doing it cell by
cell.
* src/cell.c (cell_make_value) : Fill in the implementation.
* src/clipboard.c (paste_cell_flags) : Remove some dead code.
Merged in paste_cell and fixed handling of paste by value.
2000-05-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (paste_cell) : No need to call cell_content_changed
we can queue the recalc for the entire region later. It is
sufficent to make the cell as changed with sheet_cell_changed.
(paste_cell) : It is premature to redraw, we have no yet calculated
spans. Redraw and respan at the range level, not the cell.
2000-05-20 Jody Goldberg <jgoldberg@home.com> 2000-05-20 Jody Goldberg <jgoldberg@home.com>
* Release 0.54 * Release 0.54
......
2000-05-17 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_copy_cell_range) : Adjust signature to
take a range.
(sheet_paste_selection) : Export in preparation for adding undo.
* src/commands.c (cmd_paste_copy) : Some initial work. Not used or
complete.
* src/parse-util.c (parse_text_value_or_expr) : Start passing in the
current format so that we can eventually attempt to match it before
trying all the others.
* src/sheet.c (sheet_formulas_unlink) : New function.
(sheet_destroy_contents) : Optimize.
* src/dialogs/dialog-plugin-manager.c : Make a bit prettier.
* src/dialogs/plugin-manager.glade : Ditto.
2000-05-16 Jody Goldberg <jgoldberg@home.com>
* plugins/*/*.c : Rationalize the naming scheme.
2000-05-15 Jody Goldberg <jgoldberg@home.com>
* src/eval.[ch] : Rename
cell_queue_recalc -> eval_queue_cell
cell_queue_recalc_list -> eval_queue_list
cell_unqueue_recalc -> eval_unqueue_cell
(eval_unqueue_sheet) : New function.
* src/sheet.c (sheet_cell_remove_simple) : Add precautionary removal
of cells from recalc list. We should not need this in most
instances, but the check is inexpensive so I'll play it safe.
(sheet_destroy_contents) : Batch cleanups rather than doing it cell by
cell.
* src/cell.c (cell_make_value) : Fill in the implementation.
* src/clipboard.c (paste_cell_flags) : Remove some dead code.
Merged in paste_cell and fixed handling of paste by value.
2000-05-14 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (paste_cell) : No need to call cell_content_changed
we can queue the recalc for the entire region later. It is
sufficent to make the cell as changed with sheet_cell_changed.
(paste_cell) : It is premature to redraw, we have no yet calculated
spans. Redraw and respan at the range level, not the cell.
2000-05-20 Jody Goldberg <jgoldberg@home.com> 2000-05-20 Jody Goldberg <jgoldberg@home.com>
* Release 0.54 * Release 0.54
......
...@@ -3,18 +3,11 @@ appropriate for new developers. ...@@ -3,18 +3,11 @@ appropriate for new developers.
Description Difficulty Integration Description Difficulty Integration
------------------------------------------------------ ---------- ----------- ------------------------------------------------------ ---------- -----------
- Ability to Create a new sheet that is a copy Medium Medium - Ability to Create a new sheet that is a copy Low Low
of an existing sheet. of an existing sheet.
- Financial functions (src/functions/fn-financial.c) Medium Very low - Financial functions (src/functions/fn-financial.c) Medium Very low
- Thoroughly check for division-by-zero and other Low Low
arithmetic problems in functions, mostly financial.
- Add tests for all kinds of error conditions for Low Low
functions to samples/regress.gnumeric so we can be
sure that we are returning the right error code.
- Save/Restore the values of the last selected colours Low Low - Save/Restore the values of the last selected colours Low Low
from the toolbar for background or font. from the toolbar for background or font.
...@@ -25,10 +18,6 @@ Description Difficulty Integration ...@@ -25,10 +18,6 @@ Description Difficulty Integration
- Have the pattern buttons in the format dialog Medium Low - Have the pattern buttons in the format dialog Medium Low
reflect colour changes. reflect colour changes.
- Add MS excel like format->autoformat. A dialog Low Low
that will display some canned styles and apply them
to the selection.
- Audit the help text for all the functions. Some are Low Low - Audit the help text for all the functions. Some are Low Low
missing or do not conform to the style guides, missing or do not conform to the style guides,
......
...@@ -146,9 +146,7 @@ application_clipboard_copy (Sheet *sheet, Range const *area) ...@@ -146,9 +146,7 @@ application_clipboard_copy (Sheet *sheet, Range const *area)
if (application_set_selected_sheet (sheet) ) { if (application_set_selected_sheet (sheet) ) {
app.clipboard_cut_range = *area; app.clipboard_cut_range = *area;
app.clipboard_copied_contents = app.clipboard_copied_contents =
clipboard_copy_cell_range (sheet, clipboard_copy_cell_range (sheet, area);
area->start.col, area->start.row,
area->end.col, area->end.row);
workbook_view_set_paste_special_state (sheet->workbook, TRUE); workbook_view_set_paste_special_state (sheet->workbook, TRUE);
......
...@@ -45,7 +45,7 @@ cell_formula_changed (Cell *cell, gboolean queue_recalc) ...@@ -45,7 +45,7 @@ cell_formula_changed (Cell *cell, gboolean queue_recalc)
{ {
sheet_cell_formula_link (cell); sheet_cell_formula_link (cell);
if (queue_recalc) if (queue_recalc)
cell_queue_recalc (cell); eval_queue_cell (cell);
} }
/** /**
...@@ -173,22 +173,24 @@ cell_content_changed (Cell *cell) ...@@ -173,22 +173,24 @@ cell_content_changed (Cell *cell)
/* Queue all of the dependencies for this cell */ /* Queue all of the dependencies for this cell */
deps = cell_get_dependencies (cell); deps = cell_get_dependencies (cell);
if (deps) if (deps)
cell_queue_recalc_list (deps, TRUE); eval_queue_list (deps, TRUE);
sheet_cell_changed (cell); sheet_cell_changed (cell);
} }
/* /*
* cell_relocate: * cell_relocate:
* @cell: The cell that is changing position * @cell : The cell that is changing position
* @check_bonunds : Should expressions be bounds checked. * @check_bounds : Should expressions be bounds checked.
* @unlink : Does the cell need to be unlinked from the
* expression list.
* *
* This routine is used to move a cell to a different location: * This routine is used to move a cell to a different location:
* *
* Auxiliary items canvas items attached to the cell are moved. * Auxiliary items canvas items attached to the cell are moved.
*/ */
void void
cell_relocate (Cell *cell, gboolean check_bounds) cell_relocate (Cell *cell, gboolean check_bounds, gboolean unlink)
{ {
g_return_if_fail (cell != NULL); g_return_if_fail (cell != NULL);
...@@ -197,7 +199,8 @@ cell_relocate (Cell *cell, gboolean check_bounds) ...@@ -197,7 +199,8 @@ cell_relocate (Cell *cell, gboolean check_bounds)
/* 2. If the cell contains a formula, relocate the formula */ /* 2. If the cell contains a formula, relocate the formula */
if (cell_has_expr (cell)) { if (cell_has_expr (cell)) {
sheet_cell_formula_unlink (cell); if (unlink)
sheet_cell_formula_unlink (cell);
/* /*
* WARNING WARNING WARNING * WARNING WARNING WARNING
...@@ -254,8 +257,6 @@ cell_relocate (Cell *cell, gboolean check_bounds) ...@@ -254,8 +257,6 @@ cell_relocate (Cell *cell, gboolean check_bounds)
/* 3. Move any auxiliary canvas items */ /* 3. Move any auxiliary canvas items */
if (cell->comment) if (cell->comment)
cell_comment_reposition (cell); cell_comment_reposition (cell);
cell_content_changed (cell);
} }
/****************************************************************************/ /****************************************************************************/
...@@ -287,7 +288,8 @@ cell_set_text (Cell *cell, char const *text) ...@@ -287,7 +288,8 @@ cell_set_text (Cell *cell, char const *text)
g_return_if_fail (!cell_is_partial_array (cell)); g_return_if_fail (!cell_is_partial_array (cell));
format = parse_text_value_or_expr (eval_pos_init_cell (&pos, cell), format = parse_text_value_or_expr (eval_pos_init_cell (&pos, cell),
text, &val, &expr); text, &val, &expr,
NULL /* TODO : Use assigned format ? */);
if (val != NULL) { /* String was a value */ if (val != NULL) { /* String was a value */
/* If there was a prefered format remember it */ /* If there was a prefered format remember it */
...@@ -301,7 +303,6 @@ cell_set_text (Cell *cell, char const *text) ...@@ -301,7 +303,6 @@ cell_set_text (Cell *cell, char const *text)
cell->u.entered_text = string_get (text); cell->u.entered_text = string_get (text);
cell->format = fmt; cell->format = fmt;
cell_render_value (cell); cell_render_value (cell);
cell_content_changed (cell);
} else { /* String was an expression */ } else { /* String was an expression */
cell_set_expr (cell, expr, format); cell_set_expr (cell, expr, format);
expr_tree_unref (expr); expr_tree_unref (expr);
...@@ -746,8 +747,19 @@ cell_set_format (Cell *cell, char const *format) ...@@ -746,8 +747,19 @@ cell_set_format (Cell *cell, char const *format)
cell_dirty (cell); cell_dirty (cell);
} }
/* /**
* This routine drops the formula and just keeps the value * cell_make_value : drops the expression keeps its value. Then uses the formatted
* result as if that had been entered.
*
* NOTE : the cell's expression can not be linked into the expression * list.
*
* The cell is rendered but spans are not calculated, the cell is NOT marked for
* recalc.
*
* WARNING : This is an internal routine that does not queue redraws,
* does not auto-resize, and does not calculate spans.
*
* NOTE : This DOES NOT check for array partitioning.
*/ */
void void
cell_make_value (Cell *cell) cell_make_value (Cell *cell)
...@@ -755,7 +767,15 @@ cell_make_value (Cell *cell) ...@@ -755,7 +767,15 @@ cell_make_value (Cell *cell)
g_return_if_fail (cell != NULL); g_return_if_fail (cell != NULL);
g_return_if_fail (cell_has_expr(cell)); g_return_if_fail (cell_has_expr(cell));
/* FIXME: does this work at all? -- MW */ expr_tree_unref (cell->u.expression);
/* THIS IS CRAP fix soon */ cell->u.expression = NULL;
cell->cell_flags &= ~CELL_HAS_EXPRESSION;
if (cell->rendered_value == NULL)
cell_render_value (cell);
g_return_if_fail (cell->rendered_value != NULL);
cell->u.entered_text = string_ref (cell->rendered_value->rendered_text);
cell_dirty (cell); cell_dirty (cell);
} }
...@@ -46,7 +46,9 @@ struct _Cell { ...@@ -46,7 +46,9 @@ struct _Cell {
Cell *cell_copy (Cell const *cell); Cell *cell_copy (Cell const *cell);
void cell_destroy (Cell *cell); void cell_destroy (Cell *cell);
void cell_content_changed (Cell *cell); void cell_content_changed (Cell *cell);
void cell_relocate (Cell *cell, gboolean check_bounds); void cell_relocate (Cell *cell,
gboolean check_bounds,
gboolean unlink);
/** /**
* Cell state checking * Cell state checking
......
...@@ -40,102 +40,55 @@ ...@@ -40,102 +40,55 @@
* *
* Passed through the workbook structure. * Passed through the workbook structure.
*/ */
typedef struct { struct _PasteTarget {
Sheet *dest_sheet; Sheet *dest_sheet;
CellRegion *region; CellRegion *region;
int dest_col, dest_row; int dest_col, dest_row;
int paste_flags; int paste_flags;
} clipboard_paste_closure_t; };
/** /**
* paste_cell: * paste_cell_flags: Pastes a cell in the spreadsheet
*
* @dest_sheet: The sheet where the pasting will be done * @dest_sheet: The sheet where the pasting will be done
* @new_cell: The cell to paste. * @new_cell: A new cell (not linked into the sheet, or wb->expr_list)
* @target_col: Column to put the cell into * @target_col: Column to put the cell into
* @target_row: Row to put the cell into. * @target_row: Row to put the cell into.
* @paste_flags: Bit mask that describes the paste options. * @paste_flags: Bit mask that describes the paste options.
*
* Pastes a cell in the spreadsheet
*/ */
static void static void
paste_cell (Sheet *dest_sheet, Cell *new_cell, paste_cell_flags (Sheet *dest_sheet, int target_col, int target_row,
int target_col, int target_row, CellCopy *c_copy, int paste_flags)
int paste_flags)
{ {
g_return_if_fail (target_col < SHEET_MAX_COLS); if ((paste_flags & (PASTE_FORMULAS | PASTE_VALUES))){
g_return_if_fail (target_row < SHEET_MAX_ROWS); if (c_copy->type == CELL_COPY_TYPE_CELL) {
Cell *new_cell = cell_copy (c_copy->u.cell);
if (!(paste_flags & PASTE_FORMULAS)) {
if (cell_has_expr (new_cell)) {
/*
* NOTE : the new_cell must not be linked into the
* sheet at this point
*/
expr_tree_unref (new_cell->u.expression);
new_cell->u.expression = NULL;
new_cell->cell_flags &= ~CELL_HAS_EXPRESSION;
}
}
if (cell_has_expr (new_cell)) {
if (paste_flags & PASTE_FORMULAS) {
/* Cell can not be linked in yet, but it needs an accurate location */ /* Cell can not be linked in yet, but it needs an accurate location */
new_cell->sheet = dest_sheet; new_cell->sheet = dest_sheet;
new_cell->col_info = sheet_col_fetch (dest_sheet, target_col); new_cell->col_info = sheet_col_fetch (dest_sheet, target_col);
new_cell->row_info = sheet_row_fetch (dest_sheet, target_row); new_cell->row_info = sheet_row_fetch (dest_sheet, target_row);
cell_relocate (new_cell, TRUE); if (cell_has_expr (new_cell)) {
cell_content_changed (new_cell); if (paste_flags & PASTE_FORMULAS) {
} else cell_relocate (new_cell, TRUE, FALSE);
cell_make_value (new_cell); /* FIXME : do this at a range level too */
} sheet_cell_changed (new_cell);
} else
if (new_cell->value) cell_make_value (new_cell);
cell_render_value (new_cell); } else {
g_return_if_fail (new_cell->value != NULL);
/* Once we have set the content then insert */
sheet_cell_insert (dest_sheet, new_cell, target_col, target_row); cell_render_value (new_cell);
}
sheet_redraw_cell_region (dest_sheet,
target_col, target_row,
target_col, target_row);
}
static void
paste_cell_flags (Sheet *dest_sheet, int target_col, int target_row,
CellCopy *c_copy, int paste_flags)
{
if (!(paste_flags & (PASTE_FORMULAS | PASTE_VALUES))){
Range r;
r.start.col = target_col;
r.start.row = target_row;
r.end.col = target_col;
r.end.row = target_row;
} else {
Cell *new_cell;
if (c_copy->type == CELL_COPY_TYPE_CELL) {
Range r;
new_cell = cell_copy (c_copy->u.cell);
r.start.col = target_col;
r.start.row = target_row;
r.end.col = target_col;
r.end.row = target_row;
paste_cell (dest_sheet, new_cell, sheet_cell_insert (dest_sheet, new_cell, target_col, target_row);
target_col, target_row, paste_flags);
} else { } else {
Cell *new_cell = sheet_cell_new (dest_sheet,
new_cell = sheet_cell_new (dest_sheet, target_col, target_row);
target_col, target_row);
if (c_copy->u.text) {
if (c_copy->u.text)
sheet_cell_set_text (new_cell, c_copy->u.text); sheet_cell_set_text (new_cell, c_copy->u.text);
}
if (c_copy->type == CELL_COPY_TYPE_TEXT_AND_COMMENT && c_copy->comment) if (c_copy->type == CELL_COPY_TYPE_TEXT_AND_COMMENT && c_copy->comment)
cell_set_comment (new_cell, c_copy->comment); cell_set_comment (new_cell, c_copy->comment);
...@@ -220,7 +173,7 @@ do_clipboard_paste_cell_region (CommandContext *context, ...@@ -220,7 +173,7 @@ do_clipboard_paste_cell_region (CommandContext *context,