Commit 76914832 authored by Morten Welinder's avatar Morten Welinder
Browse files

cell format: use gnm_cell_get_format

As opposed to old-style getting the mstyle and the format from that.
This handles values with format better.
parent 803e1eb4
......@@ -297,7 +297,7 @@ paste_cell (int target_col, int target_row,
if (dat->translate_dates && oldval && VALUE_IS_FLOAT (oldval)) {
GOFormat const *fmt = VALUE_FMT (oldval)
? VALUE_FMT (oldval)
: gnm_style_get_format (gnm_cell_get_style (dst));
: gnm_cell_get_format (dst);
if (go_format_is_date (fmt) > 0) {
gnm_float fnew = go_date_conv_translate
(value_get_as_float (oldval),
......
......@@ -216,7 +216,7 @@ cb_dialog_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
}
format = gnm_style_get_format (gnm_cell_get_style (state->set_cell));
format = gnm_cell_get_format (state->set_cell);
if (entry_to_float_with_format (GTK_ENTRY(state->to_value_entry),
&state->target_value, TRUE, format)){
go_gtk_notice_nonmodal_dialog (GTK_WINDOW(state->dialog),
......@@ -228,7 +228,7 @@ cb_dialog_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
return;
}
format = gnm_style_get_format (gnm_cell_get_style (state->change_cell));
format = gnm_cell_get_format (state->change_cell);
if (entry_to_float_with_format (GTK_ENTRY(state->at_least_entry),
&state->xmin, TRUE, format)) {
state->xmin = -max_range_val;
......
......@@ -119,7 +119,7 @@ get_grid_float_entry (GtkGrid *g, int y, int x, GnmCell *cell, gnm_float *number
g_return_val_if_fail (GTK_IS_ENTRY (w), 3);
*wp = GTK_ENTRY (w);
format = gnm_style_get_format (gnm_cell_get_style (cell));
format = gnm_cell_get_format (cell);
return (with_default?
entry_to_float_with_format_default (*wp, number, TRUE, format,
......
......@@ -1241,7 +1241,7 @@ stf_cell_set_text (GnmCell *cell, char const *text)
{
GnmExprTop const *texpr;
GnmValue *val;
GOFormat const *fmt = gnm_style_get_format (gnm_cell_get_style (cell));
GOFormat const *fmt = gnm_cell_get_format (cell);
const GODateConventions *date_conv = sheet_date_conv (cell->base.sheet);
if (!go_format_is_text (fmt) && *text == '=' && text[1] != 0) {
......
......@@ -63,17 +63,6 @@ tabulation_eval (G_GNUC_UNUSED Workbook *wb, int dims, gnm_float const *x,
: value_new_error_VALUE (NULL);
}
static GOFormat const *
my_get_format (GnmCell const *cell)
{
GOFormat const *format = gnm_style_get_format (gnm_cell_get_style (cell));
if (go_format_is_general (format) &&
cell->value != NULL && VALUE_FMT (cell->value) != NULL)
return VALUE_FMT (cell->value);
return format;
}
/**
* do_tabulation:
* @wbc: control
......@@ -90,7 +79,7 @@ do_tabulation (WorkbookControl *wbc,
GSList *sheet_idx = NULL;
Sheet *sheet = NULL;
gboolean sheetdim = (!data->with_coordinates && data->dims >= 3);
GOFormat const *targetformat = my_get_format (data->target);
GOFormat const *targetformat = gnm_cell_get_format (data->target);
int row = 0;
gnm_float *values = g_new (gnm_float, data->dims);
......@@ -112,7 +101,7 @@ do_tabulation (WorkbookControl *wbc,
values[i] = data->minima[i];
index[i] = 0;
formats[i] = my_get_format (data->cells[i]);
formats[i] = gnm_cell_get_format (data->cells[i]);
old_values[i] = value_dup (data->cells[i]->value);
/* Silently truncate at the edges. */
......@@ -133,7 +122,7 @@ do_tabulation (WorkbookControl *wbc,
if (sheetdim) {
int dim = 2;
gnm_float val = data->minima[dim];
GOFormat const *sf = my_get_format (data->cells[dim]);
GOFormat const *sf = gnm_cell_get_format (data->cells[dim]);
int i;
sheets = g_new (Sheet *, counts[dim]);
......
Supports Markdown
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