[gnumeric] xlsx: fix problem with header/footer import.



commit 33bb62886be4677780a66e01b51a9f115e0ac123
Author: Morten Welinder <terra gnome org>
Date:   Fri Jun 12 13:57:36 2015 -0400

    xlsx: fix problem with header/footer import.

 NEWS                          |    1 +
 plugins/excel/ChangeLog       |    5 +++++
 plugins/excel/ms-excel-read.c |    2 +-
 plugins/excel/ms-excel-util.c |    6 +++++-
 plugins/excel/ms-excel-util.h |    2 +-
 plugins/excel/xlsx-read.c     |    4 ++--
 6 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index f053a08..e38a278 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ Morten:
        * Make solver check linearity of model.
        * Fix xls saving of marker style.  [#749185]
        * Make compilation with clang work again.  [#749138]
+       * Fix xlsx problem with import of header/footer.  [#750853]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.22
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 8727915..98a2b19 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-12  Morten Welinder  <terra gnome org>
+
+       * ms-excel-util.c (xls_header_footer_import): Allocate if needed.
+       Fixes #750853.
+
 2015-06-11  Morten Welinder  <terra gnome org>
 
        * ms-excel-read.c (excel_read_AUTOFILTER): Handle invalid filter
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 7014049..0157ca3 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -6430,7 +6430,7 @@ excel_read_HEADER_FOOTER (GnmXLImporter const *importer,
 
                d (2, g_printerr ("%s == '%s'\n", is_header ? "header" : "footer", str););
 
-               xls_header_footer_import (is_header ? pi->header : pi->footer,
+               xls_header_footer_import (is_header ? &pi->header : &pi->footer,
                                          str);
 
                g_free (str);
diff --git a/plugins/excel/ms-excel-util.c b/plugins/excel/ms-excel-util.c
index e1b31a1..3d88d14 100644
--- a/plugins/excel/ms-excel-util.c
+++ b/plugins/excel/ms-excel-util.c
@@ -750,10 +750,14 @@ xls_header_footer_export (const GnmPrintHF *hf)
 }
 
 void
-xls_header_footer_import (GnmPrintHF *hf, const char *txt)
+xls_header_footer_import (GnmPrintHF **phf, const char *txt)
 {
        char section = 'L';
        GString *accum;
+       GnmPrintHF *hf = *phf;
+
+       if (!hf)
+               *phf = hf = gnm_print_hf_new ("", "", "");
 
        g_free (hf->left_format); hf->left_format = g_strdup ("");
        g_free (hf->middle_format); hf->middle_format = g_strdup ("");
diff --git a/plugins/excel/ms-excel-util.h b/plugins/excel/ms-excel-util.h
index 87fb1f6..2dc6307 100644
--- a/plugins/excel/ms-excel-util.h
+++ b/plugins/excel/ms-excel-util.h
@@ -103,7 +103,7 @@ unsigned xls_paper_size (GtkPaperSize *ps, gboolean rotated);
 /*****************************************************************************/
 
 char *xls_header_footer_export (const GnmPrintHF *hf);
-void xls_header_footer_import (GnmPrintHF *hf, const char *txt);
+void xls_header_footer_import (GnmPrintHF **hf, const char *txt);
 
 /*****************************************************************************/
 
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index d3c32f0..d4f8e04 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -2002,7 +2002,7 @@ xlsx_CT_oddheader_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
        GnmPrintInformation *pi = state->sheet->print_info;
-       xls_header_footer_import (pi->header, xin->content->str);
+       xls_header_footer_import (&pi->header, xin->content->str);
 }
 
 static void
@@ -2010,7 +2010,7 @@ xlsx_CT_oddfooter_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
        GnmPrintInformation *pi = state->sheet->print_info;
-       xls_header_footer_import (pi->footer, xin->content->str);
+       xls_header_footer_import (&pi->footer, xin->content->str);
 }
 
 static void


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