[gnumeric] stf: honour text formats.



commit f3cc857f76ffaa639928df1095597f8a7680b4fa
Author: Morten Welinder <terra gnome org>
Date:   Sun Jan 22 16:36:52 2017 -0500

    stf: honour text formats.
    
    Don't do number parsing and don't do expression parsing.

 ChangeLog       |    7 +++++++
 NEWS            |    1 +
 src/ssconvert.c |    8 +++++++-
 src/stf-parse.c |    6 ++++--
 4 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4da96e3..19b2291 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-01-22  Morten Welinder  <terra gnome org>
+
+       * src/stf-parse.c (stf_cell_set_text): Don't parse "=..." as
+       expression for text formatted cells.
+       (stf_parse_sheet): Don't try number parsing for text formatted
+       columns.  Fixes #777543.
+
 2017-01-22  Jean Brefort  <jean brefort normalesup org>
 
        * src/graph.c (cb_assign_string), (gnm_go_data_vector_get_str): use cell
diff --git a/NEWS b/NEWS
index 2b7c44b..f7691a5 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Morten:
        * Non-linear solver improvements.
        * Avoid atomizing style regions with conditional formats.
        * Adapt to glpk file format changes.
+       * Fix stf problems with text format.  [#777543]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.32
diff --git a/src/ssconvert.c b/src/ssconvert.c
index 27f4e3b..1a6398e 100644
--- a/src/ssconvert.c
+++ b/src/ssconvert.c
@@ -550,7 +550,13 @@ run_solver (Sheet *sheet, WorkbookView *wbv)
                g_main_context_iteration (NULL, TRUE);
        }
 
-       if (sol->status != GNM_SOLVER_STATUS_DONE) {
+       switch (sol->status) {
+       case GNM_SOLVER_STATUS_DONE:
+               break;
+       case GNM_SOLVER_STATUS_CANCELLED:
+               g_printerr ("Solver reached time or iteration limit\n");
+               break;
+       default:
                g_set_error (&err, go_error_invalid (), 0,
                             _("Solver ran, but failed"));
                goto done;
diff --git a/src/stf-parse.c b/src/stf-parse.c
index 8e51b93..81b13a9 100644
--- a/src/stf-parse.c
+++ b/src/stf-parse.c
@@ -1243,7 +1243,7 @@ stf_cell_set_text (GnmCell *cell, char const *text)
        const GODateConventions *date_conv =
                workbook_date_conv (cell->base.sheet->workbook);
 
-       if (*text == '=' && text[1] != 0) {
+       if (!go_format_is_text (fmt) && *text == '=' && text[1] != 0) {
                GnmExprParseFlags flags =
                        GNM_EXPR_PARSE_UNKNOWN_NAMES_ARE_INVALID;
                const char *expr_start = text + 1;
@@ -1359,6 +1359,7 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
                line = g_ptr_array_index (lines, lrow);
 
                for (lcol = 0; lcol < line->len; lcol++) {
+                       GOFormat const *fmt = g_ptr_array_index (parseoptions->formats, lcol);
                        char const *text = g_ptr_array_index (line, lcol);
                        gboolean want_col =
                                (parseoptions->col_import_array == NULL ||
@@ -1379,7 +1380,8 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
                        }
                        if (text && *text) {
                                GnmCell *cell = sheet_cell_fetch (sheet, col, row);
-                               if (lcol < parseoptions->formats_decimal->len &&
+                               if (!go_format_is_text (fmt) &&
+                                   lcol < parseoptions->formats_decimal->len &&
                                    g_ptr_array_index (parseoptions->formats_decimal, lcol)) {
                                        GOFormatFamily fam;
                                        GnmValue *v = format_match_decimal_number_with_locale


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