… | |
… | |
16 | along with this program; if not, write to the Free Software |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ |
18 | */ |
19 | |
19 | |
20 | #include "config.h" |
20 | #include "config.h" |
|
|
21 | #include "compat.h" |
|
|
22 | |
21 | #include <stdlib.h> |
23 | #include <stdlib.h> |
22 | #include <math.h> |
24 | #include <math.h> |
23 | |
25 | |
24 | #include "data.h" |
|
|
25 | #include "parse_routines.h" |
26 | #include "parse_routines.h" |
|
|
27 | #include "error.h" |
26 | |
28 | |
27 | int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off, |
29 | int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off, |
28 | int *length, psiconv_color *result) |
30 | int *length, psiconv_color *result) |
29 | { |
31 | { |
30 | int res = 0; |
32 | int res = 0; |
… | |
… | |
161 | |
163 | |
162 | psiconv_progress(lev+2,off+len,"Going to read border thickness"); |
164 | psiconv_progress(lev+2,off+len,"Going to read border thickness"); |
163 | (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng,&res); |
165 | (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng,&res); |
164 | if (res) |
166 | if (res) |
165 | goto ERROR2; |
167 | goto ERROR2; |
|
|
168 | #if 0 |
|
|
169 | /* This seems no longer necessary to test? */ |
166 | if (((*result)->kind != psiconv_border_solid) && |
170 | if (((*result)->kind != psiconv_border_solid) && |
167 | ((*result)->kind != psiconv_border_double) && |
171 | ((*result)->kind != psiconv_border_double) && |
168 | ((*result)->thickness != 0.0) && |
172 | ((*result)->thickness != 0.0) && |
169 | (fabs((*result)->thickness - 1/20) >= 1/1000)) { |
173 | (fabs((*result)->thickness - 1/20) >= 1/1000)) { |
170 | psiconv_warn(lev+2,off, |
174 | psiconv_warn(lev+2,off, |
171 | "Border thickness specified for unlikely border type"); |
175 | "Border thickness specified for unlikely border type"); |
172 | } |
176 | } |
|
|
177 | #endif |
173 | psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness); |
178 | psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness); |
174 | len += leng; |
179 | len += leng; |
175 | |
180 | |
176 | psiconv_progress(lev+2,off+len,"Going to read the border color"); |
181 | psiconv_progress(lev+2,off+len,"Going to read the border color"); |
177 | if ((psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color))) |
182 | if ((psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color))) |
178 | goto ERROR2; |
183 | goto ERROR2; |
179 | len += leng; |
184 | len += leng; |
180 | |
185 | |
181 | psiconv_progress(lev+2,off+len,"Going to read the final unknown byte " |
186 | psiconv_progress(lev+2,off+len,"Going to read the final unknown byte " |
182 | "(0x01 expected)"); |
187 | "(0x00 or 0x01 expected)"); |
183 | temp = psiconv_read_u8(buf,lev+2,off + len,&res); |
188 | temp = psiconv_read_u8(buf,lev+2,off + len,&res); |
184 | if (res) |
189 | if (res) |
185 | goto ERROR3; |
190 | goto ERROR3; |
186 | if (temp != 0x01) { |
191 | if ((temp != 0x01) && (temp != 0x00)) { |
187 | psiconv_warn(lev+2,off,"Unknown last byte in border specification"); |
192 | psiconv_warn(lev+2,off,"Unknown last byte in border specification"); |
188 | psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x", |
193 | psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x or %02x", |
189 | temp,0x01); |
194 | temp,0x00,0x01); |
190 | } |
195 | } |
191 | len ++; |
196 | len ++; |
192 | |
197 | |
193 | if (length) |
198 | if (length) |
194 | *length = len; |
199 | *length = len; |
… | |
… | |
444 | "in paragraph layout codes list"); |
449 | "in paragraph layout codes list"); |
445 | result->justify_ver = psiconv_justify_bottom; |
450 | result->justify_ver = psiconv_justify_bottom; |
446 | } |
451 | } |
447 | psiconv_debug(lev+3,off+len,"Justify: %02x",temp); |
452 | psiconv_debug(lev+3,off+len,"Justify: %02x",temp); |
448 | len ++; |
453 | len ++; |
|
|
454 | break; |
449 | case 0x07: |
455 | case 0x07: |
450 | psiconv_progress(lev+3,off+len,"Going to read linespacing distance"); |
456 | psiconv_progress(lev+3,off+len,"Going to read linespacing distance"); |
451 | result->linespacing = psiconv_read_size(buf,lev+3,off+len,&leng,&res); |
457 | result->linespacing = psiconv_read_size(buf,lev+3,off+len,&leng,&res); |
452 | if (res) |
458 | if (res) |
453 | goto ERROR1; |
459 | goto ERROR1; |
… | |
… | |
497 | break; |
503 | break; |
498 | case 0x0e: |
504 | case 0x0e: |
499 | psiconv_progress(lev+3,off+len,"Going to read no widow protection"); |
505 | psiconv_progress(lev+3,off+len,"Going to read no widow protection"); |
500 | if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, |
506 | if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, |
501 | &result->no_widow_protection))) |
507 | &result->no_widow_protection))) |
|
|
508 | goto ERROR1; |
|
|
509 | len += leng; |
|
|
510 | break; |
|
|
511 | case 0x0f: |
|
|
512 | psiconv_progress(lev+3,off+len,"Going to read wrap to fit cell limits"); |
|
|
513 | if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, |
|
|
514 | &result->wrap_to_fit_cell))) |
502 | goto ERROR1; |
515 | goto ERROR1; |
503 | len += leng; |
516 | len += leng; |
504 | break; |
517 | break; |
505 | case 0x10: |
518 | case 0x10: |
506 | psiconv_progress(lev+3,off+len,"Going to read border distance to text"); |
519 | psiconv_progress(lev+3,off+len,"Going to read border distance to text"); |
… | |
… | |
636 | if (res) |
649 | if (res) |
637 | goto ERROR1; |
650 | goto ERROR1; |
638 | psiconv_debug(lev+3,off+len,"Id: %02x",id); |
651 | psiconv_debug(lev+3,off+len,"Id: %02x",id); |
639 | len ++; |
652 | len ++; |
640 | switch(id) { |
653 | switch(id) { |
|
|
654 | case 0x18: |
|
|
655 | psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); |
|
|
656 | len ++; |
|
|
657 | break; |
641 | case 0x19: |
658 | case 0x19: |
642 | psiconv_progress(lev+3,off+len,"Going to read text color"); |
659 | psiconv_progress(lev+3,off+len,"Going to read text color"); |
643 | if ((res = psiconv_parse_color(buf,lev+3,off+len, &leng,&temp_color))) |
660 | if ((res = psiconv_parse_color(buf,lev+3,off+len, &leng,&temp_color))) |
644 | goto ERROR1; |
661 | goto ERROR1; |
645 | psiconv_free_color(result->color); |
662 | psiconv_free_color(result->color); |
… | |
… | |
651 | if ((res = psiconv_parse_color(buf,lev+2,off+len, &leng,&temp_color))) |
668 | if ((res = psiconv_parse_color(buf,lev+2,off+len, &leng,&temp_color))) |
652 | goto ERROR1; |
669 | goto ERROR1; |
653 | psiconv_free_color(result->back_color); |
670 | psiconv_free_color(result->back_color); |
654 | result->back_color = temp_color; |
671 | result->back_color = temp_color; |
655 | len += leng; |
672 | len += leng; |
|
|
673 | break; |
|
|
674 | case 0x1b: |
|
|
675 | psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); |
|
|
676 | len ++; |
656 | break; |
677 | break; |
657 | case 0x1c: |
678 | case 0x1c: |
658 | psiconv_progress(lev+3,off+len,"Going to read font size"); |
679 | psiconv_progress(lev+3,off+len,"Going to read font size"); |
659 | result->font_size = psiconv_read_size(buf,lev+3,off+len,&leng,&res); |
680 | result->font_size = psiconv_read_size(buf,lev+3,off+len,&leng,&res); |
660 | if (res) |
681 | if (res) |
… | |
… | |
711 | goto ERROR1; |
732 | goto ERROR1; |
712 | psiconv_free_font(result->font); |
733 | psiconv_free_font(result->font); |
713 | result->font = temp_font; |
734 | result->font = temp_font; |
714 | len += leng; |
735 | len += leng; |
715 | break; |
736 | break; |
|
|
737 | case 0x23: |
|
|
738 | psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); |
|
|
739 | len ++; |
|
|
740 | break; |
716 | case 0x24: |
741 | case 0x24: |
717 | psiconv_progress(lev+3,off+len, |
742 | psiconv_progress(lev+3,off+len, |
718 | "Going to read unknown code 0x24 (%02x expected)", 0); |
743 | "Going to read unknown code 0x24 (%02x expected)", 0); |
719 | temp = psiconv_read_u8(buf,lev+3,off+len,&res); |
744 | temp = psiconv_read_u8(buf,lev+3,off+len,&res); |
720 | if (res) |
745 | if (res) |