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-2004 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. |
… | |
… | |
21 | #include "compat.h" |
21 | #include "compat.h" |
22 | #include <stdlib.h> |
22 | #include <stdlib.h> |
23 | #include <string.h> |
23 | #include <string.h> |
24 | #include "data.h" |
24 | #include "data.h" |
25 | #include "list.h" |
25 | #include "list.h" |
26 | #include "general.h" |
26 | #include "unicode.h" |
|
|
27 | |
|
|
28 | #ifdef DMALLOC |
|
|
29 | #include <dmalloc.h> |
|
|
30 | #endif |
27 | |
31 | |
28 | static psiconv_color clone_color(psiconv_color color); |
32 | static psiconv_color clone_color(psiconv_color color); |
29 | static psiconv_font clone_font(psiconv_font font); |
33 | static psiconv_font clone_font(psiconv_font font); |
30 | static psiconv_border clone_border(psiconv_border border); |
34 | static psiconv_border clone_border(psiconv_border border); |
31 | static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
35 | static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
32 | static psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs); |
36 | static psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs); |
33 | static void psiconv_free_style_aux(void *style); |
37 | static void psiconv_free_style_aux(void *style); |
34 | static void psiconv_free_in_line_layout_aux(void * layout); |
38 | static void psiconv_free_in_line_layout_aux(void * layout); |
35 | static void psiconv_free_paragraph_aux(void * paragraph); |
39 | static void psiconv_free_paragraph_aux(void * paragraph); |
36 | static void psiconv_free_paint_data_section_aux(void * section); |
40 | static void psiconv_free_paint_data_section_aux(void * section); |
|
|
41 | static void psiconv_free_clipart_section_aux(void * section); |
|
|
42 | static void psiconv_free_formula_aux(void *data); |
|
|
43 | static void psiconv_free_sheet_worksheet_aux (void *data); |
|
|
44 | static void psiconv_free_sheet_variable_aux(void * variable); |
|
|
45 | static void psiconv_free_sheet_cell_aux(void *cell); |
|
|
46 | static void psiconv_free_sheet_line_aux(void *line); |
|
|
47 | static void psiconv_free_sheet_worksheet_aux (void *data); |
37 | |
48 | |
|
|
49 | static psiconv_word_styles_section psiconv_empty_word_styles_section(void); |
|
|
50 | static psiconv_text_and_layout psiconv_empty_text_and_layout(void); |
|
|
51 | static psiconv_texted_section psiconv_empty_texted_section(void); |
|
|
52 | static psiconv_page_header psiconv_empty_page_header(void); |
|
|
53 | static psiconv_page_layout_section psiconv_empty_page_layout_section(void); |
|
|
54 | static psiconv_word_status_section psiconv_empty_word_status_section(void); |
|
|
55 | static psiconv_word_f psiconv_empty_word_f(void); |
|
|
56 | static psiconv_sheet_status_section psiconv_empty_sheet_status_section(void); |
|
|
57 | static psiconv_formula_list psiconv_empty_formula_list(void); |
|
|
58 | static psiconv_sheet_workbook_section |
|
|
59 | psiconv_empty_sheet_workbook_section(void); |
|
|
60 | static psiconv_sheet_f psiconv_empty_sheet_f(void); |
|
|
61 | static psiconv_texted_f psiconv_empty_texted_f(void); |
|
|
62 | static psiconv_paint_data_section psiconv_empty_paint_data_section(void); |
|
|
63 | static psiconv_pictures psiconv_empty_pictures(void); |
|
|
64 | static psiconv_mbm_f psiconv_empty_mbm_f(void); |
|
|
65 | static psiconv_sketch_section psiconv_empty_sketch_section(void); |
|
|
66 | static psiconv_sketch_f psiconv_empty_sketch_f(void); |
|
|
67 | static psiconv_clipart_f psiconv_empty_clipart_f(void); |
|
|
68 | static psiconv_cliparts psiconv_empty_cliparts(void); |
|
|
69 | |
|
|
70 | |
|
|
71 | /* Note: these defaults seem to be hard-coded somewhere outside the |
|
|
72 | files themself. */ |
38 | psiconv_character_layout psiconv_basic_character_layout(void) |
73 | psiconv_character_layout psiconv_basic_character_layout(void) |
39 | { |
74 | { |
40 | /* Make the structures static, to oblige IRIX */ |
75 | /* Make the structures static, to oblige IRIX */ |
41 | static struct psiconv_color black = |
76 | static struct psiconv_color_s black = |
42 | { |
77 | { |
43 | 0x00, /* red */ |
78 | 0x00, /* red */ |
44 | 0x00, /* green */ |
79 | 0x00, /* green */ |
45 | 0x00, /* blue */ |
80 | 0x00, /* blue */ |
46 | }; |
81 | }; |
47 | static struct psiconv_color white = |
82 | static struct psiconv_color_s white = |
48 | { |
83 | { |
49 | 0xff, /* red */ |
84 | 0xff, /* red */ |
50 | 0xff, /* green */ |
85 | 0xff, /* green */ |
51 | 0xff, /* blue */ |
86 | 0xff, /* blue */ |
52 | }; |
87 | }; |
|
|
88 | static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ', |
|
|
89 | 'N','e','w',' ', |
|
|
90 | 'R','o','m','a','n',0 }; |
53 | static struct psiconv_font font = |
91 | static struct psiconv_font_s font = |
54 | { |
92 | { |
55 | "Times New Roman", /* name */ |
93 | font_times, /* name */ |
56 | 3 /* screenfont */ |
94 | 3 /* screenfont */ |
57 | }; |
95 | }; |
58 | struct psiconv_character_layout cl = |
96 | struct psiconv_character_layout_s cl = |
59 | { |
97 | { |
60 | &black, /* color */ |
98 | &black, /* color */ |
61 | &white, /* back_color */ |
99 | &white, /* back_color */ |
62 | 10.0, /* font_size */ |
100 | 10.0, /* font_size */ |
63 | psiconv_bool_false, /* italic */ |
101 | psiconv_bool_false, /* italic */ |
64 | psiconv_bool_false, /* bold */ |
102 | psiconv_bool_false, /* bold */ |
65 | psiconv_normalscript, /* super_sub */ |
103 | psiconv_normalscript, /* super_sub */ |
66 | psiconv_bool_false, /* underline */ |
104 | psiconv_bool_false, /* underline */ |
67 | psiconv_bool_false, /* strike_out */ |
105 | psiconv_bool_false, /* strikethrough */ |
68 | font, /* font */ |
106 | &font, /* font */ |
69 | }; |
107 | }; |
70 | |
108 | |
71 | return psiconv_clone_character_layout(&cl); |
109 | return psiconv_clone_character_layout(&cl); |
72 | } |
110 | } |
73 | |
111 | |
|
|
112 | /* Note: these defaults seem to be hard-coded somewhere outside the |
|
|
113 | files themself. */ |
74 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
114 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
75 | { |
115 | { |
|
|
116 | static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ', |
|
|
117 | 'N','e','w',' ', |
|
|
118 | 'R','o','m','a','n',0 }; |
|
|
119 | |
76 | static struct psiconv_font font = |
120 | static struct psiconv_font_s font = |
77 | { |
121 | { |
78 | "Times New Roman", /* name */ |
122 | font_times, /* name */ |
79 | 2 /* screenfont */ |
123 | 2 /* screenfont */ |
80 | }; |
124 | }; |
81 | static struct psiconv_color black = |
125 | static struct psiconv_color_s black = |
82 | { |
126 | { |
83 | 0x00, /* red */ |
127 | 0x00, /* red */ |
84 | 0x00, /* green */ |
128 | 0x00, /* green */ |
85 | 0x00, /* blue */ |
129 | 0x00, /* blue */ |
86 | }; |
130 | }; |
87 | static struct psiconv_color white = |
131 | static struct psiconv_color_s white = |
88 | { |
132 | { |
89 | 0xff, /* red */ |
133 | 0xff, /* red */ |
90 | 0xff, /* green */ |
134 | 0xff, /* green */ |
91 | 0xff, /* blue */ |
135 | 0xff, /* blue */ |
92 | }; |
136 | }; |
93 | static struct psiconv_border no_border = |
137 | static struct psiconv_border_s no_border = |
94 | { |
138 | { |
95 | psiconv_border_none, /* kind */ |
139 | psiconv_border_none, /* kind */ |
96 | 1, /* thickness */ |
140 | 1, /* thickness */ |
97 | &black /* color */ |
141 | &black /* color */ |
98 | }; |
142 | }; |
99 | static struct psiconv_bullet bullet = |
143 | static struct psiconv_bullet_s bullet = |
100 | { |
144 | { |
101 | psiconv_bool_false, /* on */ |
145 | psiconv_bool_false, /* on */ |
102 | 10.0, /* font_size */ |
146 | 10.0, /* font_size */ |
103 | 0x95, /* character */ |
147 | 0x201d, /* character */ |
104 | psiconv_bool_true, /* indent */ |
148 | psiconv_bool_true, /* indent */ |
105 | &black, /* color */ |
149 | &black, /* color */ |
106 | &font, /* font */ |
150 | &font, /* font */ |
107 | }; |
151 | }; |
108 | static struct psiconv_all_tabs tabs = |
152 | static struct psiconv_all_tabs_s tabs = |
109 | { |
153 | { |
110 | 0.64, /* normal */ |
154 | 0.64, /* normal */ |
111 | NULL /* kind */ |
155 | NULL /* kind */ |
112 | }; |
156 | }; |
113 | struct psiconv_paragraph_layout pl = |
157 | struct psiconv_paragraph_layout_s pl = |
114 | { |
158 | { |
115 | &white, /* back_color */ |
159 | &white, /* back_color */ |
116 | 0.0, /* indent_left */ |
160 | 0.0, /* indent_left */ |
117 | 0.0, /* indent_right */ |
161 | 0.0, /* indent_right */ |
118 | 0.0, /* indent_first */ |
162 | 0.0, /* indent_first */ |
119 | psiconv_justify_left, /* justify_hor */ |
163 | psiconv_justify_left, /* justify_hor */ |
120 | psiconv_justify_middle,/* justify_ver */ |
164 | psiconv_justify_middle,/* justify_ver */ |
121 | 0.0, /* interline */ |
165 | 10.0, /* linespacing */ |
122 | psiconv_bool_false, /* interline_exact */ |
166 | psiconv_bool_false, /* linespacing_exact */ |
123 | 0.0, /* top_space */ |
167 | 0.0, /* space_above */ |
124 | 0.0, /* bottom_space */ |
168 | 0.0, /* space_below */ |
125 | psiconv_bool_false, /* on_one_page */ |
|
|
126 | psiconv_bool_false, /* together_with */ |
169 | psiconv_bool_false, /* keep_together */ |
|
|
170 | psiconv_bool_false, /* keep_with_next */ |
127 | psiconv_bool_false, /* on_next_page */ |
171 | psiconv_bool_false, /* on_next_page */ |
128 | psiconv_bool_false, /* no_widow_protection */ |
172 | psiconv_bool_false, /* no_widow_protection */ |
|
|
173 | psiconv_bool_false, /* wrap_to_fit_cell */ |
129 | 0.0, /* left_margin */ |
174 | 0.0, /* left_margin */ |
130 | &bullet, /* bullet */ |
175 | &bullet, /* bullet */ |
131 | &no_border, /* left_border */ |
176 | &no_border, /* left_border */ |
132 | &no_border, /* right_border */ |
177 | &no_border, /* right_border */ |
133 | &no_border, /* top_border */ |
178 | &no_border, /* top_border */ |
134 | &no_border, /* bottom_border */ |
179 | &no_border, /* bottom_border */ |
135 | &tabs, /* tabs */ |
180 | &tabs, /* tabs */ |
136 | }; |
181 | }; |
137 | psiconv_paragraph_layout res; |
182 | psiconv_paragraph_layout res; |
138 | |
183 | |
139 | pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab)); |
184 | if (!(pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab_s)))) |
|
|
185 | return NULL; |
140 | res = psiconv_clone_paragraph_layout(&pl); |
186 | res = psiconv_clone_paragraph_layout(&pl); |
141 | psiconv_list_free(pl.tabs->extras); |
187 | psiconv_list_free(pl.tabs->extras); |
142 | return res; |
188 | return res; |
143 | } |
189 | } |
144 | |
190 | |
145 | psiconv_color clone_color(psiconv_color color) |
191 | psiconv_color clone_color(psiconv_color color) |
146 | { |
192 | { |
147 | psiconv_color result; |
193 | psiconv_color result; |
148 | result = malloc(sizeof(*result)); |
194 | if (!(result = malloc(sizeof(*result)))) |
|
|
195 | return NULL; |
149 | *result = *color; |
196 | *result = *color; |
150 | return result; |
197 | return result; |
151 | } |
198 | } |
152 | |
199 | |
153 | psiconv_font clone_font(psiconv_font font) |
200 | psiconv_font clone_font(psiconv_font font) |
154 | { |
201 | { |
155 | psiconv_font result; |
202 | psiconv_font result; |
156 | result = malloc(sizeof(*result)); |
203 | if(!(result = malloc(sizeof(*result)))) |
|
|
204 | goto ERROR1; |
157 | *result = *font; |
205 | *result = *font; |
158 | result->name = strdup(result->name); |
206 | if (!(result->name = psiconv_unicode_strdup(result->name))) |
|
|
207 | goto ERROR2; |
159 | return result; |
208 | return result; |
|
|
209 | ERROR2: |
|
|
210 | free(result); |
|
|
211 | ERROR1: |
|
|
212 | return NULL; |
160 | } |
213 | } |
161 | |
214 | |
162 | psiconv_border clone_border(psiconv_border border) |
215 | psiconv_border clone_border(psiconv_border border) |
163 | { |
216 | { |
164 | psiconv_border result; |
217 | psiconv_border result; |
165 | result = malloc(sizeof(*result)); |
218 | if (!(result = malloc(sizeof(*result)))) |
|
|
219 | goto ERROR1; |
166 | *result = *border; |
220 | *result = *border; |
167 | result->color = clone_color(result->color); |
221 | if(!(result->color = clone_color(result->color))) |
|
|
222 | goto ERROR2; |
168 | return result; |
223 | return result; |
|
|
224 | ERROR2: |
|
|
225 | free(result); |
|
|
226 | ERROR1: |
|
|
227 | return NULL; |
169 | } |
228 | } |
170 | |
229 | |
171 | psiconv_bullet clone_bullet(psiconv_bullet bullet) |
230 | psiconv_bullet clone_bullet(psiconv_bullet bullet) |
172 | { |
231 | { |
173 | psiconv_bullet result; |
232 | psiconv_bullet result; |
174 | result = malloc(sizeof(*result)); |
233 | if (!(result = malloc(sizeof(*result)))) |
|
|
234 | goto ERROR1; |
175 | *result = *bullet; |
235 | *result = *bullet; |
176 | result->font = clone_font(result->font); |
236 | if (!(result->font = clone_font(result->font))) |
|
|
237 | goto ERROR2; |
177 | result->color = clone_color(result->color); |
238 | if (!(result->color = clone_color(result->color))) |
|
|
239 | goto ERROR3; |
178 | return result; |
240 | return result; |
|
|
241 | ERROR3: |
|
|
242 | psiconv_free_font(result->font); |
|
|
243 | ERROR2: |
|
|
244 | free(result); |
|
|
245 | ERROR1: |
|
|
246 | return NULL; |
179 | } |
247 | } |
180 | |
248 | |
181 | psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs) |
249 | psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs) |
182 | { |
250 | { |
183 | psiconv_all_tabs result; |
251 | psiconv_all_tabs result; |
184 | result = malloc(sizeof(*result)); |
252 | if (!(result = malloc(sizeof(*result)))) |
|
|
253 | goto ERROR1; |
185 | *result = *all_tabs; |
254 | *result = *all_tabs; |
186 | result->extras = psiconv_list_clone(result->extras); |
255 | if (!(result->extras = psiconv_list_clone(result->extras))) |
|
|
256 | goto ERROR2; |
187 | return result; |
257 | return result; |
|
|
258 | ERROR2: |
|
|
259 | free(result); |
|
|
260 | ERROR1: |
|
|
261 | return NULL; |
188 | } |
262 | } |
189 | |
263 | |
190 | psiconv_character_layout psiconv_clone_character_layout |
264 | psiconv_character_layout psiconv_clone_character_layout |
191 | (psiconv_character_layout ls) |
265 | (psiconv_character_layout ls) |
192 | { |
266 | { |
193 | psiconv_character_layout result; |
267 | psiconv_character_layout result; |
194 | |
268 | |
195 | result = malloc(sizeof(*result)); |
269 | if (!(result = malloc(sizeof(*result)))) |
|
|
270 | goto ERROR1; |
196 | *result = *ls; |
271 | *result = *ls; |
197 | result->color = clone_color(result->color); |
272 | if (!(result->color = clone_color(result->color))) |
|
|
273 | goto ERROR2; |
198 | result->back_color = clone_color(result->back_color); |
274 | if (!(result->back_color = clone_color(result->back_color))) |
|
|
275 | goto ERROR3; |
199 | result->font = clone_font(result->font); |
276 | if (!(result->font = clone_font(result->font))) |
|
|
277 | goto ERROR4; |
200 | return result; |
278 | return result; |
|
|
279 | ERROR4: |
|
|
280 | psiconv_free_color(result->back_color); |
|
|
281 | ERROR3: |
|
|
282 | psiconv_free_color(result->color); |
|
|
283 | ERROR2: |
|
|
284 | free(result); |
|
|
285 | ERROR1: |
|
|
286 | return NULL; |
201 | } |
287 | } |
202 | |
288 | |
203 | psiconv_paragraph_layout psiconv_clone_paragraph_layout |
289 | psiconv_paragraph_layout psiconv_clone_paragraph_layout |
204 | (psiconv_paragraph_layout ls) |
290 | (psiconv_paragraph_layout ls) |
205 | { |
291 | { |
206 | psiconv_paragraph_layout result; |
292 | psiconv_paragraph_layout result; |
207 | |
293 | |
208 | result = malloc(sizeof(*result)); |
294 | if (!(result = malloc(sizeof(*result)))) |
|
|
295 | goto ERROR1; |
209 | *result = *ls; |
296 | *result = *ls; |
210 | result->back_color = clone_color(result->back_color); |
297 | if (!(result->back_color = clone_color(result->back_color))) |
|
|
298 | goto ERROR2; |
211 | result->bullet = clone_bullet(result->bullet); |
299 | if (!(result->bullet = clone_bullet(result->bullet))) |
|
|
300 | goto ERROR3; |
212 | result->left_border = clone_border(result->left_border); |
301 | if (!(result->left_border = clone_border(result->left_border))) |
|
|
302 | goto ERROR4; |
213 | result->right_border = clone_border(result->right_border); |
303 | if (!(result->right_border = clone_border(result->right_border))) |
|
|
304 | goto ERROR5; |
214 | result->top_border = clone_border(result->top_border); |
305 | if (!(result->top_border = clone_border(result->top_border))) |
|
|
306 | goto ERROR6; |
215 | result->bottom_border = clone_border(result->bottom_border); |
307 | if (!(result->bottom_border = clone_border(result->bottom_border))) |
|
|
308 | goto ERROR7; |
216 | result->tabs = clone_all_tabs(result->tabs); |
309 | if (!(result->tabs = clone_all_tabs(result->tabs))) |
|
|
310 | goto ERROR8; |
217 | return result; |
311 | return result; |
|
|
312 | ERROR8: |
|
|
313 | psiconv_free_border(result->bottom_border); |
|
|
314 | ERROR7: |
|
|
315 | psiconv_free_border(result->top_border); |
|
|
316 | ERROR6: |
|
|
317 | psiconv_free_border(result->right_border); |
|
|
318 | ERROR5: |
|
|
319 | psiconv_free_border(result->left_border); |
|
|
320 | ERROR4: |
|
|
321 | psiconv_free_bullet(result->bullet); |
|
|
322 | ERROR3: |
|
|
323 | psiconv_free_color(result->back_color); |
|
|
324 | ERROR2: |
|
|
325 | free(result); |
|
|
326 | ERROR1: |
|
|
327 | return NULL; |
218 | } |
328 | } |
219 | |
329 | |
220 | psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr) |
330 | psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr) |
221 | { |
331 | { |
222 | if (nr == 0) |
332 | if (nr == 0) |
223 | return ss->normal; |
333 | return ss->normal; |
224 | else |
334 | else |
225 | return psiconv_list_get(ss->styles,0xff - nr); |
335 | return psiconv_list_get(ss->styles,0xff - nr); |
226 | } |
336 | } |
|
|
337 | |
|
|
338 | psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) |
|
|
339 | { |
|
|
340 | return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); |
|
|
341 | } |
|
|
342 | |
|
|
343 | /* TODO: What if a cell is both in a default row and a default column?!? */ |
|
|
344 | psiconv_sheet_cell_layout psiconv_get_default_layout |
|
|
345 | (psiconv_sheet_line_list row_defaults, |
|
|
346 | psiconv_sheet_line_list col_defaults, |
|
|
347 | psiconv_sheet_cell_layout cell_default, |
|
|
348 | int row,int col) |
|
|
349 | { |
|
|
350 | int i; |
|
|
351 | psiconv_sheet_line line; |
|
|
352 | for (i = 0;i < psiconv_list_length(row_defaults);i++) { |
|
|
353 | line = psiconv_list_get(row_defaults,i); |
|
|
354 | if (line->position == row) |
|
|
355 | return line->layout; |
|
|
356 | } |
|
|
357 | for (i = 0;i < psiconv_list_length(col_defaults);i++) { |
|
|
358 | line = psiconv_list_get(col_defaults,i); |
|
|
359 | if (line->position == col) |
|
|
360 | return line->layout; |
|
|
361 | } |
|
|
362 | return cell_default; |
|
|
363 | } |
|
|
364 | |
227 | |
365 | |
228 | void psiconv_free_color (psiconv_color color) |
366 | void psiconv_free_color (psiconv_color color) |
229 | { |
367 | { |
230 | if (color) |
368 | if (color) |
231 | free(color); |
369 | free(color); |
… | |
… | |
309 | psiconv_free_style_aux(style); |
447 | psiconv_free_style_aux(style); |
310 | free(style); |
448 | free(style); |
311 | } |
449 | } |
312 | } |
450 | } |
313 | |
451 | |
|
|
452 | void psiconv_free_word_style_list(psiconv_word_style_list style_list) |
|
|
453 | { |
|
|
454 | if (style_list) |
|
|
455 | psiconv_list_free_el(style_list,psiconv_free_style_aux); |
|
|
456 | } |
|
|
457 | |
314 | void psiconv_free_word_styles_section(psiconv_word_styles_section styles) |
458 | void psiconv_free_word_styles_section(psiconv_word_styles_section styles) |
315 | { |
459 | { |
316 | if (styles) { |
460 | if (styles) { |
317 | psiconv_free_word_style(styles->normal); |
461 | psiconv_free_word_style(styles->normal); |
318 | if (styles->styles) |
462 | psiconv_free_word_style_list(styles->styles); |
319 | psiconv_list_free_el(styles->styles,psiconv_free_style_aux); |
463 | free(styles); |
320 | } |
464 | } |
321 | } |
465 | } |
322 | |
466 | |
323 | void psiconv_free_header_section(psiconv_header_section header) |
467 | void psiconv_free_header_section(psiconv_header_section header) |
324 | { |
468 | { |
… | |
… | |
345 | free(section->name); |
489 | free(section->name); |
346 | free(section); |
490 | free(section); |
347 | } |
491 | } |
348 | } |
492 | } |
349 | |
493 | |
|
|
494 | void psiconv_free_object_icon_section(psiconv_object_icon_section section) |
|
|
495 | { |
|
|
496 | if (section) { |
|
|
497 | if (section->icon_name) |
|
|
498 | free(section->icon_name); |
|
|
499 | free(section); |
|
|
500 | } |
|
|
501 | } |
|
|
502 | |
|
|
503 | void psiconv_free_object_display_section(psiconv_object_display_section section) |
|
|
504 | { |
|
|
505 | if (section) |
|
|
506 | free(section); |
|
|
507 | } |
|
|
508 | |
|
|
509 | void psiconv_free_embedded_object_section |
|
|
510 | (psiconv_embedded_object_section object) |
|
|
511 | { |
|
|
512 | if (object) { |
|
|
513 | psiconv_free_object_icon_section(object->icon); |
|
|
514 | psiconv_free_object_display_section(object->display); |
|
|
515 | psiconv_free_file(object->object); |
|
|
516 | free(object); |
|
|
517 | } |
|
|
518 | } |
|
|
519 | |
350 | void psiconv_free_in_line_layout_aux(void * layout) |
520 | void psiconv_free_in_line_layout_aux(void * layout) |
351 | { |
521 | { |
352 | psiconv_free_character_layout(((psiconv_in_line_layout) layout)->layout); |
522 | psiconv_free_character_layout(((psiconv_in_line_layout) layout)->layout); |
|
|
523 | psiconv_free_embedded_object_section |
|
|
524 | (((psiconv_in_line_layout) layout)->object); |
353 | } |
525 | } |
354 | |
526 | |
355 | void psiconv_free_in_line_layout(psiconv_in_line_layout layout) |
527 | void psiconv_free_in_line_layout(psiconv_in_line_layout layout) |
356 | { |
528 | { |
357 | if (layout) { |
529 | if (layout) { |
… | |
… | |
448 | psiconv_free_word_styles_section(file->styles_sec); |
620 | psiconv_free_word_styles_section(file->styles_sec); |
449 | free(file); |
621 | free(file); |
450 | } |
622 | } |
451 | } |
623 | } |
452 | |
624 | |
|
|
625 | void psiconv_free_sheet_status_section(psiconv_sheet_status_section section) |
|
|
626 | { |
|
|
627 | if (section) |
|
|
628 | free(section); |
|
|
629 | } |
|
|
630 | |
|
|
631 | void psiconv_free_sheet_numberformat(psiconv_sheet_numberformat numberformat) |
|
|
632 | { |
|
|
633 | if (numberformat) |
|
|
634 | free(numberformat); |
|
|
635 | } |
|
|
636 | |
|
|
637 | void psiconv_free_sheet_cell_layout(psiconv_sheet_cell_layout layout) |
|
|
638 | { |
|
|
639 | psiconv_free_paragraph_layout(layout->paragraph); |
|
|
640 | psiconv_free_character_layout(layout->character); |
|
|
641 | psiconv_free_sheet_numberformat(layout->numberformat); |
|
|
642 | } |
|
|
643 | |
|
|
644 | void psiconv_free_sheet_cell_aux(void *cell) |
|
|
645 | { |
|
|
646 | psiconv_sheet_cell data = cell; |
|
|
647 | |
|
|
648 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
649 | |
|
|
650 | if ((data->type == psiconv_cell_string) && (data->data.dat_string)) |
|
|
651 | free(data->data.dat_string); |
|
|
652 | } |
|
|
653 | |
|
|
654 | void psiconv_free_sheet_cell(psiconv_sheet_cell cell) |
|
|
655 | { |
|
|
656 | if (cell) { |
|
|
657 | psiconv_free_sheet_cell_aux(cell); |
|
|
658 | free(cell); |
|
|
659 | } |
|
|
660 | } |
|
|
661 | |
|
|
662 | void psiconv_free_sheet_cell_list(psiconv_sheet_cell_list list) |
|
|
663 | { |
|
|
664 | if (list) |
|
|
665 | psiconv_list_free_el(list,psiconv_free_sheet_cell_aux); |
|
|
666 | } |
|
|
667 | |
|
|
668 | void psiconv_free_sheet_line_aux(void *line) |
|
|
669 | { |
|
|
670 | psiconv_sheet_line data = line; |
|
|
671 | |
|
|
672 | psiconv_free_sheet_cell_layout(data->layout); |
|
|
673 | } |
|
|
674 | |
|
|
675 | void psiconv_free_sheet_line(psiconv_sheet_line line) |
|
|
676 | { |
|
|
677 | if (line) { |
|
|
678 | psiconv_free_sheet_line_aux(line); |
|
|
679 | free(line); |
|
|
680 | } |
|
|
681 | } |
|
|
682 | |
|
|
683 | |
|
|
684 | void psiconv_free_sheet_line_list(psiconv_sheet_line_list list) |
|
|
685 | { |
|
|
686 | if (list) |
|
|
687 | psiconv_list_free_el(list,psiconv_free_sheet_line_aux); |
|
|
688 | } |
|
|
689 | |
|
|
690 | void psiconv_free_sheet_grid_break_list(psiconv_sheet_grid_break_list list) |
|
|
691 | { |
|
|
692 | if (list) |
|
|
693 | psiconv_list_free(list); |
|
|
694 | } |
|
|
695 | |
|
|
696 | void psiconv_free_sheet_grid_size(psiconv_sheet_grid_size s) |
|
|
697 | { |
|
|
698 | if (s) |
|
|
699 | free(s); |
|
|
700 | } |
|
|
701 | |
|
|
702 | void psiconv_free_sheet_grid_size_list(psiconv_sheet_grid_size_list list) |
|
|
703 | { |
|
|
704 | if (list) |
|
|
705 | psiconv_list_free(list); |
|
|
706 | } |
|
|
707 | |
|
|
708 | void psiconv_free_sheet_grid_section(psiconv_sheet_grid_section sec) |
|
|
709 | { |
|
|
710 | if (sec) { |
|
|
711 | psiconv_free_sheet_grid_size_list(sec->row_heights); |
|
|
712 | psiconv_free_sheet_grid_size_list(sec->column_heights); |
|
|
713 | psiconv_free_sheet_grid_break_list(sec->row_page_breaks); |
|
|
714 | psiconv_free_sheet_grid_break_list(sec->column_page_breaks); |
|
|
715 | free(sec); |
|
|
716 | } |
|
|
717 | } |
|
|
718 | |
|
|
719 | void psiconv_free_sheet_worksheet_aux (void *data) |
|
|
720 | { |
|
|
721 | psiconv_sheet_worksheet section = data; |
|
|
722 | psiconv_free_sheet_cell_layout(section->default_layout); |
|
|
723 | psiconv_free_sheet_cell_list(section->cells); |
|
|
724 | psiconv_free_sheet_line_list(section->row_default_layouts); |
|
|
725 | psiconv_free_sheet_line_list(section->col_default_layouts); |
|
|
726 | psiconv_free_sheet_grid_section(section->grid); |
|
|
727 | } |
|
|
728 | |
|
|
729 | void psiconv_free_sheet_worksheet(psiconv_sheet_worksheet sheet) |
|
|
730 | { |
|
|
731 | if (sheet) { |
|
|
732 | psiconv_free_sheet_worksheet_aux(sheet); |
|
|
733 | free(sheet); |
|
|
734 | } |
|
|
735 | } |
|
|
736 | |
|
|
737 | void psiconv_free_sheet_worksheet_list(psiconv_sheet_worksheet_list list) |
|
|
738 | { |
|
|
739 | if (list) |
|
|
740 | psiconv_list_free_el(list,psiconv_free_sheet_worksheet_aux); |
|
|
741 | } |
|
|
742 | |
|
|
743 | void psiconv_free_formula_aux(void *data) |
|
|
744 | { |
|
|
745 | psiconv_formula formula; |
|
|
746 | formula = data; |
|
|
747 | if (formula->type == psiconv_formula_dat_string) |
|
|
748 | free(formula->data.dat_string); |
|
|
749 | else if ((formula->type != psiconv_formula_dat_int) && |
|
|
750 | (formula->type != psiconv_formula_dat_var) && |
|
|
751 | (formula->type != psiconv_formula_dat_float) && |
|
|
752 | (formula->type != psiconv_formula_dat_cellref) && |
|
|
753 | (formula->type != psiconv_formula_dat_cellblock) && |
|
|
754 | (formula->type != psiconv_formula_dat_vcellblock) && |
|
|
755 | (formula->type != psiconv_formula_mark_opsep) && |
|
|
756 | (formula->type != psiconv_formula_mark_opend) && |
|
|
757 | (formula->type != psiconv_formula_mark_eof) && |
|
|
758 | (formula->type != psiconv_formula_unknown)) |
|
|
759 | psiconv_free_formula_list(formula->data.fun_operands); |
|
|
760 | } |
|
|
761 | |
|
|
762 | void psiconv_free_formula(psiconv_formula formula) |
|
|
763 | { |
|
|
764 | if (formula) { |
|
|
765 | psiconv_free_formula_aux(formula); |
|
|
766 | free(formula); |
|
|
767 | } |
|
|
768 | } |
|
|
769 | |
|
|
770 | void psiconv_free_formula_list(psiconv_formula_list list) |
|
|
771 | { |
|
|
772 | if (list) |
|
|
773 | psiconv_list_free_el(list,psiconv_free_formula_aux); |
|
|
774 | } |
|
|
775 | |
|
|
776 | void psiconv_free_sheet_name_section(psiconv_sheet_name_section section) |
|
|
777 | { |
|
|
778 | if (section) { |
|
|
779 | if(section->name) |
|
|
780 | free(section->name); |
|
|
781 | free(section); |
|
|
782 | } |
|
|
783 | } |
|
|
784 | |
|
|
785 | void psiconv_free_sheet_info_section(psiconv_sheet_info_section section) |
|
|
786 | { |
|
|
787 | if (section) { |
|
|
788 | free(section); |
|
|
789 | } |
|
|
790 | } |
|
|
791 | |
|
|
792 | void psiconv_free_sheet_variable_aux(void * variable) |
|
|
793 | { |
|
|
794 | psiconv_sheet_variable var = variable; |
|
|
795 | if (var->name) |
|
|
796 | free(var->name); |
|
|
797 | if (var->type == psiconv_var_string) |
|
|
798 | free(var->data.dat_string); |
|
|
799 | } |
|
|
800 | |
|
|
801 | void psiconv_free_sheet_variable(psiconv_sheet_variable var) |
|
|
802 | { |
|
|
803 | if (var) { |
|
|
804 | psiconv_free_sheet_variable_aux(var); |
|
|
805 | free(var); |
|
|
806 | } |
|
|
807 | } |
|
|
808 | |
|
|
809 | void psiconv_free_sheet_variable_list(psiconv_sheet_variable_list list) |
|
|
810 | { |
|
|
811 | if (list) |
|
|
812 | psiconv_list_free_el(list,psiconv_free_sheet_variable_aux); |
|
|
813 | } |
|
|
814 | |
|
|
815 | void psiconv_free_sheet_workbook_section(psiconv_sheet_workbook_section section) |
|
|
816 | { |
|
|
817 | if (section) { |
|
|
818 | psiconv_free_formula_list(section->formulas); |
|
|
819 | psiconv_free_sheet_worksheet_list(section->worksheets); |
|
|
820 | psiconv_free_sheet_name_section(section->name); |
|
|
821 | psiconv_free_sheet_info_section(section->info); |
|
|
822 | psiconv_free_sheet_variable_list(section->variables); |
|
|
823 | free(section); |
|
|
824 | } |
|
|
825 | } |
|
|
826 | |
|
|
827 | void psiconv_free_sheet_f(psiconv_sheet_f file) |
|
|
828 | { |
|
|
829 | if (file) { |
|
|
830 | psiconv_free_page_layout_section(file->page_sec); |
|
|
831 | psiconv_free_sheet_status_section(file->status_sec); |
|
|
832 | psiconv_free_sheet_workbook_section(file->workbook_sec); |
|
|
833 | free(file); |
|
|
834 | } |
|
|
835 | } |
|
|
836 | |
453 | void psiconv_free_texted_f(psiconv_texted_f file) |
837 | void psiconv_free_texted_f(psiconv_texted_f file) |
454 | { |
838 | { |
455 | if (file) { |
839 | if (file) { |
456 | psiconv_free_page_layout_section(file->page_sec); |
840 | psiconv_free_page_layout_section(file->page_sec); |
457 | psiconv_free_texted_section(file->texted_sec); |
841 | psiconv_free_texted_section(file->texted_sec); |
… | |
… | |
481 | { |
865 | { |
482 | if (section) |
866 | if (section) |
483 | psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux); |
867 | psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux); |
484 | } |
868 | } |
485 | |
869 | |
486 | void psiconv_free_mbm_jumptable_section (psiconv_mbm_jumptable_section section) |
870 | void psiconv_free_jumptable_section (psiconv_jumptable_section section) |
487 | { |
871 | { |
488 | if (section) |
872 | if (section) |
489 | psiconv_list_free(section); |
873 | psiconv_list_free(section); |
490 | } |
874 | } |
491 | |
875 | |
492 | void psiconv_free_mbm_f(psiconv_mbm_f file) |
876 | void psiconv_free_mbm_f(psiconv_mbm_f file) |
493 | { |
877 | { |
494 | if (file) { |
878 | if (file) { |
495 | psiconv_free_pictures(file->sections); |
879 | psiconv_free_pictures(file->sections); |
|
|
880 | free(file); |
|
|
881 | } |
|
|
882 | } |
|
|
883 | |
|
|
884 | void psiconv_free_sketch_section(psiconv_sketch_section sec) |
|
|
885 | { |
|
|
886 | if (sec) { |
|
|
887 | psiconv_free_paint_data_section(sec->picture); |
|
|
888 | free(sec); |
|
|
889 | } |
|
|
890 | } |
|
|
891 | |
|
|
892 | void psiconv_free_sketch_f(psiconv_sketch_f file) |
|
|
893 | { |
|
|
894 | if (file) { |
|
|
895 | psiconv_free_sketch_section(file->sketch_sec); |
|
|
896 | free(file); |
|
|
897 | } |
|
|
898 | } |
|
|
899 | |
|
|
900 | void psiconv_free_clipart_section_aux(void *section) |
|
|
901 | { |
|
|
902 | if (section) |
|
|
903 | psiconv_free_paint_data_section(((psiconv_clipart_section) section)->picture); |
|
|
904 | } |
|
|
905 | |
|
|
906 | void psiconv_free_clipart_section(psiconv_clipart_section section) |
|
|
907 | { |
|
|
908 | if (section) { |
|
|
909 | psiconv_free_clipart_section_aux(section); |
|
|
910 | free(section); |
|
|
911 | } |
|
|
912 | } |
|
|
913 | |
|
|
914 | void psiconv_free_cliparts(psiconv_cliparts section) |
|
|
915 | { |
|
|
916 | if (section) |
|
|
917 | psiconv_list_free_el(section,&psiconv_free_clipart_section_aux); |
|
|
918 | } |
|
|
919 | |
|
|
920 | void psiconv_free_clipart_f(psiconv_clipart_f file) |
|
|
921 | { |
|
|
922 | if (file) { |
|
|
923 | psiconv_free_cliparts(file->sections); |
496 | free(file); |
924 | free(file); |
497 | } |
925 | } |
498 | } |
926 | } |
499 | |
927 | |
500 | void psiconv_free_file(psiconv_file file) |
928 | void psiconv_free_file(psiconv_file file) |
… | |
… | |
504 | psiconv_free_word_f((psiconv_word_f) file->file); |
932 | psiconv_free_word_f((psiconv_word_f) file->file); |
505 | else if (file->type == psiconv_texted_file) |
933 | else if (file->type == psiconv_texted_file) |
506 | psiconv_free_texted_f((psiconv_texted_f) file->file); |
934 | psiconv_free_texted_f((psiconv_texted_f) file->file); |
507 | else if (file->type == psiconv_mbm_file) |
935 | else if (file->type == psiconv_mbm_file) |
508 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
936 | psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
|
|
937 | else if (file->type == psiconv_sketch_file) |
|
|
938 | psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
|
|
939 | else if (file->type == psiconv_clipart_file) |
|
|
940 | psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
|
|
941 | else if (file->type == psiconv_sheet_file) |
|
|
942 | psiconv_free_sheet_f((psiconv_sheet_f) file->file); |
509 | free(file); |
943 | free(file); |
510 | } |
944 | } |
511 | } |
945 | } |
|
|
946 | |
|
|
947 | int psiconv_compare_color(const psiconv_color value1, |
|
|
948 | const psiconv_color value2) |
|
|
949 | { |
|
|
950 | if (!value1 || !value2) |
|
|
951 | return 1; |
|
|
952 | if ((value1->red == value2->red) && |
|
|
953 | (value1->green == value2->green) && |
|
|
954 | (value1->blue == value2->blue)) |
|
|
955 | return 0; |
|
|
956 | else |
|
|
957 | return 1; |
|
|
958 | } |
|
|
959 | |
|
|
960 | int psiconv_compare_font(const psiconv_font value1, |
|
|
961 | const psiconv_font value2) |
|
|
962 | { |
|
|
963 | if (!value1 || !value2 || !value1->name || !value2->name) |
|
|
964 | return 1; |
|
|
965 | if ((value1->screenfont == value2->screenfont) && |
|
|
966 | !psiconv_unicode_strcmp(value1->name,value2->name)) |
|
|
967 | return 0; |
|
|
968 | else |
|
|
969 | return 1; |
|
|
970 | } |
|
|
971 | |
|
|
972 | int psiconv_compare_border(const psiconv_border value1, |
|
|
973 | const psiconv_border value2) |
|
|
974 | { |
|
|
975 | if (!value1 || !value2) |
|
|
976 | return 1; |
|
|
977 | if ((value1->kind == value2->kind) && |
|
|
978 | (value1->thickness == value2->thickness) && |
|
|
979 | !psiconv_compare_color(value1->color,value2->color)) |
|
|
980 | return 0; |
|
|
981 | else |
|
|
982 | return 1; |
|
|
983 | } |
|
|
984 | |
|
|
985 | int psiconv_compare_bullet(const psiconv_bullet value1, |
|
|
986 | const psiconv_bullet value2) |
|
|
987 | { |
|
|
988 | if (!value1 || !value2) |
|
|
989 | return 1; |
|
|
990 | if ((value1->on == value2->on) && |
|
|
991 | (value1->font_size == value2->font_size) && |
|
|
992 | (value1->character == value2->character) && |
|
|
993 | (value1->indent == value2->indent) && |
|
|
994 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
995 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
996 | return 0; |
|
|
997 | else |
|
|
998 | return 1; |
|
|
999 | } |
|
|
1000 | |
|
|
1001 | int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2) |
|
|
1002 | { |
|
|
1003 | if (!value1 || !value2) |
|
|
1004 | return 1; |
|
|
1005 | if ((value1->location == value2->location) && |
|
|
1006 | (value1->kind == value2->kind)) |
|
|
1007 | return 0; |
|
|
1008 | else |
|
|
1009 | return 1; |
|
|
1010 | } |
|
|
1011 | |
|
|
1012 | int psiconv_compare_all_tabs(const psiconv_all_tabs value1, |
|
|
1013 | const psiconv_all_tabs value2) |
|
|
1014 | { |
|
|
1015 | int i; |
|
|
1016 | |
|
|
1017 | if (!value1 || !value2 || !value1->extras || !value2->extras) |
|
|
1018 | return 1; |
|
|
1019 | |
|
|
1020 | if ((value1->normal != value2->normal) || |
|
|
1021 | psiconv_list_length(value1->extras) != |
|
|
1022 | psiconv_list_length(value2->extras)) |
|
|
1023 | return 1; |
|
|
1024 | for (i = 0; i < psiconv_list_length(value1->extras); i++) |
|
|
1025 | if (psiconv_compare_tab(psiconv_list_get(value1->extras,i), |
|
|
1026 | psiconv_list_get(value2->extras,i))) |
|
|
1027 | |
|
|
1028 | return 1; |
|
|
1029 | return 0; |
|
|
1030 | } |
|
|
1031 | |
|
|
1032 | int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1, |
|
|
1033 | const psiconv_paragraph_layout value2) |
|
|
1034 | { |
|
|
1035 | if (!value1 || !value2) |
|
|
1036 | return 1; |
|
|
1037 | if ((value1->indent_left == value2->indent_left) && |
|
|
1038 | (value1->indent_right == value2->indent_right) && |
|
|
1039 | (value1->indent_first == value2->indent_first) && |
|
|
1040 | (value1->justify_hor == value2->justify_hor) && |
|
|
1041 | (value1->justify_ver == value2->justify_ver) && |
|
|
1042 | (value1->linespacing == value2->linespacing) && |
|
|
1043 | (value1->space_above == value2->space_above) && |
|
|
1044 | (value1->space_below == value2->space_below) && |
|
|
1045 | (value1->keep_together == value2->keep_together) && |
|
|
1046 | (value1->keep_with_next == value2->keep_with_next) && |
|
|
1047 | (value1->on_next_page == value2->on_next_page) && |
|
|
1048 | (value1->no_widow_protection == value2->no_widow_protection) && |
|
|
1049 | (value1->border_distance == value2->border_distance) && |
|
|
1050 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
1051 | !psiconv_compare_bullet(value1->bullet,value2->bullet) && |
|
|
1052 | !psiconv_compare_border(value1->left_border,value2->left_border) && |
|
|
1053 | !psiconv_compare_border(value1->right_border,value2->right_border) && |
|
|
1054 | !psiconv_compare_border(value1->top_border,value2->top_border) && |
|
|
1055 | !psiconv_compare_border(value1->bottom_border,value2->bottom_border) && |
|
|
1056 | !psiconv_compare_all_tabs(value1->tabs,value2->tabs)) |
|
|
1057 | return 0; |
|
|
1058 | else |
|
|
1059 | return 1; |
|
|
1060 | } |
|
|
1061 | |
|
|
1062 | |
|
|
1063 | int psiconv_compare_character_layout(const psiconv_character_layout value1, |
|
|
1064 | const psiconv_character_layout value2) |
|
|
1065 | { |
|
|
1066 | if (!value1 || !value2) |
|
|
1067 | return 1; |
|
|
1068 | if ((value1->font_size == value2->font_size) && |
|
|
1069 | (value1->italic == value2->italic) && |
|
|
1070 | (value1->bold == value2->bold) && |
|
|
1071 | (value1->super_sub == value2->super_sub) && |
|
|
1072 | (value1->underline == value2->underline) && |
|
|
1073 | (value1->strikethrough == value2->strikethrough) && |
|
|
1074 | !psiconv_compare_color(value1->color,value2->color) && |
|
|
1075 | !psiconv_compare_color(value1->back_color,value2->back_color) && |
|
|
1076 | !psiconv_compare_font(value1->font,value2->font)) |
|
|
1077 | return 0; |
|
|
1078 | else |
|
|
1079 | return 1; |
|
|
1080 | } |
|
|
1081 | |
|
|
1082 | |
|
|
1083 | |
|
|
1084 | psiconv_word_styles_section psiconv_empty_word_styles_section(void) |
|
|
1085 | { |
|
|
1086 | psiconv_word_styles_section result; |
|
|
1087 | if (!(result = malloc(sizeof(*result)))) |
|
|
1088 | goto ERROR1; |
|
|
1089 | if (!(result->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s)))) |
|
|
1090 | goto ERROR2; |
|
|
1091 | if (!(result->normal = malloc(sizeof(struct psiconv_word_style_s)))) |
|
|
1092 | goto ERROR3; |
|
|
1093 | if (!(result->normal->character = psiconv_basic_character_layout())) |
|
|
1094 | goto ERROR4; |
|
|
1095 | if (!(result->normal->paragraph = psiconv_basic_paragraph_layout())) |
|
|
1096 | goto ERROR5; |
|
|
1097 | result->normal->hotkey = 'N'; |
|
|
1098 | result->normal->name = NULL; |
|
|
1099 | result->normal->built_in = psiconv_bool_true; |
|
|
1100 | result->normal->outline_level = 0; |
|
|
1101 | return result; |
|
|
1102 | ERROR5: |
|
|
1103 | psiconv_free_character_layout(result->normal->character); |
|
|
1104 | ERROR4: |
|
|
1105 | free(result->normal); |
|
|
1106 | ERROR3: |
|
|
1107 | psiconv_list_free(result->styles); |
|
|
1108 | ERROR2: |
|
|
1109 | free(result); |
|
|
1110 | ERROR1: |
|
|
1111 | return NULL; |
|
|
1112 | } |
|
|
1113 | |
|
|
1114 | psiconv_text_and_layout psiconv_empty_text_and_layout(void) |
|
|
1115 | { |
|
|
1116 | return psiconv_list_new(sizeof(struct psiconv_paragraph_s)); |
|
|
1117 | } |
|
|
1118 | |
|
|
1119 | psiconv_texted_section psiconv_empty_texted_section(void) |
|
|
1120 | { |
|
|
1121 | psiconv_texted_section result; |
|
|
1122 | if (!(result = malloc(sizeof(*result)))) |
|
|
1123 | goto ERROR1; |
|
|
1124 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
1125 | goto ERROR2; |
|
|
1126 | return result; |
|
|
1127 | ERROR2: |
|
|
1128 | free(result); |
|
|
1129 | ERROR1: |
|
|
1130 | return NULL; |
|
|
1131 | } |
|
|
1132 | |
|
|
1133 | psiconv_page_header psiconv_empty_page_header(void) |
|
|
1134 | { |
|
|
1135 | psiconv_page_header result; |
|
|
1136 | if (!(result = malloc(sizeof(*result)))) |
|
|
1137 | goto ERROR1; |
|
|
1138 | result->on_first_page = psiconv_bool_true; |
|
|
1139 | if (!(result->base_paragraph_layout = psiconv_basic_paragraph_layout())) |
|
|
1140 | goto ERROR2; |
|
|
1141 | if (!(result->base_character_layout = psiconv_basic_character_layout())) |
|
|
1142 | goto ERROR3; |
|
|
1143 | if (!(result->text = psiconv_empty_texted_section())) |
|
|
1144 | goto ERROR4; |
|
|
1145 | return result; |
|
|
1146 | ERROR4: |
|
|
1147 | psiconv_free_character_layout(result->base_character_layout); |
|
|
1148 | ERROR3: |
|
|
1149 | psiconv_free_paragraph_layout(result->base_paragraph_layout); |
|
|
1150 | ERROR2: |
|
|
1151 | free(result); |
|
|
1152 | ERROR1: |
|
|
1153 | return NULL; |
|
|
1154 | } |
|
|
1155 | |
|
|
1156 | psiconv_page_layout_section psiconv_empty_page_layout_section(void) |
|
|
1157 | { |
|
|
1158 | psiconv_page_layout_section result; |
|
|
1159 | if (!(result = malloc(sizeof(*result)))) |
|
|
1160 | goto ERROR1; |
|
|
1161 | result->first_page_nr = 1; |
|
|
1162 | result->header_dist = result->footer_dist = 1.27; |
|
|
1163 | result->left_margin = result->right_margin = 3.175; |
|
|
1164 | result->top_margin = result->bottom_margin = 2.54; |
|
|
1165 | result->page_width = 21.0; |
|
|
1166 | result->page_height = 29.7; |
|
|
1167 | result->landscape = psiconv_bool_false; |
|
|
1168 | if (!(result->header = psiconv_empty_page_header())) |
|
|
1169 | goto ERROR2; |
|
|
1170 | if (!(result->footer = psiconv_empty_page_header())) |
|
|
1171 | goto ERROR3; |
|
|
1172 | return result; |
|
|
1173 | ERROR3: |
|
|
1174 | psiconv_free_page_header(result->header); |
|
|
1175 | ERROR2: |
|
|
1176 | free(result); |
|
|
1177 | ERROR1: |
|
|
1178 | return NULL; |
|
|
1179 | } |
|
|
1180 | |
|
|
1181 | psiconv_word_status_section psiconv_empty_word_status_section(void) |
|
|
1182 | { |
|
|
1183 | psiconv_word_status_section result; |
|
|
1184 | if (!(result = malloc(sizeof(*result)))) |
|
|
1185 | return NULL; |
|
|
1186 | result->show_tabs = result->show_spaces = result->show_paragraph_ends = |
|
|
1187 | result->show_hard_minus = result->show_hard_space = |
|
|
1188 | result->fit_lines_to_screen = psiconv_bool_false; |
|
|
1189 | result->show_full_pictures = result->show_full_graphs = |
|
|
1190 | result->show_top_toolbar = result->show_side_toolbar = |
|
|
1191 | psiconv_bool_true; |
|
|
1192 | result->cursor_position = 0; |
|
|
1193 | result->display_size = 1000; |
|
|
1194 | return result; |
|
|
1195 | } |
|
|
1196 | |
|
|
1197 | psiconv_word_f psiconv_empty_word_f(void) |
|
|
1198 | { |
|
|
1199 | psiconv_word_f result; |
|
|
1200 | if (!(result = malloc(sizeof(*result)))) |
|
|
1201 | goto ERROR1; |
|
|
1202 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1203 | goto ERROR2; |
|
|
1204 | if (!(result->paragraphs = psiconv_empty_text_and_layout())) |
|
|
1205 | goto ERROR3; |
|
|
1206 | if (!(result->status_sec = psiconv_empty_word_status_section())) |
|
|
1207 | goto ERROR4; |
|
|
1208 | if (!(result->styles_sec = psiconv_empty_word_styles_section())) |
|
|
1209 | goto ERROR5; |
|
|
1210 | return result; |
|
|
1211 | ERROR5: |
|
|
1212 | psiconv_free_word_status_section(result->status_sec); |
|
|
1213 | ERROR4: |
|
|
1214 | psiconv_free_text_and_layout(result->paragraphs); |
|
|
1215 | ERROR3: |
|
|
1216 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1217 | ERROR2: |
|
|
1218 | free(result); |
|
|
1219 | ERROR1: |
|
|
1220 | return NULL; |
|
|
1221 | } |
|
|
1222 | |
|
|
1223 | psiconv_sheet_status_section psiconv_empty_sheet_status_section(void) |
|
|
1224 | { |
|
|
1225 | psiconv_sheet_status_section result; |
|
|
1226 | if (!(result = malloc(sizeof(*result)))) |
|
|
1227 | return NULL; |
|
|
1228 | result->show_horizontal_scrollbar = result->show_vertical_scrollbar = |
|
|
1229 | psiconv_triple_auto; |
|
|
1230 | result->show_graph = psiconv_bool_false; |
|
|
1231 | result->show_top_sheet_toolbar = result->show_side_sheet_toolbar = |
|
|
1232 | result->show_top_graph_toolbar = result->show_side_graph_toolbar = |
|
|
1233 | psiconv_bool_true; |
|
|
1234 | result->cursor_row = result->cursor_column = 0; |
|
|
1235 | result->sheet_display_size = result->graph_display_size = 1000; |
|
|
1236 | return result; |
|
|
1237 | } |
|
|
1238 | |
|
|
1239 | psiconv_formula_list psiconv_empty_formula_list(void) |
|
|
1240 | { |
|
|
1241 | return psiconv_list_new(sizeof(struct psiconv_formula_s)); |
|
|
1242 | } |
|
|
1243 | |
|
|
1244 | psiconv_sheet_workbook_section psiconv_empty_sheet_workbook_section(void) |
|
|
1245 | { |
|
|
1246 | psiconv_sheet_workbook_section result; |
|
|
1247 | if (!(result = malloc(sizeof(*result)))) |
|
|
1248 | goto ERROR1; |
|
|
1249 | if (!(result->formulas = psiconv_empty_formula_list())) |
|
|
1250 | goto ERROR2; |
|
|
1251 | return result; |
|
|
1252 | ERROR2: |
|
|
1253 | free(result); |
|
|
1254 | ERROR1: |
|
|
1255 | return NULL; |
|
|
1256 | } |
|
|
1257 | |
|
|
1258 | |
|
|
1259 | psiconv_sheet_f psiconv_empty_sheet_f(void) |
|
|
1260 | { |
|
|
1261 | psiconv_sheet_f result; |
|
|
1262 | if (!(result = malloc(sizeof(*result)))) |
|
|
1263 | goto ERROR1; |
|
|
1264 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1265 | goto ERROR2; |
|
|
1266 | if (!(result->status_sec = psiconv_empty_sheet_status_section())) |
|
|
1267 | goto ERROR3; |
|
|
1268 | if (!(result->workbook_sec = psiconv_empty_sheet_workbook_section())) |
|
|
1269 | goto ERROR4; |
|
|
1270 | return result; |
|
|
1271 | ERROR4: |
|
|
1272 | psiconv_free_sheet_status_section(result->status_sec); |
|
|
1273 | ERROR3: |
|
|
1274 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1275 | ERROR2: |
|
|
1276 | free(result); |
|
|
1277 | ERROR1: |
|
|
1278 | return NULL; |
|
|
1279 | } |
|
|
1280 | |
|
|
1281 | psiconv_texted_f psiconv_empty_texted_f(void) |
|
|
1282 | { |
|
|
1283 | psiconv_texted_f result; |
|
|
1284 | if (!(result = malloc(sizeof(*result)))) |
|
|
1285 | goto ERROR1; |
|
|
1286 | if (!(result->page_sec = psiconv_empty_page_layout_section())) |
|
|
1287 | goto ERROR2; |
|
|
1288 | if (!(result->texted_sec = psiconv_empty_texted_section())) |
|
|
1289 | goto ERROR3; |
|
|
1290 | return result; |
|
|
1291 | ERROR3: |
|
|
1292 | psiconv_free_page_layout_section(result->page_sec); |
|
|
1293 | ERROR2: |
|
|
1294 | free(result); |
|
|
1295 | ERROR1: |
|
|
1296 | return NULL; |
|
|
1297 | } |
|
|
1298 | |
|
|
1299 | psiconv_paint_data_section psiconv_empty_paint_data_section(void) |
|
|
1300 | { |
|
|
1301 | psiconv_paint_data_section result; |
|
|
1302 | if (!(result = malloc(sizeof(*result)))) |
|
|
1303 | goto ERROR1; |
|
|
1304 | /* Is this correct? */ |
|
|
1305 | result->xsize = result->ysize = result->pic_xsize = result->pic_ysize = 0; |
|
|
1306 | /* Probably forbidden... */ |
|
|
1307 | if (!(result->red = malloc(0))) |
|
|
1308 | goto ERROR2; |
|
|
1309 | if (!(result->green = malloc(0))) |
|
|
1310 | goto ERROR3; |
|
|
1311 | if (!(result->blue = malloc(0))) |
|
|
1312 | goto ERROR4; |
|
|
1313 | return result; |
|
|
1314 | ERROR4: |
|
|
1315 | free(result->green); |
|
|
1316 | ERROR3: |
|
|
1317 | free(result->red); |
|
|
1318 | ERROR2: |
|
|
1319 | free(result); |
|
|
1320 | ERROR1: |
|
|
1321 | return NULL; |
|
|
1322 | } |
|
|
1323 | |
|
|
1324 | |
|
|
1325 | psiconv_pictures psiconv_empty_pictures(void) |
|
|
1326 | { |
|
|
1327 | psiconv_pictures result; |
|
|
1328 | psiconv_paint_data_section pds; |
|
|
1329 | if (!(result = psiconv_list_new(sizeof(struct psiconv_paint_data_section_s)))) |
|
|
1330 | goto ERROR1; |
|
|
1331 | if (!(pds = psiconv_empty_paint_data_section())) |
|
|
1332 | goto ERROR2; |
|
|
1333 | if (psiconv_list_add(result,pds)) |
|
|
1334 | goto ERROR3; |
|
|
1335 | free(pds); |
|
|
1336 | return result; |
|
|
1337 | ERROR3: |
|
|
1338 | psiconv_free_paint_data_section(pds); |
|
|
1339 | ERROR2: |
|
|
1340 | psiconv_list_free(result); |
|
|
1341 | ERROR1: |
|
|
1342 | return NULL; |
|
|
1343 | } |
|
|
1344 | |
|
|
1345 | psiconv_mbm_f psiconv_empty_mbm_f(void) |
|
|
1346 | { |
|
|
1347 | psiconv_mbm_f result; |
|
|
1348 | if (!(result = malloc(sizeof(*result)))) |
|
|
1349 | goto ERROR1; |
|
|
1350 | if (!(result->sections = psiconv_empty_pictures())) |
|
|
1351 | goto ERROR2; |
|
|
1352 | return result; |
|
|
1353 | ERROR2: |
|
|
1354 | free(result); |
|
|
1355 | ERROR1: |
|
|
1356 | return NULL; |
|
|
1357 | } |
|
|
1358 | |
|
|
1359 | psiconv_sketch_section psiconv_empty_sketch_section(void) |
|
|
1360 | { |
|
|
1361 | psiconv_sketch_section result; |
|
|
1362 | if (!(result = malloc(sizeof(*result)))) |
|
|
1363 | goto ERROR1; |
|
|
1364 | result->displayed_xsize = 320; |
|
|
1365 | result->displayed_ysize = 200; |
|
|
1366 | result->picture_data_x_offset = result->picture_data_y_offset = |
|
|
1367 | result->form_xsize = result->form_ysize = |
|
|
1368 | result->displayed_size_x_offset = result->displayed_size_y_offset = 0; |
|
|
1369 | result->magnification_x = result->magnification_y = 1.0; |
|
|
1370 | result->cut_left = result->cut_right = result->cut_top = |
|
|
1371 | result->cut_bottom = 0.0; |
|
|
1372 | if (!(result->picture = psiconv_empty_paint_data_section())) |
|
|
1373 | goto ERROR2; |
|
|
1374 | return result; |
|
|
1375 | ERROR2: |
|
|
1376 | free(result); |
|
|
1377 | ERROR1: |
|
|
1378 | return NULL; |
|
|
1379 | } |
|
|
1380 | |
|
|
1381 | psiconv_sketch_f psiconv_empty_sketch_f(void) |
|
|
1382 | { |
|
|
1383 | psiconv_sketch_f result; |
|
|
1384 | if (!(result = malloc(sizeof(*result)))) |
|
|
1385 | goto ERROR1; |
|
|
1386 | if (!(result->sketch_sec = psiconv_empty_sketch_section())) |
|
|
1387 | goto ERROR2; |
|
|
1388 | return result; |
|
|
1389 | ERROR2: |
|
|
1390 | free(result); |
|
|
1391 | ERROR1: |
|
|
1392 | return NULL; |
|
|
1393 | } |
|
|
1394 | |
|
|
1395 | psiconv_cliparts psiconv_empty_cliparts(void) |
|
|
1396 | { |
|
|
1397 | /* Is this correct? */ |
|
|
1398 | return psiconv_list_new(sizeof(struct psiconv_clipart_section_s)); |
|
|
1399 | } |
|
|
1400 | |
|
|
1401 | psiconv_clipart_f psiconv_empty_clipart_f(void) |
|
|
1402 | { |
|
|
1403 | psiconv_clipart_f result; |
|
|
1404 | if (!(result = malloc(sizeof(*result)))) |
|
|
1405 | goto ERROR1; |
|
|
1406 | if (!(result->sections = psiconv_empty_cliparts())) |
|
|
1407 | goto ERROR2; |
|
|
1408 | return result; |
|
|
1409 | ERROR2: |
|
|
1410 | free(result); |
|
|
1411 | ERROR1: |
|
|
1412 | return NULL; |
|
|
1413 | } |
|
|
1414 | |
|
|
1415 | psiconv_file psiconv_empty_file(psiconv_file_type_t type) |
|
|
1416 | { |
|
|
1417 | psiconv_file result; |
|
|
1418 | if (!(result = malloc(sizeof(*result)))) |
|
|
1419 | return NULL; |
|
|
1420 | result->type = type; |
|
|
1421 | if (type == psiconv_word_file) { |
|
|
1422 | if (!(result->file = psiconv_empty_word_f())) |
|
|
1423 | goto ERROR; |
|
|
1424 | } else if (type == psiconv_sheet_file) { |
|
|
1425 | if (!(result->file = psiconv_empty_sheet_f())) |
|
|
1426 | goto ERROR; |
|
|
1427 | } else if (type == psiconv_texted_file) { |
|
|
1428 | if (!(result->file = psiconv_empty_texted_f())) |
|
|
1429 | goto ERROR; |
|
|
1430 | } else if (type == psiconv_mbm_file) { |
|
|
1431 | if (!(result->file = psiconv_empty_mbm_f())) |
|
|
1432 | goto ERROR; |
|
|
1433 | } else if (type == psiconv_sketch_file) { |
|
|
1434 | if (!(result->file = psiconv_empty_sketch_f())) |
|
|
1435 | goto ERROR; |
|
|
1436 | } else if (type == psiconv_clipart_file) { |
|
|
1437 | if (!(result->file = psiconv_empty_clipart_f())) |
|
|
1438 | goto ERROR; |
|
|
1439 | } else |
|
|
1440 | goto ERROR; |
|
|
1441 | return result; |
|
|
1442 | ERROR: |
|
|
1443 | free(result); |
|
|
1444 | return NULL; |
|
|
1445 | } |