1 #ifndef _GNM_POSITION_H_
2 # define _GNM_POSITION_H_
3 
4 #include <gnumeric.h>
5 
6 G_BEGIN_DECLS
7 
8 GType gnm_cell_pos_get_type (void); /* boxed type */
9 
10 struct _GnmEvalPos {
11 	GnmCellPos eval;
12 	Sheet *sheet;
13 	GnmDependent *dep;	 /* optionally NULL */
14 	GnmExprTop const *array_texpr; /* non-NULL if top level is array */
15 };
16 
17 struct _GnmParsePos {
18 	GnmCellPos  eval;
19 	Sheet	   *sheet;
20 	Workbook   *wb;
21 };
22 
23 /*
24  * Used for getting a valid Sheet *from a GnmCellRef
25  * Syntax is GnmCellRef, valid Sheet *
26  */
27 #define eval_sheet(a,b)     (((a) != NULL) ? (a) : (b))
28 
29 /* Initialization routines for Evaluation Positions */
30 GType        gnm_eval_pos_get_type (void); /* Boxed type */
31 GnmEvalPos  *eval_pos_init	   (GnmEvalPos *ep, Sheet *s, int col, int row);
32 GnmEvalPos  *eval_pos_init_pos	   (GnmEvalPos *ep, Sheet *s, GnmCellPos const *pos);
33 GnmEvalPos  *eval_pos_init_dep	   (GnmEvalPos *ep, GnmDependent const *dep);
34 GnmEvalPos  *eval_pos_init_cell	   (GnmEvalPos *ep, GnmCell const *cell);
35 GnmEvalPos  *eval_pos_init_editpos (GnmEvalPos *ep, SheetView const *sv);
36 GnmEvalPos  *eval_pos_init_sheet   (GnmEvalPos *ep, Sheet const *sheet);
37 gboolean     eval_pos_is_array_context (GnmEvalPos const *ep);
38 
39 /* Initialization routines for Parse Positions */
40 GType        gnm_parse_pos_get_type (void); /* Boxed type */
41 GnmParsePos *parse_pos_init         (GnmParsePos *pp, Workbook *wb,
42 				     Sheet const *sheet, int col, int row);
43 GnmParsePos *parse_pos_init_dep	    (GnmParsePos *pp, GnmDependent const *dep);
44 GnmParsePos *parse_pos_init_cell    (GnmParsePos *pp, GnmCell const *cell);
45 GnmParsePos *parse_pos_init_evalpos (GnmParsePos *pp, GnmEvalPos const *pos);
46 GnmParsePos *parse_pos_init_editpos (GnmParsePos *pp, SheetView const *sv);
47 GnmParsePos *parse_pos_init_sheet   (GnmParsePos *pp, Sheet const *sheet);
48 
49 /*****************************************************************************/
50 
51 struct _GnmCellRef {
52 	Sheet *sheet;
53 	int   col, row;
54 
55 	unsigned char col_relative;
56 	unsigned char row_relative;
57 };
58 struct _GnmRangeRef {
59 	GnmCellRef a, b;
60 };
61 
62 GType       gnm_cellref_get_type   (void); /* Boxed type */
63 GnmCellRef *gnm_cellref_init       (GnmCellRef *ref, Sheet *sheet,
64 				    int col, int row, gboolean rel);
65 gboolean    gnm_cellref_equal	   (GnmCellRef const *a, GnmCellRef const *b);
66 guint       gnm_cellref_hash	   (GnmCellRef const *cr);
67 void        gnm_cellref_make_abs   (GnmCellRef *dest, GnmCellRef const *src,
68 				    GnmEvalPos const *ep);
69 void        gnm_cellref_set_col_ar (GnmCellRef *cr, GnmParsePos const *pp,
70 				    gboolean abs_rel);
71 void        gnm_cellref_set_row_ar (GnmCellRef *cr, GnmParsePos const *pp,
72 				    gboolean abs_rel);
73 int         gnm_cellref_get_col	   (GnmCellRef const *cr, GnmEvalPos const *ep);
74 int         gnm_cellref_get_row	   (GnmCellRef const *cr, GnmEvalPos const *ep);
75 
76 GType        gnm_rangeref_get_type (void); /* Boxed type */
77 gboolean     gnm_rangeref_equal	   (GnmRangeRef const *a, GnmRangeRef const *b);
78 guint	     gnm_rangeref_hash	   (GnmRangeRef const *cr);
79 GnmRangeRef *gnm_rangeref_dup	   (GnmRangeRef const *cr);
80 void         gnm_rangeref_normalize_pp (GnmRangeRef const *rr,
81 					GnmParsePos const *pp,
82 					Sheet **start_sheet, Sheet **end_sheet,
83 					GnmRange *dest);
84 void         gnm_rangeref_normalize (GnmRangeRef const *rr,
85 				     GnmEvalPos const *ep,
86 				     Sheet **start_sheet, Sheet **end_sheet,
87 				     GnmRange *dest);
88 
89 guint gnm_cellpos_hash		(GnmCellPos const *key);
90 gint  gnm_cellpos_equal		(GnmCellPos const *a, GnmCellPos const *b);
91 void  gnm_cellpos_init_cellref_ss (GnmCellPos *res, GnmCellRef const *cell_ref,
92 				   GnmCellPos const *pos,
93 				   GnmSheetSize const *ss);
94 void  gnm_cellpos_init_cellref	(GnmCellPos *cp, GnmCellRef const *cr,
95 				 GnmCellPos const *pos, Sheet const *base_sheet);
96 
97 G_END_DECLS
98 
99 #endif /* _GNM_POSITION_H_ */
100