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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 86 - (show annotations)
Thu Dec 28 15:49:12 2000 UTC (23 years, 3 months ago) by frodo
File MIME type: text/plain
File size: 24529 byte(s)
(Frodo) Update of format description. Added some obscure layout codes.

1 /*
2 parse_layout.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
23 #include <stdlib.h>
24 #include <math.h>
25
26 #include "parse_routines.h"
27 #include "error.h"
28
29 int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off,
30 int *length, psiconv_color *result)
31 {
32 int res = 0;
33 int len = 0;
34
35 psiconv_progress(lev+1,off,"Going to parse color");
36 if (!(*result = malloc(sizeof(**result))))
37 goto ERROR1;
38
39 (*result)->red = psiconv_read_u8(buf,lev+2,off+len,&res);
40 if (res)
41 goto ERROR2;
42 (*result)->green = psiconv_read_u8(buf,lev+2,off+len+1,&res);
43 if (res)
44 goto ERROR2;
45 (*result)->blue = psiconv_read_u8(buf,lev+2,off+len+2,&res);
46 if (res)
47 goto ERROR2;
48 len += 3;
49
50 psiconv_debug(lev+2,off,"Color: red %02x, green %02x, blue %02x",
51 (*result)->red, (*result)->green, (*result)->blue);
52 if (length)
53 *length = len;
54
55 psiconv_progress(lev+1,off+len-1,"End of color (total length: %08x)",len);
56 return 0;
57
58 ERROR2:
59 free(*result);
60 ERROR1:
61 psiconv_warn(lev+1,off,"Reading of Color failed");
62 if (length)
63 *length = 0;
64 if (res == 0)
65 return -PSICONV_E_NOMEM;
66 else
67 return res;
68 }
69
70
71
72 int psiconv_parse_font(const psiconv_buffer buf, int lev, psiconv_u32 off,
73 int *length, psiconv_font *result)
74 {
75 int res = 0;
76 int strlength,i;
77 char *str_copy;
78 int len;
79
80 psiconv_progress(lev+1,off,"Going to parse font");
81 if (!(*result = malloc(sizeof(**result))))
82 goto ERROR1;
83
84 strlength = psiconv_read_u8(buf,lev+2,off,&res);
85 if (res)
86 goto ERROR2;
87 if (!((*result)->name = malloc(strlength))) {
88 goto ERROR2;
89 }
90 for (i = 0; (i < strlength-1) && !res; i++)
91 (*result)->name[i] = psiconv_read_u8(buf,lev+2,off + 1 + i,&res);
92 if (res)
93 goto ERROR3;
94 (*result)->name[strlength-1] = 0;
95 (*result)->screenfont = psiconv_read_u8(buf,lev+2,off + strlength,&res);
96 if (res)
97 goto ERROR3;
98
99 if (!(str_copy = psiconv_make_printable((*result)->name)))
100 goto ERROR3;
101
102 psiconv_debug(lev+2,off+1,"Found font `%s', displayed with screen font %02x",
103 str_copy,(*result)->screenfont);
104 free(str_copy);
105 len = strlength + 1;
106 if (length)
107 *length = len;
108
109 psiconv_progress(lev+1,off + len - 1,"End of font (total length: %08x)",len);
110 return 0;
111
112 ERROR3:
113 free ((*result)->name);
114 ERROR2:
115 free (*result);
116 ERROR1:
117 psiconv_warn(lev+1,off,"Reading of Font failed");
118 if (length)
119 *length = 0;
120 if (!res)
121 return -PSICONV_E_NOMEM;
122 else
123 return res;
124 }
125
126 int psiconv_parse_border(const psiconv_buffer buf,int lev,psiconv_u32 off,
127 int *length, psiconv_border *result)
128 {
129 int res = 0;
130 int len = 0;
131 psiconv_u32 temp;
132 int leng;
133
134 psiconv_progress(lev+1,off,"Going to parse border data");
135 if (!(*result = malloc(sizeof(**result)))) {
136 goto ERROR1;
137 }
138
139 psiconv_progress(lev+2,off+len,"Going to read border kind");
140 temp = psiconv_read_u8(buf,lev+2,off+len,&res);
141 if (res)
142 goto ERROR2;
143 if (temp == 0x00)
144 (*result)->kind = psiconv_border_none;
145 else if (temp == 0x01)
146 (*result)->kind = psiconv_border_solid;
147 else if (temp == 0x02)
148 (*result)->kind = psiconv_border_double;
149 else if (temp == 0x03)
150 (*result)->kind = psiconv_border_dotted;
151 else if (temp == 0x04)
152 (*result)->kind = psiconv_border_dashed;
153 else if (temp == 0x05)
154 (*result)->kind = psiconv_border_dotdashed;
155 else if (temp == 0x06)
156 (*result)->kind = psiconv_border_dotdotdashed;
157 else {
158 psiconv_warn(lev+2,off,"Unknown border kind (defaults to `none')");
159 (*result)->kind = psiconv_border_none;
160 }
161 psiconv_debug(lev+2,off+len,"Kind: %02x",temp);
162 len ++;
163
164 psiconv_progress(lev+2,off+len,"Going to read border thickness");
165 (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng,&res);
166 if (res)
167 goto ERROR2;
168 #if 0
169 /* This seems no longer necessary to test? */
170 if (((*result)->kind != psiconv_border_solid) &&
171 ((*result)->kind != psiconv_border_double) &&
172 ((*result)->thickness != 0.0) &&
173 (fabs((*result)->thickness - 1/20) >= 1/1000)) {
174 psiconv_warn(lev+2,off,
175 "Border thickness specified for unlikely border type");
176 }
177 #endif
178 psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness);
179 len += leng;
180
181 psiconv_progress(lev+2,off+len,"Going to read the border color");
182 if ((psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color)))
183 goto ERROR2;
184 len += leng;
185
186 psiconv_progress(lev+2,off+len,"Going to read the final unknown byte "
187 "(0x00 or 0x01 expected)");
188 temp = psiconv_read_u8(buf,lev+2,off + len,&res);
189 if (res)
190 goto ERROR3;
191 if ((temp != 0x01) && (temp != 0x00)) {
192 psiconv_warn(lev+2,off,"Unknown last byte in border specification");
193 psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x or %02x",
194 temp,0x00,0x01);
195 }
196 len ++;
197
198 if (length)
199 *length = len;
200
201 psiconv_progress(lev+1,off + len - 1,
202 "End of border (total length: %08x)",len);
203
204 return 0;
205
206 ERROR3:
207 psiconv_free_color((*result)->color);
208 ERROR2:
209 free (result);
210 ERROR1:
211 psiconv_warn(lev+1,off,"Reading of Border failed");
212 if (length)
213 *length = 0;
214 if (!res)
215 return -PSICONV_E_NOMEM;
216 else
217 return res;
218 }
219
220 int psiconv_parse_bullet(const psiconv_buffer buf,int lev,psiconv_u32 off,
221 int *length, psiconv_bullet *result)
222 {
223 int res = 0;
224 int len = 0;
225 int leng;
226 int bullet_length;
227
228 if (!(*result = malloc(sizeof(**result))))
229 goto ERROR1;
230 (*result)->on = psiconv_bool_true;
231
232 psiconv_progress(lev+1,off,"Going to parse bullet data");
233 psiconv_progress(lev+2,off+len,"Going to read bullet length");
234 bullet_length = psiconv_read_u8(buf,lev+2,off+len,&res);
235 if (res)
236 goto ERROR2;
237 psiconv_debug(lev+2,off+len,"Length: %02x",bullet_length);
238 len ++;
239
240 psiconv_progress(lev+2,off+len,"Going to read bullet font size");
241 (*result)->font_size = psiconv_read_size(buf,lev+2,off+len, &leng,&res);
242 if (res)
243 goto ERROR2;
244 len +=leng;
245
246 psiconv_progress(lev+2,off+len,"Going to read bullet character");
247 (*result)->character = psiconv_read_u8(buf,lev+2,off+len,&res);
248 if (res)
249 goto ERROR2;
250 psiconv_debug(lev+2,off+len,"Character: %02x",(*result)->character);
251 len ++;
252
253 psiconv_progress(lev+2,off+len,"Going to read indent on/off");
254 if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng,&(*result)->indent)))
255 goto ERROR2;
256 psiconv_debug(lev+2,off+len,"Indent on: %02x",(*result)->indent);
257 len += leng;
258
259 psiconv_progress(lev+2,off+len,"Going to read bullet color");
260 if ((res = psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color)))
261 goto ERROR2;
262 len += leng;
263
264 psiconv_progress(lev+2,off+len,"Going to read bullet font");
265 if ((res = psiconv_parse_font(buf,lev+2,off+len,&leng,&(*result)->font)))
266 goto ERROR3;
267 len += leng;
268
269 if (len != bullet_length + 1) {
270 psiconv_warn(lev+2,off,"Bullet data structure length mismatch");
271 psiconv_debug(lev+2,off,"Length: specified %02x, found %02x",
272 bullet_length,len-1);
273 }
274
275 psiconv_progress(lev+1,off + len - 1,
276 "End of bullet data (total length: %08x)",len);
277
278 if (length)
279 *length = len;
280 return 0;
281
282 ERROR3:
283 psiconv_free_color((*result)->color);
284 ERROR2:
285 free (result);
286 ERROR1:
287 psiconv_warn(lev+1,off,"Reading of Bullet failed");
288 if (length)
289 *length = 0;
290 if (!res)
291 return -PSICONV_E_NOMEM;
292 else
293 return res;
294 }
295
296 int psiconv_parse_tab(const psiconv_buffer buf, int lev, psiconv_u32 off,
297 int *length, psiconv_tab *result)
298 {
299 int res = 0;
300 int len = 0;
301 int leng;
302 psiconv_u8 temp;
303
304 psiconv_progress(lev+1,off,"Going to parse tab");
305 if (!(*result = malloc(sizeof(**result))))
306 goto ERROR1;
307
308 psiconv_progress(lev+2,off,"Going to read tab location");
309 (*result)->location = psiconv_read_length(buf,lev+2,off+len,&leng,&res);
310 if (res)
311 goto ERROR2;
312 len += leng;
313
314 psiconv_progress(lev+2,off+len,"Going to read the tab kind");
315 temp = psiconv_read_u8(buf,lev+2,off+len,&res);
316 if (res)
317 goto ERROR2;
318 if (temp == 1)
319 (*result)->kind = psiconv_tab_left;
320 else if (temp == 2)
321 (*result)->kind = psiconv_tab_centre;
322 else if (temp == 3)
323 (*result)->kind = psiconv_tab_right;
324 else {
325 psiconv_warn(lev+2,off+len,"Unknown tab kind argument");
326 psiconv_debug(lev+2,off+len,"Kind found: %02x (defaulted to left tab)",
327 temp);
328 (*result)->kind = psiconv_tab_left;
329 }
330 psiconv_debug(lev+2,off+len,"Kind: %02x",temp);
331 len ++;
332
333 if (length)
334 *length = len;
335
336 psiconv_progress(lev+1,off+len-1,"End of tab (total length: %08x)",len);
337 return 0;
338
339 ERROR2:
340 free (result);
341 ERROR1:
342 psiconv_warn(lev+1,off,"Reading of Tab failed");
343 if (length)
344 *length = 0;
345 if (!res)
346 return -PSICONV_E_NOMEM;
347 else
348 return res;
349 }
350
351 int psiconv_parse_paragraph_layout_list(const psiconv_buffer buf, int lev,
352 psiconv_u32 off, int *length,
353 psiconv_paragraph_layout result)
354 {
355 int res=0;
356 int len=0;
357 int list_length,leng,nr;
358 psiconv_u8 id;
359 psiconv_u32 temp;
360 psiconv_tab temp_tab;
361 psiconv_color temp_color;
362 psiconv_border temp_border;
363 psiconv_bullet temp_bullet;
364
365 psiconv_progress(lev+1,off,"Going to read paragraph layout list");
366
367 psiconv_progress(lev+2,off,"Going to read the list length");
368 list_length = psiconv_read_u32(buf,lev+2,off + len,&res);
369 if (res)
370 goto ERROR1;
371 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length);
372 len += 4;
373
374 nr = 0;
375 while(len - 4 < list_length) {
376 psiconv_progress(lev+2,off+len,"Going to read element %d",nr);
377 psiconv_progress(lev+3,off+len,"Going to read the element id");
378 id = psiconv_read_u8(buf,lev+2,off+len,&res);
379 if (res)
380 goto ERROR1;
381 psiconv_debug(lev+3,off+len,"Id: %02x",id);
382 len ++;
383 switch(id) {
384 case 0x01:
385 psiconv_progress(lev+3,off+len,"Going to read background color");
386 if ((res = psiconv_parse_color(buf,lev+3,off+len,&leng,&temp_color)))
387 goto ERROR1;
388 psiconv_free_color(result->back_color);
389 result->back_color = temp_color;
390 len += leng;
391 break;
392 case 0x02:
393 psiconv_progress(lev+3,off+len ,"Going to read indent left");
394 result->indent_left = psiconv_read_length(buf,lev+3,off+len,&leng,&res);
395 if (res)
396 goto ERROR1;
397 len += leng;
398 break;
399 case 0x03:
400 psiconv_progress(lev+3,off+len,"Going to read indent right");
401 result->indent_right = psiconv_read_length(buf,lev+2,off+len,&leng,
402 &res);
403 if (res)
404 goto ERROR1;
405 len += leng;
406 break;
407 case 0x04:
408 psiconv_progress(lev+3,off+len,"Going to read indent left first line");
409 result->indent_first = psiconv_read_length(buf,lev+2,off+len, &leng,
410 &res);
411 if (res)
412 goto ERROR1;
413 len += leng;
414 break;
415 case 0x05:
416 psiconv_progress(lev+3,off+len,"Going to read horizontal justify");
417 temp = psiconv_read_u8(buf,lev+3,off+len,&res);
418 if (res)
419 goto ERROR1;
420 if (temp == 0x00)
421 result->justify_hor = psiconv_justify_left;
422 else if (temp == 0x01)
423 result->justify_hor = psiconv_justify_centre;
424 else if (temp == 0x02)
425 result->justify_hor = psiconv_justify_right;
426 else if (temp == 0x03)
427 result->justify_hor = psiconv_justify_full;
428 else {
429 psiconv_warn(lev+3,off+len, "Unknown horizontal justify argument "
430 "in paragraph layout codes list");
431 result->justify_hor = psiconv_justify_left;
432 }
433 psiconv_debug(lev+3,off+len,"Justify: %02x",temp);
434 len ++;
435 break;
436 case 0x06:
437 psiconv_progress(lev+3,off+len,"Going to read vertical justify");
438 temp = psiconv_read_u8(buf,lev+3,off+len,&res);
439 if (res)
440 goto ERROR1;
441 if (temp == 0x00)
442 result->justify_ver = psiconv_justify_top;
443 else if (temp == 0x01)
444 result->justify_ver = psiconv_justify_middle;
445 else if (temp == 0x02)
446 result->justify_ver = psiconv_justify_bottom;
447 else {
448 psiconv_warn(lev+3,off+len, "Unknown vertical justify argument "
449 "in paragraph layout codes list");
450 result->justify_ver = psiconv_justify_bottom;
451 }
452 psiconv_debug(lev+3,off+len,"Justify: %02x",temp);
453 len ++;
454 case 0x07:
455 psiconv_progress(lev+3,off+len,"Going to read linespacing distance");
456 result->linespacing = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
457 if (res)
458 goto ERROR1;
459 len += leng;
460 break;
461 case 0x08:
462 psiconv_progress(lev+3,off+len,"Going to read linespacing exact");
463 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
464 &result->linespacing_exact)))
465 goto ERROR1;
466 len += leng;
467 break;
468 case 0x09:
469 psiconv_progress(lev+3,off+len,"Going to read top space");
470 result->space_above = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
471 if (res)
472 goto ERROR1;
473 len += leng;
474 break;
475 case 0x0a:
476 psiconv_progress(lev+3,off+len,"Going to read bottom space");
477 result->space_below = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
478 if (res)
479 goto ERROR1;
480 len += leng;
481 break;
482 case 0x0b:
483 psiconv_progress(lev+3,off+len,"Going to read on one page");
484 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
485 &result->keep_together)))
486 goto ERROR1;
487 len += leng;
488 break;
489 case 0x0c:
490 psiconv_progress(lev+3,off+len,"Going to read together with");
491 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
492 &result->keep_with_next)))
493 goto ERROR1;
494 len += leng;
495 break;
496 case 0x0d:
497 psiconv_progress(lev+3,off+len,"Going to read on next page");
498 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
499 &result->on_next_page)))
500 goto ERROR1;
501 len += leng;
502 break;
503 case 0x0e:
504 psiconv_progress(lev+3,off+len,"Going to read no widow protection");
505 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
506 &result->no_widow_protection)))
507 goto ERROR1;
508 len += leng;
509 break;
510 case 0x10:
511 psiconv_progress(lev+3,off+len,"Going to read border distance to text");
512 result->border_distance = psiconv_read_length(buf,lev+3,
513 off+len,&leng,&res);
514 if (res)
515 goto ERROR1;
516 len += leng;
517 break;
518 case 0x11:
519 psiconv_progress(lev+3,off+len,"Going to read top border");
520 if ((res = psiconv_parse_border(buf,lev+3,off+len,&leng,&temp_border)))
521 goto ERROR1;
522 psiconv_free_border(result->top_border);
523 result->top_border = temp_border;
524 len += leng;
525 break;
526 case 0x12:
527 psiconv_progress(lev+3,off+len,"Going to read bottom border");
528 if ((res = psiconv_parse_border(buf,lev+3,off+len,&leng,&temp_border)))
529 goto ERROR1;
530 psiconv_free_border(result->bottom_border);
531 result->bottom_border = temp_border;
532 len += leng;
533 break;
534 case 0x13:
535 psiconv_progress(lev+3,off+len,"Going to read left border");
536 if ((res = psiconv_parse_border(buf,lev+3,off+len,&leng,&temp_border)))
537 goto ERROR1;
538 psiconv_free_border(result->left_border);
539 result->left_border = temp_border;
540 len += leng;
541 break;
542 case 0x14:
543 psiconv_progress(lev+3,off+len,"Going to read right border");
544 if ((res = psiconv_parse_border(buf,lev+3,off+len,&leng,&temp_border)))
545 goto ERROR1;
546 psiconv_free_border(result->right_border);
547 result->right_border = temp_border;
548 len += leng;
549 break;
550 case 0x15:
551 psiconv_progress(lev+3,off+len,"Going to read bullet");
552 if ((res = psiconv_parse_bullet(buf,lev+3,off+len,&leng,&temp_bullet)))
553 goto ERROR1;
554 psiconv_free_bullet(result->bullet);
555 result->bullet = temp_bullet;
556 len += leng;
557 break;
558 case 0x16:
559 psiconv_progress(lev+3,off+len,"Going to read standard tabs");
560 result->tabs->normal = psiconv_read_length(buf,lev+3,off+len,&leng,
561 &res);
562 if (res)
563 goto ERROR1;
564 len += leng;
565 break;
566 case 0x17:
567 psiconv_progress(lev+3,off+len,"Going to read extra tab");
568 if ((res = psiconv_parse_tab(buf,lev+3,off+len,&leng,&temp_tab)))
569 goto ERROR1;
570 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) {
571 psiconv_free_tab(temp_tab);
572 goto ERROR1;
573 }
574 len += leng;
575 break;
576 default:
577 psiconv_warn(lev+3,off+len,
578 "Unknown code in paragraph layout codes list");
579 psiconv_debug(lev+3,off+len,"Code: %02x",id);
580 len ++;
581 break;
582 }
583 nr ++;
584 }
585
586 if (len - 4 != list_length) {
587 psiconv_warn(lev+2,off+len,
588 "Read past end of paragraph layout codes list. I probably lost track"
589 "somewhere!");
590 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d",
591 len-4,list_length);
592 res = PSICONV_E_PARSE;
593 goto ERROR1;
594 }
595
596 len = list_length + 4;
597
598 psiconv_progress(lev+1,off+len,
599 "End of paragraph layout list (total length: %08x)",len);
600
601 if (length)
602 *length = len;
603 return 0;
604
605 ERROR1:
606 psiconv_warn(lev+1,off,"Reading of paragraph_layout_list failed");
607 if (length)
608 *length = 0;
609 if (!res)
610 return -PSICONV_E_NOMEM;
611 else
612 return res;
613 }
614
615 int psiconv_parse_character_layout_list(const psiconv_buffer buf, int lev,
616 psiconv_u32 off, int *length,
617 psiconv_character_layout result)
618 {
619 int res=0;
620 int len=0;
621 int list_length,leng,nr;
622 psiconv_u8 id;
623 psiconv_u32 temp;
624 psiconv_color temp_color;
625 psiconv_font temp_font;
626
627 psiconv_progress(lev+1,off,"Going to read character layout codes");
628
629 psiconv_progress(lev+2,off,"Going to read the list length");
630 list_length = psiconv_read_u32(buf,lev+2,off + len,&res);
631 if (res)
632 goto ERROR1;
633 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length);
634 len += 4;
635
636 nr = 0;
637 while(len-4 < list_length) {
638 psiconv_progress(lev+2,off+len,"Going to read element %d",nr);
639 psiconv_progress(lev+3,off+len,"Going to read the element id");
640 id = psiconv_read_u8(buf,lev+2,off+len,&res);
641 if (res)
642 goto ERROR1;
643 psiconv_debug(lev+3,off+len,"Id: %02x",id);
644 len ++;
645 switch(id) {
646 case 0x18:
647 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting");
648 len ++;
649 break;
650 case 0x19:
651 psiconv_progress(lev+3,off+len,"Going to read text color");
652 if ((res = psiconv_parse_color(buf,lev+3,off+len, &leng,&temp_color)))
653 goto ERROR1;
654 psiconv_free_color(result->color);
655 result->color = temp_color;
656 len += leng;
657 break;
658 case 0x1a:
659 psiconv_progress(lev+3,off+len,"Going to read background color (?)");
660 if ((res = psiconv_parse_color(buf,lev+2,off+len, &leng,&temp_color)))
661 goto ERROR1;
662 psiconv_free_color(result->back_color);
663 result->back_color = temp_color;
664 len += leng;
665 break;
666 case 0x1b:
667 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting");
668 len ++;
669 break;
670 case 0x1c:
671 psiconv_progress(lev+3,off+len,"Going to read font size");
672 result->font_size = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
673 if (res)
674 goto ERROR1;
675 len += leng;
676 break;
677 case 0x1d:
678 psiconv_progress(lev+3,off+len,"Going to read italic");
679 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,&result->italic)))
680 goto ERROR1;
681 len += leng;
682 break;
683 case 0x1e:
684 psiconv_progress(lev+3,off+len,"Going to read bold");
685 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,&result->bold)))
686 goto ERROR1;
687 len += leng;
688 break;
689 case 0x1f:
690 psiconv_progress(lev+3,off+len,"Going to read super_sub");
691 temp = psiconv_read_u8(buf,lev+3,off+len,&res);
692 if (res)
693 goto ERROR1;
694 if (temp == 0x00)
695 result->super_sub = psiconv_normalscript;
696 else if (temp == 0x01)
697 result->super_sub = psiconv_superscript;
698 else if (temp == 0x02)
699 result->super_sub = psiconv_subscript;
700 else {
701 psiconv_warn(lev+3,off+len,
702 "Unknown super_sub argument in character layout codes list");
703 }
704 psiconv_debug(lev+3,off+len,"Super_sub: %02x",temp);
705 len ++;
706 break;
707 case 0x20:
708 psiconv_progress(lev+3,off+len,"Going to read underline");
709 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
710 &result->underline)))
711 goto ERROR1;
712 len += leng;
713 break;
714 case 0x21:
715 psiconv_progress(lev+3,off+len,"Going to read strikethrough");
716 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
717 &result->strikethrough)))
718 goto ERROR1;
719 len += leng;
720 break;
721 case 0x22:
722 psiconv_progress(lev+3,off+len,"Going to read font");
723 if ((res = psiconv_parse_font(buf,lev+3,off+len, &leng, &temp_font)))
724 goto ERROR1;
725 psiconv_free_font(result->font);
726 result->font = temp_font;
727 len += leng;
728 break;
729 case 0x23:
730 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting");
731 len ++;
732 break;
733 case 0x24:
734 psiconv_progress(lev+3,off+len,
735 "Going to read unknown code 0x24 (%02x expected)", 0);
736 temp = psiconv_read_u8(buf,lev+3,off+len,&res);
737 if (res)
738 goto ERROR1;
739 if (temp != 0) {
740 psiconv_warn(lev+3,off+len,
741 "Unknown code 0x24 value != 0x0 (0x%02x)", temp);
742 }
743 len ++;
744 break;
745 default:
746 psiconv_warn(lev+3,off+len,"Unknown code in character layout list");
747 psiconv_debug(lev+3,off+len,"Code: %02x",id);
748 len ++;
749 break;
750 }
751 nr ++;
752 }
753
754 if (len - 4 != list_length) {
755 psiconv_warn(lev+2,off+len,
756 "Read past end of character layout codes list. I probably lost track"
757 "somewhere!");
758 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d",
759 len-4,list_length);
760 res = PSICONV_E_PARSE;
761 goto ERROR1;
762 }
763
764 len = list_length + 4;
765
766 psiconv_progress(lev+1,off+len,
767 "End of character layout list (total length: %08x)",len);
768
769 if (length)
770 *length = len;
771 return res;
772
773 ERROR1:
774 psiconv_warn(lev+1,off,"Reading of character_layout_list failed");
775 if (length)
776 *length = 0;
777 if (!res)
778 return -PSICONV_E_NOMEM;
779 else
780 return res;
781 }

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