1 #ifndef _GNM_DEPENDENT_H_
2 # define _GNM_DEPENDENT_H_
5 #include <goffice/goffice.h>
12 GnmExprTop
const *texpr
;
14 /* Double-linked list. */
15 GnmDependent
*next_dep
, *prev_dep
;
19 void (*eval
) (GnmDependent
*dep
);
20 void (*set_expr
) (GnmDependent
*dep
, GnmExprTop
const *new_texpr
);
21 GSList
* (*changed
) (GnmDependent
*dep
);
22 GnmCellPos
* (*pos
) (GnmDependent
const *dep
);
23 void (*debug_name
) (GnmDependent
const *dep
, GString
*target
);
27 DEPENDENT_NO_FLAG
= 0,
30 DEPENDENT_CELL
= 0x00000001, /* builtin type */
31 DEPENDENT_DYNAMIC_DEP
= 0x00000002, /* builtin type */
32 DEPENDENT_NAME
= 0x00000003, /* builtin pseudo type */
33 DEPENDENT_MANAGED
= 0x00000004, /* builtin type */
34 DEPENDENT_STYLE
= 0x00000005, /* builtin type */
35 DEPENDENT_TYPE_MASK
= 0x00000fff,
37 /* Linked into the workbook wide expression list */
38 DEPENDENT_IS_LINKED
= 0x00001000,
39 DEPENDENT_NEEDS_RECALC
= 0x00002000,
40 DEPENDENT_BEING_CALCULATED
= 0x00004000,
41 /* GnmDependent is in the midst of a cyclic calculation */
42 DEPENDENT_BEING_ITERATED
= 0x00008000,
44 DEPENDENT_GOES_INTERSHEET
= 0x00010000,
45 DEPENDENT_GOES_INTERBOOK
= 0x00020000,
46 DEPENDENT_USES_NAME
= 0x00040000,
47 DEPENDENT_HAS_3D
= 0x00080000,
48 DEPENDENT_HAS_DYNAMIC_DEPS
= 0x00200000,
49 DEPENDENT_IGNORE_ARGS
= 0x00400000,
50 DEPENDENT_LINK_FLAGS
= 0x007ff000,
52 /* An internal utility flag */
53 DEPENDENT_FLAGGED
= 0x01000000,
54 DEPENDENT_CAN_RELOCATE
= 0x02000000
57 #define dependent_type(dep) ((dep)->flags & DEPENDENT_TYPE_MASK)
58 #define dependent_is_cell(dep) (dependent_type (dep) == DEPENDENT_CELL)
59 #define dependent_needs_recalc(dep) ((dep)->flags & DEPENDENT_NEEDS_RECALC)
60 #define dependent_is_linked(dep) ((dep)->flags & DEPENDENT_IS_LINKED)
62 struct _GnmDepContainer
{
63 GnmDependent
*head
, *tail
;
65 /* Large ranges hashed on 'range' to accelerate duplicate culling. This
66 * is traversed by g_hash_table_foreach mostly.
69 GHashTable
**range_hash
;
70 GOMemChunk
*range_pool
;
72 /* Single ranges, this maps an GnmEvalPos * to a GSList of its
75 GHashTable
*single_hash
;
76 GOMemChunk
*single_pool
;
78 /* All of the ExprNames that refer to this container */
79 GHashTable
*referencing_names
;
82 GHashTable
*dynamic_deps
;
85 typedef void (*GnmDepFunc
) (GnmDependent
*dep
, gpointer user
);
87 guint32
dependent_type_register (GnmDependentClass
const *klass
);
88 void dependent_types_init (void);
89 void dependent_types_shutdown (void);
91 void dependent_set_expr (GnmDependent
*dep
, GnmExprTop
const *new_texpr
);
92 void dependent_set_sheet (GnmDependent
*dep
, Sheet
*sheet
);
93 void dependent_link (GnmDependent
*dep
);
94 void dependent_unlink (GnmDependent
*dep
);
95 void dependent_queue_recalc (GnmDependent
*dep
);
96 void dependent_add_dynamic_dep (GnmDependent
*dep
, GnmRangeRef
const *rr
);
98 gboolean
dependent_is_volatile (GnmDependent
*dep
);
100 gboolean
dependent_has_pos (GnmDependent
const *dep
);
101 GnmCellPos
const *dependent_pos (GnmDependent
const *dep
);
102 void dependent_move (GnmDependent
*dep
, int dx
, int dy
);
104 GOUndo
*dependents_relocate (GnmExprRelocateInfo
const *info
);
105 void dependents_link (GSList
*deps
);
107 void gnm_cell_eval (GnmCell
*cell
);
108 void cell_queue_recalc (GnmCell
*cell
);
109 void cell_foreach_dep (GnmCell
const *cell
, GnmDepFunc func
, gpointer user
);
111 void sheet_region_queue_recalc (Sheet
const *sheet
, GnmRange
const *range
);
112 void dependents_invalidate_sheet (Sheet
*sheet
, gboolean destroy
);
113 void dependents_workbook_destroy (Workbook
*wb
);
114 void dependents_revive_sheet (Sheet
*sheet
);
115 void workbook_queue_all_recalc (Workbook
*wb
);
116 void workbook_queue_volatile_recalc (Workbook
*wb
);
118 void gnm_dep_style_dependency (Sheet
*sheet
,
119 GnmExprTop
const *texpr
,
123 GnmDepContainer
*gnm_dep_container_new (Sheet
*sheet
);
124 void gnm_dep_container_dump (GnmDepContainer
const *deps
,
126 void dependents_dump (Workbook
*wb
);
127 void gnm_dep_container_sanity_check (GnmDepContainer
const *deps
);
128 void gnm_dep_container_resize (GnmDepContainer
*deps
, int rows
);
130 void dependent_managed_init (GnmDependent
*dep
, Sheet
*sheet
);
131 void dependent_managed_set_expr (GnmDependent
*dep
, GnmExprTop
const *texpr
);
132 void dependent_managed_set_sheet (GnmDependent
*dep
, Sheet
*sheet
);
134 #define DEPENDENT_CONTAINER_FOREACH_DEPENDENT(dc, dep, code) \
136 GnmDependent *dep = (dc)->head; \
138 GnmDependent *_next = dep->next_dep; \
144 #define DEPENDENT_MAKE_TYPE(t, set_expr_handler) \
146 t ## _get_dep_type (void) \
148 static guint32 type = 0; \
150 static GnmDependentClass klass; \
151 klass.eval = &t ## _eval; \
152 klass.set_expr = set_expr_handler; \
153 klass.changed = NULL; \
155 klass.debug_name = &t ## _debug_name; \
156 type = dependent_type_register (&klass); \
161 void dependent_debug_name (GnmDependent
const *dep
, GString
*target
);
165 #endif /* _GNM_DEPENDENT_H_ */