1 |
/* |
2 |
data.c - Part of psiconv, a PSION 5 file formats converter |
3 |
Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
4 |
|
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 |
#include "compat.h" |
22 |
#include <stdlib.h> |
23 |
#include <string.h> |
24 |
#include "data.h" |
25 |
|
26 |
static psiconv_color clone_color(psiconv_color color); |
27 |
static psiconv_font clone_font(psiconv_font font); |
28 |
static psiconv_border clone_border(psiconv_border border); |
29 |
static psiconv_bullet clone_bullet(psiconv_bullet bullet); |
30 |
static psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs); |
31 |
static void psiconv_free_style_aux(void *style); |
32 |
static void psiconv_free_in_line_layout_aux(void * layout); |
33 |
static void psiconv_free_paragraph_aux(void * paragraph); |
34 |
static void psiconv_free_paint_data_section_aux(void * section); |
35 |
static void psiconv_free_clipart_section_aux(void * section); |
36 |
|
37 |
/* Note: these defaults seem to be hard-coded somewhere outside the |
38 |
files themself. */ |
39 |
psiconv_character_layout psiconv_basic_character_layout(void) |
40 |
{ |
41 |
/* Make the structures static, to oblige IRIX */ |
42 |
static struct psiconv_color_s black = |
43 |
{ |
44 |
0x00, /* red */ |
45 |
0x00, /* green */ |
46 |
0x00, /* blue */ |
47 |
}; |
48 |
static struct psiconv_color_s white = |
49 |
{ |
50 |
0xff, /* red */ |
51 |
0xff, /* green */ |
52 |
0xff, /* blue */ |
53 |
}; |
54 |
static struct psiconv_font_s font = |
55 |
{ |
56 |
"Times New Roman", /* name */ |
57 |
3 /* screenfont */ |
58 |
}; |
59 |
struct psiconv_character_layout_s cl = |
60 |
{ |
61 |
&black, /* color */ |
62 |
&white, /* back_color */ |
63 |
10.0, /* font_size */ |
64 |
psiconv_bool_false, /* italic */ |
65 |
psiconv_bool_false, /* bold */ |
66 |
psiconv_normalscript, /* super_sub */ |
67 |
psiconv_bool_false, /* underline */ |
68 |
psiconv_bool_false, /* strikethrough */ |
69 |
&font, /* font */ |
70 |
}; |
71 |
|
72 |
return psiconv_clone_character_layout(&cl); |
73 |
} |
74 |
|
75 |
/* Note: these defaults seem to be hard-coded somewhere outside the |
76 |
files themself. */ |
77 |
psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
78 |
{ |
79 |
static struct psiconv_font_s font = |
80 |
{ |
81 |
"Times New Roman", /* name */ |
82 |
2 /* screenfont */ |
83 |
}; |
84 |
static struct psiconv_color_s black = |
85 |
{ |
86 |
0x00, /* red */ |
87 |
0x00, /* green */ |
88 |
0x00, /* blue */ |
89 |
}; |
90 |
static struct psiconv_color_s white = |
91 |
{ |
92 |
0xff, /* red */ |
93 |
0xff, /* green */ |
94 |
0xff, /* blue */ |
95 |
}; |
96 |
static struct psiconv_border_s no_border = |
97 |
{ |
98 |
psiconv_border_none, /* kind */ |
99 |
1, /* thickness */ |
100 |
&black /* color */ |
101 |
}; |
102 |
static struct psiconv_bullet_s bullet = |
103 |
{ |
104 |
psiconv_bool_false, /* on */ |
105 |
10.0, /* font_size */ |
106 |
0x95, /* character */ |
107 |
psiconv_bool_true, /* indent */ |
108 |
&black, /* color */ |
109 |
&font, /* font */ |
110 |
}; |
111 |
static struct psiconv_all_tabs_s tabs = |
112 |
{ |
113 |
0.64, /* normal */ |
114 |
NULL /* kind */ |
115 |
}; |
116 |
struct psiconv_paragraph_layout_s pl = |
117 |
{ |
118 |
&white, /* back_color */ |
119 |
0.0, /* indent_left */ |
120 |
0.0, /* indent_right */ |
121 |
0.0, /* indent_first */ |
122 |
psiconv_justify_left, /* justify_hor */ |
123 |
psiconv_justify_middle,/* justify_ver */ |
124 |
10.0, /* linespacing */ |
125 |
psiconv_bool_false, /* linespacing_exact */ |
126 |
0.0, /* space_above */ |
127 |
0.0, /* space_below */ |
128 |
psiconv_bool_false, /* keep_together */ |
129 |
psiconv_bool_false, /* keep_with_next */ |
130 |
psiconv_bool_false, /* on_next_page */ |
131 |
psiconv_bool_false, /* no_widow_protection */ |
132 |
0.0, /* left_margin */ |
133 |
&bullet, /* bullet */ |
134 |
&no_border, /* left_border */ |
135 |
&no_border, /* right_border */ |
136 |
&no_border, /* top_border */ |
137 |
&no_border, /* bottom_border */ |
138 |
&tabs, /* tabs */ |
139 |
}; |
140 |
psiconv_paragraph_layout res; |
141 |
|
142 |
if (!(pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab_s)))) |
143 |
return NULL; |
144 |
res = psiconv_clone_paragraph_layout(&pl); |
145 |
psiconv_list_free(pl.tabs->extras); |
146 |
return res; |
147 |
} |
148 |
|
149 |
psiconv_color clone_color(psiconv_color color) |
150 |
{ |
151 |
psiconv_color result; |
152 |
if (!(result = malloc(sizeof(*result)))) |
153 |
return NULL; |
154 |
*result = *color; |
155 |
return result; |
156 |
} |
157 |
|
158 |
psiconv_font clone_font(psiconv_font font) |
159 |
{ |
160 |
psiconv_font result; |
161 |
if(!(result = malloc(sizeof(*result)))) |
162 |
goto ERROR1; |
163 |
*result = *font; |
164 |
if (!(result->name = strdup(result->name))) |
165 |
goto ERROR2; |
166 |
return result; |
167 |
ERROR2: |
168 |
free(result); |
169 |
ERROR1: |
170 |
return NULL; |
171 |
} |
172 |
|
173 |
psiconv_border clone_border(psiconv_border border) |
174 |
{ |
175 |
psiconv_border result; |
176 |
if (!(result = malloc(sizeof(*result)))) |
177 |
goto ERROR1; |
178 |
*result = *border; |
179 |
if(!(result->color = clone_color(result->color))) |
180 |
goto ERROR2; |
181 |
return result; |
182 |
ERROR2: |
183 |
free(result); |
184 |
ERROR1: |
185 |
return NULL; |
186 |
} |
187 |
|
188 |
psiconv_bullet clone_bullet(psiconv_bullet bullet) |
189 |
{ |
190 |
psiconv_bullet result; |
191 |
if (!(result = malloc(sizeof(*result)))) |
192 |
goto ERROR1; |
193 |
*result = *bullet; |
194 |
if (!(result->font = clone_font(result->font))) |
195 |
goto ERROR2; |
196 |
if (!(result->color = clone_color(result->color))) |
197 |
goto ERROR3; |
198 |
return result; |
199 |
ERROR3: |
200 |
psiconv_free_font(result->font); |
201 |
ERROR2: |
202 |
free(result); |
203 |
ERROR1: |
204 |
return NULL; |
205 |
} |
206 |
|
207 |
psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs) |
208 |
{ |
209 |
psiconv_all_tabs result; |
210 |
if (!(result = malloc(sizeof(*result)))) |
211 |
goto ERROR1; |
212 |
*result = *all_tabs; |
213 |
if (!(result->extras = psiconv_list_clone(result->extras))) |
214 |
goto ERROR2; |
215 |
return result; |
216 |
ERROR2: |
217 |
free(result); |
218 |
ERROR1: |
219 |
return NULL; |
220 |
} |
221 |
|
222 |
psiconv_character_layout psiconv_clone_character_layout |
223 |
(psiconv_character_layout ls) |
224 |
{ |
225 |
psiconv_character_layout result; |
226 |
|
227 |
if (!(result = malloc(sizeof(*result)))) |
228 |
goto ERROR1; |
229 |
*result = *ls; |
230 |
if (!(result->color = clone_color(result->color))) |
231 |
goto ERROR2; |
232 |
if (!(result->back_color = clone_color(result->back_color))) |
233 |
goto ERROR3; |
234 |
if (!(result->font = clone_font(result->font))) |
235 |
goto ERROR4; |
236 |
return result; |
237 |
ERROR4: |
238 |
psiconv_free_color(result->back_color); |
239 |
ERROR3: |
240 |
psiconv_free_color(result->color); |
241 |
ERROR2: |
242 |
free(result); |
243 |
ERROR1: |
244 |
return NULL; |
245 |
} |
246 |
|
247 |
psiconv_paragraph_layout psiconv_clone_paragraph_layout |
248 |
(psiconv_paragraph_layout ls) |
249 |
{ |
250 |
psiconv_paragraph_layout result; |
251 |
|
252 |
if (!(result = malloc(sizeof(*result)))) |
253 |
goto ERROR1; |
254 |
*result = *ls; |
255 |
if (!(result->back_color = clone_color(result->back_color))) |
256 |
goto ERROR2; |
257 |
if (!(result->bullet = clone_bullet(result->bullet))) |
258 |
goto ERROR3; |
259 |
if (!(result->left_border = clone_border(result->left_border))) |
260 |
goto ERROR4; |
261 |
if (!(result->right_border = clone_border(result->right_border))) |
262 |
goto ERROR5; |
263 |
if (!(result->top_border = clone_border(result->top_border))) |
264 |
goto ERROR6; |
265 |
if (!(result->bottom_border = clone_border(result->bottom_border))) |
266 |
goto ERROR7; |
267 |
if (!(result->tabs = clone_all_tabs(result->tabs))) |
268 |
goto ERROR8; |
269 |
return result; |
270 |
ERROR8: |
271 |
psiconv_free_border(result->bottom_border); |
272 |
ERROR7: |
273 |
psiconv_free_border(result->top_border); |
274 |
ERROR6: |
275 |
psiconv_free_border(result->right_border); |
276 |
ERROR5: |
277 |
psiconv_free_border(result->left_border); |
278 |
ERROR4: |
279 |
psiconv_free_bullet(result->bullet); |
280 |
ERROR3: |
281 |
psiconv_free_color(result->back_color); |
282 |
ERROR2: |
283 |
free(result); |
284 |
ERROR1: |
285 |
return NULL; |
286 |
} |
287 |
|
288 |
psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr) |
289 |
{ |
290 |
if (nr == 0) |
291 |
return ss->normal; |
292 |
else |
293 |
return psiconv_list_get(ss->styles,0xff - nr); |
294 |
} |
295 |
|
296 |
void psiconv_free_color (psiconv_color color) |
297 |
{ |
298 |
if (color) |
299 |
free(color); |
300 |
} |
301 |
|
302 |
void psiconv_free_border(psiconv_border border) |
303 |
{ |
304 |
if (border) { |
305 |
psiconv_free_color(border->color); |
306 |
free(border); |
307 |
} |
308 |
} |
309 |
|
310 |
void psiconv_free_font(psiconv_font font) |
311 |
{ |
312 |
if (font) { |
313 |
if (font->name) |
314 |
free(font->name); |
315 |
free(font); |
316 |
} |
317 |
} |
318 |
|
319 |
void psiconv_free_bullet(psiconv_bullet bullet) |
320 |
{ |
321 |
if (bullet) { |
322 |
psiconv_free_color(bullet->color); |
323 |
psiconv_free_font(bullet->font); |
324 |
free(bullet); |
325 |
} |
326 |
} |
327 |
|
328 |
void psiconv_free_character_layout(psiconv_character_layout layout) |
329 |
{ |
330 |
if (layout) { |
331 |
psiconv_free_color(layout->color); |
332 |
psiconv_free_color(layout->back_color); |
333 |
psiconv_free_font(layout->font); |
334 |
free(layout); |
335 |
} |
336 |
} |
337 |
|
338 |
void psiconv_free_tab(psiconv_tab tab) |
339 |
{ |
340 |
if (tab) |
341 |
free(tab); |
342 |
} |
343 |
|
344 |
void psiconv_free_tabs(psiconv_all_tabs tabs) |
345 |
{ |
346 |
if (tabs) { |
347 |
psiconv_list_free(tabs->extras); |
348 |
free(tabs); |
349 |
} |
350 |
} |
351 |
|
352 |
void psiconv_free_paragraph_layout(psiconv_paragraph_layout layout) |
353 |
{ |
354 |
if (layout) { |
355 |
psiconv_free_color(layout->back_color); |
356 |
psiconv_free_bullet(layout->bullet); |
357 |
psiconv_free_border(layout->left_border); |
358 |
psiconv_free_border(layout->right_border); |
359 |
psiconv_free_border(layout->top_border); |
360 |
psiconv_free_border(layout->bottom_border); |
361 |
psiconv_free_tabs(layout->tabs); |
362 |
free(layout); |
363 |
} |
364 |
} |
365 |
|
366 |
void psiconv_free_style_aux(void *style) |
367 |
{ |
368 |
if(((psiconv_word_style) style)->name) |
369 |
free(((psiconv_word_style) style)->name); |
370 |
psiconv_free_character_layout(((psiconv_word_style) style)->character); |
371 |
psiconv_free_paragraph_layout(((psiconv_word_style) style)->paragraph); |
372 |
} |
373 |
|
374 |
void psiconv_free_word_style(psiconv_word_style style) |
375 |
{ |
376 |
if (style) { |
377 |
psiconv_free_style_aux(style); |
378 |
free(style); |
379 |
} |
380 |
} |
381 |
|
382 |
void psiconv_free_word_styles_section(psiconv_word_styles_section styles) |
383 |
{ |
384 |
if (styles) { |
385 |
psiconv_free_word_style(styles->normal); |
386 |
if (styles->styles) |
387 |
psiconv_list_free_el(styles->styles,psiconv_free_style_aux); |
388 |
} |
389 |
} |
390 |
|
391 |
void psiconv_free_header_section(psiconv_header_section header) |
392 |
{ |
393 |
if (header) |
394 |
free(header); |
395 |
} |
396 |
|
397 |
void psiconv_free_section_table_entry(psiconv_section_table_entry entry) |
398 |
{ |
399 |
if (entry) |
400 |
free(entry); |
401 |
} |
402 |
|
403 |
void psiconv_free_section_table_section(psiconv_section_table_section section) |
404 |
{ |
405 |
if (section) |
406 |
psiconv_list_free(section); |
407 |
} |
408 |
|
409 |
void psiconv_free_application_id_section(psiconv_application_id_section section) |
410 |
{ |
411 |
if (section) { |
412 |
if (section->name) |
413 |
free(section->name); |
414 |
free(section); |
415 |
} |
416 |
} |
417 |
|
418 |
void psiconv_free_in_line_layout_aux(void * layout) |
419 |
{ |
420 |
psiconv_free_character_layout(((psiconv_in_line_layout) layout)->layout); |
421 |
} |
422 |
|
423 |
void psiconv_free_in_line_layout(psiconv_in_line_layout layout) |
424 |
{ |
425 |
if (layout) { |
426 |
psiconv_free_in_line_layout_aux(layout); |
427 |
free(layout); |
428 |
} |
429 |
} |
430 |
|
431 |
void psiconv_free_in_line_layouts(psiconv_in_line_layouts layouts) |
432 |
{ |
433 |
if (layouts) |
434 |
psiconv_list_free_el(layouts,&psiconv_free_in_line_layout_aux); |
435 |
} |
436 |
|
437 |
void psiconv_free_replacement(psiconv_replacement replacement) |
438 |
{ |
439 |
if (replacement) |
440 |
free(replacement); |
441 |
} |
442 |
|
443 |
void psiconv_free_replacements(psiconv_replacements replacements) |
444 |
{ |
445 |
if (replacements) |
446 |
psiconv_list_free(replacements); |
447 |
} |
448 |
|
449 |
void psiconv_free_paragraph_aux(void * paragraph) |
450 |
{ |
451 |
if(((psiconv_paragraph) paragraph)->text) |
452 |
free(((psiconv_paragraph) paragraph)->text); |
453 |
psiconv_free_character_layout(((psiconv_paragraph) paragraph) |
454 |
->base_character); |
455 |
psiconv_free_paragraph_layout(((psiconv_paragraph) paragraph) |
456 |
->base_paragraph); |
457 |
psiconv_free_in_line_layouts(((psiconv_paragraph) paragraph) |
458 |
->in_lines); |
459 |
psiconv_free_replacements(((psiconv_paragraph) paragraph) |
460 |
->replacements); |
461 |
} |
462 |
|
463 |
void psiconv_free_paragraph(psiconv_paragraph paragraph) |
464 |
{ |
465 |
if (paragraph) { |
466 |
psiconv_free_paragraph_aux(paragraph); |
467 |
free(paragraph); |
468 |
} |
469 |
} |
470 |
|
471 |
void psiconv_free_text_and_layout(psiconv_text_and_layout text) |
472 |
{ |
473 |
if (text) |
474 |
psiconv_list_free_el(text,&psiconv_free_paragraph_aux); |
475 |
} |
476 |
|
477 |
void psiconv_free_texted_section(psiconv_texted_section section) |
478 |
{ |
479 |
if (section) { |
480 |
psiconv_free_text_and_layout(section->paragraphs); |
481 |
free(section); |
482 |
} |
483 |
} |
484 |
|
485 |
void psiconv_free_page_header(psiconv_page_header header) |
486 |
{ |
487 |
if (header) { |
488 |
psiconv_free_character_layout(header->base_character_layout); |
489 |
psiconv_free_paragraph_layout(header->base_paragraph_layout); |
490 |
psiconv_free_texted_section(header->text); |
491 |
free(header); |
492 |
} |
493 |
} |
494 |
|
495 |
void psiconv_free_page_layout_section(psiconv_page_layout_section section) |
496 |
{ |
497 |
if (section) { |
498 |
psiconv_free_page_header(section->header); |
499 |
psiconv_free_page_header(section->footer); |
500 |
free(section); |
501 |
} |
502 |
} |
503 |
|
504 |
void psiconv_free_word_status_section(psiconv_word_status_section section) |
505 |
{ |
506 |
if (section) |
507 |
free(section); |
508 |
} |
509 |
|
510 |
void psiconv_free_word_f(psiconv_word_f file) |
511 |
{ |
512 |
if (file) { |
513 |
psiconv_free_page_layout_section(file->page_sec); |
514 |
psiconv_free_text_and_layout(file->paragraphs); |
515 |
psiconv_free_word_status_section(file->status_sec); |
516 |
psiconv_free_word_styles_section(file->styles_sec); |
517 |
free(file); |
518 |
} |
519 |
} |
520 |
|
521 |
void psiconv_free_texted_f(psiconv_texted_f file) |
522 |
{ |
523 |
if (file) { |
524 |
psiconv_free_page_layout_section(file->page_sec); |
525 |
psiconv_free_texted_section(file->texted_sec); |
526 |
free(file); |
527 |
} |
528 |
} |
529 |
|
530 |
void psiconv_free_paint_data_section_aux(void * section) |
531 |
{ |
532 |
if (((psiconv_paint_data_section) section)->red) |
533 |
free(((psiconv_paint_data_section)section) -> red); |
534 |
if (((psiconv_paint_data_section) section)->green) |
535 |
free(((psiconv_paint_data_section)section) -> green); |
536 |
if (((psiconv_paint_data_section) section)->blue) |
537 |
free(((psiconv_paint_data_section)section) -> blue); |
538 |
} |
539 |
|
540 |
void psiconv_free_paint_data_section(psiconv_paint_data_section section) |
541 |
{ |
542 |
if (section) { |
543 |
psiconv_free_paint_data_section_aux(section); |
544 |
free(section); |
545 |
} |
546 |
} |
547 |
|
548 |
void psiconv_free_pictures(psiconv_pictures section) |
549 |
{ |
550 |
if (section) |
551 |
psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux); |
552 |
} |
553 |
|
554 |
void psiconv_free_jumptable_section (psiconv_jumptable_section section) |
555 |
{ |
556 |
if (section) |
557 |
psiconv_list_free(section); |
558 |
} |
559 |
|
560 |
void psiconv_free_mbm_f(psiconv_mbm_f file) |
561 |
{ |
562 |
if (file) { |
563 |
psiconv_free_pictures(file->sections); |
564 |
free(file); |
565 |
} |
566 |
} |
567 |
|
568 |
void psiconv_free_sketch_section(psiconv_sketch_section sec) |
569 |
{ |
570 |
if (sec) { |
571 |
psiconv_free_paint_data_section(sec->picture); |
572 |
free(sec); |
573 |
} |
574 |
} |
575 |
|
576 |
void psiconv_free_sketch_f(psiconv_sketch_f file) |
577 |
{ |
578 |
if (file) { |
579 |
psiconv_free_sketch_section(file->sketch_sec); |
580 |
free(file); |
581 |
} |
582 |
} |
583 |
|
584 |
void psiconv_free_clipart_section_aux(void *section) |
585 |
{ |
586 |
if (section) |
587 |
free(((psiconv_clipart_section ) section)->picture); |
588 |
} |
589 |
|
590 |
void psiconv_free_clipart_section(psiconv_clipart_section section) |
591 |
{ |
592 |
if (section) { |
593 |
psiconv_free_clipart_section_aux(section); |
594 |
free(section); |
595 |
} |
596 |
} |
597 |
|
598 |
void psiconv_free_cliparts(psiconv_cliparts section) |
599 |
{ |
600 |
if (section) |
601 |
psiconv_list_free_el(section,&psiconv_free_clipart_section_aux); |
602 |
} |
603 |
|
604 |
void psiconv_free_clipart_f(psiconv_clipart_f file) |
605 |
{ |
606 |
if (file) { |
607 |
psiconv_free_cliparts(file->sections); |
608 |
free(file); |
609 |
} |
610 |
} |
611 |
|
612 |
void psiconv_free_file(psiconv_file file) |
613 |
{ |
614 |
if (file) { |
615 |
if (file->type == psiconv_word_file) |
616 |
psiconv_free_word_f((psiconv_word_f) file->file); |
617 |
else if (file->type == psiconv_texted_file) |
618 |
psiconv_free_texted_f((psiconv_texted_f) file->file); |
619 |
else if (file->type == psiconv_mbm_file) |
620 |
psiconv_free_mbm_f((psiconv_mbm_f) file->file); |
621 |
else if (file->type == psiconv_sketch_file) |
622 |
psiconv_free_sketch_f((psiconv_sketch_f) file->file); |
623 |
else if (file->type == psiconv_clipart_file) |
624 |
psiconv_free_clipart_f((psiconv_clipart_f) file->file); |
625 |
free(file); |
626 |
} |
627 |
} |
628 |
|
629 |
int psiconv_compare_color(const psiconv_color value1, |
630 |
const psiconv_color value2) |
631 |
{ |
632 |
if (!value1 || !value2) |
633 |
return 1; |
634 |
if ((value1->red == value2->red) && |
635 |
(value1->green == value2->green) && |
636 |
(value1->blue == value2->blue)) |
637 |
return 0; |
638 |
else |
639 |
return 1; |
640 |
} |
641 |
|
642 |
int psiconv_compare_font(const psiconv_font value1, |
643 |
const psiconv_font value2) |
644 |
{ |
645 |
if (!value1 || !value2 || !value1->name || !value2->name) |
646 |
return 1; |
647 |
if ((value1->screenfont == value2->screenfont) && |
648 |
!strcmp(value1->name,value2->name)) |
649 |
return 0; |
650 |
else |
651 |
return 1; |
652 |
} |
653 |
|
654 |
int psiconv_compare_border(const psiconv_border value1, |
655 |
const psiconv_border value2) |
656 |
{ |
657 |
if (!value1 || !value2) |
658 |
return 1; |
659 |
if ((value1->kind == value2->kind) && |
660 |
(value1->thickness == value2->thickness) && |
661 |
!psiconv_compare_color(value1->color,value2->color)) |
662 |
return 0; |
663 |
else |
664 |
return 1; |
665 |
} |
666 |
|
667 |
int psiconv_compare_bullet(const psiconv_bullet value1, |
668 |
const psiconv_bullet value2) |
669 |
{ |
670 |
if (!value1 || !value2) |
671 |
return 1; |
672 |
if ((value1->on == value2->on) && |
673 |
(value1->font_size == value2->font_size) && |
674 |
(value1->character == value2->character) && |
675 |
(value1->indent == value2->indent) && |
676 |
!psiconv_compare_color(value1->color,value2->color) && |
677 |
!psiconv_compare_font(value1->font,value2->font)) |
678 |
return 0; |
679 |
else |
680 |
return 1; |
681 |
} |
682 |
|
683 |
int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2) |
684 |
{ |
685 |
if (!value1 || !value2) |
686 |
return 1; |
687 |
if ((value1->location == value2->location) && |
688 |
(value1->kind == value2->kind)) |
689 |
return 0; |
690 |
else |
691 |
return 1; |
692 |
} |
693 |
|
694 |
int psiconv_compare_all_tabs(const psiconv_all_tabs value1, |
695 |
const psiconv_all_tabs value2) |
696 |
{ |
697 |
int i; |
698 |
|
699 |
if (!value1 || !value2 || !value1->extras || !value2->extras) |
700 |
return 1; |
701 |
|
702 |
if ((value1->normal != value2->normal) || |
703 |
psiconv_list_length(value1->extras) != |
704 |
psiconv_list_length(value2->extras)) |
705 |
return 1; |
706 |
for (i = 0; i < psiconv_list_length(value1->extras); i++) |
707 |
if (psiconv_compare_tab(psiconv_list_get(value1->extras,i), |
708 |
psiconv_list_get(value2->extras,i))) |
709 |
|
710 |
return 1; |
711 |
return 0; |
712 |
} |
713 |
|
714 |
int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1, |
715 |
const psiconv_paragraph_layout value2) |
716 |
{ |
717 |
if (!value1 || !value2) |
718 |
return 1; |
719 |
if ((value1->indent_left == value2->indent_left) && |
720 |
(value1->indent_right == value2->indent_right) && |
721 |
(value1->indent_first == value2->indent_first) && |
722 |
(value1->justify_hor == value2->justify_hor) && |
723 |
(value1->justify_ver == value2->justify_ver) && |
724 |
(value1->linespacing == value2->linespacing) && |
725 |
(value1->space_above == value2->space_above) && |
726 |
(value1->space_below == value2->space_below) && |
727 |
(value1->keep_together == value2->keep_together) && |
728 |
(value1->keep_with_next == value2->keep_with_next) && |
729 |
(value1->on_next_page == value2->on_next_page) && |
730 |
(value1->no_widow_protection == value2->no_widow_protection) && |
731 |
(value1->border_distance == value2->border_distance) && |
732 |
!psiconv_compare_color(value1->back_color,value2->back_color) && |
733 |
!psiconv_compare_bullet(value1->bullet,value2->bullet) && |
734 |
!psiconv_compare_border(value1->left_border,value2->left_border) && |
735 |
!psiconv_compare_border(value1->right_border,value2->right_border) && |
736 |
!psiconv_compare_border(value1->top_border,value2->top_border) && |
737 |
!psiconv_compare_border(value1->bottom_border,value2->bottom_border) && |
738 |
!psiconv_compare_all_tabs(value1->tabs,value2->tabs)) |
739 |
return 0; |
740 |
else |
741 |
return 1; |
742 |
} |
743 |
|
744 |
|
745 |
int psiconv_compare_character_layout(const psiconv_character_layout value1, |
746 |
const psiconv_character_layout value2) |
747 |
{ |
748 |
if (!value1 || !value2) |
749 |
return 1; |
750 |
if ((value1->font_size == value2->font_size) && |
751 |
(value1->italic == value2->italic) && |
752 |
(value1->bold == value2->bold) && |
753 |
(value1->super_sub == value2->super_sub) && |
754 |
(value1->underline == value2->underline) && |
755 |
(value1->strikethrough == value2->strikethrough) && |
756 |
!psiconv_compare_color(value1->color,value2->color) && |
757 |
!psiconv_compare_color(value1->back_color,value2->back_color) && |
758 |
!psiconv_compare_font(value1->font,value2->font)) |
759 |
return 0; |
760 |
else |
761 |
return 1; |
762 |
} |