Commit 7008d180 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

support merged cells.


2000-12-29  Jody Goldberg <jgoldberg@home.com>

	* src/sheet.c (sheet_redraw_cell_region) : support merged cells.

	* src/style.c (style_font_new_simple) : guestimate width.
	(style_font_get_width) : new function.

	* src/rendered-value.c (rendered_value_new) : appoximate with via pts.
	  handle merged cells.

2000-12-29  Jody Goldberg <jgoldberg@home.com>

	* src/sheet.c (sheet_region_unmerge) : untag an existing cell as being
	  merged.
	(sheet_cell_remove_from_hash) : ditto.
	(sheet_region_merge) : tag an existing cell as being merged.
	(sheet_cell_add_to_hash) : ditto.

	* src/item-edit.c (recalc_spans) : support merged cells.

2000-12-29  Jody Goldberg <jgoldberg@home.com>

	* src/xml-io.c (xml_read_cell) : Early versions had newlines at the
	  end of their content

	* src/sheet.c (sheet_{insert,delete}_{cols,rows}) : no need to update
	  object positions, we have already moved them.

2000-12-29  Jody Goldberg <jgoldberg@home.com>

	* src/commands.c (GNUMERIC_MAKE_COMMAND_WITH_PARENT) : new macro.
	(update_after_action) : new function to localize calls to
	  sheet_update, dirty, recalc.
	(GnumericCommand) : Add a sheet to help localize repeated calls to
	  sheet_update, dirty, recalc.
	(command_undo) : Call update_after_action.
	(command_redo) : Call update_after_action.
	(command_push_undo) : Call update_after_action.
	(cmd_*_{undo,redo}) : remove calls to sheet_update, dirty, recalc.
	(cmd_*) : set the sheet.
	(cmd_paste_cut_update_origin) : new function.
	(cmd_paste_cut_undo) : call cmd_paste_cut_update_origin.
	(cmd_paste_cut_redo) : ditto.

	* src/commands.c (CmdMergeCells) : inherit from CmdUnmergeCells to
	  facilitate reuse and implement.
parent 4fc5cf8c
......@@ -99,9 +99,7 @@ STF - pasting a single line should not invoke the importer
- Merged Cells
- autofill
- copy/paste (cut works)
- undo/redo merge
- fix undo ins/del row/col to restore lost merged regions
- width of cell for general format
- printing
- multi line text in merged cells
......
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_redraw_cell_region) : support merged cells.
* src/style.c (style_font_new_simple) : guestimate width.
(style_font_get_width) : new function.
* src/rendered-value.c (rendered_value_new) : appoximate with via pts.
handle merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_region_unmerge) : untag an existing cell as being
merged.
(sheet_cell_remove_from_hash) : ditto.
(sheet_region_merge) : tag an existing cell as being merged.
(sheet_cell_add_to_hash) : ditto.
* src/item-edit.c (recalc_spans) : support merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_read_cell) : Early versions had newlines at the
end of their content
* src/sheet.c (sheet_{insert,delete}_{cols,rows}) : no need to update
object positions, we have already moved them.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (GNUMERIC_MAKE_COMMAND_WITH_PARENT) : new macro.
(update_after_action) : new function to localize calls to
sheet_update, dirty, recalc.
(GnumericCommand) : Add a sheet to help localize repeated calls to
sheet_update, dirty, recalc.
(command_undo) : Call update_after_action.
(command_redo) : Call update_after_action.
(command_push_undo) : Call update_after_action.
(cmd_*_{undo,redo}) : remove calls to sheet_update, dirty, recalc.
(cmd_*) : set the sheet.
(cmd_paste_cut_update_origin) : new function.
(cmd_paste_cut_undo) : call cmd_paste_cut_update_origin.
(cmd_paste_cut_redo) : ditto.
* src/commands.c (CmdMergeCells) : inherit from CmdUnmergeCells to
facilitate reuse and implement.
2000-12-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_insert) : privatize.
......
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_redraw_cell_region) : support merged cells.
* src/style.c (style_font_new_simple) : guestimate width.
(style_font_get_width) : new function.
* src/rendered-value.c (rendered_value_new) : appoximate with via pts.
handle merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_region_unmerge) : untag an existing cell as being
merged.
(sheet_cell_remove_from_hash) : ditto.
(sheet_region_merge) : tag an existing cell as being merged.
(sheet_cell_add_to_hash) : ditto.
* src/item-edit.c (recalc_spans) : support merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_read_cell) : Early versions had newlines at the
end of their content
* src/sheet.c (sheet_{insert,delete}_{cols,rows}) : no need to update
object positions, we have already moved them.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (GNUMERIC_MAKE_COMMAND_WITH_PARENT) : new macro.
(update_after_action) : new function to localize calls to
sheet_update, dirty, recalc.
(GnumericCommand) : Add a sheet to help localize repeated calls to
sheet_update, dirty, recalc.
(command_undo) : Call update_after_action.
(command_redo) : Call update_after_action.
(command_push_undo) : Call update_after_action.
(cmd_*_{undo,redo}) : remove calls to sheet_update, dirty, recalc.
(cmd_*) : set the sheet.
(cmd_paste_cut_update_origin) : new function.
(cmd_paste_cut_undo) : call cmd_paste_cut_update_origin.
(cmd_paste_cut_redo) : ditto.
* src/commands.c (CmdMergeCells) : inherit from CmdUnmergeCells to
facilitate reuse and implement.
2000-12-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_insert) : privatize.
......
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_redraw_cell_region) : support merged cells.
* src/style.c (style_font_new_simple) : guestimate width.
(style_font_get_width) : new function.
* src/rendered-value.c (rendered_value_new) : appoximate with via pts.
handle merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_region_unmerge) : untag an existing cell as being
merged.
(sheet_cell_remove_from_hash) : ditto.
(sheet_region_merge) : tag an existing cell as being merged.
(sheet_cell_add_to_hash) : ditto.
* src/item-edit.c (recalc_spans) : support merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_read_cell) : Early versions had newlines at the
end of their content
* src/sheet.c (sheet_{insert,delete}_{cols,rows}) : no need to update
object positions, we have already moved them.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (GNUMERIC_MAKE_COMMAND_WITH_PARENT) : new macro.
(update_after_action) : new function to localize calls to
sheet_update, dirty, recalc.
(GnumericCommand) : Add a sheet to help localize repeated calls to
sheet_update, dirty, recalc.
(command_undo) : Call update_after_action.
(command_redo) : Call update_after_action.
(command_push_undo) : Call update_after_action.
(cmd_*_{undo,redo}) : remove calls to sheet_update, dirty, recalc.
(cmd_*) : set the sheet.
(cmd_paste_cut_update_origin) : new function.
(cmd_paste_cut_undo) : call cmd_paste_cut_update_origin.
(cmd_paste_cut_redo) : ditto.
* src/commands.c (CmdMergeCells) : inherit from CmdUnmergeCells to
facilitate reuse and implement.
2000-12-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_insert) : privatize.
......
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_redraw_cell_region) : support merged cells.
* src/style.c (style_font_new_simple) : guestimate width.
(style_font_get_width) : new function.
* src/rendered-value.c (rendered_value_new) : appoximate with via pts.
handle merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_region_unmerge) : untag an existing cell as being
merged.
(sheet_cell_remove_from_hash) : ditto.
(sheet_region_merge) : tag an existing cell as being merged.
(sheet_cell_add_to_hash) : ditto.
* src/item-edit.c (recalc_spans) : support merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_read_cell) : Early versions had newlines at the
end of their content
* src/sheet.c (sheet_{insert,delete}_{cols,rows}) : no need to update
object positions, we have already moved them.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (GNUMERIC_MAKE_COMMAND_WITH_PARENT) : new macro.
(update_after_action) : new function to localize calls to
sheet_update, dirty, recalc.
(GnumericCommand) : Add a sheet to help localize repeated calls to
sheet_update, dirty, recalc.
(command_undo) : Call update_after_action.
(command_redo) : Call update_after_action.
(command_push_undo) : Call update_after_action.
(cmd_*_{undo,redo}) : remove calls to sheet_update, dirty, recalc.
(cmd_*) : set the sheet.
(cmd_paste_cut_update_origin) : new function.
(cmd_paste_cut_undo) : call cmd_paste_cut_update_origin.
(cmd_paste_cut_redo) : ditto.
* src/commands.c (CmdMergeCells) : inherit from CmdUnmergeCells to
facilitate reuse and implement.
2000-12-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_insert) : privatize.
......
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_redraw_cell_region) : support merged cells.
* src/style.c (style_font_new_simple) : guestimate width.
(style_font_get_width) : new function.
* src/rendered-value.c (rendered_value_new) : appoximate with via pts.
handle merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_region_unmerge) : untag an existing cell as being
merged.
(sheet_cell_remove_from_hash) : ditto.
(sheet_region_merge) : tag an existing cell as being merged.
(sheet_cell_add_to_hash) : ditto.
* src/item-edit.c (recalc_spans) : support merged cells.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_read_cell) : Early versions had newlines at the
end of their content
* src/sheet.c (sheet_{insert,delete}_{cols,rows}) : no need to update
object positions, we have already moved them.
2000-12-29 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (GNUMERIC_MAKE_COMMAND_WITH_PARENT) : new macro.
(update_after_action) : new function to localize calls to
sheet_update, dirty, recalc.
(GnumericCommand) : Add a sheet to help localize repeated calls to
sheet_update, dirty, recalc.
(command_undo) : Call update_after_action.
(command_redo) : Call update_after_action.
(command_push_undo) : Call update_after_action.
(cmd_*_{undo,redo}) : remove calls to sheet_update, dirty, recalc.
(cmd_*) : set the sheet.
(cmd_paste_cut_update_origin) : new function.
(cmd_paste_cut_undo) : call cmd_paste_cut_update_origin.
(cmd_paste_cut_redo) : ditto.
* src/commands.c (CmdMergeCells) : inherit from CmdUnmergeCells to
facilitate reuse and implement.
2000-12-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cell_insert) : privatize.
......
This diff is collapsed.
2000-12-27 Jody Goldberg <jgoldberg@home.com>
* fn-date.c (datedif_opt_yd) : only display warning once.
......@@ -208,7 +208,8 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
{
GtkWidget *canvas = GTK_WIDGET (item->canvas);
ItemEdit *item_edit = ITEM_EDIT (item);
ColRowInfo const * const ci = sheet_col_get_info (item_edit->scg->sheet, item_edit->col);
ColRowInfo const * const ci = sheet_col_get_info (item_edit->scg->sheet,
item_edit->pos.col);
int const left_pos = ((int)item->x1) + ci->margin_a - x;
/* NOTE : This does not handle vertical alignment yet so there may be some
......@@ -285,13 +286,14 @@ recalc_spans (GnomeCanvasItem *item)
GdkFont *font = item_edit->font;
const char *start = workbook_edit_get_display_text (item_edit->scg->wbcg);
const char *text = start;
int col_span, row_span, tmp;
GSList *text_offsets = NULL;
Range const *merged;
/* Adjust the spans */
GnumericSheet *gsheet = GNUMERIC_SHEET (item->canvas);
int cur_line = 1;
int cur_col = item_edit->col, max_col = cur_col;
int cur_col = item_edit->pos.col, max_col = cur_col;
ColRowInfo const * cri = sheet_col_get_info (sheet, cur_col);
/* Start after the grid line and the left margin */
......@@ -312,7 +314,7 @@ recalc_spans (GnomeCanvasItem *item)
offset = 0;
cur_line++;
cur_col = item_edit->col;
cur_col = item_edit->pos.col;
text_offsets = g_slist_prepend (text_offsets,
GINT_TO_POINTER(offset));
if (item->y1 + cur_line * item_edit->font_height >
......@@ -328,32 +330,43 @@ recalc_spans (GnomeCanvasItem *item)
* of an infinite loop if we somehow start on an
* invisible column
*/
} while (!cri->visible && cur_col != item_edit->col);
} while (!cri->visible && cur_col != item_edit->pos.col);
if (cur_col == item_edit->col)
if (cur_col == item_edit->pos.col)
left_in_col = cri->size_pixels - cri->margin_a - 1;
else
left_in_col += cri->size_pixels;
}
left_in_col -= pos_size;
}
item_edit->col_span = 1 + max_col - item_edit->col;
item_edit->col_span = 1 + max_col - item_edit->pos.col;
item_edit->lines = cur_line;
if (item_edit->text_offsets != NULL)
g_slist_free (item_edit->text_offsets);
item_edit->text_offsets = g_slist_reverse (text_offsets);
col_span = item_edit->col_span;
merged = sheet_region_get_merged_cell (sheet, &item_edit->pos);
if (merged != NULL) {
int tmp = merged->end.col - merged->start.col + 1;
if (col_span < tmp)
col_span = tmp;
row_span = merged->end.row - merged->start.row + 1;
} else
row_span = 1;
/* The lower right is based on the span size excluding the grid lines
* Recall that the bound excludes the far point
*/
item->x2 = 1 + item->x1 - 2 +
scg_colrow_distance_get (item_edit->scg, TRUE, item_edit->col,
item_edit->col + item_edit->col_span);
scg_colrow_distance_get (item_edit->scg, TRUE, item_edit->pos.col,
item_edit->pos.col + col_span);
cri = sheet_row_get_info (sheet, item_edit->row);
tmp = scg_colrow_distance_get (item_edit->scg, FALSE, item_edit->pos.row,
item_edit->pos.row + row_span) - 2;
item->y2 = 1 + item->y1 +
MAX (item_edit->lines * item_edit->font_height, cri->size_pixels - 2);
MAX (item_edit->lines * item_edit->font_height, tmp);
gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
}
......@@ -423,8 +436,8 @@ item_edit_init (ItemEdit *item_edit)
item_edit->col_span = 1;
item_edit->lines = 1;
item_edit->scg = NULL;
item_edit->col = -1;
item_edit->row = -1;
item_edit->pos.col = -1;
item_edit->pos.row = -1;
item_edit->font = NULL;
item_edit->font_height = 1;
item_edit->cursor_visible = TRUE;
......@@ -496,8 +509,7 @@ item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
item_edit->scg = item_edit->item_grid->scg;
sheet = item_edit->scg->sheet;
item_edit->entry = GTK_ENTRY (workbook_get_entry (item_edit->scg->wbcg));
item_edit->col = sheet->edit_pos.col;
item_edit->row = sheet->edit_pos.row;
item_edit->pos = sheet->edit_pos;
entry = item_edit->entry;
item_edit->signal_changed = gtk_signal_connect (
......@@ -519,7 +531,7 @@ item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
/* set the font and the upper left corner if this is the first pass */
if (item_edit->font == NULL) {
MStyle *mstyle = sheet_style_compute (sheet,
item_edit->col, item_edit->row);
item_edit->pos.col, item_edit->pos.row);
StyleFont *sf = sheet_view_get_style_font (sheet, mstyle);
item_edit->font = style_font_gdk_font (sf);
......@@ -530,10 +542,10 @@ item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
/* move inwards 1 pixel for the grid line */
item->x1 = 1 + gsheet->col_offset.first +
scg_colrow_distance_get (item_edit->scg, TRUE,
gsheet->col.first, item_edit->col);
gsheet->col.first, item_edit->pos.col);
item->y1 = 1 + gsheet->row_offset.first +
scg_colrow_distance_get (item_edit->scg, FALSE,
gsheet->row.first, item_edit->row);
gsheet->row.first, item_edit->pos.row);
item->x2 = item->x1 + 1;
item->y2 = item->y2 + 1;
......
......@@ -19,7 +19,8 @@ struct _ItemEdit {
guint signal_button_press; /* ::button-press-event signal in the GtkWidget */
/* Where are we */
int col, row, col_span, lines, ignore_lines;
CellPos pos;
int col_span, lines, ignore_lines;
GSList *text_offsets;
GdkFont *font;
......
......@@ -76,25 +76,22 @@ rendered_value_new (Cell *cell, MStyle *mstyle, gboolean dynamic_width)
style_format_is_general (cell->format))) {
StyleFont *style_font =
sheet_view_get_style_font (sheet, mstyle);
GdkFont *gdk_font =
style_font_gdk_font (style_font);
/* FIXME : how does one get the width of the
* widest character used to display numbers.
* Use 4 as the max width for now. Count the
* inter character spacing by measuring a
* string with 10 digits
*
* This does not belong here at all. There
* should be a global scaled StyleFont cache
* indexed by stylefont and scale (res*zoom)
* which pre-calculates this stuff.
*/
double const font_width = gdk_string_measure (gdk_font, "4444444444") / 10.;
if (font_width > 0)
col_width = (COL_INTERNAL_WIDTH (cell->col_info)) / font_width;
float const font_width = style_font_get_width (style_font);
style_font_unref (style_font);
if (font_width > 0.) {
float cell_width;
if (cell_is_merged (cell)) {
Range const *merged =
sheet_region_get_merged_cell (cell->base.sheet, &cell->pos);
cell_width = sheet_col_get_distance_pts (cell->base.sheet,
merged->start.col, merged->end.col + 1);
} else
cell_width = cell->col_info->size_pts;
cell_width -= cell->col_info->margin_a + cell->col_info->margin_b;
col_width = cell_width / font_width;
}
} else {
format = cell->format;
dynamic_width = FALSE;
......
......@@ -1292,13 +1292,17 @@ sheet_cell_set_value (Cell *cell, Value *v, StyleFormat *opt_fmt)
* It is usually called before a change happens to a region,
* and after the change has been done to queue the regions
* for the old contents and the new contents.
*
* It intelligently handles spans and merged ranges
*/
void
sheet_redraw_cell_region (Sheet const *sheet,
int start_col, int start_row,
int end_col, int end_row)
{
int row, min_col = start_col, max_col = end_col;
GSList *ptr;
int min_col = start_col, max_col = end_col;
int row, min_row = start_row, max_row = end_row;
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (start_col <= end_col);
......@@ -1337,10 +1341,25 @@ sheet_redraw_cell_region (Sheet const *sheet,
}
}
/* FIXME : expand the rectangle to contain any merged regions */
/* TODO : this may get expensive if there are alot of merged ranges */
/* no need to iterate, one pass is enough */
for (ptr = sheet->list_merged ; ptr != NULL ; ptr = ptr->next) {
Range const * const test = ptr->data;
if (start_row <= test->end.row || end_row >= test->start.row) {
if (min_col > test->start.col)
min_col = test->start.col;
if (max_col < test->end.col)
max_col = test->end.col;
if (min_row > test->start.row)
min_row = test->start.row;
if (max_row < test->end.row)
max_row = test->end.row;
}
}
SHEET_FOREACH_CONTROL (sheet, control,
sheet_view_redraw_cell_region ( control,
min_col, start_row, max_col, end_row););
min_col, min_row, max_col, max_row););
}
void
......@@ -1983,6 +2002,9 @@ sheet_cell_add_to_hash (Sheet *sheet, Cell *cell)
cell->row_info = sheet_row_fetch (sheet, cell->pos.row);
g_hash_table_insert (sheet->cell_hash, &cell->pos, cell);
if (sheet_region_get_merged_cell (sheet, &cell->pos))
cell->base.flags |= CELL_IS_MERGED;
}
static void
......@@ -2027,7 +2049,7 @@ sheet_cell_remove_from_hash (Sheet *sheet, Cell *cell)
cell_drop_dependencies (cell);
g_hash_table_remove (sheet->cell_hash, &cell->pos);
cell->base.flags &= ~CELL_IN_SHEET_LIST;
cell->base.flags &= ~(CELL_IN_SHEET_LIST|CELL_IS_MERGED);
}
/**
......@@ -2885,9 +2907,9 @@ sheet_insert_cols (WorkbookControl *wbc, Sheet *sheet,
colrow_move (sheet, i, 0, i, SHEET_MAX_ROWS-1,
&sheet->cols, i, i + count);
/* 4. Slide the StyleRegions and SheetObjects to the right */
sheet_relocate_objects (&reloc_info);
/* 4. Slide the StyleRegions and Merged regions to the right */
sheet_relocate_merged (&reloc_info);
sheet_relocate_objects (&reloc_info);
sheet_style_insert_colrow (sheet, col, count, TRUE);
/* 5. Recompute dependencies */
......@@ -2897,8 +2919,6 @@ sheet_insert_cols (WorkbookControl *wbc, Sheet *sheet,
sheet->priv->recompute_visibility = TRUE;
sheet->priv->recompute_spans = TRUE;
sheet_flag_status_update_range (sheet, &reloc_info.origin);
if (sheet->priv->reposition_objects.col > col)
sheet->priv->reposition_objects.col = col;
return FALSE;
}
......@@ -2959,9 +2979,9 @@ sheet_delete_cols (WorkbookControl *wbc, Sheet *sheet,
colrow_move (sheet, i, 0, i, SHEET_MAX_ROWS-1,
&sheet->cols, i, i-count);
/* 5. Slide the StyleRegions and SheetObjects left */
sheet_relocate_objects (&reloc_info);
/* 5. Slide the StyleRegions and Merge regions left */
sheet_relocate_merged (&reloc_info);
sheet_relocate_objects (&reloc_info);
sheet_style_delete_colrow (sheet, col, count, TRUE);
/* 6. Recompute dependencies */
......@@ -2971,8 +2991,6 @@ sheet_delete_cols (WorkbookControl *wbc, Sheet *sheet,
sheet->priv->recompute_visibility = TRUE;
sheet->priv->recompute_spans = TRUE;
sheet_flag_status_update_range (sheet, &reloc_info.origin);
if (sheet->priv->reposition_objects.col > col)
sheet->priv->reposition_objects.col = col;
return FALSE;
}
......@@ -3038,9 +3056,9 @@ sheet_insert_rows (WorkbookControl *wbc, Sheet *sheet,
colrow_move (sheet, 0, i, SHEET_MAX_COLS-1, i,
&sheet->rows, i, i+count);
/* 4. Slide the StyleRegions and SheetObjects down */
sheet_relocate_objects (&reloc_info);
/* 4. Slide the StyleRegions and Merge regions down */
sheet_relocate_merged (&reloc_info);
sheet_relocate_objects (&reloc_info);
sheet_style_insert_colrow (sheet, row, count, FALSE);
/* 5. Recompute dependencies */
......@@ -3050,8 +3068,6 @@ sheet_insert_rows (WorkbookControl *wbc, Sheet *sheet,
sheet->priv->recompute_visibility = TRUE;
sheet->priv->recompute_spans = TRUE;
sheet_flag_status_update_range (sheet, &reloc_info.origin);
if (sheet->priv->reposition_objects.row > row)
sheet->priv->reposition_objects.row = row;
return FALSE;
}
......@@ -3112,9 +3128,9 @@ sheet_delete_rows (WorkbookControl *wbc, Sheet *sheet,
colrow_move (sheet, 0, i, SHEET_MAX_COLS-1, i,
&sheet->rows, i, i-count);
/* 5. Slide the StyleRegions and SheetObjects up */
sheet_relocate_objects (&reloc_info);
/* 5. Slide the StyleRegions and Merge regions up */
sheet_relocate_merged (&reloc_info);
sheet_relocate_objects (&reloc_info);
sheet_style_delete_colrow (sheet, row, count, FALSE);
/* 6. Recompute dependencies */
......@@ -3124,8 +3140,6 @@ sheet_delete_rows (WorkbookControl *wbc, Sheet *sheet,
sheet->priv->recompute_visibility = TRUE;
sheet->priv->recompute_spans = TRUE;
sheet_flag_status_update_range (sheet, &reloc_info.origin);
if (sheet->priv->reposition_objects.row > row)
sheet->priv->reposition_objects.row = row;
return FALSE;
}
......@@ -3886,6 +3900,7 @@ sheet_region_merge (CommandContext *cc, Sheet *sheet, Range const *range)
{
GSList *test;
Range *r_copy;
Cell *cell;
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (range != NULL, TRUE);
......@@ -3911,6 +3926,10 @@ sheet_region_merge (CommandContext *cc, Sheet *sheet, Range const *range)
sheet->list_merged = g_slist_insert_sorted (sheet->list_merged, r_copy,
(GCompareFunc)range_row_cmp);
cell = sheet_cell_get (sheet, range->start.col, range->start.row);
if (cell != NULL)
cell->base.flags |= CELL_IS_MERGED;
sheet->priv->reposition_selection = TRUE;
return FALSE;
}
......@@ -3929,6 +3948,7 @@ gboolean
sheet_region_unmerge (CommandContext *cc, Sheet *sheet, Range const *range)
{
Range *r_copy;
Cell *cell;
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (range != NULL, TRUE);
......@@ -3942,6 +3962,10 @@ sheet_region_unmerge (CommandContext *cc, Sheet *sheet, Range const *range)
sheet->list_merged = g_slist_remove (sheet->list_merged, r_copy);
g_free (r_copy);
cell = sheet_cell_get (sheet, range->start.col, range->start.row);
if (cell != NULL)
cell->base.flags &= ~CELL_IS_MERGED;
sheet->priv->reposition_selection = TRUE;
return FALSE;
}
......
......@@ -86,6 +86,17 @@ style_font_new_simple (const char *font_name, double size, double scale,
}
font->ref_count++;
/* FIXME : how does one get the width of the
* widest character used to display numbers.
* Use 4 as the max width for now. Count the
* inter character spacing by measuring a
* string with 10 digits
*/
font->approx_width = font->gdk_font
? gnome_font_get_width_string (font->font, "4444444444") / 10.
: 1.;
#ifdef DEBUG_REF_COUNT
fprintf (stderr, __FUNCTION__ " font=%p name=%s%s%s ref_count=%d\n",
font, font->font_name,
......@@ -135,6 +146,14 @@ style_font_get_height (StyleFont const * const sf)
return gnome_display_font_height (sf->dfont);
}
float
style_font_get_width (StyleFont const *sf)
{
g_return_val_if_fail (sf != NULL, 0);
return sf->approx_width;
}
void
style_font_ref (StyleFont *sf)
{
......
......@@ -42,8 +42,9 @@ enum _StyleOrientation {
struct _StyleFont {
int ref_count;
char *font_name;
double size;
double scale;
float size;
float scale;
float approx_width;
GnomeDisplayFont *dfont;
GnomeFont *font;
GdkFont *gdk_font;
......@@ -87,8 +88,9 @@ StyleFont *style_font_new (const char *font_name,
StyleFont *style_font_new_simple (const char *font_name,
double size, double scale,
gboolean bold, gboolean italic);
GdkFont *style_font_gdk_font (StyleFont const * const sf);
int style_font_get_height (StyleFont const * const sf);
GdkFont *style_font_gdk_font (StyleFont const *sf);
int style_font_get_height (StyleFont const *sf);
float style_font_get_width (StyleFont const *sf);
void style_font_ref (StyleFont *sf);
void style_font_unref (StyleFont *sf);
......
......@@ -1979,8 +1979,15 @@ xml_read_cell (XmlParseContext *ctxt, xmlNodePtr tree)
}
child = child->next;
}
if (content == NULL)
if (content == NULL) {
content = xmlNodeGetContent (tree);
/* Early versions had newlines at the end of their content */
if (ctxt->version <= GNUM_XML_V1) {
char *tmp = strchr (content, '\n');
if (tmp != NULL)
*tmp = '\0';
}
}
if (content != NULL) {
if (is_post_52_array) {
......
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