[gnumeric] Conditional Styling: some dependency fixes.



commit 17bcc386b223e7fc8edf77569792775d70d9c87c
Author: Morten Welinder <terra gnome org>
Date:   Fri Dec 18 19:47:46 2020 -0500

    Conditional Styling: some dependency fixes.
    
    This is not complete yet, but is work towards #547.

 ChangeLog              |  7 +++++++
 src/expr.c             |  2 +-
 src/sheet-conditions.c | 30 ++++++++++++++++++++----------
 src/style-conditions.c |  3 +++
 4 files changed, 31 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 38b026562..15d8e4f41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-12-18  Morten Welinder  <terra gnome org>
+
+       * src/sheet-conditions.c (update_group): Fix eval pos -- it's
+       different for each range, even if we hang everything on the same
+       dep.  Don't use a set for dependency -- that only works right in
+       array mode -- but use a call to SUM instead.
+
 2020-10-17  Jean Brefort  <jean brefort normalesup org>
 
        * src/sheet-object-graph.c (gnm_sog_bounds_changed): fix graph size issue
diff --git a/src/expr.c b/src/expr.c
index 64addecf5..1be773541 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -93,7 +93,7 @@ gnm_expr_new_constant (GnmValue *v)
  * gnm_expr_new_funcallv: (skip)
  * @func: #GnmFunc
  * @argc: argument count
- * @argv: (array length=argc): transfers everything
+ * @argv: (in) (transfer full) (array length=argc): transfers everything
  *
  * Returns: (transfer full): function call expression.
  */
diff --git a/src/sheet-conditions.c b/src/sheet-conditions.c
index 70ff2cac4..9dddd0986 100644
--- a/src/sheet-conditions.c
+++ b/src/sheet-conditions.c
@@ -646,19 +646,25 @@ update_group (CSGroup *g)
                unsigned ix;
                for (ix = 0; ix < G_N_ELEMENTS (cond->deps); ix++) {
                        GnmExprTop const *te = gnm_style_cond_get_expr (cond, ix);
-                       if (te) {
-                               unsigned ri;
-                               eval_pos_init_dep (&state.epos, &cond->deps[ix].base);
-                               for (ri = 0; ri < g->ranges->len; ri++) {
-                                       state.r = &g_array_index (g->ranges, GnmRange, ri);
-                                       collect_group_deps (te->expr, &state, CGD_NO_FLAGS);
-                               }
+                       unsigned ri;
+                       if (!te)
+                               continue;
+
+                       eval_pos_init_dep (&state.epos, &cond->deps[ix].base);
+                       for (ri = 0; ri < g->ranges->len; ri++) {
+                               state.r = &g_array_index (g->ranges, GnmRange, ri);
+                               state.epos.eval = state.r->start;
+                               collect_group_deps (te->expr, &state, CGD_NO_FLAGS);
                        }
                }
        }
-       texpr = state.deps
-               ? gnm_expr_top_new (gnm_expr_new_set (state.deps))
-               : gnm_expr_top_new_constant (value_new_error_REF (NULL));
+
+       if (state.deps == NULL)
+               texpr = gnm_expr_top_new_constant (value_new_error_REF (NULL));
+       else {
+               GnmFunc *f = gnm_func_lookup ("SUM", NULL);
+               texpr = gnm_expr_top_new (gnm_expr_new_funcall (f, state.deps));
+       }
        set_group_pos_and_expr (g, pos, texpr);
        gnm_expr_top_unref (texpr);
 }
@@ -679,6 +685,10 @@ csgd_changed (GnmDependent *dep)
        Sheet *sheet = dep->sheet;
        unsigned ri;
 
+       if (debug_sheet_conds) {
+               g_printerr ("Changed CSGroup/%p\n", (void *)dep);
+       }
+
        for (ri = 0; ri < g->ranges->len; ri++) {
                GnmRange *r = &g_array_index (g->ranges, GnmRange, ri);
                // FIXME:
diff --git a/src/style-conditions.c b/src/style-conditions.c
index 3f8f969c2..feee1206b 100644
--- a/src/style-conditions.c
+++ b/src/style-conditions.c
@@ -764,6 +764,9 @@ static GSList *
 gscd_changed (GnmDependent *dep)
 {
        GnmStyleCondDep const *scd = (GnmStyleCondDep const *)dep;
+       if (debug_style_conds ()) {
+               g_printerr ("Changed StyleCondDep/%p\n", dep);
+       }
        return scd->dep_cont ? g_slist_prepend (NULL, scd->dep_cont) : NULL;
 }
 


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