Commit 27ababf2 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Return a StyleFormat, not a [vile XL format] string. All callers changed.

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

	* src/format.c (format_toggle_thousands, format_add_decimal,
	format_remove_decimal, reformat_decimals): Return a StyleFormat,
	not a [vile XL format] string.  All callers changed.
parent 622efe2c
2003-07-11 Morten Welinder <terra@gnome.org>
* src/format.c (format_toggle_thousands, format_add_decimal,
format_remove_decimal, reformat_decimals): Return a StyleFormat,
not a [vile XL format] string. All callers changed.
2003-07-10 Morten Welinder <terra@gnome.org>
* src/format.c (format_toggle_thousands): New function.
......
2003-07-11 Morten Welinder <terra@gnome.org>
* src/format.c (format_toggle_thousands, format_add_decimal,
format_remove_decimal, reformat_decimals): Return a StyleFormat,
not a [vile XL format] string. All callers changed.
2003-07-10 Morten Welinder <terra@gnome.org>
* src/format.c (format_toggle_thousands): New function.
......
2003-07-11 Morten Welinder <terra@gnome.org>
* src/format.c (format_toggle_thousands, format_add_decimal,
format_remove_decimal, reformat_decimals): Return a StyleFormat,
not a [vile XL format] string. All callers changed.
2003-07-10 Morten Welinder <terra@gnome.org>
* src/format.c (format_toggle_thousands): New function.
......
......@@ -919,12 +919,13 @@ find_decimal_char (char const *str)
/* An helper function which modify the number of decimals displayed
* and recreate the format string by calling the good function */
static char *
static StyleFormat *
reformat_decimals (FormatCharacteristics *fc,
void (*format_function) (GString *res, FormatCharacteristics const * fmt),
int step)
{
GString *res;
StyleFormat *sf;
/* Be sure that the number of decimals displayed will remain correct */
if ((fc->num_decimals+step > 30) || (fc->num_decimals+step <0))
......@@ -935,7 +936,9 @@ reformat_decimals (FormatCharacteristics *fc,
res = g_string_new (NULL);
(*format_function) (res, fc);
return g_string_free (res, FALSE);
sf = style_format_new_XL (res->str, FALSE);
g_string_free (res, TRUE);
return sf;
}
/*
......@@ -945,7 +948,7 @@ reformat_decimals (FormatCharacteristics *fc,
*
* Returns NULL if the new format would not change things
*/
char *
StyleFormat *
format_remove_decimal (StyleFormat const *fmt)
{
int offset = 1;
......@@ -954,6 +957,7 @@ format_remove_decimal (StyleFormat const *fmt)
char const *format_string = fmt->format;
FormatFamily ff;
FormatCharacteristics fc;
StyleFormat *sf;
/* First try to classify the format so we can regenerate it */
ff = cell_format_classify (fmt, &fc);
......@@ -1015,7 +1019,9 @@ format_remove_decimal (StyleFormat const *fmt)
strcpy (p, p + offset);
return ret;
sf = style_format_new_XL (ret, FALSE);
g_free (ret);
return sf;
}
/*
......@@ -1026,7 +1032,7 @@ format_remove_decimal (StyleFormat const *fmt)
*
* Returns NULL if the new format would not change things
*/
char *
StyleFormat *
format_add_decimal (StyleFormat const *fmt)
{
char const *pre = NULL;
......@@ -1035,6 +1041,7 @@ format_add_decimal (StyleFormat const *fmt)
char const *format_string = fmt->format;
FormatFamily ff;
FormatCharacteristics fc;
StyleFormat *sf;
/* First try to classify the format so we can regenerate it */
ff = cell_format_classify (fmt, &fc);
......@@ -1109,15 +1116,18 @@ format_add_decimal (StyleFormat const *fmt)
res[pre-format_string + 1] = '0';
strcpy (res + (pre - format_string) + 2, post);
return res;
sf = style_format_new_XL (res, FALSE);
g_free (res);
return sf;
}
char *
StyleFormat *
format_toggle_thousands (StyleFormat const *fmt)
{
FormatFamily ff;
FormatCharacteristics fc;
GString *newformat;
StyleFormat *sf;
/* First try to classify the format so we can regenerate it */
ff = cell_format_classify (fmt, &fc);
......@@ -1146,7 +1156,9 @@ format_toggle_thousands (StyleFormat const *fmt)
return NULL;
}
return g_string_free (newformat, FALSE);
sf = style_format_new_XL (newformat->str, FALSE);
g_string_free (newformat, TRUE);
return sf;
}
/*********************************************************************/
......
......@@ -44,9 +44,9 @@ void format_value_gstring (GString *result, StyleFormat const *format,
void format_color_init (void);
void format_color_shutdown (void);
char *format_add_decimal (StyleFormat const *fmt);
char *format_remove_decimal (StyleFormat const *fmt);
char *format_toggle_thousands (StyleFormat const *fmt);
StyleFormat *format_add_decimal (StyleFormat const *fmt);
StyleFormat *format_remove_decimal (StyleFormat const *fmt);
StyleFormat *format_toggle_thousands (StyleFormat const *fmt);
typedef struct {
int right_optional, right_spaces, right_req, right_allowed;
......
......@@ -320,12 +320,12 @@ cb_format_as_percent (GtkWidget *ignore, WorkbookControlGUI *wbcg)
static void
modify_format (WorkbookControlGUI *wbcg,
char *(*format_modify_fn) (StyleFormat const *format),
StyleFormat *(*format_modify_fn) (StyleFormat const *format),
char const *descriptor)
{
WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
WorkbookView const *wbv;
char *new_fmt;
StyleFormat *new_fmt;
wbv = wb_control_view (wbc);
g_return_if_fail (wbv != NULL);
......@@ -334,9 +334,9 @@ modify_format (WorkbookControlGUI *wbcg,
new_fmt = (*format_modify_fn) (mstyle_get_format (wbv->current_format));
if (new_fmt != NULL) {
MStyle *style = mstyle_new ();
mstyle_set_format_text (style, new_fmt);
mstyle_set_format (style, new_fmt);
cmd_selection_format (wbc, style, NULL, descriptor);
g_free (new_fmt);
style_format_unref (new_fmt);
}
}
......
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