/[public]/psiconv/trunk/lib/psiconv/data.c
ViewVC logotype

Contents of /psiconv/trunk/lib/psiconv/data.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 87 - (show annotations)
Sat Dec 30 22:17:59 2000 UTC (23 years, 3 months ago) by frodo
File MIME type: text/plain
File size: 30131 byte(s)
(Frodo) Added psiconv_empty_* routines

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 #include "list.h"
26
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 static void psiconv_free_paint_data_section_aux(void * section);
36 static void psiconv_free_clipart_section_aux(void * section);
37
38 static psiconv_word_styles_section psiconv_empty_word_styles_section(void);
39 static psiconv_text_and_layout psiconv_empty_text_and_layout(void);
40 static psiconv_texted_section psiconv_empty_texted_section(void);
41 static psiconv_page_header psiconv_empty_page_header(void);
42 static psiconv_page_layout_section psiconv_empty_page_layout_section(void);
43 static psiconv_word_status_section psiconv_empty_word_status_section(void);
44 static psiconv_word_f psiconv_empty_word_f(void);
45 static psiconv_texted_f psiconv_empty_texted_f(void);
46 static psiconv_paint_data_section psiconv_empty_paint_data_section(void);
47 static psiconv_pictures psiconv_empty_pictures(void);
48 static psiconv_mbm_f psiconv_empty_mbm_f(void);
49 static psiconv_sketch_section psiconv_empty_sketch_section(void);
50 static psiconv_sketch_f psiconv_empty_sketch_f(void);
51 static psiconv_clipart_f psiconv_empty_clipart_f(void);
52 static psiconv_cliparts psiconv_empty_cliparts(void);
53
54
55 /* Note: these defaults seem to be hard-coded somewhere outside the
56 files themself. */
57 psiconv_character_layout psiconv_basic_character_layout(void)
58 {
59 /* Make the structures static, to oblige IRIX */
60 static struct psiconv_color_s black =
61 {
62 0x00, /* red */
63 0x00, /* green */
64 0x00, /* blue */
65 };
66 static struct psiconv_color_s white =
67 {
68 0xff, /* red */
69 0xff, /* green */
70 0xff, /* blue */
71 };
72 static struct psiconv_font_s font =
73 {
74 "Times New Roman", /* name */
75 3 /* screenfont */
76 };
77 struct psiconv_character_layout_s cl =
78 {
79 &black, /* color */
80 &white, /* back_color */
81 10.0, /* font_size */
82 psiconv_bool_false, /* italic */
83 psiconv_bool_false, /* bold */
84 psiconv_normalscript, /* super_sub */
85 psiconv_bool_false, /* underline */
86 psiconv_bool_false, /* strikethrough */
87 &font, /* font */
88 };
89
90 return psiconv_clone_character_layout(&cl);
91 }
92
93 /* Note: these defaults seem to be hard-coded somewhere outside the
94 files themself. */
95 psiconv_paragraph_layout psiconv_basic_paragraph_layout(void)
96 {
97 static struct psiconv_font_s font =
98 {
99 "Times New Roman", /* name */
100 2 /* screenfont */
101 };
102 static struct psiconv_color_s black =
103 {
104 0x00, /* red */
105 0x00, /* green */
106 0x00, /* blue */
107 };
108 static struct psiconv_color_s white =
109 {
110 0xff, /* red */
111 0xff, /* green */
112 0xff, /* blue */
113 };
114 static struct psiconv_border_s no_border =
115 {
116 psiconv_border_none, /* kind */
117 1, /* thickness */
118 &black /* color */
119 };
120 static struct psiconv_bullet_s bullet =
121 {
122 psiconv_bool_false, /* on */
123 10.0, /* font_size */
124 0x95, /* character */
125 psiconv_bool_true, /* indent */
126 &black, /* color */
127 &font, /* font */
128 };
129 static struct psiconv_all_tabs_s tabs =
130 {
131 0.64, /* normal */
132 NULL /* kind */
133 };
134 struct psiconv_paragraph_layout_s pl =
135 {
136 &white, /* back_color */
137 0.0, /* indent_left */
138 0.0, /* indent_right */
139 0.0, /* indent_first */
140 psiconv_justify_left, /* justify_hor */
141 psiconv_justify_middle,/* justify_ver */
142 10.0, /* linespacing */
143 psiconv_bool_false, /* linespacing_exact */
144 0.0, /* space_above */
145 0.0, /* space_below */
146 psiconv_bool_false, /* keep_together */
147 psiconv_bool_false, /* keep_with_next */
148 psiconv_bool_false, /* on_next_page */
149 psiconv_bool_false, /* no_widow_protection */
150 0.0, /* left_margin */
151 &bullet, /* bullet */
152 &no_border, /* left_border */
153 &no_border, /* right_border */
154 &no_border, /* top_border */
155 &no_border, /* bottom_border */
156 &tabs, /* tabs */
157 };
158 psiconv_paragraph_layout res;
159
160 if (!(pl.tabs->extras = psiconv_list_new(sizeof(struct psiconv_tab_s))))
161 return NULL;
162 res = psiconv_clone_paragraph_layout(&pl);
163 psiconv_list_free(pl.tabs->extras);
164 return res;
165 }
166
167 psiconv_color clone_color(psiconv_color color)
168 {
169 psiconv_color result;
170 if (!(result = malloc(sizeof(*result))))
171 return NULL;
172 *result = *color;
173 return result;
174 }
175
176 psiconv_font clone_font(psiconv_font font)
177 {
178 psiconv_font result;
179 if(!(result = malloc(sizeof(*result))))
180 goto ERROR1;
181 *result = *font;
182 if (!(result->name = strdup(result->name)))
183 goto ERROR2;
184 return result;
185 ERROR2:
186 free(result);
187 ERROR1:
188 return NULL;
189 }
190
191 psiconv_border clone_border(psiconv_border border)
192 {
193 psiconv_border result;
194 if (!(result = malloc(sizeof(*result))))
195 goto ERROR1;
196 *result = *border;
197 if(!(result->color = clone_color(result->color)))
198 goto ERROR2;
199 return result;
200 ERROR2:
201 free(result);
202 ERROR1:
203 return NULL;
204 }
205
206 psiconv_bullet clone_bullet(psiconv_bullet bullet)
207 {
208 psiconv_bullet result;
209 if (!(result = malloc(sizeof(*result))))
210 goto ERROR1;
211 *result = *bullet;
212 if (!(result->font = clone_font(result->font)))
213 goto ERROR2;
214 if (!(result->color = clone_color(result->color)))
215 goto ERROR3;
216 return result;
217 ERROR3:
218 psiconv_free_font(result->font);
219 ERROR2:
220 free(result);
221 ERROR1:
222 return NULL;
223 }
224
225 psiconv_all_tabs clone_all_tabs(psiconv_all_tabs all_tabs)
226 {
227 psiconv_all_tabs result;
228 if (!(result = malloc(sizeof(*result))))
229 goto ERROR1;
230 *result = *all_tabs;
231 if (!(result->extras = psiconv_list_clone(result->extras)))
232 goto ERROR2;
233 return result;
234 ERROR2:
235 free(result);
236 ERROR1:
237 return NULL;
238 }
239
240 psiconv_character_layout psiconv_clone_character_layout
241 (psiconv_character_layout ls)
242 {
243 psiconv_character_layout result;
244
245 if (!(result = malloc(sizeof(*result))))
246 goto ERROR1;
247 *result = *ls;
248 if (!(result->color = clone_color(result->color)))
249 goto ERROR2;
250 if (!(result->back_color = clone_color(result->back_color)))
251 goto ERROR3;
252 if (!(result->font = clone_font(result->font)))
253 goto ERROR4;
254 return result;
255 ERROR4:
256 psiconv_free_color(result->back_color);
257 ERROR3:
258 psiconv_free_color(result->color);
259 ERROR2:
260 free(result);
261 ERROR1:
262 return NULL;
263 }
264
265 psiconv_paragraph_layout psiconv_clone_paragraph_layout
266 (psiconv_paragraph_layout ls)
267 {
268 psiconv_paragraph_layout result;
269
270 if (!(result = malloc(sizeof(*result))))
271 goto ERROR1;
272 *result = *ls;
273 if (!(result->back_color = clone_color(result->back_color)))
274 goto ERROR2;
275 if (!(result->bullet = clone_bullet(result->bullet)))
276 goto ERROR3;
277 if (!(result->left_border = clone_border(result->left_border)))
278 goto ERROR4;
279 if (!(result->right_border = clone_border(result->right_border)))
280 goto ERROR5;
281 if (!(result->top_border = clone_border(result->top_border)))
282 goto ERROR6;
283 if (!(result->bottom_border = clone_border(result->bottom_border)))
284 goto ERROR7;
285 if (!(result->tabs = clone_all_tabs(result->tabs)))
286 goto ERROR8;
287 return result;
288 ERROR8:
289 psiconv_free_border(result->bottom_border);
290 ERROR7:
291 psiconv_free_border(result->top_border);
292 ERROR6:
293 psiconv_free_border(result->right_border);
294 ERROR5:
295 psiconv_free_border(result->left_border);
296 ERROR4:
297 psiconv_free_bullet(result->bullet);
298 ERROR3:
299 psiconv_free_color(result->back_color);
300 ERROR2:
301 free(result);
302 ERROR1:
303 return NULL;
304 }
305
306 psiconv_word_style psiconv_get_style (psiconv_word_styles_section ss, int nr)
307 {
308 if (nr == 0)
309 return ss->normal;
310 else
311 return psiconv_list_get(ss->styles,0xff - nr);
312 }
313
314 void psiconv_free_color (psiconv_color color)
315 {
316 if (color)
317 free(color);
318 }
319
320 void psiconv_free_border(psiconv_border border)
321 {
322 if (border) {
323 psiconv_free_color(border->color);
324 free(border);
325 }
326 }
327
328 void psiconv_free_font(psiconv_font font)
329 {
330 if (font) {
331 if (font->name)
332 free(font->name);
333 free(font);
334 }
335 }
336
337 void psiconv_free_bullet(psiconv_bullet bullet)
338 {
339 if (bullet) {
340 psiconv_free_color(bullet->color);
341 psiconv_free_font(bullet->font);
342 free(bullet);
343 }
344 }
345
346 void psiconv_free_character_layout(psiconv_character_layout layout)
347 {
348 if (layout) {
349 psiconv_free_color(layout->color);
350 psiconv_free_color(layout->back_color);
351 psiconv_free_font(layout->font);
352 free(layout);
353 }
354 }
355
356 void psiconv_free_tab(psiconv_tab tab)
357 {
358 if (tab)
359 free(tab);
360 }
361
362 void psiconv_free_tabs(psiconv_all_tabs tabs)
363 {
364 if (tabs) {
365 psiconv_list_free(tabs->extras);
366 free(tabs);
367 }
368 }
369
370 void psiconv_free_paragraph_layout(psiconv_paragraph_layout layout)
371 {
372 if (layout) {
373 psiconv_free_color(layout->back_color);
374 psiconv_free_bullet(layout->bullet);
375 psiconv_free_border(layout->left_border);
376 psiconv_free_border(layout->right_border);
377 psiconv_free_border(layout->top_border);
378 psiconv_free_border(layout->bottom_border);
379 psiconv_free_tabs(layout->tabs);
380 free(layout);
381 }
382 }
383
384 void psiconv_free_style_aux(void *style)
385 {
386 if(((psiconv_word_style) style)->name)
387 free(((psiconv_word_style) style)->name);
388 psiconv_free_character_layout(((psiconv_word_style) style)->character);
389 psiconv_free_paragraph_layout(((psiconv_word_style) style)->paragraph);
390 }
391
392 void psiconv_free_word_style(psiconv_word_style style)
393 {
394 if (style) {
395 psiconv_free_style_aux(style);
396 free(style);
397 }
398 }
399
400 void psiconv_free_word_styles_section(psiconv_word_styles_section styles)
401 {
402 if (styles) {
403 psiconv_free_word_style(styles->normal);
404 if (styles->styles)
405 psiconv_list_free_el(styles->styles,psiconv_free_style_aux);
406 }
407 }
408
409 void psiconv_free_header_section(psiconv_header_section header)
410 {
411 if (header)
412 free(header);
413 }
414
415 void psiconv_free_section_table_entry(psiconv_section_table_entry entry)
416 {
417 if (entry)
418 free(entry);
419 }
420
421 void psiconv_free_section_table_section(psiconv_section_table_section section)
422 {
423 if (section)
424 psiconv_list_free(section);
425 }
426
427 void psiconv_free_application_id_section(psiconv_application_id_section section)
428 {
429 if (section) {
430 if (section->name)
431 free(section->name);
432 free(section);
433 }
434 }
435
436 void psiconv_free_in_line_layout_aux(void * layout)
437 {
438 psiconv_free_character_layout(((psiconv_in_line_layout) layout)->layout);
439 }
440
441 void psiconv_free_in_line_layout(psiconv_in_line_layout layout)
442 {
443 if (layout) {
444 psiconv_free_in_line_layout_aux(layout);
445 free(layout);
446 }
447 }
448
449 void psiconv_free_in_line_layouts(psiconv_in_line_layouts layouts)
450 {
451 if (layouts)
452 psiconv_list_free_el(layouts,&psiconv_free_in_line_layout_aux);
453 }
454
455 void psiconv_free_replacement(psiconv_replacement replacement)
456 {
457 if (replacement)
458 free(replacement);
459 }
460
461 void psiconv_free_replacements(psiconv_replacements replacements)
462 {
463 if (replacements)
464 psiconv_list_free(replacements);
465 }
466
467 void psiconv_free_paragraph_aux(void * paragraph)
468 {
469 if(((psiconv_paragraph) paragraph)->text)
470 free(((psiconv_paragraph) paragraph)->text);
471 psiconv_free_character_layout(((psiconv_paragraph) paragraph)
472 ->base_character);
473 psiconv_free_paragraph_layout(((psiconv_paragraph) paragraph)
474 ->base_paragraph);
475 psiconv_free_in_line_layouts(((psiconv_paragraph) paragraph)
476 ->in_lines);
477 psiconv_free_replacements(((psiconv_paragraph) paragraph)
478 ->replacements);
479 }
480
481 void psiconv_free_paragraph(psiconv_paragraph paragraph)
482 {
483 if (paragraph) {
484 psiconv_free_paragraph_aux(paragraph);
485 free(paragraph);
486 }
487 }
488
489 void psiconv_free_text_and_layout(psiconv_text_and_layout text)
490 {
491 if (text)
492 psiconv_list_free_el(text,&psiconv_free_paragraph_aux);
493 }
494
495 void psiconv_free_texted_section(psiconv_texted_section section)
496 {
497 if (section) {
498 psiconv_free_text_and_layout(section->paragraphs);
499 free(section);
500 }
501 }
502
503 void psiconv_free_page_header(psiconv_page_header header)
504 {
505 if (header) {
506 psiconv_free_character_layout(header->base_character_layout);
507 psiconv_free_paragraph_layout(header->base_paragraph_layout);
508 psiconv_free_texted_section(header->text);
509 free(header);
510 }
511 }
512
513 void psiconv_free_page_layout_section(psiconv_page_layout_section section)
514 {
515 if (section) {
516 psiconv_free_page_header(section->header);
517 psiconv_free_page_header(section->footer);
518 free(section);
519 }
520 }
521
522 void psiconv_free_word_status_section(psiconv_word_status_section section)
523 {
524 if (section)
525 free(section);
526 }
527
528 void psiconv_free_word_f(psiconv_word_f file)
529 {
530 if (file) {
531 psiconv_free_page_layout_section(file->page_sec);
532 psiconv_free_text_and_layout(file->paragraphs);
533 psiconv_free_word_status_section(file->status_sec);
534 psiconv_free_word_styles_section(file->styles_sec);
535 free(file);
536 }
537 }
538
539 void psiconv_free_texted_f(psiconv_texted_f file)
540 {
541 if (file) {
542 psiconv_free_page_layout_section(file->page_sec);
543 psiconv_free_texted_section(file->texted_sec);
544 free(file);
545 }
546 }
547
548 void psiconv_free_paint_data_section_aux(void * section)
549 {
550 if (((psiconv_paint_data_section) section)->red)
551 free(((psiconv_paint_data_section)section) -> red);
552 if (((psiconv_paint_data_section) section)->green)
553 free(((psiconv_paint_data_section)section) -> green);
554 if (((psiconv_paint_data_section) section)->blue)
555 free(((psiconv_paint_data_section)section) -> blue);
556 }
557
558 void psiconv_free_paint_data_section(psiconv_paint_data_section section)
559 {
560 if (section) {
561 psiconv_free_paint_data_section_aux(section);
562 free(section);
563 }
564 }
565
566 void psiconv_free_pictures(psiconv_pictures section)
567 {
568 if (section)
569 psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux);
570 }
571
572 void psiconv_free_jumptable_section (psiconv_jumptable_section section)
573 {
574 if (section)
575 psiconv_list_free(section);
576 }
577
578 void psiconv_free_mbm_f(psiconv_mbm_f file)
579 {
580 if (file) {
581 psiconv_free_pictures(file->sections);
582 free(file);
583 }
584 }
585
586 void psiconv_free_sketch_section(psiconv_sketch_section sec)
587 {
588 if (sec) {
589 psiconv_free_paint_data_section(sec->picture);
590 free(sec);
591 }
592 }
593
594 void psiconv_free_sketch_f(psiconv_sketch_f file)
595 {
596 if (file) {
597 psiconv_free_sketch_section(file->sketch_sec);
598 free(file);
599 }
600 }
601
602 void psiconv_free_clipart_section_aux(void *section)
603 {
604 if (section)
605 free(((psiconv_clipart_section ) section)->picture);
606 }
607
608 void psiconv_free_clipart_section(psiconv_clipart_section section)
609 {
610 if (section) {
611 psiconv_free_clipart_section_aux(section);
612 free(section);
613 }
614 }
615
616 void psiconv_free_cliparts(psiconv_cliparts section)
617 {
618 if (section)
619 psiconv_list_free_el(section,&psiconv_free_clipart_section_aux);
620 }
621
622 void psiconv_free_clipart_f(psiconv_clipart_f file)
623 {
624 if (file) {
625 psiconv_free_cliparts(file->sections);
626 free(file);
627 }
628 }
629
630 void psiconv_free_file(psiconv_file file)
631 {
632 if (file) {
633 if (file->type == psiconv_word_file)
634 psiconv_free_word_f((psiconv_word_f) file->file);
635 else if (file->type == psiconv_texted_file)
636 psiconv_free_texted_f((psiconv_texted_f) file->file);
637 else if (file->type == psiconv_mbm_file)
638 psiconv_free_mbm_f((psiconv_mbm_f) file->file);
639 else if (file->type == psiconv_sketch_file)
640 psiconv_free_sketch_f((psiconv_sketch_f) file->file);
641 else if (file->type == psiconv_clipart_file)
642 psiconv_free_clipart_f((psiconv_clipart_f) file->file);
643 free(file);
644 }
645 }
646
647 int psiconv_compare_color(const psiconv_color value1,
648 const psiconv_color value2)
649 {
650 if (!value1 || !value2)
651 return 1;
652 if ((value1->red == value2->red) &&
653 (value1->green == value2->green) &&
654 (value1->blue == value2->blue))
655 return 0;
656 else
657 return 1;
658 }
659
660 int psiconv_compare_font(const psiconv_font value1,
661 const psiconv_font value2)
662 {
663 if (!value1 || !value2 || !value1->name || !value2->name)
664 return 1;
665 if ((value1->screenfont == value2->screenfont) &&
666 !strcmp(value1->name,value2->name))
667 return 0;
668 else
669 return 1;
670 }
671
672 int psiconv_compare_border(const psiconv_border value1,
673 const psiconv_border value2)
674 {
675 if (!value1 || !value2)
676 return 1;
677 if ((value1->kind == value2->kind) &&
678 (value1->thickness == value2->thickness) &&
679 !psiconv_compare_color(value1->color,value2->color))
680 return 0;
681 else
682 return 1;
683 }
684
685 int psiconv_compare_bullet(const psiconv_bullet value1,
686 const psiconv_bullet value2)
687 {
688 if (!value1 || !value2)
689 return 1;
690 if ((value1->on == value2->on) &&
691 (value1->font_size == value2->font_size) &&
692 (value1->character == value2->character) &&
693 (value1->indent == value2->indent) &&
694 !psiconv_compare_color(value1->color,value2->color) &&
695 !psiconv_compare_font(value1->font,value2->font))
696 return 0;
697 else
698 return 1;
699 }
700
701 int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2)
702 {
703 if (!value1 || !value2)
704 return 1;
705 if ((value1->location == value2->location) &&
706 (value1->kind == value2->kind))
707 return 0;
708 else
709 return 1;
710 }
711
712 int psiconv_compare_all_tabs(const psiconv_all_tabs value1,
713 const psiconv_all_tabs value2)
714 {
715 int i;
716
717 if (!value1 || !value2 || !value1->extras || !value2->extras)
718 return 1;
719
720 if ((value1->normal != value2->normal) ||
721 psiconv_list_length(value1->extras) !=
722 psiconv_list_length(value2->extras))
723 return 1;
724 for (i = 0; i < psiconv_list_length(value1->extras); i++)
725 if (psiconv_compare_tab(psiconv_list_get(value1->extras,i),
726 psiconv_list_get(value2->extras,i)))
727
728 return 1;
729 return 0;
730 }
731
732 int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1,
733 const psiconv_paragraph_layout value2)
734 {
735 if (!value1 || !value2)
736 return 1;
737 if ((value1->indent_left == value2->indent_left) &&
738 (value1->indent_right == value2->indent_right) &&
739 (value1->indent_first == value2->indent_first) &&
740 (value1->justify_hor == value2->justify_hor) &&
741 (value1->justify_ver == value2->justify_ver) &&
742 (value1->linespacing == value2->linespacing) &&
743 (value1->space_above == value2->space_above) &&
744 (value1->space_below == value2->space_below) &&
745 (value1->keep_together == value2->keep_together) &&
746 (value1->keep_with_next == value2->keep_with_next) &&
747 (value1->on_next_page == value2->on_next_page) &&
748 (value1->no_widow_protection == value2->no_widow_protection) &&
749 (value1->border_distance == value2->border_distance) &&
750 !psiconv_compare_color(value1->back_color,value2->back_color) &&
751 !psiconv_compare_bullet(value1->bullet,value2->bullet) &&
752 !psiconv_compare_border(value1->left_border,value2->left_border) &&
753 !psiconv_compare_border(value1->right_border,value2->right_border) &&
754 !psiconv_compare_border(value1->top_border,value2->top_border) &&
755 !psiconv_compare_border(value1->bottom_border,value2->bottom_border) &&
756 !psiconv_compare_all_tabs(value1->tabs,value2->tabs))
757 return 0;
758 else
759 return 1;
760 }
761
762
763 int psiconv_compare_character_layout(const psiconv_character_layout value1,
764 const psiconv_character_layout value2)
765 {
766 if (!value1 || !value2)
767 return 1;
768 if ((value1->font_size == value2->font_size) &&
769 (value1->italic == value2->italic) &&
770 (value1->bold == value2->bold) &&
771 (value1->super_sub == value2->super_sub) &&
772 (value1->underline == value2->underline) &&
773 (value1->strikethrough == value2->strikethrough) &&
774 !psiconv_compare_color(value1->color,value2->color) &&
775 !psiconv_compare_color(value1->back_color,value2->back_color) &&
776 !psiconv_compare_font(value1->font,value2->font))
777 return 0;
778 else
779 return 1;
780 }
781
782
783
784 psiconv_word_styles_section psiconv_empty_word_styles_section(void)
785 {
786 psiconv_word_styles_section result;
787 if (!(result = malloc(sizeof(*result))))
788 goto ERROR1;
789 if (!(result->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s))))
790 goto ERROR2;
791 if (!(result->normal = malloc(sizeof(struct psiconv_word_style_s))))
792 goto ERROR3;
793 if (!(result->normal->character = psiconv_basic_character_layout()))
794 goto ERROR4;
795 if (!(result->normal->paragraph = psiconv_basic_paragraph_layout()))
796 goto ERROR5;
797 result->normal->hotkey = 'N';
798 result->normal->name = NULL;
799 result->normal->built_in = psiconv_bool_true;
800 result->normal->outline_level = 0;
801 return result;
802 ERROR5:
803 psiconv_free_character_layout(result->normal->character);
804 ERROR4:
805 free(result->normal);
806 ERROR3:
807 psiconv_list_free(result->styles);
808 ERROR2:
809 free(result);
810 ERROR1:
811 return NULL;
812 }
813
814 psiconv_text_and_layout psiconv_empty_text_and_layout(void)
815 {
816 return psiconv_list_new(sizeof(struct psiconv_paragraph_s));
817 }
818
819 psiconv_texted_section psiconv_empty_texted_section(void)
820 {
821 psiconv_texted_section result;
822 if (!(result = malloc(sizeof(*result))))
823 goto ERROR1;
824 if (!(result->paragraphs = psiconv_empty_text_and_layout()))
825 goto ERROR2;
826 return result;
827 ERROR2:
828 free(result);
829 ERROR1:
830 return NULL;
831 }
832
833 psiconv_page_header psiconv_empty_page_header(void)
834 {
835 psiconv_page_header result;
836 if (!(result = malloc(sizeof(*result))))
837 goto ERROR1;
838 result->on_first_page = psiconv_bool_true;
839 if (!(result->base_paragraph_layout = psiconv_basic_paragraph_layout()))
840 goto ERROR2;
841 if (!(result->base_character_layout = psiconv_basic_character_layout()))
842 goto ERROR3;
843 if (!(result->text = psiconv_empty_texted_section()))
844 goto ERROR4;
845 return result;
846 ERROR4:
847 psiconv_free_character_layout(result->base_character_layout);
848 ERROR3:
849 psiconv_free_paragraph_layout(result->base_paragraph_layout);
850 ERROR2:
851 free(result);
852 ERROR1:
853 return NULL;
854 }
855
856 psiconv_page_layout_section psiconv_empty_page_layout_section(void)
857 {
858 psiconv_page_layout_section result;
859 if (!(result = malloc(sizeof(*result))))
860 goto ERROR1;
861 result->first_page_nr = 0;
862 result->header_dist = result->footer_dist = 1.27;
863 result->left_margin = result->right_margin = 3.175;
864 result->top_margin = result->bottom_margin = 2.54;
865 result->page_width = 21.0;
866 result->page_height = 29.7;
867 result->landscape = psiconv_bool_false;
868 if (!(result->header = psiconv_empty_page_header()))
869 goto ERROR2;
870 if (!(result->footer = psiconv_empty_page_header()))
871 goto ERROR3;
872 return result;
873 ERROR3:
874 psiconv_free_page_header(result->header);
875 ERROR2:
876 free(result);
877 ERROR1:
878 return NULL;
879 }
880
881 psiconv_word_status_section psiconv_empty_word_status_section(void)
882 {
883 psiconv_word_status_section result;
884 if (!(result = malloc(sizeof(*result))))
885 return NULL;
886 result->show_tabs = result->show_spaces = result->show_paragraph_ends =
887 result->show_hard_minus = result->show_hard_space =
888 result->fit_lines_to_screen = psiconv_bool_false;
889 result->show_full_pictures = result->show_full_graphs =
890 result->show_top_toolbar = result->show_side_toolbar =
891 psiconv_bool_true;
892 result->cursor_position = 0;
893 result->display_size = 1000;
894 return result;
895 }
896
897 psiconv_word_f psiconv_empty_word_f(void)
898 {
899 psiconv_word_f result;
900 if (!(result = malloc(sizeof(*result))))
901 goto ERROR1;
902 if (!(result->page_sec = psiconv_empty_page_layout_section()))
903 goto ERROR2;
904 if (!(result->paragraphs = psiconv_empty_text_and_layout()))
905 goto ERROR3;
906 if (!(result->status_sec = psiconv_empty_word_status_section()))
907 goto ERROR4;
908 if (!(result->styles_sec = psiconv_empty_word_styles_section()))
909 goto ERROR5;
910 return result;
911 ERROR5:
912 psiconv_free_word_status_section(result->status_sec);
913 ERROR4:
914 psiconv_free_text_and_layout(result->paragraphs);
915 ERROR3:
916 psiconv_free_page_layout_section(result->page_sec);
917 ERROR2:
918 free(result);
919 ERROR1:
920 return NULL;
921 }
922
923 psiconv_texted_f psiconv_empty_texted_f(void)
924 {
925 psiconv_texted_f result;
926 if (!(result = malloc(sizeof(*result))))
927 goto ERROR1;
928 if (!(result->page_sec = psiconv_empty_page_layout_section()))
929 goto ERROR2;
930 if (!(result->texted_sec = psiconv_empty_texted_section()))
931 goto ERROR3;
932 return result;
933 ERROR3:
934 psiconv_free_page_layout_section(result->page_sec);
935 ERROR2:
936 free(result);
937 ERROR1:
938 return NULL;
939 }
940
941 psiconv_paint_data_section psiconv_empty_paint_data_section(void)
942 {
943 psiconv_paint_data_section result;
944 if (!(result = malloc(sizeof(*result))))
945 goto ERROR1;
946 /* Is this correct? */
947 result->xsize = result->ysize = result->pic_xsize = result->pic_ysize = 0;
948 /* Probably forbidden... */
949 if (!(result->red = malloc(0)))
950 goto ERROR2;
951 if (!(result->green = malloc(0)))
952 goto ERROR3;
953 if (!(result->blue = malloc(0)))
954 goto ERROR4;
955 return result;
956 ERROR4:
957 free(result->green);
958 ERROR3:
959 free(result->red);
960 ERROR2:
961 free(result);
962 ERROR1:
963 return NULL;
964 }
965
966
967 psiconv_pictures psiconv_empty_pictures(void)
968 {
969 psiconv_pictures result;
970 psiconv_paint_data_section pds;
971 if (!(result = psiconv_list_new(sizeof(struct psiconv_paint_data_section_s))))
972 goto ERROR1;
973 if (!(pds = psiconv_empty_paint_data_section()))
974 goto ERROR2;
975 if (psiconv_list_add(result,pds))
976 goto ERROR3;
977 free(pds);
978 return result;
979 ERROR3:
980 psiconv_free_paint_data_section(pds);
981 ERROR2:
982 psiconv_list_free(result);
983 ERROR1:
984 return NULL;
985 }
986
987 psiconv_mbm_f psiconv_empty_mbm_f(void)
988 {
989 psiconv_mbm_f result;
990 if (!(result = malloc(sizeof(*result))))
991 goto ERROR1;
992 if (!(result->sections = psiconv_empty_pictures()))
993 goto ERROR2;
994 return result;
995 ERROR2:
996 free(result);
997 ERROR1:
998 return NULL;
999 }
1000
1001 psiconv_sketch_section psiconv_empty_sketch_section(void)
1002 {
1003 psiconv_sketch_section result;
1004 if (!(result = malloc(sizeof(*result))))
1005 goto ERROR1;
1006 result->form_xsize = 320;
1007 result->form_ysize = 200;
1008 result->picture_x_offset = result->picture_y_offset = result->picture_xsize =
1009 result->picture_ysize = 0;
1010 result->magnification_x = result->magnification_y = 1.0;
1011 result->cut_left = result->cut_right = result->cut_top =
1012 result->cut_bottom = 0.0;
1013 if (!(result->picture = psiconv_empty_paint_data_section()))
1014 goto ERROR2;
1015 return result;
1016 ERROR2:
1017 free(result);
1018 ERROR1:
1019 return NULL;
1020 }
1021
1022 psiconv_sketch_f psiconv_empty_sketch_f(void)
1023 {
1024 psiconv_sketch_f result;
1025 if (!(result = malloc(sizeof(*result))))
1026 goto ERROR1;
1027 if (!(result->sketch_sec = psiconv_empty_sketch_section()))
1028 goto ERROR2;
1029 return result;
1030 ERROR2:
1031 free(result);
1032 ERROR1:
1033 return NULL;
1034 }
1035
1036 psiconv_cliparts psiconv_empty_cliparts(void)
1037 {
1038 /* Is this correct? */
1039 return psiconv_list_new(sizeof(struct psiconv_clipart_section_s));
1040 }
1041
1042 psiconv_clipart_f psiconv_empty_clipart_f(void)
1043 {
1044 psiconv_clipart_f result;
1045 if (!(result = malloc(sizeof(*result))))
1046 goto ERROR1;
1047 if (!(result->sections = psiconv_empty_cliparts()))
1048 goto ERROR2;
1049 return result;
1050 ERROR2:
1051 free(result);
1052 ERROR1:
1053 return NULL;
1054 }
1055
1056 psiconv_file psiconv_empty_file(psiconv_file_type_t type)
1057 {
1058 psiconv_file result;
1059 if (!(result = malloc(sizeof(*result))))
1060 return NULL;
1061 result->type = type;
1062 if (type == psiconv_word_file) {
1063 if (!(result->file = psiconv_empty_word_f()))
1064 goto ERROR;
1065 } else if (type == psiconv_texted_file) {
1066 if (!(result->file = psiconv_empty_texted_f()))
1067 goto ERROR;
1068 } else if (type == psiconv_mbm_file) {
1069 if (!(result->file = psiconv_empty_mbm_f()))
1070 goto ERROR;
1071 } else if (type == psiconv_sketch_file) {
1072 if (!(result->file = psiconv_empty_sketch_f()))
1073 goto ERROR;
1074 } else if (type == psiconv_clipart_file) {
1075 if (!(result->file = psiconv_empty_clipart_f()))
1076 goto ERROR;
1077 } else
1078 goto ERROR;
1079 return result;
1080 ERROR:
1081 free(result);
1082 return NULL;
1083 }

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26