[gnumeric] ods: fix some scoping issues with names.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ods: fix some scoping issues with names.
- Date: Mon, 6 Mar 2017 23:11:11 +0000 (UTC)
commit 6c8faab4fd87403d822947d130d0b69e7658a965
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 6 18:10:14 2017 -0500
ods: fix some scoping issues with names.
This ended up affecting hlink import.
plugins/openoffice/ChangeLog | 5 +++
plugins/openoffice/openoffice-read.c | 50 ++++++++++++---------------------
2 files changed, 23 insertions(+), 32 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index ebbffb6..0e7756c 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-06 Morten Welinder <terra gnome org>
+
+ * openoffice-read.c (oo_named_expr_common): Rename from
+ oo_named_expr and use for both preparse and parse.
+
2017-01-30 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_named_expr_preparse): we do need to define global expressions during
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 2d9dec1..0d72d79 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -482,7 +482,6 @@ struct _OOParseState {
int rep_cols_to;
} print;
- GSList *named_expression_names;
char *object_name; /* also used for table during preparsing */
OOControl *cur_control;
@@ -7727,7 +7726,7 @@ oo_style_prop (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
-oo_named_expr (GsfXMLIn *xin, xmlChar const **attrs)
+oo_named_expr_common (GsfXMLIn *xin, xmlChar const **attrs, gboolean preparse)
{
OOParseState *state = (OOParseState *)xin->user_state;
char const *name = NULL;
@@ -7748,6 +7747,10 @@ oo_named_expr (GsfXMLIn *xin, xmlChar const **attrs)
else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, "scope"))
scope = CXML2C (attrs[1]);
+ if (preparse) {
+ expr_str = "of:=#REF!";
+ base_str = NULL;
+ }
if (name != NULL && expr_str != NULL) {
GnmParsePos pp;
@@ -7804,6 +7807,12 @@ oo_named_expr (GsfXMLIn *xin, xmlChar const **attrs)
pp.sheet = state->pos.sheet;
if (pp.sheet == NULL && scope != NULL)
pp.sheet = workbook_sheet_by_name (pp.wb, scope);
+
+ if (preparse) {
+ gnm_expr_top_unref (texpr);
+ texpr = NULL;
+ }
+
expr_name_add (&pp, name, texpr, NULL,
TRUE, NULL);
}
@@ -7814,6 +7823,12 @@ oo_named_expr (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
+oo_named_expr (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ oo_named_expr_common (xin, attrs, FALSE);
+}
+
+static void
oo_db_range_start (GsfXMLIn *xin, xmlChar const **attrs)
{
OOParseState *state = (OOParseState *)xin->user_state;
@@ -11468,15 +11483,7 @@ oo_marker (GsfXMLIn *xin, xmlChar const **attrs)
static void
oo_named_expr_preparse (GsfXMLIn *xin, xmlChar const **attrs)
{
- OOParseState *state = (OOParseState *)xin->user_state;
- char const *name = NULL;
-
- for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
- if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "name"))
- name = CXML2C (attrs[1]);
-
- if (name != NULL)
- state->named_expression_names= g_slist_prepend (state->named_expression_names, g_strdup
(name));
+ oo_named_expr_common (xin, attrs, TRUE);
}
static void
@@ -11489,7 +11496,6 @@ odf_preparse_table_start (GsfXMLIn *xin, xmlChar const **attrs)
state->extent_data.col = 0;
state->extent_data.row = 0;
state->object_name = NULL;
- state->named_expression_names = NULL;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "name"))
@@ -11520,27 +11526,8 @@ odf_sheet_suggest_size (GsfXMLIn *xin, int *cols, int *rows)
}
static void
-odf_create_named_expressions (OOParseState *state, Sheet *sheet)
-{
- GSList *l;
- for (l = state->named_expression_names; l != NULL; l = l->next) {
- char *name = l->data;
- GnmParsePos pp;
-
- parse_pos_init (&pp, state->pos.wb, NULL, 0, 0);
- pp.sheet = sheet;
- expr_name_add (&pp, name, NULL, NULL, TRUE, NULL);
- }
-
- g_slist_free_full (state->named_expression_names, g_free);
- state->named_expression_names = NULL;
-}
-
-static void
odf_preparse_spreadsheet_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
{
- OOParseState *state = (OOParseState *)xin->user_state;
- odf_create_named_expressions (state, workbook_sheet_by_index (state->pos.wb, 0));
}
static void
@@ -11601,7 +11588,6 @@ odf_preparse_table_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
sot->sheet = sheet;
state->sheet_order = g_slist_prepend
(state->sheet_order, sot);
- odf_create_named_expressions (state, sheet);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]