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

fix typo. and generate the expression using the source cell rather than

2001-08-26  Jody Goldberg <jgoldberg@home.com>

	* fn-information.c (gnumeric_expression) : fix typo.
	  and generate the expression using the source cell rather than then
	  position with the call to expression.
2001-08-26  Jody Goldberg <jgoldberg@home.com>

	* src/gnumeric-graph.c (gnm_graph_add_vector) : merge with
	  gnum_graph_vector_new and add intelligence to merge multiple
	  requests for the same vector into a single vector.

2001-08-26  Jody Goldberg <jgoldberg@home.com>

	* src/position.c (cellref_get_abs_pos) : rename and adjust signature.

	* src/expr.c (expr_tree_equal) : new function.
parent d4db2b08
2001-08-26 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-graph.c (gnm_graph_add_vector) : merge with
gnum_graph_vector_new and add intelligence to merge multiple
requests for the same vector into a single vector.
2001-08-26 Jody Goldberg <jgoldberg@home.com>
* src/position.c (cellref_get_abs_pos) : rename and adjust signature.
* src/expr.c (expr_tree_equal) : new function.
2001-08-24 Jody Goldberg <jgoldberg@home.com>
......
2001-08-26 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-graph.c (gnm_graph_add_vector) : merge with
gnum_graph_vector_new and add intelligence to merge multiple
requests for the same vector into a single vector.
2001-08-26 Jody Goldberg <jgoldberg@home.com>
* src/position.c (cellref_get_abs_pos) : rename and adjust signature.
* src/expr.c (expr_tree_equal) : new function.
2001-08-24 Jody Goldberg <jgoldberg@home.com>
......
2001-08-26 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-graph.c (gnm_graph_add_vector) : merge with
gnum_graph_vector_new and add intelligence to merge multiple
requests for the same vector into a single vector.
2001-08-26 Jody Goldberg <jgoldberg@home.com>
* src/position.c (cellref_get_abs_pos) : rename and adjust signature.
* src/expr.c (expr_tree_equal) : new function.
2001-08-24 Jody Goldberg <jgoldberg@home.com>
......
2001-08-26 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-graph.c (gnm_graph_add_vector) : merge with
gnum_graph_vector_new and add intelligence to merge multiple
requests for the same vector into a single vector.
2001-08-26 Jody Goldberg <jgoldberg@home.com>
* src/position.c (cellref_get_abs_pos) : rename and adjust signature.
* src/expr.c (expr_tree_equal) : new function.
2001-08-24 Jody Goldberg <jgoldberg@home.com>
......
......@@ -270,7 +270,7 @@ BC_R(ai)(ExcelChartHandler const *handle,
#ifdef ENABLE_BONOBO
s->currentSeries->vector [purpose].g_vector =
gnm_graph_vector_new (s->graph, expr,
gnm_graph_add_vector (s->graph, expr,
s->currentSeries->vector [purpose].type,
sheet);
#endif
......
......@@ -673,9 +673,10 @@ gnumeric_isblank (FunctionEvalInfo *ei, GList *expr_node_list)
if (expr->any.oper == OPER_VAR) {
CellRef const *ref = &expr->var.ref;
Sheet const *sheet = eval_sheet (ref->sheet, ei->pos->sheet);
int row, col;
cell_get_abs_col_row(ref, &ei->pos->eval, &col, &row);
result = cell_is_blank(sheet_cell_get(sheet, col, row));
CellPos pos;
cellref_get_abs_pos (ref, &ei->pos->eval, &pos);
result = cell_is_blank (sheet_cell_get (sheet, pos.col, pos.row));
}
return value_new_bool (result);
}
......
......@@ -848,8 +848,8 @@ gnumeric_column (FunctionEvalInfo *ei, GList *nodes)
expr = (ExprTree *)nodes->data;
if (expr->any.oper == OPER_VAR)
return value_new_int (cell_ref_get_abs_col (&expr->var.ref,
ei->pos) + 1);
return value_new_int (cellref_get_abs_col (&expr->var.ref,
ei->pos) + 1);
if (expr->any.oper == OPER_CONSTANT &&
expr->constant.value->type == VALUE_CELLRANGE) {
int i, j, col;
......@@ -859,7 +859,7 @@ gnumeric_column (FunctionEvalInfo *ei, GList *nodes)
Value * res = value_new_array (abs (b->col - a->col) + 1,
abs (b->row - a->row) + 1);
col = cell_ref_get_abs_col (a, ei->pos) + 1;
col = cellref_get_abs_col (a, ei->pos) + 1;
for (i = abs (b->col - a->col) ; i >= 0 ; --i)
for (j = abs (b->row - a->row) ; j >= 0 ; --j)
value_array_set(res, i, j,
......@@ -988,7 +988,7 @@ gnumeric_row (FunctionEvalInfo *ei, GList *nodes)
expr = (ExprTree *)nodes->data;
if (expr->any.oper == OPER_VAR)
return value_new_int (cell_ref_get_abs_row (&expr->var.ref,
return value_new_int (cellref_get_abs_row (&expr->var.ref,
ei->pos) + 1);
if (expr->any.oper == OPER_CONSTANT &&
expr->constant.value->type == VALUE_CELLRANGE) {
......@@ -999,7 +999,7 @@ gnumeric_row (FunctionEvalInfo *ei, GList *nodes)
Value * res = value_new_array (abs (b->col - a->col) + 1,
abs (b->row - a->row) + 1);
row = cell_ref_get_abs_row (a, ei->pos) + 1;
row = cellref_get_abs_row (a, ei->pos) + 1;
for (i = abs (b->col - a->col) ; i >= 0 ; --i)
for (j = abs (b->row - a->row) ; j >= 0 ; --j)
value_array_set(res, i, j,
......
......@@ -220,10 +220,10 @@ do_af_suggest (const ExprTree *expr, const EvalPos *epos, char **explicit)
}
case OPER_VAR: {
Sheet *sheet;
const CellRef *ref;
int col, row;
const Cell *cell;
Sheet const *sheet;
CellRef const *ref;
Cell const *cell;
CellPos pos;
ref = &expr->var.ref;
sheet = eval_sheet (ref->sheet, epos->sheet);
......@@ -231,8 +231,8 @@ do_af_suggest (const ExprTree *expr, const EvalPos *epos, char **explicit)
if (sheet == NULL)
return AF_UNKNOWN;
cell_get_abs_col_row (ref, &epos->eval, &col, &row);
cell = sheet_cell_get (sheet, col, row);
cellref_get_abs_pos (ref, &epos->eval, &pos);
cell = sheet_cell_get (sheet, pos.col, pos.row);
if (cell == NULL)
return AF_UNKNOWN;
......
......@@ -343,7 +343,7 @@ handle_cell_single_dep (Dependent *dep, CellPos const *pos,
return;
/* Convert to absolute cordinates */
cell_get_abs_col_row (a, pos, &lookup.pos.col, &lookup.pos.row);
cellref_get_abs_pos (a, pos, &lookup.pos);
single = g_hash_table_lookup (deps->single_hash, &lookup);
......@@ -428,14 +428,10 @@ depsingle_dtor (DependencySingle *single)
static void
deprange_init (DependencyRange *range, CellPos const *pos,
CellRef const *a, CellRef const *b)
CellRef const *a, CellRef const *b)
{
cell_get_abs_col_row (a, pos,
&range->range.start.col,
&range->range.start.row);
cell_get_abs_col_row (b, pos,
&range->range.end.col,
&range->range.end.row);
cellref_get_abs_pos (a, pos, &range->range.start);
cellref_get_abs_pos (b, pos, &range->range.end);
range_normalize (&range->range);
range->dependent_list = NULL;
......
......@@ -265,13 +265,13 @@ graph_guru_create_vectors_from_range (GraphGuruState *state, Range const *src)
}
for (i = 0 ; i <= count ; i++) {
(void) gnm_graph_vector_new (state->graph,
(void) gnm_graph_add_vector (state->graph,
expr_tree_new_constant (
value_new_cellrange_r (state->sheet, &vector)),
GNM_VECTOR_AUTO, state->sheet);
if (has_header)
(void) gnm_graph_vector_new (state->graph,
(void) gnm_graph_add_vector (state->graph,
expr_tree_new_var (&header),
GNM_VECTOR_STRING, state->sheet);
......
......@@ -343,7 +343,7 @@ handle_cell_single_dep (Dependent *dep, CellPos const *pos,
return;
/* Convert to absolute cordinates */
cell_get_abs_col_row (a, pos, &lookup.pos.col, &lookup.pos.row);
cellref_get_abs_pos (a, pos, &lookup.pos);
single = g_hash_table_lookup (deps->single_hash, &lookup);
......@@ -428,14 +428,10 @@ depsingle_dtor (DependencySingle *single)
static void
deprange_init (DependencyRange *range, CellPos const *pos,
CellRef const *a, CellRef const *b)
CellRef const *a, CellRef const *b)
{
cell_get_abs_col_row (a, pos,
&range->range.start.col,
&range->range.start.row);
cell_get_abs_col_row (b, pos,
&range->range.end.col,
&range->range.end.row);
cellref_get_abs_pos (a, pos, &range->range.start);
cellref_get_abs_pos (b, pos, &range->range.end);
range_normalize (&range->range);
range->dependent_list = NULL;
......
......@@ -299,16 +299,6 @@ expr_tree_is_shared (ExprTree const *expr)
return (expr->any.ref_count > 1);
}
static gboolean
cellref_equal (CellRef const *a, CellRef const *b)
{
return (a->col_relative == b->col_relative) &&
(a->row_relative == b->row_relative) &&
(a->col == b->col) &&
(a->row == b->row) &&
(a->sheet == b->sheet);
}
/**
* expr_tree_equal : Returns TRUE if the supplied expressions are exactly the
* same. No eval position is used to see if they are effectively the same.
......@@ -842,13 +832,13 @@ eval_expr_real (EvalPos const *pos, ExprTree const *expr,
Sheet *cell_sheet;
CellRef const *ref;
Cell *cell;
int col, row;
CellPos dest;
ref = &expr->var.ref;
cell_get_abs_col_row (ref, &pos->eval, &col, &row);
cellref_get_abs_pos (ref, &pos->eval, &dest);
cell_sheet = eval_sheet (ref->sheet, pos->sheet);
cell = sheet_cell_get (cell_sheet, col, row);
cell = sheet_cell_get (cell_sheet, dest.col, dest.row);
if (cell == NULL)
return NULL;
......@@ -873,25 +863,25 @@ eval_expr_real (EvalPos const *pos, ExprTree const *expr,
* being evaluated as an array or not because we can differentiate
* based on the required type for the argument.
*/
CellRef const * const a = & res->v_range.cell.a;
CellRef const * const b = & res->v_range.cell.b;
CellRef const * const ref_a = & res->v_range.cell.a;
CellRef const * const ref_b = & res->v_range.cell.b;
gboolean found = FALSE;
if (a->sheet == b->sheet) {
int a_col, a_row, b_col, b_row;
if (ref_a->sheet == ref_b->sheet) {
CellPos a, b;
int c = pos->eval.col;
int r = pos->eval.row;
cell_get_abs_col_row (a, &pos->eval, &a_col, &a_row);
cell_get_abs_col_row (b, &pos->eval, &b_col, &b_row);
if (a_row == b_row) {
if (a_col <= c && c <= b_col) {
r = a_row;
cellref_get_abs_pos (ref_a, &pos->eval, &a);
cellref_get_abs_pos (ref_b, &pos->eval, &b);
if (a.row == b.row) {
if (a.col <= c && c <= b.col) {
r = a.row;
found = TRUE;
}
} else if (a_col == b_col) {
if (a_row <= r && r <= b_row) {
c = a_col;
} else if (a.col == b.col) {
if (a.row <= r && r <= b.row) {
c = a.col;
found = TRUE;
}
}
......@@ -1283,8 +1273,8 @@ cellref_relocate (CellRef *ref, ExprRelocateInfo const *rinfo,
* An action in () is one which is done despite being useless
* to simplify the logic.
*/
int col = cell_ref_get_abs_col (ref, &rinfo->pos);
int row = cell_ref_get_abs_row (ref, &rinfo->pos);
int col = cellref_get_abs_col (ref, &rinfo->pos);
int row = cellref_get_abs_row (ref, &rinfo->pos);
Sheet * ref_sheet = (ref->sheet != NULL) ? ref->sheet : rinfo->pos.sheet;
......
......@@ -660,12 +660,12 @@ function_marshal_arg (FunctionEvalInfo *ei,
if (v->type != VALUE_CELLRANGE)
*type_mismatch = TRUE;
else {
cell_ref_make_abs (&v->v_range.cell.a,
&v->v_range.cell.a,
ei->pos);
cell_ref_make_abs (&v->v_range.cell.b,
&v->v_range.cell.b,
ei->pos);
cellref_make_abs (&v->v_range.cell.a,
&v->v_range.cell.a,
ei->pos);
cellref_make_abs (&v->v_range.cell.b,
&v->v_range.cell.b,
ei->pos);
}
break;
......@@ -680,12 +680,12 @@ function_marshal_arg (FunctionEvalInfo *ei,
*type_mismatch = TRUE;
if (v->type == VALUE_CELLRANGE) {
cell_ref_make_abs (&v->v_range.cell.a,
&v->v_range.cell.a,
ei->pos);
cell_ref_make_abs (&v->v_range.cell.b,
&v->v_range.cell.b,
ei->pos);
cellref_make_abs (&v->v_range.cell.a,
&v->v_range.cell.a,
ei->pos);
cellref_make_abs (&v->v_range.cell.b,
&v->v_range.cell.b,
ei->pos);
}
break;
......
......@@ -673,9 +673,10 @@ gnumeric_isblank (FunctionEvalInfo *ei, GList *expr_node_list)
if (expr->any.oper == OPER_VAR) {
CellRef const *ref = &expr->var.ref;
Sheet const *sheet = eval_sheet (ref->sheet, ei->pos->sheet);
int row, col;
cell_get_abs_col_row(ref, &ei->pos->eval, &col, &row);
result = cell_is_blank(sheet_cell_get(sheet, col, row));
CellPos pos;
cellref_get_abs_pos (ref, &ei->pos->eval, &pos);
result = cell_is_blank (sheet_cell_get (sheet, pos.col, pos.row));
}
return value_new_bool (result);
}
......
......@@ -848,8 +848,8 @@ gnumeric_column (FunctionEvalInfo *ei, GList *nodes)
expr = (ExprTree *)nodes->data;
if (expr->any.oper == OPER_VAR)
return value_new_int (cell_ref_get_abs_col (&expr->var.ref,
ei->pos) + 1);
return value_new_int (cellref_get_abs_col (&expr->var.ref,
ei->pos) + 1);
if (expr->any.oper == OPER_CONSTANT &&
expr->constant.value->type == VALUE_CELLRANGE) {
int i, j, col;
......@@ -859,7 +859,7 @@ gnumeric_column (FunctionEvalInfo *ei, GList *nodes)
Value * res = value_new_array (abs (b->col - a->col) + 1,
abs (b->row - a->row) + 1);
col = cell_ref_get_abs_col (a, ei->pos) + 1;
col = cellref_get_abs_col (a, ei->pos) + 1;
for (i = abs (b->col - a->col) ; i >= 0 ; --i)
for (j = abs (b->row - a->row) ; j >= 0 ; --j)
value_array_set(res, i, j,
......@@ -988,7 +988,7 @@ gnumeric_row (FunctionEvalInfo *ei, GList *nodes)
expr = (ExprTree *)nodes->data;
if (expr->any.oper == OPER_VAR)
return value_new_int (cell_ref_get_abs_row (&expr->var.ref,
return value_new_int (cellref_get_abs_row (&expr->var.ref,
ei->pos) + 1);
if (expr->any.oper == OPER_CONSTANT &&
expr->constant.value->type == VALUE_CELLRANGE) {
......@@ -999,7 +999,7 @@ gnumeric_row (FunctionEvalInfo *ei, GList *nodes)
Value * res = value_new_array (abs (b->col - a->col) + 1,
abs (b->row - a->row) + 1);
row = cell_ref_get_abs_row (a, ei->pos) + 1;
row = cellref_get_abs_row (a, ei->pos) + 1;
for (i = abs (b->col - a->col) ; i >= 0 ; --i)
for (j = abs (b->row - a->row) ; j >= 0 ; --j)
value_array_set(res, i, j,
......
This diff is collapsed.
......@@ -4,32 +4,34 @@
#include "gnumeric.h"
#include <gtk/gtkwidget.h>
#define GNUMERIC_GRAPH_TYPE (gnm_graph_get_type ())
#define GNUMERIC_GRAPH(o) (GTK_CHECK_CAST ((o), GNUMERIC_GRAPH_TYPE, GnmGraph))
#define IS_GNUMERIC_GRAPH(o) (GTK_CHECK_TYPE ((o), GNUMERIC_GRAPH_TYPE))
GtkType gnm_graph_get_type (void);
GnmGraph *gnm_graph_new (Workbook *wb);
GtkWidget *gnm_graph_type_selector (GnmGraph *graph);
void gnm_graph_clear_vectors (GnmGraph *graph);
void gnm_graph_arrange_vectors (GnmGraph *graph);
#define GNUMERIC_GRAPH_VECTOR_TYPE (gnm_graph_vector_get_type ())
#define GNUMERIC_GRAPH_VECTOR(o) (GTK_CHECK_CAST ((o), GNUMERIC_GRAPH_VECTOR_TYPE, GnmGraphVector))
#define IS_GNUMERIC_GRAPH_VECTOR(o) (GTK_CHECK_TYPE ((o), GNUMERIC_GRAPH_VECTOR_TYPE))
typedef enum {
GNM_VECTOR_AUTO = 0,
GNM_VECTOR_SCALAR = 1,
GNM_VECTOR_DATE = 2,
GNM_VECTOR_STRING = 3
} GnmGraphVectorType;
extern char const * const gnm_graph_vector_type_name [];
GtkType gnm_graph_vector_get_type (void);
GnmGraphVector *gnm_graph_vector_new (GnmGraph *graph,
#define GNUMERIC_GRAPH_TYPE (gnm_graph_get_type ())
#define GNUMERIC_GRAPH(o) (GTK_CHECK_CAST ((o), GNUMERIC_GRAPH_TYPE, GnmGraph))
#define IS_GNUMERIC_GRAPH(o) (GTK_CHECK_TYPE ((o), GNUMERIC_GRAPH_TYPE))
GtkType gnm_graph_get_type (void);
GnmGraph *gnm_graph_new (Workbook *wb);
GtkWidget *gnm_graph_type_selector (GnmGraph *graph);
void gnm_graph_clear_vectors (GnmGraph *graph);
void gnm_graph_arrange_vectors (GnmGraph *graph);
GnmGraphVector *gnm_graph_add_vector (GnmGraph *graph,
ExprTree *expr,
GnmGraphVectorType type,
Sheet *sheet);
extern char const * const gnm_graph_vector_type_name [];
#define GNUMERIC_GRAPH_VECTOR_TYPE (gnm_graph_vector_get_type ())
#define GNUMERIC_GRAPH_VECTOR(o) (GTK_CHECK_CAST ((o), GNUMERIC_GRAPH_VECTOR_TYPE, GnmGraphVector))
#define IS_GNUMERIC_GRAPH_VECTOR(o) (GTK_CHECK_TYPE ((o), GNUMERIC_GRAPH_VECTOR_TYPE))
GtkType gnm_graph_vector_get_type (void);
#endif /* GNUMERIC_GRAPH_H */
......@@ -114,8 +114,18 @@ parse_pos_init_evalpos (ParsePos *pp, EvalPos const *ep)
return parse_pos_init (pp, NULL, ep->sheet, ep->eval.col, ep->eval.row);
}
gboolean
cellref_equal (CellRef const *a, CellRef const *b)
{
return (a->col_relative == b->col_relative) &&
(a->row_relative == b->row_relative) &&
(a->col == b->col) &&
(a->row == b->row) &&
(a->sheet == b->sheet);
}
void
cell_ref_make_abs (CellRef *dest, CellRef const *src, EvalPos const *ep)
cellref_make_abs (CellRef *dest, CellRef const *src, EvalPos const *ep)
{
g_return_if_fail (dest != NULL);
g_return_if_fail (src != NULL);
......@@ -132,7 +142,7 @@ cell_ref_make_abs (CellRef *dest, CellRef const *src, EvalPos const *ep)
}
int
cell_ref_get_abs_col (CellRef const *ref, EvalPos const *pos)
cellref_get_abs_col (CellRef const *ref, EvalPos const *pos)
{
g_return_val_if_fail (ref != NULL, 0);
g_return_val_if_fail (pos != NULL, 0);
......@@ -144,7 +154,7 @@ cell_ref_get_abs_col (CellRef const *ref, EvalPos const *pos)
}
int
cell_ref_get_abs_row (CellRef const *ref, EvalPos const *pos)
cellref_get_abs_row (CellRef const *ref, EvalPos const *pos)
{
g_return_val_if_fail (ref != NULL, 0);
g_return_val_if_fail (pos != NULL, 0);
......@@ -155,20 +165,21 @@ cell_ref_get_abs_row (CellRef const *ref, EvalPos const *pos)
}
void
cell_get_abs_col_row (CellRef const *cell_ref,
CellPos const *pos,
int *col, int *row)
cellref_get_abs_pos (CellRef const *cell_ref,
CellPos const *pos,
CellPos *res)
{
g_return_if_fail (cell_ref != NULL);
g_return_if_fail (res != NULL);
if (cell_ref->col_relative)
*col = pos->col + cell_ref->col;
res->col = cell_ref->col + pos->col;
else
*col = cell_ref->col;
res->col = cell_ref->col;
if (cell_ref->row_relative)
*row = pos->row + cell_ref->row;
res->row = cell_ref->row + pos->row;
else
*row = cell_ref->row;
res->row = cell_ref->row;
}
......@@ -44,16 +44,16 @@ struct _RangeRef {
CellRef a, b;
};
/* Normalize CellRefs */
void cell_ref_make_abs (CellRef *dest,
gboolean cellref_equal (CellRef const *a, CellRef const *b);
void cellref_make_abs (CellRef *dest,
CellRef const *src,
EvalPos const *ep);
int cell_ref_get_abs_col (CellRef const *ref,
int cellref_get_abs_col (CellRef const *ref,
EvalPos const *pos);
int cell_ref_get_abs_row (CellRef const *cell_ref,
int cellref_get_abs_row (CellRef const *cell_ref,
EvalPos const *src_fp);
void cell_get_abs_col_row (CellRef const *cell_ref,
void cellref_get_abs_pos (CellRef const *cell_ref,
CellPos const *pos,
int *col, int *row);
CellPos *res);
#endif /* GNUMERIC_POSITION_H */
......@@ -357,10 +357,8 @@ value_cellrange_normalize (EvalPos const *ep, Value const *ref,
g_return_if_fail (ep != NULL);
g_return_if_fail (ref->type == VALUE_CELLRANGE);
cell_get_abs_col_row (&ref->v_range.cell.a, &ep->eval,
&dest->start.col, &dest->start.row);
cell_get_abs_col_row (&ref->v_range.cell.b, &ep->eval,
&dest->end.col, &dest->end.row);
cellref_get_abs_pos (&ref->v_range.cell.a, &ep->eval, &dest->start);
cellref_get_abs_pos (&ref->v_range.cell.b, &ep->eval, &dest->end);
range_normalize (dest);
*start_sheet = eval_sheet (ref->v_range.cell.a.sheet, ep->sheet);
......
......@@ -1716,7 +1716,7 @@ xml_write_cell_and_position (XmlParseContext *ctxt, Cell *cell, int col, int row
ExprArray const *ar;
gboolean write_contents = TRUE;
gboolean const is_shared_expr =
(cell_has_expr (cell) && expr_tree_shared (cell->base.expression));
(cell_has_expr (cell) && expr_tree_is_shared (cell->base.expression));
cur = xmlNewDocNode (ctxt->doc, ctxt->ns, "Cell", NULL);
xml_set_value_int (cur, "Col", col);
......
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