Commit 75375f14 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

cell->entered_text is back, now only used for typo correction. Maybe I

1998-12-28  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/cell.h: cell->entered_text is back, now only used for typo
	correction.  Maybe I will use it for saving.

	* src/fn-string.c (gnumeric_right): Use value_str.
parent d88cc665
1998-12-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.h: cell->entered_text is back, now only used for typo
correction. Maybe I will use it for saving.
* src/fn-string.c (gnumeric_right): Use value_str.
(gnumeric_char): same
(gnumeric_left): same
* src/expr.c (value_str): New function.
* src/xml-io.c (writeXmlCell): Use cell_get_content instead of
cell_get_text.
......
1998-12-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.h: cell->entered_text is back, now only used for typo
correction. Maybe I will use it for saving.
* src/fn-string.c (gnumeric_right): Use value_str.
(gnumeric_char): same
(gnumeric_left): same
* src/expr.c (value_str): New function.
* src/xml-io.c (writeXmlCell): Use cell_get_content instead of
cell_get_text.
......
1998-12-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.h: cell->entered_text is back, now only used for typo
correction. Maybe I will use it for saving.
* src/fn-string.c (gnumeric_right): Use value_str.
(gnumeric_char): same
(gnumeric_left): same
* src/expr.c (value_str): New function.
* src/xml-io.c (writeXmlCell): Use cell_get_content instead of
cell_get_text.
......
1998-12-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.h: cell->entered_text is back, now only used for typo
correction. Maybe I will use it for saving.
* src/fn-string.c (gnumeric_right): Use value_str.
(gnumeric_char): same
(gnumeric_left): same
* src/expr.c (value_str): New function.
* src/xml-io.c (writeXmlCell): Use cell_get_content instead of
cell_get_text.
......
......@@ -16,17 +16,12 @@
static Value *
gnumeric_char (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
Value *v;
char result [2];
result [0] = value_get_as_int (argv [0]);
result [1] = 0;
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (result);
return v;
return value_str (result);
}
static Value *
......@@ -126,10 +121,8 @@ gnumeric_left (void *sheet, GList *expr_node_list, int eval_col, int eval_row, c
s [count] = 0;
value_release (vs);
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (s);
v = value_str (s);
g_free (s);
return v;
......@@ -189,10 +182,8 @@ gnumeric_right (void *sheet, GList *expr_node_list, int eval_col, int eval_row,
s [count] = 0;
value_release (vs);
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (s);
v = value_str (s);
g_free (s);
return v;
......
......@@ -53,9 +53,18 @@ cell_set_formula (Cell *cell, char *text)
&desired_format,
&error_msg);
if (cell->parsed_node == NULL){
cell->flags |= CELL_ERROR;
cell_set_rendered_text (cell, error_msg);
if (cell->value)
value_release (cell->value);
cell->value = NULL;
return;
} else {
if (cell->flags & CELL_ERROR)
cell->flags &= ~CELL_ERROR;
}
if (desired_format && strcmp (cell->style->format->format, "General") == 0){
style_format_unref (cell->style->format);
cell->style->format = style_format_new (desired_format);
......@@ -482,6 +491,10 @@ cell_set_text_simple (Cell *cell, char *text)
cell_modified (cell);
if (cell->entered_text)
string_unref (cell->entered_text);
cell->entered_text = string_get (text);
if (cell->value){
value_release (cell->value);
cell->value = NULL;
......@@ -1502,7 +1515,7 @@ cell_get_text (Cell *cell)
if (cell->value)
str = format_value (cell->style->format, cell->value, NULL);
else
str = g_strdup (cell->text->str);
str = g_strdup (cell->entered_text->str);
return str;
}
......@@ -1541,7 +1554,7 @@ cell_get_content (Cell *cell)
if (cell->value)
str = value_string (cell->value);
else
str = g_strdup (cell->text->str);
str = g_strdup (cell->entered_text->str);
return str;
}
......@@ -50,7 +50,7 @@ typedef struct {
ColRowInfo *row;
/* Text as entered by the user */
/* String *entered_text; */
String *entered_text;
/* Type of the content and the actual parsed content */
ExprTree *parsed_node; /* Parse tree with the expression */
......
......@@ -310,6 +310,17 @@ value_int (int i)
return v;
}
Value *
value_str (char *str)
{
Value *v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (str);
return v;
}
/*
* Casts a value to float if it is integer, and returns
* a new Value * if required
......
......@@ -159,7 +159,8 @@ Value *value_duplicate (Value *value);
Value *value_float (float_t f);
Value *value_int (int i);
Value *value_str (char *str);
int yyparse (void);
/* Setup of the symbol table */
......
......@@ -16,17 +16,12 @@
static Value *
gnumeric_char (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
Value *v;
char result [2];
result [0] = value_get_as_int (argv [0]);
result [1] = 0;
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (result);
return v;
return value_str (result);
}
static Value *
......@@ -126,10 +121,8 @@ gnumeric_left (void *sheet, GList *expr_node_list, int eval_col, int eval_row, c
s [count] = 0;
value_release (vs);
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (s);
v = value_str (s);
g_free (s);
return v;
......@@ -189,10 +182,8 @@ gnumeric_right (void *sheet, GList *expr_node_list, int eval_col, int eval_row,
s [count] = 0;
value_release (vs);
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (s);
v = value_str (s);
g_free (s);
return v;
......
......@@ -16,17 +16,12 @@
static Value *
gnumeric_char (struct FunctionDefinition *i, Value *argv [], char **error_string)
{
Value *v;
char result [2];
result [0] = value_get_as_int (argv [0]);
result [1] = 0;
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (result);
return v;
return value_str (result);
}
static Value *
......@@ -126,10 +121,8 @@ gnumeric_left (void *sheet, GList *expr_node_list, int eval_col, int eval_row, c
s [count] = 0;
value_release (vs);
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (s);
v = value_str (s);
g_free (s);
return v;
......@@ -189,10 +182,8 @@ gnumeric_right (void *sheet, GList *expr_node_list, int eval_col, int eval_row,
s [count] = 0;
value_release (vs);
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (s);
v = value_str (s);
g_free (s);
return v;
......
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