Commit 36f996ae authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Sort style regions so hash order does not matter.

2006-11-23  Morten Welinder  <terra@gnome.org>

	* src/xml-sax-write.c (xml_write_styles): Sort style regions so
	hash order does not matter.
	(xml_write_named_expressions): Sort names to hash order does not
	matter.

	* src/expr-name.c (gnm_named_expr_collection_list): New function.
parent 43161d09
2006-11-23 Morten Welinder <terra@gnome.org>
* src/xml-sax-write.c (xml_write_styles): Sort style regions so
hash order does not matter.
(xml_write_named_expressions): Sort names to hash order does not
matter.
* src/expr-name.c (gnm_named_expr_collection_list): New function.
2006-11-22 Jon K Hellan <hellan@acm.org>
* src/gnumeric-gconf.c (gnm_gconf_set_gui_zoom): Fix typo that
......
......@@ -121,6 +121,7 @@ src/widgets/gnumeric-cell-renderer-expr-entry.c
src/widgets/gnumeric-cell-renderer-text.c
src/widgets/gnumeric-cell-renderer-toggle.c
src/widgets/gnumeric-expr-entry.c
src/widgets/gnm-filter-combo.c
src/widgets/widget-font-selector.c
src/application.c
src/cell.c
......
No preview for this file type
......@@ -172,6 +172,27 @@ gnm_named_expr_collection_lookup (GnmNamedExprCollection const *scope,
return NULL;
}
static void
cb_list_names (G_GNUC_UNUSED gpointer key,
gpointer value,
gpointer user_data)
{
GSList **pres = user_data;
GO_SLIST_PREPEND (*pres, value);
}
GSList *
gnm_named_expr_collection_list (GnmNamedExprCollection const *scope)
{
GSList *res = NULL;
if (scope && scope->names) {
g_hash_table_foreach (scope->names,
cb_list_names,
&res);
}
return res;
}
static void
gnm_named_expr_collection_insert (GnmNamedExprCollection const *scope,
GnmNamedExpr *nexpr)
......
......@@ -47,6 +47,7 @@ void expr_name_downgrade_to_placeholder (GnmNamedExpr *nexpr);
int expr_name_cmp_by_name (GnmNamedExpr const *a, GnmNamedExpr const *b);
gboolean expr_name_check_for_loop (char const *name, GnmExprTop const *texpr);
GSList *gnm_named_expr_collection_list (GnmNamedExprCollection const *scope);
GList *sheet_names_get_available (Sheet const *sheet);
char const *sheet_names_check (Sheet const *sheet, GnmRange const *r);
......
......@@ -166,7 +166,7 @@ xml_write_sheet_names (GnmOutputXML *state)
}
static void
cb_xml_write_name (gpointer key, GnmNamedExpr *nexpr, GnmOutputXML *state)
xml_write_name (GnmOutputXML *state, GnmNamedExpr *nexpr)
{
char *expr_str;
......@@ -187,10 +187,18 @@ static void
xml_write_named_expressions (GnmOutputXML *state, GnmNamedExprCollection *scope)
{
if (scope != NULL) {
GSList *names =
g_slist_sort (gnm_named_expr_collection_list (scope),
(GCompareFunc)expr_name_cmp_by_name);
GSList *p;
gsf_xml_out_start_element (state->output, GNM "Names");
g_hash_table_foreach (scope->names,
(GHFunc) cb_xml_write_name, state);
for (p = names; p; p = p->next) {
GnmNamedExpr *nexpr = p->data;
xml_write_name (state, nexpr);
}
gsf_xml_out_end_element (state->output); /* </gnm:Names> */
g_slist_free (names);
}
}
......@@ -537,16 +545,35 @@ xml_write_style_region (GnmOutputXML *state, GnmStyleRegion const *region)
gsf_xml_out_end_element (state->output);
}
static int
cb_sheet_style_order (GnmStyleRegion const *a, GnmStyleRegion const *b)
{
GnmRange const *ra = &a->range;
GnmRange const *rb = &b->range;
int res;
res = ra->start.col - rb->start.col;
if (res == 0)
res = ra->start.row - rb->start.row;
return res;
}
static void
xml_write_styles (GnmOutputXML *state)
{
GnmStyleList *ptr, *styles = sheet_style_get_list (state->sheet, NULL);
GnmStyleList *styles =
g_slist_sort (sheet_style_get_list (state->sheet, NULL),
(GCompareFunc)cb_sheet_style_order);
if (styles != NULL) {
GnmStyleList *ptr;
gsf_xml_out_start_element (state->output, GNM "Styles");
for (ptr = styles; ptr; ptr = ptr->next)
xml_write_style_region (state, ptr->data);
style_list_free (styles);
gsf_xml_out_end_element (state->output);
style_list_free (styles);
}
}
......
......@@ -14,15 +14,10 @@
TESTS = $(wildcard t[0-9][0-9][0-9][0-9]-*.pl)
testsuite: $(TESTS)
import-db:
for t in t5[0-9][0-9][0-9]-*.pl; do echo "*** $$t ***"; $(PERL) $$t create-db; done
$(TESTS):
@echo "*** $@ ***" && $(PERL) $@
EXTRA_DIST = GnumericTest.pm normalize-gnumeric $(TESTS)
.PHONY: testsuite importdb $(TESTS) clean
.PHONY: import-db $(TESTS)
.NOTPARALLEL:
......@@ -24,7 +24,7 @@ while (<STDIN>) {
}
# Sort names.
if (m|^\s*<gnm:Sheets>\s*$| .. m|^\s*</gnm:Sheets>\s*$|) {
if (0 && m|^\s*<gnm:Sheets>\s*$| .. m|^\s*</gnm:Sheets>\s*$|) {
if (m|^\s*<gnm:Names>\s*$| .. m|^\s*</gnm:Names>\s*$|) {
if (m|^\s*<gnm:Names>\s*$|) {
# Zip.
......
......@@ -8,5 +8,5 @@ use GnumericTest;
# See test_importer comments for mode definitions.
my $mode = ((shift @ARGV) || "check");
&test_importer ("$samples/sc/demo_func", "51068c9f192b82b45ac1619f616794c17029b842", $mode);
&test_importer ("$samples/sc/demo_math", "d746da48c1d7d1e7540a95650edb53aa6c0ca066", $mode);
&test_importer ("$samples/sc/demo_func", "82e84c6e21c4aa3e70d9e05eb5d4d08ca1de810f", $mode);
&test_importer ("$samples/sc/demo_math", "8faad9c99be6a3202cfc5e1ebd77700b2a3264f1", $mode);
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