[gnumeric] Fix hyperlinks import from ODF. [#779635]



commit 1f7f821ce9e4597d5fc220c20ce5e49bd7fae60b
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sun Mar 5 21:18:25 2017 -0700

    Fix hyperlinks import from ODF. [#779635]
    
    2017-01-30  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_named_expr_preparse): we do need to define global expressions during
        preparse for internal links
        (odf_create_named_expressions): new, extracted from odf_preparse_table_end
        (odf_preparse_table_end) : use odf_create_named_expressions
        (odf_preparse_spreadsheet_end): new
        (opendoc_content_preparse_overrides): connect odf_preparse_spreadsheet_end

 NEWS                                 |    3 ++
 plugins/openoffice/ChangeLog         |    9 +++++++
 plugins/openoffice/openoffice-read.c |   42 ++++++++++++++++++++-------------
 3 files changed, 37 insertions(+), 17 deletions(-)
---
diff --git a/NEWS b/NEWS
index 25f2439..bef13bb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 Gnumeric 1.12.34
 
+Andreas:
+       * Fix hyperlinks import from ODF. [#779635]
+
 Jean:
        * Fix xlsx export of chart series names. [#778618]
        * Always export a transparent fill style in charts. [#779160]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 41f594d..ebbffb6 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,12 @@
+2017-01-30  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_named_expr_preparse): we do need to define global expressions during
+       preparse for internal links
+       (odf_create_named_expressions): new, extracted from odf_preparse_table_end
+       (odf_preparse_table_end) : use odf_create_named_expressions
+       (odf_preparse_spreadsheet_end): new
+       (opendoc_content_preparse_overrides): connect odf_preparse_spreadsheet_end
+
 2017-01-30  Morten Welinder <terra gnome org>
 
        * Release 1.12.33
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 2a9bde9..2d9dec1 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -11471,10 +11471,6 @@ oo_named_expr_preparse (GsfXMLIn *xin, xmlChar const **attrs)
        OOParseState *state = (OOParseState *)xin->user_state;
        char const *name      = NULL;
 
-       if (state->object_name == NULL)
-               /* We do not need to define global names during preparsing. */
-               return;
-
        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]);
@@ -11523,6 +11519,29 @@ odf_sheet_suggest_size (GsfXMLIn *xin, int *cols, int *rows)
        *rows = r;
 }
 
+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
 odf_preparse_table_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
@@ -11532,7 +11551,6 @@ odf_preparse_table_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
        char *table_name = state->object_name;
        Sheet *sheet;
        sheet_order_t *sot = g_new(sheet_order_t, 1);
-       GSList *l;
 
        cols = state->extent_data.col + 1;
        rows = state->extent_data.row + 1;
@@ -11583,18 +11601,7 @@ odf_preparse_table_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
        sot->sheet = sheet;
        state->sheet_order = g_slist_prepend
                (state->sheet_order, sot);
-
-       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;
+       odf_create_named_expressions (state, sheet);
 }
 
 
@@ -12268,6 +12275,7 @@ GSF_XML_IN_NODE_END
 
 static GsfXMLInNode const opendoc_content_preparse_overrides[] =
 {
+       GSF_XML_IN_NODE (OFFICE_BODY, SPREADSHEET, OO_NS_OFFICE, "spreadsheet", GSF_XML_NO_CONTENT, NULL, 
&odf_preparse_spreadsheet_end),
        GSF_XML_IN_NODE (SPREADSHEET, TABLE, OO_NS_TABLE, "table", GSF_XML_NO_CONTENT, 
&odf_preparse_table_start, &odf_preparse_table_end),
        GSF_XML_IN_NODE (TABLE, TABLE_ROW, OO_NS_TABLE, "table-row", GSF_XML_NO_CONTENT, 
&odf_preparse_row_start, &odf_preparse_row_end),
        GSF_XML_IN_NODE (TABLE_ROW, TABLE_CELL, OO_NS_TABLE, "table-cell", GSF_XML_NO_CONTENT, 
&odf_preparse_cell_start, NULL),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]