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