Commit c6a63d53 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg
Browse files

Set the CELL_IN_SHEET_LIST flag. (sheet_cell_remove_from_hash) : Clear the


2000-06-04  Jody Goldberg <jgoldberg@home.com>

	* src/sheet.c (sheet_cell_add_to_hash) : Set the CELL_IN_SHEET_LIST
	  flag.
	(sheet_cell_remove_from_hash) : Clear the CELL_IN_SHEET_LIST flag.
	(cb_remove_allcells) : Ditto.
	(sheet_cell_formula_link) : Set the CELL_IN_EXPR_LIST flag.
	(sheet_cell_formula_unlink) : Clear the CELL_IN_EXPR_LIST flag.
	(sheet_formulas_unlink) : Ditto.

	* src/clipboard.c (paste_cell_flags) : Take some additional arguments
	  so that pasted cells can potentially have their references made
	  invariant, this is for sorting.
	(clipboard_paste_region) : Pass the additional offsets when
	  PASTE_EXPR_RELOCATE is specified.
	(append_cell_closure_t) : Delete this type.  Move the origin cell info
	  into CellRegion.

	* src/cell.c (cell_copy) : Clear the sheet and associated flags for
	  the copied cell.  This avoids accidentally realizing comments that
	  become undeletable.
	(cell_relocate) : Remove the unlink flag now that we have the
	  additional cell_flags.
parent 082e1c3e
......@@ -5,10 +5,13 @@ and longer term bugs.
Release Critical
----------------
- Changing a name that is in use causes a crash.
- The max row/col canvas scroll size is still hard coded.
- Resize row/col undo is unfinished.
- Saving xml should not rely on changing the textdomain to disable translation
of TRUE/FALSE.
Long term breakage
------------------
- The max row/col scroll size is still hard coded.
- Sorting should move styles too (jpr is working on this)
......
2000-06-04 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_add_to_hash) : Set the CELL_IN_SHEET_LIST
flag.
(sheet_cell_remove_from_hash) : Clear the CELL_IN_SHEET_LIST flag.
(cb_remove_allcells) : Ditto.
(sheet_cell_formula_link) : Set the CELL_IN_EXPR_LIST flag.
(sheet_cell_formula_unlink) : Clear the CELL_IN_EXPR_LIST flag.
(sheet_formulas_unlink) : Ditto.
* src/clipboard.c (paste_cell_flags) : Take some additional arguments
so that pasted cells can potentially have their references made
invariant, this is for sorting.
(clipboard_paste_region) : Pass the additional offsets when
PASTE_EXPR_RELOCATE is specified.
(append_cell_closure_t) : Delete this type. Move the origin cell info
into CellRegion.
* src/cell.c (cell_copy) : Clear the sheet and associated flags for
the copied cell. This avoids accidentally realizing comments that
become undeletable.
(cell_relocate) : Remove the unlink flag now that we have the
additional cell_flags.
2000-06-02 Michael Meeks <michael@helixcode.com>
* Makefile.am (SUBDIRS): remove libole2. duh.
......
2000-06-04 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_add_to_hash) : Set the CELL_IN_SHEET_LIST
flag.
(sheet_cell_remove_from_hash) : Clear the CELL_IN_SHEET_LIST flag.
(cb_remove_allcells) : Ditto.
(sheet_cell_formula_link) : Set the CELL_IN_EXPR_LIST flag.
(sheet_cell_formula_unlink) : Clear the CELL_IN_EXPR_LIST flag.
(sheet_formulas_unlink) : Ditto.
* src/clipboard.c (paste_cell_flags) : Take some additional arguments
so that pasted cells can potentially have their references made
invariant, this is for sorting.
(clipboard_paste_region) : Pass the additional offsets when
PASTE_EXPR_RELOCATE is specified.
(append_cell_closure_t) : Delete this type. Move the origin cell info
into CellRegion.
* src/cell.c (cell_copy) : Clear the sheet and associated flags for
the copied cell. This avoids accidentally realizing comments that
become undeletable.
(cell_relocate) : Remove the unlink flag now that we have the
additional cell_flags.
2000-06-02 Michael Meeks <michael@helixcode.com>
* Makefile.am (SUBDIRS): remove libole2. duh.
......
2000-06-04 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_add_to_hash) : Set the CELL_IN_SHEET_LIST
flag.
(sheet_cell_remove_from_hash) : Clear the CELL_IN_SHEET_LIST flag.
(cb_remove_allcells) : Ditto.
(sheet_cell_formula_link) : Set the CELL_IN_EXPR_LIST flag.
(sheet_cell_formula_unlink) : Clear the CELL_IN_EXPR_LIST flag.
(sheet_formulas_unlink) : Ditto.
* src/clipboard.c (paste_cell_flags) : Take some additional arguments
so that pasted cells can potentially have their references made
invariant, this is for sorting.
(clipboard_paste_region) : Pass the additional offsets when
PASTE_EXPR_RELOCATE is specified.
(append_cell_closure_t) : Delete this type. Move the origin cell info
into CellRegion.
* src/cell.c (cell_copy) : Clear the sheet and associated flags for
the copied cell. This avoids accidentally realizing comments that
become undeletable.
(cell_relocate) : Remove the unlink flag now that we have the
additional cell_flags.
2000-06-02 Michael Meeks <michael@helixcode.com>
* Makefile.am (SUBDIRS): remove libole2. duh.
......
2000-06-04 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_add_to_hash) : Set the CELL_IN_SHEET_LIST
flag.
(sheet_cell_remove_from_hash) : Clear the CELL_IN_SHEET_LIST flag.
(cb_remove_allcells) : Ditto.
(sheet_cell_formula_link) : Set the CELL_IN_EXPR_LIST flag.
(sheet_cell_formula_unlink) : Clear the CELL_IN_EXPR_LIST flag.
(sheet_formulas_unlink) : Ditto.
* src/clipboard.c (paste_cell_flags) : Take some additional arguments
so that pasted cells can potentially have their references made
invariant, this is for sorting.
(clipboard_paste_region) : Pass the additional offsets when
PASTE_EXPR_RELOCATE is specified.
(append_cell_closure_t) : Delete this type. Move the origin cell info
into CellRegion.
* src/cell.c (cell_copy) : Clear the sheet and associated flags for
the copied cell. This avoids accidentally realizing comments that
become undeletable.
(cell_relocate) : Remove the unlink flag now that we have the
additional cell_flags.
2000-06-02 Michael Meeks <michael@helixcode.com>
* Makefile.am (SUBDIRS): remove libole2. duh.
......
2000-06-04 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_add_to_hash) : Set the CELL_IN_SHEET_LIST
flag.
(sheet_cell_remove_from_hash) : Clear the CELL_IN_SHEET_LIST flag.
(cb_remove_allcells) : Ditto.
(sheet_cell_formula_link) : Set the CELL_IN_EXPR_LIST flag.
(sheet_cell_formula_unlink) : Clear the CELL_IN_EXPR_LIST flag.
(sheet_formulas_unlink) : Ditto.
* src/clipboard.c (paste_cell_flags) : Take some additional arguments
so that pasted cells can potentially have their references made
invariant, this is for sorting.
(clipboard_paste_region) : Pass the additional offsets when
PASTE_EXPR_RELOCATE is specified.
(append_cell_closure_t) : Delete this type. Move the origin cell info
into CellRegion.
* src/cell.c (cell_copy) : Clear the sheet and associated flags for
the copied cell. This avoids accidentally realizing comments that
become undeletable.
(cell_relocate) : Remove the unlink flag now that we have the
additional cell_flags.
2000-06-02 Michael Meeks <michael@helixcode.com>
* Makefile.am (SUBDIRS): remove libole2. duh.
......
2000-06-04 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_add_to_hash) : Set the CELL_IN_SHEET_LIST
flag.
(sheet_cell_remove_from_hash) : Clear the CELL_IN_SHEET_LIST flag.
(cb_remove_allcells) : Ditto.
(sheet_cell_formula_link) : Set the CELL_IN_EXPR_LIST flag.
(sheet_cell_formula_unlink) : Clear the CELL_IN_EXPR_LIST flag.
(sheet_formulas_unlink) : Ditto.
* src/clipboard.c (paste_cell_flags) : Take some additional arguments
so that pasted cells can potentially have their references made
invariant, this is for sorting.
(clipboard_paste_region) : Pass the additional offsets when
PASTE_EXPR_RELOCATE is specified.
(append_cell_closure_t) : Delete this type. Move the origin cell info
into CellRegion.
* src/cell.c (cell_copy) : Clear the sheet and associated flags for
the copied cell. This avoids accidentally realizing comments that
become undeletable.
(cell_relocate) : Remove the unlink flag now that we have the
additional cell_flags.
2000-06-02 Michael Meeks <michael@helixcode.com>
* Makefile.am (SUBDIRS): remove libole2. duh.
......
2000-06-04 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_add_to_hash) : Set the CELL_IN_SHEET_LIST
flag.
(sheet_cell_remove_from_hash) : Clear the CELL_IN_SHEET_LIST flag.
(cb_remove_allcells) : Ditto.
(sheet_cell_formula_link) : Set the CELL_IN_EXPR_LIST flag.
(sheet_cell_formula_unlink) : Clear the CELL_IN_EXPR_LIST flag.
(sheet_formulas_unlink) : Ditto.
* src/clipboard.c (paste_cell_flags) : Take some additional arguments
so that pasted cells can potentially have their references made
invariant, this is for sorting.
(clipboard_paste_region) : Pass the additional offsets when
PASTE_EXPR_RELOCATE is specified.
(append_cell_closure_t) : Delete this type. Move the origin cell info
into CellRegion.
* src/cell.c (cell_copy) : Clear the sheet and associated flags for
the copied cell. This avoids accidentally realizing comments that
become undeletable.
(cell_relocate) : Remove the unlink flag now that we have the
additional cell_flags.
2000-06-02 Michael Meeks <michael@helixcode.com>
* Makefile.am (SUBDIRS): remove libole2. duh.
......
......@@ -117,7 +117,9 @@ cell_copy (Cell const *cell)
/* bitmap copy first */
*new_cell = *cell;
new_cell->cell_flags &= ~CELL_QUEUED_FOR_RECALC;
/* The new cell is not linked into any of the major management structures */
new_cell->sheet = NULL;
new_cell->cell_flags &= ~(CELL_QUEUED_FOR_RECALC|CELL_IN_SHEET_LIST|CELL_IN_EXPR_LIST);
/* now copy properly the rest */
if (cell_has_expr (new_cell))
......@@ -182,15 +184,13 @@ cell_content_changed (Cell *cell)
* cell_relocate:
* @cell : The cell that is changing position
* @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:
*
* Auxiliary items canvas items attached to the cell are moved.
*/
void
cell_relocate (Cell *cell, gboolean check_bounds, gboolean unlink)
cell_relocate (Cell *cell, int col_offset, int row_offset, gboolean check_bounds)
{
g_return_if_fail (cell != NULL);
......@@ -199,7 +199,7 @@ cell_relocate (Cell *cell, gboolean check_bounds, gboolean unlink)
/* 2. If the cell contains a formula, relocate the formula */
if (cell_has_expr (cell)) {
if (unlink)
if (cell_expr_is_linked (cell))
sheet_cell_formula_unlink (cell);
/*
......
......@@ -54,8 +54,8 @@ Cell *cell_copy (Cell const *cell);
void cell_destroy (Cell *cell);
void cell_content_changed (Cell *cell);
void cell_relocate (Cell *cell,
gboolean check_bounds,
gboolean unlink);
int col_offset, int row_offset,
gboolean check_bounds);
/**
* Cell state checking
......@@ -68,6 +68,8 @@ ExprArray const * cell_is_array (Cell const * cell);
gboolean cell_is_partial_array (Cell const * cell);
#define cell_needs_recalc(cell) ((cell)->cell_flags & CELL_QUEUED_FOR_RECALC)
#define cell_has_expr(cell) ((cell)->cell_flags & CELL_HAS_EXPRESSION)
#define cell_is_linked(cell) ((cell)->cell_flags & CELL_IN_SHEET_LIST)
#define cell_expr_is_linked(cell) ((cell)->cell_flags & CELL_IN_EXPR_LIST)
#define cell_has_comment(cell) ((cell)->comment != NULL)
/**
......
......@@ -47,7 +47,9 @@
* @paste_flags: Bit mask that describes the paste options.
*/
static void
paste_cell_flags (Sheet *dest_sheet, int target_col, int target_row,
paste_cell_flags (Sheet *dest_sheet,
int target_col, int target_row,
int col_offset, int row_offset,
CellCopy *c_copy, int paste_flags)
{
if ((paste_flags & (PASTE_FORMULAS | PASTE_VALUES))){
......@@ -61,7 +63,8 @@ paste_cell_flags (Sheet *dest_sheet, int target_col, int target_row,
if (cell_has_expr (new_cell)) {
if (paste_flags & PASTE_FORMULAS) {
cell_relocate (new_cell, TRUE, FALSE);
cell_relocate (new_cell, col_offset, row_offset, TRUE);
/* FIXME : do this at a range level too */
sheet_cell_changed (new_cell);
} else
......@@ -168,6 +171,12 @@ clipboard_paste_region (CommandContext *context,
int const left = repeat_horizontal * src_cols + pt->range.start.col;
int const top = repeat_vertical * src_rows + pt->range.start.row;
CellCopyList *l;
int col_offset = 0, row_offset = 0;
if (pt->paste_flags & PASTE_EXPR_RELOCATE) {
col_offset = left - content->base_col;
row_offset = top - content->base_row;
}
/* Move the styles on here so we get correct formats before recalc */
if (pt->paste_flags & PASTE_FORMATS) {
......@@ -196,7 +205,9 @@ clipboard_paste_region (CommandContext *context,
target_row += c_copy->row_offset;
}
paste_cell_flags (pt->sheet, target_col, target_row,
paste_cell_flags (pt->sheet,
target_col, target_row,
col_offset, row_offset,
c_copy, pt->paste_flags);
}
}
......@@ -216,15 +227,10 @@ clipboard_paste_region (CommandContext *context,
return FALSE;
}
typedef struct {
int base_col, base_row;
CellRegion *r;
} append_cell_closure_t;
static Value *
clipboard_prepend_cell (Sheet *sheet, int col, int row, Cell *cell, void *user_data)
{
append_cell_closure_t *c = user_data;
CellRegion *c = user_data;
CellCopy *copy;
copy = g_new (CellCopy, 1);
......@@ -233,7 +239,7 @@ clipboard_prepend_cell (Sheet *sheet, int col, int row, Cell *cell, void *user_d
copy->col_offset = col - c->base_col;
copy->row_offset = row - c->base_row;
c->r->list = g_list_prepend (c->r->list, copy);
c->list = g_list_prepend (c->list, copy);
return NULL;
}
......@@ -246,31 +252,31 @@ clipboard_prepend_cell (Sheet *sheet, int col, int row, Cell *cell, void *user_d
CellRegion *
clipboard_copy_range (Sheet *sheet, Range const *r)
{
append_cell_closure_t c;
CellRegion *c;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
g_return_val_if_fail (r->start.col <= r->end.col, NULL);
g_return_val_if_fail (r->start.row <= r->end.row, NULL);
c.r = g_new0 (CellRegion, 1);
c = g_new0 (CellRegion, 1);
c.base_col = r->start.col;
c.base_row = r->start.row;
c.r->cols = r->end.col - r->start.col + 1;
c.r->rows = r->end.row - r->start.row + 1;
c->base_col = r->start.col;
c->base_row = r->start.row;
c->cols = r->end.col - r->start.col + 1;
c->rows = r->end.row - r->start.row + 1;
sheet_cell_foreach_range ( sheet, TRUE,
r->start.col, r->start.row,
r->end.col, r->end.row,
clipboard_prepend_cell, &c);
clipboard_prepend_cell, c);
c.r->styles = sheet_get_styles_in_range (sheet, r);
c->styles = sheet_get_styles_in_range (sheet, r);
/* reverse the list so that upper left corner is first */
c.r->list = g_list_reverse (c.r->list);
c->list = g_list_reverse (c->list);
return c.r;
return c;
}
/**
......
......@@ -2,18 +2,19 @@
#define GNUMERIC_CLIPBOARD_H
enum {
PASTE_VALUES = 1 << 0,
PASTE_FORMULAS = 1 << 1,
PASTE_FORMATS = 1 << 2,
PASTE_VALUES = 1 << 0, /* At most VALUES or FORMATS can */
PASTE_FORMULAS = 1 << 1, /* be applied */
PASTE_FORMATS = 1 << 2,
/* Operations that can be performed at paste time on a cell */
PASTE_OPER_ADD = 1 << 3,
PASTE_OPER_SUB = 1 << 4,
PASTE_OPER_MULT = 1 << 5,
PASTE_OPER_DIV = 1 << 6,
PASTE_OPER_ADD = 1 << 3,
PASTE_OPER_SUB = 1 << 4,
PASTE_OPER_MULT = 1 << 5,
PASTE_OPER_DIV = 1 << 6,
/* Whether the paste transposes or not */
PASTE_TRANSPOSE = 1 << 7
PASTE_TRANSPOSE = 1 << 7,
PASTE_EXPR_RELOCATE = 1 << 8
};
#define PASTE_ALL_TYPES (PASTE_FORMULAS | PASTE_VALUES | PASTE_FORMATS)
......@@ -39,6 +40,7 @@ typedef struct {
typedef GList CellCopyList;
struct _CellRegion {
int base_col, base_row;
int cols, rows;
CellCopyList *list;
GList *styles;
......
......@@ -1989,7 +1989,9 @@ sheet_cell_add_to_hash (Sheet *sheet, Cell *cell)
g_return_if_fail (cell->col_info->pos < SHEET_MAX_COLS);
g_return_if_fail (cell->row_info != NULL);
g_return_if_fail (cell->row_info->pos < SHEET_MAX_ROWS);
g_return_if_fail (!cell_is_linked (cell));
cell->cell_flags |= CELL_IN_SHEET_LIST;
cell->pos.col = cell->col_info->pos;
cell->pos.row = cell->row_info->pos;
......@@ -2035,16 +2037,16 @@ sheet_cell_remove_from_hash (Sheet *sheet, Cell *cell)
{
Cell cellpos;
g_return_if_fail (cell_is_linked (cell));
cellpos.pos.col = cell->col_info->pos;
cellpos.pos.row = cell->row_info->pos;
cell_unregister_span (cell);
cell_drop_dependencies (cell);
if (g_hash_table_lookup (sheet->cell_hash, &cellpos))
g_hash_table_remove (sheet->cell_hash, &cellpos);
else
g_warning ("Cell not in hash table |\n");
g_hash_table_remove (sheet->cell_hash, &cellpos);
cell->cell_flags &= ~CELL_IN_SHEET_LIST;
}
/**
......@@ -2125,6 +2127,7 @@ sheet_cell_formula_link (Cell *cell)
g_return_if_fail (cell != NULL);
g_return_if_fail (cell_has_expr (cell));
g_return_if_fail (!cell_expr_is_linked (cell));
sheet = cell->sheet;
......@@ -2139,6 +2142,7 @@ sheet_cell_formula_link (Cell *cell)
sheet->workbook->formula_cell_list =
g_list_prepend (sheet->workbook->formula_cell_list, cell);
cell_add_dependencies (cell);
cell->cell_flags |= CELL_IN_EXPR_LIST;
}
void
......@@ -2148,10 +2152,12 @@ sheet_cell_formula_unlink (Cell *cell)
g_return_if_fail (cell != NULL);
g_return_if_fail (cell_has_expr (cell));
g_return_if_fail (cell_expr_is_linked (cell));
sheet = cell->sheet;
g_return_if_fail (sheet != NULL); /* Catch use of deleted cell */
cell->cell_flags &= ~CELL_IN_EXPR_LIST;
cell_drop_dependencies (cell);
sheet->workbook->formula_cell_list = g_list_remove (sheet->workbook->formula_cell_list, cell);
......@@ -2183,6 +2189,7 @@ sheet_formulas_unlink (Sheet *sheet)
next = ptr->next;
if (cell->sheet == sheet) {
cell->cell_flags &= ~CELL_IN_EXPR_LIST;
queue = g_list_remove_link (queue, ptr);
g_list_free_1 (ptr);
}
......@@ -2279,6 +2286,7 @@ cb_remove_allcells (gpointer key, gpointer value, gpointer flags)
Cell *cell = value;
cell_drop_dependencies (cell);
cell->cell_flags &= ~CELL_IN_SHEET_LIST;
cell->sheet = NULL;
cell_destroy (cell);
return TRUE;
......@@ -2943,7 +2951,7 @@ colrow_move (Sheet *sheet,
cell = cells->data;
sheet_cell_add_to_hash (sheet, cell);
cell_relocate (cell, FALSE, TRUE);
cell_relocate (cell, 0, 0, FALSE);
cell_content_changed (cell);
}
}
......@@ -3374,7 +3382,7 @@ sheet_move_range (CommandContext *context,
sheet_cell_formula_link (cell);
/* Move comments */
cell_relocate (cell, FALSE, TRUE);
cell_relocate (cell, 0, 0, FALSE);
cell_content_changed (cell);
}
......
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