Commit e605d42e authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

comment out the warning. These the life cycles of names are too fluid to


2000-12-10  Jody Goldberg <jgoldberg@home.com>

	* src/expr-name.c (expr_name_invalidate_refs_sheet) : comment out the
	  warning.  These the life cycles of names are too fluid to scare
	  users yet.
	(expr_name_invalidate_refs_wb) : Ditto.

2000-12-10  Jody Goldberg <jgoldberg@home.com>

	* src/cell.c (cell_set_text) : send the current format to the
	  number matcher..
	* src/sheet.c (sheet_cell_set_text) : Ditto.

	* src/parse-util.c (parse_text_value_or_expr) : send the curent
	  format to the number matcher.

	* src/number-match.c (format_match) : take the current format as a
	  parameter.  Begin using it to handle cells formated as text.

	* src/format.c (style_format_is_text)  utility routine.

2000-12-09  Jody Goldberg <jgoldberg@home.com>

	* src/selection.c (sheet_selection_set_internal) : rename from
	  sheet_selection_set and add the 'just_add_it' flag to indicate that
	  we don't need to do anything fancy.
parent 4f042a12
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (expr_name_invalidate_refs_sheet) : comment out the
warning. These the life cycles of names are too fluid to scare
users yet.
(expr_name_invalidate_refs_wb) : Ditto.
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_set_text) : send the current format to the
number matcher..
* src/sheet.c (sheet_cell_set_text) : Ditto.
* src/parse-util.c (parse_text_value_or_expr) : send the curent
format to the number matcher.
* src/number-match.c (format_match) : take the current format as a
parameter. Begin using it to handle cells formated as text.
* src/format.c (style_format_is_text) utility routine.
2000-12-09 Jody Goldberg <jgoldberg@home.com>
* src/selection.c (sheet_selection_set_internal) : rename from
sheet_selection_set and add the 'just_add_it' flag to indicate that
we don't need to do anything fancy.
2000-12-09 Chema Celorio <chema@celorio.com>
* src/xml-io.c (xml_write_names): Always wrinte a <Names> node,
......
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (expr_name_invalidate_refs_sheet) : comment out the
warning. These the life cycles of names are too fluid to scare
users yet.
(expr_name_invalidate_refs_wb) : Ditto.
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_set_text) : send the current format to the
number matcher..
* src/sheet.c (sheet_cell_set_text) : Ditto.
* src/parse-util.c (parse_text_value_or_expr) : send the curent
format to the number matcher.
* src/number-match.c (format_match) : take the current format as a
parameter. Begin using it to handle cells formated as text.
* src/format.c (style_format_is_text) utility routine.
2000-12-09 Jody Goldberg <jgoldberg@home.com>
* src/selection.c (sheet_selection_set_internal) : rename from
sheet_selection_set and add the 'just_add_it' flag to indicate that
we don't need to do anything fancy.
2000-12-09 Chema Celorio <chema@celorio.com>
* src/xml-io.c (xml_write_names): Always wrinte a <Names> node,
......
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (expr_name_invalidate_refs_sheet) : comment out the
warning. These the life cycles of names are too fluid to scare
users yet.
(expr_name_invalidate_refs_wb) : Ditto.
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_set_text) : send the current format to the
number matcher..
* src/sheet.c (sheet_cell_set_text) : Ditto.
* src/parse-util.c (parse_text_value_or_expr) : send the curent
format to the number matcher.
* src/number-match.c (format_match) : take the current format as a
parameter. Begin using it to handle cells formated as text.
* src/format.c (style_format_is_text) utility routine.
2000-12-09 Jody Goldberg <jgoldberg@home.com>
* src/selection.c (sheet_selection_set_internal) : rename from
sheet_selection_set and add the 'just_add_it' flag to indicate that
we don't need to do anything fancy.
2000-12-09 Chema Celorio <chema@celorio.com>
* src/xml-io.c (xml_write_names): Always wrinte a <Names> node,
......
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (expr_name_invalidate_refs_sheet) : comment out the
warning. These the life cycles of names are too fluid to scare
users yet.
(expr_name_invalidate_refs_wb) : Ditto.
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_set_text) : send the current format to the
number matcher..
* src/sheet.c (sheet_cell_set_text) : Ditto.
* src/parse-util.c (parse_text_value_or_expr) : send the curent
format to the number matcher.
* src/number-match.c (format_match) : take the current format as a
parameter. Begin using it to handle cells formated as text.
* src/format.c (style_format_is_text) utility routine.
2000-12-09 Jody Goldberg <jgoldberg@home.com>
* src/selection.c (sheet_selection_set_internal) : rename from
sheet_selection_set and add the 'just_add_it' flag to indicate that
we don't need to do anything fancy.
2000-12-09 Chema Celorio <chema@celorio.com>
* src/xml-io.c (xml_write_names): Always wrinte a <Names> node,
......
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/expr-name.c (expr_name_invalidate_refs_sheet) : comment out the
warning. These the life cycles of names are too fluid to scare
users yet.
(expr_name_invalidate_refs_wb) : Ditto.
2000-12-10 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_set_text) : send the current format to the
number matcher..
* src/sheet.c (sheet_cell_set_text) : Ditto.
* src/parse-util.c (parse_text_value_or_expr) : send the curent
format to the number matcher.
* src/number-match.c (format_match) : take the current format as a
parameter. Begin using it to handle cells formated as text.
* src/format.c (style_format_is_text) utility routine.
2000-12-09 Jody Goldberg <jgoldberg@home.com>
* src/selection.c (sheet_selection_set_internal) : rename from
sheet_selection_set and add the 'just_add_it' flag to indicate that
we don't need to do anything fancy.
2000-12-09 Chema Celorio <chema@celorio.com>
* src/xml-io.c (xml_write_names): Always wrinte a <Names> node,
......
......@@ -977,7 +977,7 @@ applix_read_cells (ApplixReadState *state)
if (!val_is_string)
/* Does it match any formats */
val = format_match (ptr, NULL);
val = format_match (ptr, NULL, NULL);
if (val == NULL)
/* TODO : Could this happen ? */
......@@ -1073,7 +1073,7 @@ applix_read_cells (ApplixReadState *state)
#endif
/* Does it match any formats */
if (!val_is_string)
val = format_match (ptr, NULL);
val = format_match (ptr, NULL, NULL);
if (val == NULL)
val = value_new_string (ptr);
......
......@@ -819,7 +819,7 @@ gnumeric_n (FunctionEvalInfo *ei, Value **argv)
return value_new_error (ei->pos, gnumeric_err_NUM);
str = argv[0]->v_str.val->str;
if (NULL != (v = format_match (str, NULL)))
if (NULL != (v = format_match (str, NULL, NULL)))
return v;
return value_new_float (0);
}
......
......@@ -756,7 +756,7 @@ gnumeric_text (FunctionEvalInfo *ei, Value **args)
}
if (arg->type == VALUE_STRING) {
Value *match = format_match (arg->v_str.val->str, NULL);
Value *match = format_match (arg->v_str.val->str, NULL, NULL);
ok = (match != NULL);
if (ok)
tmp = match;
......@@ -909,7 +909,7 @@ gnumeric_value (FunctionEvalInfo *ei, Value **argv)
}
*q = 0;
v = format_match (arg, NULL);
v = format_match (arg, NULL, NULL);
free (arg);
if (v)
......
......@@ -292,14 +292,18 @@ cell_set_text (Cell *cell, char const *text)
Value *val;
ExprTree *expr;
EvalPos pos;
MStyle *mstyle;
StyleFormat *cformat;
g_return_if_fail (cell != NULL);
g_return_if_fail (text != NULL);
g_return_if_fail (!cell_is_partial_array (cell));
mstyle = cell_get_mstyle (cell);
cformat = mstyle_get_format (mstyle);
mstyle_unref (mstyle);
format = parse_text_value_or_expr (eval_pos_init_cell (&pos, cell),
text, &val, &expr,
NULL /* TODO : Use assigned format ? */);
text, &val, &expr, cformat);
if (val != NULL) { /* String was a value */
cell_cleanout (cell);
......
......@@ -76,11 +76,8 @@ datetime_value_to_serial_raw (const Value *v)
if (VALUE_IS_NUMBER (v))
serial = value_get_as_float (v);
else {
char *str;
Value *conversion;
str = value_get_as_string (v);
conversion = format_match (str, NULL);
char *str = value_get_as_string (v);
Value *conversion = format_match (str, NULL, NULL);
if (conversion) {
if (VALUE_IS_NUMBER (conversion))
......
......@@ -489,7 +489,7 @@ stf_preview_format_line (RenderData_t *renderdata, GSList *data, int colcount)
}
/* Formatting */
if (NULL == (value = format_match (iterator->data, NULL)))
if (NULL == (value = format_match (iterator->data, NULL, NULL)))
value = value_new_string (iterator->data);
sf = g_ptr_array_index (renderdata->colformats, col);
......
......@@ -307,23 +307,19 @@ expr_name_list (Workbook *wb, Sheet *sheet, gboolean builtins_too)
char *
expr_name_value (const NamedExpression *expr_name)
{
gchar *val;
if (!expr_name->builtin) {
char * val;
ParsePos pos, *pp;
pp = parse_pos_init (&pos, expr_name->wb,
expr_name->sheet, 0, 0);
val = expr_tree_as_string (expr_name->t.expr_tree, pp);
} else
val = g_strdup (_("Builtin"));
if (val)
if (val == NULL)
return g_strdup ("Error");
return val;
else
return g_strdup ("Error");
return val;
}
return g_strdup (_("Builtin"));
}
......@@ -358,19 +354,23 @@ expr_name_invalidate_refs_name (NamedExpression *exprn)
void
expr_name_invalidate_refs_sheet (const Sheet *sheet)
{
#if 0
static gboolean warned = FALSE;
if (!warned)
g_warning ("Implement Me !. expr_name_invalidate_refs_sheet\n");
warned = TRUE;
#endif
}
void
expr_name_invalidate_refs_wb (const Workbook *wb)
{
#if 0
static gboolean warned = FALSE;
if (!warned)
g_warning ("Implement Me !. expr_name_invalidate_refs_wb\n");
warned = TRUE;
#endif
}
......
......@@ -594,7 +594,7 @@ eval_expr_real (EvalPos const *pos, ExprTree const *tree,
/* 2) #!VALUE error if A is not a number */
if (a->type == VALUE_STRING) {
Value *tmp = format_match (a->v_str.val->str, NULL);
Value *tmp = format_match (a->v_str.val->str, NULL, NULL);
value_release (a);
if (tmp == NULL)
......@@ -628,7 +628,7 @@ eval_expr_real (EvalPos const *pos, ExprTree const *tree,
/* 4) #!VALUE error if B is not a number */
if (b->type == VALUE_STRING) {
Value *tmp = format_match (b->v_str.val->str, NULL);
Value *tmp = format_match (b->v_str.val->str, NULL, NULL);
value_release (b);
if (tmp == NULL) {
......
......@@ -1929,3 +1929,15 @@ style_format_is_general (StyleFormat const *sf)
{
return 0 == strcmp (sf->format, "General");
}
/**
* style_format_is_general :
* @sf : the format to check
*
* A small utility to check whether a format is 'General'
*/
gboolean
style_format_is_text (StyleFormat const *sf)
{
return 0 == strcmp (sf->format, "@");
}
......@@ -14,6 +14,7 @@ char *style_format_str_as_XL (const char *descriptor_string,
void style_format_ref (StyleFormat *sf);
void style_format_unref (StyleFormat *sf);
gboolean style_format_is_general (StyleFormat const *sf);
gboolean style_format_is_text (StyleFormat const *sf);
void format_destroy (StyleFormat *format);
char *format_value (StyleFormat *format, const Value *value, StyleColor **color,
......
......@@ -819,7 +819,7 @@ gnumeric_n (FunctionEvalInfo *ei, Value **argv)
return value_new_error (ei->pos, gnumeric_err_NUM);
str = argv[0]->v_str.val->str;
if (NULL != (v = format_match (str, NULL)))
if (NULL != (v = format_match (str, NULL, NULL)))
return v;
return value_new_float (0);
}
......
......@@ -756,7 +756,7 @@ gnumeric_text (FunctionEvalInfo *ei, Value **args)
}
if (arg->type == VALUE_STRING) {
Value *match = format_match (arg->v_str.val->str, NULL);
Value *match = format_match (arg->v_str.val->str, NULL, NULL);
ok = (match != NULL);
if (ok)
tmp = match;
......@@ -909,7 +909,7 @@ gnumeric_value (FunctionEvalInfo *ei, Value **argv)
}
*q = 0;
v = format_match (arg, NULL);
v = format_match (arg, NULL, NULL);
free (arg);
if (v)
......
......@@ -25,6 +25,7 @@
#include "formats.h"
#include "command-context.h"
#include "workbook.h"
#include "sheet-object.h"
#include "number-match.h"
#include "main.h"
#include "expr-name.h"
......
......@@ -25,6 +25,7 @@
#include "formats.h"
#include "command-context.h"
#include "workbook.h"
#include "sheet-object.h"
#include "number-match.h"
#include "main.h"
#include "expr-name.h"
......
......@@ -28,7 +28,7 @@ main ()
if (s [strlen (s)-1] == '\n')
s [strlen (s)-1] = 0;
if (format_match (s, &format))
if (format_match (s, NULL, &format))
printf ("Format matched: %s\n", format);
else
printf ("No match found\n");
......
......@@ -1017,7 +1017,8 @@ format_match_simple (const char *text)
#define NM 40
Value *
format_match (const char *text, StyleFormat **format)
format_match (const char *text, StyleFormat const *current_format,
StyleFormat **format)
{
Value *v;
GList *l;
......@@ -1033,6 +1034,12 @@ format_match (const char *text, StyleFormat **format)
if (text[0] == '\'')
return value_new_string (text + 1);
/* FIXME : when the regex merges with the StyleFormat we can do this properly
* for now at least handle text
*/
if (current_format && style_format_is_text (current_format))
return value_new_string (text);
/* TODO : We should check the format associated with the region first,
* but we're not passing that information in yet
*/
......
......@@ -7,6 +7,7 @@ gboolean format_match_define (const char *format);
void format_match_init (void);
void format_match_finish (void);
Value *format_match_simple (const char *s);
Value *format_match (const char *s, StyleFormat **format);
Value *format_match (const char *s, StyleFormat const *current_format,
StyleFormat **format);
#endif /* GNUMERIC_NUMBER_MATCH_H */
......@@ -497,8 +497,7 @@ parse_cell_name_list (Sheet *sheet,
* @text: The text to be parsed.
* @val : Returns a Value * if the text was a value, otherwise NULL.
* @expr: Returns an ExprTree * if the text was an expression, otherwise NULL.
* @current_format : An optional string with the current number format. Not
* implemented
* @current_format : Optional, current number format.
*
* Returns : A pointer to the optimal format to display the value or
* expression result, possibly NULL if there is no preffered format.
......@@ -509,7 +508,7 @@ parse_cell_name_list (Sheet *sheet,
StyleFormat *
parse_text_value_or_expr (EvalPos const *pos, char const *text,
Value **val, ExprTree **expr,
char const *current_format /* can be NULL */)
StyleFormat const *current_format /* can be NULL */)
{
StyleFormat *desired_format = NULL;
char const * const expr_start = gnumeric_char_start_expr_p (text);
......@@ -536,7 +535,7 @@ parse_text_value_or_expr (EvalPos const *pos, char const *text,
}
} else {
/* Does it match any formats? */
*val = format_match (text, &desired_format);
*val = format_match (text, current_format, &desired_format);
/* If it does not match known formats, assume it is text. */
if (*val == NULL)
......
......@@ -34,7 +34,7 @@ GSList *parse_cell_name_list (Sheet *sheet, const char *cell_name_str,
StyleFormat *parse_text_value_or_expr (EvalPos const *pos,
char const *text,
Value **val, ExprTree **expr,
char const *current_format /* can be NULL */);
StyleFormat const *current_format /* can be NULL */);
/* Is this string potentially the start of an expression */
char const * gnumeric_char_start_expr_p (char const * c);
......
......@@ -1200,23 +1200,24 @@ sheet_range_set_text (EvalPos const *pos, Range const *r, char const *str)
}
void
sheet_cell_set_text (Cell *cell, char const *str)
sheet_cell_set_text (Cell *cell, char const *text)
{
StyleFormat *format;
Value *val;
ExprTree *expr;
EvalPos pos;
char *cformat;
MStyle *mstyle;
StyleFormat *cformat;
g_return_if_fail (str != NULL);
g_return_if_fail (cell != NULL);
g_return_if_fail (text != NULL);
g_return_if_fail (!cell_is_partial_array (cell));
cformat = cell_get_format (cell);
mstyle = cell_get_mstyle (cell);
cformat = mstyle_get_format (mstyle);
mstyle_unref (mstyle);
format = parse_text_value_or_expr (eval_pos_init_cell (&pos, cell),
str, &val, &expr,
cformat);
g_free (cformat);
text, &val, &expr, cformat);
if (expr != NULL) {
cell_set_expr (cell, expr, format);
......
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