/[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 65 Revision 84
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
27int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off, 29int 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;
145 else if (temp == 0x02) 147 else if (temp == 0x02)
146 (*result)->kind = psiconv_border_double; 148 (*result)->kind = psiconv_border_double;
147 else if (temp == 0x03) 149 else if (temp == 0x03)
148 (*result)->kind = psiconv_border_dotted; 150 (*result)->kind = psiconv_border_dotted;
149 else if (temp == 0x04) 151 else if (temp == 0x04)
150 (*result)->kind = psiconv_border_striped; 152 (*result)->kind = psiconv_border_dashed;
151 else if (temp == 0x05) 153 else if (temp == 0x05)
152 (*result)->kind = psiconv_border_dotstripe; 154 (*result)->kind = psiconv_border_dotdashed;
153 else if (temp == 0x06) 155 else if (temp == 0x06)
154 (*result)->kind = psiconv_border_dotdotstripe; 156 (*result)->kind = psiconv_border_dotdotdashed;
155 else { 157 else {
156 psiconv_warn(lev+2,off,"Unknown border kind (defaults to `none')"); 158 psiconv_warn(lev+2,off,"Unknown border kind (defaults to `none')");
157 (*result)->kind = psiconv_border_none; 159 (*result)->kind = psiconv_border_none;
158 } 160 }
159 psiconv_debug(lev+2,off+len,"Kind: %02x",temp); 161 psiconv_debug(lev+2,off+len,"Kind: %02x",temp);
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;
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 ++;
449 case 0x07: 454 case 0x07:
450 psiconv_progress(lev+3,off+len,"Going to read interline distance"); 455 psiconv_progress(lev+3,off+len,"Going to read linespacing distance");
451 result->interline = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 456 result->linespacing = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
452 if (res) 457 if (res)
453 goto ERROR1; 458 goto ERROR1;
454 len += leng; 459 len += leng;
455 break; 460 break;
456 case 0x08: 461 case 0x08:
457 psiconv_progress(lev+3,off+len,"Going to read interline exact"); 462 psiconv_progress(lev+3,off+len,"Going to read linespacing exact");
458 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 463 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
459 &result->interline_exact))) 464 &result->linespacing_exact)))
460 goto ERROR1; 465 goto ERROR1;
461 len += leng; 466 len += leng;
462 break; 467 break;
463 case 0x09: 468 case 0x09:
464 psiconv_progress(lev+3,off+len,"Going to read top space"); 469 psiconv_progress(lev+3,off+len,"Going to read top space");
465 result->top_space = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 470 result->space_above = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
466 if (res) 471 if (res)
467 goto ERROR1; 472 goto ERROR1;
468 len += leng; 473 len += leng;
469 break; 474 break;
470 case 0x0a: 475 case 0x0a:
471 psiconv_progress(lev+3,off+len,"Going to read bottom space"); 476 psiconv_progress(lev+3,off+len,"Going to read bottom space");
472 result->bottom_space = psiconv_read_size(buf,lev+3,off+len,&leng,&res); 477 result->space_below = psiconv_read_size(buf,lev+3,off+len,&leng,&res);
473 if (res) 478 if (res)
474 goto ERROR1; 479 goto ERROR1;
475 len += leng; 480 len += leng;
476 break; 481 break;
477 case 0x0b: 482 case 0x0b:
478 psiconv_progress(lev+3,off+len,"Going to read on one page"); 483 psiconv_progress(lev+3,off+len,"Going to read on one page");
479 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 484 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
480 &result->on_one_page))) 485 &result->keep_together)))
481 goto ERROR1; 486 goto ERROR1;
482 len += leng; 487 len += leng;
483 break; 488 break;
484 case 0x0c: 489 case 0x0c:
485 psiconv_progress(lev+3,off+len,"Going to read together with"); 490 psiconv_progress(lev+3,off+len,"Going to read together with");
486 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 491 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
487 &result->together_with))) 492 &result->keep_with_next)))
488 goto ERROR1; 493 goto ERROR1;
489 len += leng; 494 len += leng;
490 break; 495 break;
491 case 0x0d: 496 case 0x0d:
492 psiconv_progress(lev+3,off+len,"Going to read on next page"); 497 psiconv_progress(lev+3,off+len,"Going to read on next page");
697 &result->underline))) 702 &result->underline)))
698 goto ERROR1; 703 goto ERROR1;
699 len += leng; 704 len += leng;
700 break; 705 break;
701 case 0x21: 706 case 0x21:
702 psiconv_progress(lev+3,off+len,"Going to read strike_out"); 707 psiconv_progress(lev+3,off+len,"Going to read strikethrough");
703 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 708 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng,
704 &result->strike_out))) 709 &result->strikethrough)))
705 goto ERROR1; 710 goto ERROR1;
706 len += leng; 711 len += leng;
707 break; 712 break;
708 case 0x22: 713 case 0x22:
709 psiconv_progress(lev+3,off+len,"Going to read font"); 714 psiconv_progress(lev+3,off+len,"Going to read font");

Legend:
Removed from v.65  
changed lines
  Added in v.84

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