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

- Bug 5036 - Fix inconsistancies in the hack to accept formulas with a

- Bug 5036
- Fix inconsistancies in the hack to accept formulas with a leading
  '@'.

2000-01-08  Jody Goldberg <jgoldberg@home.com>

	* src/gnumeric-util.c (gnumeric_char_start_expr_p) : new function.

	* src/workbook.c (wizard_input) : Use gnumeric_char_start_expr_p.

	* src/cell.c (cell_set_formula) : Add a precondition to ensure that
	  this is an expression.
	(cell_set_text_simple) : Use gnumeric_char_start_expr_p.

	* src/gnumeric-sheet.c (gnumeric_sheet_can_move_cursor) : Ditto.

	* src/sheet.c (sheet_set_text) : Ditto.
parent ebcc021d
2000-01-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-util.c (gnumeric_char_start_expr_p) : new function.
* src/workbook.c (wizard_input) : Use gnumeric_char_start_expr_p.
* src/cell.c (cell_set_formula) : Add a precondition to ensure that
this is an expression.
(cell_set_text_simple) : Use gnumeric_char_start_expr_p.
* src/gnumeric-sheet.c (gnumeric_sheet_can_move_cursor) : Ditto.
* src/sheet.c (sheet_set_text) : Ditto.
2000-01-07 Jody Goldberg <jgoldberg@home.com> 2000-01-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Recalc here until there is a * src/sheet.c (sheet_move_range) : Recalc here until there is a
......
2000-01-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-util.c (gnumeric_char_start_expr_p) : new function.
* src/workbook.c (wizard_input) : Use gnumeric_char_start_expr_p.
* src/cell.c (cell_set_formula) : Add a precondition to ensure that
this is an expression.
(cell_set_text_simple) : Use gnumeric_char_start_expr_p.
* src/gnumeric-sheet.c (gnumeric_sheet_can_move_cursor) : Ditto.
* src/sheet.c (sheet_set_text) : Ditto.
2000-01-07 Jody Goldberg <jgoldberg@home.com> 2000-01-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Recalc here until there is a * src/sheet.c (sheet_move_range) : Recalc here until there is a
......
...@@ -78,9 +78,10 @@ cell_set_formula (Cell *cell, const char *text) ...@@ -78,9 +78,10 @@ cell_set_formula (Cell *cell, const char *text)
g_return_if_fail (cell != NULL); g_return_if_fail (cell != NULL);
g_return_if_fail (text != NULL); g_return_if_fail (text != NULL);
g_return_if_fail (gnumeric_char_start_expr_p (*text));
cell_modified (cell); cell_modified (cell);
new_expr = expr_parse_string (&text [1], new_expr = expr_parse_string (text+1, /* Ignore leading char (=,@,+) */
parse_pos_cell (&pp, cell), parse_pos_cell (&pp, cell),
&desired_format, &desired_format,
&error_msg); &error_msg);
...@@ -484,9 +485,9 @@ cell_set_text_simple (Cell *cell, const char *text) ...@@ -484,9 +485,9 @@ cell_set_text_simple (Cell *cell, const char *text)
cell_modified (cell); cell_modified (cell);
cell_cleanout (cell); cell_cleanout (cell);
if (text [0] == '=' && text [1] != 0){ if (gnumeric_char_start_expr_p (*text) && text[1] != '\0')
cell_set_formula (cell, text); cell_set_formula (cell, text);
} else { else {
char *end; char *end;
long l; long l;
int set=0; int set=0;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <string.h> #include <string.h>
#include "gnumeric.h" #include "gnumeric.h"
#include "gnumeric-sheet.h" #include "gnumeric-sheet.h"
#include "gnumeric-util.h"
#include "sheet-object.h" #include "sheet-object.h"
#include "color.h" #include "color.h"
#include "cursors.h" #include "cursors.h"
...@@ -281,7 +282,7 @@ gnumeric_sheet_can_move_cursor (GnumericSheet *gsheet) ...@@ -281,7 +282,7 @@ gnumeric_sheet_can_move_cursor (GnumericSheet *gsheet)
entry = GTK_ENTRY (gsheet->entry); entry = GTK_ENTRY (gsheet->entry);
cursor_pos = GTK_EDITABLE (entry)->current_pos; cursor_pos = GTK_EDITABLE (entry)->current_pos;
if (entry->text [0] != '=') if (!gnumeric_char_start_expr_p (entry->text[0]))
return FALSE; return FALSE;
if (cursor_pos == 0) if (cursor_pos == 0)
return FALSE; return FALSE;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <string.h> #include <string.h>
#include "gnumeric.h" #include "gnumeric.h"
#include "gnumeric-sheet.h" #include "gnumeric-sheet.h"
#include "gnumeric-util.h"
#include "sheet-object.h" #include "sheet-object.h"
#include "color.h" #include "color.h"
#include "cursors.h" #include "cursors.h"
...@@ -281,7 +282,7 @@ gnumeric_sheet_can_move_cursor (GnumericSheet *gsheet) ...@@ -281,7 +282,7 @@ gnumeric_sheet_can_move_cursor (GnumericSheet *gsheet)
entry = GTK_ENTRY (gsheet->entry); entry = GTK_ENTRY (gsheet->entry);
cursor_pos = GTK_EDITABLE (entry)->current_pos; cursor_pos = GTK_EDITABLE (entry)->current_pos;
if (entry->text [0] != '=') if (!gnumeric_char_start_expr_p (entry->text[0]))
return FALSE; return FALSE;
if (cursor_pos == 0) if (cursor_pos == 0)
return FALSE; return FALSE;
......
...@@ -284,3 +284,8 @@ gnumeric_position_tooltip (GtkWidget *tip, int horizontal) ...@@ -284,3 +284,8 @@ gnumeric_position_tooltip (GtkWidget *tip, int horizontal)
gtk_widget_set_uposition (gtk_widget_get_toplevel (tip), x, y); gtk_widget_set_uposition (gtk_widget_get_toplevel (tip), x, y);
} }
gboolean
gnumeric_char_start_expr_p (char const c)
{
return (c == '=') || (c == '@') || (c == '+');
}
...@@ -24,9 +24,12 @@ void gnumeric_auto_kill_popup_menu_on_hide (GtkMenu *menu); ...@@ -24,9 +24,12 @@ void gnumeric_auto_kill_popup_menu_on_hide (GtkMenu *menu);
void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event); void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event);
/* /*
* Some tool tip support code. * Pseudo-tool-tip support code.
*/ */
void gnumeric_position_tooltip (GtkWidget *tip, int horizontal); void gnumeric_position_tooltip (GtkWidget *tip, int horizontal);
GtkWidget * gnumeric_create_tooltip (void); GtkWidget * gnumeric_create_tooltip (void);
/* Is this character the start of an expression */
gboolean gnumeric_char_start_expr_p (char const c);
#endif /* GNUMERIC_GNUMERIC_UTIL_H */ #endif /* GNUMERIC_GNUMERIC_UTIL_H */
...@@ -284,3 +284,8 @@ gnumeric_position_tooltip (GtkWidget *tip, int horizontal) ...@@ -284,3 +284,8 @@ gnumeric_position_tooltip (GtkWidget *tip, int horizontal)
gtk_widget_set_uposition (gtk_widget_get_toplevel (tip), x, y); gtk_widget_set_uposition (gtk_widget_get_toplevel (tip), x, y);
} }
gboolean
gnumeric_char_start_expr_p (char const c)
{
return (c == '=') || (c == '@') || (c == '+');
}
...@@ -24,9 +24,12 @@ void gnumeric_auto_kill_popup_menu_on_hide (GtkMenu *menu); ...@@ -24,9 +24,12 @@ void gnumeric_auto_kill_popup_menu_on_hide (GtkMenu *menu);
void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event); void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event);
/* /*
* Some tool tip support code. * Pseudo-tool-tip support code.
*/ */
void gnumeric_position_tooltip (GtkWidget *tip, int horizontal); void gnumeric_position_tooltip (GtkWidget *tip, int horizontal);
GtkWidget * gnumeric_create_tooltip (void); GtkWidget * gnumeric_create_tooltip (void);
/* Is this character the start of an expression */
gboolean gnumeric_char_start_expr_p (char const c);
#endif /* GNUMERIC_GNUMERIC_UTIL_H */ #endif /* GNUMERIC_GNUMERIC_UTIL_H */
...@@ -1271,7 +1271,7 @@ sheet_set_text (Sheet *sheet, char const *text, Range const * r) ...@@ -1271,7 +1271,7 @@ sheet_set_text (Sheet *sheet, char const *text, Range const * r)
* a rendered version of the text, if they compare equally, then * a rendered version of the text, if they compare equally, then
* use that. * use that.
*/ */
if (*text != '=') { if (!gnumeric_char_start_expr_p (*text) || text[1] == '\0') {
closure_set_cell_value closure; closure_set_cell_value closure;
char *end; char *end;
...@@ -1310,7 +1310,7 @@ sheet_set_current_value (Sheet *sheet) ...@@ -1310,7 +1310,7 @@ sheet_set_current_value (Sheet *sheet)
g_return_if_fail (str != NULL); g_return_if_fail (str != NULL);
/* A hack to accept Lotus 123 style formula entries */ /* A hack to accept Lotus 123 style formula entries */
if (*str == '@') { if (gnumeric_char_start_expr_p (*str) && *str != '=' && str[1] != '\0') {
char *new_text = g_strdup (str); char *new_text = g_strdup (str);
*new_text = *str = '='; *new_text = *str = '=';
......
...@@ -1376,7 +1376,8 @@ wb_edit_key_pressed (GtkEntry *entry, GdkEventKey *event, Workbook *wb) ...@@ -1376,7 +1376,8 @@ wb_edit_key_pressed (GtkEntry *entry, GdkEventKey *event, Workbook *wb)
event->keyval = GDK_VoidSymbol; event->keyval = GDK_VoidSymbol;
/* Only apply do this for formulas */ /* Only apply do this for formulas */
if (entry->text [0] != '=') if (!gnumeric_char_start_expr_p (entry->text[0]) ||
entry->text_length < 1)
return TRUE; return TRUE;
/* /*
...@@ -1554,7 +1555,7 @@ wizard_input (GtkWidget *widget, Workbook *wb) ...@@ -1554,7 +1555,7 @@ wizard_input (GtkWidget *widget, Workbook *wb)
g_free (txt); g_free (txt);
txt = gtk_entry_get_text (entry); txt = gtk_entry_get_text (entry);
if (txt [0] != '=') if (!gnumeric_char_start_expr_p (txt[0]))
edittxt = g_strconcat ("=", txt, NULL); edittxt = g_strconcat ("=", txt, NULL);
else else
edittxt = g_strdup (txt); edittxt = g_strdup (txt);
......
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