Commit 3a74dd20 authored by Morten Welinder's avatar Morten Welinder

xlsx: make export more deterministic.

parent 00b92b17
2015-04-15 Morten Welinder <terra@gnome.org>
* src/ranges.c (gnm_range_compare): New function.
2015-04-13 Jean Brefort <jean.brefort@normalesup.org>
* src/wbc-gtk.c (set_entry_contents): format number whenever possible.
......
2015-04-15 Morten Welinder <terra@gnome.org>
* xlsx-write.c (xlsx_write_validations): Impose an ordering of
validation entries.
2015-04-13 Morten Welinder <terra@gnome.org>
* xlsx-read-drawing.c (xlsx_chart_pie_angle): Read firstSliceAng.
......
......@@ -2021,6 +2021,16 @@ xlsx_write_validation (XLValInputPair const *vip, G_GNUC_UNUSED gpointer dummy,
gsf_xml_out_end_element (info->xml); /* </dataValidation> */
}
static int
by_first_range (gpointer vip_a, G_GNUC_UNUSED gpointer val_a,
gpointer vip_b, G_GNUC_UNUSED gpointer val_b,
G_GNUC_UNUSED gpointer user)
{
const XLValInputPair *a = vip_a;
const XLValInputPair *b = vip_b;
return gnm_range_compare (a->ranges->data, b->ranges->data);
}
static void
xlsx_write_validations (XLSXWriteState *state, GsfXMLOut *xml, G_GNUC_UNUSED GnmRange const *extent)
{
......@@ -2035,7 +2045,10 @@ xlsx_write_validations (XLSXWriteState *state, GsfXMLOut *xml, G_GNUC_UNUSED Gnm
gsf_xml_out_start_element (xml, "dataValidations");
gsf_xml_out_add_int (xml, "count", g_hash_table_size (group)) ;
g_hash_table_foreach (group, (GHFunc) xlsx_write_validation, &info);
gnm_hash_table_foreach_ordered
(group, (GHFunc)xlsx_write_validation,
by_first_range,
&info);
gsf_xml_out_end_element (xml); /* </dataValidations> */
g_hash_table_destroy (group);
......
......@@ -784,6 +784,28 @@ gnm_range_equal (const GnmRange *a, const GnmRange *b)
return range_equal (a, b);
}
/**
* gnm_range_compare:
* @a: first range
* @b: second range
*
* Returns: a value that is negative if range @a comes before range @b;
* zero if the two ranges are equal; positive if range @a comes after
* range @b. The order imposed is lexicographical by starting row,
* then column, then ending row, then column.
*/
int
gnm_range_compare (GnmRange const *a, GnmRange const *b)
{
int i = 0;
if (!i) i = a->start.row - b->start.row;
if (!i) i = a->start.col - b->start.col;
if (!i) i = a->end.row - b->end.row;
if (!i) i = a->end.col - b->end.col;
return i;
}
GnmSheetRange *
gnm_sheet_range_new (Sheet *sheet, GnmRange const *r)
{
......
......@@ -24,6 +24,7 @@ G_BEGIN_DECLS
GType gnm_range_get_type (void); /* GBoxedType */
GnmRange *gnm_range_dup (GnmRange const *r);
gboolean gnm_range_equal (GnmRange const *a, GnmRange const *b);
int gnm_range_compare (GnmRange const *a, GnmRange const *b);
/**
* range_overlap:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment