Compilation: prefer glib functions over goffice equivalents
[gnumeric.git] / plugins / excel / ms-obj.h
blob529fd88bdb9d706bd00a87064810bf60b575e704
1 #ifndef GNM_MS_OBJ_H
2 #define GNM_MS_OBJ_H
4 /**
5 * ms-obj.h: MS Excel Graphic Object support for Gnumeric
7 * Authors:
8 * Jody Goldberg (jody@gnome.org)
9 * Michael Meeks (michael@ximian.com)
11 * (C) 1998-2001 Michael Meeks
12 * (C) 2002-2005 Jody Goldberg
13 **/
15 #include "ms-excel-read.h"
16 #include "ms-excel-write.h"
18 #define MS_ANCHOR_SIZE 18
20 enum {
21 MSOT_GROUP00 = 0x00, /* ??? */
22 MSOT_LINE = 0x01,
23 MSOT_RECTANGLE = 0x02,
24 MSOT_OVAL = 0x03,
25 MSOT_ARC = 0x04,
26 MSOT_CHART = 0x05,
27 MSOT_TEXTBOX = 0x06,
28 MSOT_BUTTON = 0x07,
29 MSOT_PICTURE = 0x08,
30 MSOT_POLYGON = 0x09,
31 MSOT_CHECKBOX = 0x0b,
32 MSOT_OPTION = 0x0c,
33 MSOT_EDIT = 0x0d,
34 MSOT_LABEL = 0x0e,
35 MSOT_DIALOG = 0x0f,
36 MSOT_SPINNER = 0x10,
37 MSOT_SCROLLBAR = 0x11,
38 MSOT_LIST = 0x12,
39 MSOT_GROUP = 0x13,
40 MSOT_COMBO = 0x14,
41 MSOT_COMMENT = 0x19,
42 MSOT_DRAWING = 0x1e,
43 MSOT_TOGGLE = 0x70
47 typedef enum {
48 MS_OBJ_ATTR_NONE = 0,
50 /* Flags */
51 MS_OBJ_ATTR_FLIP_H,
52 MS_OBJ_ATTR_FLIP_V,
53 MS_OBJ_ATTR_UNFILLED,
54 MS_OBJ_ATTR_OUTLINE_HIDE, /* true of style == 0 hides a line */
56 /* Integers & Enums */
57 MS_OBJ_ATTR_IS_INT_MASK = 0x1000,
58 MS_OBJ_ATTR_BLIP_ID,
59 MS_OBJ_ATTR_FILL_TYPE,
60 MS_OBJ_ATTR_FILL_SHADE_TYPE,
61 MS_OBJ_ATTR_FILL_ANGLE,
62 MS_OBJ_ATTR_FILL_FOCUS,
63 MS_OBJ_ATTR_FILL_COLOR,
64 MS_OBJ_ATTR_FILL_ALPHA,
65 MS_OBJ_ATTR_FILL_PRESET,
66 MS_OBJ_ATTR_FILL_BACKGROUND,
67 MS_OBJ_ATTR_FILL_BACKGROUND_ALPHA,
68 MS_OBJ_ATTR_OUTLINE_COLOR,
69 MS_OBJ_ATTR_OUTLINE_WIDTH,
70 MS_OBJ_ATTR_OUTLINE_STYLE,
71 MS_OBJ_ATTR_SCROLLBAR_VALUE,
72 MS_OBJ_ATTR_SCROLLBAR_MIN,
73 MS_OBJ_ATTR_SCROLLBAR_MAX,
74 MS_OBJ_ATTR_SCROLLBAR_INC,
75 MS_OBJ_ATTR_SCROLLBAR_PAGE,
76 MS_OBJ_ATTR_SCROLLBAR_HORIZ,
77 MS_OBJ_ATTR_BLIP_CROP_TOP,
78 MS_OBJ_ATTR_BLIP_CROP_BOTTOM,
79 MS_OBJ_ATTR_BLIP_CROP_LEFT,
80 MS_OBJ_ATTR_BLIP_CROP_RIGHT,
81 MS_OBJ_ATTR_ARROW_START,
82 MS_OBJ_ATTR_ARROW_START_WIDTH,
83 MS_OBJ_ATTR_ARROW_START_LENGTH,
84 MS_OBJ_ATTR_ARROW_END,
85 MS_OBJ_ATTR_ARROW_END_WIDTH,
86 MS_OBJ_ATTR_ARROW_END_LENGTH,
88 /* Ptrs */
89 MS_OBJ_ATTR_IS_PTR_MASK = 0x2000,
90 MS_OBJ_ATTR_ANCHOR,
91 MS_OBJ_ATTR_TEXT, /* just the text, no markup */
92 MS_OBJ_ATTR_OBJ_NAME,
93 MS_OBJ_ATTR_OBJ_ALT_TEXT,
95 /* GArrays */
96 MS_OBJ_ATTR_IS_GARRAY_MASK = 0x4000,
97 MS_OBJ_ATTR_POLYGON_COORDS,
99 /* PangoAttrList */
100 MS_OBJ_ATTR_IS_PANGO_ATTR_LIST_MASK = 0x10000,
101 MS_OBJ_ATTR_MARKUP,
103 /* Expressions */
104 MS_OBJ_ATTR_IS_EXPR_MASK = 0x20000,
105 MS_OBJ_ATTR_LINKED_TO_CELL,
106 MS_OBJ_ATTR_INPUT_FROM,
107 MS_OBJ_ATTR_MACRO_EXPR,
109 /* GObjects */
110 MS_OBJ_ATTR_IS_GOBJECT_MASK = 0x40000,
111 MS_OBJ_ATTR_IMDATA,
113 MS_OBJ_ATTR_MASK = 0x77000
114 } MSObjAttrID;
116 typedef struct {
117 MSObjAttrID const id;
118 union {
119 gboolean v_boolean;
120 guint32 v_uint;
121 guint32 v_int;
122 gpointer v_ptr;
123 GArray *v_array;
124 GnmExprTop const *v_texpr;
125 PangoAttrList *v_markup;
126 GObject *v_object;
127 } v;
128 } MSObjAttr;
130 MSObjAttr *ms_obj_attr_new_flag (MSObjAttrID id);
131 MSObjAttr *ms_obj_attr_new_uint (MSObjAttrID id, guint32 val);
132 MSObjAttr *ms_obj_attr_new_int (MSObjAttrID id, gint32 val);
133 MSObjAttr *ms_obj_attr_new_ptr (MSObjAttrID id, gpointer val);
134 MSObjAttr *ms_obj_attr_new_array (MSObjAttrID id, GArray *array);
135 MSObjAttr *ms_obj_attr_new_expr (MSObjAttrID id, GnmExprTop const *texpr);
136 MSObjAttr *ms_obj_attr_new_markup (MSObjAttrID id, PangoAttrList *list);
137 MSObjAttr *ms_obj_attr_new_gobject (MSObjAttrID id, GObject *object);
139 typedef GHashTable MSObjAttrBag;
140 MSObjAttrBag *ms_obj_attr_bag_new (void);
141 void ms_obj_attr_bag_destroy (MSObjAttrBag *ab);
142 void ms_obj_attr_bag_insert (MSObjAttrBag *ab,
143 MSObjAttr *attr);
144 MSObjAttr *ms_obj_attr_bag_lookup (MSObjAttrBag *ab,
145 MSObjAttrID id);
146 guint32 ms_obj_attr_get_uint (MSObjAttrBag *ab, MSObjAttrID id,
147 guint32 default_value);
148 gint32 ms_obj_attr_get_int (MSObjAttrBag *ab, MSObjAttrID id,
149 gint32 default_value);
150 gboolean ms_obj_attr_get_ptr (MSObjAttrBag *ab, MSObjAttrID id,
151 gpointer *res, gboolean steal);
152 GArray *ms_obj_attr_get_array (MSObjAttrBag *ab, MSObjAttrID id,
153 GArray *default_value, gboolean steal);
154 GnmExprTop const *ms_obj_attr_get_expr (MSObjAttrBag *ab, MSObjAttrID id,
155 GnmExprTop const *default_value,
156 gboolean steal);
157 PangoAttrList *ms_obj_attr_get_markup (MSObjAttrBag *ab, MSObjAttrID id,
158 PangoAttrList *default_value, gboolean steal);
159 GObject *ms_obj_attr_get_gobject (MSObjAttrBag *attrs, MSObjAttrID id);
162 struct _MSObj {
163 int id;
165 /* Type specific parameters */
166 SheetObject *gnum_obj;
167 int excel_type;
168 char const *excel_type_name;
170 /* a kludge for now until the indicator and the box have distinct objects */
171 GnmCellPos comment_pos;
172 gboolean auto_combo; /* Filter, Validation, ... */
173 gboolean is_linked;
174 MSObjAttrBag *attrs;
176 MSObj *ms_obj_new (MSObjAttrBag *ab);
177 gboolean ms_read_OBJ (BiffQuery *q, MSContainer *c, MSObjAttrBag *ab);
178 void ms_obj_delete (MSObj *obj);
179 char *ms_read_TXO (BiffQuery *q, MSContainer *c, PangoAttrList **markup);
181 /********************************************************/
183 void ms_objv8_write_common (BiffPut *bp, int id, int type, guint16 flags);
184 void ms_objv8_write_scrollbar_old (BiffPut *bp);
185 void ms_objv8_write_listbox (BiffPut *bp, guint8 lct, gboolean filtered);
187 void ms_objv8_write_note (BiffPut *bp);
189 void ms_objv8_write_checkbox (BiffPut *bp,
190 gboolean active,
191 ExcelWriteSheet *esheet,
192 GnmExprTop const *link_texpr,
193 GnmNamedExpr *macro_nexpr);
194 void ms_objv8_write_radiobutton (BiffPut *bp,
195 gboolean active,
196 ExcelWriteSheet *esheet,
197 GnmExprTop const *link_texpr,
198 GnmNamedExpr *macro_nexpr);
199 void ms_objv8_write_spinbutton (BiffPut *bp,
200 ExcelWriteSheet *esheet,
201 GtkAdjustment *adj, gboolean horiz,
202 GnmExprTop const *link_texpr,
203 GnmNamedExpr *macro_nexpr);
204 void ms_objv8_write_scrollbar (BiffPut *bp,
205 ExcelWriteSheet *esheet,
206 GtkAdjustment *adj, gboolean horiz,
207 GnmExprTop const *link_texpr,
208 GnmNamedExpr *macro_nexpr);
209 void ms_objv8_write_list (BiffPut *bp,
210 ExcelWriteSheet *esheet,
211 GtkAdjustment *adj,
212 GnmExprTop const *res_texpr,
213 GnmExprTop const *data_texpr,
214 GnmNamedExpr *macro_nexpr);
215 void ms_objv8_write_button (BiffPut *bp,
216 ExcelWriteSheet *esheet,
217 GnmNamedExpr *macro_nexpr);
220 #endif /* GNM_MS_OBJ_H */