Commit 57e340cb authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Take cell value's format into account.

2003-07-10  Morten Welinder  <terra@gnome.org>

	* src/workbook-view.c (wb_view_format_feedback): Take cell value's
	format into account.

	* src/format.c (style_format_equal): New function.
parent 9ca56421
2003-07-10 Morten Welinder <terra@gnome.org>
* src/workbook-view.c (wb_view_format_feedback): Take cell value's
format into account.
* src/format.c (style_format_equal): New function.
2003-07-09 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/stf.c (stf_text_to_columns): do not pass null data to stf_dialog
......
......@@ -94,6 +94,7 @@ Morten:
* Use pool allocation for cell style tiles.
* Fix rounding and error problems with GCD and LCM.
* Make +/- buttons work for changing precision of fraction formats.
* Fix +/- buttons for cells with value formats.
--------------------------------------------------------------------------
......
2003-07-10 Morten Welinder <terra@gnome.org>
* src/workbook-view.c (wb_view_format_feedback): Take cell value's
format into account.
* src/format.c (style_format_equal): New function.
2003-07-09 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/stf.c (stf_text_to_columns): do not pass null data to stf_dialog
......
2003-07-10 Morten Welinder <terra@gnome.org>
* src/workbook-view.c (wb_view_format_feedback): Take cell value's
format into account.
* src/format.c (style_format_equal): New function.
2003-07-09 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/stf.c (stf_text_to_columns): do not pass null data to stf_dialog
......
......@@ -2039,6 +2039,15 @@ style_format_as_XL (StyleFormat const *fmt, gboolean localized)
return style_format_str_as_XL (fmt->format, localized);
}
gboolean
style_format_equal (StyleFormat const *a, StyleFormat const *b)
{
g_return_val_if_fail (a != NULL, FALSE);
g_return_val_if_fail (b != NULL, FALSE);
return (a == b) || strcmp (a->format, b->format) == 0;
}
/**
* style_format_ref :
* @sf :
......
......@@ -27,6 +27,7 @@ void style_format_ref (StyleFormat *sf);
void style_format_unref (StyleFormat *sf);
gboolean style_format_is_general (StyleFormat const *sf);
gboolean style_format_is_text (StyleFormat const *sf);
gboolean style_format_equal (StyleFormat const *a, StyleFormat const *b);
StyleFormat *style_format_general (void);
StyleFormat *style_format_default_date (void);
......
......@@ -193,18 +193,30 @@ wb_view_format_feedback (WorkbookView *wbv, gboolean display)
MStyle *mstyle = sheet_style_get (sv->sheet,
sv->edit_pos.col,
sv->edit_pos.row);
mstyle_ref (mstyle);
if (wbv->current_format != NULL) {
mstyle_unref (wbv->current_format);
/* Cheap anti-flicker.
* Compare pointers (content may be invalid)
* No need for an expensive compare.
*/
StyleFormat *sf_style = mstyle_get_format (mstyle);
StyleFormat *sf_cell;
Cell *cell;
if (style_format_is_general (sf_style) &&
(cell = sheet_cell_get (sv->sheet, sv->edit_pos.col, sv->edit_pos.row)) &&
cell->value && VALUE_FMT (cell->value))
sf_cell = VALUE_FMT (cell->value);
else
sf_cell = sf_style;
if (style_format_equal (sf_cell, sf_style)) {
if (mstyle == wbv->current_format)
return;
mstyle_ref (mstyle);
} else {
mstyle = mstyle_copy (mstyle);
mstyle_set_format (mstyle, sf_cell);
}
if (wbv->current_format != NULL)
mstyle_unref (wbv->current_format);
wbv->current_format = mstyle;
if (display) {
WORKBOOK_VIEW_FOREACH_CONTROL(wbv, control,
wb_control_format_feedback (control););
......
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