Commit 724d660c authored by Jody Goldberg's avatar Jody Goldberg

Updates spans and rendering when undoing a format application.

parent f5098d7b
2000-05-19 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_format_undo) : It is necessary to respan, resize
things when some format elements change.
* src/sheet-style.c (sheet_range_apply_style) : Changing the word
wrapping changes the size, changing the underline or strikethrough
does not.
(required_updates_for_style) : Split out from sheet_range_apply_style.
(sheet_style_attach_list) : Track the types of updates required.
2000-05-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_workbook_read) : Set the textdomain as well as the
......
2000-05-19 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_format_undo) : It is necessary to respan, resize
things when some format elements change.
* src/sheet-style.c (sheet_range_apply_style) : Changing the word
wrapping changes the size, changing the underline or strikethrough
does not.
(required_updates_for_style) : Split out from sheet_range_apply_style.
(sheet_style_attach_list) : Track the types of updates required.
2000-05-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_workbook_read) : Set the textdomain as well as the
......
2000-05-19 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_format_undo) : It is necessary to respan, resize
things when some format elements change.
* src/sheet-style.c (sheet_range_apply_style) : Changing the word
wrapping changes the size, changing the underline or strikethrough
does not.
(required_updates_for_style) : Split out from sheet_range_apply_style.
(sheet_style_attach_list) : Track the types of updates required.
2000-05-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_workbook_read) : Set the textdomain as well as the
......
2000-05-19 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_format_undo) : It is necessary to respan, resize
things when some format elements change.
* src/sheet-style.c (sheet_range_apply_style) : Changing the word
wrapping changes the size, changing the underline or strikethrough
does not.
(required_updates_for_style) : Split out from sheet_range_apply_style.
(sheet_style_attach_list) : Track the types of updates required.
2000-05-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_workbook_read) : Set the textdomain as well as the
......
2000-05-19 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_format_undo) : It is necessary to respan, resize
things when some format elements change.
* src/sheet-style.c (sheet_range_apply_style) : Changing the word
wrapping changes the size, changing the underline or strikethrough
does not.
(required_updates_for_style) : Split out from sheet_range_apply_style.
(sheet_style_attach_list) : Track the types of updates required.
2000-05-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_workbook_read) : Set the textdomain as well as the
......
2000-05-19 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_format_undo) : It is necessary to respan, resize
things when some format elements change.
* src/sheet-style.c (sheet_range_apply_style) : Changing the word
wrapping changes the size, changing the underline or strikethrough
does not.
(required_updates_for_style) : Split out from sheet_range_apply_style.
(sheet_style_attach_list) : Track the types of updates required.
2000-05-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_workbook_read) : Set the textdomain as well as the
......
2000-05-19 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_format_undo) : It is necessary to respan, resize
things when some format elements change.
* src/sheet-style.c (sheet_range_apply_style) : Changing the word
wrapping changes the size, changing the underline or strikethrough
does not.
(required_updates_for_style) : Split out from sheet_range_apply_style.
(sheet_style_attach_list) : Track the types of updates required.
2000-05-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_workbook_read) : Set the textdomain as well as the
......
......@@ -1004,13 +1004,22 @@ cmd_format_undo (GnumericCommand *cmd, CommandContext *context)
g_return_val_if_fail (me != NULL, TRUE);
if (me->old_styles) {
GSList *l;
for (l = me->old_styles; l; l = l->next) {
CmdFormatOldStyle *os = l->data;
sheet_style_attach_list (me->sheet, os->styles,
&os->pos, FALSE);
GSList *l1 = me->old_styles;
GSList *l2 = me->selection;
for (; l1; l1 = l1->next, l2 = l2->next) {
Range *r;
CmdFormatOldStyle *os = l1->data;
SpanCalcFlags flags =
sheet_style_attach_list (me->sheet, os->styles,
&os->pos, FALSE);
g_return_val_if_fail (l2 && l2->data, TRUE);
r = l2->data;
sheet_range_calc_spans (me->sheet, *r, flags);
if (flags != SPANCALC_SIMPLE)
rows_height_update (me->sheet, r);
}
}
......
......@@ -694,6 +694,30 @@ sheet_style_compute (const Sheet *sheet, int col, int row)
return mstyle;
}
/**
* required_updates_for_style
* @style: the style
*
* What changes are required after applying the supplied style.
*/
SpanCalcFlags
required_updates_for_style (MStyle *style)
{
gboolean const size_change =
(mstyle_is_element_set (style, MSTYLE_FONT_NAME) ||
mstyle_is_element_set (style, MSTYLE_FONT_BOLD) ||
mstyle_is_element_set (style, MSTYLE_FONT_ITALIC) ||
mstyle_is_element_set (style, MSTYLE_FONT_SIZE) ||
mstyle_is_element_set (style, MSTYLE_FIT_IN_CELL));
gboolean const format_change =
mstyle_is_element_set (style, MSTYLE_FORMAT);
return format_change
? SPANCALC_RE_RENDER|SPANCALC_RESIZE
: size_change ? SPANCALC_RESIZE
: SPANCALC_SIMPLE;
}
/**
* sheet_selection_apply_style:
* @sheet: the sheet in which can be found
......@@ -708,25 +732,13 @@ sheet_range_apply_style (Sheet *sheet,
const Range *range,
MStyle *style)
{
gboolean const font_change =
(mstyle_is_element_set (style, MSTYLE_FONT_NAME) ||
mstyle_is_element_set (style, MSTYLE_FONT_BOLD) ||
mstyle_is_element_set (style, MSTYLE_FONT_ITALIC) ||
mstyle_is_element_set (style, MSTYLE_FONT_UNDERLINE) ||
mstyle_is_element_set (style, MSTYLE_FONT_SIZE));
gboolean const format_change =
mstyle_is_element_set (style, MSTYLE_FORMAT);
SpanCalcFlags spanflags =
format_change ? SPANCALC_RE_RENDER|SPANCALC_RESIZE
: font_change ? SPANCALC_RESIZE
: SPANCALC_SIMPLE;
SpanCalcFlags const spanflags = required_updates_for_style (style);
sheet_style_attach (sheet, *range, style);
sheet_style_optimize (sheet, *range);
sheet_range_calc_spans (sheet, *range, spanflags);
if (format_change || font_change)
if (spanflags != SPANCALC_SIMPLE)
rows_height_update (sheet, range);
sheet_redraw_range (sheet, range);
......@@ -1166,14 +1178,15 @@ sheet_style_list_destroy (GList *list)
g_list_free (list);
}
void
SpanCalcFlags
sheet_style_attach_list (Sheet *sheet, const GList *list,
const CellPos *corner, gboolean transpose)
{
SpanCalcFlags spanflags = SPANCALC_SIMPLE;
const GList *l;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_val_if_fail (sheet != NULL, spanflags);
g_return_val_if_fail (IS_SHEET (sheet), spanflags);
/* Sluggish but simple implementation for now */
for (l = list; l; l = g_list_next (l)) {
......@@ -1186,7 +1199,9 @@ sheet_style_attach_list (Sheet *sheet, const GList *list,
mstyle_ref (sr->style);
sheet_style_attach (sheet, r, sr->style);
spanflags |= required_updates_for_style (sr->style);
}
return spanflags;
}
static void
......
......@@ -47,6 +47,13 @@ typedef enum {
SHEET_MODE_OBJECT_SELECTED,
} SheetModeType;
typedef enum {
SPANCALC_SIMPLE = 0x0, /* Just calc spans */
SPANCALC_RESIZE = 0x1, /* Calculate the size of the rendered result */
SPANCALC_RENDER = 0x2, /* render and size any unrendered cells */
SPANCALC_RE_RENDER = 0x4, /* render of all cells */
} SpanCalcFlags;
typedef struct _SheetPrivate SheetPrivate;
struct _Sheet {
......@@ -274,7 +281,7 @@ Range sheet_get_extent (const Sheet *sheet);
GList *sheet_get_styles_in_range (Sheet *sheet, const Range *r);
void sheet_style_list_destroy (GList *l);
void sheet_style_attach_list (Sheet *sheet, const GList *l,
SpanCalcFlags sheet_style_attach_list (Sheet *sheet, const GList *l,
const CellPos *corner, gboolean transpose);
gboolean sheet_range_splits_array (Sheet const *sheet,
......@@ -339,15 +346,11 @@ void sheet_cell_set_value (Cell *cell, Value *v, char const *optional_format);
void sheet_cell_set_text (Cell *cell, char const *str);
void sheet_range_set_text (EvalPos const *pos, Range const *r, char const *str);
typedef enum {
SPANCALC_SIMPLE = 0x0, /* Just calc spans */
SPANCALC_RESIZE = 0x1, /* Calculate the size of the rendered result */
SPANCALC_RENDER = 0x2, /* render and size any unrendered cells */
SPANCALC_RE_RENDER = 0x4, /* render of all cells */
} SpanCalcFlags;
void sheet_calc_spans (Sheet const *sheet, SpanCalcFlags const flags);
void sheet_range_calc_spans (Sheet *sheet, Range r, SpanCalcFlags const flags);
void sheet_cell_calc_span (Cell const *cell, SpanCalcFlags const flags);
SpanCalcFlags required_updates_for_style (MStyle *style);
/*
* Sheet, Bobobo objects
*/
......
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