Commit 816218f5 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Take new "translated" argument and respect it for booleans and errors. All

2002-12-17  Morten Welinder  <terra@diku.dk>

	* src/value.c (value_new_from_string): Take new "translated"
	argument and respect it for booleans and errors.  All callers
	changed.
parent ff9ff49a
......@@ -61,10 +61,6 @@ Pending Patches
for that format
6.9) autofilter export
7) Expr Parser
7.1) Move the host of flags into an GnmExprConventions (DONE)
7.2) Use conventions obj to generate strings {Morten}
8) Reinstate auto-format
8.1) Add characterization (units) to StyleFormat
8.2) Move type information to function flags. (DONE)
......@@ -278,6 +274,9 @@ Plugins
Finished
4) finish support for h/v only splits (DONE)
7) Expr Parser (DONE)
7.1) Move the host of flags into an GnmExprConventions (DONE)
7.2) Use conventions obj to generate strings (DONE)
9) Manual recalc (DONE)
9.1) finish calculation ui in workbook attr dialog (DONE)
10) fix highlighting of completion code (DONE)
......
2002-12-17 Morten Welinder <terra@diku.dk>
* src/value.c (value_new_from_string): Take new "translated"
argument and respect it for booleans and errors. All callers
changed.
* src/format.c (format_get_currency): Make really sure not to
return NULL.
......
......@@ -60,7 +60,7 @@ Morten:
* Make print-info use GnomePrintUnit instead of our own half-baked
stuff.
* Overhaul error value layers.
* Fix saving of error values in xml format.
* Fix loading and saving of error values in xml format.
--------------------------------------------------------------------------
Gnumeric 1.1.12
......
2002-12-17 Morten Welinder <terra@diku.dk>
* src/value.c (value_new_from_string): Take new "translated"
argument and respect it for booleans and errors. All callers
changed.
* src/format.c (format_get_currency): Make really sure not to
return NULL.
......
2002-12-17 Morten Welinder <terra@diku.dk>
* src/value.c (value_new_from_string): Take new "translated"
argument and respect it for booleans and errors. All callers
changed.
* src/format.c (format_get_currency): Make really sure not to
return NULL.
......
......@@ -1189,7 +1189,7 @@ xml_sax_cell_content (GsfXmlSAXState *gsf_state)
} else if (state->version >= GNUM_XML_V3 ||
xml_not_used_old_array_spec (cell, content)) {
if (value_type > 0) {
Value *v = value_new_from_string (value_type, content, value_fmt);
Value *v = value_new_from_string (value_type, content, value_fmt, FALSE);
cell_set_value (cell, v);
} else
cell_set_text (cell, content);
......
......@@ -389,7 +389,8 @@ value_new_array_empty (guint cols, guint rows)
}
Value *
value_new_from_string (ValueType t, char const *str, StyleFormat *sf)
value_new_from_string (ValueType t, char const *str, StyleFormat *sf,
gboolean translated)
{
Value *res = NULL;
switch (t) {
......@@ -397,13 +398,16 @@ value_new_from_string (ValueType t, char const *str, StyleFormat *sf)
res = value_new_empty ();
break;
case VALUE_BOOLEAN:
/* Is it a boolean */
if (0 == g_ascii_strcasecmp (str, _("TRUE")))
case VALUE_BOOLEAN: {
const char *C_true = N_("TRUE");
const char *C_false = N_("FALSE");
if (0 == g_ascii_strcasecmp (str, translated ? _(C_true) : C_true))
res = value_new_bool (TRUE);
else if (0 == g_ascii_strcasecmp (str, _("FALSE")))
else if (0 == g_ascii_strcasecmp (str, translated ? _(C_false) : C_false))
res = value_new_bool (FALSE);
break;
}
case VALUE_INTEGER: {
char *end;
......@@ -428,7 +432,20 @@ value_new_from_string (ValueType t, char const *str, StyleFormat *sf)
}
case VALUE_ERROR:
res = value_new_error (NULL, str);
/*
* Tricky. We are currently storing errors in translated
* format, so we might have to undo that.
*/
if (!translated) {
size_t i;
for (i = 0; i < G_N_ELEMENTS (standard_errors); i++)
if (strcmp (standard_errors[i].C_name, str) == 0) {
res = value_new_error_std (NULL, (GnmStdError)i);
break;
}
}
if (!res)
res = value_new_error (NULL, str);
break;
case VALUE_STRING:
......@@ -443,7 +460,8 @@ value_new_from_string (ValueType t, char const *str, StyleFormat *sf)
return NULL;
}
value_set_fmt (res, sf);
if (res)
value_set_fmt (res, sf);
return res;
}
......
......@@ -119,7 +119,7 @@ Value *value_new_cellrange_r (Sheet *sheet, Range const *r);
Value *value_new_array (guint cols, guint rows);
Value *value_new_array_empty (guint cols, guint rows);
Value *value_new_array_non_init (guint cols, guint rows);
Value *value_new_from_string (ValueType t, char const *str, StyleFormat *sf);
Value *value_new_from_string (ValueType t, char const *str, StyleFormat *sf, gboolean translated);
void value_release (Value *v);
void value_set_fmt (Value *v, StyleFormat const *fmt);
......
......@@ -1922,7 +1922,7 @@ xml_read_cell (XmlParseContext *ctxt, xmlNodePtr tree)
cell_set_value (cell,
value_new_from_string (value_type,
CXML2C (content),
value_fmt));
value_fmt, FALSE));
else {
/* cell_set_text would probably handle this.
* BUT, be extra careful just incase a sheet
......@@ -2076,7 +2076,9 @@ xml_read_filter_expr (XmlParseContext *ctxt, xmlNode *field)
if (tmp == NULL)
break;
v[i] = value_new_from_string (value_type,
CXML2C (tmp), NULL);
CXML2C (tmp),
NULL,
FALSE);
xmlFree (tmp);
}
......@@ -2957,7 +2959,10 @@ xml_read_cell_copy (XmlParseContext *ctxt, xmlNodePtr tree,
g_return_if_fail (expr != NULL);
#warning TODO : arrays
} else if (is_value)
cell->value = value_new_from_string (value_type, CXML2C (content), value_fmt);
cell->value = value_new_from_string (value_type,
CXML2C (content),
value_fmt,
FALSE);
else {
Value *val;
GnmExpr const *expr;
......
......@@ -1189,7 +1189,7 @@ xml_sax_cell_content (GsfXmlSAXState *gsf_state)
} else if (state->version >= GNUM_XML_V3 ||
xml_not_used_old_array_spec (cell, content)) {
if (value_type > 0) {
Value *v = value_new_from_string (value_type, content, value_fmt);
Value *v = value_new_from_string (value_type, content, value_fmt, FALSE);
cell_set_value (cell, v);
} else
cell_set_text (cell, content);
......
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