2 # define _GNM_RANGES_H_
5 #include <glib-object.h>
14 * NB. commutative, symmetric, and transitive.
16 * Returns: True if both ranges are equal.
18 #define range_equal(a,b) ((a)->start.row == (b)->start.row && \
19 (a)->end.row == (b)->end.row && \
20 (a)->start.col == (b)->start.col && \
21 (a)->end.col == (b)->end.col)
23 GType
gnm_range_get_type (void); /* GBoxedType */
24 GnmRange
*gnm_range_dup (GnmRange
const *r
);
25 gboolean
gnm_range_equal (GnmRange
const *a
, GnmRange
const *b
);
26 int gnm_range_compare (GnmRange
const *a
, GnmRange
const *b
);
33 * NB. commutative, symmetric, but not transitive.
35 * Returns: True if the ranges overlap at all.
37 #define range_overlap(a,b) (((a)->end.row >= (b)->start.row) && \
38 ((b)->end.row >= (a)->start.row) && \
39 ((a)->end.col >= (b)->start.col) && \
40 ((b)->end.col >= (a)->start.col))
44 * @r: range to operate on
48 * Determine if a range contains a col,row co-ordinate.
50 * Return value: TRUE if co-ordinate contained.
52 #define range_contains(r,x,y) (((y) <= (r)->end.row) && \
53 ((y) >= (r)->start.row) && \
54 ((x) >= (r)->start.col) && \
55 ((x) <= (r)->end.col))
58 * Quickly Test if a range is valid
60 #define range_valid(r) ((r)->start.col <= (r)->end.col && \
61 (r)->start.row <= (r)->end.row)
63 #define range_fragment_free(f) g_slist_free_full ((f), g_free)
65 GnmRange
*range_init_full_sheet (GnmRange
*r
, Sheet
const *sheet
);
66 GnmRange
*range_init_cols (GnmRange
*r
, Sheet
const *sheet
,
67 int start_col
, int end_col
);
68 GnmRange
*range_init_rows (GnmRange
*r
, Sheet
const *sheet
,
69 int start_row
, int end_row
);
70 GnmRange
*range_init_invalid (GnmRange
*r
);
71 GnmRange
*range_init_rangeref (GnmRange
*r
, GnmRangeRef
const *rr
);
72 GnmRange
*range_init_value (GnmRange
*r
, GnmValue
const *v
);
73 GnmRange
*range_init_cellpos (GnmRange
*r
, GnmCellPos
const *pos
);
74 GnmRange
*range_init_cellpos_size (GnmRange
*r
, GnmCellPos
const *start
,
76 GnmRange
*range_init (GnmRange
*r
, int start_col
, int start_row
,
77 int end_col
, int end_row
);
78 gboolean
range_parse (GnmRange
*r
, char const *text
,
79 GnmSheetSize
const *ss
);
81 void range_list_destroy (GSList
*ranges
);
83 int range_width (GnmRange
const *r
);
84 int range_height (GnmRange
const *r
);
85 gboolean
range_is_singleton (GnmRange
const *r
);
86 gboolean
range_is_full (GnmRange
const *r
, Sheet
const *sheet
, gboolean horiz
);
87 void range_clip_to_finite(GnmRange
*range
, Sheet
*sheet
);
88 gboolean
range_contained (GnmRange
const *a
, GnmRange
const *b
);
89 gboolean
range_intersection (GnmRange
*r
,
92 void range_normalize (GnmRange
*src
);
93 GnmRange
range_union (GnmRange
const *a
, GnmRange
const *b
);
94 void range_ensure_sanity (GnmRange
*range
, Sheet
const *sheet
);
95 gboolean
range_is_sane (GnmRange
const *range
);
96 gboolean
range_translate (GnmRange
*range
, Sheet
const *sheet
,
97 int col_offset
, int row_offset
);
98 gboolean
range_transpose (GnmRange
*range
, Sheet
const *sheet
,
99 GnmCellPos
const *origin
);
101 char const *range_as_string (GnmRange
const *r
);
102 void range_dump (GnmRange
const *r
, char const *suffix
);
104 GSList
*range_split_ranges (GnmRange
const *hard
, GnmRange
const *soft
);
105 GSList
*range_fragment (GnmRange
const *a
, GnmRange
const *b
);
107 GType
gnm_sheet_range_get_type (void); /* GBoxedType */
108 GnmSheetRange
*gnm_sheet_range_new (Sheet
*sheet
, GnmRange
const *r
);
109 void gnm_sheet_range_free (GnmSheetRange
*r
);
110 gboolean
gnm_sheet_range_from_value (GnmSheetRange
*r
, GnmValue
const *v
);
111 gboolean
gnm_sheet_range_overlap (GnmSheetRange
const *a
, GnmSheetRange
const *b
);
112 GnmSheetRange
*gnm_sheet_range_dup (GnmSheetRange
const *sr
);
113 gboolean
gnm_sheet_range_equal (GnmSheetRange
const *a
,
114 GnmSheetRange
const *b
);
116 char *global_range_name (Sheet
const *sheet
, GnmRange
const *r
);
117 char *undo_cell_pos_name (Sheet
const *sheet
, GnmCellPos
const *pos
);
118 char *undo_range_name (Sheet
const *sheet
, GnmRange
const *r
);
119 char *undo_range_list_name (Sheet
const *sheet
, GSList
const *ranges
);
121 GSList
*global_range_list_parse (Sheet
*sheet
, char const *str
);
122 GnmValue
*global_range_list_foreach (GSList
*gr_list
, GnmEvalPos
const *ep
,
124 CellIterFunc handler
,
126 gboolean
global_range_contained (Sheet
const *sheet
,
127 GnmValue
const *a
, GnmValue
const *b
);
131 #endif /* _GNM_RANGES_H_ */