Commit 778809a4 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

delete the 'selection' function. It is no longer possible with a


2002-06-23  Jody Goldberg <jody@gnome.org>

	* src/func-builtin.c (func_builtin_init) : delete the 'selection'
	  function.  It is no longer possible with a sheetview.

	* src/workbook-control-gui.c (cb_select_auto_expr) : remove
	  'selection(0)' argument and just pass function name.  The conversion
	  to SheetView forces a different methodology.
	* src/workbook-view.c (workbook_view_new) : ditto.
	(wb_view_auto_expr_recalc) : Make the call manually.
parent d1bcb69c
......@@ -10,7 +10,6 @@ Release Critical
- We need to somehow add --export-dynamic to the gnumeric link line, or else
plugins won't load on Solaris/gcc. (This might just be my bastard libtool.)
- 3D reference fixes on sheet deletion
- Re-enable autoexpressions
- Dependencies for constructed ranges
- Figure out why the cursor is not on the edit pos when loading an xls fromthe
cmd line.
......
2002-06-23 Jody Goldberg <jody@gnome.org>
* src/func-builtin.c (func_builtin_init) : delete the 'selection'
function. It is no longer possible with a sheetview.
* src/workbook-control-gui.c (cb_select_auto_expr) : remove
'selection(0)' argument and just pass function name. The conversion
to SheetView forces a different methodology.
* src/workbook-view.c (workbook_view_new) : ditto.
(wb_view_auto_expr_recalc) : Make the call manually.
2002-06-22 Jody Goldberg <jody@gnome.org>
* src/expr.h : support constructed ranges.
......
2002-06-23 Jody Goldberg <jody@gnome.org>
* src/func-builtin.c (func_builtin_init) : delete the 'selection'
function. It is no longer possible with a sheetview.
* src/workbook-control-gui.c (cb_select_auto_expr) : remove
'selection(0)' argument and just pass function name. The conversion
to SheetView forces a different methodology.
* src/workbook-view.c (workbook_view_new) : ditto.
(wb_view_auto_expr_recalc) : Make the call manually.
2002-06-22 Jody Goldberg <jody@gnome.org>
* src/expr.h : support constructed ranges.
......
2002-06-23 Jody Goldberg <jody@gnome.org>
* src/func-builtin.c (func_builtin_init) : delete the 'selection'
function. It is no longer possible with a sheetview.
* src/workbook-control-gui.c (cb_select_auto_expr) : remove
'selection(0)' argument and just pass function name. The conversion
to SheetView forces a different methodology.
* src/workbook-view.c (workbook_view_new) : ditto.
(wb_view_auto_expr_recalc) : Make the call manually.
2002-06-22 Jody Goldberg <jody@gnome.org>
* src/expr.h : support constructed ranges.
......
2002-06-22 Jody Goldberg <jody@gnome.org>
* ms-formula-write.c (operations) : export intersection.
* ms-formula-read.c (ms_excel_parse_formula) : enable mem_func
support.
(binary_ops) : use range_ctor for RANGE.
......
......@@ -545,8 +545,9 @@ write_node (PolishData *pd, GnmExpr const *tree, int paren_level)
{ FORMULA_PTG_U_MINUS, 5, 0, 0 }, /* Unary - */
{ FORMULA_PTG_U_PLUS, 5, 0, 0 }, /* Unary + */
{ FORMULA_PTG_PERCENT, 5, 0, 0 }, /* Percentage (NOT MODULO) */
{ 0, 0, 0, 0 }, /* Array */
{ 0, 0, 0, 0 } /* Set */
{ 0, 0, 0, 0 }, /* Array */
{ 0, 0, 0, 0 }, /* Set */
{ FORMULA_PTG_RANGE, 10, 1, 0 }
};
int op;
g_return_if_fail (pd);
......@@ -554,6 +555,7 @@ write_node (PolishData *pd, GnmExpr const *tree, int paren_level)
op = tree->any.oper;
switch (op) {
case GNM_EXPR_OP_RANGE_CTOR:
case GNM_EXPR_OP_ANY_BINARY : {
int const prec = operations[op].prec;
......
......@@ -122,90 +122,6 @@ gnumeric_version (FunctionEvalInfo *ei, Value *argv [])
/***************************************************************************/
static const char *help_selection = {
N_("@FUNCTION=SELECTION\n"
"@SYNTAX=SELECTION(permit_intersection)\n"
"@DESCRIPTION="
"SELECTION function returns a list with the values in the current "
"selection. This is usually used to implement on-the-fly computation "
"of values.\n"
"If @permit_intersection is TRUE the user specifed selection "
"ranges are returned, EVEN IF THEY OVERLAP. "
"If @permit_intersection is FALSE a distict set of regions is "
"returned, however, there may be more of them than "
"the user initially specified."
"\n"
"@EXAMPLES=\n"
"\n"
"@SEEALSO=")
};
#if 0
typedef struct
{
GSList * res;
int index;
} selection_accumulator;
static void
accumulate_regions (SheetView *sv, Range const *r, gpointer closure)
{
selection_accumulator *accum = closure;
CellRef a, b;
/* Fill it in */
/* start */
a.sheet = sv->sheet;
a.col_relative = a.row_relative = FALSE;
a.col = r->start.col;
a.row = r->start.row;
/* end */
b.sheet = sv->sheet;
b.col_relative = b.row_relative = FALSE;
b.col = r->end.col;
b.row = r->end.row;
/* Dummy up the eval pos it does not matter */
accum->res = g_slist_prepend (accum->res,
value_new_cellrange(&a, &b, 0, 0));
accum->index++;
}
/* This routine is used to implement the auto_expr functionality. It is called
* to provide the selection to the defined functions.
*/
static Value *
gnumeric_selection (FunctionEvalInfo *ei, Value *argv [])
{
Sheet * const sheet = ei->pos->sheet;
gboolean const permit_intersection = argv [0]->v_bool.val;
Value * res;
int i;
selection_accumulator accum;
accum.res = NULL;
accum.index = 0;
selection_apply (sheet, &accumulate_regions,
permit_intersection, &accum);
i = accum.index;
res = value_new_array_empty (i, 1);
while (i-- > 0) {
/* pop the 1st element off the list */
Value *range = accum.res->data;
accum.res = g_slist_remove (accum.res, range);
value_array_set (res, i, 0, range);
}
return res;
}
#endif
#warning we can no longer ue this method, think of another way
static Value *
gnumeric_selection (FunctionEvalInfo *ei, Value *argv [])
{
return value_new_float (12.34);
......@@ -244,10 +160,6 @@ func_builtin_init (void)
def = function_add_args (gnumericcat, "gnumeric_version", "", "",
&help_gnumeric_version, gnumeric_version);
gnumericfuncs = g_slist_prepend (gnumericfuncs, def);
def = function_add_args (sheetcat, "selection", "b", N_("permit_intersection"),
&help_selection, gnumeric_selection);
sheetfuncs = g_slist_prepend (sheetfuncs, def);
}
static void
......
......@@ -4120,20 +4120,20 @@ cb_select_auto_expr (GtkWidget *widget, GdkEventButton *event, Workbook *wbcg)
* locale C does.
*
* eg tolower ('I') != 'i'
* Which would break function lookup when looking up for funtion 'selectIon'
* Which would break function lookup when looking up for function 'selectIon'
* when it was registered as 'selection'
*
* WARNING * WARNING * WARNING
*/
static struct {
const char *displayed_name;
const char *function;
char const * const displayed_name;
char const * const function;
} const quick_compute_routines [] = {
{ N_("Sum"), "sum(selection(0))" },
{ N_("Min"), "min(selection(0))" },
{ N_("Max"), "max(selection(0))" },
{ N_("Average"), "average(selection(0))" },
{ N_("Count"), "count(selection(0))" },
{ N_("Sum"), "sum" },
{ N_("Min"), "min" },
{ N_("Max"), "max" },
{ N_("Average"), "average" },
{ N_("Count"), "count" },
{ NULL, NULL }
};
......
......@@ -33,14 +33,15 @@
#include "sheet-style.h"
#include "str.h"
#include "format.h"
#include "func.h"
#include "expr.h"
#include "expr-impl.h"
#include "value.h"
#include "ranges.h"
#include "selection.h"
#include "mstyle.h"
#include "position.h"
#include "cell.h"
#include "parse-util.h"
#include "io-context.h"
#include <gsf/gsf-input-memory.h>
......@@ -313,39 +314,16 @@ wb_view_edit_line_set (WorkbookView *wbv, WorkbookControl *optional_wbc)
}
void
wb_view_auto_expr (WorkbookView *wbv, char const *descr, char const *expression)
wb_view_auto_expr (WorkbookView *wbv, char const *descr, char const *func_name)
{
char *old_num_locale, *old_monetary_locale, *old_msg_locale;
GnmExpr const *new_auto_expr;
ParsePos pp;
old_num_locale = g_strdup (gnumeric_setlocale (LC_NUMERIC, NULL));
gnumeric_setlocale (LC_NUMERIC, "C");
old_monetary_locale = g_strdup (gnumeric_setlocale (LC_MONETARY, NULL));
gnumeric_setlocale (LC_MONETARY, "C");
/* FIXME : Get rid of this */
old_msg_locale = g_strdup (textdomain (NULL));
textdomain ("C");
parse_pos_init (&pp, wb_view_workbook (wbv), NULL, 0, 0);
new_auto_expr = gnm_expr_parse_str_simple (expression, &pp);
g_return_if_fail (new_auto_expr != NULL);
textdomain (old_msg_locale);
g_free (old_msg_locale);
gnumeric_setlocale (LC_MONETARY, old_monetary_locale);
g_free (old_monetary_locale);
gnumeric_setlocale (LC_NUMERIC, old_num_locale);
g_free (old_num_locale);
if (wbv->auto_expr_desc)
g_free (wbv->auto_expr_desc);
if (wbv->auto_expr)
gnm_expr_unref (wbv->auto_expr);
wbv->auto_expr_desc = g_strdup (descr);
wbv->auto_expr = new_auto_expr;
wbv->auto_expr = gnm_expr_new_funcall (
func_lookup_by_name (func_name, NULL), NULL);
if (wbv->current_sheet != NULL)
wb_view_auto_expr_recalc (wbv, TRUE);
......@@ -358,21 +336,46 @@ wb_view_auto_expr_value_display (WorkbookView *wbv)
wb_control_auto_expr_value (control););
}
static void
accumulate_regions (SheetView *sv, Range const *r, gpointer closure)
{
GnmExprList **selection = closure;
CellRef a, b;
a.sheet = b.sheet = sv_sheet (sv);
a.col_relative = a.row_relative = b.col_relative = b.row_relative = FALSE;
a.col = r->start.col;
a.row = r->start.row;
b.col = r->end.col;
b.row = r->end.row;
*selection = gnm_expr_list_prepend (*selection,
gnm_expr_new_constant (value_new_cellrange_unsafe (&a, &b)));
}
void
wb_view_auto_expr_recalc (WorkbookView *wbv, gboolean display)
{
EvalPos ep;
Value *v;
FunctionEvalInfo ei;
EvalPos ep;
GnmExprList *selection = NULL;
Value *v;
g_return_if_fail (IS_WORKBOOK_VIEW (wbv));
g_return_if_fail (wbv->auto_expr != NULL);
v = gnm_expr_eval (wbv->auto_expr,
eval_pos_init_sheet (&ep, wbv->current_sheet),
GNM_EXPR_EVAL_STRICT);
selection_apply (wb_view_cur_sheet_view (wbv), &accumulate_regions,
FALSE, &selection);
ei.pos = eval_pos_init_sheet (&ep, wbv->current_sheet);
ei.func_call = (GnmExprFunction const *)wbv->auto_expr;
v = function_call_with_list (&ei, selection);
gnm_expr_list_unref (selection);
if (wbv->auto_expr_value_as_string)
g_free (wbv->auto_expr_value_as_string);
if (v) {
char const *val_str = value_peek_string (v);
wbv->auto_expr_value_as_string =
......@@ -494,7 +497,7 @@ workbook_view_new (Workbook *wb)
wbv->auto_expr = NULL;
wbv->auto_expr_desc = NULL;
wbv->auto_expr_value_as_string = NULL;
wb_view_auto_expr (wbv, _("Sum"), "sum(selection(0))");
wb_view_auto_expr (wbv, _("Sum"), "sum");
wbv->current_format = NULL;
......
......@@ -74,7 +74,8 @@ void wb_view_edit_line_set (WorkbookView *wbv,
WorkbookControl *optional_wbc);
void wb_view_auto_expr_recalc (WorkbookView *wbv, gboolean display);
void wb_view_auto_expr (WorkbookView *wbv,
char const *name, char const *expr);
char const *name,
char const *func_name);
/* I/O routines */
gboolean wb_view_save_as (WorkbookView *wbv, GnumFileSaver *fs,
......
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