[gnumeric] xls: fix roundtrip of xls macros.



commit faa6ce7f0607be1020c9416b04dc8a5b45034b24
Author: Morten Welinder <terra gnome org>
Date:   Wed Feb 26 10:22:01 2014 -0500

    xls: fix roundtrip of xls macros.

 NEWS                    |    2 +-
 plugins/excel/ChangeLog |    1 +
 plugins/excel/boot.c    |   20 +++++++++-----------
 3 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/NEWS b/NEWS
index e1e4d56..ebcc0f4 100644
--- a/NEWS
+++ b/NEWS
@@ -40,7 +40,7 @@ Morten:
        * Work around gtk+ criticals.  [#725142]
        * Fix xls/biff8 export of long comments.  [#725168]
        * Fix xls/biff8 import of comment's text attributes.  [#725168]
-       * Improve the xls macro-roundtrip situation.  [Part of #725220]
+       * Improve the xls macro-roundtrip situation.  [#725220]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.11
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 703dc8d..afbddd4 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -3,6 +3,7 @@
        * boot.c (excel_save): Make sure to save macros in the
        _VBA_PROJECT_CUR directory that we loaded them from.
        (excel_save): Restore \001Ole member too.
+       (excel_save): Save the entire _VBA_PROJECT_CUR directory.
 
 2014-02-25  Morten Welinder  <terra gnome org>
 
diff --git a/plugins/excel/boot.c b/plugins/excel/boot.c
index 5bdf292..cfb9df3 100644
--- a/plugins/excel/boot.c
+++ b/plugins/excel/boot.c
@@ -202,9 +202,12 @@ excel_enc_file_open (GOFileOpener const *fo, char const *enc, GOIOContext *conte
        /* See if there are any macros to keep around */
        stream = gsf_infile_child_by_name (ole, "\01CompObj");
        if (stream != NULL) {
-               GsfInput *macros = gsf_infile_child_by_vname (ole, "_VBA_PROJECT_CUR", "VBA", NULL);
+               GsfInput *macros = gsf_infile_child_by_name (ole, "_VBA_PROJECT_CUR");
                if (macros != NULL) {
-                       GsfInfile *vba = gsf_infile_msvba_new (GSF_INFILE (macros), NULL);
+                       GsfInput *vba_child = gsf_infile_child_by_name (GSF_INFILE (macros), "VBA");
+                       GsfInfile *vba = vba_child
+                               ? gsf_infile_msvba_new (GSF_INFILE (vba_child), NULL)
+                               : NULL;
                        if (NULL != vba) {
                                GHashTable *modules =
                                        gsf_infile_msvba_steal_modules (GSF_INFILE_MSVBA (vba));
@@ -218,8 +221,9 @@ excel_enc_file_open (GOFileOpener const *fo, char const *enc, GOIOContext *conte
                                }
                                g_object_unref (vba);
                        }
+                       if (vba_child)
+                               g_object_unref (vba_child);
 
-                       /* LOOKS BROKEN */
                        g_object_set_data_full (G_OBJECT (wb), "MS_EXCEL_COMPOBJ_STREAM",
                                gsf_structured_blob_read (stream), g_object_unref);
 
@@ -315,14 +319,8 @@ excel_save (GOIOContext *context, WorkbookView const *wbv, GsfOutput *output,
                gsf_structured_blob_write (blob, outfile);
 
        blob = g_object_get_data (G_OBJECT (wb), "MS_EXCEL_MACROS");
-       if (blob != NULL) {
-               GsfOutput *vba = gsf_outfile_new_child (outfile, "_VBA_PROJECT_CUR", TRUE);
-               if (vba) {
-                       gsf_structured_blob_write (blob, GSF_OUTFILE (vba));
-                       gsf_output_close (vba);
-                       g_object_unref (vba);
-               }
-       }
+       if (blob)
+               gsf_structured_blob_write (blob, outfile);
 
        gsf_output_close (GSF_OUTPUT (outfile));
        g_object_unref (outfile);


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