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); |
36 | |
38 | |
|
|
39 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
|
|
40 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
|
|
41 | static psiconv_texted_section psiconv_empty_texted_section(void); |
|
|
42 | static psiconv_page_header psiconv_empty_page_header(void); |
|
|
43 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
|
|
44 | static psiconv_word_status_section psiconv_empty_word_status_section(void); |
|
|
45 | static psiconv_word_f psiconv_empty_word_f(void); |
|
|
46 | static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void); |
|
|
47 | static psiconv_formula_list psiconv_empty_formula_list(void); |
|
|
48 | static psiconv_sheet_workbook_section |
|
|
49 | psiconv_empty_sheet_workbook_section(void); |
|
|
50 | static psiconv_sheet_f psiconv_empty_sheet_f(void); |
|
|
51 | static psiconv_texted_f psiconv_empty_texted_f(void); |
|
|
52 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
|
|
53 | static psiconv_pictures psiconv_empty_pictures(void); |
|
|
54 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
|
|
55 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
|
|
56 | static psiconv_sketch_f psiconv_empty_sketch_f(void); |
|
|
57 | static psiconv_clipart_f psiconv_empty_clipart_f(void); |
|
|
58 | static psiconv_cliparts psiconv_empty_cliparts(void); |
|
|
59 | |
|
|
60 | |
|
|
61 | /* Note: these defaults seem to be hard-coded somewhere outside the |
|
|
62 | files themself. */ |
37 | psiconv_character_layout psiconv_basic_character_layout(void) |
63 | psiconv_character_layout psiconv_basic_character_layout(void) |
38 | { |
64 | { |
|
|
65 | /* Make the structures static, to oblige IRIX */ |
39 | struct psiconv_color black = |
66 | static struct psiconv_color_s black = |
40 | { |
67 | { |
41 | 0x00, /* red */ |
68 | 0x00, /* red */ |
42 | 0x00, /* green */ |
69 | 0x00, /* green */ |
43 | 0x00, /* blue */ |
70 | 0x00, /* blue */ |
44 | }; |
71 | }; |
45 | struct psiconv_color white = |
72 | static struct psiconv_color_s white = |
46 | { |
73 | { |
47 | 0xff, /* red */ |
74 | 0xff, /* red */ |
48 | 0xff, /* green */ |
75 | 0xff, /* green */ |
49 | 0xff, /* blue */ |
76 | 0xff, /* blue */ |
50 | }; |
77 | }; |
|
|
78 | static struct psiconv_font_s font = |
|
|
79 | { |
|
|
80 | "Times New Roman", /* name */ |
|
|
81 | 3 /* screenfont */ |
|
|
82 | }; |
51 | struct psiconv_character_layout cl = |
83 | struct psiconv_character_layout_s cl = |
52 | { |
84 | { |
53 | &black, /* color */ |
85 | &black, /* color */ |
54 | &white, /* back_color */ |
86 | &white, /* back_color */ |
55 | 10.0, /* font_size */ |
87 | 10.0, /* font_size */ |
56 | psiconv_bool_false, /* italic */ |
88 | psiconv_bool_false, /* italic */ |
57 | psiconv_bool_false, /* bold */ |
89 | psiconv_bool_false, /* bold */ |
58 | psiconv_normalscript, /* super_sub */ |
90 | psiconv_normalscript, /* super_sub */ |
59 | psiconv_bool_false, /* underline */ |
91 | psiconv_bool_false, /* underline */ |
60 | psiconv_bool_false, /* strike_out */ |
92 | psiconv_bool_false, /* strikethrough */ |
61 | NULL, /* font */ |
93 | &font, /* font */ |
62 | }; |
94 | }; |
63 | |
95 | |
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); |
96 | return psiconv_clone_character_layout(&cl); |
76 | } |
97 | } |
77 | |
98 | |
|
|
99 | /* Note: these defaults seem to be hard-coded somewhere outside the |
|
|
100 | files themself. */ |
78 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
101 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
79 | { |
102 | { |
80 | char base_font[] = "Times New Roman"; |
|
|
81 | |
|
|
82 | struct psiconv_font font = |
103 | static struct psiconv_font_s font = |
83 | { |
104 | { |
84 | base_font, /* name */ |
105 | "Times New Roman", /* name */ |
85 | 2 /* screenfont */ |
106 | 2 /* screenfont */ |
86 | }; |
107 | }; |
87 | struct psiconv_color black = |
108 | static struct psiconv_color_s black = |
88 | { |
109 | { |
89 | 0x00, /* red */ |
110 | 0x00, /* red */ |
90 | 0x00, /* green */ |
111 | 0x00, /* green */ |
91 | 0x00, /* blue */ |
112 | 0x00, /* blue */ |
92 | }; |
113 | }; |
93 | struct psiconv_color white = |
114 | static struct psiconv_color_s white = |
94 | { |
115 | { |
95 | 0xff, /* red */ |
116 | 0xff, /* red */ |
96 | 0xff, /* green */ |
117 | 0xff, /* green */ |
97 | 0xff, /* blue */ |
118 | 0xff, /* blue */ |
98 | }; |
119 | }; |
99 | struct psiconv_border no_border = |
120 | static struct psiconv_border_s no_border = |
100 | { |
121 | { |
101 | psiconv_border_none, /* kind */ |
122 | psiconv_border_none, /* kind */ |
102 | 1, /* thickness */ |
123 | 1, /* thickness */ |
103 | &black /* color */ |
124 | &black /* color */ |
104 | }; |
125 | }; |
105 | struct psiconv_bullet bullet = |
126 | static struct psiconv_bullet_s bullet = |
106 | { |
127 | { |
107 | psiconv_bool_false, /* on */ |
128 | psiconv_bool_false, /* on */ |
108 | 10.0, /* font_size */ |
129 | 10.0, /* font_size */ |
109 | 0x95, /* character */ |
130 | 0x95, /* character */ |
110 | psiconv_bool_true, /* indent */ |
131 | psiconv_bool_true, /* indent */ |
111 | &black, /* color */ |
132 | &black, /* color */ |
112 | &font, /* font */ |
133 | &font, /* font */ |
113 | }; |
134 | }; |
114 | struct psiconv_all_tabs tabs = |
135 | static struct psiconv_all_tabs_s tabs = |
115 | { |
136 | { |
116 | 0.64, /* normal */ |
137 | 0.64, /* normal */ |
117 | NULL /* kind */ |
138 | NULL /* kind */ |
118 | }; |
139 | }; |
119 | struct psiconv_paragraph_layout pl = |
140 | struct psiconv_paragraph_layout_s pl = |
120 | { |
141 | { |
121 | &white, /* back_color */ |
142 | &white, /* back_color */ |
122 | 0.0, /* indent_left */ |
143 | 0.0, /* indent_left */ |
123 | 0.0, /* indent_right */ |
144 | 0.0, /* indent_right */ |
124 | 0.0, /* indent_first */ |
145 | 0.0, /* indent_first */ |
125 | psiconv_justify_left, /* justify_hor */ |
146 | psiconv_justify_left, /* justify_hor */ |
126 | psiconv_justify_middle,/* justify_ver */ |
147 | psiconv_justify_middle,/* justify_ver */ |
127 | 0.0, /* interline */ |
148 | 10.0, /* linespacing */ |
128 | psiconv_bool_false, /* interline_exact */ |
149 | psiconv_bool_false, /* linespacing_exact */ |
129 | 0.0, /* top_space */ |
150 | 0.0, /* space_above */ |
130 | 0.0, /* bottom_space */ |
151 | 0.0, /* space_below */ |
131 | psiconv_bool_false, /* on_one_page */ |
|
|
132 | psiconv_bool_false, /* together_with */ |
152 | psiconv_bool_false, /* keep_together */ |
|
|
153 | psiconv_bool_false, /* keep_with_next */ |
133 | psiconv_bool_false, /* on_next_page */ |
154 | psiconv_bool_false, /* on_next_page */ |
134 | psiconv_bool_false, /* no_widow_protection */ |
155 | psiconv_bool_false, /* no_widow_protection */ |
135 | 0.0, /* left_margin */ |
156 | 0.0, /* left_margin */ |
136 | &bullet, /* bullet */ |
157 | &bullet, /* bullet */ |
137 | &no_border, /* left_border */ |
158 | &no_border, /* left_border */ |
… | |
… | |
140 | &no_border, /* bottom_border */ |
161 | &no_border, /* bottom_border */ |
141 | &tabs, /* tabs */ |
162 | &tabs, /* tabs */ |
142 | }; |
163 | }; |
143 | psiconv_paragraph_layout res; |
164 | psiconv_paragraph_layout res; |
144 | |
165 | |
145 | pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab)); |
166 | if (!(pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab_s)))) |
|
|
167 | return NULL; |
146 | res = psiconv_clone_paragraph_layout(&pl); |
168 | res = psiconv_clone_paragraph_layout(&pl); |
147 | psiconv_list_free(pl.tabs->extras); |
169 | psiconv_list_free(pl.tabs->extras); |
148 | return res; |
170 | return res; |
149 | } |
171 | } |
150 | |
172 | |
151 | psiconv_color clone_color(psiconv_color color) |
173 | psiconv_color clone_color(psiconv_color color) |
152 | { |
174 | { |
153 | psiconv_color result; |
175 | psiconv_color result; |
154 | result = malloc(sizeof(*result)); |
176 | if (!(result = malloc(sizeof(*result)))) |
|
|
177 | return NULL; |
155 | *result = *color; |
178 | *result = *color; |
156 | return result; |
179 | return result; |
157 | } |
180 | } |
158 | |
181 | |
159 | psiconv_font clone_font(psiconv_font font) |
182 | psiconv_font clone_font(psiconv_font font) |
160 | { |
183 | { |
161 | psiconv_font result; |
184 | psiconv_font result; |
162 | result = malloc(sizeof(*result)); |
185 | if(!(result = malloc(sizeof(*result)))) |
|
|
186 | goto ERROR1; |
163 | *result = *font; |
187 | *result = *font; |
164 | result->name = strdup(result->name); |
188 | if (!(result->name = strdup(result->name))) |
|
|
189 | goto ERROR2; |
165 | return result; |
190 | return result; |
|
|
191 | ERROR2: |
|
|
192 | free(result); |
|
|
193 | ERROR1: |
|
|
194 | return NULL; |
166 | } |
195 | } |
167 | |
196 | |
168 | psiconv_border clone_border(psiconv_border border) |
197 | psiconv_border clone_border(psiconv_border border) |
169 | { |
198 | { |
170 | psiconv_border result; |
199 | psiconv_border result; |
171 | result = malloc(sizeof(*result)); |
200 | if (!(result = malloc(sizeof(*result)))) |
|
|
201 | goto ERROR1; |
172 | *result = *border; |
202 | *result = *border; |
173 | result->color = clone_color(result->color); |
203 | if(!(result->color = clone_color(result->color))) |
|
|
204 | goto ERROR2; |
174 | return result; |
205 | return result; |
|
|
206 | ERROR2: |
|
|
207 | free(result); |
|
|
208 | ERROR1: |
|
|
209 | return NULL; |
175 | } |
210 | } |
176 | |
211 | |
177 | psiconv_bullet clone_bullet(psiconv_bullet bullet) |
212 | psiconv_bullet clone_bullet(psiconv_bullet bullet) |
178 | { |
213 | { |
179 | psiconv_bullet result; |
214 | psiconv_bullet result; |
180 | result = malloc(sizeof(*result)); |
215 | if (!(result = malloc(sizeof(*result)))) |
|
|
216 | goto ERROR1; |
181 | *result = *bullet; |
217 | *result = *bullet; |
182 | result->font = clone_font(result->font); |
218 | if (!(result->font = clone_font(result->font))) |
|
|
219 | goto ERROR2; |
183 | result->color = clone_color(result->color); |
220 | if (!(result->color = clone_color(result->color))) |
|
|
221 | goto ERROR3; |
184 | return result; |
222 | return result; |
|
|
223 | ERROR3: |
|
|
224 | psiconv_free_font(result->font); |
|
|
225 | ERROR2: |
|
|
226 | free(result); |
|
|
227 | ERROR1: |
|
|
228 | return NULL; |
185 | } |
229 | } |
186 | |
230 | |
187 | psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs) |
231 | psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs) |
188 | { |
232 | { |
189 | psiconv_all_tabs result; |
233 | psiconv_all_tabs result; |
190 | result = malloc(sizeof(*result)); |
234 | if (!(result = malloc(sizeof(*result)))) |
|
|
235 | goto ERROR1; |
191 | *result = *all_tabs; |
236 | *result = *all_tabs; |
192 | result->extras = psiconv_list_clone(result->extras); |
237 | if (!(result->extras = psiconv_list_clone(result->extras))) |
|
|
238 | goto ERROR2; |
193 | return result; |
239 | return result; |
|
|
240 | ERROR2: |
|
|
241 | free(result); |
|
|
242 | ERROR1: |
|
|
243 | return NULL; |
194 | } |
244 | } |
195 | |
245 | |
196 | psiconv_character_layout psiconv_clone_character_layout |
246 | psiconv_character_layout psiconv_clone_character_layout |
197 | (psiconv_character_layout ls) |
247 | (psiconv_character_layout ls) |
198 | { |
248 | { |
199 | psiconv_character_layout result; |
249 | psiconv_character_layout result; |
200 | |
250 | |
201 | result = malloc(sizeof(*result)); |
251 | if (!(result = malloc(sizeof(*result)))) |
|
|
252 | goto ERROR1; |
202 | *result = *ls; |
253 | *result = *ls; |
203 | result->color = clone_color(result->color); |
254 | if (!(result->color = clone_color(result->color))) |
|
|
255 | goto ERROR2; |
204 | result->back_color = clone_color(result->back_color); |
256 | if (!(result->back_color = clone_color(result->back_color))) |
|
|
257 | goto ERROR3; |
205 | result->font = clone_font(result->font); |
258 | if (!(result->font = clone_font(result->font))) |
|
|
259 | goto ERROR4; |
206 | return result; |
260 | return result; |
|
|
261 | ERROR4: |
|
|
262 | psiconv_free_color(result->back_color); |
|
|
263 | ERROR3: |
|
|
264 | psiconv_free_color(result->color); |
|
|
265 | ERROR2: |
|
|
266 | free(result); |
|
|
267 | ERROR1: |
|
|
268 | return NULL; |
207 | } |
269 | } |
208 | |
270 | |
209 | psiconv_paragraph_layout psiconv_clone_paragraph_layout |
271 | psiconv_paragraph_layout psiconv_clone_paragraph_layout |
210 | (psiconv_paragraph_layout ls) |
272 | (psiconv_paragraph_layout ls) |
211 | { |
273 | { |
212 | psiconv_paragraph_layout result; |
274 | psiconv_paragraph_layout result; |
213 | |
275 | |
214 | result = malloc(sizeof(*result)); |
276 | if (!(result = malloc(sizeof(*result)))) |
|
|
277 | goto ERROR1; |
215 | *result = *ls; |
278 | *result = *ls; |
216 | result->back_color = clone_color(result->back_color); |
279 | if (!(result->back_color = clone_color(result->back_color))) |
|
|
280 | goto ERROR2; |
217 | result->bullet = clone_bullet(result->bullet); |
281 | if (!(result->bullet = clone_bullet(result->bullet))) |
|
|
282 | goto ERROR3; |
218 | result->left_border = clone_border(result->left_border); |
283 | if (!(result->left_border = clone_border(result->left_border))) |
|
|
284 | goto ERROR4; |
219 | result->right_border = clone_border(result->right_border); |
285 | if (!(result->right_border = clone_border(result->right_border))) |
|
|
286 | goto ERROR5; |
220 | result->top_border = clone_border(result->top_border); |
287 | if (!(result->top_border = clone_border(result->top_border))) |
|
|
288 | goto ERROR6; |
221 | result->bottom_border = clone_border(result->bottom_border); |
289 | if (!(result->bottom_border = clone_border(result->bottom_border))) |
|
|
290 | goto ERROR7; |
222 | result->tabs = clone_all_tabs(result->tabs); |
291 | if (!(result->tabs = clone_all_tabs(result->tabs))) |
|
|
292 | goto ERROR8; |
223 | return result; |
293 | return result; |
|
|
294 | ERROR8: |
|
|
295 | psiconv_free_border(result->bottom_border); |
|
|
296 | ERROR7: |
|
|
297 | psiconv_free_border(result->top_border); |
|
|
298 | ERROR6: |
|
|
299 | psiconv_free_border(result->right_border); |
|
|
300 | ERROR5: |
|
|
301 | psiconv_free_border(result->left_border); |
|
|
302 | ERROR4: |
|
|
303 | psiconv_free_bullet(result->bullet); |
|
|
304 | ERROR3: |
|
|
305 | psiconv_free_color(result->back_color); |
|
|
306 | ERROR2: |
|
|
307 | free(result); |
|
|
308 | ERROR1: |
|
|
309 | return NULL; |
224 | } |
310 | } |
225 | |
311 | |
226 | psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr) |
312 | psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr) |
227 | { |
313 | { |
228 | if (nr == 0) |
314 | if (nr == 0) |
… | |
… | |
454 | psiconv_free_word_styles_section(file->styles_sec); |
540 | psiconv_free_word_styles_section(file->styles_sec); |
455 | free(file); |
541 | free(file); |
456 | } |
542 | } |
457 | } |
543 | } |
458 | |
544 | |
|
|
545 | void psiconv_free_sheet_status_section(psiconv_sheet_status_section section) |
|
|
546 | { |
|
|
547 | if (section) |
|
|
548 | free(section); |
|
|
549 | } |
|
|
550 | |
|
|
551 | void psiconv_free_formula_aux(void *data) |
|
|
552 | { |
|
|
553 | psiconv_formula formula; |
|
|
554 | formula = data; |
|
|
555 | if (formula->type == psiconv_formula_dat_string) |
|
|
556 | free(formula->data.dat_string); |
|
|
557 | else if ((formula->type != psiconv_formula_dat_int) && |
|
|
558 | (formula->type != psiconv_formula_dat_var) && |
|
|
559 | (formula->type != psiconv_formula_dat_float) && |
|
|
560 | (formula->type != psiconv_formula_dat_cellref) && |
|
|
561 | (formula->type != psiconv_formula_dat_cellblock) && |
|
|
562 | (formula->type != psiconv_formula_dat_vcellblock) && |
|
|
563 | (formula->type != psiconv_formula_mark_opsep) && |
|
|
564 | (formula->type != psiconv_formula_mark_opend) && |
|
|
565 | (formula->type != psiconv_formula_mark_eof) && |
|
|
566 | (formula->type != psiconv_formula_unknown)) |
|
|
567 | psiconv_free_formula_list(formula->data.fun_operands); |
|
|
568 | } |
|
|
569 | |
|
|
570 | void psiconv_free_formula(psiconv_formula formula) |
|
|
571 | { |
|
|
572 | if (formula) { |
|
|
573 | psiconv_free_formula_aux(formula); |
|
|
574 | free(formula); |
|
|
575 | } |
|
|
576 | } |
|
|
577 | |
|
|
578 | void psiconv_free_formula_list(psiconv_formula_list list) |
|
|
579 | { |
|
|
580 | if (list) |
|
|
581 | psiconv_list_free_el(list,psiconv_free_formula_aux); |
|
|
582 | } |
|
|
583 | |
|
|
584 | void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) |
|
|
585 | { |
|
|
586 | if (section) { |
|
|
587 | psiconv_free_formula_list(section->formulas); |
|
|
588 | free(section); |
|
|
589 | } |
|
|
590 | } |
|
|
591 | |
|
|
592 | void psiconv_free_sheet_f(psiconv_sheet_f file) |
|
|
593 | { |
|
|
594 | if (file) { |
|
|
595 | psiconv_free_page_layout_section(file->page_sec); |
|
|
596 | psiconv_free_sheet_status_section(file->status_sec); |
|
|
597 | psiconv_free_sheet_workbook_section(file->workbook_sec); |
|
|
598 | free(file); |
|
|
599 | } |
|
|
600 | } |
|
|
601 | |
459 | void psiconv_free_texted_f(psiconv_texted_f file) |
602 | void psiconv_free_texted_f(psiconv_texted_f file) |
460 | { |
603 | { |
461 | if (file) { |
604 | if (file) { |
462 | psiconv_free_page_layout_section(file->page_sec); |
605 | psiconv_free_page_layout_section(file->page_sec); |
463 | psiconv_free_texted_section(file->texted_sec); |
606 | psiconv_free_texted_section(file->texted_sec); |
… | |
… | |
487 | { |
630 | { |
488 | if (section) |
631 | if (section) |
489 | psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux); |
632 | psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux); |
490 | } |
633 | } |
491 | |
634 | |
|
|
635 | void psiconv_free_jumptable_section (psiconv_jumptable_section section) |
|
|
636 | { |
|
|
637 | if (section) |
|
|
638 | psiconv_list_free(section); |
|
|
639 | } |
|
|
640 | |
492 | void psiconv_free_mbm_f(psiconv_mbm_f file) |
641 | void psiconv_free_mbm_f(psiconv_mbm_f file) |
493 | { |
642 | { |
494 | if (file) { |
643 | if (file) { |
495 | psiconv_free_pictures(file->sections); |
644 | psiconv_free_pictures(file->sections); |
496 | free(file); |
645 | free(file); |
497 | } |
646 | } |
498 | } |
647 | } |
499 | |
648 | |
500 | void psiconv_free_mbm_jumptable_section (psiconv_mbm_jumptable_section section) |
649 | void psiconv_free_sketch_section(psiconv_sketch_section sec) |
|
|
650 | { |
|
|
651 | if (sec) { |
|
|
652 | psiconv_free_paint_data_section(sec->picture); |
|
|
653 | free(sec); |
|
|
654 | } |
|
|
655 | } |
|
|
656 | |
|
|
657 | void psiconv_free_sketch_f(psiconv_sketch_f file) |
|
|
658 | { |
|
|
659 | if (file) { |
|
|
660 | psiconv_free_sketch_section(file->sketch_sec); |
|
|
661 | free(file); |
|
|
662 | } |
|
|
663 | } |
|
|
664 | |
|
|
665 | void psiconv_free_clipart_section_aux(void *section) |
501 | { |
666 | { |
502 | if (section) |
667 | if (section) |
503 | psiconv_list_free(section); |
668 | free(((psiconv_clipart_section ) section)->picture); |
504 | } |
669 | } |
|
|
670 | |
|
|
671 | void psiconv_free_clipart_section(psiconv_clipart_section section) |
|
|
672 | { |
|
|
673 | if (section) { |
|
|
674 | psiconv_free_clipart_section_aux(section); |
|
|
675 | free(section); |
|
|
676 | } |
|
|
677 | } |
|
|
678 | |
|
|
679 | void psiconv_free_cliparts(psiconv_cliparts section) |
|
|
680 | { |
|
|
681 | if (section) |
|
|
682 | psiconv_list_free_el(section,&psiconv_free_clipart_section_aux); |
|
|
683 | } |
|
|
684 | |
|
|
685 | void psiconv_free_clipart_f(psiconv_clipart_f file) |
|
|
686 | { |
|
|
687 | if (file) { |
|
|
688 | psiconv_free_cliparts(file->sections); |
|
|
689 | free(file); |
|
|
690 | } |
|
|
691 | } |
505 | |
692 | |
506 | void psiconv_free_file(psiconv_file file) |
693 | void psiconv_free_file(psiconv_file file) |
507 | { |
694 | { |
508 | if (file) { |
695 | if (file) { |
509 | if (file->type == psiconv_word_file) |
696 | if (file->type == psiconv_word_file) |
510 | psiconv_free_word_f((psiconv_word_f) file->file); |
697 | psiconv_free_word_f((psiconv_word_f) file->file); |
511 | else if (file->type == psiconv_texted_file) |
698 | else if (file->type == psiconv_texted_file) |
512 | psiconv_free_texted_f((psiconv_texted_f) file->file); |
699 | psiconv_free_texted_f((psiconv_texted_f) file->file); |
513 | else if (file->type == psiconv_mbm_file) |
700 | else if (file->type == psiconv_mbm_file) |
514 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
701 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
|
|
702 | else if (file->type == psiconv_sketch_file) |
|
|
703 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
|
|
704 | else if (file->type == psiconv_clipart_file) |
|
|
705 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
|
|
706 | else if (file->type == psiconv_sheet_file) |
|
|
707 | psiconv_free_sheet_f((psiconv_sheet_f) file->file); |
515 | free(file); |
708 | free(file); |
516 | } |
709 | } |
517 | } |
710 | } |
|
|
711 | |
|
|
712 | int psiconv_compare_color(const psiconv_color value1, |
|
|
713 | const psiconv_color value2) |
|
|
714 | { |
|
|
715 | if (!value1 || !value2) |
|
|
716 | return 1; |
|
|
717 | if ((value1->red == value2->red) && |
|
|
718 | (value1->green == value2->green) && |
|
|
719 | (value1->blue == value2->blue)) |
|
|
720 | return 0; |
|
|
721 | else |
|
|
722 | return 1; |
|
|
723 | } |
|
|
724 | |
|
|
725 | int psiconv_compare_font(const psiconv_font value1, |
|
|
726 | const psiconv_font value2) |
|
|
727 | { |
|
|
728 | if (!value1 || !value2 || !value1->name || !value2->name) |
|
|
729 | return 1; |
|
|
730 | if ((value1->screenfont == value2->screenfont) && |
|
|
731 | !strcmp(value1->name,value2->name)) |
|
|
732 | return 0; |
|
|
733 | else |
|
|
734 | return 1; |
|
|
735 | } |
|
|
736 | |
|
|
737 | int psiconv_compare_border(const psiconv_border value1, |
|
|
738 | const psiconv_border value2) |
|
|
739 | { |
|
|
740 | if (!value1 || !value2) |
|
|
741 | return 1; |
|
|
742 | if ((value1->kind == value2->kind) && |
|
|
743 | (value1->thickness == value2->thickness) && |
|
|
744 | !psiconv_compare_color(value1->color,value2->color)) |
|
|
745 | return 0; |
|
|
746 | else |
|
|
747 | return 1; |
|
|
748 | } |
|
|
749 | |
|
|
750 | int psiconv_compare_bullet(const psiconv_bullet value1, |
|
|
751 | const psiconv_bullet value2) |
|
|
752 | { |
|
|
753 | if (!value1 || !value2) |
|
|
754 | return 1; |
|
|
755 | if ((value1->on == value2->on) && |
|
|
756 | (value1->font_size == value2->font_size) && |
|
|
757 | (value1->character == value2->character) && |
|
|
758 | (value1->indent == value2->indent) && |
|
|
759 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
760 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
761 | return 0; |
|
|
762 | else |
|
|
763 | return 1; |
|
|
764 | } |
|
|
765 | |
|
|
766 | int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2) |
|
|
767 | { |
|
|
768 | if (!value1 || !value2) |
|
|
769 | return 1; |
|
|
770 | if ((value1->location == value2->location) && |
|
|
771 | (value1->kind == value2->kind)) |
|
|
772 | return 0; |
|
|
773 | else |
|
|
774 | return 1; |
|
|
775 | } |
|
|
776 | |
|
|
777 | int psiconv_compare_all_tabs(const psiconv_all_tabs value1, |
|
|
778 | const psiconv_all_tabs value2) |
|
|
779 | { |
|
|
780 | int i; |
|
|
781 | |
|
|
782 | if (!value1 || !value2 || !value1->extras || !value2->extras) |
|
|
783 | return 1; |
|
|
784 | |
|
|
785 | if ((value1->normal != value2->normal) || |
|
|
786 | psiconv_list_length(value1->extras) != |
|
|
787 | psiconv_list_length(value2->extras)) |
|
|
788 | return 1; |
|
|
789 | for (i = 0; i < psiconv_list_length(value1->extras); i++) |
|
|
790 | if (psiconv_compare_tab(psiconv_list_get(value1->extras,i), |
|
|
791 | psiconv_list_get(value2->extras,i))) |
|
|
792 | |
|
|
793 | return 1; |
|
|
794 | return 0; |
|
|
795 | } |
|
|
796 | |
|
|
797 | int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1, |
|
|
798 | const psiconv_paragraph_layout value2) |
|
|
799 | { |
|
|
800 | if (!value1 || !value2) |
|
|
801 | return 1; |
|
|
802 | if ((value1->indent_left == value2->indent_left) && |
|
|
803 | (value1->indent_right == value2->indent_right) && |
|
|
804 | (value1->indent_first == value2->indent_first) && |
|
|
805 | (value1->justify_hor == value2->justify_hor) && |
|
|
806 | (value1->justify_ver == value2->justify_ver) && |
|
|
807 | (value1->linespacing == value2->linespacing) && |
|
|
808 | (value1->space_above == value2->space_above) && |
|
|
809 | (value1->space_below == value2->space_below) && |
|
|
810 | (value1->keep_together == value2->keep_together) && |
|
|
811 | (value1->keep_with_next == value2->keep_with_next) && |
|
|
812 | (value1->on_next_page == value2->on_next_page) && |
|
|
813 | (value1->no_widow_protection == value2->no_widow_protection) && |
|
|
814 | (value1->border_distance == value2->border_distance) && |
|
|
815 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
816 | !psiconv_compare_bullet(value1->bullet,value2->bullet) && |
|
|
817 | !psiconv_compare_border(value1->left_border,value2->left_border) && |
|
|
818 | !psiconv_compare_border(value1->right_border,value2->right_border) && |
|
|
819 | !psiconv_compare_border(value1->top_border,value2->top_border) && |
|
|
820 | !psiconv_compare_border(value1->bottom_border,value2->bottom_border) && |
|
|
821 | !psiconv_compare_all_tabs(value1->tabs,value2->tabs)) |
|
|
822 | return 0; |
|
|
823 | else |
|
|
824 | return 1; |
|
|
825 | } |
|
|
826 | |
|
|
827 | |
|
|
828 | int psiconv_compare_character_layout(const psiconv_character_layout value1, |
|
|
829 | const psiconv_character_layout value2) |
|
|
830 | { |
|
|
831 | if (!value1 || !value2) |
|
|
832 | return 1; |
|
|
833 | if ((value1->font_size == value2->font_size) && |
|
|
834 | (value1->italic == value2->italic) && |
|
|
835 | (value1->bold == value2->bold) && |
|
|
836 | (value1->super_sub == value2->super_sub) && |
|
|
837 | (value1->underline == value2->underline) && |
|
|
838 | (value1->strikethrough == value2->strikethrough) && |
|
|
839 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
840 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
841 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
842 | return 0; |
|
|
843 | else |
|
|
844 | return 1; |
|
|
845 | } |
|
|
846 | |
|
|
847 | |
|
|
848 | |
|
|
849 | psiconv_word_styles_section psiconv_empty_word_styles_section(void) |
|
|
850 | { |
|
|
851 | psiconv_word_styles_section result; |
|
|
852 | if (!(result = malloc(sizeof(*result)))) |
|
|
853 | goto ERROR1; |
|
|
854 | if (!(result->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s)))) |
|
|
855 | goto ERROR2; |
|
|
856 | if (!(result->normal = malloc(sizeof(struct psiconv_word_style_s)))) |
|
|
857 | goto ERROR3; |
|
|
858 | if (!(result->normal->character = psiconv_basic_character_layout())) |
|
|
859 | goto ERROR4; |
|
|
860 | if (!(result->normal->paragraph = psiconv_basic_paragraph_layout())) |
|
|
861 | goto ERROR5; |
|
|
862 | result->normal->hotkey = 'N'; |
|
|
863 | result->normal->name = NULL; |
|
|
864 | result->normal->built_in = psiconv_bool_true; |
|
|
865 | result->normal->outline_level = 0; |
|
|
866 | return result; |
|
|
867 | ERROR5: |
|
|
868 | psiconv_free_character_layout(result->normal->character); |
|
|
869 | ERROR4: |
|
|
870 | free(result->normal); |
|
|
871 | ERROR3: |
|
|
872 | psiconv_list_free(result->styles); |
|
|
873 | ERROR2: |
|
|
874 | free(result); |
|
|
875 | ERROR1: |
|
|
876 | return NULL; |
|
|
877 | } |
|
|
878 | |
|
|
879 | psiconv_text_and_layout psiconv_empty_text_and_layout(void) |
|
|
880 | { |
|
|
881 | return psiconv_list_new(sizeof(struct psiconv_paragraph_s)); |
|
|
882 | } |
|
|
883 | |
|
|
884 | psiconv_texted_section psiconv_empty_texted_section(void) |
|
|
885 | { |
|
|
886 | psiconv_texted_section result; |
|
|
887 | if (!(result = malloc(sizeof(*result)))) |
|
|
888 | goto ERROR1; |
|
|
889 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
890 | goto ERROR2; |
|
|
891 | return result; |
|
|
892 | ERROR2: |
|
|
893 | free(result); |
|
|
894 | ERROR1: |
|
|
895 | return NULL; |
|
|
896 | } |
|
|
897 | |
|
|
898 | psiconv_page_header psiconv_empty_page_header(void) |
|
|
899 | { |
|
|
900 | psiconv_page_header result; |
|
|
901 | if (!(result = malloc(sizeof(*result)))) |
|
|
902 | goto ERROR1; |
|
|
903 | result->on_first_page = psiconv_bool_true; |
|
|
904 | if (!(result->base_paragraph_layout = psiconv_basic_paragraph_layout())) |
|
|
905 | goto ERROR2; |
|
|
906 | if (!(result->base_character_layout = psiconv_basic_character_layout())) |
|
|
907 | goto ERROR3; |
|
|
908 | if (!(result->text = psiconv_empty_texted_section())) |
|
|
909 | goto ERROR4; |
|
|
910 | return result; |
|
|
911 | ERROR4: |
|
|
912 | psiconv_free_character_layout(result->base_character_layout); |
|
|
913 | ERROR3: |
|
|
914 | psiconv_free_paragraph_layout(result->base_paragraph_layout); |
|
|
915 | ERROR2: |
|
|
916 | free(result); |
|
|
917 | ERROR1: |
|
|
918 | return NULL; |
|
|
919 | } |
|
|
920 | |
|
|
921 | psiconv_page_layout_section psiconv_empty_page_layout_section(void) |
|
|
922 | { |
|
|
923 | psiconv_page_layout_section result; |
|
|
924 | if (!(result = malloc(sizeof(*result)))) |
|
|
925 | goto ERROR1; |
|
|
926 | result->first_page_nr = 1; |
|
|
927 | result->header_dist = result->footer_dist = 1.27; |
|
|
928 | result->left_margin = result->right_margin = 3.175; |
|
|
929 | result->top_margin = result->bottom_margin = 2.54; |
|
|
930 | result->page_width = 21.0; |
|
|
931 | result->page_height = 29.7; |
|
|
932 | result->landscape = psiconv_bool_false; |
|
|
933 | if (!(result->header = psiconv_empty_page_header())) |
|
|
934 | goto ERROR2; |
|
|
935 | if (!(result->footer = psiconv_empty_page_header())) |
|
|
936 | goto ERROR3; |
|
|
937 | return result; |
|
|
938 | ERROR3: |
|
|
939 | psiconv_free_page_header(result->header); |
|
|
940 | ERROR2: |
|
|
941 | free(result); |
|
|
942 | ERROR1: |
|
|
943 | return NULL; |
|
|
944 | } |
|
|
945 | |
|
|
946 | psiconv_word_status_section psiconv_empty_word_status_section(void) |
|
|
947 | { |
|
|
948 | psiconv_word_status_section result; |
|
|
949 | if (!(result = malloc(sizeof(*result)))) |
|
|
950 | return NULL; |
|
|
951 | result->show_tabs = result->show_spaces = result->show_paragraph_ends = |
|
|
952 | result->show_hard_minus = result->show_hard_space = |
|
|
953 | result->fit_lines_to_screen = psiconv_bool_false; |
|
|
954 | result->show_full_pictures = result->show_full_graphs = |
|
|
955 | result->show_top_toolbar = result->show_side_toolbar = |
|
|
956 | psiconv_bool_true; |
|
|
957 | result->cursor_position = 0; |
|
|
958 | result->display_size = 1000; |
|
|
959 | return result; |
|
|
960 | } |
|
|
961 | |
|
|
962 | psiconv_word_f psiconv_empty_word_f(void) |
|
|
963 | { |
|
|
964 | psiconv_word_f result; |
|
|
965 | if (!(result = malloc(sizeof(*result)))) |
|
|
966 | goto ERROR1; |
|
|
967 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
968 | goto ERROR2; |
|
|
969 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
970 | goto ERROR3; |
|
|
971 | if (!(result->status_sec = psiconv_empty_word_status_section())) |
|
|
972 | goto ERROR4; |
|
|
973 | if (!(result->styles_sec = psiconv_empty_word_styles_section())) |
|
|
974 | goto ERROR5; |
|
|
975 | return result; |
|
|
976 | ERROR5: |
|
|
977 | psiconv_free_word_status_section(result->status_sec); |
|
|
978 | ERROR4: |
|
|
979 | psiconv_free_text_and_layout(result->paragraphs); |
|
|
980 | ERROR3: |
|
|
981 | psiconv_free_page_layout_section(result->page_sec); |
|
|
982 | ERROR2: |
|
|
983 | free(result); |
|
|
984 | ERROR1: |
|
|
985 | return NULL; |
|
|
986 | } |
|
|
987 | |
|
|
988 | psiconv_sheet_status_section psiconv_empty_sheet_status_section(void) |
|
|
989 | { |
|
|
990 | psiconv_sheet_status_section result; |
|
|
991 | if (!(result = malloc(sizeof(*result)))) |
|
|
992 | return NULL; |
|
|
993 | result->show_horizontal_scrollbar = result->show_vertical_scrollbar = |
|
|
994 | psiconv_triple_auto; |
|
|
995 | result->show_graph = psiconv_bool_false; |
|
|
996 | result->show_top_sheet_toolbar = result->show_side_sheet_toolbar = |
|
|
997 | result->show_top_graph_toolbar = result->show_side_graph_toolbar = |
|
|
998 | psiconv_bool_true; |
|
|
999 | result->cursor_row = result->cursor_column = 0; |
|
|
1000 | result->sheet_display_size = result->graph_display_size = 1000; |
|
|
1001 | return result; |
|
|
1002 | } |
|
|
1003 | |
|
|
1004 | psiconv_formula_list psiconv_empty_formula_list(void) |
|
|
1005 | { |
|
|
1006 | return psiconv_list_new(sizeof(struct psiconv_formula_s)); |
|
|
1007 | } |
|
|
1008 | |
|
|
1009 | psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) |
|
|
1010 | { |
|
|
1011 | psiconv_sheet_workbook_section result; |
|
|
1012 | if (!(result = malloc(sizeof(*result)))) |
|
|
1013 | goto ERROR1; |
|
|
1014 | if (!(result->formulas = psiconv_empty_formula_list())) |
|
|
1015 | goto ERROR2; |
|
|
1016 | return result; |
|
|
1017 | ERROR2: |
|
|
1018 | free(result); |
|
|
1019 | ERROR1: |
|
|
1020 | return NULL; |
|
|
1021 | } |
|
|
1022 | |
|
|
1023 | |
|
|
1024 | psiconv_sheet_f psiconv_empty_sheet_f(void) |
|
|
1025 | { |
|
|
1026 | psiconv_sheet_f result; |
|
|
1027 | if (!(result = malloc(sizeof(*result)))) |
|
|
1028 | goto ERROR1; |
|
|
1029 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1030 | goto ERROR2; |
|
|
1031 | if (!(result->status_sec = psiconv_empty_sheet_status_section())) |
|
|
1032 | goto ERROR3; |
|
|
1033 | if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section())) |
|
|
1034 | goto ERROR4; |
|
|
1035 | return result; |
|
|
1036 | ERROR4: |
|
|
1037 | psiconv_free_sheet_status_section(result->status_sec); |
|
|
1038 | ERROR3: |
|
|
1039 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1040 | ERROR2: |
|
|
1041 | free(result); |
|
|
1042 | ERROR1: |
|
|
1043 | return NULL; |
|
|
1044 | } |
|
|
1045 | |
|
|
1046 | psiconv_texted_f psiconv_empty_texted_f(void) |
|
|
1047 | { |
|
|
1048 | psiconv_texted_f result; |
|
|
1049 | if (!(result = malloc(sizeof(*result)))) |
|
|
1050 | goto ERROR1; |
|
|
1051 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1052 | goto ERROR2; |
|
|
1053 | if (!(result->texted_sec = psiconv_empty_texted_section())) |
|
|
1054 | goto ERROR3; |
|
|
1055 | return result; |
|
|
1056 | ERROR3: |
|
|
1057 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1058 | ERROR2: |
|
|
1059 | free(result); |
|
|
1060 | ERROR1: |
|
|
1061 | return NULL; |
|
|
1062 | } |
|
|
1063 | |
|
|
1064 | psiconv_paint_data_section psiconv_empty_paint_data_section(void) |
|
|
1065 | { |
|
|
1066 | psiconv_paint_data_section result; |
|
|
1067 | if (!(result = malloc(sizeof(*result)))) |
|
|
1068 | goto ERROR1; |
|
|
1069 | /* Is this correct? */ |
|
|
1070 | result->xsize = result->ysize = result->pic_xsize = result->pic_ysize = 0; |
|
|
1071 | /* Probably forbidden... */ |
|
|
1072 | if (!(result->red = malloc(0))) |
|
|
1073 | goto ERROR2; |
|
|
1074 | if (!(result->green = malloc(0))) |
|
|
1075 | goto ERROR3; |
|
|
1076 | if (!(result->blue = malloc(0))) |
|
|
1077 | goto ERROR4; |
|
|
1078 | return result; |
|
|
1079 | ERROR4: |
|
|
1080 | free(result->green); |
|
|
1081 | ERROR3: |
|
|
1082 | free(result->red); |
|
|
1083 | ERROR2: |
|
|
1084 | free(result); |
|
|
1085 | ERROR1: |
|
|
1086 | return NULL; |
|
|
1087 | } |
|
|
1088 | |
|
|
1089 | |
|
|
1090 | psiconv_pictures psiconv_empty_pictures(void) |
|
|
1091 | { |
|
|
1092 | psiconv_pictures result; |
|
|
1093 | psiconv_paint_data_section pds; |
|
|
1094 | if (!(result = psiconv_list_new(sizeof(struct psiconv_paint_data_section_s)))) |
|
|
1095 | goto ERROR1; |
|
|
1096 | if (!(pds = psiconv_empty_paint_data_section())) |
|
|
1097 | goto ERROR2; |
|
|
1098 | if (psiconv_list_add(result,pds)) |
|
|
1099 | goto ERROR3; |
|
|
1100 | free(pds); |
|
|
1101 | return result; |
|
|
1102 | ERROR3: |
|
|
1103 | psiconv_free_paint_data_section(pds); |
|
|
1104 | ERROR2: |
|
|
1105 | psiconv_list_free(result); |
|
|
1106 | ERROR1: |
|
|
1107 | return NULL; |
|
|
1108 | } |
|
|
1109 | |
|
|
1110 | psiconv_mbm_f psiconv_empty_mbm_f(void) |
|
|
1111 | { |
|
|
1112 | psiconv_mbm_f result; |
|
|
1113 | if (!(result = malloc(sizeof(*result)))) |
|
|
1114 | goto ERROR1; |
|
|
1115 | if (!(result->sections = psiconv_empty_pictures())) |
|
|
1116 | goto ERROR2; |
|
|
1117 | return result; |
|
|
1118 | ERROR2: |
|
|
1119 | free(result); |
|
|
1120 | ERROR1: |
|
|
1121 | return NULL; |
|
|
1122 | } |
|
|
1123 | |
|
|
1124 | psiconv_sketch_section psiconv_empty_sketch_section(void) |
|
|
1125 | { |
|
|
1126 | psiconv_sketch_section result; |
|
|
1127 | if (!(result = malloc(sizeof(*result)))) |
|
|
1128 | goto ERROR1; |
|
|
1129 | result->form_xsize = 320; |
|
|
1130 | result->form_ysize = 200; |
|
|
1131 | result->picture_x_offset = result->picture_y_offset = result->picture_xsize = |
|
|
1132 | result->picture_ysize = 0; |
|
|
1133 | result->magnification_x = result->magnification_y = 1.0; |
|
|
1134 | result->cut_left = result->cut_right = result->cut_top = |
|
|
1135 | result->cut_bottom = 0.0; |
|
|
1136 | if (!(result->picture = psiconv_empty_paint_data_section())) |
|
|
1137 | goto ERROR2; |
|
|
1138 | return result; |
|
|
1139 | ERROR2: |
|
|
1140 | free(result); |
|
|
1141 | ERROR1: |
|
|
1142 | return NULL; |
|
|
1143 | } |
|
|
1144 | |
|
|
1145 | psiconv_sketch_f psiconv_empty_sketch_f(void) |
|
|
1146 | { |
|
|
1147 | psiconv_sketch_f result; |
|
|
1148 | if (!(result = malloc(sizeof(*result)))) |
|
|
1149 | goto ERROR1; |
|
|
1150 | if (!(result->sketch_sec = psiconv_empty_sketch_section())) |
|
|
1151 | goto ERROR2; |
|
|
1152 | return result; |
|
|
1153 | ERROR2: |
|
|
1154 | free(result); |
|
|
1155 | ERROR1: |
|
|
1156 | return NULL; |
|
|
1157 | } |
|
|
1158 | |
|
|
1159 | psiconv_cliparts psiconv_empty_cliparts(void) |
|
|
1160 | { |
|
|
1161 | /* Is this correct? */ |
|
|
1162 | return psiconv_list_new(sizeof(struct psiconv_clipart_section_s)); |
|
|
1163 | } |
|
|
1164 | |
|
|
1165 | psiconv_clipart_f psiconv_empty_clipart_f(void) |
|
|
1166 | { |
|
|
1167 | psiconv_clipart_f result; |
|
|
1168 | if (!(result = malloc(sizeof(*result)))) |
|
|
1169 | goto ERROR1; |
|
|
1170 | if (!(result->sections = psiconv_empty_cliparts())) |
|
|
1171 | goto ERROR2; |
|
|
1172 | return result; |
|
|
1173 | ERROR2: |
|
|
1174 | free(result); |
|
|
1175 | ERROR1: |
|
|
1176 | return NULL; |
|
|
1177 | } |
|
|
1178 | |
|
|
1179 | psiconv_file psiconv_empty_file(psiconv_file_type_t type) |
|
|
1180 | { |
|
|
1181 | psiconv_file result; |
|
|
1182 | if (!(result = malloc(sizeof(*result)))) |
|
|
1183 | return NULL; |
|
|
1184 | result->type = type; |
|
|
1185 | if (type == psiconv_word_file) { |
|
|
1186 | if (!(result->file = psiconv_empty_word_f())) |
|
|
1187 | goto ERROR; |
|
|
1188 | } else if (type == psiconv_sheet_file) { |
|
|
1189 | if (!(result->file = psiconv_empty_sheet_f())) |
|
|
1190 | goto ERROR; |
|
|
1191 | } else if (type == psiconv_texted_file) { |
|
|
1192 | if (!(result->file = psiconv_empty_texted_f())) |
|
|
1193 | goto ERROR; |
|
|
1194 | } else if (type == psiconv_mbm_file) { |
|
|
1195 | if (!(result->file = psiconv_empty_mbm_f())) |
|
|
1196 | goto ERROR; |
|
|
1197 | } else if (type == psiconv_sketch_file) { |
|
|
1198 | if (!(result->file = psiconv_empty_sketch_f())) |
|
|
1199 | goto ERROR; |
|
|
1200 | } else if (type == psiconv_clipart_file) { |
|
|
1201 | if (!(result->file = psiconv_empty_clipart_f())) |
|
|
1202 | goto ERROR; |
|
|
1203 | } else |
|
|
1204 | goto ERROR; |
|
|
1205 | return result; |
|
|
1206 | ERROR: |
|
|
1207 | free(result); |
|
|
1208 | return NULL; |
|
|
1209 | } |