[gnumeric] xlsx: ignore bogus Print_Area "!#REF!"
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: ignore bogus Print_Area "!#REF!"
- Date: Wed, 11 Oct 2017 15:51:33 +0000 (UTC)
commit 90fb7e8383bf0af908a5f30478c1aa63888ad002
Author: Morten Welinder <terra gnome org>
Date: Wed Oct 11 11:50:54 2017 -0400
xlsx: ignore bogus Print_Area "!#REF!"
NEWS | 1 +
plugins/excel/ChangeLog | 4 ++++
plugins/excel/xlsx-read.c | 30 +++++++++++++++++++++---------
3 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6f082f9..93af873 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Morten:
* Convert all xpm files to png.
* Avoid to-pixdata options for resources. It's going away.
* Minor CORREL improvement.
+ * Fix error on xlsx files with bogus Print_Area.
--------------------------------------------------------------------------
Gnumeric 1.12.35
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index c265796..88ebb66 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-11 Morten Welinder <terra gnome org>
+
+ * xlsx-read.c (xlsx_wb_name_end): Ignore bogus Print_Area names.
+
2017-07-06 Morten Welinder <terra gnome org>
* Release 1.12.35
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 2e3cc66..91c3da6 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -3740,31 +3740,43 @@ xlsx_wb_name_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
Sheet *sheet = state->defined_name_sheet;
GnmNamedExpr *nexpr;
char *error_msg = NULL;
+ const char *thename = state->defined_name;
+ const char *thevalue = xin->content->str;
+ gboolean bogus = FALSE;
- g_return_if_fail (state->defined_name != NULL);
+ g_return_if_fail (thename != NULL);
parse_pos_init (&pp, state->wb, sheet, 0, 0);
- if (g_str_has_prefix (state->defined_name, "_xlnm.")) {
- gboolean editable = (0 == strcmp (state->defined_name + 6, "Sheet_Title"));
- nexpr = expr_name_add (&pp, state->defined_name + 6,
- gnm_expr_top_new_constant (value_new_empty ()),
- &error_msg, TRUE, NULL);
+ if (g_str_has_prefix (thename, "_xlnm.")) {
+ gboolean editable;
+
+ thename += 6;
+ editable = g_str_equal (thename, "Sheet_Title");
+ bogus = g_str_equal (thename, "Print_Area") &&
+ g_str_equal (thevalue, "!#REF!");
+ nexpr = bogus
+ ? NULL
+ : expr_name_add (&pp, thename,
+ gnm_expr_top_new_constant (value_new_empty ()),
+ &error_msg, TRUE, NULL);
if (nexpr) {
nexpr->is_permanent = TRUE;
nexpr->is_editable = editable;
}
} else
- nexpr = expr_name_add (&pp, state->defined_name,
+ nexpr = expr_name_add (&pp, thename,
gnm_expr_top_new_constant (value_new_empty ()),
&error_msg, TRUE, NULL);
- if (nexpr) {
+ if (bogus) {
+ /* Silently ignore */
+ } else if (nexpr) {
state->delayed_names =
g_list_prepend (state->delayed_names, sheet);
state->delayed_names =
g_list_prepend (state->delayed_names,
- g_strdup (xin->content->str));
+ g_strdup (thevalue));
state->delayed_names =
g_list_prepend (state->delayed_names, nexpr);
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]