[gnumeric] Validation: insist of getting the sheet when object is created.



commit 465dd968b0410fc7f6358ea21e68aaf89efeb624
Author: Morten Welinder <terra gnome org>
Date:   Mon Jul 20 18:54:50 2020 -0400

    Validation: insist of getting the sheet when object is created.

 src/mstyle.c     |  3 +--
 src/validation.c | 25 ++++++-------------------
 src/validation.h |  3 +--
 3 files changed, 8 insertions(+), 23 deletions(-)
---
diff --git a/src/mstyle.c b/src/mstyle.c
index 76d43fc1b3..572073e769 100644
--- a/src/mstyle.c
+++ b/src/mstyle.c
@@ -984,8 +984,7 @@ gnm_style_linked_sheet_changed (GnmStyle *style)
        if (elem_is_set (style, MSTYLE_VALIDATION) &&
            style->validation &&
            gnm_validation_get_sheet (style->validation) != sheet) {
-               GnmValidation *new_v = gnm_validation_dup (style->validation);
-               gnm_validation_set_sheet (new_v, sheet);
+               GnmValidation *new_v = gnm_validation_dup_to (style->validation, sheet);
                gnm_style_set_validation (style, new_v);
        }
 
diff --git a/src/validation.c b/src/validation.c
index 9933a7230d..ea0c987d99 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -312,7 +312,7 @@ gnm_validation_new (ValidationStyle style,
 }
 
 GnmValidation *
-gnm_validation_dup (GnmValidation *v)
+gnm_validation_dup_to (GnmValidation *v, Sheet *sheet)
 {
        GnmValidation *dst;
        int i;
@@ -320,11 +320,11 @@ gnm_validation_dup (GnmValidation *v)
        g_return_val_if_fail (v != NULL, NULL);
 
        dst = gnm_validation_new (v->style, v->type, v->op,
-                             gnm_validation_get_sheet (v),
-                             v->title ? v->title->str : NULL,
-                             v->msg ? v->msg->str : NULL,
-                             NULL, NULL,
-                             v->allow_blank, v->use_dropdown);
+                                 sheet,
+                                 v->title ? v->title->str : NULL,
+                                 v->msg ? v->msg->str : NULL,
+                                 NULL, NULL,
+                                 v->allow_blank, v->use_dropdown);
        for (i = 0; i < 2; i++)
                gnm_validation_set_expr (dst, v->deps[i].base.texpr, i);
        return dst;
@@ -423,19 +423,6 @@ gnm_validation_get_sheet (GnmValidation const *v)
        return v->deps[0].base.sheet;
 }
 
-void
-gnm_validation_set_sheet (GnmValidation *v, Sheet *sheet)
-{
-       int i;
-
-       g_return_if_fail (v != NULL);
-       g_return_if_fail (IS_SHEET (sheet));
-
-       for (i = 0; i < 2; i++)
-               dependent_managed_set_sheet (&v->deps[i], sheet);
-}
-
-
 /**
  * gnm_validation_set_expr:
  * @v: #GnmValidation
diff --git a/src/validation.h b/src/validation.h
index aab4b2db35..c7bc973a18 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -73,7 +73,7 @@ GnmValidation *gnm_validation_new   (ValidationStyle style,
                                     GnmExprTop const *texpr1,
                                     gboolean allow_blank,
                                     gboolean use_dropdown);
-GnmValidation *gnm_validation_dup   (GnmValidation *v);
+GnmValidation *gnm_validation_dup_to(GnmValidation *v, Sheet *sheet);
 gboolean    gnm_validation_equal    (GnmValidation const *a,
                                     GnmValidation const *b,
                                     gboolean relax_sheet);
@@ -86,7 +86,6 @@ void      gnm_validation_set_expr (GnmValidation *v,
 GError    *gnm_validation_is_ok    (GnmValidation const *v);
 
 Sheet      *gnm_validation_get_sheet (GnmValidation const *v);
-void        gnm_validation_set_sheet (GnmValidation *v, Sheet *sheet);
 
 ValidationStatus gnm_validation_eval (WorkbookControl *wbc,
                                      GnmStyle const *mstyle,


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