Commit 952d5246 authored by Morten Welinder's avatar Morten Welinder
Browse files

xlsx: fix reading/writing of number format 14.

It's locale dependent, despite what the spec says.  That's a dumb idea,
but it is not our dumb idea.
parent ec3eca79
......@@ -3,6 +3,7 @@ Gnumeric 1.12.53
Morten:
* Fix xlsx import of T.INV.
* Fix inter-process array paste problem. [#634]
* Fix problem with xlsx number format 14.
--------------------------------------------------------------------------
Gnumeric 1.12.52
......
2022-05-22 Morten Welinder <terra@gnome.org>
* xlsx-read.c (xlsx_get_num_fmt): Format 14 is locale dependent.
* xlsx-write.c (xlsx_load_buildin_num_formats): Ditto.
2022-04-18 Morten Welinder <terra@gnome.org>
* Release 1.12.52
......
......@@ -1059,7 +1059,7 @@ xlsx_get_num_fmt (GsfXMLIn *xin, char const *id)
/* 11 */ "0.00E+00",
/* 12 */ "# ?/?",
/* 13 */ "# ?""?/?""?", /* silly trick to avoid using a trigraph */
/* 14 */ "mm-dd-yy",
/* 14 */ NULL, // Locale version of "mm-dd-yy"
/* 15 */ "d-mmm-yy",
/* 16 */ "d-mmm",
/* 17 */ "mmm-yy",
......@@ -1172,13 +1172,20 @@ xlsx_get_num_fmt (GsfXMLIn *xin, char const *id)
/* builtins */
i = strtol (id, &end, 10);
if (end != id && *end == '\0' &&
i >= 0 && i < (int) G_N_ELEMENTS (std_builtins) &&
std_builtins[i] != NULL) {
if (end == id || *end != 0 || i < 0 || i >= (int) G_N_ELEMENTS (std_builtins))
i = -1;
if (i >= 0 && std_builtins[i] != NULL) {
res = go_format_new_from_XL (std_builtins[i]);
g_hash_table_replace (state->num_fmts, g_strdup (id), res);
} else if (i == 14) {
// Format 14 is locale dependent. ms-excel-read.c suggests that maybe
// 15 should be too, but I cannot verify that anywhere.
res = go_format_new_magic (GO_FORMAT_MAGIC_SHORT_DATE);
g_hash_table_replace (state->num_fmts, g_strdup (id), res);
} else
xlsx_warning (xin, _("Undefined number format id '%s'"), id);
return res;
}
......
......@@ -548,7 +548,7 @@ xlsx_load_buildin_num_formats (GHashTable *hash)
/* 11 */ "0.00E+00",
/* 12 */ "# ?/?",
/* 13 */ "# ?""?/?""?", /* silly trick to avoid using a trigraph */
/* 14 */ "mm-dd-yy",
/* 14 */ NULL, // Locale version of "mm-dd-yy"
/* 15 */ "d-mmm-yy",
/* 16 */ "d-mmm",
/* 17 */ "mmm-yy",
......@@ -586,12 +586,20 @@ xlsx_load_buildin_num_formats (GHashTable *hash)
/* 49 */ "@"
};
unsigned int i;
GOFormat const *fmt;
g_return_if_fail (NUM_FORMAT_BASE > (int) G_N_ELEMENTS (std_builtins));
for (i = 1; i < G_N_ELEMENTS (std_builtins); i++)
if (std_builtins[i] != NULL)
g_hash_table_insert (hash, g_strdup (std_builtins[i]), GUINT_TO_POINTER (i));
// Format 14 is locale dependent. ms-excel-read.c suggests that maybe
// 15 should be too, but I cannot verify that anywhere.
fmt = go_format_new_magic (GO_FORMAT_MAGIC_SHORT_DATE);
g_hash_table_insert (hash, g_strdup (go_format_as_XL (fmt)),
GUINT_TO_POINTER (14));
go_format_unref (fmt);
}
static void
......
Supports Markdown
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