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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 71 Revision 143
23#include <stdlib.h> 23#include <stdlib.h>
24#include <math.h> 24#include <math.h>
25 25
26#include "parse_routines.h" 26#include "parse_routines.h"
27#include "error.h" 27#include "error.h"
28
29#ifdef DMALLOC
30#include <dmalloc.h>
31#endif
32
28 33
29int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off, 34int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off,
30 int *length, psiconv_color *result) 35 int *length, psiconv_color *result)
31{ 36{
32 int res = 0; 37 int res = 0;
163 168
164 psiconv_progress(lev+2,off+len,"Going to read border thickness"); 169 psiconv_progress(lev+2,off+len,"Going to read border thickness");
165 (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng,&res); 170 (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng,&res);
166 if (res) 171 if (res)
167 goto ERROR2; 172 goto ERROR2;
173#if 0
174 /* This seems no longer necessary to test? */
168 if (((*result)->kind != psiconv_border_solid) && 175 if (((*result)->kind != psiconv_border_solid) &&
169 ((*result)->kind != psiconv_border_double) && 176 ((*result)->kind != psiconv_border_double) &&
170 ((*result)->thickness != 0.0) && 177 ((*result)->thickness != 0.0) &&
171 (fabs((*result)->thickness - 1/20) >= 1/1000)) { 178 (fabs((*result)->thickness - 1/20) >= 1/1000)) {
172 psiconv_warn(lev+2,off, 179 psiconv_warn(lev+2,off,
173 "Border thickness specified for unlikely border type"); 180 "Border thickness specified for unlikely border type");
174 } 181 }
182#endif
175 psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness); 183 psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness);
176 len += leng; 184 len += leng;
177 185
178 psiconv_progress(lev+2,off+len,"Going to read the border color"); 186 psiconv_progress(lev+2,off+len,"Going to read the border color");
179 if ((psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color))) 187 if ((psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color)))
180 goto ERROR2; 188 goto ERROR2;
181 len += leng; 189 len += leng;
182 190
183 psiconv_progress(lev+2,off+len,"Going to read the final unknown byte " 191 psiconv_progress(lev+2,off+len,"Going to read the final unknown byte "
184 "(0x01 expected)"); 192 "(0x00 or 0x01 expected)");
185 temp = psiconv_read_u8(buf,lev+2,off + len,&res); 193 temp = psiconv_read_u8(buf,lev+2,off + len,&res);
186 if (res) 194 if (res)
187 goto ERROR3; 195 goto ERROR3;
188 if (temp != 0x01) { 196 if ((temp != 0x01) && (temp != 0x00)) {
189 psiconv_warn(lev+2,off,"Unknown last byte in border specification"); 197 psiconv_warn(lev+2,off,"Unknown last byte in border specification");
190 psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x", 198 psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x or %02x",
191 temp,0x01); 199 temp,0x00,0x01);
192 } 200 }
193 len ++; 201 len ++;
194 202
195 if (length) 203 if (length)
196 *length = len; 204 *length = len;
446 "in paragraph layout codes list"); 454 "in paragraph layout codes list");
447 result->justify_ver = psiconv_justify_bottom; 455 result->justify_ver = psiconv_justify_bottom;
448 } 456 }
449 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 457 psiconv_debug(lev+3,off+len,"Justify: %02x",temp);
450 len ++; 458 len ++;
459 break;
451 case 0x07: 460 case 0x07:
452 psiconv_progress(lev+3,off+len,"Going to read linespacing distance"); 461 psiconv_progress(lev+3,off+len,"Going to read linespacing distance");
453 result->linespacing = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 462 result->linespacing = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
454 if (res) 463 if (res)
455 goto ERROR1; 464 goto ERROR1;
502 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 511 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
503 &result->no_widow_protection))) 512 &result->no_widow_protection)))
504 goto ERROR1; 513 goto ERROR1;
505 len += leng; 514 len += leng;
506 break; 515 break;
516 case 0x0f:
517 psiconv_progress(lev+3,off+len,"Going to read wrap to fit cell limits");
518 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
519 &result->wrap_to_fit_cell)))
520 goto ERROR1;
521 len += leng;
522 break;
507 case 0x10: 523 case 0x10:
508 psiconv_progress(lev+3,off+len,"Going to read border distance to text"); 524 psiconv_progress(lev+3,off+len,"Going to read border distance to text");
509 result->border_distance = psiconv_read_length(buf,lev+3, 525 result->border_distance = psiconv_read_length(buf,lev+3,
510 off+len,&leng,&res); 526 off+len,&leng,&res);
511 if (res) 527 if (res)
566 goto ERROR1; 582 goto ERROR1;
567 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) { 583 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) {
568 psiconv_free_tab(temp_tab); 584 psiconv_free_tab(temp_tab);
569 goto ERROR1; 585 goto ERROR1;
570 } 586 }
587 psiconv_free_tab(temp_tab);
571 len += leng; 588 len += leng;
572 break; 589 break;
573 default: 590 default:
574 psiconv_warn(lev+3,off+len, 591 psiconv_warn(lev+3,off+len,
575 "Unknown code in paragraph layout codes list"); 592 "Unknown code in paragraph layout codes list");
638 if (res) 655 if (res)
639 goto ERROR1; 656 goto ERROR1;
640 psiconv_debug(lev+3,off+len,"Id: %02x",id); 657 psiconv_debug(lev+3,off+len,"Id: %02x",id);
641 len ++; 658 len ++;
642 switch(id) { 659 switch(id) {
660 case 0x18:
661 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting");
662 len ++;
663 break;
643 case 0x19: 664 case 0x19:
644 psiconv_progress(lev+3,off+len,"Going to read text color"); 665 psiconv_progress(lev+3,off+len,"Going to read text color");
645 if ((res = psiconv_parse_color(buf,lev+3,off+len, &leng,&temp_color))) 666 if ((res = psiconv_parse_color(buf,lev+3,off+len, &leng,&temp_color)))
646 goto ERROR1; 667 goto ERROR1;
647 psiconv_free_color(result->color); 668 psiconv_free_color(result->color);
653 if ((res = psiconv_parse_color(buf,lev+2,off+len, &leng,&temp_color))) 674 if ((res = psiconv_parse_color(buf,lev+2,off+len, &leng,&temp_color)))
654 goto ERROR1; 675 goto ERROR1;
655 psiconv_free_color(result->back_color); 676 psiconv_free_color(result->back_color);
656 result->back_color = temp_color; 677 result->back_color = temp_color;
657 len += leng; 678 len += leng;
679 break;
680 case 0x1b:
681 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting");
682 len ++;
658 break; 683 break;
659 case 0x1c: 684 case 0x1c:
660 psiconv_progress(lev+3,off+len,"Going to read font size"); 685 psiconv_progress(lev+3,off+len,"Going to read font size");
661 result->font_size = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 686 result->font_size = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
662 if (res) 687 if (res)
713 goto ERROR1; 738 goto ERROR1;
714 psiconv_free_font(result->font); 739 psiconv_free_font(result->font);
715 result->font = temp_font; 740 result->font = temp_font;
716 len += leng; 741 len += leng;
717 break; 742 break;
743 case 0x23:
744 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting");
745 len ++;
746 break;
718 case 0x24: 747 case 0x24:
719 psiconv_progress(lev+3,off+len, 748 psiconv_progress(lev+3,off+len,
720 "Going to read unknown code 0x24 (%02x expected)", 0); 749 "Going to read unknown code 0x24 (%02x expected)", 0);
721 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 750 temp = psiconv_read_u8(buf,lev+3,off+len,&res);
722 if (res) 751 if (res)

Legend:
Removed from v.71  
changed lines
  Added in v.143

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