Commit 08425f65 authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

Use formatting attributes whenever we format numbers. [#584380][#651561]

2011-08-01 Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* configure.in: Disable GTK depreciation check
	* src/cell-draw.c (cell_calc_layout): use gnm_rendered_value_get_color
	* src/cell.c (gnm_cell_get_render_color): ditto
	* src/gnm-format.c (gnm_format_layout): drop argument and change all
	callers
	(format_value_gstring): ditto
	(format_value): ditto
	(format_value_layout): new
	* src/gnm-format.h (gnm_format_layout): drop argument and change all
	callers
	(format_value_gstring): ditto
	(format_value): ditto
	(format_value_layout): new
	* src/rendered-value.c (gnm_rendered_value_new): include foreground
	color in attributes list
	(colour_selector_cb): new
	(colour_from_layout): new
	* src/widgets/gnm-format-sel.c (cb_generate_preview): use attributes
	* src/workbook-view.c (wb_view_auto_expr_recalc): use
	format_value_layout
parent 19559947
2011-08-01 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* configure.in: Disable GTK depreciation check
* src/cell-draw.c (cell_calc_layout): use gnm_rendered_value_get_color
* src/cell.c (gnm_cell_get_render_color): ditto
* src/gnm-format.c (gnm_format_layout): drop argument and change all
callers
(format_value_gstring): ditto
(format_value): ditto
(format_value_layout): new
* src/gnm-format.h (gnm_format_layout): drop argument and change all
callers
(format_value_gstring): ditto
(format_value): ditto
(format_value_layout): new
* src/rendered-value.c (gnm_rendered_value_new): include foreground
color in attributes list
(colour_selector_cb): new
(colour_from_layout): new
* src/widgets/gnm-format-sel.c (cb_generate_preview): use attributes
* src/workbook-view.c (wb_view_auto_expr_recalc): use
format_value_layout
2011-08-01 Morten Welinder <terra@gnome.org>
* Branch to 1.11.0
2011-07-31 Morten Welinder <terra@gnome.org>
* configure.in: Post-release bump.
......
Gnumeric 1.11.0
Andreas:
* Use formatting attributes whenever we format numbers.
[#584380][#651561]
--------------------------------------------------------------------------
Gnumeric 1.10.17
......
......@@ -271,7 +271,7 @@ fi
AC_SUBST(GNUMERIC_PLUGIN_LDFLAGS)
dnl disable for in stable release, enable for development series
if test $gnumeric_devel = yes; then
if test XXX$gnumeric_devel = yes; then
CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DPANGO_DISABLE_DEPRECATED"
if test "x$gnumeric_with_gtk" = xtrue; then
......
......@@ -54,7 +54,7 @@ xlsx_write_pivot_val (XLSXWriteState *state, GsfXMLOut *xml,
case VALUE_FLOAT: {
GOFormat const *fmt = go_val_get_fmt (v);
if (NULL != fmt && go_format_is_date (fmt)) {
char *d = format_value (state->date_fmt, v, NULL, -1, workbook_date_conv (state->base.wb));
char *d = format_value (state->date_fmt, v, -1, workbook_date_conv (state->base.wb));
gsf_xml_out_start_element (xml, "d");
gsf_xml_out_add_cstr_unchecked (xml, "v", d);
gsf_xml_out_end_element (xml);
......@@ -183,7 +183,7 @@ xlsx_write_date (XLSXWriteState *state, GsfXMLOut *xml,
char const *id, gnm_float v)
{
GOVal *tmp = go_val_new_float (v);
char *d = format_value (state->date_fmt, tmp, NULL, -1, workbook_date_conv (state->base.wb));
char *d = format_value (state->date_fmt, tmp, -1, workbook_date_conv (state->base.wb));
gsf_xml_out_add_cstr_unchecked (xml, id, d);
g_free (d);
go_val_free (tmp);
......@@ -277,7 +277,7 @@ xlsx_write_pivot_cache_definition (XLSXWriteState *state, GsfOutfile *wb_part,
go_val_as_float (cache->refreshed_on), -1);
else {
GOFormat const *format = go_format_new_from_XL ("yyyy-mm-dd\"T\"hh:mm:ss");
gchar *date = format_value (format, cache->refreshed_on, NULL, -1, NULL);
gchar *date = format_value (format, cache->refreshed_on, -1, NULL);
gsf_xml_out_add_cstr_unchecked (xml, "refreshedDateIso", date);
g_free (date);
go_format_unref (format);
......
......@@ -733,7 +733,7 @@ gnumeric_fixed (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
fmt = go_format_new_from_XL (format->str);
g_string_free (format, TRUE);
res = format_value (fmt, v, NULL, -1,
res = format_value (fmt, v, -1,
workbook_date_conv (ei->pos->sheet->workbook));
go_format_unref (fmt);
......@@ -949,7 +949,7 @@ gnumeric_text (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GOFormatNumberError err;
g_free (lfmt);
err = format_value_gstring (str, fmt, v, NULL, -1, conv);
err = format_value_gstring (str, fmt, v, -1, conv);
if (err) {
g_string_free (str, TRUE);
res = value_new_error_VALUE (ei->pos);
......@@ -1241,7 +1241,7 @@ gnumeric_dollar (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
sf = go_format_new_from_XL (fmt_str->str);
v = value_new_float (number);
s = format_value (sf, v, NULL, -1,
s = format_value (sf, v, -1,
workbook_date_conv (ei->pos->sheet->workbook));
value_release (v);
go_format_unref (sf);
......
......@@ -3022,12 +3022,12 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
if (f == gnm_floor (f)) {
gsf_xml_out_add_cstr_unchecked (state->xml,
OFFICE "value-type", "date");
str = format_value (state->date_fmt, cell->value, NULL, -1, workbook_date_conv (state->wb));
str = format_value (state->date_fmt, cell->value, -1, workbook_date_conv (state->wb));
gsf_xml_out_add_cstr (state->xml, OFFICE "date-value", str);
} else {
gsf_xml_out_add_cstr_unchecked (state->xml,
OFFICE "value-type", "date");
str = format_value (state->date_long_fmt, cell->value, NULL, -1, workbook_date_conv (state->wb));
str = format_value (state->date_long_fmt, cell->value, -1, workbook_date_conv (state->wb));
gsf_xml_out_add_cstr (state->xml, OFFICE "date-value", str);
}
g_free (str);
......@@ -3035,7 +3035,7 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
char *str;
gsf_xml_out_add_cstr_unchecked (state->xml,
OFFICE "value-type", "time");
str = format_value (state->time_fmt, cell->value, NULL, -1, workbook_date_conv (state->wb));
str = format_value (state->time_fmt, cell->value, -1, workbook_date_conv (state->wb));
gsf_xml_out_add_cstr (state->xml, OFFICE "time-value", str);
g_free (str);
} else {
......
......@@ -238,7 +238,7 @@ cell_calc_layout (GnmCell const *cell, GnmRenderedValue *rv, int y_direction,
rv->layout_natural_width, rv->layout_natural_height);
#endif
*res_color = rv->go_fore_color;
*res_color = gnm_rendered_value_get_color (rv);
*res_x = rect_x + hoffset;
*res_y = text_base;
......
......@@ -611,7 +611,7 @@ gnm_cell_get_render_color (GnmCell const *cell)
rv = gnm_cell_fetch_rendered_value (cell, TRUE);
return rv->go_fore_color;
return gnm_rendered_value_get_color (rv);
}
/**
......@@ -669,7 +669,7 @@ gnm_cell_get_entered_text (GnmCell const *cell)
return g_strconcat ("\'", tmp, NULL);
} else {
GOFormat const *fmt = gnm_cell_get_format (cell);
return format_value (fmt, v, NULL, -1, date_conv);
return format_value (fmt, v, -1, date_conv);
}
}
......
......@@ -1022,7 +1022,7 @@ cellregion_to_string (GnmCellRegion const *cr,
fmt = VALUE_FMT (cc->val);
format_value_gstring (line, fmt, cc->val,
NULL, -1, date_conv);
-1, date_conv);
}
if (++col <= extent.end.col)
g_string_append_c (line, '\t');
......
......@@ -655,8 +655,9 @@ make_expr_example (Sheet *sheet, const char *text, gboolean localized)
GnmValue *val = gnm_expr_top_eval
(texpr, &ep, GNM_EXPR_EVAL_PERMIT_NON_SCALAR);
GOFormat const *format = auto_style_format_suggest (texpr, &ep);
char *vtxt = format_value(format, val, NULL, -1,
workbook_date_conv (sheet->workbook));
char *vtxt = format_value (format, val, -1,
workbook_date_conv
(sheet->workbook));
go_format_unref (format);
gnm_expr_top_unref (texpr);
......
......@@ -413,7 +413,7 @@ cb_dialog_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
GOFormat *format = go_format_general ();
GnmValue *error_value = value_new_float (state->target_value -
value_get_as_float (state->set_cell->value));
char *target_str = format_value (format, error_value, NULL, -1,
char *target_str = format_value (format, error_value, -1,
workbook_date_conv (state->wb));
gtk_label_set_text (GTK_LABEL (state->target_value_label), target_str);
g_free (target_str);
......
......@@ -45,7 +45,7 @@ gnm_datetime_allow_negative (void)
GnmValue *v = value_new_int (-42);
GODateConventions const *conv =
go_date_conv_from_str ("Lotus:1900");
char *text = format_value (fmt, v, NULL, -1, conv);
char *text = format_value (fmt, v, -1, conv);
allow = (strcmp (text, "1899-11-19") == 0);
......
......@@ -83,7 +83,7 @@ format_value_common (PangoLayout *layout, GString *str,
const GOFormatMeasure measure,
const GOFontMetrics *metrics,
GOFormat const *format,
GnmValue const *value, GOColor *go_color,
GnmValue const *value,
int col_width,
GODateConventions const *date_conv,
gboolean unicode_minus)
......@@ -142,9 +142,9 @@ format_value_common (PangoLayout *layout, GString *str,
}
err = gnm_format_value_gstring (layout, str, measure, metrics,
format,
val, type, sval,
go_color,
val, type, sval, NULL,
col_width, date_conv, unicode_minus);
g_free (sval_free);
switch (err) {
......@@ -167,7 +167,7 @@ GOFormatNumberError
gnm_format_layout (PangoLayout *layout,
GOFontMetrics *metrics,
GOFormat const *format,
GnmValue const *value, GOColor *go_color,
GnmValue const *value,
int col_width,
GODateConventions const *date_conv,
gboolean unicode_minus)
......@@ -179,7 +179,7 @@ gnm_format_layout (PangoLayout *layout,
go_format_measure_pango,
metrics,
format,
value, go_color,
value,
col_width, date_conv, unicode_minus);
g_string_free (tmp_str, TRUE);
......@@ -192,18 +192,17 @@ gnm_format_layout (PangoLayout *layout,
* @str : append the result here.
* @format : #GOFormat.
* @value : #GnmValue to convert
* @go_color : return the #GOColor to use
* col_width : optional
* @date_conv : #GODateConventions.
*
**/
GOFormatNumberError
format_value_gstring (GString *str, GOFormat const *format,
GnmValue const *value, GOColor *go_color,
format_value_gstring (GString *str,
GOFormat const *format,
GnmValue const *value,
int col_width,
GODateConventions const *date_conv)
{
gboolean unicode_minus = FALSE;
GString *tmp_str = str->len ? g_string_sized_new (100) : NULL;
GOFormatNumberError err;
......@@ -211,24 +210,49 @@ format_value_gstring (GString *str, GOFormat const *format,
go_format_measure_strlen,
go_font_metrics_unit,
format,
value, go_color,
col_width, date_conv, unicode_minus);
value,
col_width, date_conv, FALSE);
if (tmp_str) {
if (!err)
go_string_append_gstring (str, tmp_str);
g_string_free (tmp_str, TRUE);
}
return err;
}
/**
* format_value_layout :
* @layout
* @format : #GOFormat.
* @value : #GnmValue to convert
* col_width : optional
* @date_conv : #GODateConventions.
*
**/
GOFormatNumberError
format_value_layout (PangoLayout *layout,
GOFormat const *format,
GnmValue const *value,
int col_width,
GODateConventions const *date_conv)
{
return format_value_common (layout, NULL,
go_format_measure_strlen,
go_font_metrics_unit,
format, value,
col_width, date_conv, FALSE);
}
gchar *
format_value (GOFormat const *format, GnmValue const *value, GOColor *go_color,
format_value (GOFormat const *format,
GnmValue const *value,
int col_width, GODateConventions const *date_conv)
{
GString *result = g_string_sized_new (20);
format_value_gstring (result, format, value, go_color,
format_value_gstring (result, format, value,
col_width, date_conv);
return g_string_free (result, FALSE);
}
......
......@@ -9,22 +9,25 @@
G_BEGIN_DECLS
char *format_value (GOFormat const *format,
GnmValue const *value, GOColor *go_color,
GnmValue const *value,
int col_width,
GODateConventions const *date_conv);
GOFormatNumberError format_value_gstring (GString *result,
GOFormat const *format,
GnmValue const *value,
GOColor *go_color,
int col_width,
GODateConventions const *date_conv);
GOFormatNumberError format_value_layout (PangoLayout *result,
GOFormat const *format,
GnmValue const *value,
int col_width,
GODateConventions const *date_conv);
GOFormatNumberError gnm_format_layout (PangoLayout *result,
GOFontMetrics *metrics,
GOFormat const *format,
GnmValue const *value,
GOColor *go_color,
int col_width,
GODateConventions const *date_conv,
gboolean unicode_minus);
......
......@@ -304,7 +304,7 @@ go_data_cache_dump_value (GOVal const *v)
GOFormat const *fmt = go_val_get_fmt (v);
if (NULL != fmt) {
char *str = format_value (fmt, v, NULL, -1, NULL);
char *str = format_value (fmt, v, -1, NULL);
g_print ("'%s'", str);
g_free (str);
} else
......
......@@ -109,7 +109,7 @@ render_val (GnmValue const *v, int i, int j,
} else if (v->type == VALUE_ARRAY)
v = value_area_get_x_y (v, i, j, ep);
return format_value (fmt, v, NULL, -1, date_conv);
return format_value (fmt, v, -1, date_conv);
}
/* ------------------------------------------------------------------------- */
......
......@@ -1075,7 +1075,7 @@ entry_to_float_with_format (GtkEntry *entry, gnm_float *the_float,
*the_float = value_get_as_float (value);
if (update) {
char *tmp = format_value (format, value, NULL, 16, NULL);
char *tmp = format_value (format, value, 16, NULL);
gtk_entry_set_text (entry, tmp);
g_free (tmp);
}
......@@ -1110,7 +1110,7 @@ entry_to_int (GtkEntry *entry, gint *the_int, gboolean update)
}
if (update) {
char *tmp = format_value (NULL, value, NULL, 16, NULL);
char *tmp = format_value (NULL, value, 16, NULL);
gtk_entry_set_text (entry, tmp);
g_free (tmp);
}
......@@ -1129,7 +1129,7 @@ void
float_to_entry (GtkEntry *entry, gnm_float the_float)
{
GnmValue *val = value_new_float (the_float);
char *text = format_value (NULL, val, NULL, 16, NULL);
char *text = format_value (NULL, val, 16, NULL);
value_release(val);
if (text != NULL) {
gtk_entry_set_text (entry, text);
......@@ -1148,7 +1148,7 @@ void
int_to_entry (GtkEntry *entry, gint the_int)
{
GnmValue *val = value_new_int (the_int);
char *text = format_value (NULL, val, NULL, 16, NULL);
char *text = format_value (NULL, val, 16, NULL);
value_release(val);
if (text != NULL) {
gtk_entry_set_text (entry, text);
......
......@@ -521,7 +521,7 @@ render_timestamp_with_format (GString *target, char const *number_format, HFRend
/* TODO : Check this assumption. Is it a localized format? */
format = go_format_new_from_XL (number_format);
format_value_gstring (target, format, info->date_time,
NULL, -1, info->date_conv);
-1, info->date_conv);
go_format_unref (format);
}
......
/* vim: set sw=8: */
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* rendered-value.c: Management & utility routines for formated
......@@ -162,7 +162,6 @@ gnm_rendered_value_remeasure (GnmRenderedValue *rv)
&rv->layout_natural_height);
}
/**
* gnm_rendered_value_new:
* @cell: The cell
......@@ -179,7 +178,6 @@ gnm_rendered_value_new (GnmCell const *cell,
double zoom)
{
GnmRenderedValue *res;
GOColor fore;
PangoLayout *layout;
PangoAttrList *attrs;
int rotation;
......@@ -188,6 +186,7 @@ gnm_rendered_value_new (GnmCell const *cell,
GnmStyle const *mstyle;
PangoDirection dir;
char const *text;
PangoAttribute *attr;
g_return_val_if_fail (cell != NULL, NULL);
......@@ -284,6 +283,14 @@ gnm_rendered_value_new (GnmCell const *cell,
pango_attr_list_unref (orig);
}
}
/* Add foreground color. */
attr = go_color_to_pango
((gnm_style_get_font_color (mstyle))->go_color, TRUE);
attr->start_index = 0;
attr->end_index = G_MAXUINT;
pango_attr_list_insert_before (attrs, attr);
pango_layout_set_attributes (res->layout, attrs);
pango_attr_list_unref (attrs);
......@@ -326,11 +333,9 @@ gnm_rendered_value_new (GnmCell const *cell,
g_string_append_c (out.accum, '}');
pango_layout_set_text (layout, out.accum->str, out.accum->len);
g_string_free (out.accum, TRUE);
fore = 0;
res->might_overflow = FALSE;
} else if (sheet->hide_zero && gnm_cell_is_zero (cell)) {
pango_layout_set_text (layout, "", 0);
fore = 0;
res->might_overflow = FALSE;
} else {
int col_width = -1;
......@@ -377,7 +382,7 @@ gnm_rendered_value_new (GnmCell const *cell,
err = gnm_format_layout (layout, font->go.metrics, format,
cell->value,
&fore, col_width, date_conv, TRUE);
col_width, date_conv, TRUE);
switch (err) {
case GO_FORMAT_NUMBER_DATE_ERROR:
......@@ -439,18 +444,6 @@ gnm_rendered_value_new (GnmCell const *cell,
}
/* ---------------------------------------- */
/*
* We store the foreground color separately because
* 1. It is [used to be?] slow to store it as an attribute, see
* http://bugzilla.gnome.org/show_bug.cgi?id=105322
* 2. This way we get to share the attribute list.
*/
if (0 == fore) {
GnmColor const *c = gnm_style_get_font_color (mstyle);
res->go_fore_color = c->go_color;
} else
res->go_fore_color = fore;
gnm_rendered_value_remeasure (res);
return res;
......@@ -533,6 +526,43 @@ gnm_rendered_value_get_text (GnmRenderedValue const *rv)
return pango_layout_get_text (rv->layout);
}
static gboolean
colour_selector_cb (PangoAttribute *attribute, PangoColor *color)
{
if (attribute->start_index == 0 &&
PANGO_ATTR_FOREGROUND == attribute->klass->type) {
*color = ((PangoAttrColor *)(attribute))->color;
return FALSE;
}
return FALSE;
}
static GOColor
colour_from_layout (PangoLayout *layout)
{
PangoAttrList *attrs = pango_layout_get_attributes (layout),
*fattrs;
PangoColor c;
if (go_pango_attr_list_is_empty (attrs))
return 0;
fattrs = pango_attr_list_filter
(attrs, (PangoAttrFilterFunc)colour_selector_cb, &c);
if (fattrs == NULL)
return 0;
pango_attr_list_unref (fattrs);
return GO_COLOR_FROM_RGBA (c.red, c.green, c.blue, 0xff);
}
GOColor
gnm_rendered_value_get_color (GnmRenderedValue const * rv)
{
return colour_from_layout (rv->layout);
}
/* ------------------------------------------------------------------------- */
static gboolean
......
......@@ -16,8 +16,6 @@ struct _GnmRenderedValue {
/* In pixels: */
guint16 indent_left, indent_right;
GOColor go_fore_color;
guint effective_halign : 8;
guint effective_valign : 5;
guint variable_width : 1; /* result depends on the width of cell */
......@@ -53,6 +51,8 @@ void gnm_rendered_value_remeasure (GnmRenderedValue *rv);
/* Return the value as a single string without format infomation. */
char const *gnm_rendered_value_get_text (GnmRenderedValue const * rv);
GOColor gnm_rendered_value_get_color (GnmRenderedValue const * rv);
/* ------------------------------------------------------------------------- */
struct _GnmRenderedValueCollection {
......
......@@ -217,7 +217,7 @@ afa_hint (AutoFiller *af, GnmCellPos *pos, int n)
{
AutoFillerArithmetic *afa = (AutoFillerArithmetic *)af;
GnmValue *v = afa_compute (afa, n);
char *res = format_value (NULL, v, NULL, -1, afa->dateconv);
char *res = format_value (NULL, v, -1, afa->dateconv);
value_release (v);
return res;
}
......@@ -627,7 +627,7 @@ afm_hint (AutoFiller *af, GnmCellPos *pos, int n)
char *res = NULL;
if (v) {
res = format_value (NULL, v, NULL, -1, afm->dateconv);
res = format_value (NULL, v, -1, afm->dateconv);
value_release (v);
}
......@@ -904,7 +904,7 @@ afc_set_cell_hint (AutoFiller *af, GnmCell *cell, GnmCellPos const *pos,
GODateConventions const *dateconv =
workbook_date_conv (sheet->workbook);
GOFormat const *format = gnm_cell_get_format (src);
return format_value (format, src->value, NULL, -1,
return format_value (format, src->value, -1,
dateconv);
}
} else {
......
......@@ -173,7 +173,7 @@ filter_cell_contents (GnmCell *cell)
GOFormat const *format = gnm_cell_get_format (cell);
GODateConventions const *date_conv =
workbook_date_conv (cell->base.sheet->workbook);
return format_value (format, cell->value, NULL, -1, date_conv);
return format_value (format, cell->value, -1, date_conv);
}
static gboolean
......@@ -210,7 +210,7 @@ filter_expr_eval (GnmFilterOp op, GnmValue const *src, GORegexp const *regexp,
if (VALUE_IS_STRING (target) && VALUE_IS_NUMBER (src)) {
GODateConventions const *date_conv =
workbook_date_conv (cell->base.sheet->workbook);
char *str = format_value (NULL, src, NULL, -1, date_conv);
char *str = format_value (NULL, src, -1, date_conv);
fake_val = value_new_string_nocopy (str);
src = fake_val;
}
......
......@@ -3392,7 +3392,7 @@ cb_collect (GnmValueIter const *iter, GtkListStore *model)
if (NULL != iter->v) {
GOFormat const *fmt = (NULL != iter->cell_iter)
? gnm_cell_get_format (iter->cell_iter->cell) : NULL;
char *label = format_value (fmt, iter->v, NULL, -1, NULL);
char *label = format_value (fmt, iter->v, -1, NULL);
gtk_list_store_set (model, &list_iter, 0, label, -1);
g_free (label);
} else
......
......@@ -155,7 +155,7 @@ try_auto_float (GnmValue *value, const GOFormat *format,
if (is_date || is_time > 0)
return NULL;
return format_value (go_format_general (), value, NULL, -1, date_conv);
return format_value (go_format_general (), value, -1, date_conv);
}
......@@ -209,7 +209,7 @@ try_auto_date (GnmValue *value, const GOFormat *format,
}
actual = go_format_new_from_XL (xlfmt->str);
g_string_free (xlfmt, TRUE);
res = format_value (actual, value, NULL, -1, date_conv);
res = format_value (actual, value, -1, date_conv);
go_format_unref (actual);
return res;
......
......@@ -301,7 +301,7 @@ cb_get_content (GnmCellIter const *iter, GsfOutput *buf)
tmp = gnm_expr_top_as_string (cell->base.texpr,
&iter->pp, iter->pp.sheet->convs);
else if (VALUE_FMT (cell->value) != NULL)
tmp = format_value (NULL, cell->value, NULL, -1,
tmp = format_value (NULL, cell->value, -1,
workbook_date_conv (iter->pp.wb));
else
tmp = value_get_as_string (cell->value);
......
......@@ -120,7 +120,7 @@ do_tabulation (WorkbookControl *wbc,
sheets = g_new (Sheet *, counts[dim]);
for (i = 0; i < counts[dim]; i++) {
GnmValue *v = value_new_float (val);
char *base_name = format_value (sf, v, NULL, -1,
char *base_name = format_value (sf, v, -1,
workbook_date_conv (wb));
char *unique_name =
workbook_sheet_get_free_name (wb,
......
......@@ -820,13 +820,13 @@ insert_date_time_common (WBCGtk *wbcg, gboolean do_date, gboolean do_time)
if (do_date) {
GOFormat *fmt = gnm_format_for_date_editing (cell);
dtxt = format_value (fmt, v, NULL, -1, date_conv);
dtxt = format_value (fmt, v, -1, date_conv);
go_format_unref (fmt);
}
if (do_time) {
GOFormat const *fmt = go_format_default_time ();
ttxt = format_value (fmt, v, NULL, -1, date_conv);
ttxt = format_value (fmt, v, -1, date_conv);
}
if (do_date && do_time) {
......
......@@ -1036,12 +1036,12 @@ wbcg_edit_start (WBCGtk *wbcg,
}
text = format_value (new_fmt, cell->value,
NULL, -1, date_conv);
-1, date_conv);
if (!text || text[0] == 0) {
g_free (text);
text = format_value (go_format_general (),
cell->value,
NULL, -1,
-1,
date_conv);
}
set_text = TRUE;
......@@ -1052,7 +1052,7 @@ wbcg_edit_start (WBCGtk *wbcg,
case GO_FORMAT_TIME: {
GOFormat *new_fmt = guess_time_format (NULL, f);
text = format_value (new_fmt, cell->value, NULL, -1,
text = format_value (new_fmt, cell->value, -1,
workbook_date_conv (sv->sheet->workbook));
set_text = TRUE;
go_format_unref (new_fmt);
......
......@@ -125,7 +125,7 @@ cb_collect_content (GnmCellIter const *iter, UniqueCollection *uc)
GnmValue const *v = cell->value;
g_hash_table_replace (uc->hash,
value_dup (v),
format_value (fmt, v, NULL, -1, uc->date_conv));
format_value (fmt, v, -1, uc->date_conv));
}
return NULL;
......
......@@ -21,18 +21,37 @@
#include "gnm-format-sel.h"
#include "src/value.h"
#include "src/gnm-format.h"
#include "src/style-font.h"
static char *
cb_generate_preview (GOFormatSel *gfs, GOColor *c)
cb_generate_preview (GOFormatSel *gfs, PangoAttrList **attrs)
{
GnmValue const *v = g_object_get_data (G_OBJECT (gfs), "value");
GOFormat const *fmt = go_format_sel_get_fmt (gfs);
if (NULL == v)
return NULL;
if (go_format_is_general (fmt) && VALUE_FMT (v) != NULL)
fmt = VALUE_FMT (v);
return format_value (fmt, v, c, -1, go_format_sel_get_dateconv (gfs));
else {
GOFormat const *fmt = go_format_sel_get_fmt (gfs);
PangoContext *context = gnm_pango_context_get ();
PangoLayout *layout = pango_layout_new (context);
char *str;
GOFormatNumberError err;
if (go_format_is_general (fmt) && VALUE_FMT (v) != NULL)
fmt = VALUE_FMT (v