[gnumeric] Arrays: don't allow array entry on top of merges.



commit 2c7c27c8afcea94f1f81e88e101e0ee9257d812a
Author: Morten Welinder <terra gnome org>
Date:   Fri Feb 7 14:00:14 2014 -0500

    Arrays: don't allow array entry on top of merges.
    
    It won't work.

 ChangeLog          |    5 +++++
 NEWS               |    1 +
 src/sheet.c        |    2 +-
 src/wbc-gtk-edit.c |   43 +++++++++++++++++++++++++------------------
 4 files changed, 32 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cbec715..639dce0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-07  Morten Welinder  <terra gnome org>
+
+       * src/wbc-gtk-edit.c (wbcg_edit_finish): Disallow array formula
+       entry on top of merged cells.  Fixes #723600.
+
 2014-02-06  Jean Brefort  <jean brefort normalesup org>
 
        * src/sheet-object-component.c (destroy_cb), (gnm_soc_user_config):
diff --git a/NEWS b/NEWS
index 75a37a1..60831cf 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,7 @@ Morten:
          RAYLEIGH.
        * Minor theming improvement.  [#722074]
        * Save some vertical space between toolbars.
+       * Fix array/merge interaction problem.  [#723600]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.9
diff --git a/src/sheet.c b/src/sheet.c
index d1091a0..01682f3 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -3475,7 +3475,7 @@ sheet_range_splits_array (Sheet const *sheet,
  *
  * A utility to see whether moving the range @r will split any arrays
  * or merged regions.
- * Returns: whether any arrays or merged regions will be splitted.
+ * Returns: whether any arrays or merged regions will be split.
  */
 gboolean
 sheet_range_splits_region (Sheet const *sheet,
diff --git a/src/wbc-gtk-edit.c b/src/wbc-gtk-edit.c
index 5631f69..76985c9 100644
--- a/src/wbc-gtk-edit.c
+++ b/src/wbc-gtk-edit.c
@@ -150,6 +150,11 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
 
                parse_pos_init_editpos (&pp, sv);
 
+               /* Array only works on single range.  */
+               if (result == WBC_EDIT_ACCEPT_ARRAY &&
+                   (selection == NULL || selection->next != NULL))
+                       result = WBC_EDIT_ACCEPT_RANGE;
+
                /******* Check whether we would split a range ********/
 
                switch (result) {
@@ -162,6 +167,16 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
                                        *showed_dialog = TRUE;
                                return FALSE;
                        }
+
+                       if (result == WBC_EDIT_ACCEPT_ARRAY &&
+                           sheet_range_contains_region (sheet, selection->data,
+                                                        GO_CMD_CONTEXT (wbc), _("Set Text"))) {
+                               range_fragment_free (selection);
+                               if (showed_dialog != NULL)
+                                       *showed_dialog = TRUE;
+                               return FALSE;
+                       }
+
                        break;
                }
                case (WBC_EDIT_ACCEPT_WO_AC):
@@ -239,7 +254,6 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
                        GnmExprTop const *texpr_test = NULL;
                        GnmParseError  perr;
 
-
                        parse_error_init (&perr);
                        texpr_test = gnm_expr_parse_str (expr_txt,
                                                         &pp, GNM_EXPR_PARSE_DEFAULT, NULL, &perr);
@@ -301,27 +315,20 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
                                gnm_expr_top_unref (texpr_test);
                }
 
-               /* We only enter an array formula if
-                *   1) the text is a formula
-                *   2) It's entered as an array formula
-                *   3) There is only one 1 selection
-                */
+               /* We only enter an array formula if the text is a formula */
+               if (result == WBC_EDIT_ACCEPT_ARRAY && !expr_txt)
+                       result = WBC_EDIT_ACCEPT_RANGE;
 
                if (result == WBC_EDIT_ACCEPT_ARRAY) {
-                       if (expr_txt == NULL ||
-                           selection == NULL || selection->next != NULL)
-                               result = WBC_EDIT_ACCEPT_RANGE;
-                       else {
-                               GnmParsePos    pp_array;
-                               GnmRange *r = selection->data;
+                       GnmParsePos pp_array;
+                       GnmRange *r = selection->data;
 
-                               parse_pos_init (&pp_array, sheet->workbook, sheet, r->start.col, 
r->start.row);
+                       parse_pos_init (&pp_array, sheet->workbook, sheet, r->start.col, r->start.row);
 
-                               if ((texpr = gnm_expr_parse_str
-                                    (expr_txt, &pp_array, GNM_EXPR_PARSE_DEFAULT,
-                                     sheet_get_conventions (sheet), NULL)) == NULL)
-                                       result = WBC_EDIT_ACCEPT_RANGE;
-                       }
+                       if ((texpr = gnm_expr_parse_str
+                            (expr_txt, &pp_array, GNM_EXPR_PARSE_DEFAULT,
+                             sheet_get_conventions (sheet), NULL)) == NULL)
+                               result = WBC_EDIT_ACCEPT_RANGE;
                }
 
                /* We need to save the information that we will temporarily overwrite */


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