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