[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH] option to display formulas
- From: Martin Sheppard <shepp camtech net au>
- To: gnumeric-list gnome org
- Subject: [PATCH] option to display formulas
- Date: Tue, 28 Dec 1999 17:18:09 +1000
Hi,
This patch adds a menu item which toggles displaying the text of formulas
entered rather than the value they evaluate to. This functionality is
present in Excel and is essential for a particular school maths course here
in South Australia. Ultimately the option should probably go somewhere else
like Excel's Tools->Options dialog, but for the moment the current location
on the view menu seems sendible. It works by setting the rendered text of a
cell to the text of the formula instead of the value of the formula when
the option is switched on. If the option is changed then a recalculation is
triggered to flush the now incorrect rendered value.
Cheers,
Martin Sheppard.
diff -rup gnumeric-0.45-clean/src/cell.c gnumeric-0.45/src/cell.c
---
gnumeric-0.45-clean/src/cell.c Sat Nov 20 08:29:00 1999
+++
gnumeric-0.45/src/cell.c Mon Dec 27 13:50:49 1999
@@ -378,7 +378,9 @@
cell_get_formatted_val (Cell *cell, Styl
* cell_render_value
* @cell:
The cell whose value needs to be rendered
*
- * The value of the cell is
formated according to the format style
+ * The value of the cell is
formated according to the format style, but if
+ * formulas are being
displayed then use the text of the formula instead of
+ * its value.
*/
void
cell_render_value (Cell *cell)
@@ -398,6 +400,14 @@ cell_render_value
(Cell *cell)
}
str = cell_get_formatted_val (cell, &color);
+ if
(cell->sheet->workbook->display_formulas && cell->parsed_node){
+
ParsePosition pp;
+ char *tmpstr = expr_decode_tree (cell->parsed_node,
+
parse_pos_cell (&pp, cell));
+ g_free (str);
+ str = g_strconcat
("=", tmpstr, NULL);
+ g_free (tmpstr);
+ }
cell->render_color = color;
cell_set_rendered_text (cell, str);
diff -rup
gnumeric-0.45-clean/src/workbook.c gnumeric-0.45/src/workbook.c
---
gnumeric-0.45-clean/src/workbook.c Sat Dec 4 12:30:11 1999
+++
gnumeric-0.45/src/workbook.c Mon Dec 27 13:43:43 1999
@@ -752,6 +752,13 @@
zoom_cmd (GtkWidget *widget, Workbook *w
}
static
void
+toggle_formulas_cmd (GtkWidget *widget, Workbook *wb)
+{
+
wb->display_formulas = !wb->display_formulas;
+ workbook_recalc_all
(wb);
+}
+
+static void
format_cells_cmd (GtkWidget *widget, Workbook
*wb)
{
Sheet *sheet;
@@ -1005,6 +1012,8 @@ static GnomeUIInfo
workbook_menu_edit []
static GnomeUIInfo workbook_menu_view [] = {
{
GNOME_APP_UI_ITEM, N_("_Zoom..."),
N_("Zoom the spreadsheet in or
out"), zoom_cmd },
+ { GNOME_APP_UI_ITEM, N_("Toggle _Formulas"),
+
N_("Toggle the display of formulas"), toggle_formulas_cmd },
GNOMEUIINFO_END
};
@@ -2041,6 +2050,7 @@ workbook_new (void)
wb =
gtk_type_new (workbook_get_type ());
wb->toplevel = gnome_app_new
("Gnumeric", "Gnumeric");
wb->table = gtk_table_new (0, 0, 0);
+
wb->display_formulas = FALSE;
gtk_window_set_policy (GTK_WINDOW
(wb->toplevel), 1, 1, 0);
sx = MAX (gdk_screen_width () - 64, 400);
diff
-rup gnumeric-0.45-clean/src/workbook.h gnumeric-0.45/src/workbook.h
---
gnumeric-0.45-clean/src/workbook.h Sat Dec 4 12:30:11 1999
+++
gnumeric-0.45/src/workbook.h Mon Dec 27 13:46:59 1999
@@ -111,6 +111,8 @@
struct _Workbook {
void *corba_server;
+ gboolean
display_formulas;
+
WorkbookPrivate *priv;
};
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]