[gnumeric] Sheet: fix sheet shrink.



commit cbf54f5c3e04872d62bd05236cc784348cc79669
Author: Morten Welinder <terra gnome org>
Date:   Sat Dec 20 16:48:15 2014 -0500

    Sheet: fix sheet shrink.

 ChangeLog   |    5 +++++
 src/sheet.c |    8 +++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 02f3bc0..026fa0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-20  Morten Welinder  <terra gnome org>
+
+       * src/sheet.c (sheet_insdel_colrow): Fix handling of too-big
+       count in delete, such as used from sheet resize.
+
 2014-12-19  Morten Welinder  <terra gnome org>
 
        * src/libgnumeric.c (gnm_pre_parse_init): Use putenv for win32
diff --git a/src/sheet.c b/src/sheet.c
index 7222eb0..0fb7297 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -4961,6 +4961,7 @@ sheet_insdel_colrow (Sheet *sheet, int pos, int count,
        ColRowStateList *states = NULL;
        GnmExprRelocateInfo reloc_info;
        GSList *l;
+       gboolean sticky_end = TRUE;
 
        g_return_val_if_fail (IS_SHEET (sheet), TRUE);
        g_return_val_if_fail (count > 0, TRUE);
@@ -4981,6 +4982,11 @@ sheet_insdel_colrow (Sheet *sheet, int pos, int count,
                move_start = pos;
                move_end = kill_start - 1;
        } else {
+               int max_count = last_pos + 1 - pos;
+               if (count > max_count) {
+                       sticky_end = FALSE;
+                       count = max_count;
+               }
                kill_start = pos;
                kill_end = pos + (count - 1);
                move_start = kill_end + 1;
@@ -5022,7 +5028,7 @@ sheet_insdel_colrow (Sheet *sheet, int pos, int count,
        sheet_objects_clear (sheet, &kill_zone, G_TYPE_NONE, pundo);
 
        reloc_info.reloc_type = is_cols ? GNM_EXPR_RELOCATE_COLS : GNM_EXPR_RELOCATE_ROWS;
-       reloc_info.sticky_end = is_insert || !(kill_end > last_pos);
+       reloc_info.sticky_end = sticky_end;
        reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
        parse_pos_init_sheet (&reloc_info.pos, sheet);
 


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