1 // TODO unstable
2 #define DWG_TYPE DWG_TYPE_TABLESTYLE
3 #include "common.c"
4
5 void
6 api_process (dwg_object *obj)
7 {
8 int error, isnew;
9 BITCODE_BS class_version;
10 BITCODE_BS flags;
11 BITCODE_BS flow_direction;
12 BITCODE_BD horiz_cell_margin;
13 BITCODE_BD vert_cell_margin;
14 BITCODE_B is_title_suppressed;
15 BITCODE_B is_header_suppressed;
16 BITCODE_BL i, j, num_rowstyles;
17 Dwg_TABLESTYLE_rowstyles *rowstyles;
18 Dwg_TABLESTYLE_CellStyle sty;
19 BITCODE_RC unknown_rc;
20 BITCODE_BL unknown_bl1;
21 BITCODE_BL unknown_bl2;
22 BITCODE_H cellstyle;
23
24 Dwg_Version_Type dwg_version = obj->parent->header.version;
25 dwg_obj_tablestyle *tblstyle = dwg_object_to_TABLESTYLE (obj);
26
27 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, class_version, BL);
28 {
29 BITCODE_T name;
30 CHK_ENTITY_UTF8TEXT (tblstyle, TABLESTYLE, name);
31 }
32 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, flow_direction, BS);
33 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, horiz_cell_margin, BD);
34 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, vert_cell_margin, BD);
35 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, is_title_suppressed, B);
36 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, is_header_suppressed, B);
37 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, num_rowstyles, BL);
38 if (num_rowstyles != 3)
39 fail ("TABLESTYLE.num_rowstyles %d != 3", num_rowstyles);
40 if (!dwg_dynapi_entity_value (tblstyle, "TABLESTYLE", "rowstyles",
41 &rowstyles, NULL))
42 fail ("TABLESTYLE.rowstyles");
43
44 #ifndef DEBUG_CLASSS
45 if (dwg_version >= R_2010)
46 {
47 printf ("skip: TABLESTYLE r2010+ not yet implemented\n");
48 }
49 #else
50 if (dwg_version >= R_2010)
51 {
52 BITCODE_T name;
53 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, unknown_rc, RC);
54 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, unknown_bl1, BL);
55 CHK_ENTITY_TYPE (tblstyle, TABLESTYLE, unknown_bl2, BL);
56 CHK_ENTITY_H (tblstyle, TABLESTYLE, cellstyle);
57
58 if (!dwg_dynapi_entity_value (tblstyle, "TABLESTYLE", "sty", &sty, NULL))
59 fail ("TABLESTYLE.sty");
60 CHK_SUBCLASS_TYPE (sty, TABLESTYLE_CellStyle, id, BL);
61 CHK_SUBCLASS_TYPE (sty, TABLESTYLE_CellStyle, type, BL);
62 CHK_SUBCLASS_MAX (sty, TABLESTYLE_CellStyle, type, BL, 2);
63 // CHK_SUBCLASS_UTF8TEXT (sty, TABLESTYLE_CellStyle, name);
64
65 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, type, BL);
66 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, data_flags, BS);
67 if (sty.cellstyle.data_flags)
68 {
69 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, property_override_flags,
70 BL);
71 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, merge_flags, BL);
72 CHK_SUBCLASS_CMC (sty.cellstyle, CellStyle, bg_color);
73 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, content_layout, BL);
74 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
75 property_override_flags, BL);
76 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
77 property_override_flags, BL);
78 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
79 property_flags, BL);
80 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
81 value_data_type, BL);
82 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
83 value_unit_type, BL);
84 CHK_SUBCLASS_UTF8TEXT (sty.cellstyle.content_format, ContentFormat,
85 value_format_string);
86 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
87 rotation, BD);
88 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
89 block_scale, BD);
90 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
91 cell_alignment, BL);
92 CHK_SUBCLASS_CMC (sty.cellstyle.content_format, ContentFormat,
93 content_color);
94 CHK_SUBCLASS_H (sty.cellstyle.content_format, ContentFormat,
95 text_style);
96 CHK_SUBCLASS_TYPE (sty.cellstyle.content_format, ContentFormat,
97 text_height, BD);
98 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, margin_override_flags,
99 BS);
100 if (sty.cellstyle.margin_override_flags)
101 {
102 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, vert_margin, BD);
103 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, horiz_margin, BD);
104 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, bottom_margin, BD);
105 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, right_margin, BD);
106 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle,
107 margin_horiz_spacing, BD);
108 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, margin_vert_spacing,
109 BD);
110 }
111 }
112 CHK_SUBCLASS_TYPE (sty.cellstyle, CellStyle, num_borders, BL);
113 for (j = 0; j < sty.cellstyle.num_borders; j++)
114 {
115 CHK_SUBCLASS_TYPE (sty.cellstyle.borders[j], GridFormat, index_mask,
116 BL);
117 if (!sty.cellstyle.borders[j].index_mask)
118 continue;
119 CHK_SUBCLASS_TYPE (sty.cellstyle.borders[j], GridFormat,
120 border_overrides, BL);
121 CHK_SUBCLASS_TYPE (sty.cellstyle.borders[j], GridFormat, border_type,
122 BL);
123 CHK_SUBCLASS_CMC (sty.cellstyle.borders[j], GridFormat, color);
124 CHK_SUBCLASS_TYPE (sty.cellstyle.borders[j], GridFormat, linewt,
125 BLd);
126 CHK_SUBCLASS_H (sty.cellstyle.borders[j], GridFormat, ltype);
127 CHK_SUBCLASS_TYPE (sty.cellstyle.borders[j], GridFormat, visible, B);
128 CHK_SUBCLASS_TYPE (sty.cellstyle.borders[j], GridFormat,
129 double_line_spacing, BD);
130 }
131 }
132 #endif
133
134 for (i = 0; i < num_rowstyles; i++)
135 {
136 CHK_SUBCLASS_H (rowstyles[i], TABLESTYLE_rowstyles, text_style);
137 CHK_SUBCLASS_TYPE (rowstyles[i], TABLESTYLE_rowstyles, text_height, BD);
138 CHK_SUBCLASS_TYPE (rowstyles[i], TABLESTYLE_rowstyles, text_alignment,
139 BS);
140 CHK_SUBCLASS_CMC (rowstyles[i], TABLESTYLE_rowstyles, text_color);
141 CHK_SUBCLASS_CMC (rowstyles[i], TABLESTYLE_rowstyles, fill_color);
142 CHK_SUBCLASS_TYPE (rowstyles[i], TABLESTYLE_rowstyles, has_bgcolor, B);
143 if (rowstyles[i].num_borders != 6)
144 fail ("TABLESTYLE.rowstyles[%d].num_borders %d != 6", i,
145 rowstyles[i].num_borders);
146 if (rowstyles[i].borders)
147 for (j = 0; j < 6; j++)
148 {
149 CHK_SUBCLASS_TYPE (rowstyles[i].borders[j], TABLESTYLE_border,
150 linewt, BSd);
151 CHK_SUBCLASS_TYPE (rowstyles[i].borders[j], TABLESTYLE_border,
152 visible, B);
153 CHK_SUBCLASS_CMC (rowstyles[i].borders[j], TABLESTYLE_border,
154 color);
155 }
156 if (dwg_version >= R_2007)
157 {
158 CHK_SUBCLASS_TYPE (rowstyles[i], TABLESTYLE_rowstyles, data_type,
159 BL);
160 CHK_SUBCLASS_TYPE (rowstyles[i], TABLESTYLE_rowstyles, unit_type,
161 BL);
162 CHK_SUBCLASS_UTF8TEXT (rowstyles[i], TABLESTYLE_rowstyles,
163 format_string);
164 }
165 }
166 }