[gnumeric] xls: fix biff7 import of long strings.



commit 88f385414ca48cddf7c981ad42f050cb51b8070d
Author: Morten Welinder <terra gnome org>
Date:   Mon Feb 17 11:55:32 2014 -0500

    xls: fix biff7 import of long strings.

 NEWS                    |    3 +++
 plugins/excel/ChangeLog |    5 +++++
 plugins/excel/ms-biff.c |   37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index d37e7b2..f82b634 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ Andreas:
 Jean:
        * Fix persistence of hyperlinks tips. [see #724108]
 
+Morten:
+       * Fix BIFF7 import of long strings.  [#724399]
+
 --------------------------------------------------------------------------
 Gnumeric 1.12.11
 
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index cb1bf51..ce30a15 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-17  Morten Welinder  <terra gnome org>
+
+       * ms-biff.c (ms_biff_query_next): Handle continuation records
+       here for certain opcodes.  Fixes part of #724399.
+
 2014-02-16  Morten Welinder <terra gnome org>
 
        * Release 1.12.11
diff --git a/plugins/excel/ms-biff.c b/plugins/excel/ms-biff.c
index b64efa8..52a8739 100644
--- a/plugins/excel/ms-biff.c
+++ b/plugins/excel/ms-biff.c
@@ -408,6 +408,7 @@ ms_biff_query_next (BiffQuery *q)
 {
        guint8 const *data;
        guint16 len;
+       gboolean auto_continue;
 
        g_return_val_if_fail (q != NULL, FALSE);
 
@@ -498,6 +499,42 @@ ms_biff_query_next (BiffQuery *q)
        g_printerr ("Biff read code 0x%x, length %d\n", q->opcode, q->length);
        ms_biff_query_dump (q);
 #endif
+
+       /*
+        * I am guessing that we should always handle BIFF_CONTINUE here,
+        * except for the few record types exempt from encryption.  For
+        * now, however, do the bare minimum.
+        */        
+       switch (q->opcode) {
+       case BIFF_LABEL_v0:
+       case BIFF_LABEL_v2:
+               auto_continue = TRUE;
+               break;
+       case BIFF_CONTINUE:
+       default:
+               auto_continue = FALSE;
+       }
+       if (auto_continue) {
+               guint16 opcode;
+
+               while (ms_biff_query_peek_next (q, &opcode) &&
+                      opcode == BIFF_CONTINUE) {
+                       GString *data = g_string_new_len (q->data, q->length);
+                       opcode = q->opcode;
+                       if (!ms_biff_query_next (q)) {
+                               g_string_free (data, TRUE);
+                               return FALSE; /* Probably shouldn't happen */
+                       }
+                       q->opcode = opcode;
+                       g_string_append_len (data, q->data, q->length);
+                       if (q->data_malloced)
+                               g_free (q->data);
+                       q->length = data->len;
+                       q->data = g_string_free (data, FALSE);
+                       q->data_malloced = TRUE;
+               }
+       }
+
        return TRUE;
 }
 


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