1 | /* |
1 | /* |
2 | data.c - Part of psiconv, a PSION 5 file formats converter |
2 | data.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
16 | along with this program; if not, write to the Free Software |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ |
18 | */ |
19 | |
19 | |
20 | #include "config.h" |
20 | #include "config.h" |
|
|
21 | #include "compat.h" |
21 | #include <stdlib.h> |
22 | #include <stdlib.h> |
22 | #include <string.h> |
23 | #include <string.h> |
23 | #include "data.h" |
24 | #include "data.h" |
24 | #include "list.h" |
25 | #include "list.h" |
25 | #include "general.h" |
|
|
26 | |
26 | |
27 | static psiconv_color clone_color(psiconv_color color); |
27 | static psiconv_color clone_color(psiconv_color color); |
28 | static psiconv_font clone_font(psiconv_font font); |
28 | static psiconv_font clone_font(psiconv_font font); |
29 | static psiconv_border clone_border(psiconv_border border); |
29 | static psiconv_border clone_border(psiconv_border border); |
30 | static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
30 | static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
31 | static psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs); |
31 | static psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs); |
32 | static void psiconv_free_style_aux(void *style); |
32 | static void psiconv_free_style_aux(void *style); |
33 | static void psiconv_free_in_line_layout_aux(void * layout); |
33 | static void psiconv_free_in_line_layout_aux(void * layout); |
34 | static void psiconv_free_paragraph_aux(void * paragraph); |
34 | static void psiconv_free_paragraph_aux(void * paragraph); |
35 | static void psiconv_free_paint_data_section_aux(void * section); |
35 | static void psiconv_free_paint_data_section_aux(void * section); |
|
|
36 | static void psiconv_free_clipart_section_aux(void * section); |
|
|
37 | static void psiconv_free_formula_aux(void *data); |
|
|
38 | static void psiconv_free_sheet_worksheet_aux (void *data); |
36 | |
39 | |
|
|
40 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
|
|
41 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
|
|
42 | static psiconv_texted_section psiconv_empty_texted_section(void); |
|
|
43 | static psiconv_page_header psiconv_empty_page_header(void); |
|
|
44 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
|
|
45 | static psiconv_word_status_section psiconv_empty_word_status_section(void); |
|
|
46 | static psiconv_word_f psiconv_empty_word_f(void); |
|
|
47 | static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void); |
|
|
48 | static psiconv_formula_list psiconv_empty_formula_list(void); |
|
|
49 | static psiconv_sheet_workbook_section |
|
|
50 | psiconv_empty_sheet_workbook_section(void); |
|
|
51 | static psiconv_sheet_f psiconv_empty_sheet_f(void); |
|
|
52 | static psiconv_texted_f psiconv_empty_texted_f(void); |
|
|
53 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
|
|
54 | static psiconv_pictures psiconv_empty_pictures(void); |
|
|
55 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
|
|
56 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
|
|
57 | static psiconv_sketch_f psiconv_empty_sketch_f(void); |
|
|
58 | static psiconv_clipart_f psiconv_empty_clipart_f(void); |
|
|
59 | static psiconv_cliparts psiconv_empty_cliparts(void); |
|
|
60 | |
|
|
61 | |
|
|
62 | /* Note: these defaults seem to be hard-coded somewhere outside the |
|
|
63 | files themself. */ |
37 | psiconv_character_layout psiconv_basic_character_layout(void) |
64 | psiconv_character_layout psiconv_basic_character_layout(void) |
38 | { |
65 | { |
|
|
66 | /* Make the structures static, to oblige IRIX */ |
39 | struct psiconv_color black = |
67 | static struct psiconv_color_s black = |
40 | { |
68 | { |
41 | 0x00, /* red */ |
69 | 0x00, /* red */ |
42 | 0x00, /* green */ |
70 | 0x00, /* green */ |
43 | 0x00, /* blue */ |
71 | 0x00, /* blue */ |
44 | }; |
72 | }; |
45 | struct psiconv_color white = |
73 | static struct psiconv_color_s white = |
46 | { |
74 | { |
47 | 0xff, /* red */ |
75 | 0xff, /* red */ |
48 | 0xff, /* green */ |
76 | 0xff, /* green */ |
49 | 0xff, /* blue */ |
77 | 0xff, /* blue */ |
50 | }; |
78 | }; |
|
|
79 | static struct psiconv_font_s font = |
|
|
80 | { |
|
|
81 | "Times New Roman", /* name */ |
|
|
82 | 3 /* screenfont */ |
|
|
83 | }; |
51 | struct psiconv_character_layout cl = |
84 | struct psiconv_character_layout_s cl = |
52 | { |
85 | { |
53 | &black, /* color */ |
86 | &black, /* color */ |
54 | &white, /* back_color */ |
87 | &white, /* back_color */ |
55 | 10.0, /* font_size */ |
88 | 10.0, /* font_size */ |
56 | psiconv_bool_false, /* italic */ |
89 | psiconv_bool_false, /* italic */ |
57 | psiconv_bool_false, /* bold */ |
90 | psiconv_bool_false, /* bold */ |
58 | psiconv_normalscript, /* super_sub */ |
91 | psiconv_normalscript, /* super_sub */ |
59 | psiconv_bool_false, /* underline */ |
92 | psiconv_bool_false, /* underline */ |
60 | psiconv_bool_false, /* strike_out */ |
93 | psiconv_bool_false, /* strikethrough */ |
61 | NULL, /* font */ |
94 | &font, /* font */ |
62 | }; |
95 | }; |
63 | |
96 | |
64 | cl.color = malloc(sizeof(*cl.color)); |
|
|
65 | cl.color->red = 0x00; |
|
|
66 | cl.color->green = 0x00; |
|
|
67 | cl.color->blue = 0x00; |
|
|
68 | cl.back_color = malloc(sizeof(*cl.color)); |
|
|
69 | cl.back_color->red = 0xff; |
|
|
70 | cl.back_color->green = 0xff; |
|
|
71 | cl.back_color->blue = 0xff; |
|
|
72 | cl.font = malloc(sizeof(*cl.font)); |
|
|
73 | cl.font->name = strdup("Times New Roman"); |
|
|
74 | cl.font->screenfont = 3; |
|
|
75 | return psiconv_clone_character_layout(&cl); |
97 | return psiconv_clone_character_layout(&cl); |
76 | } |
98 | } |
77 | |
99 | |
|
|
100 | /* Note: these defaults seem to be hard-coded somewhere outside the |
|
|
101 | files themself. */ |
78 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
102 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
79 | { |
103 | { |
80 | char base_font[] = "Times New Roman"; |
|
|
81 | |
|
|
82 | struct psiconv_font font = |
104 | static struct psiconv_font_s font = |
83 | { |
105 | { |
84 | base_font, /* name */ |
106 | "Times New Roman", /* name */ |
85 | 2 /* screenfont */ |
107 | 2 /* screenfont */ |
86 | }; |
108 | }; |
87 | struct psiconv_color black = |
109 | static struct psiconv_color_s black = |
88 | { |
110 | { |
89 | 0x00, /* red */ |
111 | 0x00, /* red */ |
90 | 0x00, /* green */ |
112 | 0x00, /* green */ |
91 | 0x00, /* blue */ |
113 | 0x00, /* blue */ |
92 | }; |
114 | }; |
93 | struct psiconv_color white = |
115 | static struct psiconv_color_s white = |
94 | { |
116 | { |
95 | 0xff, /* red */ |
117 | 0xff, /* red */ |
96 | 0xff, /* green */ |
118 | 0xff, /* green */ |
97 | 0xff, /* blue */ |
119 | 0xff, /* blue */ |
98 | }; |
120 | }; |
99 | struct psiconv_border no_border = |
121 | static struct psiconv_border_s no_border = |
100 | { |
122 | { |
101 | psiconv_border_none, /* kind */ |
123 | psiconv_border_none, /* kind */ |
102 | 1, /* thickness */ |
124 | 1, /* thickness */ |
103 | &black /* color */ |
125 | &black /* color */ |
104 | }; |
126 | }; |
105 | struct psiconv_bullet bullet = |
127 | static struct psiconv_bullet_s bullet = |
106 | { |
128 | { |
107 | psiconv_bool_false, /* on */ |
129 | psiconv_bool_false, /* on */ |
108 | 10.0, /* font_size */ |
130 | 10.0, /* font_size */ |
109 | 0x95, /* character */ |
131 | 0x95, /* character */ |
110 | psiconv_bool_true, /* indent */ |
132 | psiconv_bool_true, /* indent */ |
111 | &black, /* color */ |
133 | &black, /* color */ |
112 | &font, /* font */ |
134 | &font, /* font */ |
113 | }; |
135 | }; |
114 | struct psiconv_all_tabs tabs = |
136 | static struct psiconv_all_tabs_s tabs = |
115 | { |
137 | { |
116 | 0.64, /* normal */ |
138 | 0.64, /* normal */ |
117 | NULL /* kind */ |
139 | NULL /* kind */ |
118 | }; |
140 | }; |
119 | struct psiconv_paragraph_layout pl = |
141 | struct psiconv_paragraph_layout_s pl = |
120 | { |
142 | { |
121 | &white, /* back_color */ |
143 | &white, /* back_color */ |
122 | 0.0, /* indent_left */ |
144 | 0.0, /* indent_left */ |
123 | 0.0, /* indent_right */ |
145 | 0.0, /* indent_right */ |
124 | 0.0, /* indent_first */ |
146 | 0.0, /* indent_first */ |
125 | psiconv_justify_left, /* justify_hor */ |
147 | psiconv_justify_left, /* justify_hor */ |
126 | psiconv_justify_middle,/* justify_ver */ |
148 | psiconv_justify_middle,/* justify_ver */ |
127 | 0.0, /* interline */ |
149 | 10.0, /* linespacing */ |
128 | psiconv_bool_false, /* interline_exact */ |
150 | psiconv_bool_false, /* linespacing_exact */ |
129 | 0.0, /* top_space */ |
151 | 0.0, /* space_above */ |
130 | 0.0, /* bottom_space */ |
152 | 0.0, /* space_below */ |
131 | psiconv_bool_false, /* on_one_page */ |
|
|
132 | psiconv_bool_false, /* together_with */ |
153 | psiconv_bool_false, /* keep_together */ |
|
|
154 | psiconv_bool_false, /* keep_with_next */ |
133 | psiconv_bool_false, /* on_next_page */ |
155 | psiconv_bool_false, /* on_next_page */ |
134 | psiconv_bool_false, /* no_widow_protection */ |
156 | psiconv_bool_false, /* no_widow_protection */ |
|
|
157 | psiconv_bool_false, /* wrap_to_fit_cell */ |
135 | 0.0, /* left_margin */ |
158 | 0.0, /* left_margin */ |
136 | &bullet, /* bullet */ |
159 | &bullet, /* bullet */ |
137 | &no_border, /* left_border */ |
160 | &no_border, /* left_border */ |
138 | &no_border, /* right_border */ |
161 | &no_border, /* right_border */ |
139 | &no_border, /* top_border */ |
162 | &no_border, /* top_border */ |
140 | &no_border, /* bottom_border */ |
163 | &no_border, /* bottom_border */ |
141 | &tabs, /* tabs */ |
164 | &tabs, /* tabs */ |
142 | }; |
165 | }; |
143 | psiconv_paragraph_layout res; |
166 | psiconv_paragraph_layout res; |
144 | |
167 | |
145 | pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab)); |
168 | if (!(pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab_s)))) |
|
|
169 | return NULL; |
146 | res = psiconv_clone_paragraph_layout(&pl); |
170 | res = psiconv_clone_paragraph_layout(&pl); |
147 | psiconv_list_free(pl.tabs->extras); |
171 | psiconv_list_free(pl.tabs->extras); |
148 | return res; |
172 | return res; |
149 | } |
173 | } |
150 | |
174 | |
151 | psiconv_color clone_color(psiconv_color color) |
175 | psiconv_color clone_color(psiconv_color color) |
152 | { |
176 | { |
153 | psiconv_color result; |
177 | psiconv_color result; |
154 | result = malloc(sizeof(*result)); |
178 | if (!(result = malloc(sizeof(*result)))) |
|
|
179 | return NULL; |
155 | *result = *color; |
180 | *result = *color; |
156 | return result; |
181 | return result; |
157 | } |
182 | } |
158 | |
183 | |
159 | psiconv_font clone_font(psiconv_font font) |
184 | psiconv_font clone_font(psiconv_font font) |
160 | { |
185 | { |
161 | psiconv_font result; |
186 | psiconv_font result; |
162 | result = malloc(sizeof(*result)); |
187 | if(!(result = malloc(sizeof(*result)))) |
|
|
188 | goto ERROR1; |
163 | *result = *font; |
189 | *result = *font; |
164 | result->name = strdup(result->name); |
190 | if (!(result->name = strdup(result->name))) |
|
|
191 | goto ERROR2; |
165 | return result; |
192 | return result; |
|
|
193 | ERROR2: |
|
|
194 | free(result); |
|
|
195 | ERROR1: |
|
|
196 | return NULL; |
166 | } |
197 | } |
167 | |
198 | |
168 | psiconv_border clone_border(psiconv_border border) |
199 | psiconv_border clone_border(psiconv_border border) |
169 | { |
200 | { |
170 | psiconv_border result; |
201 | psiconv_border result; |
171 | result = malloc(sizeof(*result)); |
202 | if (!(result = malloc(sizeof(*result)))) |
|
|
203 | goto ERROR1; |
172 | *result = *border; |
204 | *result = *border; |
173 | result->color = clone_color(result->color); |
205 | if(!(result->color = clone_color(result->color))) |
|
|
206 | goto ERROR2; |
174 | return result; |
207 | return result; |
|
|
208 | ERROR2: |
|
|
209 | free(result); |
|
|
210 | ERROR1: |
|
|
211 | return NULL; |
175 | } |
212 | } |
176 | |
213 | |
177 | psiconv_bullet clone_bullet(psiconv_bullet bullet) |
214 | psiconv_bullet clone_bullet(psiconv_bullet bullet) |
178 | { |
215 | { |
179 | psiconv_bullet result; |
216 | psiconv_bullet result; |
180 | result = malloc(sizeof(*result)); |
217 | if (!(result = malloc(sizeof(*result)))) |
|
|
218 | goto ERROR1; |
181 | *result = *bullet; |
219 | *result = *bullet; |
182 | result->font = clone_font(result->font); |
220 | if (!(result->font = clone_font(result->font))) |
|
|
221 | goto ERROR2; |
183 | result->color = clone_color(result->color); |
222 | if (!(result->color = clone_color(result->color))) |
|
|
223 | goto ERROR3; |
184 | return result; |
224 | return result; |
|
|
225 | ERROR3: |
|
|
226 | psiconv_free_font(result->font); |
|
|
227 | ERROR2: |
|
|
228 | free(result); |
|
|
229 | ERROR1: |
|
|
230 | return NULL; |
185 | } |
231 | } |
186 | |
232 | |
187 | psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs) |
233 | psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs) |
188 | { |
234 | { |
189 | psiconv_all_tabs result; |
235 | psiconv_all_tabs result; |
190 | result = malloc(sizeof(*result)); |
236 | if (!(result = malloc(sizeof(*result)))) |
|
|
237 | goto ERROR1; |
191 | *result = *all_tabs; |
238 | *result = *all_tabs; |
192 | result->extras = psiconv_list_clone(result->extras); |
239 | if (!(result->extras = psiconv_list_clone(result->extras))) |
|
|
240 | goto ERROR2; |
193 | return result; |
241 | return result; |
|
|
242 | ERROR2: |
|
|
243 | free(result); |
|
|
244 | ERROR1: |
|
|
245 | return NULL; |
194 | } |
246 | } |
195 | |
247 | |
196 | psiconv_character_layout psiconv_clone_character_layout |
248 | psiconv_character_layout psiconv_clone_character_layout |
197 | (psiconv_character_layout ls) |
249 | (psiconv_character_layout ls) |
198 | { |
250 | { |
199 | psiconv_character_layout result; |
251 | psiconv_character_layout result; |
200 | |
252 | |
201 | result = malloc(sizeof(*result)); |
253 | if (!(result = malloc(sizeof(*result)))) |
|
|
254 | goto ERROR1; |
202 | *result = *ls; |
255 | *result = *ls; |
203 | result->color = clone_color(result->color); |
256 | if (!(result->color = clone_color(result->color))) |
|
|
257 | goto ERROR2; |
204 | result->back_color = clone_color(result->back_color); |
258 | if (!(result->back_color = clone_color(result->back_color))) |
|
|
259 | goto ERROR3; |
205 | result->font = clone_font(result->font); |
260 | if (!(result->font = clone_font(result->font))) |
|
|
261 | goto ERROR4; |
206 | return result; |
262 | return result; |
|
|
263 | ERROR4: |
|
|
264 | psiconv_free_color(result->back_color); |
|
|
265 | ERROR3: |
|
|
266 | psiconv_free_color(result->color); |
|
|
267 | ERROR2: |
|
|
268 | free(result); |
|
|
269 | ERROR1: |
|
|
270 | return NULL; |
207 | } |
271 | } |
208 | |
272 | |
209 | psiconv_paragraph_layout psiconv_clone_paragraph_layout |
273 | psiconv_paragraph_layout psiconv_clone_paragraph_layout |
210 | (psiconv_paragraph_layout ls) |
274 | (psiconv_paragraph_layout ls) |
211 | { |
275 | { |
212 | psiconv_paragraph_layout result; |
276 | psiconv_paragraph_layout result; |
213 | |
277 | |
214 | result = malloc(sizeof(*result)); |
278 | if (!(result = malloc(sizeof(*result)))) |
|
|
279 | goto ERROR1; |
215 | *result = *ls; |
280 | *result = *ls; |
216 | result->back_color = clone_color(result->back_color); |
281 | if (!(result->back_color = clone_color(result->back_color))) |
|
|
282 | goto ERROR2; |
217 | result->bullet = clone_bullet(result->bullet); |
283 | if (!(result->bullet = clone_bullet(result->bullet))) |
|
|
284 | goto ERROR3; |
218 | result->left_border = clone_border(result->left_border); |
285 | if (!(result->left_border = clone_border(result->left_border))) |
|
|
286 | goto ERROR4; |
219 | result->right_border = clone_border(result->right_border); |
287 | if (!(result->right_border = clone_border(result->right_border))) |
|
|
288 | goto ERROR5; |
220 | result->top_border = clone_border(result->top_border); |
289 | if (!(result->top_border = clone_border(result->top_border))) |
|
|
290 | goto ERROR6; |
221 | result->bottom_border = clone_border(result->bottom_border); |
291 | if (!(result->bottom_border = clone_border(result->bottom_border))) |
|
|
292 | goto ERROR7; |
222 | result->tabs = clone_all_tabs(result->tabs); |
293 | if (!(result->tabs = clone_all_tabs(result->tabs))) |
|
|
294 | goto ERROR8; |
223 | return result; |
295 | return result; |
|
|
296 | ERROR8: |
|
|
297 | psiconv_free_border(result->bottom_border); |
|
|
298 | ERROR7: |
|
|
299 | psiconv_free_border(result->top_border); |
|
|
300 | ERROR6: |
|
|
301 | psiconv_free_border(result->right_border); |
|
|
302 | ERROR5: |
|
|
303 | psiconv_free_border(result->left_border); |
|
|
304 | ERROR4: |
|
|
305 | psiconv_free_bullet(result->bullet); |
|
|
306 | ERROR3: |
|
|
307 | psiconv_free_color(result->back_color); |
|
|
308 | ERROR2: |
|
|
309 | free(result); |
|
|
310 | ERROR1: |
|
|
311 | return NULL; |
224 | } |
312 | } |
225 | |
313 | |
226 | psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr) |
314 | psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr) |
227 | { |
315 | { |
228 | if (nr == 0) |
316 | if (nr == 0) |
229 | return ss->normal; |
317 | return ss->normal; |
230 | else |
318 | else |
231 | return psiconv_list_get(ss->styles,0xff - nr); |
319 | return psiconv_list_get(ss->styles,0xff - nr); |
232 | } |
320 | } |
|
|
321 | |
|
|
322 | psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) |
|
|
323 | { |
|
|
324 | return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); |
|
|
325 | } |
|
|
326 | |
|
|
327 | /* TODO: What if a cell is both in a default row and a default column?!? */ |
|
|
328 | psiconv_sheet_cell_layout psiconv_get_default_layout |
|
|
329 | (psiconv_sheet_line_list row_defaults, |
|
|
330 | psiconv_sheet_line_list col_defaults, |
|
|
331 | psiconv_sheet_cell_layout cell_default, |
|
|
332 | int row,int col) |
|
|
333 | { |
|
|
334 | int i; |
|
|
335 | psiconv_sheet_line line; |
|
|
336 | for (i = 0;i < psiconv_list_length(row_defaults);i++) { |
|
|
337 | line = psiconv_list_get(row_defaults,i); |
|
|
338 | if (line->position == row) |
|
|
339 | return line->layout; |
|
|
340 | } |
|
|
341 | for (i = 0;i < psiconv_list_length(col_defaults);i++) { |
|
|
342 | line = psiconv_list_get(col_defaults,i); |
|
|
343 | if (line->position == col) |
|
|
344 | return line->layout; |
|
|
345 | } |
|
|
346 | return cell_default; |
|
|
347 | } |
|
|
348 | |
233 | |
349 | |
234 | void psiconv_free_color (psiconv_color color) |
350 | void psiconv_free_color (psiconv_color color) |
235 | { |
351 | { |
236 | if (color) |
352 | if (color) |
237 | free(color); |
353 | free(color); |
… | |
… | |
454 | psiconv_free_word_styles_section(file->styles_sec); |
570 | psiconv_free_word_styles_section(file->styles_sec); |
455 | free(file); |
571 | free(file); |
456 | } |
572 | } |
457 | } |
573 | } |
458 | |
574 | |
|
|
575 | void psiconv_free_sheet_status_section(psiconv_sheet_status_section section) |
|
|
576 | { |
|
|
577 | if (section) |
|
|
578 | free(section); |
|
|
579 | } |
|
|
580 | |
|
|
581 | void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat) |
|
|
582 | { |
|
|
583 | if (numberformat) |
|
|
584 | free(numberformat); |
|
|
585 | } |
|
|
586 | |
|
|
587 | void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout) |
|
|
588 | { |
|
|
589 | psiconv_free_paragraph_layout(layout->paragraph); |
|
|
590 | psiconv_free_character_layout(layout->character); |
|
|
591 | psiconv_free_sheet_numberformat(layout->numberformat); |
|
|
592 | } |
|
|
593 | |
|
|
594 | void psiconv_free_sheet_cell_aux(void *cell) |
|
|
595 | { |
|
|
596 | psiconv_sheet_cell data = cell; |
|
|
597 | |
|
|
598 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
599 | |
|
|
600 | if ((data->type == psiconv_cell_string) && (data->data.dat_string)) |
|
|
601 | free(data->data.dat_string); |
|
|
602 | } |
|
|
603 | |
|
|
604 | void psiconv_free_sheet_cell(psiconv_sheet_cell cell) |
|
|
605 | { |
|
|
606 | if (cell) { |
|
|
607 | psiconv_free_sheet_cell_aux(cell); |
|
|
608 | free(cell); |
|
|
609 | } |
|
|
610 | } |
|
|
611 | |
|
|
612 | void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list) |
|
|
613 | { |
|
|
614 | if (list) |
|
|
615 | psiconv_list_free_el(list,psiconv_free_sheet_cell_aux); |
|
|
616 | } |
|
|
617 | |
|
|
618 | void psiconv_free_sheet_line_aux(void *line) |
|
|
619 | { |
|
|
620 | psiconv_sheet_line data = line; |
|
|
621 | |
|
|
622 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
623 | } |
|
|
624 | |
|
|
625 | void psiconv_free_sheet_line(psiconv_sheet_line line) |
|
|
626 | { |
|
|
627 | if (line) { |
|
|
628 | psiconv_free_sheet_line_aux(line); |
|
|
629 | free(line); |
|
|
630 | } |
|
|
631 | } |
|
|
632 | |
|
|
633 | void psiconv_free_sheet_line_list(psiconv_sheet_line_list list) |
|
|
634 | { |
|
|
635 | if (list) |
|
|
636 | psiconv_list_free_el(list,psiconv_free_sheet_line_aux); |
|
|
637 | } |
|
|
638 | |
|
|
639 | void psiconv_free_sheet_worksheet_aux (void *data) |
|
|
640 | { |
|
|
641 | psiconv_sheet_worksheet section = data; |
|
|
642 | psiconv_free_sheet_cell_layout(section->default_layout); |
|
|
643 | psiconv_free_sheet_cell_list(section->cells); |
|
|
644 | psiconv_free_sheet_line_list(section->row_default_layouts); |
|
|
645 | psiconv_free_sheet_line_list(section->col_default_layouts); |
|
|
646 | } |
|
|
647 | |
|
|
648 | void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) |
|
|
649 | { |
|
|
650 | if (sheet) { |
|
|
651 | psiconv_free_sheet_worksheet_aux(sheet); |
|
|
652 | free(sheet); |
|
|
653 | } |
|
|
654 | } |
|
|
655 | |
|
|
656 | void psiconv_free_sheet_worksheet_list(psiconv_sheet_worksheet_list list) |
|
|
657 | { |
|
|
658 | if (list) |
|
|
659 | psiconv_list_free_el(list,psiconv_free_sheet_worksheet_aux); |
|
|
660 | } |
|
|
661 | |
|
|
662 | void psiconv_free_formula_aux(void *data) |
|
|
663 | { |
|
|
664 | psiconv_formula formula; |
|
|
665 | formula = data; |
|
|
666 | if (formula->type == psiconv_formula_dat_string) |
|
|
667 | free(formula->data.dat_string); |
|
|
668 | else if ((formula->type != psiconv_formula_dat_int) && |
|
|
669 | (formula->type != psiconv_formula_dat_var) && |
|
|
670 | (formula->type != psiconv_formula_dat_float) && |
|
|
671 | (formula->type != psiconv_formula_dat_cellref) && |
|
|
672 | (formula->type != psiconv_formula_dat_cellblock) && |
|
|
673 | (formula->type != psiconv_formula_dat_vcellblock) && |
|
|
674 | (formula->type != psiconv_formula_mark_opsep) && |
|
|
675 | (formula->type != psiconv_formula_mark_opend) && |
|
|
676 | (formula->type != psiconv_formula_mark_eof) && |
|
|
677 | (formula->type != psiconv_formula_unknown)) |
|
|
678 | psiconv_free_formula_list(formula->data.fun_operands); |
|
|
679 | } |
|
|
680 | |
|
|
681 | void psiconv_free_formula(psiconv_formula formula) |
|
|
682 | { |
|
|
683 | if (formula) { |
|
|
684 | psiconv_free_formula_aux(formula); |
|
|
685 | free(formula); |
|
|
686 | } |
|
|
687 | } |
|
|
688 | |
|
|
689 | void psiconv_free_formula_list(psiconv_formula_list list) |
|
|
690 | { |
|
|
691 | if (list) |
|
|
692 | psiconv_list_free_el(list,psiconv_free_formula_aux); |
|
|
693 | } |
|
|
694 | |
|
|
695 | void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) |
|
|
696 | { |
|
|
697 | if (section) { |
|
|
698 | psiconv_free_formula_list(section->formulas); |
|
|
699 | psiconv_free_sheet_worksheet_list(section->worksheets); |
|
|
700 | free(section); |
|
|
701 | } |
|
|
702 | } |
|
|
703 | |
|
|
704 | void psiconv_free_sheet_f(psiconv_sheet_f file) |
|
|
705 | { |
|
|
706 | if (file) { |
|
|
707 | psiconv_free_page_layout_section(file->page_sec); |
|
|
708 | psiconv_free_sheet_status_section(file->status_sec); |
|
|
709 | psiconv_free_sheet_workbook_section(file->workbook_sec); |
|
|
710 | free(file); |
|
|
711 | } |
|
|
712 | } |
|
|
713 | |
459 | void psiconv_free_texted_f(psiconv_texted_f file) |
714 | void psiconv_free_texted_f(psiconv_texted_f file) |
460 | { |
715 | { |
461 | if (file) { |
716 | if (file) { |
462 | psiconv_free_page_layout_section(file->page_sec); |
717 | psiconv_free_page_layout_section(file->page_sec); |
463 | psiconv_free_texted_section(file->texted_sec); |
718 | psiconv_free_texted_section(file->texted_sec); |
… | |
… | |
487 | { |
742 | { |
488 | if (section) |
743 | if (section) |
489 | psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux); |
744 | psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux); |
490 | } |
745 | } |
491 | |
746 | |
492 | void psiconv_free_mbm_jumptable_section (psiconv_mbm_jumptable_section section) |
747 | void psiconv_free_jumptable_section (psiconv_jumptable_section section) |
493 | { |
748 | { |
494 | if (section) |
749 | if (section) |
495 | psiconv_list_free(section); |
750 | psiconv_list_free(section); |
496 | } |
751 | } |
497 | |
752 | |
498 | void psiconv_free_mbm_f(psiconv_mbm_f file) |
753 | void psiconv_free_mbm_f(psiconv_mbm_f file) |
499 | { |
754 | { |
500 | if (file) { |
755 | if (file) { |
501 | psiconv_free_pictures(file->sections); |
756 | psiconv_free_pictures(file->sections); |
|
|
757 | free(file); |
|
|
758 | } |
|
|
759 | } |
|
|
760 | |
|
|
761 | void psiconv_free_sketch_section(psiconv_sketch_section sec) |
|
|
762 | { |
|
|
763 | if (sec) { |
|
|
764 | psiconv_free_paint_data_section(sec->picture); |
|
|
765 | free(sec); |
|
|
766 | } |
|
|
767 | } |
|
|
768 | |
|
|
769 | void psiconv_free_sketch_f(psiconv_sketch_f file) |
|
|
770 | { |
|
|
771 | if (file) { |
|
|
772 | psiconv_free_sketch_section(file->sketch_sec); |
|
|
773 | free(file); |
|
|
774 | } |
|
|
775 | } |
|
|
776 | |
|
|
777 | void psiconv_free_clipart_section_aux(void *section) |
|
|
778 | { |
|
|
779 | if (section) |
|
|
780 | free(((psiconv_clipart_section ) section)->picture); |
|
|
781 | } |
|
|
782 | |
|
|
783 | void psiconv_free_clipart_section(psiconv_clipart_section section) |
|
|
784 | { |
|
|
785 | if (section) { |
|
|
786 | psiconv_free_clipart_section_aux(section); |
|
|
787 | free(section); |
|
|
788 | } |
|
|
789 | } |
|
|
790 | |
|
|
791 | void psiconv_free_cliparts(psiconv_cliparts section) |
|
|
792 | { |
|
|
793 | if (section) |
|
|
794 | psiconv_list_free_el(section,&psiconv_free_clipart_section_aux); |
|
|
795 | } |
|
|
796 | |
|
|
797 | void psiconv_free_clipart_f(psiconv_clipart_f file) |
|
|
798 | { |
|
|
799 | if (file) { |
|
|
800 | psiconv_free_cliparts(file->sections); |
502 | free(file); |
801 | free(file); |
503 | } |
802 | } |
504 | } |
803 | } |
505 | |
804 | |
506 | void psiconv_free_file(psiconv_file file) |
805 | void psiconv_free_file(psiconv_file file) |
… | |
… | |
510 | psiconv_free_word_f((psiconv_word_f) file->file); |
809 | psiconv_free_word_f((psiconv_word_f) file->file); |
511 | else if (file->type == psiconv_texted_file) |
810 | else if (file->type == psiconv_texted_file) |
512 | psiconv_free_texted_f((psiconv_texted_f) file->file); |
811 | psiconv_free_texted_f((psiconv_texted_f) file->file); |
513 | else if (file->type == psiconv_mbm_file) |
812 | else if (file->type == psiconv_mbm_file) |
514 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
813 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
|
|
814 | else if (file->type == psiconv_sketch_file) |
|
|
815 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
|
|
816 | else if (file->type == psiconv_clipart_file) |
|
|
817 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
|
|
818 | else if (file->type == psiconv_sheet_file) |
|
|
819 | psiconv_free_sheet_f((psiconv_sheet_f) file->file); |
515 | free(file); |
820 | free(file); |
516 | } |
821 | } |
517 | } |
822 | } |
|
|
823 | |
|
|
824 | int psiconv_compare_color(const psiconv_color value1, |
|
|
825 | const psiconv_color value2) |
|
|
826 | { |
|
|
827 | if (!value1 || !value2) |
|
|
828 | return 1; |
|
|
829 | if ((value1->red == value2->red) && |
|
|
830 | (value1->green == value2->green) && |
|
|
831 | (value1->blue == value2->blue)) |
|
|
832 | return 0; |
|
|
833 | else |
|
|
834 | return 1; |
|
|
835 | } |
|
|
836 | |
|
|
837 | int psiconv_compare_font(const psiconv_font value1, |
|
|
838 | const psiconv_font value2) |
|
|
839 | { |
|
|
840 | if (!value1 || !value2 || !value1->name || !value2->name) |
|
|
841 | return 1; |
|
|
842 | if ((value1->screenfont == value2->screenfont) && |
|
|
843 | !strcmp(value1->name,value2->name)) |
|
|
844 | return 0; |
|
|
845 | else |
|
|
846 | return 1; |
|
|
847 | } |
|
|
848 | |
|
|
849 | int psiconv_compare_border(const psiconv_border value1, |
|
|
850 | const psiconv_border value2) |
|
|
851 | { |
|
|
852 | if (!value1 || !value2) |
|
|
853 | return 1; |
|
|
854 | if ((value1->kind == value2->kind) && |
|
|
855 | (value1->thickness == value2->thickness) && |
|
|
856 | !psiconv_compare_color(value1->color,value2->color)) |
|
|
857 | return 0; |
|
|
858 | else |
|
|
859 | return 1; |
|
|
860 | } |
|
|
861 | |
|
|
862 | int psiconv_compare_bullet(const psiconv_bullet value1, |
|
|
863 | const psiconv_bullet value2) |
|
|
864 | { |
|
|
865 | if (!value1 || !value2) |
|
|
866 | return 1; |
|
|
867 | if ((value1->on == value2->on) && |
|
|
868 | (value1->font_size == value2->font_size) && |
|
|
869 | (value1->character == value2->character) && |
|
|
870 | (value1->indent == value2->indent) && |
|
|
871 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
872 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
873 | return 0; |
|
|
874 | else |
|
|
875 | return 1; |
|
|
876 | } |
|
|
877 | |
|
|
878 | int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2) |
|
|
879 | { |
|
|
880 | if (!value1 || !value2) |
|
|
881 | return 1; |
|
|
882 | if ((value1->location == value2->location) && |
|
|
883 | (value1->kind == value2->kind)) |
|
|
884 | return 0; |
|
|
885 | else |
|
|
886 | return 1; |
|
|
887 | } |
|
|
888 | |
|
|
889 | int psiconv_compare_all_tabs(const psiconv_all_tabs value1, |
|
|
890 | const psiconv_all_tabs value2) |
|
|
891 | { |
|
|
892 | int i; |
|
|
893 | |
|
|
894 | if (!value1 || !value2 || !value1->extras || !value2->extras) |
|
|
895 | return 1; |
|
|
896 | |
|
|
897 | if ((value1->normal != value2->normal) || |
|
|
898 | psiconv_list_length(value1->extras) != |
|
|
899 | psiconv_list_length(value2->extras)) |
|
|
900 | return 1; |
|
|
901 | for (i = 0; i < psiconv_list_length(value1->extras); i++) |
|
|
902 | if (psiconv_compare_tab(psiconv_list_get(value1->extras,i), |
|
|
903 | psiconv_list_get(value2->extras,i))) |
|
|
904 | |
|
|
905 | return 1; |
|
|
906 | return 0; |
|
|
907 | } |
|
|
908 | |
|
|
909 | int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1, |
|
|
910 | const psiconv_paragraph_layout value2) |
|
|
911 | { |
|
|
912 | if (!value1 || !value2) |
|
|
913 | return 1; |
|
|
914 | if ((value1->indent_left == value2->indent_left) && |
|
|
915 | (value1->indent_right == value2->indent_right) && |
|
|
916 | (value1->indent_first == value2->indent_first) && |
|
|
917 | (value1->justify_hor == value2->justify_hor) && |
|
|
918 | (value1->justify_ver == value2->justify_ver) && |
|
|
919 | (value1->linespacing == value2->linespacing) && |
|
|
920 | (value1->space_above == value2->space_above) && |
|
|
921 | (value1->space_below == value2->space_below) && |
|
|
922 | (value1->keep_together == value2->keep_together) && |
|
|
923 | (value1->keep_with_next == value2->keep_with_next) && |
|
|
924 | (value1->on_next_page == value2->on_next_page) && |
|
|
925 | (value1->no_widow_protection == value2->no_widow_protection) && |
|
|
926 | (value1->border_distance == value2->border_distance) && |
|
|
927 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
928 | !psiconv_compare_bullet(value1->bullet,value2->bullet) && |
|
|
929 | !psiconv_compare_border(value1->left_border,value2->left_border) && |
|
|
930 | !psiconv_compare_border(value1->right_border,value2->right_border) && |
|
|
931 | !psiconv_compare_border(value1->top_border,value2->top_border) && |
|
|
932 | !psiconv_compare_border(value1->bottom_border,value2->bottom_border) && |
|
|
933 | !psiconv_compare_all_tabs(value1->tabs,value2->tabs)) |
|
|
934 | return 0; |
|
|
935 | else |
|
|
936 | return 1; |
|
|
937 | } |
|
|
938 | |
|
|
939 | |
|
|
940 | int psiconv_compare_character_layout(const psiconv_character_layout value1, |
|
|
941 | const psiconv_character_layout value2) |
|
|
942 | { |
|
|
943 | if (!value1 || !value2) |
|
|
944 | return 1; |
|
|
945 | if ((value1->font_size == value2->font_size) && |
|
|
946 | (value1->italic == value2->italic) && |
|
|
947 | (value1->bold == value2->bold) && |
|
|
948 | (value1->super_sub == value2->super_sub) && |
|
|
949 | (value1->underline == value2->underline) && |
|
|
950 | (value1->strikethrough == value2->strikethrough) && |
|
|
951 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
952 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
953 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
954 | return 0; |
|
|
955 | else |
|
|
956 | return 1; |
|
|
957 | } |
|
|
958 | |
|
|
959 | |
|
|
960 | |
|
|
961 | psiconv_word_styles_section psiconv_empty_word_styles_section(void) |
|
|
962 | { |
|
|
963 | psiconv_word_styles_section result; |
|
|
964 | if (!(result = malloc(sizeof(*result)))) |
|
|
965 | goto ERROR1; |
|
|
966 | if (!(result->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s)))) |
|
|
967 | goto ERROR2; |
|
|
968 | if (!(result->normal = malloc(sizeof(struct psiconv_word_style_s)))) |
|
|
969 | goto ERROR3; |
|
|
970 | if (!(result->normal->character = psiconv_basic_character_layout())) |
|
|
971 | goto ERROR4; |
|
|
972 | if (!(result->normal->paragraph = psiconv_basic_paragraph_layout())) |
|
|
973 | goto ERROR5; |
|
|
974 | result->normal->hotkey = 'N'; |
|
|
975 | result->normal->name = NULL; |
|
|
976 | result->normal->built_in = psiconv_bool_true; |
|
|
977 | result->normal->outline_level = 0; |
|
|
978 | return result; |
|
|
979 | ERROR5: |
|
|
980 | psiconv_free_character_layout(result->normal->character); |
|
|
981 | ERROR4: |
|
|
982 | free(result->normal); |
|
|
983 | ERROR3: |
|
|
984 | psiconv_list_free(result->styles); |
|
|
985 | ERROR2: |
|
|
986 | free(result); |
|
|
987 | ERROR1: |
|
|
988 | return NULL; |
|
|
989 | } |
|
|
990 | |
|
|
991 | psiconv_text_and_layout psiconv_empty_text_and_layout(void) |
|
|
992 | { |
|
|
993 | return psiconv_list_new(sizeof(struct psiconv_paragraph_s)); |
|
|
994 | } |
|
|
995 | |
|
|
996 | psiconv_texted_section psiconv_empty_texted_section(void) |
|
|
997 | { |
|
|
998 | psiconv_texted_section result; |
|
|
999 | if (!(result = malloc(sizeof(*result)))) |
|
|
1000 | goto ERROR1; |
|
|
1001 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
1002 | goto ERROR2; |
|
|
1003 | return result; |
|
|
1004 | ERROR2: |
|
|
1005 | free(result); |
|
|
1006 | ERROR1: |
|
|
1007 | return NULL; |
|
|
1008 | } |
|
|
1009 | |
|
|
1010 | psiconv_page_header psiconv_empty_page_header(void) |
|
|
1011 | { |
|
|
1012 | psiconv_page_header result; |
|
|
1013 | if (!(result = malloc(sizeof(*result)))) |
|
|
1014 | goto ERROR1; |
|
|
1015 | result->on_first_page = psiconv_bool_true; |
|
|
1016 | if (!(result->base_paragraph_layout = psiconv_basic_paragraph_layout())) |
|
|
1017 | goto ERROR2; |
|
|
1018 | if (!(result->base_character_layout = psiconv_basic_character_layout())) |
|
|
1019 | goto ERROR3; |
|
|
1020 | if (!(result->text = psiconv_empty_texted_section())) |
|
|
1021 | goto ERROR4; |
|
|
1022 | return result; |
|
|
1023 | ERROR4: |
|
|
1024 | psiconv_free_character_layout(result->base_character_layout); |
|
|
1025 | ERROR3: |
|
|
1026 | psiconv_free_paragraph_layout(result->base_paragraph_layout); |
|
|
1027 | ERROR2: |
|
|
1028 | free(result); |
|
|
1029 | ERROR1: |
|
|
1030 | return NULL; |
|
|
1031 | } |
|
|
1032 | |
|
|
1033 | psiconv_page_layout_section psiconv_empty_page_layout_section(void) |
|
|
1034 | { |
|
|
1035 | psiconv_page_layout_section result; |
|
|
1036 | if (!(result = malloc(sizeof(*result)))) |
|
|
1037 | goto ERROR1; |
|
|
1038 | result->first_page_nr = 1; |
|
|
1039 | result->header_dist = result->footer_dist = 1.27; |
|
|
1040 | result->left_margin = result->right_margin = 3.175; |
|
|
1041 | result->top_margin = result->bottom_margin = 2.54; |
|
|
1042 | result->page_width = 21.0; |
|
|
1043 | result->page_height = 29.7; |
|
|
1044 | result->landscape = psiconv_bool_false; |
|
|
1045 | if (!(result->header = psiconv_empty_page_header())) |
|
|
1046 | goto ERROR2; |
|
|
1047 | if (!(result->footer = psiconv_empty_page_header())) |
|
|
1048 | goto ERROR3; |
|
|
1049 | return result; |
|
|
1050 | ERROR3: |
|
|
1051 | psiconv_free_page_header(result->header); |
|
|
1052 | ERROR2: |
|
|
1053 | free(result); |
|
|
1054 | ERROR1: |
|
|
1055 | return NULL; |
|
|
1056 | } |
|
|
1057 | |
|
|
1058 | psiconv_word_status_section psiconv_empty_word_status_section(void) |
|
|
1059 | { |
|
|
1060 | psiconv_word_status_section result; |
|
|
1061 | if (!(result = malloc(sizeof(*result)))) |
|
|
1062 | return NULL; |
|
|
1063 | result->show_tabs = result->show_spaces = result->show_paragraph_ends = |
|
|
1064 | result->show_hard_minus = result->show_hard_space = |
|
|
1065 | result->fit_lines_to_screen = psiconv_bool_false; |
|
|
1066 | result->show_full_pictures = result->show_full_graphs = |
|
|
1067 | result->show_top_toolbar = result->show_side_toolbar = |
|
|
1068 | psiconv_bool_true; |
|
|
1069 | result->cursor_position = 0; |
|
|
1070 | result->display_size = 1000; |
|
|
1071 | return result; |
|
|
1072 | } |
|
|
1073 | |
|
|
1074 | psiconv_word_f psiconv_empty_word_f(void) |
|
|
1075 | { |
|
|
1076 | psiconv_word_f result; |
|
|
1077 | if (!(result = malloc(sizeof(*result)))) |
|
|
1078 | goto ERROR1; |
|
|
1079 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1080 | goto ERROR2; |
|
|
1081 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
1082 | goto ERROR3; |
|
|
1083 | if (!(result->status_sec = psiconv_empty_word_status_section())) |
|
|
1084 | goto ERROR4; |
|
|
1085 | if (!(result->styles_sec = psiconv_empty_word_styles_section())) |
|
|
1086 | goto ERROR5; |
|
|
1087 | return result; |
|
|
1088 | ERROR5: |
|
|
1089 | psiconv_free_word_status_section(result->status_sec); |
|
|
1090 | ERROR4: |
|
|
1091 | psiconv_free_text_and_layout(result->paragraphs); |
|
|
1092 | ERROR3: |
|
|
1093 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1094 | ERROR2: |
|
|
1095 | free(result); |
|
|
1096 | ERROR1: |
|
|
1097 | return NULL; |
|
|
1098 | } |
|
|
1099 | |
|
|
1100 | psiconv_sheet_status_section psiconv_empty_sheet_status_section(void) |
|
|
1101 | { |
|
|
1102 | psiconv_sheet_status_section result; |
|
|
1103 | if (!(result = malloc(sizeof(*result)))) |
|
|
1104 | return NULL; |
|
|
1105 | result->show_horizontal_scrollbar = result->show_vertical_scrollbar = |
|
|
1106 | psiconv_triple_auto; |
|
|
1107 | result->show_graph = psiconv_bool_false; |
|
|
1108 | result->show_top_sheet_toolbar = result->show_side_sheet_toolbar = |
|
|
1109 | result->show_top_graph_toolbar = result->show_side_graph_toolbar = |
|
|
1110 | psiconv_bool_true; |
|
|
1111 | result->cursor_row = result->cursor_column = 0; |
|
|
1112 | result->sheet_display_size = result->graph_display_size = 1000; |
|
|
1113 | return result; |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | psiconv_formula_list psiconv_empty_formula_list(void) |
|
|
1117 | { |
|
|
1118 | return psiconv_list_new(sizeof(struct psiconv_formula_s)); |
|
|
1119 | } |
|
|
1120 | |
|
|
1121 | psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) |
|
|
1122 | { |
|
|
1123 | psiconv_sheet_workbook_section result; |
|
|
1124 | if (!(result = malloc(sizeof(*result)))) |
|
|
1125 | goto ERROR1; |
|
|
1126 | if (!(result->formulas = psiconv_empty_formula_list())) |
|
|
1127 | goto ERROR2; |
|
|
1128 | return result; |
|
|
1129 | ERROR2: |
|
|
1130 | free(result); |
|
|
1131 | ERROR1: |
|
|
1132 | return NULL; |
|
|
1133 | } |
|
|
1134 | |
|
|
1135 | |
|
|
1136 | psiconv_sheet_f psiconv_empty_sheet_f(void) |
|
|
1137 | { |
|
|
1138 | psiconv_sheet_f result; |
|
|
1139 | if (!(result = malloc(sizeof(*result)))) |
|
|
1140 | goto ERROR1; |
|
|
1141 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1142 | goto ERROR2; |
|
|
1143 | if (!(result->status_sec = psiconv_empty_sheet_status_section())) |
|
|
1144 | goto ERROR3; |
|
|
1145 | if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section())) |
|
|
1146 | goto ERROR4; |
|
|
1147 | return result; |
|
|
1148 | ERROR4: |
|
|
1149 | psiconv_free_sheet_status_section(result->status_sec); |
|
|
1150 | ERROR3: |
|
|
1151 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1152 | ERROR2: |
|
|
1153 | free(result); |
|
|
1154 | ERROR1: |
|
|
1155 | return NULL; |
|
|
1156 | } |
|
|
1157 | |
|
|
1158 | psiconv_texted_f psiconv_empty_texted_f(void) |
|
|
1159 | { |
|
|
1160 | psiconv_texted_f result; |
|
|
1161 | if (!(result = malloc(sizeof(*result)))) |
|
|
1162 | goto ERROR1; |
|
|
1163 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1164 | goto ERROR2; |
|
|
1165 | if (!(result->texted_sec = psiconv_empty_texted_section())) |
|
|
1166 | goto ERROR3; |
|
|
1167 | return result; |
|
|
1168 | ERROR3: |
|
|
1169 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1170 | ERROR2: |
|
|
1171 | free(result); |
|
|
1172 | ERROR1: |
|
|
1173 | return NULL; |
|
|
1174 | } |
|
|
1175 | |
|
|
1176 | psiconv_paint_data_section psiconv_empty_paint_data_section(void) |
|
|
1177 | { |
|
|
1178 | psiconv_paint_data_section result; |
|
|
1179 | if (!(result = malloc(sizeof(*result)))) |
|
|
1180 | goto ERROR1; |
|
|
1181 | /* Is this correct? */ |
|
|
1182 | result->xsize = result->ysize = result->pic_xsize = result->pic_ysize = 0; |
|
|
1183 | /* Probably forbidden... */ |
|
|
1184 | if (!(result->red = malloc(0))) |
|
|
1185 | goto ERROR2; |
|
|
1186 | if (!(result->green = malloc(0))) |
|
|
1187 | goto ERROR3; |
|
|
1188 | if (!(result->blue = malloc(0))) |
|
|
1189 | goto ERROR4; |
|
|
1190 | return result; |
|
|
1191 | ERROR4: |
|
|
1192 | free(result->green); |
|
|
1193 | ERROR3: |
|
|
1194 | free(result->red); |
|
|
1195 | ERROR2: |
|
|
1196 | free(result); |
|
|
1197 | ERROR1: |
|
|
1198 | return NULL; |
|
|
1199 | } |
|
|
1200 | |
|
|
1201 | |
|
|
1202 | psiconv_pictures psiconv_empty_pictures(void) |
|
|
1203 | { |
|
|
1204 | psiconv_pictures result; |
|
|
1205 | psiconv_paint_data_section pds; |
|
|
1206 | if (!(result = psiconv_list_new(sizeof(struct psiconv_paint_data_section_s)))) |
|
|
1207 | goto ERROR1; |
|
|
1208 | if (!(pds = psiconv_empty_paint_data_section())) |
|
|
1209 | goto ERROR2; |
|
|
1210 | if (psiconv_list_add(result,pds)) |
|
|
1211 | goto ERROR3; |
|
|
1212 | free(pds); |
|
|
1213 | return result; |
|
|
1214 | ERROR3: |
|
|
1215 | psiconv_free_paint_data_section(pds); |
|
|
1216 | ERROR2: |
|
|
1217 | psiconv_list_free(result); |
|
|
1218 | ERROR1: |
|
|
1219 | return NULL; |
|
|
1220 | } |
|
|
1221 | |
|
|
1222 | psiconv_mbm_f psiconv_empty_mbm_f(void) |
|
|
1223 | { |
|
|
1224 | psiconv_mbm_f result; |
|
|
1225 | if (!(result = malloc(sizeof(*result)))) |
|
|
1226 | goto ERROR1; |
|
|
1227 | if (!(result->sections = psiconv_empty_pictures())) |
|
|
1228 | goto ERROR2; |
|
|
1229 | return result; |
|
|
1230 | ERROR2: |
|
|
1231 | free(result); |
|
|
1232 | ERROR1: |
|
|
1233 | return NULL; |
|
|
1234 | } |
|
|
1235 | |
|
|
1236 | psiconv_sketch_section psiconv_empty_sketch_section(void) |
|
|
1237 | { |
|
|
1238 | psiconv_sketch_section result; |
|
|
1239 | if (!(result = malloc(sizeof(*result)))) |
|
|
1240 | goto ERROR1; |
|
|
1241 | result->form_xsize = 320; |
|
|
1242 | result->form_ysize = 200; |
|
|
1243 | result->picture_x_offset = result->picture_y_offset = result->picture_xsize = |
|
|
1244 | result->picture_ysize = 0; |
|
|
1245 | result->magnification_x = result->magnification_y = 1.0; |
|
|
1246 | result->cut_left = result->cut_right = result->cut_top = |
|
|
1247 | result->cut_bottom = 0.0; |
|
|
1248 | if (!(result->picture = psiconv_empty_paint_data_section())) |
|
|
1249 | goto ERROR2; |
|
|
1250 | return result; |
|
|
1251 | ERROR2: |
|
|
1252 | free(result); |
|
|
1253 | ERROR1: |
|
|
1254 | return NULL; |
|
|
1255 | } |
|
|
1256 | |
|
|
1257 | psiconv_sketch_f psiconv_empty_sketch_f(void) |
|
|
1258 | { |
|
|
1259 | psiconv_sketch_f result; |
|
|
1260 | if (!(result = malloc(sizeof(*result)))) |
|
|
1261 | goto ERROR1; |
|
|
1262 | if (!(result->sketch_sec = psiconv_empty_sketch_section())) |
|
|
1263 | goto ERROR2; |
|
|
1264 | return result; |
|
|
1265 | ERROR2: |
|
|
1266 | free(result); |
|
|
1267 | ERROR1: |
|
|
1268 | return NULL; |
|
|
1269 | } |
|
|
1270 | |
|
|
1271 | psiconv_cliparts psiconv_empty_cliparts(void) |
|
|
1272 | { |
|
|
1273 | /* Is this correct? */ |
|
|
1274 | return psiconv_list_new(sizeof(struct psiconv_clipart_section_s)); |
|
|
1275 | } |
|
|
1276 | |
|
|
1277 | psiconv_clipart_f psiconv_empty_clipart_f(void) |
|
|
1278 | { |
|
|
1279 | psiconv_clipart_f result; |
|
|
1280 | if (!(result = malloc(sizeof(*result)))) |
|
|
1281 | goto ERROR1; |
|
|
1282 | if (!(result->sections = psiconv_empty_cliparts())) |
|
|
1283 | goto ERROR2; |
|
|
1284 | return result; |
|
|
1285 | ERROR2: |
|
|
1286 | free(result); |
|
|
1287 | ERROR1: |
|
|
1288 | return NULL; |
|
|
1289 | } |
|
|
1290 | |
|
|
1291 | psiconv_file psiconv_empty_file(psiconv_file_type_t type) |
|
|
1292 | { |
|
|
1293 | psiconv_file result; |
|
|
1294 | if (!(result = malloc(sizeof(*result)))) |
|
|
1295 | return NULL; |
|
|
1296 | result->type = type; |
|
|
1297 | if (type == psiconv_word_file) { |
|
|
1298 | if (!(result->file = psiconv_empty_word_f())) |
|
|
1299 | goto ERROR; |
|
|
1300 | } else if (type == psiconv_sheet_file) { |
|
|
1301 | if (!(result->file = psiconv_empty_sheet_f())) |
|
|
1302 | goto ERROR; |
|
|
1303 | } else if (type == psiconv_texted_file) { |
|
|
1304 | if (!(result->file = psiconv_empty_texted_f())) |
|
|
1305 | goto ERROR; |
|
|
1306 | } else if (type == psiconv_mbm_file) { |
|
|
1307 | if (!(result->file = psiconv_empty_mbm_f())) |
|
|
1308 | goto ERROR; |
|
|
1309 | } else if (type == psiconv_sketch_file) { |
|
|
1310 | if (!(result->file = psiconv_empty_sketch_f())) |
|
|
1311 | goto ERROR; |
|
|
1312 | } else if (type == psiconv_clipart_file) { |
|
|
1313 | if (!(result->file = psiconv_empty_clipart_f())) |
|
|
1314 | goto ERROR; |
|
|
1315 | } else |
|
|
1316 | goto ERROR; |
|
|
1317 | return result; |
|
|
1318 | ERROR: |
|
|
1319 | free(result); |
|
|
1320 | return NULL; |
|
|
1321 | } |