1 | /* |
1 | /* |
2 | data.c - Part of psiconv, a PSION 5 file formats converter |
2 | data.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
21 | #include "compat.h" |
21 | #include "compat.h" |
22 | #include <stdlib.h> |
22 | #include <stdlib.h> |
23 | #include <string.h> |
23 | #include <string.h> |
24 | #include "data.h" |
24 | #include "data.h" |
25 | #include "list.h" |
25 | #include "list.h" |
|
|
26 | #include "unicode.h" |
26 | |
27 | |
27 | #ifdef DMALLOC |
28 | #ifdef DMALLOC |
28 | #include <dmalloc.h> |
29 | #include <dmalloc.h> |
29 | #endif |
30 | #endif |
30 | |
31 | |
… | |
… | |
82 | { |
83 | { |
83 | 0xff, /* red */ |
84 | 0xff, /* red */ |
84 | 0xff, /* green */ |
85 | 0xff, /* green */ |
85 | 0xff, /* blue */ |
86 | 0xff, /* blue */ |
86 | }; |
87 | }; |
|
|
88 | static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ', |
|
|
89 | 'N','e','w',' ', |
|
|
90 | 'R','o','m','a','n',0 }; |
87 | static struct psiconv_font_s font = |
91 | static struct psiconv_font_s font = |
88 | { |
92 | { |
89 | "Times New Roman", /* name */ |
93 | font_times, /* name */ |
90 | 3 /* screenfont */ |
94 | 3 /* screenfont */ |
91 | }; |
95 | }; |
92 | struct psiconv_character_layout_s cl = |
96 | struct psiconv_character_layout_s cl = |
93 | { |
97 | { |
94 | &black, /* color */ |
98 | &black, /* color */ |
… | |
… | |
107 | |
111 | |
108 | /* Note: these defaults seem to be hard-coded somewhere outside the |
112 | /* Note: these defaults seem to be hard-coded somewhere outside the |
109 | files themself. */ |
113 | files themself. */ |
110 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
114 | psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) |
111 | { |
115 | { |
|
|
116 | static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ', |
|
|
117 | 'N','e','w',' ', |
|
|
118 | 'R','o','m','a','n',0 }; |
|
|
119 | |
112 | static struct psiconv_font_s font = |
120 | static struct psiconv_font_s font = |
113 | { |
121 | { |
114 | "Times New Roman", /* name */ |
122 | font_times, /* name */ |
115 | 2 /* screenfont */ |
123 | 2 /* screenfont */ |
116 | }; |
124 | }; |
117 | static struct psiconv_color_s black = |
125 | static struct psiconv_color_s black = |
118 | { |
126 | { |
119 | 0x00, /* red */ |
127 | 0x00, /* red */ |
… | |
… | |
134 | }; |
142 | }; |
135 | static struct psiconv_bullet_s bullet = |
143 | static struct psiconv_bullet_s bullet = |
136 | { |
144 | { |
137 | psiconv_bool_false, /* on */ |
145 | psiconv_bool_false, /* on */ |
138 | 10.0, /* font_size */ |
146 | 10.0, /* font_size */ |
139 | 0x95, /* character */ |
147 | 0x201d, /* character */ |
140 | psiconv_bool_true, /* indent */ |
148 | psiconv_bool_true, /* indent */ |
141 | &black, /* color */ |
149 | &black, /* color */ |
142 | &font, /* font */ |
150 | &font, /* font */ |
143 | }; |
151 | }; |
144 | static struct psiconv_all_tabs_s tabs = |
152 | static struct psiconv_all_tabs_s tabs = |
… | |
… | |
193 | { |
201 | { |
194 | psiconv_font result; |
202 | psiconv_font result; |
195 | if(!(result = malloc(sizeof(*result)))) |
203 | if(!(result = malloc(sizeof(*result)))) |
196 | goto ERROR1; |
204 | goto ERROR1; |
197 | *result = *font; |
205 | *result = *font; |
198 | if (!(result->name = strdup(result->name))) |
206 | if (!(result->name = psiconv_unicode_strdup(result->name))) |
199 | goto ERROR2; |
207 | goto ERROR2; |
200 | return result; |
208 | return result; |
201 | ERROR2: |
209 | ERROR2: |
202 | free(result); |
210 | free(result); |
203 | ERROR1: |
211 | ERROR1: |
… | |
… | |
439 | psiconv_free_style_aux(style); |
447 | psiconv_free_style_aux(style); |
440 | free(style); |
448 | free(style); |
441 | } |
449 | } |
442 | } |
450 | } |
443 | |
451 | |
|
|
452 | void psiconv_free_word_style_list(psiconv_word_style_list style_list) |
|
|
453 | { |
|
|
454 | if (style_list) |
|
|
455 | psiconv_list_free_el(style_list,psiconv_free_style_aux); |
|
|
456 | } |
|
|
457 | |
444 | void psiconv_free_word_styles_section(psiconv_word_styles_section styles) |
458 | void psiconv_free_word_styles_section(psiconv_word_styles_section styles) |
445 | { |
459 | { |
446 | if (styles) { |
460 | if (styles) { |
447 | psiconv_free_word_style(styles->normal); |
461 | psiconv_free_word_style(styles->normal); |
448 | if (styles->styles) |
462 | psiconv_free_word_style_list(styles->styles); |
449 | psiconv_list_free_el(styles->styles,psiconv_free_style_aux); |
|
|
450 | free(styles); |
463 | free(styles); |
451 | } |
464 | } |
452 | } |
465 | } |
453 | |
466 | |
454 | void psiconv_free_header_section(psiconv_header_section header) |
467 | void psiconv_free_header_section(psiconv_header_section header) |
… | |
… | |
885 | } |
898 | } |
886 | |
899 | |
887 | void psiconv_free_clipart_section_aux(void *section) |
900 | void psiconv_free_clipart_section_aux(void *section) |
888 | { |
901 | { |
889 | if (section) |
902 | if (section) |
890 | free(((psiconv_clipart_section ) section)->picture); |
903 | psiconv_free_paint_data_section(((psiconv_clipart_section) section)->picture); |
891 | } |
904 | } |
892 | |
905 | |
893 | void psiconv_free_clipart_section(psiconv_clipart_section section) |
906 | void psiconv_free_clipart_section(psiconv_clipart_section section) |
894 | { |
907 | { |
895 | if (section) { |
908 | if (section) { |
… | |
… | |
948 | const psiconv_font value2) |
961 | const psiconv_font value2) |
949 | { |
962 | { |
950 | if (!value1 || !value2 || !value1->name || !value2->name) |
963 | if (!value1 || !value2 || !value1->name || !value2->name) |
951 | return 1; |
964 | return 1; |
952 | if ((value1->screenfont == value2->screenfont) && |
965 | if ((value1->screenfont == value2->screenfont) && |
953 | !strcmp(value1->name,value2->name)) |
966 | !psiconv_unicode_strcmp(value1->name,value2->name)) |
954 | return 0; |
967 | return 0; |
955 | else |
968 | else |
956 | return 1; |
969 | return 1; |
957 | } |
970 | } |
958 | |
971 | |