[gnumeric] ColRow: don't remove colrow entries used by cells.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ColRow: don't remove colrow entries used by cells.
- Date: Sat, 7 May 2011 18:36:08 +0000 (UTC)
commit 6469a8789c8b909051231d210d230fca212e7db8
Author: Morten Welinder <terra gnome org>
Date: Sat May 7 14:35:32 2011 -0400
ColRow: don't remove colrow entries used by cells.
ChangeLog | 5 +++++
src/sheet.c | 28 ++++++++++++++++++++++------
2 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 675e6af..1b01d16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-07 Morten Welinder <terra gnome org>
+
+ * src/sheet.c (sheet_colrow_optimize1): Take sheet extent into
+ account.
+
2011-05-06 Morten Welinder <terra gnome org>
* src/sheet.c (sheet_colrow_optimize): New function.
diff --git a/src/sheet.c b/src/sheet.c
index b91627c..c286acf 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -3420,11 +3420,14 @@ sheet_colrow_get_default (Sheet const *sheet, gboolean is_cols)
}
static void
-sheet_colrow_optimize1 (int max, ColRowCollection *collection)
+sheet_colrow_optimize1 (int max, int max_used, ColRowCollection *collection)
{
int i;
+ int first_unused = max_used + 1;
- for (i = 0; i < max; i += COLROW_SEGMENT_SIZE) {
+ for (i = COLROW_SEGMENT_START (first_unused);
+ i < max;
+ i += COLROW_SEGMENT_SIZE) {
ColRowSegment *segment = COLROW_GET_SEGMENT (collection, i);
int j;
gboolean any = FALSE;
@@ -3435,11 +3438,14 @@ sheet_colrow_optimize1 (int max, ColRowCollection *collection)
ColRowInfo *info = segment->info[j];
if (!info)
continue;
- if (colrow_equal (&collection->default_style, info)) {
+ if (i + j >= first_unused &&
+ colrow_equal (&collection->default_style, info)) {
colrow_free (info);
segment->info[j] = NULL;
- } else
+ } else {
any = TRUE;
+ max_used = i + j;
+ }
}
if (!any) {
@@ -3447,15 +3453,25 @@ sheet_colrow_optimize1 (int max, ColRowCollection *collection)
COLROW_GET_SEGMENT (collection, i) = NULL;
}
}
+
+ collection->max_used = max_used;
}
void
sheet_colrow_optimize (Sheet *sheet)
{
+ GnmRange extent;
+
g_return_if_fail (IS_SHEET (sheet));
- sheet_colrow_optimize1 (gnm_sheet_get_max_cols (sheet), &sheet->cols);
- sheet_colrow_optimize1 (gnm_sheet_get_max_rows (sheet), &sheet->rows);
+ extent = sheet_get_extent (sheet, TRUE);
+
+ sheet_colrow_optimize1 (gnm_sheet_get_max_cols (sheet),
+ extent.end.col,
+ &sheet->cols);
+ sheet_colrow_optimize1 (gnm_sheet_get_max_rows (sheet),
+ extent.end.row,
+ &sheet->rows);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]