Commit 3416220d authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Functions returning an array when only scalar results are permitted


2004-08-02  Jody Goldberg <jody@gnome.org>

	* src/expr.c (gnm_expr_eval) : Functions returning an array when only
	  scalar results are permitted produce #VALUE!

	* src/style.c (style_default_halign) : Fix drilling down into arrays

	* src/wbc-gtk.c (cb_add_menus_toolbars) : Init state.

2004-08-01  Jody Goldberg <jody@gnome.org>

	* src/func.c (function_call_with_list) : Array parms seem to accept
	  scalars.

	* src/value.c (value_dup) : Accept NULL

	* src/expr.c (gnm_expr_eval) : do intersection for constant arrays too

2004-07-30  Jody Goldberg <jody@gnome.org>

	* src/wbc-gtk.c (wbc_gtk_init_zoom) : We need a label for the action
	  in case it is a menu item.
parent d28efcac
2004-08-02 Jody Goldberg <jody@gnome.org>
* src/expr.c (gnm_expr_eval) : Functions returning an array when only
scalar results are permitted produce #VALUE!
* src/style.c (style_default_halign) : Fix drilling down into arrays
* src/wbc-gtk.c (cb_add_menus_toolbars) : Init state.
2004-08-01 Jody Goldberg <jody@gnome.org>
* src/func.c (function_call_with_list) : Array parms seem to accept
scalars.
* src/value.c (value_dup) : Accept NULL
* src/expr.c (gnm_expr_eval) : do intersection for constant arrays too
2004-07-30 Jody Goldberg <jody@gnome.org>
* src/wbc-gtk.c (wbc_gtk_init_zoom) : We need a label for the action
in case it is a menu item.
2004-07-30 Morten Welinder <terra@gnome.org>
* src/wbc-gtk.c (cb_add_menus_toolbars): Plug leaks.
......
2004-08-02 Jody Goldberg <jody@gnome.org>
* src/expr.c (gnm_expr_eval) : Functions returning an array when only
scalar results are permitted produce #VALUE!
* src/style.c (style_default_halign) : Fix drilling down into arrays
* src/wbc-gtk.c (cb_add_menus_toolbars) : Init state.
2004-08-01 Jody Goldberg <jody@gnome.org>
* src/func.c (function_call_with_list) : Array parms seem to accept
scalars.
* src/value.c (value_dup) : Accept NULL
* src/expr.c (gnm_expr_eval) : do intersection for constant arrays too
2004-07-30 Jody Goldberg <jody@gnome.org>
* src/wbc-gtk.c (wbc_gtk_init_zoom) : We need a label for the action
in case it is a menu item.
2004-07-30 Morten Welinder <terra@gnome.org>
* src/wbc-gtk.c (cb_add_menus_toolbars): Plug leaks.
......
......@@ -29,6 +29,10 @@ G_BEGIN_DECLS
typedef struct _GOApp GOApp;
typedef struct _GODoc GODoc;
typedef struct _GODocControl GODocControl;
typedef struct _GOPlugin GOPlugin;
typedef struct _GOPluginService GOPluginService;
typedef struct _GOPluginLoader GOPluginLoader;
typedef struct _GOErrorInfo GOErrorInfo;
G_END_DECLS
......
......@@ -565,7 +565,7 @@ handle_empty (GnmValue *res, GnmExprEvalFlags flags)
/**
* value_intersection :
* @v : a VALUE_CELLRANGE
* @v : a VALUE_CELLRANGE or VALUE_ARRAY
* @pos :
*
* Handle the implicit union of a single row or column with the eval position.
......@@ -1255,7 +1255,10 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
ei.pos = pos;
ei.func_call = (GnmExprFunction const *)expr;
res = function_call_with_list (&ei, expr->func.arg_list, flags);
if (res != NULL && res->type == VALUE_CELLRANGE) {
if (res == NULL)
return (flags & GNM_EXPR_EVAL_PERMIT_EMPTY)
? NULL : value_new_int (0);
if (res->type == VALUE_CELLRANGE) {
dependent_add_dynamic_dep (pos->dep, &res->v_range);
if (!(flags & GNM_EXPR_EVAL_PERMIT_NON_SCALAR)) {
res = value_intersection (res, pos);
......@@ -1265,9 +1268,11 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
}
return res;
}
if (res == NULL)
return (flags & GNM_EXPR_EVAL_PERMIT_EMPTY)
? NULL : value_new_int (0);
if (res->type == VALUE_ARRAY &&
!(flags & GNM_EXPR_EVAL_PERMIT_NON_SCALAR)) {
value_release (res);
return value_new_error_VALUE (pos);
}
return res;
}
......@@ -1294,22 +1299,15 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
case GNM_EXPR_OP_CONSTANT:
res = value_dup (expr->constant.value);
if (res->type != VALUE_CELLRANGE)
return handle_empty (res, flags);
if (flags & GNM_EXPR_EVAL_PERMIT_NON_SCALAR) {
#if 0
workbook_foreach_cell_in_range (pos, res,
CELL_ITER_IGNORE_BLANK,
cb_range_eval, NULL);
#endif
return res;
} else {
if (res->type == VALUE_CELLRANGE || res->type == VALUE_ARRAY) {
if (flags & GNM_EXPR_EVAL_PERMIT_NON_SCALAR)
return res;
res = value_intersection (res, pos);
return (res != NULL)
? handle_empty (res, flags)
: value_new_error_VALUE (pos);
}
return handle_empty (res, flags);
case GNM_EXPR_OP_ARRAY: {
/* The upper left corner manages the recalc of the expr */
......@@ -1346,6 +1344,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
tmp_ep.eval.col -= x;
tmp_ep.eval.row -= y;
g_warning ("yoyo");
/* If the src array is 1 element wide or tall we wrap */
if (x >= 1 && num_x == 1)
x = 0;
......
......@@ -814,7 +814,9 @@ function_call_with_list (FunctionEvalInfo *ei, GnmExprList *l,
cellref_make_abs (&tmp->v_range.cell.b,
&tmp->v_range.cell.b,
ei->pos);
} else if (tmp->type != VALUE_ARRAY || arg_type != 'A') {
/* Array args accept scalars */
} else if (arg_type != 'A' && tmp->type != VALUE_ARRAY) {
free_values (args, i + 1);
return value_new_error_VALUE (ei->pos);
}
......
......@@ -2,7 +2,6 @@
#define GNUMERIC_PLUGIN_H
#include "gnumeric.h"
#include "error-info.h"
#include <glib-object.h>
/*
......
......@@ -609,12 +609,13 @@ style_default_halign (GnmStyle const *mstyle, GnmCell const *c)
/* Tail recurse into the array */
if (v->v_array.x > 0 && v->v_array.y > 0) {
v = v->v_array.vals [0][0];
break;
continue;
}
default :
return HALIGN_LEFT;
}
return HALIGN_RIGHT;
}
return align;
......
......@@ -541,15 +541,19 @@ value_release (GnmValue *value)
g_assert_not_reached ();
}
/*
* Makes a copy of a GnmValue
*/
/**
* value_dup :
* @src : #GnmValue
*
* Returns a copy of @src. @src == NULL will return NULL
**/
GnmValue *
value_dup (GnmValue const *src)
{
GnmValue *res;
g_return_val_if_fail (src != NULL, NULL);
if (src == NULL)
return NULL;
switch (src->type){
case VALUE_EMPTY:
......
......@@ -160,6 +160,7 @@ wbc_gtk_init_zoom (WBCgtk *gtk)
gtk->zoom = g_object_new (go_action_combo_text_get_type (),
"name", "Zoom",
"label", _("_Zoom"),
NULL);
go_action_combo_text_set_width (gtk->zoom, "10000%");
for (i = 0; preset_zoom[i] != NULL ; ++i)
......@@ -1121,6 +1122,7 @@ cb_add_menus_toolbars (G_GNUC_UNUSED GtkUIManager *ui,
entry.accelerator = (0 == strcmp (name, "StandardToolbar")) ? "<control>8" : NULL;
entry.tooltip = tooltip;
entry.callback = G_CALLBACK (cb_toolbar_activate);
entry.is_active = TRUE;
gtk_action_group_add_toggle_actions (gtk->toolbar.actions,
&entry, 1, (WorkbookControlGUI *)wbcg);
gtk_ui_manager_add_ui (gtk->ui, gtk->toolbar.merge_id,
......
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