[gnumeric] gui: fix problems with 3d ranges.



commit 1a437ffccb8c99340c7414a0f607b53d61bd4c82
Author: Morten Welinder <terra gnome org>
Date:   Mon Jul 15 14:28:33 2013 -0400

    gui: fix problems with 3d ranges.

 ChangeLog       |    7 +++++++
 NEWS            |    2 +-
 src/dependent.c |   12 ++++++++++--
 src/expr.c      |    8 +-------
 4 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3605fe9..dc51e97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-07-15  Morten Welinder  <terra gnome org>
+
+       * src/expr.c (gnm_expr_new_range_ctor): Undo previous change.
+
+       * src/dependent.c (link_range_dep, unlink_range_dep): Protect
+       against oversize range.
+
 2013-07-12  Morten Welinder  <terra gnome org>
 
        * src/expr.c (gnm_expr_range_op): When constructing a range, make
diff --git a/NEWS b/NEWS
index e5eae63..042be8c 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ Andreas:
        * Improve ODF import of cells with links. [#704022]
 
 Morten:
-       * Fix crazy parsing problem.  [#704109]
+       * Fix crazy parsing problem.  [#704109] [#704140]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.4
diff --git a/src/dependent.c b/src/dependent.c
index e042a92..12b4e37 100644
--- a/src/dependent.c
+++ b/src/dependent.c
@@ -932,9 +932,15 @@ link_range_dep (GnmDepContainer *deps, GnmDependent *dep,
                DependencyRange const *r)
 {
        int i = BUCKET_OF_ROW (r->range.start.row);
-       int const end = BUCKET_OF_ROW (r->range.end.row);
+       int end = BUCKET_OF_ROW (r->range.end.row);
        DependencyRange r2 = *r;
 
+       /*
+        * It is possible to see ranges bigger than the sheet when
+        * operating with 3D ranges.  See bug #704109.
+        */
+       end = MIN (end, deps->buckets - 1);
+
        for ( ; i <= end; i++) {
                DependencyRange *result;
 
@@ -968,12 +974,14 @@ unlink_range_dep (GnmDepContainer *deps, GnmDependent *dep,
                  DependencyRange const *r)
 {
        int i = BUCKET_OF_ROW (r->range.start.row);
-       int const end = BUCKET_OF_ROW (r->range.end.row);
+       int end = BUCKET_OF_ROW (r->range.end.row);
        DependencyRange r2 = *r;
 
        if (!deps)
                return;
 
+       end = MIN (end, deps->buckets - 1);
+
        for ( ; i <= end; i++) {
                DependencyRange *result;
 
diff --git a/src/expr.c b/src/expr.c
index 4ce80fb..c3a4baa 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -360,7 +360,6 @@ GnmExpr const *
 gnm_expr_new_range_ctor (GnmExpr const *l, GnmExpr const *r)
 {
        GnmValue *v;
-       const GnmCellRef *lr, *rr;
 
        g_return_val_if_fail (l != NULL, NULL);
        g_return_val_if_fail (r != NULL, NULL);
@@ -370,12 +369,7 @@ gnm_expr_new_range_ctor (GnmExpr const *l, GnmExpr const *r)
        if (GNM_EXPR_GET_OPER (r) != GNM_EXPR_OP_CELLREF)
                goto fallback;
 
-       lr = &l->cellref.ref;
-       rr = &r->cellref.ref;
-       if (lr->sheet != rr->sheet)
-               goto fallback;
-
-       v = value_new_cellrange_unsafe (lr, rr);
+       v = value_new_cellrange_unsafe (&l->cellref.ref, &r->cellref.ref);
        gnm_expr_free (l);
        gnm_expr_free (r);
        return gnm_expr_new_constant (v);


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