[gnumeric] Fixup the dependent container on sheet resize.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Fixup the dependent container on sheet resize.
- Date: Wed, 22 Apr 2009 09:06:50 -0400 (EDT)
commit 639c98276bb65fe49c88b6df2ca17d677c14d9f3
Author: Morten Welinder <terra gnome org>
Date: Wed Apr 22 09:06:14 2009 -0400
Fixup the dependent container on sheet resize.
---
ChangeLog | 5 +++++
src/dependent.c | 25 ++++++++++++++++++++++++-
src/dependent.h | 1 +
src/dialogs/dialog-sheet-resize.c | 3 ++-
src/sheet.c | 28 +++++++++++++++++++++++++++-
5 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2b3474c..37bbaf8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-22 Morten Welinder <terra gnome org>
+
+ * src/sheet.c (gnm_sheet_resize_main): Change container size too.
+ Unlink, re-link, and recalculate all dependencies.
+
2009-04-21 Morten Welinder <terra gnome org>
* src/dependent.c (gnm_dep_container_new): Calculate the number of
diff --git a/src/dependent.c b/src/dependent.c
index 758a8b4..43282a2 100644
--- a/src/dependent.c
+++ b/src/dependent.c
@@ -2574,7 +2574,7 @@ dependents_revive_sheet (Sheet *sheet)
void
workbook_queue_all_recalc (Workbook *wb)
{
- /* FIXME: what about dependents in other workbooks */
+ /* FIXME: what about dependents in other workbooks? */
WORKBOOK_FOREACH_DEPENDENT (wb, dep, dependent_flag_recalc (dep););
}
@@ -2686,6 +2686,29 @@ gnm_dep_container_new (Sheet *sheet)
return deps;
}
+void
+gnm_dep_container_resize (GnmDepContainer *deps, int rows)
+{
+ int i, buckets = 1 + BUCKET_OF_ROW (rows - 1);
+
+ for (i = buckets; i < deps->buckets; i++) {
+ GHashTable *hash = deps->range_hash[i];
+ if (hash != NULL) {
+ g_printerr ("Hash table size: %d\n",
+ g_hash_table_size (hash));
+ g_hash_table_destroy (hash);
+ deps->range_hash[i] = NULL;
+ }
+ }
+
+ deps->range_hash = g_renew (GHashTable *, deps->range_hash, buckets);
+
+ for (i = deps->buckets; i < buckets; i++)
+ deps->range_hash[i] = NULL;
+
+ deps->buckets = buckets;
+}
+
/****************************************************************************
* Debug utils
*/
diff --git a/src/dependent.h b/src/dependent.h
index 80f90ea..461378d 100644
--- a/src/dependent.h
+++ b/src/dependent.h
@@ -111,6 +111,7 @@ GnmDepContainer *gnm_dep_container_new (Sheet *sheet);
void gnm_dep_container_dump (GnmDepContainer const *deps,
Sheet *sheet);
void gnm_dep_container_sanity_check (GnmDepContainer const *deps);
+void gnm_dep_container_resize (GnmDepContainer *deps, int rows);
#define DEPENDENT_CONTAINER_FOREACH_DEPENDENT(dc, dep, code) \
do { \
diff --git a/src/dialogs/dialog-sheet-resize.c b/src/dialogs/dialog-sheet-resize.c
index 285dc71..1cc6bbb 100644
--- a/src/dialogs/dialog-sheet-resize.c
+++ b/src/dialogs/dialog-sheet-resize.c
@@ -136,7 +136,8 @@ cb_ok_clicked (ResizeState *state)
g_list_free (sheets);
if (changed_sheets)
- cmd_resize_sheets (wbc, changed_sheets, cols, rows);
+ cmd_resize_sheets (wbc, g_slist_reverse (changed_sheets),
+ cols, rows);
gtk_widget_destroy (state->dialog);
}
diff --git a/src/sheet.c b/src/sheet.c
index 4e10624..c0e8e9c 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -1123,7 +1123,6 @@ gnm_sheet_resize_main (Sheet *sheet, int cols, int rows,
if (pundo)
*pundo = go_undo_combine (*pundo, u);
}
- colrow_resize (&sheet->cols, cols);
if (rows < old_rows) {
GOUndo *u = NULL;
@@ -1135,8 +1134,35 @@ gnm_sheet_resize_main (Sheet *sheet, int cols, int rows,
if (pundo)
*pundo = go_undo_combine (*pundo, u);
}
+
+ /* ---------------------------------------- */
+
+ colrow_resize (&sheet->cols, cols);
colrow_resize (&sheet->rows, rows);
+ {
+ GSList *l, *linked = NULL;
+ /* FIXME: what about dependents in other workbooks? */
+ WORKBOOK_FOREACH_DEPENDENT
+ (sheet->workbook, dep,
+
+ if (dependent_is_linked (dep)) {
+ dependent_unlink (dep);
+ linked = g_slist_prepend (linked, dep);
+ });
+
+ gnm_dep_container_resize (sheet->deps, rows);
+
+ for (l = linked; l; l = l->next) {
+ GnmDependent *dep = l->data;
+ dependent_link (dep);
+ }
+
+ g_slist_free (linked);
+
+ workbook_queue_all_recalc (sheet->workbook);
+ }
+
/* ---------------------------------------- */
/* Actually change the properties. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]