[gnumeric] xlsx: improve export of comments.



commit 165165fda2ca0e463feeea20e0ab82f667620848
Author: Morten Welinder <terra gnome org>
Date:   Wed Apr 15 08:22:32 2015 -0400

    xlsx: improve export of comments.

 plugins/excel/ChangeLog             |    3 +++
 plugins/excel/xlsx-write.c          |   11 ++++++++++-
 samples/cell-comment-tests.gnumeric |  Bin 3351 -> 3420 bytes
 3 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index aaa56d8..5433d29 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,5 +1,8 @@
 2015-04-15  Morten Welinder  <terra gnome org>
 
+       * xlsx-write.c (xlsx_write_comments): Write comment authors in
+       deterministic order.
+
        * ms-excel-util.c (xls_collect_validations): Rename from
        excel_collect_validations and move from ms-excel-write.c.
        Sort ranges.
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 8cef02f..9cfc3e8 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -2670,6 +2670,14 @@ xlsx_write_print_info (XLSXWriteState *state, GsfXMLOut *xml)
 
 /**********************************************************************/
 
+static int
+by_key_str (gpointer key_a, G_GNUC_UNUSED gpointer val_a,
+           gpointer key_b, G_GNUC_UNUSED gpointer val_b,
+           G_GNUC_UNUSED gpointer user)
+{
+       return strcmp (key_a, key_b);
+}
+
 static void
 write_comment_author (gpointer key, G_GNUC_UNUSED gpointer value, GsfXMLOut *xml)
 {
@@ -2707,7 +2715,8 @@ xlsx_write_comments (XLSXWriteState *state, GsfOutput *sheet_part, GSList *objec
        }
        /* save authors */
        gsf_xml_out_start_element (xml, "authors");
-       g_hash_table_foreach (authors, (GHFunc) write_comment_author, xml);
+       gnm_hash_table_foreach_ordered (authors, (GHFunc) write_comment_author,
+                                       by_key_str, xml);
        gsf_xml_out_end_element (xml); /* </authors> */
        /* save comments */
        gsf_xml_out_start_element (xml, "commentList");
diff --git a/samples/cell-comment-tests.gnumeric b/samples/cell-comment-tests.gnumeric
index 9bae349..3fbefcc 100644
Binary files a/samples/cell-comment-tests.gnumeric and b/samples/cell-comment-tests.gnumeric differ


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]