gnumeric r17004 - trunk/plugins/excel
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17004 - trunk/plugins/excel
- Date: Fri, 12 Dec 2008 21:27:38 +0000 (UTC)
Author: mortenw
Date: Fri Dec 12 21:27:38 2008
New Revision: 17004
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17004&view=rev
Log:
2008-12-12 Morten Welinder <terra gnome org>
* ms-excel-util.c (two_way_table_move): Make sure we keep
unique_keys correct. See #564078.
Modified:
trunk/plugins/excel/ChangeLog
trunk/plugins/excel/ms-excel-util.c
trunk/plugins/excel/ms-excel-write.c
Modified: trunk/plugins/excel/ms-excel-util.c
==============================================================================
--- trunk/plugins/excel/ms-excel-util.c (original)
+++ trunk/plugins/excel/ms-excel-util.c Fri Dec 12 21:27:38 2008
@@ -92,6 +92,27 @@
g_free (table);
}
+static void
+two_way_table_dump (const TwoWayTable *table)
+{
+ size_t ui;
+
+ g_printerr ("Table at %p has "
+ "unique_keys.size=%d; "
+ "all_keys.size=%d; "
+ "idx_to_key.size=%d\n",
+ table,
+ g_hash_table_size (table->unique_keys),
+ g_hash_table_size (table->all_keys),
+ table->idx_to_key->len);
+
+ for (ui = 0; ui < table->idx_to_key->len; ui++) {
+ gpointer key = g_ptr_array_index (table->idx_to_key, ui);
+ g_printerr ("%p => %d %d\n", key, (int)ui,
+ two_way_table_key_to_idx (table, key));
+ }
+}
+
/**
* two_way_table_put
* @table Table
@@ -139,6 +160,8 @@
if (apf)
apf (key, addit, index, closure);
+ if (0) two_way_table_dump (table);
+
return index;
}
@@ -155,6 +178,7 @@
two_way_table_move (TwoWayTable const *table, gint dst_idx, gint src_idx)
{
gpointer key_to_forget, key_to_move;
+ size_t ui;
key_to_forget = two_way_table_idx_to_key (table, dst_idx);
key_to_move = two_way_table_idx_to_key (table, src_idx);
@@ -167,11 +191,26 @@
dst_idx += table->base;
src_idx += table->base;
g_hash_table_insert (table->all_keys, key_to_move,
- GINT_TO_POINTER (dst_idx + table->base + 1));
+ GINT_TO_POINTER (dst_idx + table->base + 1));
g_hash_table_insert (table->unique_keys, key_to_move,
- GINT_TO_POINTER (dst_idx + table->base + 1));
- g_ptr_array_index (table->idx_to_key, dst_idx) = key_to_move;
- g_ptr_array_index (table->idx_to_key, src_idx) = (gpointer)0xdeadbeef; /* poison */
+ GINT_TO_POINTER (dst_idx + table->base + 1));
+ g_ptr_array_index (table->idx_to_key, dst_idx) = key_to_move;
+
+ if (table->idx_to_key->len - 1 == (size_t)src_idx)
+ g_ptr_array_set_size (table->idx_to_key, src_idx);
+ else
+ g_ptr_array_index (table->idx_to_key, src_idx) =
+ (gpointer)0xdeadbeef; /* poison */
+
+ for (ui = 0; ui < table->idx_to_key->len; ui++) {
+ if (g_ptr_array_index (table->idx_to_key, ui) == key_to_forget) {
+ g_hash_table_insert (table->unique_keys, key_to_forget,
+ GINT_TO_POINTER (ui + 1));
+ break;
+ }
+ }
+
+ if (0) two_way_table_dump (table);
}
/**
Modified: trunk/plugins/excel/ms-excel-write.c
==============================================================================
--- trunk/plugins/excel/ms-excel-write.c (original)
+++ trunk/plugins/excel/ms-excel-write.c Fri Dec 12 21:27:38 2008
@@ -1842,9 +1842,9 @@
for (j = upper_limit - 1; j > 1; j--) {
if (!xle->pal.entry_in_use[j]) {
/* Replace table entry with color. */
- d (2, fprintf (stderr, "Custom color %d (0x%x)"
- " moved to unused index %d\n",
- i, color, j););
+ d (2, g_printerr ("Custom color %d (0x%x)"
+ " moved to unused index %d\n",
+ i, color, j););
two_way_table_move (twt, j, i);
upper_limit = j;
xle->pal.entry_in_use[j] = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]