1 // TODO debugging
2 #define DWG_TYPE DWG_TYPE_TABLE
3 #include "common.c"
4
5 void
6 api_process (dwg_object *obj)
7 {
8 int error, isnew;
9 BITCODE_BL i, j;
10 Dwg_LinkedData ldata;
11 Dwg_LinkedTableData tdata;
12 Dwg_FormattedTableData fdata;
13 BITCODE_H tablestyle;
14
15 BITCODE_RC unknown_rc;
16 BITCODE_H unknown_h;
17 BITCODE_BL unknown_bl;
18 BITCODE_B unknown_b;
19 BITCODE_BL unknown_bl1;
20 BITCODE_3BD ins_pt;
21 BITCODE_3BD scale;
22 BITCODE_BB scale_flag;
23 BITCODE_BD rotation;
24 BITCODE_BE extrusion;
25 BITCODE_B has_attribs;
26 BITCODE_BL num_owned;
27 BITCODE_BS flag_for_table_value;
28 BITCODE_3BD horiz_direction;
29 BITCODE_BL num_cols;
30 BITCODE_BL num_rows;
31 unsigned long num_cells;
32 BITCODE_BD *col_widths;
33 BITCODE_BD *row_heights;
34 Dwg_TABLE_Cell *cells;
35 BITCODE_BL num_attr_defs;
36 Dwg_TABLE_AttrDef *attr_defs;
37 BITCODE_B has_table_overrides;
38 BITCODE_BL table_flag_override;
39 BITCODE_B title_suppressed;
40 BITCODE_B header_suppressed;
41 BITCODE_BS flow_direction;
42 BITCODE_BD horiz_cell_margin;
43 BITCODE_BD vert_cell_margin;
44 BITCODE_CMC title_row_color;
45 BITCODE_CMC header_row_color;
46 BITCODE_CMC data_row_color;
47 BITCODE_B title_row_fill_none;
48 BITCODE_B header_row_fill_none;
49 BITCODE_B data_row_fill_none;
50 BITCODE_CMC title_row_fill_color;
51 BITCODE_CMC header_row_fill_color;
52 BITCODE_CMC data_row_fill_color;
53 BITCODE_BS title_row_alignment;
54 BITCODE_BS header_row_alignment;
55 BITCODE_BS data_row_alignment;
56 BITCODE_H title_text_style;
57 BITCODE_H header_text_style;
58 BITCODE_H data_text_style;
59 BITCODE_BD title_row_height;
60 BITCODE_BD header_row_height;
61 BITCODE_BD data_row_height;
62 BITCODE_B has_border_color_overrides;
63 BITCODE_BL border_color_overrides_flag;
64 BITCODE_CMC title_horiz_top_color;
65 BITCODE_CMC title_horiz_ins_color;
66 BITCODE_CMC title_horiz_bottom_color;
67 BITCODE_CMC title_vert_left_color;
68 BITCODE_CMC title_vert_ins_color;
69 BITCODE_CMC title_vert_right_color;
70 BITCODE_CMC header_horiz_top_color;
71 BITCODE_CMC header_horiz_ins_color;
72 BITCODE_CMC header_horiz_bottom_color;
73 BITCODE_CMC header_vert_left_color;
74 BITCODE_CMC header_vert_ins_color;
75 BITCODE_CMC header_vert_right_color;
76 BITCODE_CMC data_horiz_top_color;
77 BITCODE_CMC data_horiz_ins_color;
78 BITCODE_CMC data_horiz_bottom_color;
79 BITCODE_CMC data_vert_left_color;
80 BITCODE_CMC data_vert_ins_color;
81 BITCODE_CMC data_vert_right_color;
82
83 BITCODE_B has_border_lineweight_overrides;
84 BITCODE_BL border_lineweight_overrides_flag;
85 BITCODE_BS title_horiz_top_linewt;
86 BITCODE_BS title_horiz_ins_linewt;
87 BITCODE_BS title_horiz_bottom_linewt;
88 BITCODE_BS title_vert_left_linewt;
89 BITCODE_BS title_vert_ins_linewt;
90 BITCODE_BS title_vert_right_linewt;
91 BITCODE_BS header_horiz_top_linewt;
92 BITCODE_BS header_horiz_ins_linewt;
93 BITCODE_BS header_horiz_bottom_linewt;
94 BITCODE_BS header_vert_left_linewt;
95 BITCODE_BS header_vert_ins_linewt;
96 BITCODE_BS header_vert_right_linewt;
97 BITCODE_BS data_horiz_top_linewt;
98 BITCODE_BS data_horiz_ins_linewt;
99 BITCODE_BS data_horiz_bottom_linewt;
100 BITCODE_BS data_vert_left_linewt;
101 BITCODE_BS data_vert_ins_linewt;
102 BITCODE_BS data_vert_right_linewt;
103 BITCODE_B has_border_visibility_overrides;
104 BITCODE_BL border_visibility_overrides_flag;
105 BITCODE_BS title_horiz_top_visibility;
106 BITCODE_BS title_horiz_ins_visibility;
107 BITCODE_BS title_horiz_bottom_visibility;
108 BITCODE_BS title_vert_left_visibility;
109 BITCODE_BS title_vert_ins_visibility;
110 BITCODE_BS title_vert_right_visibility;
111 BITCODE_BS header_horiz_top_visibility;
112 BITCODE_BS header_horiz_ins_visibility;
113 BITCODE_BS header_horiz_bottom_visibility;
114 BITCODE_BS header_vert_left_visibility;
115 BITCODE_BS header_vert_ins_visibility;
116 BITCODE_BS header_vert_right_visibility;
117 BITCODE_BS data_horiz_top_visibility;
118 BITCODE_BS data_horiz_ins_visibility;
119 BITCODE_BS data_horiz_bottom_visibility;
120 BITCODE_BS data_vert_left_visibility;
121 BITCODE_BS data_vert_ins_visibility;
122 BITCODE_BS data_vert_right_visibility;
123 BITCODE_H block_header;
124 BITCODE_H first_attrib;
125 BITCODE_H last_attrib;
126 BITCODE_H *attribs;
127 BITCODE_H seqend;
128 BITCODE_H title_row_style_override;
129 BITCODE_H header_row_style_override;
130 BITCODE_H data_row_style_override;
131 BITCODE_BS unknown_bs;
132 BITCODE_3BD hor_dir;
133 BITCODE_BL has_break_data;
134 BITCODE_BL break_flag;
135 BITCODE_BL break_flow_direction;
136 BITCODE_BD break_spacing;
137 BITCODE_BL break_unknown1;
138 BITCODE_BL break_unknown2;
139 BITCODE_BL num_break_heights;
140 Dwg_TABLE_BreakHeight *break_heights;
141 BITCODE_BL num_break_rows;
142 Dwg_TABLE_BreakRow *break_rows;
143
144 Dwg_Version_Type dwg_version = obj->parent->header.version;
145 dwg_ent_table *table = dwg_object_to_TABLE (obj);
146
147 if (dwg_version >= R_2010)
148 {
149 printf ("TABLECONTENT r2010+ nyi\n"); // TODO
150 // return;
151 }
152
153 CHK_ENTITY_TYPE (table, TABLE, unknown_rc, RC);
154 CHK_ENTITY_H (table, TABLE, unknown_h);
155 CHK_ENTITY_TYPE (table, TABLE, unknown_bl, BL);
156 CHK_ENTITY_TYPE (table, TABLE, unknown_b, B);
157 CHK_ENTITY_TYPE (table, TABLE, unknown_bl1, BL);
158 CHK_ENTITY_3RD (table, TABLE, ins_pt);
159 CHK_ENTITY_3RD (table, TABLE, scale);
160 CHK_ENTITY_TYPE (table, TABLE, scale_flag, BB);
161 CHK_ENTITY_TYPE (table, TABLE, rotation, BD);
162 CHK_ENTITY_MAX (table, TABLE, rotation, BD, MAX_ANGLE);
163 CHK_ENTITY_3RD (table, TABLE, extrusion);
164 CHK_ENTITY_TYPE (table, TABLE, has_attribs, B);
165 CHK_ENTITY_TYPE (table, TABLE, num_owned, BL);
166
167 CHK_ENTITY_H (table, TABLE, tablestyle);
168 CHK_ENTITY_TYPE (table, TABLE, flag_for_table_value, BS);
169 CHK_ENTITY_3RD (table, TABLE, horiz_direction);
170 CHK_ENTITY_TYPE (table, TABLE, num_cols, BL);
171 CHK_ENTITY_TYPE (table, TABLE, num_rows, BL);
172 CHK_ENTITY_TYPE (table, TABLE, num_cells, BLL);
173 // BITCODE_BD* col_widths;
174 // BITCODE_BD* row_heights;
175 if (!dwg_dynapi_entity_value (table, "TABLE", "cells", &cells, NULL))
176 fail ("TABLE.cells");
177 else
178 for (i = 0; i < num_cells; i++)
179 {
180 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, type, BS);
181 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, flags, RC);
182 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, is_merged_value, B);
183 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, is_autofit_flag, B);
184 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, merged_width_flag, BL);
185 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, merged_height_flag, BL);
186 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, rotation, BD);
187 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, additional_data_flag, B);
188 if (cells[i].type == 1)
189 {
190 CHK_SUBCLASS_UTF8TEXT (cells[i], TABLE_Cell, text_value);
191 CHK_SUBCLASS_H (cells[i], TABLE_Cell, text_style);
192 }
193 else
194 {
195 CHK_SUBCLASS_H (cells[i], TABLE_Cell, block_handle);
196 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, block_scale, BD);
197 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, num_attr_defs, BL);
198 if (!dwg_dynapi_subclass_value (&cells[i], "TABLE_Cell",
199 "attr_defs", &attr_defs, NULL))
200 fail ("TABLE.attr_defs");
201 for (j = 0; j < cells[i].num_attr_defs; j++)
202 {
203 CHK_SUBCLASS_H (attr_defs[j], TABLE_AttrDef, attdef);
204 CHK_SUBCLASS_TYPE (attr_defs[j], TABLE_AttrDef, index, BS);
205 CHK_SUBCLASS_UTF8TEXT (attr_defs[j], TABLE_AttrDef, text);
206 }
207 }
208 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, cell_flag_override, BL);
209 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, virtual_edge_flag, RC);
210 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, cell_alignment, RS);
211 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, bg_fill_none, B);
212 CHK_SUBCLASS_CMC (cells[i], TABLE_Cell, bg_color);
213 CHK_SUBCLASS_CMC (cells[i], TABLE_Cell, content_color);
214 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, text_height, BD);
215 CHK_SUBCLASS_CMC (cells[i], TABLE_Cell, top_grid_color);
216 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, top_grid_linewt, BS);
217 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, top_visibility, BS);
218 CHK_SUBCLASS_CMC (cells[i], TABLE_Cell, right_grid_color);
219 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, right_grid_linewt, BS);
220 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, right_visibility, BS);
221 CHK_SUBCLASS_CMC (cells[i], TABLE_Cell, bottom_grid_color);
222 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, bottom_grid_linewt, BS);
223 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, bottom_visibility, BS);
224 CHK_SUBCLASS_CMC (cells[i], TABLE_Cell, left_grid_color);
225 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, left_grid_linewt, BS);
226 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, left_visibility, BS);
227 CHK_SUBCLASS_TYPE (cells[i], TABLE_Cell, unknown, BL);
228 // Dwg_TABLE_value value;
229 }
230 CHK_ENTITY_TYPE (table, TABLE, has_table_overrides, B);
231 CHK_ENTITY_TYPE (table, TABLE, table_flag_override, BL);
232 CHK_ENTITY_TYPE (table, TABLE, title_suppressed, B);
233 CHK_ENTITY_TYPE (table, TABLE, header_suppressed, B);
234 CHK_ENTITY_TYPE (table, TABLE, flow_direction, BS);
235 CHK_ENTITY_TYPE (table, TABLE, horiz_cell_margin, BD);
236 CHK_ENTITY_TYPE (table, TABLE, vert_cell_margin, BD);
237 CHK_ENTITY_CMC (table, TABLE, title_row_color);
238 CHK_ENTITY_CMC (table, TABLE, header_row_color);
239 CHK_ENTITY_CMC (table, TABLE, data_row_color);
240 CHK_ENTITY_TYPE (table, TABLE, title_row_fill_none, B);
241 CHK_ENTITY_TYPE (table, TABLE, header_row_fill_none, B);
242 CHK_ENTITY_TYPE (table, TABLE, data_row_fill_none, B);
243 CHK_ENTITY_CMC (table, TABLE, title_row_fill_color);
244 CHK_ENTITY_CMC (table, TABLE, header_row_fill_color);
245 CHK_ENTITY_CMC (table, TABLE, data_row_fill_color);
246 CHK_ENTITY_TYPE (table, TABLE, title_row_alignment, BS);
247 CHK_ENTITY_TYPE (table, TABLE, header_row_alignment, BS);
248 CHK_ENTITY_TYPE (table, TABLE, data_row_alignment, BS);
249 CHK_ENTITY_H (table, TABLE, title_text_style);
250 CHK_ENTITY_H (table, TABLE, header_text_style);
251 CHK_ENTITY_H (table, TABLE, data_text_style);
252 CHK_ENTITY_TYPE (table, TABLE, title_row_height, BD);
253 CHK_ENTITY_TYPE (table, TABLE, header_row_height, BD);
254 CHK_ENTITY_TYPE (table, TABLE, data_row_height, BD);
255 CHK_ENTITY_TYPE (table, TABLE, has_border_color_overrides, B);
256 CHK_ENTITY_TYPE (table, TABLE, border_color_overrides_flag, BL);
257 CHK_ENTITY_CMC (table, TABLE, title_horiz_top_color);
258 CHK_ENTITY_CMC (table, TABLE, title_horiz_ins_color);
259 CHK_ENTITY_CMC (table, TABLE, title_horiz_bottom_color);
260 CHK_ENTITY_CMC (table, TABLE, title_vert_left_color);
261 CHK_ENTITY_CMC (table, TABLE, title_vert_ins_color);
262 CHK_ENTITY_CMC (table, TABLE, title_vert_right_color);
263 CHK_ENTITY_CMC (table, TABLE, header_horiz_top_color);
264 CHK_ENTITY_CMC (table, TABLE, header_horiz_ins_color);
265 CHK_ENTITY_CMC (table, TABLE, header_horiz_bottom_color);
266 CHK_ENTITY_CMC (table, TABLE, header_vert_left_color);
267 CHK_ENTITY_CMC (table, TABLE, header_vert_ins_color);
268 CHK_ENTITY_CMC (table, TABLE, header_vert_right_color);
269 CHK_ENTITY_CMC (table, TABLE, data_horiz_top_color);
270 CHK_ENTITY_CMC (table, TABLE, data_horiz_ins_color);
271 CHK_ENTITY_CMC (table, TABLE, data_horiz_bottom_color);
272 CHK_ENTITY_CMC (table, TABLE, data_vert_left_color);
273 CHK_ENTITY_CMC (table, TABLE, data_vert_ins_color);
274 CHK_ENTITY_CMC (table, TABLE, data_vert_right_color);
275
276 CHK_ENTITY_TYPE (table, TABLE, has_border_lineweight_overrides, B);
277 CHK_ENTITY_TYPE (table, TABLE, border_lineweight_overrides_flag, BL);
278 CHK_ENTITY_TYPE (table, TABLE, title_horiz_top_linewt, BS);
279 CHK_ENTITY_TYPE (table, TABLE, title_horiz_ins_linewt, BS);
280 CHK_ENTITY_TYPE (table, TABLE, title_horiz_bottom_linewt, BS);
281 CHK_ENTITY_TYPE (table, TABLE, title_vert_left_linewt, BS);
282 CHK_ENTITY_TYPE (table, TABLE, title_vert_ins_linewt, BS);
283 CHK_ENTITY_TYPE (table, TABLE, title_vert_right_linewt, BS);
284 CHK_ENTITY_TYPE (table, TABLE, header_horiz_top_linewt, BS);
285 CHK_ENTITY_TYPE (table, TABLE, header_horiz_ins_linewt, BS);
286 CHK_ENTITY_TYPE (table, TABLE, header_horiz_bottom_linewt, BS);
287 CHK_ENTITY_TYPE (table, TABLE, header_vert_left_linewt, BS);
288 CHK_ENTITY_TYPE (table, TABLE, header_vert_ins_linewt, BS);
289 CHK_ENTITY_TYPE (table, TABLE, header_vert_right_linewt, BS);
290 CHK_ENTITY_TYPE (table, TABLE, data_horiz_top_linewt, BS);
291 CHK_ENTITY_TYPE (table, TABLE, data_horiz_ins_linewt, BS);
292 CHK_ENTITY_TYPE (table, TABLE, data_horiz_bottom_linewt, BS);
293 CHK_ENTITY_TYPE (table, TABLE, data_vert_left_linewt, BS);
294 CHK_ENTITY_TYPE (table, TABLE, data_vert_ins_linewt, BS);
295 CHK_ENTITY_TYPE (table, TABLE, data_vert_right_linewt, BS);
296 CHK_ENTITY_TYPE (table, TABLE, has_border_visibility_overrides, B);
297 CHK_ENTITY_TYPE (table, TABLE, border_visibility_overrides_flag, BL);
298 CHK_ENTITY_TYPE (table, TABLE, title_horiz_top_visibility, BS);
299 CHK_ENTITY_TYPE (table, TABLE, title_horiz_ins_visibility, BS);
300 CHK_ENTITY_TYPE (table, TABLE, title_horiz_bottom_visibility, BS);
301 CHK_ENTITY_TYPE (table, TABLE, title_vert_left_visibility, BS);
302 CHK_ENTITY_TYPE (table, TABLE, title_vert_ins_visibility, BS);
303 CHK_ENTITY_TYPE (table, TABLE, title_vert_right_visibility, BS);
304 CHK_ENTITY_TYPE (table, TABLE, header_horiz_top_visibility, BS);
305 CHK_ENTITY_TYPE (table, TABLE, header_horiz_ins_visibility, BS);
306 CHK_ENTITY_TYPE (table, TABLE, header_horiz_bottom_visibility, BS);
307 CHK_ENTITY_TYPE (table, TABLE, header_vert_left_visibility, BS);
308 CHK_ENTITY_TYPE (table, TABLE, header_vert_ins_visibility, BS);
309 CHK_ENTITY_TYPE (table, TABLE, header_vert_right_visibility, BS);
310 CHK_ENTITY_TYPE (table, TABLE, data_horiz_top_visibility, BS);
311 CHK_ENTITY_TYPE (table, TABLE, data_horiz_ins_visibility, BS);
312 CHK_ENTITY_TYPE (table, TABLE, data_horiz_bottom_visibility, BS);
313 CHK_ENTITY_TYPE (table, TABLE, data_vert_left_visibility, BS);
314 CHK_ENTITY_TYPE (table, TABLE, data_vert_ins_visibility, BS);
315 CHK_ENTITY_TYPE (table, TABLE, data_vert_right_visibility, BS);
316 CHK_ENTITY_H (table, TABLE, block_header);
317 CHK_ENTITY_H (table, TABLE, first_attrib);
318 CHK_ENTITY_H (table, TABLE, last_attrib);
319 // CHK_ENTITY_TYPE (table, TABLE, attribs, H*, attribs);
320 CHK_ENTITY_H (table, TABLE, seqend);
321 CHK_ENTITY_H (table, TABLE, title_row_style_override);
322 CHK_ENTITY_H (table, TABLE, header_row_style_override);
323 CHK_ENTITY_H (table, TABLE, data_row_style_override);
324 CHK_ENTITY_TYPE (table, TABLE, unknown_bs, BS);
325 CHK_ENTITY_3RD (table, TABLE, hor_dir);
326 CHK_ENTITY_TYPE (table, TABLE, has_break_data, BL);
327 CHK_ENTITY_TYPE (table, TABLE, break_flag, BL);
328 CHK_ENTITY_TYPE (table, TABLE, break_flow_direction, BL);
329 CHK_ENTITY_TYPE (table, TABLE, break_spacing, BD);
330 CHK_ENTITY_TYPE (table, TABLE, break_unknown1, BL);
331 CHK_ENTITY_TYPE (table, TABLE, break_unknown2, BL);
332 CHK_ENTITY_TYPE (table, TABLE, num_break_heights, BL);
333 // Dwg_TABLE_BreakHeight *break_heights;
334 CHK_ENTITY_TYPE (table, TABLE, num_break_rows, BL);
335 // Dwg_TABLE_BreakRow *break_rows;
336
337 #if 0
338 if (!dwg_dynapi_entity_value (table, "TABLE", "rowstyles", &rowstyles, NULL))
339 fail ("TABLE.rowstyles");
340 for (i = 0; i < num_rowstyles; i++)
341 {
342 CHK_SUBCLASS_H (rowstyles[i], TABLE_rowstyles, text_style);
343 CHK_SUBCLASS_TYPE (rowstyles[i], TABLE_rowstyles, text_height, BD);
344 CHK_SUBCLASS_TYPE (rowstyles[i], TABLE_rowstyles, text_alignment, BS);
345 CHK_SUBCLASS_CMC (rowstyles[i], TABLE_rowstyles, text_color);
346 CHK_SUBCLASS_CMC (rowstyles[i], TABLE_rowstyles, fill_color);
347 CHK_SUBCLASS_TYPE (rowstyles[i], TABLE_rowstyles, has_bgcolor, B);
348 if (rowstyles[i].num_borders != 6)
349 fail ("TABLE.rowstyles[%d].num_borders %d != 6", i, rowstyles[i].num_borders);
350 for (int j = 0; j < 6; j++)
351 {
352 CHK_SUBCLASS_TYPE (rowstyles[i].borders[j], TABLE_border, linewt, BSd);
353 CHK_SUBCLASS_TYPE (rowstyles[i].borders[j], TABLE_border, visible, B);
354 CHK_SUBCLASS_CMC (rowstyles[i].borders[j], TABLE_border, color);
355 }
356 if (dwg_version >= R_2007)
357 {
358 CHK_SUBCLASS_TYPE (rowstyles[i], TABLE_rowstyles, data_type, BL);
359 CHK_SUBCLASS_TYPE (rowstyles[i], TABLE_rowstyles, unit_type, BL);
360 CHK_SUBCLASS_UTF8TEXT (rowstyles[i], TABLE_rowstyles, format_string);
361 }
362 }
363 #endif
364 }