Commit df5819e6 authored by Morten Welinder's avatar Morten Welinder

Tabulation: fix sheet range limitation.

parent 3b50c06a
...@@ -9,6 +9,7 @@ Morten: ...@@ -9,6 +9,7 @@ Morten:
* Improve accuracy of BESSELJ and BESSELY. * Improve accuracy of BESSELJ and BESSELY.
* New functions: IMGAMMA, IMFACT. * New functions: IMGAMMA, IMFACT.
* Avoid some overflows in IMGAMMA. * Avoid some overflows in IMGAMMA.
* Fix tabulation truncation issue.
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Gnumeric 1.12.9 Gnumeric 1.12.9
......
2013-12-10 Morten Welinder <terra@gnome.org>
* tabulate.c (do_tabulation): Fix cut-off when we go off sheet.
(Row-vs-column confusion combined with failing to take header into
account.)
2013-11-28 Morten Welinder <terra@gnome.org> 2013-11-28 Morten Welinder <terra@gnome.org>
* Release 1.12.9 * Release 1.12.9
......
...@@ -94,21 +94,33 @@ do_tabulation (WorkbookControl *wbc, ...@@ -94,21 +94,33 @@ do_tabulation (WorkbookControl *wbc,
GOFormat const **formats = g_new (GOFormat const *, data->dims); GOFormat const **formats = g_new (GOFormat const *, data->dims);
GnmValue **old_values = g_new (GnmValue *, data->dims); GnmValue **old_values = g_new (GnmValue *, data->dims);
/* No real reason to limit to this. */
int cols = gnm_sheet_get_max_cols (old_sheet);
int rows = gnm_sheet_get_max_rows (old_sheet);
{ {
int i; int i;
for (i = 0; i < data->dims; i++) { for (i = 0; i < data->dims; i++) {
int max;
gnm_float full_count;
values[i] = data->minima[i]; values[i] = data->minima[i];
index[i] = 0; index[i] = 0;
formats[i] = my_get_format (data->cells[i]); formats[i] = my_get_format (data->cells[i]);
old_values[i] = value_dup (data->cells[i]->value); old_values[i] = value_dup (data->cells[i]->value);
counts[i] = 1 + gnm_fake_floor ((data->maxima[i] - data->minima[i]) / data->steps[i]);
/* Silently truncate at the edges. */ /* Silently truncate at the edges. */
if (!data->with_coordinates && i == 0 && counts[i] > gnm_sheet_get_last_col (old_sheet)) { full_count = 1 + gnm_fake_floor ((data->maxima[i] - data->minima[i]) / data->steps[i]);
counts[i] = gnm_sheet_get_last_col (old_sheet); if (data->with_coordinates) {
} else if (!data->with_coordinates && i == 1 && counts[i] > gnm_sheet_get_last_row (old_sheet)) { max = rows;
counts[i] = gnm_sheet_get_last_row (old_sheet); } else {
switch (i) {
case 0: max = rows - 1; break;
case 1: max = cols - 1; break;
default: max = 64 * 1024; break; /* Large number of sheets. */
}
} }
counts[i] = (int)CLAMP (full_count, 0, max);
} }
} }
...@@ -130,10 +142,7 @@ do_tabulation (WorkbookControl *wbc, ...@@ -130,10 +142,7 @@ do_tabulation (WorkbookControl *wbc,
g_free (base_name); g_free (base_name);
value_release (v); value_release (v);
sheet = sheets[i] = sheet = sheets[i] = sheet_new (wb, unique_name, cols, rows);
sheet_new (wb, unique_name,
gnm_sheet_get_max_cols (old_sheet),
gnm_sheet_get_max_rows (old_sheet));
g_free (unique_name); g_free (unique_name);
workbook_sheet_attach (wb, sheet); workbook_sheet_attach (wb, sheet);
sheet_idx = g_slist_prepend (sheet_idx, sheet_idx = g_slist_prepend (sheet_idx,
...@@ -146,9 +155,7 @@ do_tabulation (WorkbookControl *wbc, ...@@ -146,9 +155,7 @@ do_tabulation (WorkbookControl *wbc,
workbook_sheet_get_free_name (wb, workbook_sheet_get_free_name (wb,
_("Tabulation"), _("Tabulation"),
FALSE, FALSE); FALSE, FALSE);
sheet = sheet_new (wb, unique_name, sheet = sheet_new (wb, unique_name, cols, rows);
gnm_sheet_get_max_cols (old_sheet),
gnm_sheet_get_max_rows (old_sheet));
g_free (unique_name); g_free (unique_name);
workbook_sheet_attach (wb, sheet); workbook_sheet_attach (wb, sheet);
sheet_idx = g_slist_prepend (sheet_idx, sheet_idx = g_slist_prepend (sheet_idx,
......
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