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