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

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

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

Revision 109 Revision 110
286 {psiconv_formula_unknown,0,"*UNKNOWN*"}, 286 {psiconv_formula_unknown,0,"*UNKNOWN*"},
287 {psiconv_formula_unknown,0,"*UNKNOWN*"}, 287 {psiconv_formula_unknown,0,"*UNKNOWN*"},
288 {psiconv_formula_unknown,0,"*UNKNOWN*"}, 288 {psiconv_formula_unknown,0,"*UNKNOWN*"},
289 {psiconv_formula_unknown,0,"*UNKNOWN*"}}; 289 {psiconv_formula_unknown,0,"*UNKNOWN*"}};
290 290
291static psiconv_string_t psiconv_read_sheet_string(const psiconv_buffer buf,
292 int lev,
293 psiconv_u32 off,int *length, int *status)
294{
295 int stringlen,i,len,localstatus;
296 psiconv_string_t result;
297 char *res_copy;
298
299 psiconv_progress(lev+1,off,"Going to read a sheet string");
300
301 stringlen = psiconv_read_u8(buf,lev+2,off,&localstatus);
302 if (localstatus)
303 goto ERROR1;
304 psiconv_debug(lev+2,off,"Length: %i",stringlen);
305 len = 1;
306
307 result = malloc(stringlen + 1);
308 if (!result)
309 goto ERROR1;
310 for (i = 0; (i < stringlen) && !localstatus; i++)
311 result[i] = psiconv_read_u8(buf,lev,off+i+len,&localstatus);
312 if (localstatus)
313 goto ERROR2;
314 result[stringlen] = 0;
315 len += stringlen;
316
317 res_copy = psiconv_make_printable(result);
318 if (!res_copy)
319 goto ERROR2;
320 psiconv_debug(lev+2,off,"Contents: `%s'",res_copy);
321 free(res_copy);
322
323 if (length)
324 *length = len;
325
326 if (status)
327 *status = 0;
328
329 psiconv_progress(lev+1,off+len-1,"End of sheet string (total length: %08x)",
330 len);
331
332 return result;
333
334
335ERROR2:
336 free(result);
337ERROR1:
338 psiconv_warn(lev+1,off,"Reading of sheet string failed");
339 if (status)
340 *status = localstatus;
341 if (length)
342 *length = 0;
343 return NULL;
344}
345
346
347static int psiconv_parse_sheet_ref(const psiconv_buffer buf,int lev, 291static int psiconv_parse_sheet_ref(const psiconv_buffer buf,int lev,
348 psiconv_u32 off, int *length, 292 psiconv_u32 off, int *length,
349 psiconv_sheet_ref_t *result) 293 psiconv_sheet_ref_t *result)
350{ 294{
351 int res; 295 int res;
546 formula->type = psiconv_formula_unknown; 490 formula->type = psiconv_formula_unknown;
547 } else if (formula_elements[marker].formula_type == 491 } else if (formula_elements[marker].formula_type ==
548 psiconv_formula_dat_string) { 492 psiconv_formula_dat_string) {
549 psiconv_progress(lev+3,off+len,"Next item: a string"); 493 psiconv_progress(lev+3,off+len,"Next item: a string");
550 formula->data.dat_string = 494 formula->data.dat_string =
551 psiconv_read_sheet_string(buf,lev+2,off+len,&leng,&res); 495 psiconv_read_short_string(buf,lev+2,off+len,&leng,&res);
552 if (res) 496 if (res)
553 goto ERROR8; 497 goto ERROR8;
554 formula->type = formula_elements[marker].formula_type; 498 formula->type = formula_elements[marker].formula_type;
555 len += leng; 499 len += leng;
556 if ((res = psiconv_list_add(formula_stack,formula))) 500 if ((res = psiconv_list_add(formula_stack,formula)))

Legend:
Removed from v.109  
changed lines
  Added in v.110

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