[gnumeric] sheet-style: fix problems with width/height in foreach_tile users.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] sheet-style: fix problems with width/height in foreach_tile users.
- Date: Mon, 12 Mar 2012 15:38:11 +0000 (UTC)
commit 80fac7d8a440bc5a9c718a5be005fb17403d2739
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 12 11:36:26 2012 -0400
sheet-style: fix problems with width/height in foreach_tile users.
width and height refer to tile size. They may extend beyond the
range being iterated over and even beyond the sheet.
ChangeLog | 5 +++++
src/sheet-style.c | 20 +++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 208f386..ee2017c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-12 Morten Welinder <terra gnome org>
+
+ * src/sheet-style.c (cb_style_extent, cb_is_default)
+ (cb_most_common): Fix handling of width and height.
+
2012-03-11 Morten Welinder <terra gnome org>
* src/print-info.c (print_info_get_paper_size): New function.
diff --git a/src/sheet-style.c b/src/sheet-style.c
index 25e5f41..2d0e6b5 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -975,6 +975,11 @@ try_optimize:
}
}
+/* Handler for foreach_tile.
+ *
+ * "width" and "height" refer to tile size which may extend beyond
+ * the range supplied to foreach_tile and even beyond the sheet.
+ */
typedef void (*ForeachTileFunc) (GnmStyle *style,
int corner_col, int corner_row, int width, int height,
GnmRange const *apply_to, gpointer user);
@@ -1931,7 +1936,13 @@ cb_style_extent (GnmStyle *style,
{
GnmRange *res = user;
if (gnm_style_visible_in_blank (style)) {
- int tmp = corner_col+width-1;
+ int tmp;
+
+ /* The given dimensions refer to the tile, not the area. */
+ width = MIN (width, apply_to->end.col - corner_col + 1);
+ height = MIN (height, apply_to->end.row - corner_row + 1);
+
+ tmp = corner_col+width-1;
if (res->end.col < tmp)
res->end.col = tmp;
if (res->start.col > corner_col)
@@ -2022,6 +2033,9 @@ cb_is_default (GnmStyle *style,
struct cb_is_default *user = user_;
int i;
+ /* The given "width" refers to the tile, not the area. */
+ width = MIN (width, apply_to->end.col - corner_col + 1);
+
for (i = 0; user->res && i < width; i++) {
if (style != user->col_defaults[corner_col + i])
user->res = FALSE;
@@ -2063,6 +2077,10 @@ cb_most_common (GnmStyle *style,
g_hash_table_insert (cmc->h, style, counts);
}
+ /* The given dimensions refer to the tile, not the area. */
+ width = MIN (width, apply_to->end.col - corner_col + 1);
+ height = MIN (height, apply_to->end.row - corner_row + 1);
+
if (cmc->is_col)
for (i = 0; i < width; i++)
counts[corner_col + i] += height;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]