Commit 404ae94b authored by Morten Welinder's avatar Morten Welinder

cellpos normalize: do full modulo operation

parent 8f2a8ecf
2015-07-09 Morten Welinder <terra@gnome.org>
* src/position.c (gnm_cellpos_init_cellref_ss): Do a full modulo
operation. Fixes #752124.
2015-07-06 Morten Welinder <terra@gnome.org>
* src/func-builtin.c (gnumeric_table): Avoid FMR. Fixes #752021.
......
......@@ -34,6 +34,7 @@ Morten:
[#751126] [#751254] [#751253] [#750851] [#751258] [#751259]
[#751502] [#751390] [#751579] [#751659] [#751660] [#751662]
[#751970] [#752022] [#751988] [#752021] [#752080] [#752081]
[#752124]
* Make solver check linearity of model.
* Fix xls saving of marker style. [#749185]
* Make compilation with clang work again. [#749138]
......
......@@ -434,6 +434,20 @@ gnm_cellref_get_row (GnmCellRef const *ref, GnmEvalPos const *ep)
return ref->row;
}
static int
modulo (int i, int max)
{
if (i < 0) {
i %= max;
if (i < 0)
i += max;
} else if (i >= max)
i %= max;
return i;
}
void
gnm_cellpos_init_cellref_ss (GnmCellPos *res, GnmCellRef const *cell_ref,
GnmCellPos const *pos, GnmSheetSize const *ss)
......@@ -443,23 +457,13 @@ gnm_cellpos_init_cellref_ss (GnmCellPos *res, GnmCellRef const *cell_ref,
if (cell_ref->col_relative) {
int col = cell_ref->col + pos->col;
int max = ss->max_cols;
if (col < 0)
col += max;
else if (col >= max)
col -= max;
res->col = col;
res->col = modulo (col, ss->max_cols);
} else
res->col = cell_ref->col;
if (cell_ref->row_relative) {
int row = cell_ref->row + pos->row;
int max = ss->max_rows;
if (row < 0)
row += max;
else if (row >= max)
row -= max;
res->row = row;
res->row = modulo (row, ss->max_rows);
} else
res->row = cell_ref->row;
}
......
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