Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GNOME
gnumeric
Commits
d3455f38
Commit
d3455f38
authored
Jun 24, 1999
by
Michael Meeks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Area functions updated.
parent
419a71d7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
81 deletions
+125
-81
ChangeLog-1999-07-09
ChangeLog-1999-07-09
+9
-0
ChangeLog-2000-02-23
ChangeLog-2000-02-23
+9
-0
OChangeLog-1999-07-09
OChangeLog-1999-07-09
+9
-0
OChangeLog-2000-02-23
OChangeLog-2000-02-23
+9
-0
plugins/fn-lookup/functions.c
plugins/fn-lookup/functions.c
+21
-21
src/expr.c
src/expr.c
+21
-15
src/expr.h
src/expr.h
+5
-3
src/fn-lookup.c
src/fn-lookup.c
+21
-21
src/functions/fn-lookup.c
src/functions/fn-lookup.c
+21
-21
No files found.
ChangeLog-1999-07-09
View file @
d3455f38
1999-06-24 Michael Meeks <michael@edenproject.org>
* src/expr.c (value_area_get_at_x_y): Return value_zero instead
of the leaky value_new_int.
(value_area_get_at_x_y, value_area_get_width, value_area_get_height):
Updated to fall back to EvalPosition's Sheet *.
* src/expr.h: Added 'EvalPosition' parameter to area functions.
1999-06-23 Morten Welinder <terra@diku.dk>
* src/fn-stat.c (gnumeric_poisson): Fix formula and error
...
...
ChangeLog-2000-02-23
View file @
d3455f38
1999-06-24 Michael Meeks <michael@edenproject.org>
* src/expr.c (value_area_get_at_x_y): Return value_zero instead
of the leaky value_new_int.
(value_area_get_at_x_y, value_area_get_width, value_area_get_height):
Updated to fall back to EvalPosition's Sheet *.
* src/expr.h: Added 'EvalPosition' parameter to area functions.
1999-06-23 Morten Welinder <terra@diku.dk>
* src/fn-stat.c (gnumeric_poisson): Fix formula and error
...
...
OChangeLog-1999-07-09
View file @
d3455f38
1999-06-24 Michael Meeks <michael@edenproject.org>
* src/expr.c (value_area_get_at_x_y): Return value_zero instead
of the leaky value_new_int.
(value_area_get_at_x_y, value_area_get_width, value_area_get_height):
Updated to fall back to EvalPosition's Sheet *.
* src/expr.h: Added 'EvalPosition' parameter to area functions.
1999-06-23 Morten Welinder <terra@diku.dk>
* src/fn-stat.c (gnumeric_poisson): Fix formula and error
...
...
OChangeLog-2000-02-23
View file @
d3455f38
1999-06-24 Michael Meeks <michael@edenproject.org>
* src/expr.c (value_area_get_at_x_y): Return value_zero instead
of the leaky value_new_int.
(value_area_get_at_x_y, value_area_get_width, value_area_get_height):
Updated to fall back to EvalPosition's Sheet *.
* src/expr.h: Added 'EvalPosition' parameter to area functions.
1999-06-23 Morten Welinder <terra@diku.dk>
* src/fn-stat.c (gnumeric_poisson): Fix formula and error
...
...
plugins/fn-lookup/functions.c
View file @
d3455f38
...
...
@@ -263,13 +263,13 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
const
Value
*
next_largest
=
NULL
;
int
height
,
lp
,
approx
,
col_idx
,
next_largest_row
=
0
;
height
=
value_area_get_height
(
args
[
1
]);
height
=
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]);
col_idx
=
value_get_as_int
(
args
[
2
]);
if
(
col_idx
<=
0
)
return
function_error
(
ei
,
gnumeric_err_NUM
);
if
(
col_idx
>
value_area_get_width
(
args
[
1
]))
if
(
col_idx
>
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]))
return
function_error
(
ei
,
gnumeric_err_REF
);
if
(
args
[
3
]){
...
...
@@ -286,7 +286,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
int
compare
;
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
0
,
lp
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
0
,
lp
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -295,7 +295,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
if
(
compare
==
1
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
col_idx
-
1
,
lp
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
col_idx
-
1
,
lp
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -308,7 +308,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
if
(
approx
&&
next_largest
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
col_idx
-
1
,
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
col_idx
-
1
,
next_largest_row
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -345,12 +345,12 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
int
height
,
lp
,
approx
,
row_idx
,
next_largest_col
=
0
;
row_idx
=
value_get_as_int
(
args
[
2
]);
height
=
value_area_get_width
(
args
[
1
]);
height
=
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]);
if
(
row_idx
<=
0
)
return
function_error
(
ei
,
gnumeric_err_NUM
);
if
(
row_idx
>
value_area_get_height
(
args
[
1
]))
if
(
row_idx
>
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]))
return
function_error
(
ei
,
gnumeric_err_REF
);
if
(
args
[
3
]){
...
...
@@ -366,7 +366,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
int
compare
;
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
lp
,
0
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
lp
,
0
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -375,7 +375,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
if
(
compare
==
1
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
lp
,
row_idx
-
1
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
lp
,
row_idx
-
1
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -389,7 +389,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
if
(
approx
&&
next_largest
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
next_largest_col
,
row_idx
-
1
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -429,8 +429,8 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
int
next_largest_x
=
0
;
int
next_largest_y
=
0
;
height
=
value_area_get_height
(
args
[
1
]);
width
=
value_area_get_width
(
args
[
1
]);
height
=
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]);
width
=
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]);
if
((
args
[
1
]
->
type
==
VALUE_ARRAY
))
{
if
(
args
[
2
])
...
...
@@ -458,19 +458,19 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
src
=
args
[
1
];
dest
=
args
[
2
];
}
maxy
=
value_area_get_height
(
src
);
maxx
=
value_area_get_width
(
dest
);
if
((
tmp
=
value_area_get_height
(
src
))
<
maxy
)
maxy
=
value_area_get_height
(
&
ei
->
pos
,
src
);
maxx
=
value_area_get_width
(
&
ei
->
pos
,
dest
);
if
((
tmp
=
value_area_get_height
(
&
ei
->
pos
,
src
))
<
maxy
)
maxy
=
tmp
;
if
((
tmp
=
value_area_get_width
(
src
))
<
maxx
)
if
((
tmp
=
value_area_get_width
(
&
ei
->
pos
,
src
))
<
maxx
)
maxx
=
tmp
;
touched
=
0
;
for
(
lpx
=
0
,
lpy
=
0
;
lpx
<
maxx
&&
lpy
<
maxy
;)
{
const
Value
*
v
=
value_area_get_at_x_y
(
src
,
lpx
,
lpy
);
const
Value
*
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
src
,
lpx
,
lpy
);
compare
=
lookup_similar
(
v
,
args
[
0
],
next_largest
,
1
);
if
(
compare
==
1
)
return
value_duplicate
(
value_duplicate
(
value_area_get_at_x_y
(
dest
,
next_largest_x
+
x_offset
,
return
value_duplicate
(
value_duplicate
(
value_area_get_at_x_y
(
&
ei
->
pos
,
dest
,
next_largest_x
+
x_offset
,
next_largest_y
+
y_offset
)));
if
(
compare
<
0
)
{
next_largest
=
v
;
...
...
@@ -488,7 +488,7 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
if
(
!
next_largest
)
return
function_error
(
ei
,
gnumeric_err_NA
);
return
value_duplicate
(
value_area_get_at_x_y
(
dest
,
return
value_duplicate
(
value_area_get_at_x_y
(
&
ei
->
pos
,
dest
,
next_largest_x
+
x_offset
,
next_largest_y
+
y_offset
));
}
...
...
@@ -554,7 +554,7 @@ static char *help_columns = {
static
Value
*
gnumeric_columns
(
FunctionEvalInfo
*
ei
,
Value
**
args
)
{
return
value_new_int
(
value_area_get_width
(
args
[
0
]));
return
value_new_int
(
value_area_get_width
(
&
ei
->
pos
,
args
[
0
]));
}
static
char
*
help_offset
=
{
...
...
@@ -659,7 +659,7 @@ static char *help_rows = {
static
Value
*
gnumeric_rows
(
FunctionEvalInfo
*
ei
,
Value
**
args
)
{
return
value_new_int
(
value_area_get_height
(
args
[
0
]));
return
value_new_int
(
value_area_get_height
(
&
ei
->
pos
,
args
[
0
]));
}
void
lookup_functions_init
()
...
...
src/expr.c
View file @
d3455f38
...
...
@@ -784,7 +784,7 @@ value_array_copy_to (Value *v, const Value *src)
}
guint
value_area_get_width
(
Value
*
v
)
value_area_get_width
(
const
EvalPosition
*
ep
,
Value
*
v
)
{
g_return_val_if_fail
(
v
,
0
);
g_return_val_if_fail
(
v
->
type
==
VALUE_ARRAY
||
...
...
@@ -792,18 +792,19 @@ value_area_get_width (Value *v)
if
(
v
->
type
==
VALUE_ARRAY
)
return
v
->
v
.
array
.
x
;
else
{
else
{
/* FIXME: 3D references, may not clip correctly */
Sheet
*
sheeta
=
v
->
v
.
cell_range
.
cell_a
.
sheet
?
v
->
v
.
cell_range
.
cell_a
.
sheet
:
ep
->
sheet
;
guint
ans
=
v
->
v
.
cell_range
.
cell_b
.
col
-
v
->
v
.
cell_range
.
cell_a
.
col
+
1
;
if
(
v
->
v
.
cell_range
.
cell_a
.
sheet
&&
v
->
v
.
cell_range
.
cell_a
.
sheet
->
max_col_used
<
ans
)
ans
=
v
->
v
.
cell_range
.
cell_a
.
sheet
->
max_col_used
+
1
;
if
(
sheeta
&&
sheeta
->
max_col_used
<
ans
)
/* Clip */
ans
=
sheeta
->
max_col_used
+
1
;
return
ans
;
}
}
guint
value_area_get_height
(
Value
*
v
)
value_area_get_height
(
const
EvalPosition
*
ep
,
Value
*
v
)
{
g_return_val_if_fail
(
v
,
0
);
g_return_val_if_fail
(
v
->
type
==
VALUE_ARRAY
||
...
...
@@ -811,49 +812,54 @@ value_area_get_height (Value *v)
if
(
v
->
type
==
VALUE_ARRAY
)
return
v
->
v
.
array
.
y
;
else
{
else
{
/* FIXME: 3D references, may not clip correctly */
Sheet
*
sheeta
=
v
->
v
.
cell_range
.
cell_a
.
sheet
?
v
->
v
.
cell_range
.
cell_a
.
sheet
:
ep
->
sheet
;
guint
ans
=
v
->
v
.
cell_range
.
cell_b
.
row
-
v
->
v
.
cell_range
.
cell_a
.
row
+
1
;
if
(
v
->
v
.
cell_range
.
cell_a
.
sheet
&&
v
->
v
.
cell_range
.
cell_a
.
sheet
->
max_row_used
<
ans
)
ans
=
v
->
v
.
cell_range
.
cell_a
.
sheet
->
max_row_used
+
1
;
if
(
sheeta
&&
sheeta
->
max_row_used
<
ans
)
/* Clip */
ans
=
sheeta
->
max_row_used
+
1
;
return
ans
;
}
}
const
Value
*
value_area_get_at_x_y
(
Value
*
v
,
guint
x
,
guint
y
)
value_area_get_at_x_y
(
const
EvalPosition
*
ep
,
Value
*
v
,
guint
x
,
guint
y
)
{
g_return_val_if_fail
(
v
,
0
);
g_return_val_if_fail
(
v
->
type
==
VALUE_ARRAY
||
v
->
type
==
VALUE_CELLRANGE
,
value_
new_int
(
0
)
);
value_
zero
);
if
(
v
->
type
==
VALUE_ARRAY
){
g_return_val_if_fail
(
v
->
v
.
array
.
x
<
x
&&
v
->
v
.
array
.
y
<
y
,
value_
new_int
(
0
)
);
value_
zero
);
return
v
->
v
.
array
.
vals
[
x
][
y
];
}
else
{
CellRef
*
a
,
*
b
;
Cell
*
cell
;
Sheet
*
sheet
;
a
=
&
v
->
v
.
cell_range
.
cell_a
;
b
=
&
v
->
v
.
cell_range
.
cell_b
;
/* Fixme: these need to be altered to use 'ep' to calc.
non relative values if necessary */
g_return_val_if_fail
(
!
a
->
col_relative
,
value_zero
);
g_return_val_if_fail
(
!
b
->
col_relative
,
value_zero
);
g_return_val_if_fail
(
!
a
->
row_relative
,
value_zero
);
g_return_val_if_fail
(
!
b
->
row_relative
,
value_zero
);
g_return_val_if_fail
(
a
->
col
<=
b
->
col
,
value_zero
);
g_return_val_if_fail
(
a
->
row
<=
b
->
row
,
value_zero
);
g_return_val_if_fail
(
a
->
sheet
,
value_zero
);
sheet
=
a
->
sheet
?
a
->
sheet
:
ep
->
sheet
;
g_return_val_if_fail
(
sheet
,
value_zero
);
/* Speedup */
if
(
a
->
sheet
->
max_col_used
<
a
->
col
+
x
||
a
->
sheet
->
max_row_used
<
a
->
row
+
y
)
return
value_zero
;
cell
=
sheet_cell_get
(
a
->
sheet
,
a
->
col
+
x
,
a
->
row
+
y
);
cell
=
sheet_cell_get
(
sheet
,
a
->
col
+
x
,
a
->
row
+
y
);
if
(
cell
&&
cell
->
value
)
return
cell
->
value
;
...
...
src/expr.h
View file @
d3455f38
...
...
@@ -262,9 +262,11 @@ char *value_get_as_string (const Value *value);
void
value_dump
(
const
Value
*
value
);
/* Area functions ( works on VALUE_RANGE or VALUE_ARRAY */
guint
value_area_get_width
(
Value
*
v
);
guint
value_area_get_height
(
Value
*
v
);
const
Value
*
value_area_get_at_x_y
(
Value
*
v
,
guint
x
,
guint
y
);
/* The EvalPosition provides a Sheet context; this allows
calculation of relative references. 'x','y' give the position */
guint
value_area_get_width
(
const
EvalPosition
*
ep
,
Value
*
v
);
guint
value_area_get_height
(
const
EvalPosition
*
ep
,
Value
*
v
);
const
Value
*
value_area_get_at_x_y
(
const
EvalPosition
*
ep
,
Value
*
v
,
guint
x
,
guint
y
);
Value
*
value_array_new
(
guint
width
,
guint
height
);
void
value_array_set
(
Value
*
array
,
guint
col
,
guint
row
,
Value
*
v
);
...
...
src/fn-lookup.c
View file @
d3455f38
...
...
@@ -263,13 +263,13 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
const
Value
*
next_largest
=
NULL
;
int
height
,
lp
,
approx
,
col_idx
,
next_largest_row
=
0
;
height
=
value_area_get_height
(
args
[
1
]);
height
=
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]);
col_idx
=
value_get_as_int
(
args
[
2
]);
if
(
col_idx
<=
0
)
return
function_error
(
ei
,
gnumeric_err_NUM
);
if
(
col_idx
>
value_area_get_width
(
args
[
1
]))
if
(
col_idx
>
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]))
return
function_error
(
ei
,
gnumeric_err_REF
);
if
(
args
[
3
]){
...
...
@@ -286,7 +286,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
int
compare
;
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
0
,
lp
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
0
,
lp
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -295,7 +295,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
if
(
compare
==
1
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
col_idx
-
1
,
lp
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
col_idx
-
1
,
lp
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -308,7 +308,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
if
(
approx
&&
next_largest
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
col_idx
-
1
,
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
col_idx
-
1
,
next_largest_row
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -345,12 +345,12 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
int
height
,
lp
,
approx
,
row_idx
,
next_largest_col
=
0
;
row_idx
=
value_get_as_int
(
args
[
2
]);
height
=
value_area_get_width
(
args
[
1
]);
height
=
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]);
if
(
row_idx
<=
0
)
return
function_error
(
ei
,
gnumeric_err_NUM
);
if
(
row_idx
>
value_area_get_height
(
args
[
1
]))
if
(
row_idx
>
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]))
return
function_error
(
ei
,
gnumeric_err_REF
);
if
(
args
[
3
]){
...
...
@@ -366,7 +366,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
int
compare
;
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
lp
,
0
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
lp
,
0
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -375,7 +375,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
if
(
compare
==
1
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
lp
,
row_idx
-
1
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
lp
,
row_idx
-
1
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -389,7 +389,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
if
(
approx
&&
next_largest
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
next_largest_col
,
row_idx
-
1
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -429,8 +429,8 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
int
next_largest_x
=
0
;
int
next_largest_y
=
0
;
height
=
value_area_get_height
(
args
[
1
]);
width
=
value_area_get_width
(
args
[
1
]);
height
=
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]);
width
=
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]);
if
((
args
[
1
]
->
type
==
VALUE_ARRAY
))
{
if
(
args
[
2
])
...
...
@@ -458,19 +458,19 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
src
=
args
[
1
];
dest
=
args
[
2
];
}
maxy
=
value_area_get_height
(
src
);
maxx
=
value_area_get_width
(
dest
);
if
((
tmp
=
value_area_get_height
(
src
))
<
maxy
)
maxy
=
value_area_get_height
(
&
ei
->
pos
,
src
);
maxx
=
value_area_get_width
(
&
ei
->
pos
,
dest
);
if
((
tmp
=
value_area_get_height
(
&
ei
->
pos
,
src
))
<
maxy
)
maxy
=
tmp
;
if
((
tmp
=
value_area_get_width
(
src
))
<
maxx
)
if
((
tmp
=
value_area_get_width
(
&
ei
->
pos
,
src
))
<
maxx
)
maxx
=
tmp
;
touched
=
0
;
for
(
lpx
=
0
,
lpy
=
0
;
lpx
<
maxx
&&
lpy
<
maxy
;)
{
const
Value
*
v
=
value_area_get_at_x_y
(
src
,
lpx
,
lpy
);
const
Value
*
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
src
,
lpx
,
lpy
);
compare
=
lookup_similar
(
v
,
args
[
0
],
next_largest
,
1
);
if
(
compare
==
1
)
return
value_duplicate
(
value_duplicate
(
value_area_get_at_x_y
(
dest
,
next_largest_x
+
x_offset
,
return
value_duplicate
(
value_duplicate
(
value_area_get_at_x_y
(
&
ei
->
pos
,
dest
,
next_largest_x
+
x_offset
,
next_largest_y
+
y_offset
)));
if
(
compare
<
0
)
{
next_largest
=
v
;
...
...
@@ -488,7 +488,7 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
if
(
!
next_largest
)
return
function_error
(
ei
,
gnumeric_err_NA
);
return
value_duplicate
(
value_area_get_at_x_y
(
dest
,
return
value_duplicate
(
value_area_get_at_x_y
(
&
ei
->
pos
,
dest
,
next_largest_x
+
x_offset
,
next_largest_y
+
y_offset
));
}
...
...
@@ -554,7 +554,7 @@ static char *help_columns = {
static
Value
*
gnumeric_columns
(
FunctionEvalInfo
*
ei
,
Value
**
args
)
{
return
value_new_int
(
value_area_get_width
(
args
[
0
]));
return
value_new_int
(
value_area_get_width
(
&
ei
->
pos
,
args
[
0
]));
}
static
char
*
help_offset
=
{
...
...
@@ -659,7 +659,7 @@ static char *help_rows = {
static
Value
*
gnumeric_rows
(
FunctionEvalInfo
*
ei
,
Value
**
args
)
{
return
value_new_int
(
value_area_get_height
(
args
[
0
]));
return
value_new_int
(
value_area_get_height
(
&
ei
->
pos
,
args
[
0
]));
}
void
lookup_functions_init
()
...
...
src/functions/fn-lookup.c
View file @
d3455f38
...
...
@@ -263,13 +263,13 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
const
Value
*
next_largest
=
NULL
;
int
height
,
lp
,
approx
,
col_idx
,
next_largest_row
=
0
;
height
=
value_area_get_height
(
args
[
1
]);
height
=
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]);
col_idx
=
value_get_as_int
(
args
[
2
]);
if
(
col_idx
<=
0
)
return
function_error
(
ei
,
gnumeric_err_NUM
);
if
(
col_idx
>
value_area_get_width
(
args
[
1
]))
if
(
col_idx
>
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]))
return
function_error
(
ei
,
gnumeric_err_REF
);
if
(
args
[
3
]){
...
...
@@ -286,7 +286,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
int
compare
;
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
0
,
lp
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
0
,
lp
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -295,7 +295,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
if
(
compare
==
1
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
col_idx
-
1
,
lp
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
col_idx
-
1
,
lp
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -308,7 +308,7 @@ gnumeric_vlookup (FunctionEvalInfo *ei, Value **args)
if
(
approx
&&
next_largest
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
col_idx
-
1
,
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
col_idx
-
1
,
next_largest_row
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -345,12 +345,12 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
int
height
,
lp
,
approx
,
row_idx
,
next_largest_col
=
0
;
row_idx
=
value_get_as_int
(
args
[
2
]);
height
=
value_area_get_width
(
args
[
1
]);
height
=
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]);
if
(
row_idx
<=
0
)
return
function_error
(
ei
,
gnumeric_err_NUM
);
if
(
row_idx
>
value_area_get_height
(
args
[
1
]))
if
(
row_idx
>
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]))
return
function_error
(
ei
,
gnumeric_err_REF
);
if
(
args
[
3
]){
...
...
@@ -366,7 +366,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
int
compare
;
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
lp
,
0
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
lp
,
0
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -375,7 +375,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
if
(
compare
==
1
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
lp
,
row_idx
-
1
);
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
lp
,
row_idx
-
1
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
return
value_duplicate
(
v
);
...
...
@@ -389,7 +389,7 @@ gnumeric_hlookup (FunctionEvalInfo *ei, Value **args)
if
(
approx
&&
next_largest
){
const
Value
*
v
;
v
=
value_area_get_at_x_y
(
args
[
1
],
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
args
[
1
],
next_largest_col
,
row_idx
-
1
);
g_return_val_if_fail
(
v
!=
NULL
,
NULL
);
...
...
@@ -429,8 +429,8 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
int
next_largest_x
=
0
;
int
next_largest_y
=
0
;
height
=
value_area_get_height
(
args
[
1
]);
width
=
value_area_get_width
(
args
[
1
]);
height
=
value_area_get_height
(
&
ei
->
pos
,
args
[
1
]);
width
=
value_area_get_width
(
&
ei
->
pos
,
args
[
1
]);
if
((
args
[
1
]
->
type
==
VALUE_ARRAY
))
{
if
(
args
[
2
])
...
...
@@ -458,19 +458,19 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
src
=
args
[
1
];
dest
=
args
[
2
];
}
maxy
=
value_area_get_height
(
src
);
maxx
=
value_area_get_width
(
dest
);
if
((
tmp
=
value_area_get_height
(
src
))
<
maxy
)
maxy
=
value_area_get_height
(
&
ei
->
pos
,
src
);
maxx
=
value_area_get_width
(
&
ei
->
pos
,
dest
);
if
((
tmp
=
value_area_get_height
(
&
ei
->
pos
,
src
))
<
maxy
)
maxy
=
tmp
;
if
((
tmp
=
value_area_get_width
(
src
))
<
maxx
)
if
((
tmp
=
value_area_get_width
(
&
ei
->
pos
,
src
))
<
maxx
)
maxx
=
tmp
;
touched
=
0
;
for
(
lpx
=
0
,
lpy
=
0
;
lpx
<
maxx
&&
lpy
<
maxy
;)
{
const
Value
*
v
=
value_area_get_at_x_y
(
src
,
lpx
,
lpy
);
const
Value
*
v
=
value_area_get_at_x_y
(
&
ei
->
pos
,
src
,
lpx
,
lpy
);
compare
=
lookup_similar
(
v
,
args
[
0
],
next_largest
,
1
);
if
(
compare
==
1
)
return
value_duplicate
(
value_duplicate
(
value_area_get_at_x_y
(
dest
,
next_largest_x
+
x_offset
,
return
value_duplicate
(
value_duplicate
(
value_area_get_at_x_y
(
&
ei
->
pos
,
dest
,
next_largest_x
+
x_offset
,
next_largest_y
+
y_offset
)));
if
(
compare
<
0
)
{
next_largest
=
v
;
...
...
@@ -488,7 +488,7 @@ gnumeric_lookup (FunctionEvalInfo *ei, Value **args)
if
(
!
next_largest
)
return
function_error
(
ei
,
gnumeric_err_NA
);
return
value_duplicate
(
value_area_get_at_x_y
(
dest
,
return
value_duplicate
(
value_area_get_at_x_y
(
&
ei
->
pos
,
dest
,
next_largest_x
+
x_offset
,
next_largest_y
+
y_offset
));
}
...
...
@@ -554,7 +554,7 @@ static char *help_columns = {
static
Value
*
gnumeric_columns
(
FunctionEvalInfo
*
ei
,
Value
**
args
)
{
return
value_new_int
(
value_area_get_width
(
args
[
0
]));
return
value_new_int
(
value_area_get_width
(
&
ei
->
pos
,
args
[
0
]));
}
static
char
*
help_offset
=
{
...
...
@@ -659,7 +659,7 @@ static char *help_rows = {
static
Value
*
gnumeric_rows
(
FunctionEvalInfo
*
ei
,
Value
**
args
)
{
return
value_new_int
(
value_area_get_height
(
args
[
0
]));
return
value_new_int
(
value_area_get_height
(
&
ei
->
pos
,
args
[
0
]));
}
void
lookup_functions_init
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment