[gnumeric] In ODF import, do not create sheets we did not see during preparsing!



commit 61554647476245985365894faf45ec60982b036e
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Jul 24 12:01:42 2013 -0600

    In ODF import, do not create sheets we did not see during preparsing!
    
    2013-07-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_cellref_parse): do not create new sheets
        since we created them all during preparsing
        (openoffice_file_open): since we never add additional sheets we need
        not delete them

 plugins/openoffice/ChangeLog         |    7 +++++
 plugins/openoffice/openoffice-read.c |   46 ++++++---------------------------
 2 files changed, 16 insertions(+), 37 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index d743e27..382afad 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2013-07-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_cellref_parse): do not create new sheets
+       since we created them all during preparsing
+       (openoffice_file_open): since we never add additional sheets we need
+       not delete them
+
 2013-07-23  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (oo_plot_assign_dim): clear the correct spaces
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 4b139c6..08e5f5f 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1279,7 +1279,6 @@ oo_cellref_parse (GnmCellRef *ref, char const *start, GnmParsePos const *pp,
        GnmSheetSize const *ss;
        GnmSheetSize ss_max = { GNM_MAX_COLS, GNM_MAX_ROWS};
        Sheet *sheet;
-       char *new_sheet_name = NULL;
 
        if (*ptr != '.') {
                char *name, *accum;
@@ -1330,20 +1329,16 @@ two_quotes :
                        *foreign_sheet = g_strdup (name);
                        ref->sheet = NULL;
                } else {
-                       /* OpenCalc does not pre-declare its sheets, but it does have a
-                        * nice unambiguous format.  So if we find a name that has not
-                        * been added yet add it.  Reorder below. */
+                       /* We have seen instances of ODF files generated by   */
+                       /* Libreoffice referring internally to table included */
+                       /* inside charts. See                                 */
+                       /* https://bugzilla.gnome.org/show_bug.cgi?id=698388  */
+                       /* Since all true sheets have been created during     */
+                       /* preparsing, this reference should just be invalid! */
+
                        ref->sheet = workbook_sheet_by_name (pp->wb, name);
-                       if (ref->sheet == NULL) {
-                               if (strcmp (name, "#REF!") == 0) {
+                       if (ref->sheet == NULL)
                                        ref->sheet = invalid_sheet;
-                               } else {
-                                       /* We can't add it yet since this whole ref */
-                                       /* may be invalid */
-                                       new_sheet_name = g_strdup (name);
-                                       ref->sheet = NULL;
-                               }
-                       }
                }
        } else {
                ptr++; /* local ref */
@@ -1361,19 +1356,8 @@ two_quotes :
        if (tmp)
                ptr = tmp;
 
-       if (ref->sheet == invalid_sheet) {
-               g_free (new_sheet_name);
+       if (ref->sheet == invalid_sheet)
                return ptr;
-       }
-
-       if (new_sheet_name != NULL) {
-               Sheet *old_sheet = workbook_sheet_by_index (pp->wb, 0);
-               ref->sheet = sheet_new (pp->wb, new_sheet_name,
-                                       gnm_sheet_get_max_cols (old_sheet),
-                                       gnm_sheet_get_max_rows (old_sheet));
-               workbook_sheet_attach (pp->wb, ref->sheet);
-               g_free (new_sheet_name);
-       }
 
        sheet = eval_sheet (ref->sheet, pp->sheet);
        ss = gnm_sheet_get_size (sheet);
@@ -12226,7 +12210,6 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
        OOParseState     state;
        GError          *err = NULL;
        int i;
-       guint n;
        gboolean         content_malformed = FALSE;
 
        zip = gsf_infile_zip_new (input, &err);
@@ -12437,17 +12420,6 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
                content_malformed = !gsf_xml_in_doc_parse (doc, contents, &state);
        }
 
-       n = g_slist_length (state.sheet_order);
-       while (n < (guint) workbook_sheet_count (state.pos.wb))
-               /* We have seen instances of ODF files generated by   */
-               /* Libreoffice referring internally to table included */
-               /* inside charts. Those tables defacto don't exist    */
-               /* but we have to assume their existence to resolve   */
-               /* the references. We need to delete them now. See    */
-               /* https://bugzilla.gnome.org/show_bug.cgi?id=698388  */
-               workbook_sheet_delete (workbook_sheet_by_index (state.pos.wb, n));
-       g_slist_free_full (state.sheet_order, g_free);
-
        odf_fix_expr_names (&state);
 
        if (!content_malformed) {


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