[gnumeric] xls: cleanup.



commit c8c3c92df2ad8dd054aa7cf54b3cccc5163704c0
Author: Morten Welinder <terra gnome org>
Date:   Sat Feb 22 15:12:38 2014 -0500

    xls: cleanup.

 plugins/excel/ms-formula-write.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/plugins/excel/ms-formula-write.c b/plugins/excel/ms-formula-write.c
index 3ca4d7b..3b341ec 100644
--- a/plugins/excel/ms-formula-write.c
+++ b/plugins/excel/ms-formula-write.c
@@ -368,13 +368,20 @@ write_string (PolishData *pd, gchar const *txt)
 {
        size_t i, n = 0, len = g_utf8_strlen (txt, -1);
        const char *p = txt;
-
+       const size_t CHUNK_LEN = 255;
+
+       /*
+        * The xls format only handles strings up to 255 characters
+        * in formulae.  To make up for that, we create expressions
+        * like ("s1"&"s2"&...).  Note, that the parentheses are
+        * explicitly present in the file.
+        */
        for (i = 0; n == 0 || i < len; ) {
-               if (len - i <= 255) {
+               if (len - i <= CHUNK_LEN) {
                        write_string1 (pd, p);
                        i = len;
                } else {
-                       const char *endcut = g_utf8_offset_to_pointer (p, 255);
+                       const char *endcut = g_utf8_offset_to_pointer (p, CHUNK_LEN);
                        size_t cutlen = endcut - p;
                        char *cut = g_memdup (p, cutlen + 1);
                        cut[cutlen] = 0;
@@ -382,7 +389,7 @@ write_string (PolishData *pd, gchar const *txt)
                        g_free (cut);
 
                        p = endcut;
-                       i += 255;
+                       i += CHUNK_LEN;
                }
 
                if (n > 0)


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