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

Make the sheet_sep, and range_sep conditional so that I can use the parser


2000-04-29  Jody Goldberg <jgoldberg@home.com>

	* src/parser.y : Make the sheet_sep, and range_sep conditional
	  so that I can use the parser for applix too.

	* src/workbook.c (workbook_unref) : encapsulate workbook_unref.

	* src/application.c (application_init) : Do not save the value if it
	  is not there.  Fix typo.

	* src/mstyle.c (mstyle_unref) : If the default style is released
	  clear the cached pointer.  This can happen if the first workbook
	  loaded fails.
parent 2d5190a6
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
so that I can use the parser for applix too.
* src/workbook.c (workbook_unref) : encapsulate workbook_unref.
* src/application.c (application_init) : Do not save the value if it
is not there. Fix typo.
* src/mstyle.c (mstyle_unref) : If the default style is released
clear the cached pointer. This can happen if the first workbook
loaded fails.
2000-04-28 Miguel de Icaza <miguel@helixcode.com>
* src/complete.c (complete_idle): Removed debugging messages
......
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
so that I can use the parser for applix too.
* src/workbook.c (workbook_unref) : encapsulate workbook_unref.
* src/application.c (application_init) : Do not save the value if it
is not there. Fix typo.
* src/mstyle.c (mstyle_unref) : If the default style is released
clear the cached pointer. This can happen if the first workbook
loaded fails.
2000-04-28 Miguel de Icaza <miguel@helixcode.com>
* src/complete.c (complete_idle): Removed debugging messages
......
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
so that I can use the parser for applix too.
* src/workbook.c (workbook_unref) : encapsulate workbook_unref.
* src/application.c (application_init) : Do not save the value if it
is not there. Fix typo.
* src/mstyle.c (mstyle_unref) : If the default style is released
clear the cached pointer. This can happen if the first workbook
loaded fails.
2000-04-28 Miguel de Icaza <miguel@helixcode.com>
* src/complete.c (complete_idle): Removed debugging messages
......
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
so that I can use the parser for applix too.
* src/workbook.c (workbook_unref) : encapsulate workbook_unref.
* src/application.c (application_init) : Do not save the value if it
is not there. Fix typo.
* src/mstyle.c (mstyle_unref) : If the default style is released
clear the cached pointer. This can happen if the first workbook
loaded fails.
2000-04-28 Miguel de Icaza <miguel@helixcode.com>
* src/complete.c (complete_idle): Removed debugging messages
......
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
so that I can use the parser for applix too.
* src/workbook.c (workbook_unref) : encapsulate workbook_unref.
* src/application.c (application_init) : Do not save the value if it
is not there. Fix typo.
* src/mstyle.c (mstyle_unref) : If the default style is released
clear the cached pointer. This can happen if the first workbook
loaded fails.
2000-04-28 Miguel de Icaza <miguel@helixcode.com>
* src/complete.c (complete_idle): Removed debugging messages
......
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
so that I can use the parser for applix too.
* src/workbook.c (workbook_unref) : encapsulate workbook_unref.
* src/application.c (application_init) : Do not save the value if it
is not there. Fix typo.
* src/mstyle.c (mstyle_unref) : If the default style is released
clear the cached pointer. This can happen if the first workbook
loaded fails.
2000-04-28 Miguel de Icaza <miguel@helixcode.com>
* src/complete.c (complete_idle): Removed debugging messages
......
2000-04-29 Jody Goldberg <jgoldberg@home.com>
* src/parser.y : Make the sheet_sep, and range_sep conditional
so that I can use the parser for applix too.
* src/workbook.c (workbook_unref) : encapsulate workbook_unref.
* src/application.c (application_init) : Do not save the value if it
is not there. Fix typo.
* src/mstyle.c (mstyle_unref) : If the default style is released
clear the cached pointer. This can happen if the first workbook
loaded fails.
2000-04-28 Miguel de Icaza <miguel@helixcode.com>
* src/complete.c (complete_idle): Removed debugging messages
......
......@@ -39,9 +39,6 @@ static GnumericApplication app;
void
application_init (void)
{
gboolean h_was_default = TRUE;
gboolean v_was_default = TRUE;
app.clipboard_copied_contents = NULL;
app.clipboard_sheet = NULL;
......@@ -58,31 +55,14 @@ application_init (void)
* I'll leave it as is for now, and revisit the solution when we shake
* out the flaws in the display code.
*/
app.horizontal_dpi = 96.;
app.vertical_dpi = 96.;
gnome_config_push_prefix ("Gnumeric/Screen_Resolution/");
app.horizontal_dpi =
gnome_config_get_float_with_default ("Horizontal_dpi=96",
&h_was_default);
app.vertical_dpi =
gnome_config_get_float_with_default ("Vertical_dpi=96",
&v_was_default);
if (h_was_default)
gnome_config_set_float ("Horizontal_dpi", app.horizontal_dpi);
if (v_was_default)
gnome_config_set_float ("Vertical_dpi", app.vertical_dpi);
if (h_was_default || v_was_default)
gnome_config_sync ();
app.horizontal_dpi = gnome_config_get_float ("Horizontal_dpi=96");
app.vertical_dpi = gnome_config_get_float ("Vertical_dpi=96");
gnome_config_pop_prefix ();
gnome_config_push_prefix ("Gnumeric/Editing");
app.edit_auto_complete =
gnome_config_get_bool ("AutoComplete=true");
gnome_config_push_prefix ("Gnumeric/Editing/");
app.edit_auto_complete = gnome_config_get_bool ("AutoComplete=true");
gnome_config_pop_prefix ();
}
/**
......
......@@ -583,7 +583,8 @@ cell_is_error (Cell const * const cell)
inline gboolean
cell_is_number (const Cell *cell)
{
return cell->value && VALUE_IS_NUMBER (cell->value);
/* FIXME : This does not handle arrays or ranges */
return (cell->value && VALUE_IS_NUMBER (cell->value));
}
gboolean
......
......@@ -197,7 +197,7 @@ expr_parse_string (const char *expr, const ParsePosition *pp,
ExprTree *tree;
g_return_val_if_fail (expr != NULL, NULL);
switch (gnumeric_expr_parser (expr, pp, desired_format, &tree)) {
switch (gnumeric_expr_parser (expr, pp, TRUE, desired_format, &tree)) {
case PARSE_OK:
*error_msg = NULL;
return tree;
......
......@@ -31,7 +31,7 @@ file_history_cmd (GtkWidget *widget, Workbook *wb)
gtk_widget_show (new_wb->toplevel);
if (workbook_is_pristine (wb))
gtk_object_unref (GTK_OBJECT (wb));
workbook_unref (wb);
}
}
......@@ -51,7 +51,7 @@ file_history_cmd (BonoboUIHandler *uih, Workbook *wb, const char *path)
gtk_widget_show (new_wb->toplevel);
if (workbook_is_pristine (wb))
bonobo_object_unref (BONOBO_OBJECT (wb));
workbook_unref (wb);
}
}
#endif
......
......@@ -592,8 +592,11 @@ mstyle_unref (MStyle *style)
style->ref_count--;
if (style->ref_count == 0)
if (style->ref_count <= 0) {
if (default_mstyle == style)
default_mstyle = NULL;
mstyle_destroy (style);
}
}
MStyle *
......
......@@ -47,6 +47,7 @@ typedef enum {
} ParseErr;
ParseErr gnumeric_expr_parser (const char *expr,
const ParsePosition *pp,
gboolean use_excel_range_conventions,
char **desired_format,
ExprTree **result);
......
......@@ -206,6 +206,7 @@ static char **parser_desired_format;
static char parser_decimal_point;
static char parser_separator;
static char parser_array_col_separator;
static gboolean parser_use_excel_reference_conventions;
static ExprTree **parser_result;
......@@ -295,7 +296,7 @@ int yyparse(void);
%left '-' '+'
%left '*' '/'
%left NEG PLUS
%left '!'
%left RANGE_SEP SHEET_SEP
%right '^'
%right '%'
......@@ -343,7 +344,7 @@ exp: NUMBER { $$ = $1; }
}
;
sheetref: STRING '!' {
sheetref: STRING SHEET_SEP {
Sheet *sheet = sheet_lookup_by_name (parser_wb, $1->u.constant->v.str->str);
/* TODO : Get rid of ParseErr and replace it with something richer. */
unregister_allocation ($1); expr_tree_unref ($1);
......@@ -354,7 +355,7 @@ sheetref: STRING '!' {
$$ = sheet;
}
| '[' STRING ']' STRING '!' {
| '[' STRING ']' STRING SHEET_SEP {
/* TODO : Get rid of ParseErr and replace it with something richer.
* The replace ment should include more detail as to what the error
* was, and where in the expr string to highlight.
......@@ -394,7 +395,7 @@ cellref: CELLREF {
$$ = $2;
}
| CELLREF ':' CELLREF {
| CELLREF RANGE_SEP CELLREF {
unregister_allocation ($3);
unregister_allocation ($1);
$$ = register_expr_allocation
......@@ -405,7 +406,7 @@ cellref: CELLREF {
expr_tree_unref ($1);
}
| sheetref CELLREF ':' opt_sheetref CELLREF {
| sheetref CELLREF RANGE_SEP opt_sheetref CELLREF {
unregister_allocation ($5);
unregister_allocation ($2);
$2->u.ref.sheet = $1;
......@@ -603,6 +604,20 @@ yylex (void)
if (c == '(' || c == ')')
return c;
if (parser_use_excel_reference_conventions) {
if (c == ':')
return RANGE_SEP;
if (c == '!')
return SHEET_SEP;
} else {
if (c == '.' && *parser_expr == '.') {
parser_expr++;
return RANGE_SEP;
}
if (c == ':')
return SHEET_SEP;
}
if (c == parser_separator)
return SEPARATOR;
......@@ -707,7 +722,8 @@ yylex (void)
int len;
while (isalnum ((unsigned char)*parser_expr) || *parser_expr == '_' ||
*parser_expr == '$' || *parser_expr == '.')
*parser_expr == '$' ||
(parser_use_excel_reference_conventions && *parser_expr == '.'))
parser_expr++;
len = parser_expr - start;
......@@ -754,6 +770,7 @@ yyerror (char *s)
ParseErr
gnumeric_expr_parser (const char *expr, const ParsePosition *pp,
gboolean use_excel_range_conventions,
char **desired_format, ExprTree **result)
{
struct lconv *locinfo;
......@@ -773,6 +790,8 @@ gnumeric_expr_parser (const char *expr, const ParsePosition *pp,
if (parser_desired_format)
*parser_desired_format = NULL;
parser_use_excel_reference_conventions = use_excel_range_conventions;
locinfo = localeconv ();
if (locinfo->decimal_point && locinfo->decimal_point[0] &&
locinfo->decimal_point[1] == 0)
......
......@@ -142,8 +142,8 @@ typedef struct {
GtkType workbook_get_type (void);
Workbook *workbook_new (void);
Workbook *workbook_core_new (void);
Workbook *workbook_new_with_sheets (int sheet_count);
void workbook_unref (Workbook *wb);
void workbook_set_attributev (Workbook *wb, GList *list);
GtkArg *workbook_get_attributev (Workbook *wb, guint *n_args);
......
......@@ -111,13 +111,8 @@ file_open_cmd (GtkWidget *widget, Workbook *wb)
/* If the current workbook is empty and untouched remove it
* in favour of the new book
*/
if (workbook_is_pristine (wb)) {
#ifdef ENABLE_BONOBO
bonobo_object_unref (BONOBO_OBJECT (wb));
#else
gtk_object_unref (GTK_OBJECT (wb));
#endif
}
if (workbook_is_pristine (wb))
workbook_unref (wb);
}
g_free (fname);
}
......@@ -136,13 +131,8 @@ file_import_cmd (GtkWidget *widget, Workbook *wb)
if (new_wb) {
gtk_widget_show (new_wb->toplevel);
if (workbook_is_pristine (wb)) {
#ifdef ENABLE_BONOBO
bonobo_object_unref (BONOBO_OBJECT (wb));
#else
gtk_object_unref (GTK_OBJECT (wb));
#endif
}
if (workbook_is_pristine (wb))
workbook_unref (wb);
}
g_free (fname);
}
......@@ -578,15 +568,7 @@ workbook_close_if_user_permits (Workbook *wb)
in_can_close = FALSE;
if (can_close) {
#ifdef ENABLE_BONOBO
if (wb->workbook_views) {
gtk_widget_hide (GTK_WIDGET (wb->toplevel));
return FALSE;
}
bonobo_object_unref (BONOBO_OBJECT (wb));
#else
gtk_object_unref (GTK_OBJECT (wb));
#endif
workbook_unref (wb);
return FALSE;
} else
return TRUE;
......@@ -1940,7 +1922,7 @@ workbook_set_auto_expr (Workbook *wb,
expr_tree_unref (wb->auto_expr);
g_assert (gnumeric_expr_parser (expression, parse_pos_init (&pp, wb, NULL, 0, 0),
NULL, &wb->auto_expr) == PARSE_OK);
TRUE, NULL, &wb->auto_expr) == PARSE_OK);
if (wb->auto_expr_desc)
string_unref (wb->auto_expr_desc);
......@@ -3682,3 +3664,16 @@ workbook_get_entry (Workbook const *wb)
/* TODO : If there is an function wizard up use the edit line from there */
return wb->priv->edit_line;
}
void
workbook_unref (Workbook *wb)
{
#ifdef ENABLE_BONOBO
if (wb->workbook_views)
gtk_widget_hide (GTK_WIDGET (wb->toplevel));
else
bonobo_object_unref (BONOBO_OBJECT (wb));
#else
gtk_object_unref (GTK_OBJECT (wb));
#endif
}
......@@ -142,8 +142,8 @@ typedef struct {
GtkType workbook_get_type (void);
Workbook *workbook_new (void);
Workbook *workbook_core_new (void);
Workbook *workbook_new_with_sheets (int sheet_count);
void workbook_unref (Workbook *wb);
void workbook_set_attributev (Workbook *wb, GList *list);
GtkArg *workbook_get_attributev (Workbook *wb, guint *n_args);
......
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