Commit 16ad54ce authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Change traversal order for ranges.

2000-07-08  Morten Welinder  <terra@diku.dk>

	* src/sheet.c (sheet_cell_foreach_range): Change traversal order
 	for ranges.

	* src/func.c (function_iterate_do_value): Fix traversal order for
 	arrays.
parent b123a111
......@@ -57,6 +57,10 @@ Long term breakage
eg value_error_new("1+3") will print the string 1+3 as the error.
Something more comprehensive is necessary.
- Functions like SUMPRODUCT need to have better support for sparse ranges.
We should probably create synchroneously_walk_ranges. (XL goes kaboom on
large ranges also, but we ought to be smarter.)
Dialogs
-------
- Use color combos in format dialog.
......
2000-07-08 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_cell_foreach_range): Change traversal order
for ranges.
* src/func.c (function_iterate_do_value): Fix traversal order for
arrays.
2000-07-07 Morten Welinder <terra@diku.dk>
* src/functions/fn-math.c (gnumeric_sumproduct): Rewrite with lots
......
2000-07-08 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_cell_foreach_range): Change traversal order
for ranges.
* src/func.c (function_iterate_do_value): Fix traversal order for
arrays.
2000-07-07 Morten Welinder <terra@diku.dk>
* src/functions/fn-math.c (gnumeric_sumproduct): Rewrite with lots
......
......@@ -23,6 +23,8 @@ Morten:
* Cleanup analysis tool code.
* Eliminate many fixed limits in the code. (Still some to go.)
* Rewrote SUMPRODUCT.
* Fix array and range traversal order, thus fixing all strict
range functions. (SUM, MIN, ...)
Translations:
* Updated: de (Karl), no (Kjartan), maybe more.
......
2000-07-08 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_cell_foreach_range): Change traversal order
for ranges.
* src/func.c (function_iterate_do_value): Fix traversal order for
arrays.
2000-07-07 Morten Welinder <terra@diku.dk>
* src/functions/fn-math.c (gnumeric_sumproduct): Rewrite with lots
......
2000-07-08 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_cell_foreach_range): Change traversal order
for ranges.
* src/func.c (function_iterate_do_value): Fix traversal order for
arrays.
2000-07-07 Morten Welinder <terra@diku.dk>
* src/functions/fn-math.c (gnumeric_sumproduct): Rewrite with lots
......
2000-07-08 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_cell_foreach_range): Change traversal order
for ranges.
* src/func.c (function_iterate_do_value): Fix traversal order for
arrays.
2000-07-07 Morten Welinder <terra@diku.dk>
* src/functions/fn-math.c (gnumeric_sumproduct): Rewrite with lots
......
2000-07-08 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_cell_foreach_range): Change traversal order
for ranges.
* src/func.c (function_iterate_do_value): Fix traversal order for
arrays.
2000-07-07 Morten Welinder <terra@diku.dk>
* src/functions/fn-math.c (gnumeric_sumproduct): Rewrite with lots
......
2000-07-08 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_cell_foreach_range): Change traversal order
for ranges.
* src/func.c (function_iterate_do_value): Fix traversal order for
arrays.
2000-07-07 Morten Welinder <terra@diku.dk>
* src/functions/fn-math.c (gnumeric_sumproduct): Rewrite with lots
......
......@@ -286,6 +286,11 @@ clipboard_copy_range (Sheet *sheet, Range const *r)
c->cols = r->end.col - r->start.col + 1;
c->rows = r->end.row - r->start.row + 1;
/*
* We assume that the cells are traversed somehow starting at
* the upper left corner. We don't depend on whether it is
* row-major or col-major.
*/
sheet_cell_foreach_range ( sheet, TRUE,
r->start.col, r->start.row,
r->end.col, r->end.row,
......
......@@ -649,9 +649,10 @@ function_iterate_do_value (EvalPos const *ep,
case VALUE_ARRAY:
{
int x, y;
for (x = 0; x < value->v_array.x; x++) {
for (y = 0; y < value->v_array.y; y++) {
/* Note the order here. */
for (y = 0; y < value->v_array.y; y++) {
for (x = 0; x < value->v_array.x; x++) {
res = function_iterate_do_value (
ep, callback, closure,
value->v_array.vals [x][y],
......
......@@ -1762,6 +1762,16 @@ sheet_row_fetch (Sheet *sheet, int pos)
* Return value:
* non-NULL on error, or value_terminate() if some invoked routine requested
* to stop (by returning non-NULL).
*
* NOTE: between 0.56 and 0.57, the traversal order changed. The order is now
*
* 1 2 3
* 4 5 6
* 7 8 9
*
* (This appears to be the order in which XL looks at the values of ranges.)
* If your code depends on any particular ordering, please add a very visible
* comment near the call.
*/
Value *
sheet_cell_foreach_range (Sheet *sheet, gboolean only_existing,
......@@ -1790,21 +1800,21 @@ sheet_cell_foreach_range (Sheet *sheet, gboolean only_existing,
end_row = sheet->rows.max_used;
}
for (i = start_col; i <= end_col ; ++i) {
ColRowInfo *ci = sheet_col_get (sheet, i);
for (i = start_row; i <= end_row; ++i) {
ColRowInfo *ci = sheet_row_get (sheet, i);
if (ci == NULL) {
if (only_existing) {
/* skip segments with no cells */
if (i == COLROW_SEGMENT_START (i)) {
ColRowInfo const * const * const segment =
COLROW_GET_SEGMENT(&(sheet->cols), i);
COLROW_GET_SEGMENT(&(sheet->rows), i);
if (segment == NULL)
i = COLROW_SEGMENT_END(i);
}
} else {
for (j = start_row; j <= end_row ; ++j) {
cont = (*callback)(sheet, i, j, NULL, closure);
for (j = start_col; j <= end_col; ++j) {
cont = (*callback)(sheet, j, i, NULL, closure);
if (cont != NULL)
return cont;
}
......@@ -1813,25 +1823,25 @@ sheet_cell_foreach_range (Sheet *sheet, gboolean only_existing,
continue;
}
for (j = start_row; j <= end_row ; ++j) {
ColRowInfo *ri = sheet_row_get (sheet, j);
for (j = start_col; j <= end_col; ++j) {
ColRowInfo *ri = sheet_col_get (sheet, j);
Cell *cell = NULL;
if (ri != NULL)
cell = sheet_cell_get (sheet, i, j);
cell = sheet_cell_get (sheet, j, i);
if (cell == NULL && only_existing) {
/* skip segments with no cells */
if (j == COLROW_SEGMENT_START (j)) {
ColRowInfo const * const * const segment =
COLROW_GET_SEGMENT(&(sheet->rows), j);
COLROW_GET_SEGMENT(&(sheet->cols), j);
if (segment == NULL)
j = COLROW_SEGMENT_END(j);
}
continue;
}
cont = (*callback)(sheet, i, j, cell, closure);
cont = (*callback)(sheet, j, i, cell, closure);
if (cont != NULL)
return cont;
}
......
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