… | |
… | |
79 | ERROR1: |
79 | ERROR1: |
80 | return NULL; |
80 | return NULL; |
81 | } |
81 | } |
82 | |
82 | |
83 | static psiconv_sheet_cell_reference_t |
83 | static psiconv_sheet_cell_reference_t |
84 | psiconv_read_var_cellref (const psiconv_buffer buf, int lev, |
84 | psiconv_read_var_cellref (const psiconv_config config, |
|
|
85 | const psiconv_buffer buf, int lev, |
85 | psiconv_u32 off, int *length, |
86 | psiconv_u32 off, int *length, |
86 | int *status) |
87 | int *status) |
87 | { |
88 | { |
88 | int len=0; |
89 | int len=0; |
89 | int res; |
90 | int res; |
90 | psiconv_sheet_cell_reference_t result; |
91 | psiconv_sheet_cell_reference_t result; |
91 | psiconv_u32 temp; |
92 | psiconv_u32 temp; |
92 | |
93 | |
93 | psiconv_progress(lev+1,off+len,"Going to read a sheet cell reference"); |
94 | psiconv_progress(config,lev+1,off+len,"Going to read a sheet cell reference"); |
94 | psiconv_progress(lev+2,off+len, |
95 | psiconv_progress(config,lev+2,off+len, |
95 | "Going to read the initial byte (%02x expected)",0x00); |
96 | "Going to read the initial byte (%02x expected)",0x00); |
96 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
97 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
97 | if (res) |
98 | if (res) |
98 | goto ERROR1; |
99 | goto ERROR1; |
99 | if (temp != 0x00) { |
100 | if (temp != 0x00) { |
100 | psiconv_warn(lev+2,off+len, |
101 | psiconv_warn(config,lev+2,off+len, |
101 | "Sheet cell reference initial byte unknown value (ignored)"); |
102 | "Sheet cell reference initial byte unknown value (ignored)"); |
102 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
103 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
103 | } |
104 | } |
104 | len ++; |
105 | len ++; |
105 | |
106 | |
106 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
107 | temp = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
107 | if (res) |
108 | if (res) |
108 | goto ERROR1; |
109 | goto ERROR1; |
109 | if (temp & 0xffff0000) { |
110 | if (temp & 0xffff0000) { |
110 | psiconv_warn(lev+2,off+len, |
111 | psiconv_warn(config,lev+2,off+len, |
111 | "Sheet cell row reference to unknown row (reset)"); |
112 | "Sheet cell row reference to unknown row (reset)"); |
112 | } |
113 | } |
113 | result.row.offset = temp; |
114 | result.row.offset = temp; |
114 | result.row.absolute = psiconv_bool_true; |
115 | result.row.absolute = psiconv_bool_true; |
115 | len += 4; |
116 | len += 4; |
116 | |
117 | |
117 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
118 | temp = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
118 | if (res) |
119 | if (res) |
119 | goto ERROR1; |
120 | goto ERROR1; |
120 | if (temp & 0xffff0000) { |
121 | if (temp & 0xffff0000) { |
121 | psiconv_warn(lev+2,off+len, |
122 | psiconv_warn(config,lev+2,off+len, |
122 | "Sheet cell column reference to unknown row (reset)"); |
123 | "Sheet cell column reference to unknown row (reset)"); |
123 | } |
124 | } |
124 | result.column.offset = temp; |
125 | result.column.offset = temp; |
125 | result.column.absolute = psiconv_bool_true; |
126 | result.column.absolute = psiconv_bool_true; |
126 | len += 4; |
127 | len += 4; |
127 | |
128 | |
128 | if (length) |
129 | if (length) |
129 | *length = len; |
130 | *length = len; |
130 | |
131 | |
131 | psiconv_progress(lev,off+len-1, |
132 | psiconv_progress(config,lev,off+len-1, |
132 | "End of sheet column reference (total length: %08x)", len); |
133 | "End of sheet column reference (total length: %08x)", len); |
133 | return result; |
134 | return result; |
134 | ERROR1: |
135 | ERROR1: |
135 | psiconv_warn(lev+1,off,"Reading of Sheet Column Reference failed"); |
136 | psiconv_warn(config,lev+1,off,"Reading of Sheet Column Reference failed"); |
136 | if (length) |
137 | if (length) |
137 | *length = 0; |
138 | *length = 0; |
138 | if (status) |
139 | if (status) |
139 | *status = res?res:-PSICONV_E_NOMEM; |
140 | *status = res?res:-PSICONV_E_NOMEM; |
140 | return result; |
141 | return result; |
141 | } |
142 | } |
142 | |
143 | |
143 | static psiconv_sheet_cell_block_t |
144 | static psiconv_sheet_cell_block_t |
144 | psiconv_read_var_cellblock (const psiconv_buffer buf, int lev, |
145 | psiconv_read_var_cellblock (const psiconv_config config, |
|
|
146 | const psiconv_buffer buf, int lev, |
145 | psiconv_u32 off, int *length, |
147 | psiconv_u32 off, int *length, |
146 | int *status) |
148 | int *status) |
147 | { |
149 | { |
148 | int len=0; |
150 | int len=0; |
149 | int res; |
151 | int res; |
150 | psiconv_sheet_cell_block_t result; |
152 | psiconv_sheet_cell_block_t result; |
151 | psiconv_u32 temp; |
153 | psiconv_u32 temp; |
152 | |
154 | |
153 | psiconv_progress(lev+1,off+len,"Going to read a sheet cell block reference"); |
155 | psiconv_progress(config,lev+1,off+len,"Going to read a sheet cell block reference"); |
154 | psiconv_progress(lev+2,off+len, |
156 | psiconv_progress(config,lev+2,off+len, |
155 | "Going to read the initial byte (%02x expected)",0x00); |
157 | "Going to read the initial byte (%02x expected)",0x00); |
156 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
158 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
157 | if (res) |
159 | if (res) |
158 | goto ERROR1; |
160 | goto ERROR1; |
159 | if (temp != 0x00) { |
161 | if (temp != 0x00) { |
160 | psiconv_warn(lev+2,off+len, |
162 | psiconv_warn(config,lev+2,off+len, |
161 | "Sheet cell reference initial byte unknown value (ignored)"); |
163 | "Sheet cell reference initial byte unknown value (ignored)"); |
162 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
164 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
163 | } |
165 | } |
164 | len ++; |
166 | len ++; |
165 | |
167 | |
166 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
168 | temp = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
167 | if (res) |
169 | if (res) |
168 | goto ERROR1; |
170 | goto ERROR1; |
169 | if (temp & 0xffff0000) { |
171 | if (temp & 0xffff0000) { |
170 | psiconv_warn(lev+2,off+len, |
172 | psiconv_warn(config,lev+2,off+len, |
171 | "Sheet block initial row reference to unknown row (reset)"); |
173 | "Sheet block initial row reference to unknown row (reset)"); |
172 | } |
174 | } |
173 | result.first.row.offset = temp; |
175 | result.first.row.offset = temp; |
174 | result.first.row.absolute = psiconv_bool_true; |
176 | result.first.row.absolute = psiconv_bool_true; |
175 | len += 4; |
177 | len += 4; |
176 | |
178 | |
177 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
179 | temp = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
178 | if (res) |
180 | if (res) |
179 | goto ERROR1; |
181 | goto ERROR1; |
180 | if (temp & 0xffff0000) { |
182 | if (temp & 0xffff0000) { |
181 | psiconv_warn(lev+2,off+len, |
183 | psiconv_warn(config,lev+2,off+len, |
182 | "Sheet block initial column reference to unknown row (reset)"); |
184 | "Sheet block initial column reference to unknown row (reset)"); |
183 | } |
185 | } |
184 | result.first.column.offset = temp; |
186 | result.first.column.offset = temp; |
185 | result.first.column.absolute = psiconv_bool_true; |
187 | result.first.column.absolute = psiconv_bool_true; |
186 | len += 4; |
188 | len += 4; |
187 | |
189 | |
188 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
190 | temp = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
189 | if (res) |
191 | if (res) |
190 | goto ERROR1; |
192 | goto ERROR1; |
191 | if (temp & 0xffff0000) { |
193 | if (temp & 0xffff0000) { |
192 | psiconv_warn(lev+2,off+len, |
194 | psiconv_warn(config,lev+2,off+len, |
193 | "Sheet block final row reference to unknown row (reset)"); |
195 | "Sheet block final row reference to unknown row (reset)"); |
194 | } |
196 | } |
195 | result.last.row.offset = temp; |
197 | result.last.row.offset = temp; |
196 | result.last.row.absolute = psiconv_bool_true; |
198 | result.last.row.absolute = psiconv_bool_true; |
197 | len += 4; |
199 | len += 4; |
198 | |
200 | |
199 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
201 | temp = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
200 | if (res) |
202 | if (res) |
201 | goto ERROR1; |
203 | goto ERROR1; |
202 | if (temp & 0xffff0000) { |
204 | if (temp & 0xffff0000) { |
203 | psiconv_warn(lev+2,off+len, |
205 | psiconv_warn(config,lev+2,off+len, |
204 | "Sheet block final column reference to unknown row (reset)"); |
206 | "Sheet block final column reference to unknown row (reset)"); |
205 | } |
207 | } |
206 | result.last.column.offset = temp; |
208 | result.last.column.offset = temp; |
207 | result.last.column.absolute = psiconv_bool_true; |
209 | result.last.column.absolute = psiconv_bool_true; |
208 | len += 4; |
210 | len += 4; |
209 | |
211 | |
210 | if (length) |
212 | if (length) |
211 | *length = len; |
213 | *length = len; |
212 | |
214 | |
213 | psiconv_progress(lev,off+len-1, |
215 | psiconv_progress(config,lev,off+len-1, |
214 | "End of sheet cell block reference (total length: %08x)", |
216 | "End of sheet cell block reference (total length: %08x)", |
215 | len); |
217 | len); |
216 | return result; |
218 | return result; |
217 | ERROR1: |
219 | ERROR1: |
218 | psiconv_warn(lev+1,off,"Reading of Sheet Cell Block Reference failed"); |
220 | psiconv_warn(config,lev+1,off,"Reading of Sheet Cell Block Reference failed"); |
219 | if (length) |
221 | if (length) |
220 | *length = 0; |
222 | *length = 0; |
221 | if (status) |
223 | if (status) |
222 | *status = res?res:-PSICONV_E_NOMEM; |
224 | *status = res?res:-PSICONV_E_NOMEM; |
223 | return result; |
225 | return result; |
224 | } |
226 | } |
225 | |
227 | |
226 | int psiconv_parse_sheet_numberformat(const psiconv_buffer buf, int lev, |
228 | int psiconv_parse_sheet_numberformat(const psiconv_config config, |
|
|
229 | const psiconv_buffer buf, int lev, |
227 | psiconv_u32 off, int *length, |
230 | psiconv_u32 off, int *length, |
228 | psiconv_sheet_numberformat result) |
231 | psiconv_sheet_numberformat result) |
229 | { |
232 | { |
230 | int res=0; |
233 | int res=0; |
231 | int len=0; |
234 | int len=0; |
232 | psiconv_u8 temp; |
235 | psiconv_u8 temp; |
233 | |
236 | |
234 | psiconv_progress(lev+1,off,"Going to read a sheet numberformat"); |
237 | psiconv_progress(config,lev+1,off,"Going to read a sheet numberformat"); |
235 | |
238 | |
236 | psiconv_progress(lev+2,off+len, |
239 | psiconv_progress(config,lev+2,off+len, |
237 | "Going to read the initial byte (%02x expected)",0x02); |
240 | "Going to read the initial byte (%02x expected)",0x02); |
238 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
241 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
239 | if (res) |
242 | if (res) |
240 | goto ERROR1; |
243 | goto ERROR1; |
241 | if (temp != 0x02) { |
244 | if (temp != 0x02) { |
242 | psiconv_warn(lev+2,off+len, |
245 | psiconv_warn(config,lev+2,off+len, |
243 | "Sheet numberformat initial byte unknown value (ignored)"); |
246 | "Sheet numberformat initial byte unknown value (ignored)"); |
244 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
247 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
245 | } |
248 | } |
246 | len ++; |
249 | len ++; |
247 | |
250 | |
248 | psiconv_progress(lev+2,off+len, "Going to read the code byte"); |
251 | psiconv_progress(config,lev+2,off+len, "Going to read the code byte"); |
249 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
252 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
250 | if (res) |
253 | if (res) |
251 | goto ERROR1; |
254 | goto ERROR1; |
252 | psiconv_debug(lev+2,off+len,"Code: %02x",temp); |
255 | psiconv_debug(config,lev+2,off+len,"Code: %02x",temp); |
253 | if (temp == 0x00) |
256 | if (temp == 0x00) |
254 | result->code = psiconv_numberformat_general; |
257 | result->code = psiconv_numberformat_general; |
255 | else if (temp == 0x02) |
258 | else if (temp == 0x02) |
256 | result->code = psiconv_numberformat_fixeddecimal; |
259 | result->code = psiconv_numberformat_fixeddecimal; |
257 | else if (temp == 0x04) |
260 | else if (temp == 0x04) |
… | |
… | |
311 | else if (temp == 0x3A) |
314 | else if (temp == 0x3A) |
312 | result->code = psiconv_numberformat_time_HHii; |
315 | result->code = psiconv_numberformat_time_HHii; |
313 | else if (temp == 0x3C) |
316 | else if (temp == 0x3C) |
314 | result->code = psiconv_numberformat_time_HHiiss; |
317 | result->code = psiconv_numberformat_time_HHiiss; |
315 | else { |
318 | else { |
316 | psiconv_warn(lev+2,off+len,"Unknown number format (assumed general)"); |
319 | psiconv_warn(config,lev+2,off+len,"Unknown number format (assumed general)"); |
317 | result->code = psiconv_numberformat_general; |
320 | result->code = psiconv_numberformat_general; |
318 | } |
321 | } |
319 | len ++; |
322 | len ++; |
320 | |
323 | |
321 | psiconv_progress(lev+2,off+len, "Going to read the number of decimals"); |
324 | psiconv_progress(config,lev+2,off+len, "Going to read the number of decimals"); |
322 | result->decimal = psiconv_read_u8(buf,lev+2,off+len,&res) >> 1; |
325 | result->decimal = psiconv_read_u8(config,buf,lev+2,off+len,&res) >> 1; |
323 | if (res) |
326 | if (res) |
324 | goto ERROR1; |
327 | goto ERROR1; |
325 | psiconv_debug(lev+2,off+len,"Decimals: %d",result->decimal); |
328 | psiconv_debug(config,lev+2,off+len,"Decimals: %d",result->decimal); |
326 | len ++; |
329 | len ++; |
327 | |
330 | |
328 | if (length) |
331 | if (length) |
329 | *length = len; |
332 | *length = len; |
330 | |
333 | |
331 | psiconv_progress(lev,off+len-1, |
334 | psiconv_progress(config,lev,off+len-1, |
332 | "End of sheet number format (total length: %08x)", len); |
335 | "End of sheet number format (total length: %08x)", len); |
333 | return 0; |
336 | return 0; |
334 | |
337 | |
335 | ERROR1: |
338 | ERROR1: |
336 | psiconv_warn(lev+1,off,"Reading of Sheet Number Format failed"); |
339 | psiconv_warn(config,lev+1,off,"Reading of Sheet Number Format failed"); |
337 | if (length) |
340 | if (length) |
338 | *length = 0; |
341 | *length = 0; |
339 | if (!res) |
342 | if (!res) |
340 | return -PSICONV_E_NOMEM; |
343 | return -PSICONV_E_NOMEM; |
341 | else |
344 | else |
342 | return res; |
345 | return res; |
343 | } |
346 | } |
344 | |
347 | |
345 | int psiconv_parse_sheet_status_section(const psiconv_buffer buf, int lev, |
348 | int psiconv_parse_sheet_status_section(const psiconv_config config, |
|
|
349 | const psiconv_buffer buf, int lev, |
346 | psiconv_u32 off, int *length, |
350 | psiconv_u32 off, int *length, |
347 | psiconv_sheet_status_section *result) |
351 | psiconv_sheet_status_section *result) |
348 | { |
352 | { |
349 | int res=0; |
353 | int res=0; |
350 | int len=0; |
354 | int len=0; |
351 | psiconv_u32 temp; |
355 | psiconv_u32 temp; |
352 | int leng; |
356 | int leng; |
353 | |
357 | |
354 | psiconv_progress(lev+1,off,"Going to read the sheet status section"); |
358 | psiconv_progress(config,lev+1,off,"Going to read the sheet status section"); |
355 | if (!(*result = malloc(sizeof(**result)))) |
359 | if (!(*result = malloc(sizeof(**result)))) |
356 | goto ERROR1; |
360 | goto ERROR1; |
357 | |
361 | |
358 | psiconv_progress(lev+2,off+len, |
362 | psiconv_progress(config,lev+2,off+len, |
359 | "Going to read the initial byte (%02x expected)",0x02); |
363 | "Going to read the initial byte (%02x expected)",0x02); |
360 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
364 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
361 | if (res) |
365 | if (res) |
362 | goto ERROR2; |
366 | goto ERROR2; |
363 | if (temp != 0x02) { |
367 | if (temp != 0x02) { |
364 | psiconv_warn(lev+2,off+len, |
368 | psiconv_warn(config,lev+2,off+len, |
365 | "Sheet status section initial byte unknown value (ignored)"); |
369 | "Sheet status section initial byte unknown value (ignored)"); |
366 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
370 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
367 | } |
371 | } |
368 | len ++; |
372 | len ++; |
369 | |
373 | |
370 | psiconv_progress(lev+2,off+len, |
374 | psiconv_progress(config,lev+2,off+len, |
371 | "Going to read the cursor row"); |
375 | "Going to read the cursor row"); |
372 | (*result)->cursor_row = psiconv_read_u32(buf,lev+2,off + len,&res); |
376 | (*result)->cursor_row = psiconv_read_u32(config,buf,lev+2,off + len,&res); |
373 | if (res) |
377 | if (res) |
374 | goto ERROR2; |
378 | goto ERROR2; |
375 | psiconv_debug(lev+2,off+len,"Cursor row: %08x", |
379 | psiconv_debug(config,lev+2,off+len,"Cursor row: %08x", |
376 | (*result)->cursor_row); |
380 | (*result)->cursor_row); |
377 | len += 0x04; |
381 | len += 0x04; |
378 | |
382 | |
379 | psiconv_progress(lev+2,off+len, |
383 | psiconv_progress(config,lev+2,off+len, |
380 | "Going to read the cursor column"); |
384 | "Going to read the cursor column"); |
381 | (*result)->cursor_column = psiconv_read_u32(buf,lev+2,off + len,&res); |
385 | (*result)->cursor_column = psiconv_read_u32(config,buf,lev+2,off + len,&res); |
382 | if (res) |
386 | if (res) |
383 | goto ERROR2; |
387 | goto ERROR2; |
384 | psiconv_debug(lev+2,off+len,"Cursor column: %08x", |
388 | psiconv_debug(config,lev+2,off+len,"Cursor column: %08x", |
385 | (*result)->cursor_column); |
389 | (*result)->cursor_column); |
386 | len += 0x04; |
390 | len += 0x04; |
387 | |
391 | |
388 | psiconv_progress(lev+2,off+len,"Going to read initially display graph"); |
392 | psiconv_progress(config,lev+2,off+len,"Going to read initially display graph"); |
389 | if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng, |
393 | if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng, |
390 | &(*result)->show_graph))) |
394 | &(*result)->show_graph))) |
391 | goto ERROR2; |
395 | goto ERROR2; |
392 | len += leng; |
396 | len += leng; |
393 | |
397 | |
394 | psiconv_progress(lev+2,off+len, |
398 | psiconv_progress(config,lev+2,off+len, |
395 | "Going to read the toolbar status byte"); |
399 | "Going to read the toolbar status byte"); |
396 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
400 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
397 | if (res) |
401 | if (res) |
398 | goto ERROR2; |
402 | goto ERROR2; |
399 | |
403 | |
400 | (*result)->show_side_sheet_toolbar = temp&0x01 ? psiconv_bool_true : |
404 | (*result)->show_side_sheet_toolbar = temp&0x01 ? psiconv_bool_true : |
401 | psiconv_bool_false; |
405 | psiconv_bool_false; |
402 | psiconv_debug(lev+2,off+len,"Show side sheet toolbar: %02x", |
406 | psiconv_debug(config,lev+2,off+len,"Show side sheet toolbar: %02x", |
403 | (*result)->show_side_sheet_toolbar); |
407 | (*result)->show_side_sheet_toolbar); |
404 | (*result)->show_top_sheet_toolbar = temp&0x02 ? psiconv_bool_true : |
408 | (*result)->show_top_sheet_toolbar = temp&0x02 ? psiconv_bool_true : |
405 | psiconv_bool_false; |
409 | psiconv_bool_false; |
406 | psiconv_debug(lev+2,off+len,"Show top sheet toolbar: %02x", |
410 | psiconv_debug(config,lev+2,off+len,"Show top sheet toolbar: %02x", |
407 | (*result)->show_top_sheet_toolbar); |
411 | (*result)->show_top_sheet_toolbar); |
408 | (*result)->show_side_graph_toolbar = temp&0x04 ? psiconv_bool_true : |
412 | (*result)->show_side_graph_toolbar = temp&0x04 ? psiconv_bool_true : |
409 | psiconv_bool_false; |
413 | psiconv_bool_false; |
410 | psiconv_debug(lev+2,off+len,"Show side graph toolbar: %02x", |
414 | psiconv_debug(config,lev+2,off+len,"Show side graph toolbar: %02x", |
411 | (*result)->show_side_graph_toolbar); |
415 | (*result)->show_side_graph_toolbar); |
412 | (*result)->show_top_graph_toolbar = temp&0x08 ? psiconv_bool_true : |
416 | (*result)->show_top_graph_toolbar = temp&0x08 ? psiconv_bool_true : |
413 | psiconv_bool_false; |
417 | psiconv_bool_false; |
414 | psiconv_debug(lev+2,off+len,"Show top graph toolbar: %02x", |
418 | psiconv_debug(config,lev+2,off+len,"Show top graph toolbar: %02x", |
415 | (*result)->show_top_graph_toolbar); |
419 | (*result)->show_top_graph_toolbar); |
416 | if (temp & 0xf0) { |
420 | if (temp & 0xf0) { |
417 | psiconv_warn(lev+2,off+len,"Sheet status section toolbar byte " |
421 | psiconv_warn(config,lev+2,off+len,"Sheet status section toolbar byte " |
418 | "flags contains unknown flags (ignored)"); |
422 | "flags contains unknown flags (ignored)"); |
419 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp & 0xf0); |
423 | psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp & 0xf0); |
420 | } |
424 | } |
421 | len ++; |
425 | len ++; |
422 | |
426 | |
423 | psiconv_progress(lev+2,off+len, |
427 | psiconv_progress(config,lev+2,off+len, |
424 | "Going to read the scrollbar status byte"); |
428 | "Going to read the scrollbar status byte"); |
425 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
429 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
426 | if (res) |
430 | if (res) |
427 | goto ERROR2; |
431 | goto ERROR2; |
428 | if ((temp & 0x03) == 0x03) { |
432 | if ((temp & 0x03) == 0x03) { |
429 | psiconv_warn(lev+2,off+len,"Sheet status section scrollbar byte " |
433 | psiconv_warn(config,lev+2,off+len,"Sheet status section scrollbar byte " |
430 | "flags contains unknown flags (ignored)"); |
434 | "flags contains unknown flags (ignored)"); |
431 | psiconv_debug(lev+2,off+len,"Unknown flag: %02x",temp & 0x03); |
435 | psiconv_debug(config,lev+2,off+len,"Unknown flag: %02x",temp & 0x03); |
432 | } |
436 | } |
433 | (*result)->show_horizontal_scrollbar = (temp&0x03) == 1? psiconv_triple_off : |
437 | (*result)->show_horizontal_scrollbar = (temp&0x03) == 1? psiconv_triple_off : |
434 | (temp&0x03) == 2? psiconv_triple_auto: |
438 | (temp&0x03) == 2? psiconv_triple_auto: |
435 | psiconv_triple_on; |
439 | psiconv_triple_on; |
436 | psiconv_debug(lev+2,off+len,"Show horizontal scrollbar: %02x", |
440 | psiconv_debug(config,lev+2,off+len,"Show horizontal scrollbar: %02x", |
437 | (*result)->show_horizontal_scrollbar); |
441 | (*result)->show_horizontal_scrollbar); |
438 | if ((temp & 0x0c) == 0x0c) { |
442 | if ((temp & 0x0c) == 0x0c) { |
439 | psiconv_warn(lev+2,off+len,"Sheet status section scrollbar byte " |
443 | psiconv_warn(config,lev+2,off+len,"Sheet status section scrollbar byte " |
440 | "flags contains unknown flags (ignored)"); |
444 | "flags contains unknown flags (ignored)"); |
441 | psiconv_debug(lev+2,off+len,"Unknown flag: %02x",temp & 0x0c); |
445 | psiconv_debug(config,lev+2,off+len,"Unknown flag: %02x",temp & 0x0c); |
442 | } |
446 | } |
443 | (*result)->show_vertical_scrollbar = (temp&0x0c) ==0x04? psiconv_triple_off: |
447 | (*result)->show_vertical_scrollbar = (temp&0x0c) ==0x04? psiconv_triple_off: |
444 | (temp&0x0c) ==0x08? psiconv_triple_auto: |
448 | (temp&0x0c) ==0x08? psiconv_triple_auto: |
445 | psiconv_triple_on; |
449 | psiconv_triple_on; |
446 | psiconv_debug(lev+2,off+len,"Show vertical scrollbar: %02x", |
450 | psiconv_debug(config,lev+2,off+len,"Show vertical scrollbar: %02x", |
447 | (*result)->show_vertical_scrollbar); |
451 | (*result)->show_vertical_scrollbar); |
448 | if (temp & 0xf0) { |
452 | if (temp & 0xf0) { |
449 | psiconv_warn(lev+2,off+len,"Sheet status section scrollbar byte " |
453 | psiconv_warn(config,lev+2,off+len,"Sheet status section scrollbar byte " |
450 | "flags contains unknown flags (ignored)"); |
454 | "flags contains unknown flags (ignored)"); |
451 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp & 0xf0); |
455 | psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp & 0xf0); |
452 | } |
456 | } |
453 | len ++; |
457 | len ++; |
454 | |
458 | |
455 | psiconv_progress(lev+2,off+len, |
459 | psiconv_progress(config,lev+2,off+len, |
456 | "Going to read an unknown byte (%02x expected)",0x00); |
460 | "Going to read an unknown byte (%02x expected)",0x00); |
457 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
461 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
458 | if (res) |
462 | if (res) |
459 | goto ERROR2; |
463 | goto ERROR2; |
460 | if (temp != 0x00) { |
464 | if (temp != 0x00) { |
461 | psiconv_warn(lev+2,off+len, |
465 | psiconv_warn(config,lev+2,off+len, |
462 | "Sheet status section unknown byte unknown value (ignored)"); |
466 | "Sheet status section unknown byte unknown value (ignored)"); |
463 | psiconv_debug(lev+2,off+len,"Unknown byte: %02x",temp); |
467 | psiconv_debug(config,lev+2,off+len,"Unknown byte: %02x",temp); |
464 | } |
468 | } |
465 | len ++; |
469 | len ++; |
466 | |
470 | |
467 | psiconv_progress(lev+2,off+len,"Going to read sheet display size"); |
471 | psiconv_progress(config,lev+2,off+len,"Going to read sheet display size"); |
468 | (*result)->sheet_display_size = psiconv_read_u32(buf,lev+2,off + len,&res); |
472 | (*result)->sheet_display_size = psiconv_read_u32(config,buf,lev+2,off + len,&res); |
469 | if (res) |
473 | if (res) |
470 | goto ERROR2; |
474 | goto ERROR2; |
471 | psiconv_debug(lev+2,off+len,"Sheet display size: %08x", |
475 | psiconv_debug(config,lev+2,off+len,"Sheet display size: %08x", |
472 | (*result)->sheet_display_size); |
476 | (*result)->sheet_display_size); |
473 | len += 0x04; |
477 | len += 0x04; |
474 | |
478 | |
475 | psiconv_progress(lev+2,off+len,"Going to read graph display size"); |
479 | psiconv_progress(config,lev+2,off+len,"Going to read graph display size"); |
476 | (*result)->graph_display_size = psiconv_read_u32(buf,lev+2,off + len,&res); |
480 | (*result)->graph_display_size = psiconv_read_u32(config,buf,lev+2,off + len,&res); |
477 | if (res) |
481 | if (res) |
478 | goto ERROR2; |
482 | goto ERROR2; |
479 | psiconv_debug(lev+2,off+len,"Graph display size: %08x", |
483 | psiconv_debug(config,lev+2,off+len,"Graph display size: %08x", |
480 | (*result)->graph_display_size); |
484 | (*result)->graph_display_size); |
481 | len += 0x04; |
485 | len += 0x04; |
482 | |
486 | |
483 | if (length) |
487 | if (length) |
484 | *length = len; |
488 | *length = len; |
485 | |
489 | |
486 | psiconv_progress(lev,off+len-1, |
490 | psiconv_progress(config,lev,off+len-1, |
487 | "End of sheet status section (total length: %08x)", len); |
491 | "End of sheet status section (total length: %08x)", len); |
488 | return 0; |
492 | return 0; |
489 | |
493 | |
490 | ERROR2: |
494 | ERROR2: |
491 | free (*result); |
495 | free (*result); |
492 | ERROR1: |
496 | ERROR1: |
493 | psiconv_warn(lev+1,off,"Reading of Sheet Status Section failed"); |
497 | psiconv_warn(config,lev+1,off,"Reading of Sheet Status Section failed"); |
494 | if (length) |
498 | if (length) |
495 | *length = 0; |
499 | *length = 0; |
496 | if (!res) |
500 | if (!res) |
497 | return -PSICONV_E_NOMEM; |
501 | return -PSICONV_E_NOMEM; |
498 | else |
502 | else |
499 | return res; |
503 | return res; |
500 | } |
504 | } |
501 | |
505 | |
502 | int psiconv_parse_sheet_workbook_section(const psiconv_buffer buf, int lev, |
506 | int psiconv_parse_sheet_workbook_section(const psiconv_config config, |
|
|
507 | const psiconv_buffer buf, int lev, |
503 | psiconv_u32 off, int *length, |
508 | psiconv_u32 off, int *length, |
504 | psiconv_sheet_workbook_section *result) |
509 | psiconv_sheet_workbook_section *result) |
505 | { |
510 | { |
506 | int res=0,with_name; |
511 | int res=0,with_name; |
507 | psiconv_u32 temp,formulas_off,worksheets_off,info_off,var_off,name_off=0; |
512 | psiconv_u32 temp,formulas_off,worksheets_off,info_off,var_off,name_off=0; |
508 | int len=0; |
513 | int len=0; |
509 | |
514 | |
510 | psiconv_progress(lev+1,off,"Going to read the sheet workbook section"); |
515 | psiconv_progress(config,lev+1,off,"Going to read the sheet workbook section"); |
511 | if (!(*result = malloc(sizeof(**result)))) |
516 | if (!(*result = malloc(sizeof(**result)))) |
512 | goto ERROR1; |
517 | goto ERROR1; |
513 | |
518 | |
514 | psiconv_progress(lev+2,off+len, |
519 | psiconv_progress(config,lev+2,off+len, |
515 | "Going to read the initial byte (%02x or %02x expected)", |
520 | "Going to read the initial byte (%02x or %02x expected)", |
516 | 0x02,0x04); |
521 | 0x02,0x04); |
517 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
522 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
518 | if (res) |
523 | if (res) |
519 | goto ERROR2; |
524 | goto ERROR2; |
520 | if ((temp != 0x04) && temp !=0x02) { |
525 | if ((temp != 0x04) && temp !=0x02) { |
521 | psiconv_warn(lev+2,off+len, |
526 | psiconv_warn(config,lev+2,off+len, |
522 | "Sheet workbook section initial byte unknown value (ignored)"); |
527 | "Sheet workbook section initial byte unknown value (ignored)"); |
523 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
528 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
524 | } |
529 | } |
525 | with_name = temp ==0x04; |
530 | with_name = temp ==0x04; |
526 | len ++; |
531 | len ++; |
527 | |
532 | |
528 | psiconv_progress(lev+2,off+len, |
533 | psiconv_progress(config,lev+2,off+len, |
529 | "Going to read the offset of the sheet info Section"); |
534 | "Going to read the offset of the sheet info Section"); |
530 | info_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
535 | info_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
531 | if (res) |
536 | if (res) |
532 | goto ERROR2; |
537 | goto ERROR2; |
533 | psiconv_debug(lev+2,off+len,"Offset: %04x",info_off); |
538 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",info_off); |
534 | len += 4; |
539 | len += 4; |
535 | |
540 | |
536 | psiconv_progress(lev+2,off+len, |
541 | psiconv_progress(config,lev+2,off+len, |
537 | "Going to read the offset of the Formulas List"); |
542 | "Going to read the offset of the Formulas List"); |
538 | formulas_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
543 | formulas_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
539 | if (res) |
544 | if (res) |
540 | goto ERROR2; |
545 | goto ERROR2; |
541 | psiconv_debug(lev+2,off+len,"Offset: %04x",formulas_off); |
546 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",formulas_off); |
542 | len += 4; |
547 | len += 4; |
543 | |
548 | |
544 | psiconv_progress(lev+2,off+len, |
549 | psiconv_progress(config,lev+2,off+len, |
545 | "Going to read the offset of the Worksheet List"); |
550 | "Going to read the offset of the Worksheet List"); |
546 | worksheets_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
551 | worksheets_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
547 | if (res) |
552 | if (res) |
548 | goto ERROR2; |
553 | goto ERROR2; |
549 | psiconv_debug(lev+2,off+len,"Offset: %04x",worksheets_off); |
554 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",worksheets_off); |
550 | len += 4; |
555 | len += 4; |
551 | |
556 | |
552 | psiconv_progress(lev+2,off+len, |
557 | psiconv_progress(config,lev+2,off+len, |
553 | "Going to read the offset of the Variable List"); |
558 | "Going to read the offset of the Variable List"); |
554 | var_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
559 | var_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
555 | if (res) |
560 | if (res) |
556 | goto ERROR2; |
561 | goto ERROR2; |
557 | psiconv_debug(lev+2,off+len,"Offset: %04x",var_off); |
562 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",var_off); |
558 | len += 4; |
563 | len += 4; |
559 | |
564 | |
560 | if (with_name) { |
565 | if (with_name) { |
561 | psiconv_progress(lev+2,off+len, |
566 | psiconv_progress(config,lev+2,off+len, |
562 | "Going to read the offset of the Name Section"); |
567 | "Going to read the offset of the Name Section"); |
563 | name_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
568 | name_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
564 | if (res) |
569 | if (res) |
565 | goto ERROR2; |
570 | goto ERROR2; |
566 | psiconv_debug(lev+2,off+len,"Offset: %04x",name_off); |
571 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",name_off); |
567 | len += 4; |
572 | len += 4; |
568 | } |
573 | } |
569 | |
574 | |
570 | |
575 | |
571 | psiconv_progress(lev+2,off+len,"Going to read the info section"); |
576 | psiconv_progress(config,lev+2,off+len,"Going to read the info section"); |
572 | if ((res = psiconv_parse_sheet_info_section(buf,lev+2,info_off,NULL, |
577 | if ((res = psiconv_parse_sheet_info_section(config,buf,lev+2,info_off,NULL, |
573 | &(*result)->info))) |
578 | &(*result)->info))) |
574 | goto ERROR2; |
579 | goto ERROR2; |
575 | |
580 | |
576 | psiconv_progress(lev+2,off+len,"Going to read the variables list"); |
581 | psiconv_progress(config,lev+2,off+len,"Going to read the variables list"); |
577 | if ((res = psiconv_parse_sheet_variable_list(buf,lev+2,var_off,NULL, |
582 | if ((res = psiconv_parse_sheet_variable_list(config,buf,lev+2,var_off,NULL, |
578 | &(*result)->variables))) |
583 | &(*result)->variables))) |
579 | goto ERROR3; |
584 | goto ERROR3; |
580 | |
585 | |
581 | psiconv_progress(lev+2,off+len,"Going to read the formulas list"); |
586 | psiconv_progress(config,lev+2,off+len,"Going to read the formulas list"); |
582 | if ((res = psiconv_parse_sheet_formula_list(buf,lev+2,formulas_off,NULL, |
587 | if ((res = psiconv_parse_sheet_formula_list(config,buf,lev+2,formulas_off,NULL, |
583 | &(*result)->formulas))) |
588 | &(*result)->formulas))) |
584 | goto ERROR4; |
589 | goto ERROR4; |
585 | |
590 | |
586 | psiconv_progress(lev+2,off+len,"Going to read the worksheet list"); |
591 | psiconv_progress(config,lev+2,off+len,"Going to read the worksheet list"); |
587 | if ((res = psiconv_parse_sheet_worksheet_list(buf,lev+2,worksheets_off, |
592 | if ((res = psiconv_parse_sheet_worksheet_list(config,buf,lev+2,worksheets_off, |
588 | NULL,&(*result)->worksheets))) |
593 | NULL,&(*result)->worksheets))) |
589 | goto ERROR5; |
594 | goto ERROR5; |
590 | |
595 | |
591 | if (with_name) { |
596 | if (with_name) { |
592 | psiconv_progress(lev+2,off+len,"Going to read the name section"); |
597 | psiconv_progress(config,lev+2,off+len,"Going to read the name section"); |
593 | if ((res = psiconv_parse_sheet_name_section(buf,lev+2,name_off,NULL, |
598 | if ((res = psiconv_parse_sheet_name_section(config,buf,lev+2,name_off,NULL, |
594 | &(*result)->name))) |
599 | &(*result)->name))) |
595 | goto ERROR6; |
600 | goto ERROR6; |
596 | } else |
601 | } else |
597 | (*result)->name = NULL; |
602 | (*result)->name = NULL; |
598 | |
603 | |
599 | if (length) |
604 | if (length) |
600 | *length = len; |
605 | *length = len; |
601 | |
606 | |
602 | psiconv_progress(lev,off+len-1, |
607 | psiconv_progress(config,lev,off+len-1, |
603 | "End of sheet workbook section (total length: %08x)", len); |
608 | "End of sheet workbook section (total length: %08x)", len); |
604 | return 0; |
609 | return 0; |
605 | |
610 | |
606 | ERROR6: |
611 | ERROR6: |
607 | psiconv_free_sheet_worksheet_list((*result)->worksheets); |
612 | psiconv_free_sheet_worksheet_list((*result)->worksheets); |
… | |
… | |
612 | ERROR3: |
617 | ERROR3: |
613 | psiconv_free_sheet_info_section((*result)->info); |
618 | psiconv_free_sheet_info_section((*result)->info); |
614 | ERROR2: |
619 | ERROR2: |
615 | free (*result); |
620 | free (*result); |
616 | ERROR1: |
621 | ERROR1: |
617 | psiconv_warn(lev+1,off,"Reading of Sheet Workbook Section failed"); |
622 | psiconv_warn(config,lev+1,off,"Reading of Sheet Workbook Section failed"); |
618 | if (length) |
623 | if (length) |
619 | *length = 0; |
624 | *length = 0; |
620 | if (!res) |
625 | if (!res) |
621 | return -PSICONV_E_NOMEM; |
626 | return -PSICONV_E_NOMEM; |
622 | else |
627 | else |
623 | return res; |
628 | return res; |
624 | } |
629 | } |
625 | |
630 | |
626 | int psiconv_parse_sheet_name_section(const psiconv_buffer buf, int lev, |
631 | int psiconv_parse_sheet_name_section(const psiconv_config config, |
|
|
632 | const psiconv_buffer buf, int lev, |
627 | psiconv_u32 off, int *length, |
633 | psiconv_u32 off, int *length, |
628 | psiconv_sheet_name_section *result) |
634 | psiconv_sheet_name_section *result) |
629 | { |
635 | { |
630 | int res=0; |
636 | int res=0; |
631 | psiconv_u32 temp; |
637 | psiconv_u32 temp; |
632 | int len=0,leng; |
638 | int len=0,leng; |
633 | |
639 | |
634 | psiconv_progress(lev+1,off,"Going to read the sheet name section"); |
640 | psiconv_progress(config,lev+1,off,"Going to read the sheet name section"); |
635 | if (!(*result = malloc(sizeof(**result)))) |
641 | if (!(*result = malloc(sizeof(**result)))) |
636 | goto ERROR1; |
642 | goto ERROR1; |
637 | |
643 | |
638 | psiconv_progress(lev+2,off+len, |
644 | psiconv_progress(config,lev+2,off+len, |
639 | "Going to read the initial byte (%02x expected)",0x02); |
645 | "Going to read the initial byte (%02x expected)",0x02); |
640 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
646 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
641 | if (res) |
647 | if (res) |
642 | goto ERROR2; |
648 | goto ERROR2; |
643 | if (temp != 0x02) { |
649 | if (temp != 0x02) { |
644 | psiconv_warn(lev+2,off+len, |
650 | psiconv_warn(config,lev+2,off+len, |
645 | "Sheet name section initial byte unknown value (ignored)"); |
651 | "Sheet name section initial byte unknown value (ignored)"); |
646 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
652 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
647 | } |
653 | } |
648 | len ++; |
654 | len ++; |
649 | |
655 | |
650 | psiconv_progress(lev+2,off+len, "Going to read the sheet name"); |
656 | psiconv_progress(config,lev+2,off+len, "Going to read the sheet name"); |
651 | (*result)->name = psiconv_read_string(buf,lev+2,off+len,&leng,&res); |
657 | (*result)->name = psiconv_read_string(config,buf,lev+2,off+len,&leng,&res); |
652 | if (res) |
658 | if (res) |
653 | goto ERROR2; |
659 | goto ERROR2; |
654 | len += leng; |
660 | len += leng; |
655 | |
661 | |
656 | if (length) |
662 | if (length) |
657 | *length = len; |
663 | *length = len; |
658 | |
664 | |
659 | psiconv_progress(lev,off+len-1, |
665 | psiconv_progress(config,lev,off+len-1, |
660 | "End of sheet name section (total length: %08x)", len); |
666 | "End of sheet name section (total length: %08x)", len); |
661 | return 0; |
667 | return 0; |
662 | |
668 | |
663 | ERROR2: |
669 | ERROR2: |
664 | free(*result); |
670 | free(*result); |
665 | ERROR1: |
671 | ERROR1: |
666 | psiconv_warn(lev+1,off,"Reading of Sheet Name Section failed"); |
672 | psiconv_warn(config,lev+1,off,"Reading of Sheet Name Section failed"); |
667 | if (length) |
673 | if (length) |
668 | *length = 0; |
674 | *length = 0; |
669 | if (!res) |
675 | if (!res) |
670 | return -PSICONV_E_NOMEM; |
676 | return -PSICONV_E_NOMEM; |
671 | else |
677 | else |
672 | return res; |
678 | return res; |
673 | } |
679 | } |
674 | |
680 | |
675 | int psiconv_parse_sheet_info_section(const psiconv_buffer buf, int lev, |
681 | int psiconv_parse_sheet_info_section(const psiconv_config config, |
|
|
682 | const psiconv_buffer buf, int lev, |
676 | psiconv_u32 off, int *length, |
683 | psiconv_u32 off, int *length, |
677 | psiconv_sheet_info_section *result) |
684 | psiconv_sheet_info_section *result) |
678 | { |
685 | { |
679 | int res=0; |
686 | int res=0; |
680 | psiconv_u32 temp; |
687 | psiconv_u32 temp; |
681 | int len=0,leng; |
688 | int len=0,leng; |
682 | |
689 | |
683 | psiconv_progress(lev+1,off,"Going to read the sheet info section"); |
690 | psiconv_progress(config,lev+1,off,"Going to read the sheet info section"); |
684 | if (!(*result = malloc(sizeof(**result)))) |
691 | if (!(*result = malloc(sizeof(**result)))) |
685 | goto ERROR1; |
692 | goto ERROR1; |
686 | |
693 | |
687 | psiconv_progress(lev+2,off+len, |
694 | psiconv_progress(config,lev+2,off+len, |
688 | "Going to read the initial byte (%02x expected)",0x02); |
695 | "Going to read the initial byte (%02x expected)",0x02); |
689 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
696 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
690 | if (res) |
697 | if (res) |
691 | goto ERROR2; |
698 | goto ERROR2; |
692 | if (temp != 0x02) { |
699 | if (temp != 0x02) { |
693 | psiconv_warn(lev+2,off+len, |
700 | psiconv_warn(config,lev+2,off+len, |
694 | "Sheet info section initial byte unknown value (ignored)"); |
701 | "Sheet info section initial byte unknown value (ignored)"); |
695 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
702 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
696 | } |
703 | } |
697 | len ++; |
704 | len ++; |
698 | |
705 | |
699 | psiconv_progress(lev+2,off+len, "Going to read an unknown Xint"); |
706 | psiconv_progress(config,lev+2,off+len, "Going to read an unknown Xint"); |
700 | temp = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
707 | temp = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
701 | if (res) |
708 | if (res) |
702 | goto ERROR2; |
709 | goto ERROR2; |
703 | psiconv_debug(lev+2,off+len,"Value: %d\n",temp); |
710 | psiconv_debug(config,lev+2,off+len,"Value: %d\n",temp); |
704 | len += leng; |
711 | len += leng; |
705 | |
712 | |
706 | psiconv_progress(lev+2,off+len, "Going to read the flags byte"); |
713 | psiconv_progress(config,lev+2,off+len, "Going to read the flags byte"); |
707 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
714 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
708 | if (res) |
715 | if (res) |
709 | goto ERROR2; |
716 | goto ERROR2; |
710 | (*result)->auto_recalc = temp & 0x01 ? psiconv_bool_true:psiconv_bool_false; |
717 | (*result)->auto_recalc = temp & 0x01 ? psiconv_bool_true:psiconv_bool_false; |
711 | psiconv_debug(lev+2,off+len,"Auto recalculation: %02x", |
718 | psiconv_debug(config,lev+2,off+len,"Auto recalculation: %02x", |
712 | (*result)->auto_recalc); |
719 | (*result)->auto_recalc); |
713 | if ((temp & 0xfe) != 0x02) { |
720 | if ((temp & 0xfe) != 0x02) { |
714 | psiconv_warn(lev+2,off+len,"Sheet Info Section flags byte " |
721 | psiconv_warn(config,lev+2,off+len,"Sheet Info Section flags byte " |
715 | "contains unknown flags (ignored)"); |
722 | "contains unknown flags (ignored)"); |
716 | psiconv_debug(lev+2,off+len,"Unknown flags: %02x",temp &0xfe); |
723 | psiconv_debug(config,lev+2,off+len,"Unknown flags: %02x",temp &0xfe); |
717 | } |
724 | } |
718 | |
725 | |
719 | len ++; |
726 | len ++; |
720 | |
727 | |
721 | |
728 | |
722 | if (length) |
729 | if (length) |
723 | *length = len; |
730 | *length = len; |
724 | |
731 | |
725 | psiconv_progress(lev,off+len-1, |
732 | psiconv_progress(config,lev,off+len-1, |
726 | "End of sheet info section (total length: %08x)", len); |
733 | "End of sheet info section (total length: %08x)", len); |
727 | return 0; |
734 | return 0; |
728 | |
735 | |
729 | ERROR2: |
736 | ERROR2: |
730 | free(*result); |
737 | free(*result); |
731 | ERROR1: |
738 | ERROR1: |
732 | psiconv_warn(lev+1,off,"Reading of Sheet Name Section failed"); |
739 | psiconv_warn(config,lev+1,off,"Reading of Sheet Name Section failed"); |
733 | if (length) |
740 | if (length) |
734 | *length = 0; |
741 | *length = 0; |
735 | if (!res) |
742 | if (!res) |
736 | return -PSICONV_E_NOMEM; |
743 | return -PSICONV_E_NOMEM; |
737 | else |
744 | else |
738 | return res; |
745 | return res; |
739 | } |
746 | } |
740 | |
747 | |
741 | int psiconv_parse_sheet_formula_list(const psiconv_buffer buf, int lev, |
748 | int psiconv_parse_sheet_formula_list(const psiconv_config config, |
|
|
749 | const psiconv_buffer buf, int lev, |
742 | psiconv_u32 off, int *length, |
750 | psiconv_u32 off, int *length, |
743 | psiconv_formula_list *result) |
751 | psiconv_formula_list *result) |
744 | { |
752 | { |
745 | int res=0; |
753 | int res=0; |
746 | int len=0; |
754 | int len=0; |
747 | psiconv_u32 temp; |
755 | psiconv_u32 temp; |
748 | psiconv_formula formula; |
756 | psiconv_formula formula; |
749 | psiconv_u32 listlen,i; |
757 | psiconv_u32 listlen,i; |
750 | int leng; |
758 | int leng; |
751 | |
759 | |
752 | psiconv_progress(lev+1,off,"Going to read the sheet formula list"); |
760 | psiconv_progress(config,lev+1,off,"Going to read the sheet formula list"); |
753 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_formula_s)))) |
761 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_formula_s)))) |
754 | goto ERROR1; |
762 | goto ERROR1; |
755 | |
763 | |
756 | psiconv_progress(lev+2,off+len, |
764 | psiconv_progress(config,lev+2,off+len, |
757 | "Going to read the initial byte (%02x expected)",0x02); |
765 | "Going to read the initial byte (%02x expected)",0x02); |
758 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
766 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
759 | if (res) |
767 | if (res) |
760 | goto ERROR2; |
768 | goto ERROR2; |
761 | if (temp != 0x02) { |
769 | if (temp != 0x02) { |
762 | psiconv_warn(lev+2,off+len, |
770 | psiconv_warn(config,lev+2,off+len, |
763 | "Sheet formula list initial byte unknown value (ignored)"); |
771 | "Sheet formula list initial byte unknown value (ignored)"); |
764 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
772 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
765 | } |
773 | } |
766 | len ++; |
774 | len ++; |
767 | |
775 | |
768 | psiconv_progress(lev+2,off+len, |
776 | psiconv_progress(config,lev+2,off+len, |
769 | "Going to read the number of formulas"); |
777 | "Going to read the number of formulas"); |
770 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
778 | listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
771 | if (res) |
779 | if (res) |
772 | goto ERROR2; |
780 | goto ERROR2; |
773 | psiconv_debug(lev+2,off+len,"Number of formulas: %d",listlen); |
781 | psiconv_debug(config,lev+2,off+len,"Number of formulas: %d",listlen); |
774 | len += leng; |
782 | len += leng; |
775 | |
783 | |
776 | psiconv_progress(lev+2,off+len,"Going to read all formulas"); |
784 | psiconv_progress(config,lev+2,off+len,"Going to read all formulas"); |
777 | for (i = 0; i < listlen; i++) { |
785 | for (i = 0; i < listlen; i++) { |
778 | psiconv_progress(lev+3,off+len,"Going to read formula %d",i); |
786 | psiconv_progress(config,lev+3,off+len,"Going to read formula %d",i); |
779 | if ((res = psiconv_parse_formula(buf,lev+3,off+len,&leng,&formula))) |
787 | if ((res = psiconv_parse_formula(config,buf,lev+3,off+len,&leng,&formula))) |
780 | goto ERROR2; |
788 | goto ERROR2; |
781 | if ((res = psiconv_list_add(*result,formula))) |
789 | if ((res = psiconv_list_add(*result,formula))) |
782 | goto ERROR3; |
790 | goto ERROR3; |
783 | free(formula); |
791 | free(formula); |
784 | len += leng; |
792 | len += leng; |
785 | } |
793 | } |
786 | |
794 | |
787 | if (length) |
795 | if (length) |
788 | *length = len; |
796 | *length = len; |
789 | |
797 | |
790 | psiconv_progress(lev,off+len-1, |
798 | psiconv_progress(config,lev,off+len-1, |
791 | "End of sheet formula list (total length: %08x)", len); |
799 | "End of sheet formula list (total length: %08x)", len); |
792 | return 0; |
800 | return 0; |
793 | |
801 | |
794 | ERROR3: |
802 | ERROR3: |
795 | psiconv_free_formula(formula); |
803 | psiconv_free_formula(formula); |
796 | ERROR2: |
804 | ERROR2: |
797 | psiconv_list_free(*result); |
805 | psiconv_list_free(*result); |
798 | ERROR1: |
806 | ERROR1: |
799 | psiconv_warn(lev+1,off,"Reading of Sheet Formula list failed"); |
807 | psiconv_warn(config,lev+1,off,"Reading of Sheet Formula list failed"); |
800 | if (length) |
808 | if (length) |
801 | *length = 0; |
809 | *length = 0; |
802 | if (!res) |
810 | if (!res) |
803 | return -PSICONV_E_NOMEM; |
811 | return -PSICONV_E_NOMEM; |
804 | else |
812 | else |
805 | return res; |
813 | return res; |
806 | } |
814 | } |
807 | |
815 | |
808 | int psiconv_parse_sheet_cell(const psiconv_buffer buf, int lev, |
816 | int psiconv_parse_sheet_cell(const psiconv_config config, |
|
|
817 | const psiconv_buffer buf, int lev, |
809 | psiconv_u32 off, int *length, |
818 | psiconv_u32 off, int *length, |
810 | psiconv_sheet_cell *result, |
819 | psiconv_sheet_cell *result, |
811 | const psiconv_sheet_cell_layout default_layout, |
820 | const psiconv_sheet_cell_layout default_layout, |
812 | const psiconv_sheet_line_list row_default_layouts, |
821 | const psiconv_sheet_line_list row_default_layouts, |
813 | const psiconv_sheet_line_list col_default_layouts) |
822 | const psiconv_sheet_line_list col_default_layouts) |
… | |
… | |
816 | int len=0; |
825 | int len=0; |
817 | psiconv_u32 temp; |
826 | psiconv_u32 temp; |
818 | psiconv_bool_t has_layout; |
827 | psiconv_bool_t has_layout; |
819 | int leng; |
828 | int leng; |
820 | |
829 | |
821 | psiconv_progress(lev+1,off,"Going to read a sheet cell structure"); |
830 | psiconv_progress(config,lev+1,off,"Going to read a sheet cell structure"); |
822 | if (!(*result = malloc(sizeof(**result)))) |
831 | if (!(*result = malloc(sizeof(**result)))) |
823 | goto ERROR1; |
832 | goto ERROR1; |
824 | |
833 | |
825 | (*result)->layout = NULL; |
834 | (*result)->layout = NULL; |
826 | (*result)->type = psiconv_cell_blank; |
835 | (*result)->type = psiconv_cell_blank; |
827 | |
836 | |
828 | psiconv_progress(lev+2,off+len,"Going to read the cell position"); |
837 | psiconv_progress(config,lev+2,off+len,"Going to read the cell position"); |
829 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
838 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
830 | if (res) |
839 | if (res) |
831 | goto ERROR2; |
840 | goto ERROR2; |
832 | len ++; |
841 | len ++; |
833 | temp += psiconv_read_u8(buf,lev+2,off+len,&res) << 8; |
842 | temp += psiconv_read_u8(config,buf,lev+2,off+len,&res) << 8; |
834 | if (res) |
843 | if (res) |
835 | goto ERROR2; |
844 | goto ERROR2; |
836 | len ++; |
845 | len ++; |
837 | temp += psiconv_read_u8(buf,lev+2,off+len,&res) << 16; |
846 | temp += psiconv_read_u8(config,buf,lev+2,off+len,&res) << 16; |
838 | if (res) |
847 | if (res) |
839 | goto ERROR2; |
848 | goto ERROR2; |
840 | len ++; |
849 | len ++; |
841 | (*result)->column = (temp >> 2) & 0xFF; |
850 | (*result)->column = (temp >> 2) & 0xFF; |
842 | (*result)->row = (temp >> 10) & 0x3FFF; |
851 | (*result)->row = (temp >> 10) & 0x3FFF; |
843 | psiconv_debug(lev+2,off+len,"Cell position is col:%02x row:%04x", |
852 | psiconv_debug(config,lev+2,off+len,"Cell position is col:%02x row:%04x", |
844 | (*result)->column,(*result)->row); |
853 | (*result)->column,(*result)->row); |
845 | if (temp & 0x03) { |
854 | if (temp & 0x03) { |
846 | psiconv_warn(lev+2,off+len,"Unknown flags in cell position (ignored)"); |
855 | psiconv_warn(config,lev+2,off+len,"Unknown flags in cell position (ignored)"); |
847 | psiconv_debug(lev+2,off+len,"Flags: %02x",temp & 0x03); |
856 | psiconv_debug(config,lev+2,off+len,"Flags: %02x",temp & 0x03); |
848 | } |
857 | } |
849 | |
858 | |
850 | psiconv_progress(lev+2,off+len,"Going to read the cell type"); |
859 | psiconv_progress(config,lev+2,off+len,"Going to read the cell type"); |
851 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
860 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
852 | if (res) |
861 | if (res) |
853 | goto ERROR2; |
862 | goto ERROR2; |
854 | len ++; |
863 | len ++; |
855 | (*result)->type = (temp >> 5) & 0x07; |
864 | (*result)->type = (temp >> 5) & 0x07; |
856 | (*result)->calculated = (temp & 0x08)?psiconv_bool_true:psiconv_bool_false; |
865 | (*result)->calculated = (temp & 0x08)?psiconv_bool_true:psiconv_bool_false; |
857 | has_layout = (temp & 0x10)?psiconv_bool_true:psiconv_bool_false; |
866 | has_layout = (temp & 0x10)?psiconv_bool_true:psiconv_bool_false; |
858 | |
867 | |
859 | psiconv_progress(lev+2,off+len,"Going to read the cell value"); |
868 | psiconv_progress(config,lev+2,off+len,"Going to read the cell value"); |
860 | if ((*result)->type == psiconv_cell_blank) { |
869 | if ((*result)->type == psiconv_cell_blank) { |
861 | psiconv_debug(lev+2,off+len,"Cell type is blank: no value given."); |
870 | psiconv_debug(config,lev+2,off+len,"Cell type is blank: no value given."); |
862 | } else if ((*result)->type == psiconv_cell_int) { |
871 | } else if ((*result)->type == psiconv_cell_int) { |
863 | psiconv_progress(lev+2,off+len,"Going to read an integer"); |
872 | psiconv_progress(config,lev+2,off+len,"Going to read an integer"); |
864 | (*result)->data.dat_int = psiconv_read_u32(buf,lev+2,off+len,&res); |
873 | (*result)->data.dat_int = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
865 | if (res) |
874 | if (res) |
866 | goto ERROR2; |
875 | goto ERROR2; |
867 | len += 4; |
876 | len += 4; |
868 | psiconv_debug(lev+2,off+len,"Cell contents: %ld",(*result)->data.dat_int); |
877 | psiconv_debug(config,lev+2,off+len,"Cell contents: %ld",(*result)->data.dat_int); |
869 | |
878 | |
870 | } else if ((*result)->type == psiconv_cell_bool) { |
879 | } else if ((*result)->type == psiconv_cell_bool) { |
871 | psiconv_progress(lev+2,off+len,"Going to read a boolean"); |
880 | psiconv_progress(config,lev+2,off+len,"Going to read a boolean"); |
872 | if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng, |
881 | if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng, |
873 | &(*result)->data.dat_bool))) |
882 | &(*result)->data.dat_bool))) |
874 | goto ERROR2; |
883 | goto ERROR2; |
875 | psiconv_debug(lev+2,off+len,"Cell contents: %01x",temp); |
884 | psiconv_debug(config,lev+2,off+len,"Cell contents: %01x",temp); |
876 | (*result)->data.dat_bool = temp?psiconv_bool_true:psiconv_bool_false; |
885 | (*result)->data.dat_bool = temp?psiconv_bool_true:psiconv_bool_false; |
877 | len += leng; |
886 | len += leng; |
878 | } else if ((*result)->type == psiconv_cell_error) { |
887 | } else if ((*result)->type == psiconv_cell_error) { |
879 | psiconv_progress(lev+2,off+len,"Going to read the error code"); |
888 | psiconv_progress(config,lev+2,off+len,"Going to read the error code"); |
880 | temp = psiconv_read_u16(buf,lev+2,off+len,&res); |
889 | temp = psiconv_read_u16(config,buf,lev+2,off+len,&res); |
881 | if (res) |
890 | if (res) |
882 | goto ERROR2; |
891 | goto ERROR2; |
883 | if (temp == 0) |
892 | if (temp == 0) |
884 | (*result)->data.dat_error = psiconv_sheet_error_none; |
893 | (*result)->data.dat_error = psiconv_sheet_error_none; |
885 | else if (temp == 1) |
894 | else if (temp == 1) |
… | |
… | |
895 | else if (temp == 6) |
904 | else if (temp == 6) |
896 | (*result)->data.dat_error = psiconv_sheet_error_number; |
905 | (*result)->data.dat_error = psiconv_sheet_error_number; |
897 | else if (temp == 7) |
906 | else if (temp == 7) |
898 | (*result)->data.dat_error = psiconv_sheet_error_notavail; |
907 | (*result)->data.dat_error = psiconv_sheet_error_notavail; |
899 | else { |
908 | else { |
900 | psiconv_warn(lev+2,off+len,"Unknown error code (default assumed)"); |
909 | psiconv_warn(config,lev+2,off+len,"Unknown error code (default assumed)"); |
901 | psiconv_debug(lev+2,off+len,"Error code: %04x",temp); |
910 | psiconv_debug(config,lev+2,off+len,"Error code: %04x",temp); |
902 | (*result)->data.dat_error = psiconv_sheet_error_none; |
911 | (*result)->data.dat_error = psiconv_sheet_error_none; |
903 | } |
912 | } |
904 | psiconv_debug(lev+2,off+len,"Cell contents: %04x", |
913 | psiconv_debug(config,lev+2,off+len,"Cell contents: %04x", |
905 | (*result)->data.dat_error); |
914 | (*result)->data.dat_error); |
906 | len += 2; |
915 | len += 2; |
907 | } else if ((*result)->type == psiconv_cell_float) { |
916 | } else if ((*result)->type == psiconv_cell_float) { |
908 | psiconv_progress(lev+2,off+len,"Going to read a float"); |
917 | psiconv_progress(config,lev+2,off+len,"Going to read a float"); |
909 | (*result)->data.dat_float = |
918 | (*result)->data.dat_float = |
910 | psiconv_read_float(buf,lev+2,off+len,&leng,&res); |
919 | psiconv_read_float(config,buf,lev+2,off+len,&leng,&res); |
911 | if (res) |
920 | if (res) |
912 | goto ERROR2; |
921 | goto ERROR2; |
913 | psiconv_debug(lev+2,off+len,"Cell contents: %f",(*result)->data.dat_float); |
922 | psiconv_debug(config,lev+2,off+len,"Cell contents: %f",(*result)->data.dat_float); |
914 | len += leng; |
923 | len += leng; |
915 | } else if ((*result)->type == psiconv_cell_string) { |
924 | } else if ((*result)->type == psiconv_cell_string) { |
916 | psiconv_progress(lev+2,off+len,"Going to read a string"); |
925 | psiconv_progress(config,lev+2,off+len,"Going to read a string"); |
917 | (*result)->data.dat_string = |
926 | (*result)->data.dat_string = |
918 | psiconv_read_string(buf,lev+2,off+len,&leng,&res); |
927 | psiconv_read_string(config,buf,lev+2,off+len,&leng,&res); |
919 | if (res) |
928 | if (res) |
920 | goto ERROR2; |
929 | goto ERROR2; |
921 | psiconv_debug(lev+2,off+len,"Cell contents: `%s'", |
930 | psiconv_debug(config,lev+2,off+len,"Cell contents: `%s'", |
922 | (*result)->data.dat_string); |
931 | (*result)->data.dat_string); |
923 | len += leng; |
932 | len += leng; |
924 | } else { |
933 | } else { |
925 | psiconv_warn(lev+2,off+len,"Unknown Sheet Cell type: %02x",(*result)->type); |
934 | psiconv_warn(config,lev+2,off+len,"Unknown Sheet Cell type: %02x",(*result)->type); |
926 | res = PSICONV_E_PARSE; |
935 | res = PSICONV_E_PARSE; |
927 | goto ERROR2; |
936 | goto ERROR2; |
928 | } |
937 | } |
929 | |
938 | |
930 | if (!((*result)->layout = psiconv_clone_cell_layout( |
939 | if (!((*result)->layout = psiconv_clone_cell_layout( |
… | |
… | |
933 | default_layout, |
942 | default_layout, |
934 | (*result)->row, |
943 | (*result)->row, |
935 | (*result)->column)))) |
944 | (*result)->column)))) |
936 | goto ERROR2; |
945 | goto ERROR2; |
937 | if (has_layout) { |
946 | if (has_layout) { |
938 | if ((res = psiconv_parse_sheet_cell_layout(buf,lev+2,off+len, |
947 | if ((res = psiconv_parse_sheet_cell_layout(config,buf,lev+2,off+len, |
939 | &leng,(*result)->layout))) |
948 | &leng,(*result)->layout))) |
940 | goto ERROR2; |
949 | goto ERROR2; |
941 | len += leng; |
950 | len += leng; |
942 | } |
951 | } |
943 | |
952 | |
944 | if ((*result)->calculated) { |
953 | if ((*result)->calculated) { |
945 | psiconv_progress(lev+2,off+len,"Going to read the cell formula reference"); |
954 | psiconv_progress(config,lev+2,off+len,"Going to read the cell formula reference"); |
946 | temp = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
955 | temp = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
947 | if (res) |
956 | if (res) |
948 | goto ERROR2; |
957 | goto ERROR2; |
949 | psiconv_debug(lev+2,off+len,"Cell formula reference: %d",temp); |
958 | psiconv_debug(config,lev+2,off+len,"Cell formula reference: %d",temp); |
950 | len += leng; |
959 | len += leng; |
951 | (*result)->ref_formula = temp; |
960 | (*result)->ref_formula = temp; |
952 | } |
961 | } |
953 | |
962 | |
954 | if (length) |
963 | if (length) |
955 | *length = len; |
964 | *length = len; |
956 | |
965 | |
957 | psiconv_progress(lev,off+len-1, |
966 | psiconv_progress(config,lev,off+len-1, |
958 | "End of sheet cell structure (total length: %08x)", len); |
967 | "End of sheet cell structure (total length: %08x)", len); |
959 | return 0; |
968 | return 0; |
960 | |
969 | |
961 | ERROR2: |
970 | ERROR2: |
962 | psiconv_free_sheet_cell(*result); |
971 | psiconv_free_sheet_cell(*result); |
963 | ERROR1: |
972 | ERROR1: |
964 | psiconv_warn(lev+1,off,"Reading of Sheet Cell Structure failed"); |
973 | psiconv_warn(config,lev+1,off,"Reading of Sheet Cell Structure failed"); |
965 | if (length) |
974 | if (length) |
966 | *length = 0; |
975 | *length = 0; |
967 | if (!res) |
976 | if (!res) |
968 | return -PSICONV_E_NOMEM; |
977 | return -PSICONV_E_NOMEM; |
969 | else |
978 | else |
970 | return res; |
979 | return res; |
971 | } |
980 | } |
972 | |
981 | |
973 | int psiconv_parse_sheet_cell_list(const psiconv_buffer buf, int lev, |
982 | int psiconv_parse_sheet_cell_list(const psiconv_config config, |
|
|
983 | const psiconv_buffer buf, int lev, |
974 | psiconv_u32 off, int *length, |
984 | psiconv_u32 off, int *length, |
975 | psiconv_sheet_cell_list *result, |
985 | psiconv_sheet_cell_list *result, |
976 | const psiconv_sheet_cell_layout default_layout, |
986 | const psiconv_sheet_cell_layout default_layout, |
977 | const psiconv_sheet_line_list row_default_layouts, |
987 | const psiconv_sheet_line_list row_default_layouts, |
978 | const psiconv_sheet_line_list col_default_layouts) |
988 | const psiconv_sheet_line_list col_default_layouts) |
… | |
… | |
982 | psiconv_u32 temp; |
992 | psiconv_u32 temp; |
983 | psiconv_sheet_cell cell; |
993 | psiconv_sheet_cell cell; |
984 | psiconv_u32 listlen,i; |
994 | psiconv_u32 listlen,i; |
985 | int leng; |
995 | int leng; |
986 | |
996 | |
987 | psiconv_progress(lev+1,off,"Going to read the sheet cell list"); |
997 | psiconv_progress(config,lev+1,off,"Going to read the sheet cell list"); |
988 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_cell_s)))) |
998 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_cell_s)))) |
989 | goto ERROR1; |
999 | goto ERROR1; |
990 | |
1000 | |
991 | psiconv_progress(lev+2,off+len, |
1001 | psiconv_progress(config,lev+2,off+len, |
992 | "Going to read the initial byte (%02x expected)",0x02); |
1002 | "Going to read the initial byte (%02x expected)",0x02); |
993 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1003 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
994 | if (res) |
1004 | if (res) |
995 | goto ERROR2; |
1005 | goto ERROR2; |
996 | if (temp != 0x02) { |
1006 | if (temp != 0x02) { |
997 | psiconv_warn(lev+2,off+len, |
1007 | psiconv_warn(config,lev+2,off+len, |
998 | "Sheet cell list initial byte unknown value (ignored)"); |
1008 | "Sheet cell list initial byte unknown value (ignored)"); |
999 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
1009 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
1000 | } |
1010 | } |
1001 | len ++; |
1011 | len ++; |
1002 | |
1012 | |
1003 | psiconv_progress(lev+2,off+len, |
1013 | psiconv_progress(config,lev+2,off+len, |
1004 | "Going to read the initial byte (%02x expected)",0x00); |
1014 | "Going to read the initial byte (%02x expected)",0x00); |
1005 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1015 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1006 | if (res) |
1016 | if (res) |
1007 | goto ERROR2; |
1017 | goto ERROR2; |
1008 | if (temp != 0x00) { |
1018 | if (temp != 0x00) { |
1009 | psiconv_warn(lev+2,off+len, |
1019 | psiconv_warn(config,lev+2,off+len, |
1010 | "Sheet cell list initial byte unknown value (ignored)"); |
1020 | "Sheet cell list initial byte unknown value (ignored)"); |
1011 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
1021 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
1012 | } |
1022 | } |
1013 | len ++; |
1023 | len ++; |
1014 | |
1024 | |
1015 | psiconv_progress(lev+2,off+len, |
1025 | psiconv_progress(config,lev+2,off+len, |
1016 | "Going to read the number of defined cells"); |
1026 | "Going to read the number of defined cells"); |
1017 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
1027 | listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
1018 | if (res) |
1028 | if (res) |
1019 | goto ERROR2; |
1029 | goto ERROR2; |
1020 | psiconv_debug(lev+2,off+len,"Number of defined cells: %d",listlen); |
1030 | psiconv_debug(config,lev+2,off+len,"Number of defined cells: %d",listlen); |
1021 | len += leng; |
1031 | len += leng; |
1022 | |
1032 | |
1023 | psiconv_progress(lev+2,off+len,"Going to read all cells"); |
1033 | psiconv_progress(config,lev+2,off+len,"Going to read all cells"); |
1024 | for (i = 0; i < listlen; i++) { |
1034 | for (i = 0; i < listlen; i++) { |
1025 | psiconv_progress(lev+3,off+len,"Going to read cell %d",i); |
1035 | psiconv_progress(config,lev+3,off+len,"Going to read cell %d",i); |
1026 | if ((res = psiconv_parse_sheet_cell(buf,lev+3,off+len,&leng,&cell, |
1036 | if ((res = psiconv_parse_sheet_cell(config,buf,lev+3,off+len,&leng,&cell, |
1027 | default_layout,row_default_layouts, |
1037 | default_layout,row_default_layouts, |
1028 | col_default_layouts))) |
1038 | col_default_layouts))) |
1029 | goto ERROR2; |
1039 | goto ERROR2; |
1030 | if ((res = psiconv_list_add(*result,cell))) |
1040 | if ((res = psiconv_list_add(*result,cell))) |
1031 | goto ERROR3; |
1041 | goto ERROR3; |
… | |
… | |
1034 | } |
1044 | } |
1035 | |
1045 | |
1036 | if (length) |
1046 | if (length) |
1037 | *length = len; |
1047 | *length = len; |
1038 | |
1048 | |
1039 | psiconv_progress(lev,off+len-1, |
1049 | psiconv_progress(config,lev,off+len-1, |
1040 | "End of sheet cell list (total length: %08x)", len); |
1050 | "End of sheet cell list (total length: %08x)", len); |
1041 | return 0; |
1051 | return 0; |
1042 | |
1052 | |
1043 | ERROR3: |
1053 | ERROR3: |
1044 | psiconv_free_sheet_cell(cell); |
1054 | psiconv_free_sheet_cell(cell); |
1045 | ERROR2: |
1055 | ERROR2: |
1046 | psiconv_free_sheet_cell_list(*result); |
1056 | psiconv_free_sheet_cell_list(*result); |
1047 | ERROR1: |
1057 | ERROR1: |
1048 | psiconv_warn(lev+1,off,"Reading of Sheet Cells List failed"); |
1058 | psiconv_warn(config,lev+1,off,"Reading of Sheet Cells List failed"); |
1049 | if (length) |
1059 | if (length) |
1050 | *length = 0; |
1060 | *length = 0; |
1051 | if (!res) |
1061 | if (!res) |
1052 | return -PSICONV_E_NOMEM; |
1062 | return -PSICONV_E_NOMEM; |
1053 | else |
1063 | else |
1054 | return res; |
1064 | return res; |
1055 | } |
1065 | } |
1056 | |
1066 | |
1057 | |
1067 | |
1058 | int psiconv_parse_sheet_worksheet_list( const psiconv_buffer buf, int lev, |
1068 | int psiconv_parse_sheet_worksheet_list(const psiconv_config config, |
|
|
1069 | const psiconv_buffer buf, int lev, |
1059 | psiconv_u32 off, int *length, |
1070 | psiconv_u32 off, int *length, |
1060 | psiconv_sheet_worksheet_list *result) |
1071 | psiconv_sheet_worksheet_list *result) |
1061 | { |
1072 | { |
1062 | psiconv_sheet_worksheet worksheet; |
1073 | psiconv_sheet_worksheet worksheet; |
1063 | int res=0; |
1074 | int res=0; |
1064 | int len=0; |
1075 | int len=0; |
1065 | psiconv_u8 temp; |
1076 | psiconv_u8 temp; |
1066 | psiconv_u32 offset; |
1077 | psiconv_u32 offset; |
1067 | int leng,i,nr; |
1078 | int leng,i,nr; |
1068 | |
1079 | |
1069 | psiconv_progress(lev+1,off,"Going to read the worksheet list"); |
1080 | psiconv_progress(config,lev+1,off,"Going to read the worksheet list"); |
1070 | if (!(*result = psiconv_list_new(sizeof(*worksheet)))) |
1081 | if (!(*result = psiconv_list_new(sizeof(*worksheet)))) |
1071 | goto ERROR1; |
1082 | goto ERROR1; |
1072 | |
1083 | |
1073 | psiconv_progress(lev+2,off+len, |
1084 | psiconv_progress(config,lev+2,off+len, |
1074 | "Going to read the initial bytes (%02x expected)",0x02); |
1085 | "Going to read the initial bytes (%02x expected)",0x02); |
1075 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1086 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1076 | if (res) |
1087 | if (res) |
1077 | goto ERROR2; |
1088 | goto ERROR2; |
1078 | if (temp != 0x02) { |
1089 | if (temp != 0x02) { |
1079 | psiconv_warn(lev+2,off+len, |
1090 | psiconv_warn(config,lev+2,off+len, |
1080 | "Sheet worksheet list initial byte unknown value (ignored)"); |
1091 | "Sheet worksheet list initial byte unknown value (ignored)"); |
1081 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
1092 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
1082 | } |
1093 | } |
1083 | len ++; |
1094 | len ++; |
1084 | |
1095 | |
1085 | psiconv_progress(lev+2,off+len,"Going to read the list length"); |
1096 | psiconv_progress(config,lev+2,off+len,"Going to read the list length"); |
1086 | nr = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
1097 | nr = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
1087 | if (res) |
1098 | if (res) |
1088 | goto ERROR2; |
1099 | goto ERROR2; |
1089 | psiconv_debug(lev+2,off+len,"Length: %02x",nr); |
1100 | psiconv_debug(config,lev+2,off+len,"Length: %02x",nr); |
1090 | len += leng; |
1101 | len += leng; |
1091 | |
1102 | |
1092 | psiconv_progress(lev+2,off+len,"Going to read the list"); |
1103 | psiconv_progress(config,lev+2,off+len,"Going to read the list"); |
1093 | for (i=0 ; i < nr; i++) { |
1104 | for (i=0 ; i < nr; i++) { |
1094 | psiconv_progress(lev+3,off+len,"Going to read element %d",i); |
1105 | psiconv_progress(config,lev+3,off+len,"Going to read element %d",i); |
1095 | psiconv_progress(lev+4,off+len, |
1106 | psiconv_progress(config,lev+4,off+len, |
1096 | "Going to read the initial byte (%02x expected)",0x00); |
1107 | "Going to read the initial byte (%02x expected)",0x00); |
1097 | temp = psiconv_read_u8(buf,lev+4,off+len,&res); |
1108 | temp = psiconv_read_u8(config,buf,lev+4,off+len,&res); |
1098 | if (res) |
1109 | if (res) |
1099 | goto ERROR2; |
1110 | goto ERROR2; |
1100 | if (temp != 0x00) { |
1111 | if (temp != 0x00) { |
1101 | psiconv_warn(lev+4,off+len, |
1112 | psiconv_warn(config,lev+4,off+len, |
1102 | "Sheet worksheet element initial byte unknown value (ignored)"); |
1113 | "Sheet worksheet element initial byte unknown value (ignored)"); |
1103 | psiconv_debug(lev+4,off+len,"Initial byte: %02x",temp); |
1114 | psiconv_debug(config,lev+4,off+len,"Initial byte: %02x",temp); |
1104 | } |
1115 | } |
1105 | len ++; |
1116 | len ++; |
1106 | |
1117 | |
1107 | psiconv_progress(lev+4,off+len,"Going to read the worksheet offset"); |
1118 | psiconv_progress(config,lev+4,off+len,"Going to read the worksheet offset"); |
1108 | offset = psiconv_read_u32(buf,lev+2,off+len,&res); |
1119 | offset = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1109 | if (res) |
1120 | if (res) |
1110 | goto ERROR2; |
1121 | goto ERROR2; |
1111 | psiconv_debug(lev+4,off+len,"Offset: %08x",offset); |
1122 | psiconv_debug(config,lev+4,off+len,"Offset: %08x",offset); |
1112 | len += 4; |
1123 | len += 4; |
1113 | |
1124 | |
1114 | if ((res = psiconv_parse_sheet_worksheet(buf,lev+4,offset,NULL, |
1125 | if ((res = psiconv_parse_sheet_worksheet(config,buf,lev+4,offset,NULL, |
1115 | &worksheet))) |
1126 | &worksheet))) |
1116 | goto ERROR2; |
1127 | goto ERROR2; |
1117 | if ((res = psiconv_list_add(*result,worksheet))) |
1128 | if ((res = psiconv_list_add(*result,worksheet))) |
1118 | goto ERROR3; |
1129 | goto ERROR3; |
1119 | free(worksheet); |
1130 | free(worksheet); |
1120 | } |
1131 | } |
1121 | |
1132 | |
1122 | if (length) |
1133 | if (length) |
1123 | *length = len; |
1134 | *length = len; |
1124 | |
1135 | |
1125 | psiconv_progress(lev,off+len-1, |
1136 | psiconv_progress(config,lev,off+len-1, |
1126 | "End of worksheet list (total length: %08x)", len); |
1137 | "End of worksheet list (total length: %08x)", len); |
1127 | |
1138 | |
1128 | return 0; |
1139 | return 0; |
1129 | |
1140 | |
1130 | ERROR3: |
1141 | ERROR3: |
1131 | psiconv_free_sheet_worksheet(worksheet); |
1142 | psiconv_free_sheet_worksheet(worksheet); |
1132 | ERROR2: |
1143 | ERROR2: |
1133 | psiconv_free_sheet_worksheet_list(*result); |
1144 | psiconv_free_sheet_worksheet_list(*result); |
1134 | ERROR1: |
1145 | ERROR1: |
1135 | psiconv_warn(lev+1,off,"Reading of worksheet list failed"); |
1146 | psiconv_warn(config,lev+1,off,"Reading of worksheet list failed"); |
1136 | if (length) |
1147 | if (length) |
1137 | *length = 0; |
1148 | *length = 0; |
1138 | if (!res) |
1149 | if (!res) |
1139 | return -PSICONV_E_NOMEM; |
1150 | return -PSICONV_E_NOMEM; |
1140 | else |
1151 | else |
1141 | return res; |
1152 | return res; |
1142 | } |
1153 | } |
1143 | |
1154 | |
1144 | int psiconv_parse_sheet_cell_layout(const psiconv_buffer buf, int lev, |
1155 | int psiconv_parse_sheet_cell_layout(const psiconv_config config, |
|
|
1156 | const psiconv_buffer buf, int lev, |
1145 | psiconv_u32 off, int *length, |
1157 | psiconv_u32 off, int *length, |
1146 | psiconv_sheet_cell_layout result) |
1158 | psiconv_sheet_cell_layout result) |
1147 | |
1159 | |
1148 | { |
1160 | { |
1149 | int res=0; |
1161 | int res=0; |
1150 | int len=0; |
1162 | int len=0; |
1151 | int leng; |
1163 | int leng; |
1152 | psiconv_u8 temp; |
1164 | psiconv_u8 temp; |
1153 | |
1165 | |
1154 | psiconv_progress(lev+1,off,"Going to read a sheet cell layout"); |
1166 | psiconv_progress(config,lev+1,off,"Going to read a sheet cell layout"); |
1155 | |
1167 | |
1156 | psiconv_progress(lev+2,off+len, |
1168 | psiconv_progress(config,lev+2,off+len, |
1157 | "Going to read the first byte (%02x expected)",0x02); |
1169 | "Going to read the first byte (%02x expected)",0x02); |
1158 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1170 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1159 | if (res) |
1171 | if (res) |
1160 | goto ERROR1; |
1172 | goto ERROR1; |
1161 | if (temp != 0x02) { |
1173 | if (temp != 0x02) { |
1162 | psiconv_warn(lev+2,off+len, |
1174 | psiconv_warn(config,lev+2,off+len, |
1163 | "Worksheet section initial byte unknown value (ignored)"); |
1175 | "Worksheet section initial byte unknown value (ignored)"); |
1164 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
1176 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
1165 | } |
1177 | } |
1166 | len ++; |
1178 | len ++; |
1167 | |
1179 | |
1168 | psiconv_progress(lev+2,off+len,"Going to read the default formats flag"); |
1180 | psiconv_progress(config,lev+2,off+len,"Going to read the default formats flag"); |
1169 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1181 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1170 | if (res) |
1182 | if (res) |
1171 | goto ERROR1; |
1183 | goto ERROR1; |
1172 | len ++; |
1184 | len ++; |
1173 | |
1185 | |
1174 | if (temp & 0x01) { |
1186 | if (temp & 0x01) { |
1175 | psiconv_progress(lev+3,off+len,"Going to read the default paragraph codes"); |
1187 | psiconv_progress(config,lev+3,off+len,"Going to read the default paragraph codes"); |
1176 | if ((res = psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
1188 | if ((res = psiconv_parse_paragraph_layout_list(config,buf,lev+3,off+len,&leng, |
1177 | result->paragraph))) |
1189 | result->paragraph))) |
1178 | goto ERROR1; |
1190 | goto ERROR1; |
1179 | len += leng; |
1191 | len += leng; |
1180 | } |
1192 | } |
1181 | |
1193 | |
1182 | if (temp & 0x02) { |
1194 | if (temp & 0x02) { |
1183 | psiconv_progress(lev+3,off+len,"Going to read the default character codes"); |
1195 | psiconv_progress(config,lev+3,off+len,"Going to read the default character codes"); |
1184 | if ((res = psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
1196 | if ((res = psiconv_parse_character_layout_list(config,buf,lev+3,off+len,&leng, |
1185 | result->character))) |
1197 | result->character))) |
1186 | goto ERROR1; |
1198 | goto ERROR1; |
1187 | len += leng; |
1199 | len += leng; |
1188 | } |
1200 | } |
1189 | |
1201 | |
1190 | if (temp & 0x04) { |
1202 | if (temp & 0x04) { |
1191 | psiconv_progress(lev+3,off+len, "Going to read the default number format"); |
1203 | psiconv_progress(config,lev+3,off+len, "Going to read the default number format"); |
1192 | psiconv_parse_sheet_numberformat(buf,lev+3,off+len,&leng, |
1204 | psiconv_parse_sheet_numberformat(config,buf,lev+3,off+len,&leng, |
1193 | result->numberformat); |
1205 | result->numberformat); |
1194 | len += leng; |
1206 | len += leng; |
1195 | } |
1207 | } |
1196 | |
1208 | |
1197 | if (length) |
1209 | if (length) |
1198 | *length = len; |
1210 | *length = len; |
1199 | |
1211 | |
1200 | psiconv_progress(lev,off+len-1, |
1212 | psiconv_progress(config,lev,off+len-1, |
1201 | "End of sheet cell layout (total length: %08x)", len); |
1213 | "End of sheet cell layout (total length: %08x)", len); |
1202 | |
1214 | |
1203 | return 0; |
1215 | return 0; |
1204 | |
1216 | |
1205 | ERROR1: |
1217 | ERROR1: |
1206 | psiconv_warn(lev+1,off,"Reading of sheet cell layout failed"); |
1218 | psiconv_warn(config,lev+1,off,"Reading of sheet cell layout failed"); |
1207 | if (length) |
1219 | if (length) |
1208 | *length = 0; |
1220 | *length = 0; |
1209 | if (!res) |
1221 | if (!res) |
1210 | return -PSICONV_E_NOMEM; |
1222 | return -PSICONV_E_NOMEM; |
1211 | else |
1223 | else |
1212 | return res; |
1224 | return res; |
1213 | } |
1225 | } |
1214 | |
1226 | |
1215 | |
1227 | |
1216 | int psiconv_parse_sheet_worksheet(const psiconv_buffer buf, int lev, |
1228 | int psiconv_parse_sheet_worksheet(const psiconv_config config, |
|
|
1229 | const psiconv_buffer buf, int lev, |
1217 | psiconv_u32 off, int *length, |
1230 | psiconv_u32 off, int *length, |
1218 | psiconv_sheet_worksheet *result) |
1231 | psiconv_sheet_worksheet *result) |
1219 | { |
1232 | { |
1220 | int res=0; |
1233 | int res=0; |
1221 | psiconv_u32 temp,cells_off,grid_off,rows_off,cols_off,unknown_off; |
1234 | psiconv_u32 temp,cells_off,grid_off,rows_off,cols_off,unknown_off; |
1222 | int len=0; |
1235 | int len=0; |
1223 | int leng; |
1236 | int leng; |
1224 | |
1237 | |
1225 | psiconv_progress(lev+1,off,"Going to read the sheet worksheet section"); |
1238 | psiconv_progress(config,lev+1,off,"Going to read the sheet worksheet section"); |
1226 | if (!(*result = malloc(sizeof(**result)))) |
1239 | if (!(*result = malloc(sizeof(**result)))) |
1227 | goto ERROR1; |
1240 | goto ERROR1; |
1228 | |
1241 | |
1229 | psiconv_progress(lev+2,off+len, |
1242 | psiconv_progress(config,lev+2,off+len, |
1230 | "Going to read the initial bytes (%02x expected)",0x04); |
1243 | "Going to read the initial bytes (%02x expected)",0x04); |
1231 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1244 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1232 | if (res) |
1245 | if (res) |
1233 | goto ERROR2; |
1246 | goto ERROR2; |
1234 | if (temp != 0x04) { |
1247 | if (temp != 0x04) { |
1235 | psiconv_warn(lev+2,off+len, |
1248 | psiconv_warn(config,lev+2,off+len, |
1236 | "Worksheet section initial byte unknown value (ignored)"); |
1249 | "Worksheet section initial byte unknown value (ignored)"); |
1237 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
1250 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
1238 | } |
1251 | } |
1239 | len ++; |
1252 | len ++; |
1240 | |
1253 | |
1241 | psiconv_progress(lev+2,off+len, "Going to read the flags byte"); |
1254 | psiconv_progress(config,lev+2,off+len, "Going to read the flags byte"); |
1242 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1255 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1243 | if (res) |
1256 | if (res) |
1244 | goto ERROR2; |
1257 | goto ERROR2; |
1245 | psiconv_debug(lev+2,off+len,"Flags byte: %02x",temp); |
1258 | psiconv_debug(config,lev+2,off+len,"Flags byte: %02x",temp); |
1246 | (*result)->show_zeros = (temp & 0x01)?psiconv_bool_true:psiconv_bool_false; |
1259 | (*result)->show_zeros = (temp & 0x01)?psiconv_bool_true:psiconv_bool_false; |
1247 | if (temp & 0xfe) { |
1260 | if (temp & 0xfe) { |
1248 | psiconv_warn(lev+2,off+len, |
1261 | psiconv_warn(config,lev+2,off+len, |
1249 | "Worksheet section flags byte unknown bits (ignored)"); |
1262 | "Worksheet section flags byte unknown bits (ignored)"); |
1250 | } |
1263 | } |
1251 | len ++; |
1264 | len ++; |
1252 | |
1265 | |
1253 | psiconv_progress(lev+2,off+len,"Going to read the default cell layout"); |
1266 | psiconv_progress(config,lev+2,off+len,"Going to read the default cell layout"); |
1254 | if (!((*result)->default_layout = psiconv_basic_cell_layout())) |
1267 | if (!((*result)->default_layout = psiconv_basic_cell_layout())) |
1255 | goto ERROR2; |
1268 | goto ERROR2; |
1256 | if ((res = psiconv_parse_sheet_cell_layout(buf,lev+2,off+len,&leng, |
1269 | if ((res = psiconv_parse_sheet_cell_layout(config,buf,lev+2,off+len,&leng, |
1257 | (*result)->default_layout))) |
1270 | (*result)->default_layout))) |
1258 | goto ERROR3; |
1271 | goto ERROR3; |
1259 | len += leng; |
1272 | len += leng; |
1260 | |
1273 | |
1261 | psiconv_progress(lev+2,off+len, |
1274 | psiconv_progress(config,lev+2,off+len, |
1262 | "Going to read the offset of the row defaults Section"); |
1275 | "Going to read the offset of the row defaults Section"); |
1263 | rows_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
1276 | rows_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1264 | if (res) |
1277 | if (res) |
1265 | goto ERROR3; |
1278 | goto ERROR3; |
1266 | psiconv_debug(lev+2,off+len,"Offset: %04x",rows_off); |
1279 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",rows_off); |
1267 | len += 4; |
1280 | len += 4; |
1268 | |
1281 | |
1269 | psiconv_progress(lev+2,off+len, |
1282 | psiconv_progress(config,lev+2,off+len, |
1270 | "Going to read the offset of the column defaults Section"); |
1283 | "Going to read the offset of the column defaults Section"); |
1271 | cols_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
1284 | cols_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1272 | if (res) |
1285 | if (res) |
1273 | goto ERROR3; |
1286 | goto ERROR3; |
1274 | psiconv_debug(lev+2,off+len,"Offset: %04x",cols_off); |
1287 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",cols_off); |
1275 | len += 4; |
1288 | len += 4; |
1276 | |
1289 | |
1277 | psiconv_progress(lev+2,off+len, |
1290 | psiconv_progress(config,lev+2,off+len, |
1278 | "Going to read the offset of the Cells List"); |
1291 | "Going to read the offset of the Cells List"); |
1279 | cells_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
1292 | cells_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1280 | if (res) |
1293 | if (res) |
1281 | goto ERROR3; |
1294 | goto ERROR3; |
1282 | psiconv_debug(lev+2,off+len,"Offset: %04x",cells_off); |
1295 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",cells_off); |
1283 | len += 4; |
1296 | len += 4; |
1284 | |
1297 | |
1285 | psiconv_progress(lev+2,off+len, |
1298 | psiconv_progress(config,lev+2,off+len, |
1286 | "Going to read the offset of the Grid Section"); |
1299 | "Going to read the offset of the Grid Section"); |
1287 | grid_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
1300 | grid_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1288 | if (res) |
1301 | if (res) |
1289 | goto ERROR3; |
1302 | goto ERROR3; |
1290 | psiconv_debug(lev+2,off+len,"Offset: %04x",grid_off); |
1303 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",grid_off); |
1291 | len += 4; |
1304 | len += 4; |
1292 | |
1305 | |
1293 | psiconv_progress(lev+2,off+len, |
1306 | psiconv_progress(config,lev+2,off+len, |
1294 | "Going to read the offset of the 3rd ??? Section"); |
1307 | "Going to read the offset of the 3rd ??? Section"); |
1295 | unknown_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
1308 | unknown_off = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1296 | if (res) |
1309 | if (res) |
1297 | goto ERROR3; |
1310 | goto ERROR3; |
1298 | psiconv_debug(lev+2,off+len,"Offset: %04x",unknown_off); |
1311 | psiconv_debug(config,lev+2,off+len,"Offset: %04x",unknown_off); |
1299 | len += 4; |
1312 | len += 4; |
1300 | |
1313 | |
1301 | psiconv_progress(lev+2,off+len, |
1314 | psiconv_progress(config,lev+2,off+len, |
1302 | "Going to read a long of the 3rd ??? Section " |
1315 | "Going to read a long of the 3rd ??? Section " |
1303 | "(%08x expected)",0x00); |
1316 | "(%08x expected)",0x00); |
1304 | temp = psiconv_read_u32(buf,lev+2,unknown_off,&res); |
1317 | temp = psiconv_read_u32(config,buf,lev+2,unknown_off,&res); |
1305 | if (res) |
1318 | if (res) |
1306 | goto ERROR3; |
1319 | goto ERROR3; |
1307 | if (temp != 0x00) { |
1320 | if (temp != 0x00) { |
1308 | psiconv_warn(lev+2,unknown_off, |
1321 | psiconv_warn(config,lev+2,unknown_off, |
1309 | "Unknown worksheet subsection has unknown contents (ignored)"); |
1322 | "Unknown worksheet subsection has unknown contents (ignored)"); |
1310 | psiconv_debug(lev+2,unknown_off,"Offset: %04x",temp); |
1323 | psiconv_debug(config,lev+2,unknown_off,"Offset: %04x",temp); |
1311 | } |
1324 | } |
1312 | len += 4; |
1325 | len += 4; |
1313 | |
1326 | |
1314 | psiconv_progress(lev+2,off+len,"Going to read the row defaults"); |
1327 | psiconv_progress(config,lev+2,off+len,"Going to read the row defaults"); |
1315 | if ((res = psiconv_parse_sheet_line_list(buf,lev+2,rows_off,NULL, |
1328 | if ((res = psiconv_parse_sheet_line_list(config,buf,lev+2,rows_off,NULL, |
1316 | &(*result)->row_default_layouts, |
1329 | &(*result)->row_default_layouts, |
1317 | (*result)->default_layout))) |
1330 | (*result)->default_layout))) |
1318 | goto ERROR3; |
1331 | goto ERROR3; |
1319 | |
1332 | |
1320 | psiconv_progress(lev+2,off+len,"Going to read the column defaults"); |
1333 | psiconv_progress(config,lev+2,off+len,"Going to read the column defaults"); |
1321 | if ((res = psiconv_parse_sheet_line_list(buf,lev+2,cols_off,NULL, |
1334 | if ((res = psiconv_parse_sheet_line_list(config,buf,lev+2,cols_off,NULL, |
1322 | &(*result)->col_default_layouts, |
1335 | &(*result)->col_default_layouts, |
1323 | (*result)->default_layout))) |
1336 | (*result)->default_layout))) |
1324 | goto ERROR4; |
1337 | goto ERROR4; |
1325 | |
1338 | |
1326 | psiconv_progress(lev+2,off+len,"Going to read the cells list"); |
1339 | psiconv_progress(config,lev+2,off+len,"Going to read the cells list"); |
1327 | if ((res = psiconv_parse_sheet_cell_list(buf,lev+2,cells_off,NULL, |
1340 | if ((res = psiconv_parse_sheet_cell_list(config,buf,lev+2,cells_off,NULL, |
1328 | &(*result)->cells, |
1341 | &(*result)->cells, |
1329 | (*result)->default_layout, |
1342 | (*result)->default_layout, |
1330 | (*result)->row_default_layouts, |
1343 | (*result)->row_default_layouts, |
1331 | (*result)->col_default_layouts))) |
1344 | (*result)->col_default_layouts))) |
1332 | goto ERROR5; |
1345 | goto ERROR5; |
1333 | |
1346 | |
1334 | |
1347 | |
1335 | psiconv_progress(lev+2,off+len,"Going to read the grid section"); |
1348 | psiconv_progress(config,lev+2,off+len,"Going to read the grid section"); |
1336 | if ((res = psiconv_parse_sheet_grid_section(buf,lev+2,grid_off,NULL, |
1349 | if ((res = psiconv_parse_sheet_grid_section(config,buf,lev+2,grid_off,NULL, |
1337 | &(*result)->grid))) |
1350 | &(*result)->grid))) |
1338 | goto ERROR6; |
1351 | goto ERROR6; |
1339 | |
1352 | |
1340 | |
1353 | |
1341 | |
1354 | |
1342 | if (length) |
1355 | if (length) |
1343 | *length = len; |
1356 | *length = len; |
1344 | |
1357 | |
1345 | psiconv_progress(lev,off+len-1, |
1358 | psiconv_progress(config,lev,off+len-1, |
1346 | "End of sheet worksheet section (total length: %08x)", len); |
1359 | "End of sheet worksheet section (total length: %08x)", len); |
1347 | return 0; |
1360 | return 0; |
1348 | |
1361 | |
1349 | ERROR6: |
1362 | ERROR6: |
1350 | psiconv_free_sheet_cell_list((*result)->cells); |
1363 | psiconv_free_sheet_cell_list((*result)->cells); |
… | |
… | |
1355 | ERROR3: |
1368 | ERROR3: |
1356 | psiconv_free_sheet_cell_layout((*result)->default_layout); |
1369 | psiconv_free_sheet_cell_layout((*result)->default_layout); |
1357 | ERROR2: |
1370 | ERROR2: |
1358 | free (*result); |
1371 | free (*result); |
1359 | ERROR1: |
1372 | ERROR1: |
1360 | psiconv_warn(lev+1,off,"Reading of Sheet Worksheet Section failed"); |
1373 | psiconv_warn(config,lev+1,off,"Reading of Sheet Worksheet Section failed"); |
1361 | if (length) |
1374 | if (length) |
1362 | *length = 0; |
1375 | *length = 0; |
1363 | if (!res) |
1376 | if (!res) |
1364 | return -PSICONV_E_NOMEM; |
1377 | return -PSICONV_E_NOMEM; |
1365 | else |
1378 | else |
1366 | return res; |
1379 | return res; |
1367 | } |
1380 | } |
1368 | |
1381 | |
1369 | int psiconv_parse_sheet_line(const psiconv_buffer buf, int lev, |
1382 | int psiconv_parse_sheet_line(const psiconv_config config, |
|
|
1383 | const psiconv_buffer buf, int lev, |
1370 | psiconv_u32 off, int *length, |
1384 | psiconv_u32 off, int *length, |
1371 | psiconv_sheet_line *result, |
1385 | psiconv_sheet_line *result, |
1372 | const psiconv_sheet_cell_layout default_layout) |
1386 | const psiconv_sheet_cell_layout default_layout) |
1373 | { |
1387 | { |
1374 | int res=0; |
1388 | int res=0; |
1375 | int len=0; |
1389 | int len=0; |
1376 | int leng; |
1390 | int leng; |
1377 | |
1391 | |
1378 | |
1392 | |
1379 | psiconv_progress(lev+1,off,"Going to read a sheet line"); |
1393 | psiconv_progress(config,lev+1,off,"Going to read a sheet line"); |
1380 | if (!(*result = malloc(sizeof(**result)))) |
1394 | if (!(*result = malloc(sizeof(**result)))) |
1381 | goto ERROR1; |
1395 | goto ERROR1; |
1382 | |
1396 | |
1383 | psiconv_progress(lev+2,off+len,"Going to read the line number"); |
1397 | psiconv_progress(config,lev+2,off+len,"Going to read the line number"); |
1384 | (*result)->position = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
1398 | (*result)->position = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
1385 | if (res) |
1399 | if (res) |
1386 | goto ERROR2; |
1400 | goto ERROR2; |
1387 | psiconv_debug(lev+2,off+len,"Line number: %d\n",(*result)->position); |
1401 | psiconv_debug(config,lev+2,off+len,"Line number: %d\n",(*result)->position); |
1388 | len += leng; |
1402 | len += leng; |
1389 | |
1403 | |
1390 | if (!((*result)->layout = psiconv_clone_cell_layout(default_layout))) |
1404 | if (!((*result)->layout = psiconv_clone_cell_layout(default_layout))) |
1391 | goto ERROR2; |
1405 | goto ERROR2; |
1392 | if ((res = psiconv_parse_sheet_cell_layout(buf,lev+2,off+len, |
1406 | if ((res = psiconv_parse_sheet_cell_layout(config,buf,lev+2,off+len, |
1393 | &leng,(*result)->layout))) |
1407 | &leng,(*result)->layout))) |
1394 | goto ERROR3; |
1408 | goto ERROR3; |
1395 | len += leng; |
1409 | len += leng; |
1396 | |
1410 | |
1397 | if (length) |
1411 | if (length) |
1398 | *length = len; |
1412 | *length = len; |
1399 | |
1413 | |
1400 | psiconv_progress(lev,off+len-1, |
1414 | psiconv_progress(config,lev,off+len-1, |
1401 | "End of the sheet line (total length: %08x)", len); |
1415 | "End of the sheet line (total length: %08x)", len); |
1402 | return 0; |
1416 | return 0; |
1403 | |
1417 | |
1404 | ERROR3: |
1418 | ERROR3: |
1405 | psiconv_free_sheet_cell_layout((*result)->layout); |
1419 | psiconv_free_sheet_cell_layout((*result)->layout); |
1406 | ERROR2: |
1420 | ERROR2: |
1407 | free (*result); |
1421 | free (*result); |
1408 | ERROR1: |
1422 | ERROR1: |
1409 | psiconv_warn(lev+1,off,"Reading of the sheet line failed"); |
1423 | psiconv_warn(config,lev+1,off,"Reading of the sheet line failed"); |
1410 | if (length) |
1424 | if (length) |
1411 | *length = 0; |
1425 | *length = 0; |
1412 | if (!res) |
1426 | if (!res) |
1413 | return -PSICONV_E_NOMEM; |
1427 | return -PSICONV_E_NOMEM; |
1414 | else |
1428 | else |
1415 | return res; |
1429 | return res; |
1416 | } |
1430 | } |
1417 | |
1431 | |
1418 | |
1432 | |
1419 | int psiconv_parse_sheet_line_list(const psiconv_buffer buf, int lev, |
1433 | int psiconv_parse_sheet_line_list(const psiconv_config config, |
|
|
1434 | const psiconv_buffer buf, int lev, |
1420 | psiconv_u32 off, int *length, |
1435 | psiconv_u32 off, int *length, |
1421 | psiconv_sheet_line_list *result, |
1436 | psiconv_sheet_line_list *result, |
1422 | const psiconv_sheet_cell_layout default_layout) |
1437 | const psiconv_sheet_cell_layout default_layout) |
1423 | { |
1438 | { |
1424 | int res=0; |
1439 | int res=0; |
… | |
… | |
1426 | psiconv_u32 temp; |
1441 | psiconv_u32 temp; |
1427 | psiconv_sheet_line line; |
1442 | psiconv_sheet_line line; |
1428 | psiconv_u32 listlen,i; |
1443 | psiconv_u32 listlen,i; |
1429 | int leng; |
1444 | int leng; |
1430 | |
1445 | |
1431 | psiconv_progress(lev+1,off,"Going to read the sheet line list"); |
1446 | psiconv_progress(config,lev+1,off,"Going to read the sheet line list"); |
1432 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_line_s)))) |
1447 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_line_s)))) |
1433 | goto ERROR1; |
1448 | goto ERROR1; |
1434 | |
1449 | |
1435 | psiconv_progress(lev+2,off+len, |
1450 | psiconv_progress(config,lev+2,off+len, |
1436 | "Going to read the initial byte (%02x expected)",0x02); |
1451 | "Going to read the initial byte (%02x expected)",0x02); |
1437 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1452 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1438 | if (res) |
1453 | if (res) |
1439 | goto ERROR2; |
1454 | goto ERROR2; |
1440 | if (temp != 0x02) { |
1455 | if (temp != 0x02) { |
1441 | psiconv_warn(lev+2,off+len, |
1456 | psiconv_warn(config,lev+2,off+len, |
1442 | "Sheet line list initial byte unknown value (ignored)"); |
1457 | "Sheet line list initial byte unknown value (ignored)"); |
1443 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
1458 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
1444 | } |
1459 | } |
1445 | len ++; |
1460 | len ++; |
1446 | |
1461 | |
1447 | psiconv_progress(lev+2,off+len, |
1462 | psiconv_progress(config,lev+2,off+len, |
1448 | "Going to read the number of defined lines"); |
1463 | "Going to read the number of defined lines"); |
1449 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
1464 | listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
1450 | if (res) |
1465 | if (res) |
1451 | goto ERROR2; |
1466 | goto ERROR2; |
1452 | psiconv_debug(lev+2,off+len,"Number of defined lines: %d",listlen); |
1467 | psiconv_debug(config,lev+2,off+len,"Number of defined lines: %d",listlen); |
1453 | len += leng; |
1468 | len += leng; |
1454 | |
1469 | |
1455 | psiconv_progress(lev+2,off+len,"Going to read all lines"); |
1470 | psiconv_progress(config,lev+2,off+len,"Going to read all lines"); |
1456 | for (i = 0; i < listlen; i++) { |
1471 | for (i = 0; i < listlen; i++) { |
1457 | psiconv_progress(lev+3,off+len,"Going to read line %d",i); |
1472 | psiconv_progress(config,lev+3,off+len,"Going to read line %d",i); |
1458 | if ((res = psiconv_parse_sheet_line(buf,lev+3,off+len,&leng,&line, |
1473 | if ((res = psiconv_parse_sheet_line(config,buf,lev+3,off+len,&leng,&line, |
1459 | default_layout))) |
1474 | default_layout))) |
1460 | goto ERROR2; |
1475 | goto ERROR2; |
1461 | if ((res = psiconv_list_add(*result,line))) |
1476 | if ((res = psiconv_list_add(*result,line))) |
1462 | goto ERROR3; |
1477 | goto ERROR3; |
1463 | free(line); |
1478 | free(line); |
… | |
… | |
1465 | } |
1480 | } |
1466 | |
1481 | |
1467 | if (length) |
1482 | if (length) |
1468 | *length = len; |
1483 | *length = len; |
1469 | |
1484 | |
1470 | psiconv_progress(lev,off+len-1, |
1485 | psiconv_progress(config,lev,off+len-1, |
1471 | "End of sheet line list (total length: %08x)", len); |
1486 | "End of sheet line list (total length: %08x)", len); |
1472 | return 0; |
1487 | return 0; |
1473 | |
1488 | |
1474 | ERROR3: |
1489 | ERROR3: |
1475 | psiconv_free_sheet_line(line); |
1490 | psiconv_free_sheet_line(line); |
1476 | ERROR2: |
1491 | ERROR2: |
1477 | psiconv_free_sheet_line_list(*result); |
1492 | psiconv_free_sheet_line_list(*result); |
1478 | ERROR1: |
1493 | ERROR1: |
1479 | psiconv_warn(lev+1,off,"Reading of Sheet Line List failed"); |
1494 | psiconv_warn(config,lev+1,off,"Reading of Sheet Line List failed"); |
1480 | if (length) |
1495 | if (length) |
1481 | *length = 0; |
1496 | *length = 0; |
1482 | if (!res) |
1497 | if (!res) |
1483 | return -PSICONV_E_NOMEM; |
1498 | return -PSICONV_E_NOMEM; |
1484 | else |
1499 | else |
1485 | return res; |
1500 | return res; |
1486 | } |
1501 | } |
1487 | |
1502 | |
1488 | int psiconv_parse_sheet_variable(const psiconv_buffer buf, int lev, |
1503 | int psiconv_parse_sheet_variable(const psiconv_config config, |
|
|
1504 | const psiconv_buffer buf, int lev, |
1489 | psiconv_u32 off, int *length, |
1505 | psiconv_u32 off, int *length, |
1490 | psiconv_sheet_variable *result) |
1506 | psiconv_sheet_variable *result) |
1491 | { |
1507 | { |
1492 | int res=0; |
1508 | int res=0; |
1493 | int len=0; |
1509 | int len=0; |
1494 | psiconv_u32 marker; |
1510 | psiconv_u32 marker; |
1495 | int leng; |
1511 | int leng; |
1496 | |
1512 | |
1497 | psiconv_progress(lev+1,off,"Going to read a sheet variable"); |
1513 | psiconv_progress(config,lev+1,off,"Going to read a sheet variable"); |
1498 | if (!(*result = malloc(sizeof(**result)))) |
1514 | if (!(*result = malloc(sizeof(**result)))) |
1499 | goto ERROR1; |
1515 | goto ERROR1; |
1500 | |
1516 | |
1501 | psiconv_progress(lev+2,off+len, "Going to read the variable name"); |
1517 | psiconv_progress(config,lev+2,off+len, "Going to read the variable name"); |
1502 | (*result)->name = psiconv_read_string(buf,lev+2,off+len,&leng,&res); |
1518 | (*result)->name = psiconv_read_string(config,buf,lev+2,off+len,&leng,&res); |
1503 | if (res) |
1519 | if (res) |
1504 | goto ERROR2; |
1520 | goto ERROR2; |
1505 | len += leng; |
1521 | len += leng; |
1506 | |
1522 | |
1507 | psiconv_progress(lev+2,off+len,"Going to read the type marker"); |
1523 | psiconv_progress(config,lev+2,off+len,"Going to read the type marker"); |
1508 | marker = psiconv_read_u8(buf,lev+2,off+len,&res); |
1524 | marker = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1509 | if (res) |
1525 | if (res) |
1510 | goto ERROR3; |
1526 | goto ERROR3; |
1511 | psiconv_debug(lev+2,off+len,"Marker: %02x",marker); |
1527 | psiconv_debug(config,lev+2,off+len,"Marker: %02x",marker); |
1512 | len ++; |
1528 | len ++; |
1513 | |
1529 | |
1514 | if (marker == 0x00) { |
1530 | if (marker == 0x00) { |
1515 | (*result)->type = psiconv_var_int; |
1531 | (*result)->type = psiconv_var_int; |
1516 | psiconv_progress(lev+2,off+len,"Going to read a signed integer"); |
1532 | psiconv_progress(config,lev+2,off+len,"Going to read a signed integer"); |
1517 | (*result)->data.dat_int = psiconv_read_sint(buf,lev+2,off+len,&leng,&res); |
1533 | (*result)->data.dat_int = psiconv_read_sint(config,buf,lev+2,off+len,&leng,&res); |
1518 | if (res) |
1534 | if (res) |
1519 | goto ERROR3; |
1535 | goto ERROR3; |
1520 | psiconv_debug(lev+2,off+len,"Value: %d",(*result)->data.dat_int); |
1536 | psiconv_debug(config,lev+2,off+len,"Value: %d",(*result)->data.dat_int); |
1521 | len += leng; |
1537 | len += leng; |
1522 | } else if (marker == 0x01) { |
1538 | } else if (marker == 0x01) { |
1523 | (*result)->type = psiconv_var_float; |
1539 | (*result)->type = psiconv_var_float; |
1524 | psiconv_progress(lev+2,off+len,"Going to read a floating point number"); |
1540 | psiconv_progress(config,lev+2,off+len,"Going to read a floating point number"); |
1525 | (*result)->data.dat_float = psiconv_read_float(buf,lev+2,off+len,&leng, |
1541 | (*result)->data.dat_float = psiconv_read_float(config,buf,lev+2,off+len,&leng, |
1526 | &res); |
1542 | &res); |
1527 | if (res) |
1543 | if (res) |
1528 | goto ERROR3; |
1544 | goto ERROR3; |
1529 | psiconv_debug(lev+2,off+len,"Value: %f",(*result)->data.dat_float); |
1545 | psiconv_debug(config,lev+2,off+len,"Value: %f",(*result)->data.dat_float); |
1530 | len += leng; |
1546 | len += leng; |
1531 | } else if (marker == 0x02) { |
1547 | } else if (marker == 0x02) { |
1532 | (*result)->type = psiconv_var_string; |
1548 | (*result)->type = psiconv_var_string; |
1533 | psiconv_progress(lev+2,off+len,"Going to read a string"); |
1549 | psiconv_progress(config,lev+2,off+len,"Going to read a string"); |
1534 | (*result)->data.dat_string = psiconv_read_string(buf,lev+2,off+len,&leng, |
1550 | (*result)->data.dat_string = psiconv_read_string(config,buf,lev+2,off+len,&leng, |
1535 | &res); |
1551 | &res); |
1536 | if (res) |
1552 | if (res) |
1537 | goto ERROR3; |
1553 | goto ERROR3; |
1538 | len += leng; |
1554 | len += leng; |
1539 | } else if (marker == 0x03) { |
1555 | } else if (marker == 0x03) { |
1540 | (*result)->type = psiconv_var_cellref; |
1556 | (*result)->type = psiconv_var_cellref; |
1541 | psiconv_progress(lev+2,off+len,"Going to read a cell reference"); |
1557 | psiconv_progress(config,lev+2,off+len,"Going to read a cell reference"); |
1542 | (*result)->data.dat_cellref = psiconv_read_var_cellref(buf,lev+2,off+len, |
1558 | (*result)->data.dat_cellref = psiconv_read_var_cellref(config,buf,lev+2,off+len, |
1543 | &leng, &res); |
1559 | &leng, &res); |
1544 | if (res) |
1560 | if (res) |
1545 | goto ERROR3; |
1561 | goto ERROR3; |
1546 | len += leng; |
1562 | len += leng; |
1547 | } else if (marker == 0x04) { |
1563 | } else if (marker == 0x04) { |
1548 | (*result)->type = psiconv_var_cellblock; |
1564 | (*result)->type = psiconv_var_cellblock; |
1549 | psiconv_progress(lev+2,off+len,"Going to read a cell block reference"); |
1565 | psiconv_progress(config,lev+2,off+len,"Going to read a cell block reference"); |
1550 | (*result)->data.dat_cellblock = psiconv_read_var_cellblock(buf,lev+2, |
1566 | (*result)->data.dat_cellblock = psiconv_read_var_cellblock(config,buf,lev+2, |
1551 | off+len, |
1567 | off+len, |
1552 | &leng, &res); |
1568 | &leng, &res); |
1553 | if (res) |
1569 | if (res) |
1554 | goto ERROR3; |
1570 | goto ERROR3; |
1555 | len += leng; |
1571 | len += leng; |
1556 | } else { |
1572 | } else { |
1557 | psiconv_warn(lev+2,off+len,"Sheet variable unknown type marker"); |
1573 | psiconv_warn(config,lev+2,off+len,"Sheet variable unknown type marker"); |
1558 | res = -PSICONV_E_PARSE; |
1574 | res = -PSICONV_E_PARSE; |
1559 | goto ERROR3; |
1575 | goto ERROR3; |
1560 | } |
1576 | } |
1561 | |
1577 | |
1562 | psiconv_progress(lev+2,off+len,"Going to read the variable number"); |
1578 | psiconv_progress(config,lev+2,off+len,"Going to read the variable number"); |
1563 | (*result)->number = psiconv_read_u32(buf,lev+2,off+len,&res); |
1579 | (*result)->number = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1564 | if (res) |
1580 | if (res) |
1565 | goto ERROR4; |
1581 | goto ERROR4; |
1566 | psiconv_debug(lev+2,off+len,"Number: %08x",(*result)->number); |
1582 | psiconv_debug(config,lev+2,off+len,"Number: %08x",(*result)->number); |
1567 | len += 4; |
1583 | len += 4; |
1568 | |
1584 | |
1569 | if (length) |
1585 | if (length) |
1570 | *length = len; |
1586 | *length = len; |
1571 | |
1587 | |
1572 | psiconv_progress(lev,off+len-1, |
1588 | psiconv_progress(config,lev,off+len-1, |
1573 | "End of sheet variable (total length: %08x)", len); |
1589 | "End of sheet variable (total length: %08x)", len); |
1574 | return 0; |
1590 | return 0; |
1575 | |
1591 | |
1576 | ERROR4: |
1592 | ERROR4: |
1577 | if ((*result)->type == psiconv_var_string) |
1593 | if ((*result)->type == psiconv_var_string) |
… | |
… | |
1579 | ERROR3: |
1595 | ERROR3: |
1580 | free((*result)->name); |
1596 | free((*result)->name); |
1581 | ERROR2: |
1597 | ERROR2: |
1582 | free (*result); |
1598 | free (*result); |
1583 | ERROR1: |
1599 | ERROR1: |
1584 | psiconv_warn(lev+1,off,"Reading of Sheet Variable failed"); |
1600 | psiconv_warn(config,lev+1,off,"Reading of Sheet Variable failed"); |
1585 | if (length) |
1601 | if (length) |
1586 | *length = 0; |
1602 | *length = 0; |
1587 | if (!res) |
1603 | if (!res) |
1588 | return -PSICONV_E_NOMEM; |
1604 | return -PSICONV_E_NOMEM; |
1589 | else |
1605 | else |
1590 | return res; |
1606 | return res; |
1591 | } |
1607 | } |
1592 | |
1608 | |
1593 | |
1609 | |
1594 | int psiconv_parse_sheet_variable_list(const psiconv_buffer buf, int lev, |
1610 | int psiconv_parse_sheet_variable_list(const psiconv_config config, |
|
|
1611 | const psiconv_buffer buf, int lev, |
1595 | psiconv_u32 off, int *length, |
1612 | psiconv_u32 off, int *length, |
1596 | psiconv_sheet_variable_list *result) |
1613 | psiconv_sheet_variable_list *result) |
1597 | { |
1614 | { |
1598 | int res=0; |
1615 | int res=0; |
1599 | int len=0; |
1616 | int len=0; |
1600 | psiconv_u32 temp; |
1617 | psiconv_u32 temp; |
1601 | psiconv_sheet_variable variable; |
1618 | psiconv_sheet_variable variable; |
1602 | psiconv_u32 listlen,i; |
1619 | psiconv_u32 listlen,i; |
1603 | int leng; |
1620 | int leng; |
1604 | |
1621 | |
1605 | psiconv_progress(lev+1,off,"Going to read the sheet variable list"); |
1622 | psiconv_progress(config,lev+1,off,"Going to read the sheet variable list"); |
1606 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_variable_s)))) |
1623 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_variable_s)))) |
1607 | goto ERROR1; |
1624 | goto ERROR1; |
1608 | |
1625 | |
1609 | psiconv_progress(lev+2,off+len, |
1626 | psiconv_progress(config,lev+2,off+len, |
1610 | "Going to read the initial byte (%02x expected)",0x02); |
1627 | "Going to read the initial byte (%02x expected)",0x02); |
1611 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1628 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1612 | if (res) |
1629 | if (res) |
1613 | goto ERROR2; |
1630 | goto ERROR2; |
1614 | if (temp != 0x02) { |
1631 | if (temp != 0x02) { |
1615 | psiconv_warn(lev+2,off+len, |
1632 | psiconv_warn(config,lev+2,off+len, |
1616 | "Sheet variable list initial byte unknown value (ignored)"); |
1633 | "Sheet variable list initial byte unknown value (ignored)"); |
1617 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
1634 | psiconv_debug(config,lev+2,off+len,"Initial byte: %02x",temp); |
1618 | } |
1635 | } |
1619 | len ++; |
1636 | len ++; |
1620 | |
1637 | |
1621 | psiconv_progress(lev+2,off+len, |
1638 | psiconv_progress(config,lev+2,off+len, |
1622 | "Going to read the number of variables"); |
1639 | "Going to read the number of variables"); |
1623 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
1640 | listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
1624 | if (res) |
1641 | if (res) |
1625 | goto ERROR2; |
1642 | goto ERROR2; |
1626 | psiconv_debug(lev+2,off+len,"Number of variables: %d",listlen); |
1643 | psiconv_debug(config,lev+2,off+len,"Number of variables: %d",listlen); |
1627 | len += leng; |
1644 | len += leng; |
1628 | |
1645 | |
1629 | psiconv_progress(lev+2,off+len,"Going to read all variables"); |
1646 | psiconv_progress(config,lev+2,off+len,"Going to read all variables"); |
1630 | for (i = 0; i < listlen; i++) { |
1647 | for (i = 0; i < listlen; i++) { |
1631 | psiconv_progress(lev+3,off+len,"Going to read variable %d",i); |
1648 | psiconv_progress(config,lev+3,off+len,"Going to read variable %d",i); |
1632 | if ((res = psiconv_parse_sheet_variable(buf,lev+3,off+len,&leng,&variable))) |
1649 | if ((res = psiconv_parse_sheet_variable(config,buf,lev+3,off+len,&leng,&variable))) |
1633 | goto ERROR2; |
1650 | goto ERROR2; |
1634 | if ((res = psiconv_list_add(*result,variable))) |
1651 | if ((res = psiconv_list_add(*result,variable))) |
1635 | goto ERROR3; |
1652 | goto ERROR3; |
1636 | len += leng; |
1653 | len += leng; |
1637 | } |
1654 | } |
1638 | |
1655 | |
1639 | if (length) |
1656 | if (length) |
1640 | *length = len; |
1657 | *length = len; |
1641 | |
1658 | |
1642 | psiconv_progress(lev,off+len-1, |
1659 | psiconv_progress(config,lev,off+len-1, |
1643 | "End of sheet variabels list (total length: %08x)", len); |
1660 | "End of sheet variabels list (total length: %08x)", len); |
1644 | return 0; |
1661 | return 0; |
1645 | |
1662 | |
1646 | ERROR3: |
1663 | ERROR3: |
1647 | psiconv_free_sheet_variable(variable); |
1664 | psiconv_free_sheet_variable(variable); |
1648 | ERROR2: |
1665 | ERROR2: |
1649 | psiconv_list_free(*result); |
1666 | psiconv_list_free(*result); |
1650 | ERROR1: |
1667 | ERROR1: |
1651 | psiconv_warn(lev+1,off,"Reading of Sheet Variable list failed"); |
1668 | psiconv_warn(config,lev+1,off,"Reading of Sheet Variable list failed"); |
1652 | if (length) |
1669 | if (length) |
1653 | *length = 0; |
1670 | *length = 0; |
1654 | if (!res) |
1671 | if (!res) |
1655 | return -PSICONV_E_NOMEM; |
1672 | return -PSICONV_E_NOMEM; |
1656 | else |
1673 | else |
1657 | return res; |
1674 | return res; |
1658 | } |
1675 | } |
1659 | |
1676 | |
1660 | int psiconv_parse_sheet_grid_section(const psiconv_buffer buf, int lev, |
1677 | int psiconv_parse_sheet_grid_section(const psiconv_config config, |
|
|
1678 | const psiconv_buffer buf, int lev, |
1661 | psiconv_u32 off, int *length, |
1679 | psiconv_u32 off, int *length, |
1662 | psiconv_sheet_grid_section *result) |
1680 | psiconv_sheet_grid_section *result) |
1663 | { |
1681 | { |
1664 | int res=0,i; |
1682 | int res=0,i; |
1665 | int len=0,leng; |
1683 | int len=0,leng; |
1666 | psiconv_u32 temp; |
1684 | psiconv_u32 temp; |
1667 | |
1685 | |
1668 | psiconv_progress(lev+1,off,"Going to read the sheet grid section"); |
1686 | psiconv_progress(config,lev+1,off,"Going to read the sheet grid section"); |
1669 | if (!(*result = malloc(sizeof(**result)))) |
1687 | if (!(*result = malloc(sizeof(**result)))) |
1670 | goto ERROR1; |
1688 | goto ERROR1; |
1671 | |
1689 | |
1672 | psiconv_progress(lev+2,off+len, "Going to read the first flags byte"); |
1690 | psiconv_progress(config,lev+2,off+len, "Going to read the first flags byte"); |
1673 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1691 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1674 | if (res) |
1692 | if (res) |
1675 | goto ERROR2; |
1693 | goto ERROR2; |
1676 | (*result)->show_column_titles = temp&0x01?psiconv_bool_true: |
1694 | (*result)->show_column_titles = temp&0x01?psiconv_bool_true: |
1677 | psiconv_bool_false; |
1695 | psiconv_bool_false; |
1678 | psiconv_debug(lev+2,off+len, |
1696 | psiconv_debug(config,lev+2,off+len, |
1679 | "Show column titles: %s", |
1697 | "Show column titles: %s", |
1680 | (*result)->show_column_titles?"true":"false"); |
1698 | (*result)->show_column_titles?"true":"false"); |
1681 | (*result)->show_row_titles = temp&0x02?psiconv_bool_true:psiconv_bool_false; |
1699 | (*result)->show_row_titles = temp&0x02?psiconv_bool_true:psiconv_bool_false; |
1682 | psiconv_debug(lev+2,off+len, |
1700 | psiconv_debug(config,lev+2,off+len, |
1683 | "Show row titles: %s", |
1701 | "Show row titles: %s", |
1684 | (*result)->show_row_titles?"true":"false"); |
1702 | (*result)->show_row_titles?"true":"false"); |
1685 | (*result)->show_vertical_grid = temp&0x04?psiconv_bool_true: |
1703 | (*result)->show_vertical_grid = temp&0x04?psiconv_bool_true: |
1686 | psiconv_bool_false; |
1704 | psiconv_bool_false; |
1687 | psiconv_debug(lev+2,off+len, |
1705 | psiconv_debug(config,lev+2,off+len, |
1688 | "Show vertical grid: %s", |
1706 | "Show vertical grid: %s", |
1689 | (*result)->show_vertical_grid?"true":"false"); |
1707 | (*result)->show_vertical_grid?"true":"false"); |
1690 | (*result)->show_horizontal_grid = temp&0x07?psiconv_bool_true: |
1708 | (*result)->show_horizontal_grid = temp&0x07?psiconv_bool_true: |
1691 | psiconv_bool_false; |
1709 | psiconv_bool_false; |
1692 | psiconv_debug(lev+2,off+len, |
1710 | psiconv_debug(config,lev+2,off+len, |
1693 | "Show horizontal grid: %s", |
1711 | "Show horizontal grid: %s", |
1694 | (*result)->show_horizontal_grid?"true":"false"); |
1712 | (*result)->show_horizontal_grid?"true":"false"); |
1695 | (*result)->freeze_rows = temp&0x80?psiconv_bool_true:psiconv_bool_false; |
1713 | (*result)->freeze_rows = temp&0x80?psiconv_bool_true:psiconv_bool_false; |
1696 | psiconv_debug(lev+2,off+len, |
1714 | psiconv_debug(config,lev+2,off+len, |
1697 | "Freeze rows: %s", |
1715 | "Freeze rows: %s", |
1698 | (*result)->freeze_rows?"true":"false"); |
1716 | (*result)->freeze_rows?"true":"false"); |
1699 | if ((temp & 0x70) != 0x30) { |
1717 | if ((temp & 0x70) != 0x30) { |
1700 | psiconv_warn(lev+2,off+len, |
1718 | psiconv_warn(config,lev+2,off+len, |
1701 | "Grid section first flag byte has unknown bits (ignored)"); |
1719 | "Grid section first flag byte has unknown bits (ignored)"); |
1702 | psiconv_debug(lev+2,off+len,"Bits: %02x (%02x expected)",temp&0x70,0x30); |
1720 | psiconv_debug(config,lev+2,off+len,"Bits: %02x (%02x expected)",temp&0x70,0x30); |
1703 | } |
1721 | } |
1704 | len ++; |
1722 | len ++; |
1705 | |
1723 | |
1706 | psiconv_progress(lev+2,off+len, "Going to read the second flags byte"); |
1724 | psiconv_progress(config,lev+2,off+len, "Going to read the second flags byte"); |
1707 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1725 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1708 | if (res) |
1726 | if (res) |
1709 | goto ERROR2; |
1727 | goto ERROR2; |
1710 | (*result)->freeze_columns = temp&0x01?psiconv_bool_true:psiconv_bool_false; |
1728 | (*result)->freeze_columns = temp&0x01?psiconv_bool_true:psiconv_bool_false; |
1711 | psiconv_debug(lev+2,off+len, |
1729 | psiconv_debug(config,lev+2,off+len, |
1712 | "Freeze columns: %s", (*result)->freeze_columns?"true":"false"); |
1730 | "Freeze columns: %s", (*result)->freeze_columns?"true":"false"); |
1713 | if ((temp & 0xfe) != 0x80) { |
1731 | if ((temp & 0xfe) != 0x80) { |
1714 | psiconv_warn(lev+2,off+len, |
1732 | psiconv_warn(config,lev+2,off+len, |
1715 | "Grid section second flag byte has unknown bits (ignored)"); |
1733 | "Grid section second flag byte has unknown bits (ignored)"); |
1716 | psiconv_debug(lev+2,off+len,"Bits: %02x (%02x expected)",temp&0xfe,0x80); |
1734 | psiconv_debug(config,lev+2,off+len,"Bits: %02x (%02x expected)",temp&0xfe,0x80); |
1717 | } |
1735 | } |
1718 | len ++; |
1736 | len ++; |
1719 | |
1737 | |
1720 | psiconv_progress(lev+2,off+len, |
1738 | psiconv_progress(config,lev+2,off+len, |
1721 | "Going to an unknown byte (%02x expected)",0x90); |
1739 | "Going to an unknown byte (%02x expected)",0x90); |
1722 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1740 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1723 | if (res) |
1741 | if (res) |
1724 | goto ERROR2; |
1742 | goto ERROR2; |
1725 | if (temp != 0x90) { |
1743 | if (temp != 0x90) { |
1726 | psiconv_warn(lev+2,off+len, |
1744 | psiconv_warn(config,lev+2,off+len, |
1727 | "Grid section third byte unknown value (ignored)"); |
1745 | "Grid section third byte unknown value (ignored)"); |
1728 | psiconv_debug(lev+2,off+len,"Value: %02x",temp); |
1746 | psiconv_debug(config,lev+2,off+len,"Value: %02x",temp); |
1729 | } |
1747 | } |
1730 | len ++; |
1748 | len ++; |
1731 | |
1749 | |
1732 | psiconv_progress(lev+2,off+len, "Going to read the fourth flags byte"); |
1750 | psiconv_progress(config,lev+2,off+len, "Going to read the fourth flags byte"); |
1733 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1751 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1734 | if (res) |
1752 | if (res) |
1735 | goto ERROR2; |
1753 | goto ERROR2; |
1736 | (*result)->show_page_breaks = temp&0x04?psiconv_bool_true:psiconv_bool_false; |
1754 | (*result)->show_page_breaks = temp&0x04?psiconv_bool_true:psiconv_bool_false; |
1737 | psiconv_debug(lev+2,off+len, |
1755 | psiconv_debug(config,lev+2,off+len, |
1738 | "Show page breaks: %s", |
1756 | "Show page breaks: %s", |
1739 | (*result)->show_page_breaks?"true":"false"); |
1757 | (*result)->show_page_breaks?"true":"false"); |
1740 | if ((temp & 0xfc) != 0x00) { |
1758 | if ((temp & 0xfc) != 0x00) { |
1741 | psiconv_warn(lev+2,off+len, |
1759 | psiconv_warn(config,lev+2,off+len, |
1742 | "Grid section fourth flag byte has unknown bits (ignored)"); |
1760 | "Grid section fourth flag byte has unknown bits (ignored)"); |
1743 | psiconv_debug(lev+2,off+len,"Bits: %02x (%02x expected)",temp&0xfc,0x00); |
1761 | psiconv_debug(config,lev+2,off+len,"Bits: %02x (%02x expected)",temp&0xfc,0x00); |
1744 | } |
1762 | } |
1745 | len ++; |
1763 | len ++; |
1746 | |
1764 | |
1747 | psiconv_progress(lev+2,off+len,"Going to read the first visible row"); |
1765 | psiconv_progress(config,lev+2,off+len,"Going to read the first visible row"); |
1748 | (*result)->first_row = psiconv_read_u32(buf,lev+2,off+len,&res); |
1766 | (*result)->first_row = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1749 | if (res) |
1767 | if (res) |
1750 | goto ERROR2; |
1768 | goto ERROR2; |
1751 | psiconv_debug(lev+2,off+len,"First row: %d",(*result)->first_row); |
1769 | psiconv_debug(config,lev+2,off+len,"First row: %d",(*result)->first_row); |
1752 | len += 4; |
1770 | len += 4; |
1753 | |
1771 | |
1754 | psiconv_progress(lev+2,off+len,"Going to read the first visible column"); |
1772 | psiconv_progress(config,lev+2,off+len,"Going to read the first visible column"); |
1755 | (*result)->first_column = psiconv_read_u32(buf,lev+2,off+len,&res); |
1773 | (*result)->first_column = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1756 | if (res) |
1774 | if (res) |
1757 | goto ERROR2; |
1775 | goto ERROR2; |
1758 | psiconv_debug(lev+2,off+len,"First column: %d",(*result)->first_column); |
1776 | psiconv_debug(config,lev+2,off+len,"First column: %d",(*result)->first_column); |
1759 | len += 4; |
1777 | len += 4; |
1760 | |
1778 | |
1761 | psiconv_progress(lev+2,off+len,"Going to read the last visible row"); |
1779 | psiconv_progress(config,lev+2,off+len,"Going to read the last visible row"); |
1762 | (*result)->last_row = psiconv_read_u32(buf,lev+2,off+len,&res); |
1780 | (*result)->last_row = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1763 | if (res) |
1781 | if (res) |
1764 | goto ERROR2; |
1782 | goto ERROR2; |
1765 | psiconv_debug(lev+2,off+len,"Last row: %d",(*result)->last_row); |
1783 | psiconv_debug(config,lev+2,off+len,"Last row: %d",(*result)->last_row); |
1766 | len += 4; |
1784 | len += 4; |
1767 | |
1785 | |
1768 | psiconv_progress(lev+2,off+len,"Going to read the last visible column"); |
1786 | psiconv_progress(config,lev+2,off+len,"Going to read the last visible column"); |
1769 | (*result)->last_column = psiconv_read_u32(buf,lev+2,off+len,&res); |
1787 | (*result)->last_column = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1770 | if (res) |
1788 | if (res) |
1771 | goto ERROR2; |
1789 | goto ERROR2; |
1772 | psiconv_debug(lev+2,off+len,"Last column: %d",(*result)->last_column); |
1790 | psiconv_debug(config,lev+2,off+len,"Last column: %d",(*result)->last_column); |
1773 | len += 4; |
1791 | len += 4; |
1774 | |
1792 | |
1775 | psiconv_progress(lev+2,off+len,"Going to read the default row height"); |
1793 | psiconv_progress(config,lev+2,off+len,"Going to read the default row height"); |
1776 | (*result)->default_row_height = psiconv_read_length(buf,lev+2,off+len, |
1794 | (*result)->default_row_height = psiconv_read_length(config,buf,lev+2,off+len, |
1777 | &leng,&res); |
1795 | &leng,&res); |
1778 | if (res) |
1796 | if (res) |
1779 | goto ERROR2; |
1797 | goto ERROR2; |
1780 | psiconv_debug(lev+2,off+len,"Default row height: %f", |
1798 | psiconv_debug(config,lev+2,off+len,"Default row height: %f", |
1781 | (*result)->default_row_height); |
1799 | (*result)->default_row_height); |
1782 | len += leng; |
1800 | len += leng; |
1783 | |
1801 | |
1784 | psiconv_progress(lev+2,off+len,"Going to read the row heights list"); |
1802 | psiconv_progress(config,lev+2,off+len,"Going to read the row heights list"); |
1785 | if ((res = psiconv_parse_sheet_grid_size_list(buf,lev+2,off+len,&leng, |
1803 | if ((res = psiconv_parse_sheet_grid_size_list(config,buf,lev+2,off+len,&leng, |
1786 | &(*result)->row_heights))) |
1804 | &(*result)->row_heights))) |
1787 | goto ERROR2; |
1805 | goto ERROR2; |
1788 | len += leng; |
1806 | len += leng; |
1789 | |
1807 | |
1790 | psiconv_progress(lev+2,off+len,"Going to read the default column height"); |
1808 | psiconv_progress(config,lev+2,off+len,"Going to read the default column height"); |
1791 | (*result)->default_column_width = psiconv_read_length(buf,lev+2,off+len, |
1809 | (*result)->default_column_width = psiconv_read_length(config,buf,lev+2,off+len, |
1792 | &leng,&res); |
1810 | &leng,&res); |
1793 | if (res) |
1811 | if (res) |
1794 | goto ERROR3; |
1812 | goto ERROR3; |
1795 | psiconv_debug(lev+2,off+len,"Default column width: %f", |
1813 | psiconv_debug(config,lev+2,off+len,"Default column width: %f", |
1796 | (*result)->default_column_width); |
1814 | (*result)->default_column_width); |
1797 | len += leng; |
1815 | len += leng; |
1798 | |
1816 | |
1799 | psiconv_progress(lev+2,off+len,"Going to read the column heights list"); |
1817 | psiconv_progress(config,lev+2,off+len,"Going to read the column heights list"); |
1800 | if ((res = psiconv_parse_sheet_grid_size_list(buf,lev+2,off+len,&leng, |
1818 | if ((res = psiconv_parse_sheet_grid_size_list(config,buf,lev+2,off+len,&leng, |
1801 | &(*result)->column_heights))) |
1819 | &(*result)->column_heights))) |
1802 | goto ERROR3; |
1820 | goto ERROR3; |
1803 | len += leng; |
1821 | len += leng; |
1804 | |
1822 | |
1805 | psiconv_progress(lev+2,off+len, |
1823 | psiconv_progress(config,lev+2,off+len, |
1806 | "Going to read an unknown word (%04x expected)",0x00); |
1824 | "Going to read an unknown word (%04x expected)",0x00); |
1807 | temp = psiconv_read_u16(buf,lev+2,off+len,&res); |
1825 | temp = psiconv_read_u16(config,buf,lev+2,off+len,&res); |
1808 | if (res) |
1826 | if (res) |
1809 | goto ERROR4; |
1827 | goto ERROR4; |
1810 | if (temp != 0x00) { |
1828 | if (temp != 0x00) { |
1811 | psiconv_warn(lev+2,off+len, |
1829 | psiconv_warn(config,lev+2,off+len, |
1812 | "Grid section unknown word has unknown value (ignored)"); |
1830 | "Grid section unknown word has unknown value (ignored)"); |
1813 | psiconv_debug(lev+2,off+len,"Value: %04x",temp); |
1831 | psiconv_debug(config,lev+2,off+len,"Value: %04x",temp); |
1814 | } |
1832 | } |
1815 | len += 2; |
1833 | len += 2; |
1816 | |
1834 | |
1817 | psiconv_progress(lev+2,off+len,"Going to read the row breaks list"); |
1835 | psiconv_progress(config,lev+2,off+len,"Going to read the row breaks list"); |
1818 | if ((res = psiconv_parse_sheet_grid_break_list(buf,lev+2,off+len,&leng, |
1836 | if ((res = psiconv_parse_sheet_grid_break_list(config,buf,lev+2,off+len,&leng, |
1819 | &(*result)->row_page_breaks))) |
1837 | &(*result)->row_page_breaks))) |
1820 | goto ERROR4; |
1838 | goto ERROR4; |
1821 | len += leng; |
1839 | len += leng; |
1822 | |
1840 | |
1823 | psiconv_progress(lev+2,off+len,"Going to read the column breaks list"); |
1841 | psiconv_progress(config,lev+2,off+len,"Going to read the column breaks list"); |
1824 | if ((res = psiconv_parse_sheet_grid_break_list(buf,lev+2,off+len,&leng, |
1842 | if ((res = psiconv_parse_sheet_grid_break_list(config,buf,lev+2,off+len,&leng, |
1825 | &(*result)->column_page_breaks))) |
1843 | &(*result)->column_page_breaks))) |
1826 | goto ERROR5; |
1844 | goto ERROR5; |
1827 | len += leng; |
1845 | len += leng; |
1828 | |
1846 | |
1829 | |
1847 | |
1830 | psiconv_progress(lev+2,off+len, |
1848 | psiconv_progress(config,lev+2,off+len, |
1831 | "Going to read 22 unknown bytes (%02x expected)",0x00); |
1849 | "Going to read 22 unknown bytes (%02x expected)",0x00); |
1832 | for (i = 0; i < 22 ; i++) { |
1850 | for (i = 0; i < 22 ; i++) { |
1833 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1851 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1834 | if (res) |
1852 | if (res) |
1835 | goto ERROR6; |
1853 | goto ERROR6; |
1836 | if (temp != 0x00) { |
1854 | if (temp != 0x00) { |
1837 | psiconv_warn(lev+2,off+len, |
1855 | psiconv_warn(config,lev+2,off+len, |
1838 | "Grid section unknown byte %d has unknown value (ignored)", |
1856 | "Grid section unknown byte %d has unknown value (ignored)", |
1839 | i); |
1857 | i); |
1840 | psiconv_debug(lev+2,off+len,"Value: %02x",temp); |
1858 | psiconv_debug(config,lev+2,off+len,"Value: %02x",temp); |
1841 | } |
1859 | } |
1842 | len += 1; |
1860 | len += 1; |
1843 | } |
1861 | } |
1844 | |
1862 | |
1845 | if ((*result)->freeze_rows || (*result)->freeze_columns) { |
1863 | if ((*result)->freeze_rows || (*result)->freeze_columns) { |
1846 | |
1864 | |
1847 | psiconv_progress(lev+2,off+len,"Going to read number of frozen rows"); |
1865 | psiconv_progress(config,lev+2,off+len,"Going to read number of frozen rows"); |
1848 | (*result)->frozen_rows = psiconv_read_u32(buf,lev+2,off+len, &res); |
1866 | (*result)->frozen_rows = psiconv_read_u32(config,buf,lev+2,off+len, &res); |
1849 | if (res) |
1867 | if (res) |
1850 | goto ERROR6; |
1868 | goto ERROR6; |
1851 | psiconv_debug(lev+2,off+len,"Number of frozen rows: %d", |
1869 | psiconv_debug(config,lev+2,off+len,"Number of frozen rows: %d", |
1852 | (*result)->frozen_rows); |
1870 | (*result)->frozen_rows); |
1853 | len += leng; |
1871 | len += leng; |
1854 | |
1872 | |
1855 | psiconv_progress(lev+2,off+len,"Going to read number of frozen columns"); |
1873 | psiconv_progress(config,lev+2,off+len,"Going to read number of frozen columns"); |
1856 | (*result)->frozen_columns = psiconv_read_u32(buf,lev+2,off+len, &res); |
1874 | (*result)->frozen_columns = psiconv_read_u32(config,buf,lev+2,off+len, &res); |
1857 | if (res) |
1875 | if (res) |
1858 | goto ERROR6; |
1876 | goto ERROR6; |
1859 | psiconv_debug(lev+2,off+len,"Number of frozen columns: %d", |
1877 | psiconv_debug(config,lev+2,off+len,"Number of frozen columns: %d", |
1860 | (*result)->frozen_columns); |
1878 | (*result)->frozen_columns); |
1861 | len += leng; |
1879 | len += leng; |
1862 | |
1880 | |
1863 | psiconv_progress(lev+2,off+len,"Going to read first unfrozen row"); |
1881 | psiconv_progress(config,lev+2,off+len,"Going to read first unfrozen row"); |
1864 | (*result)->first_unfrozen_row_displayed = psiconv_read_u32(buf,lev+2, |
1882 | (*result)->first_unfrozen_row_displayed = psiconv_read_u32(config,buf,lev+2, |
1865 | off+len, &res); |
1883 | off+len, &res); |
1866 | if (res) |
1884 | if (res) |
1867 | goto ERROR6; |
1885 | goto ERROR6; |
1868 | psiconv_debug(lev+2,off+len,"First row: %d", |
1886 | psiconv_debug(config,lev+2,off+len,"First row: %d", |
1869 | (*result)->first_unfrozen_row_displayed); |
1887 | (*result)->first_unfrozen_row_displayed); |
1870 | len += leng; |
1888 | len += leng; |
1871 | |
1889 | |
1872 | psiconv_progress(lev+2,off+len,"Going to read first unfrozen column"); |
1890 | psiconv_progress(config,lev+2,off+len,"Going to read first unfrozen column"); |
1873 | (*result)->first_unfrozen_column_displayed = psiconv_read_u32(buf,lev+2, |
1891 | (*result)->first_unfrozen_column_displayed = psiconv_read_u32(config,buf,lev+2, |
1874 | off+len,&res); |
1892 | off+len,&res); |
1875 | if (res) |
1893 | if (res) |
1876 | goto ERROR6; |
1894 | goto ERROR6; |
1877 | psiconv_debug(lev+2,off+len,"First column: %d", |
1895 | psiconv_debug(config,lev+2,off+len,"First column: %d", |
1878 | (*result)->first_unfrozen_column_displayed); |
1896 | (*result)->first_unfrozen_column_displayed); |
1879 | len += leng; |
1897 | len += leng; |
1880 | } else |
1898 | } else |
1881 | (*result)->frozen_rows = (*result)->frozen_columns = |
1899 | (*result)->frozen_rows = (*result)->frozen_columns = |
1882 | (*result)->first_unfrozen_row_displayed = |
1900 | (*result)->first_unfrozen_row_displayed = |
1883 | (*result)->first_unfrozen_column_displayed = 0; |
1901 | (*result)->first_unfrozen_column_displayed = 0; |
1884 | |
1902 | |
1885 | psiconv_progress(lev+2,off+len, |
1903 | psiconv_progress(config,lev+2,off+len, |
1886 | "Going to read 3 unknown bytes (%02x expected)",0xff); |
1904 | "Going to read 3 unknown bytes (%02x expected)",0xff); |
1887 | for (i = 0; i < 3 ; i++) { |
1905 | for (i = 0; i < 3 ; i++) { |
1888 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
1906 | temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
1889 | if (res) |
1907 | if (res) |
1890 | goto ERROR6; |
1908 | goto ERROR6; |
1891 | if (temp != 0xff) { |
1909 | if (temp != 0xff) { |
1892 | psiconv_warn(lev+2,off+len, |
1910 | psiconv_warn(config,lev+2,off+len, |
1893 | "Grid section unknown byte %d has unknown value (ignored)", |
1911 | "Grid section unknown byte %d has unknown value (ignored)", |
1894 | i); |
1912 | i); |
1895 | psiconv_debug(lev+2,off+len,"Value: %02x",temp); |
1913 | psiconv_debug(config,lev+2,off+len,"Value: %02x",temp); |
1896 | } |
1914 | } |
1897 | len ++; |
1915 | len ++; |
1898 | } |
1916 | } |
1899 | |
1917 | |
1900 | if (length) |
1918 | if (length) |
1901 | *length = len; |
1919 | *length = len; |
1902 | |
1920 | |
1903 | psiconv_progress(lev,off+len-1, |
1921 | psiconv_progress(config,lev,off+len-1, |
1904 | "End of sheet grid section (total length: %08x)", len); |
1922 | "End of sheet grid section (total length: %08x)", len); |
1905 | return 0; |
1923 | return 0; |
1906 | |
1924 | |
1907 | ERROR6: |
1925 | ERROR6: |
1908 | psiconv_free_sheet_grid_break_list((*result)->column_page_breaks); |
1926 | psiconv_free_sheet_grid_break_list((*result)->column_page_breaks); |
… | |
… | |
1913 | ERROR3: |
1931 | ERROR3: |
1914 | psiconv_free_sheet_grid_size_list((*result)->row_heights); |
1932 | psiconv_free_sheet_grid_size_list((*result)->row_heights); |
1915 | ERROR2: |
1933 | ERROR2: |
1916 | free(*result); |
1934 | free(*result); |
1917 | ERROR1: |
1935 | ERROR1: |
1918 | psiconv_warn(lev+1,off,"Reading of Sheet Grid Section failed"); |
1936 | psiconv_warn(config,lev+1,off,"Reading of Sheet Grid Section failed"); |
1919 | if (length) |
1937 | if (length) |
1920 | *length = 0; |
1938 | *length = 0; |
1921 | if (!res) |
1939 | if (!res) |
1922 | return -PSICONV_E_NOMEM; |
1940 | return -PSICONV_E_NOMEM; |
1923 | else |
1941 | else |
1924 | return res; |
1942 | return res; |
1925 | } |
1943 | } |
1926 | |
1944 | |
1927 | |
1945 | |
1928 | int psiconv_parse_sheet_grid_size_list(const psiconv_buffer buf, int lev, |
1946 | int psiconv_parse_sheet_grid_size_list(const psiconv_config config, |
|
|
1947 | const psiconv_buffer buf, int lev, |
1929 | psiconv_u32 off, int *length, |
1948 | psiconv_u32 off, int *length, |
1930 | psiconv_sheet_grid_size_list *result) |
1949 | psiconv_sheet_grid_size_list *result) |
1931 | { |
1950 | { |
1932 | int res=0; |
1951 | int res=0; |
1933 | int len=0,i; |
1952 | int len=0,i; |
1934 | int leng,listlen; |
1953 | int leng,listlen; |
1935 | psiconv_sheet_grid_size size; |
1954 | psiconv_sheet_grid_size size; |
1936 | |
1955 | |
1937 | psiconv_progress(lev+1,off,"Going to read a sheet grid size list"); |
1956 | psiconv_progress(config,lev+1,off,"Going to read a sheet grid size list"); |
1938 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_grid_size_s)))) |
1957 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_grid_size_s)))) |
1939 | goto ERROR1; |
1958 | goto ERROR1; |
1940 | |
1959 | |
1941 | psiconv_progress(lev+2,off+len, |
1960 | psiconv_progress(config,lev+2,off+len, |
1942 | "Going to read the number of elements"); |
1961 | "Going to read the number of elements"); |
1943 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
1962 | listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
1944 | if (res) |
1963 | if (res) |
1945 | goto ERROR2; |
1964 | goto ERROR2; |
1946 | psiconv_debug(lev+2,off+len,"Number of elements: %d",listlen); |
1965 | psiconv_debug(config,lev+2,off+len,"Number of elements: %d",listlen); |
1947 | len += leng; |
1966 | len += leng; |
1948 | |
1967 | |
1949 | psiconv_progress(lev+2,off+len,"Going to read all elements"); |
1968 | psiconv_progress(config,lev+2,off+len,"Going to read all elements"); |
1950 | for (i = 0; i < listlen; i++) { |
1969 | for (i = 0; i < listlen; i++) { |
1951 | psiconv_progress(lev+3,off+len,"Going to read element %d",i); |
1970 | psiconv_progress(config,lev+3,off+len,"Going to read element %d",i); |
1952 | if ((res = psiconv_parse_sheet_grid_size(buf,lev+3,off+len,&leng,&size))) |
1971 | if ((res = psiconv_parse_sheet_grid_size(config,buf,lev+3,off+len,&leng,&size))) |
1953 | goto ERROR2; |
1972 | goto ERROR2; |
1954 | if ((res = psiconv_list_add(*result,size))) |
1973 | if ((res = psiconv_list_add(*result,size))) |
1955 | goto ERROR3; |
1974 | goto ERROR3; |
1956 | free(size); |
1975 | free(size); |
1957 | len += leng; |
1976 | len += leng; |
1958 | } |
1977 | } |
1959 | |
1978 | |
1960 | if (length) |
1979 | if (length) |
1961 | *length = len; |
1980 | *length = len; |
1962 | |
1981 | |
1963 | psiconv_progress(lev,off+len-1, |
1982 | psiconv_progress(config,lev,off+len-1, |
1964 | "End of sheet grid size list (total length: %08x)", len); |
1983 | "End of sheet grid size list (total length: %08x)", len); |
1965 | return 0; |
1984 | return 0; |
1966 | |
1985 | |
1967 | ERROR3: |
1986 | ERROR3: |
1968 | psiconv_free_sheet_grid_size(size); |
1987 | psiconv_free_sheet_grid_size(size); |
1969 | ERROR2: |
1988 | ERROR2: |
1970 | psiconv_list_free(*result); |
1989 | psiconv_list_free(*result); |
1971 | ERROR1: |
1990 | ERROR1: |
1972 | psiconv_warn(lev+1,off,"Reading of Sheet Grid Size List failed"); |
1991 | psiconv_warn(config,lev+1,off,"Reading of Sheet Grid Size List failed"); |
1973 | if (length) |
1992 | if (length) |
1974 | *length = 0; |
1993 | *length = 0; |
1975 | if (!res) |
1994 | if (!res) |
1976 | return -PSICONV_E_NOMEM; |
1995 | return -PSICONV_E_NOMEM; |
1977 | else |
1996 | else |
1978 | return res; |
1997 | return res; |
1979 | } |
1998 | } |
1980 | |
1999 | |
1981 | int psiconv_parse_sheet_grid_size(const psiconv_buffer buf, int lev, |
2000 | int psiconv_parse_sheet_grid_size(const psiconv_config config, |
|
|
2001 | const psiconv_buffer buf, int lev, |
1982 | psiconv_u32 off, int *length, |
2002 | psiconv_u32 off, int *length, |
1983 | psiconv_sheet_grid_size *result) |
2003 | psiconv_sheet_grid_size *result) |
1984 | { |
2004 | { |
1985 | int res=0; |
2005 | int res=0; |
1986 | int len=0; |
2006 | int len=0; |
1987 | int leng; |
2007 | int leng; |
1988 | |
2008 | |
1989 | psiconv_progress(lev+1,off,"Going to read a sheet grid size"); |
2009 | psiconv_progress(config,lev+1,off,"Going to read a sheet grid size"); |
1990 | |
2010 | |
1991 | if (!(*result = malloc(sizeof(**result)))) |
2011 | if (!(*result = malloc(sizeof(**result)))) |
1992 | goto ERROR1; |
2012 | goto ERROR1; |
1993 | |
2013 | |
1994 | psiconv_progress(lev+2,off+len, "Going to read the row or column number"); |
2014 | psiconv_progress(config,lev+2,off+len, "Going to read the row or column number"); |
1995 | (*result)->line_number = psiconv_read_u32(buf,lev+2,off+len,&res); |
2015 | (*result)->line_number = psiconv_read_u32(config,buf,lev+2,off+len,&res); |
1996 | if (res) |
2016 | if (res) |
1997 | goto ERROR2; |
2017 | goto ERROR2; |
1998 | psiconv_debug(lev+2,off+len,"Line number: %d\n",(*result)->line_number); |
2018 | psiconv_debug(config,lev+2,off+len,"Line number: %d\n",(*result)->line_number); |
1999 | len += 4; |
2019 | len += 4; |
2000 | |
2020 | |
2001 | psiconv_progress(lev+2,off+len, "Going to read the row or column height"); |
2021 | psiconv_progress(config,lev+2,off+len, "Going to read the row or column height"); |
2002 | (*result)->size = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
2022 | (*result)->size = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); |
2003 | if (res) |
2023 | if (res) |
2004 | goto ERROR2; |
2024 | goto ERROR2; |
2005 | psiconv_debug(lev+2,off+len,"Size: %f\n",(*result)->size); |
2025 | psiconv_debug(config,lev+2,off+len,"Size: %f\n",(*result)->size); |
2006 | len += leng; |
2026 | len += leng; |
2007 | |
2027 | |
2008 | if (length) |
2028 | if (length) |
2009 | *length = len; |
2029 | *length = len; |
2010 | |
2030 | |
2011 | psiconv_progress(lev,off+len-1, |
2031 | psiconv_progress(config,lev,off+len-1, |
2012 | "End of sheet grid size(total length: %08x)", len); |
2032 | "End of sheet grid size(total length: %08x)", len); |
2013 | return 0; |
2033 | return 0; |
2014 | |
2034 | |
2015 | ERROR2: |
2035 | ERROR2: |
2016 | free (*result); |
2036 | free (*result); |
2017 | ERROR1: |
2037 | ERROR1: |
2018 | psiconv_warn(lev+1,off,"Reading of Sheet Grid Size failed"); |
2038 | psiconv_warn(config,lev+1,off,"Reading of Sheet Grid Size failed"); |
2019 | if (length) |
2039 | if (length) |
2020 | *length = 0; |
2040 | *length = 0; |
2021 | if (!res) |
2041 | if (!res) |
2022 | return -PSICONV_E_NOMEM; |
2042 | return -PSICONV_E_NOMEM; |
2023 | else |
2043 | else |
2024 | return res; |
2044 | return res; |
2025 | } |
2045 | } |
2026 | |
2046 | |
2027 | |
2047 | |
2028 | int psiconv_parse_sheet_grid_break_list(const psiconv_buffer buf, int lev, |
2048 | int psiconv_parse_sheet_grid_break_list(const psiconv_config config, |
|
|
2049 | const psiconv_buffer buf, int lev, |
2029 | psiconv_u32 off, int *length, |
2050 | psiconv_u32 off, int *length, |
2030 | psiconv_sheet_grid_break_list *result) |
2051 | psiconv_sheet_grid_break_list *result) |
2031 | { |
2052 | { |
2032 | int res=0; |
2053 | int res=0; |
2033 | int len=0,i; |
2054 | int len=0,i; |
2034 | int leng,listlen; |
2055 | int leng,listlen; |
2035 | psiconv_u32 nr; |
2056 | psiconv_u32 nr; |
2036 | |
2057 | |
2037 | psiconv_progress(lev+1,off,"Going to read a sheet grid break list"); |
2058 | psiconv_progress(config,lev+1,off,"Going to read a sheet grid break list"); |
2038 | if (!(*result = psiconv_list_new(sizeof(psiconv_u32)))) |
2059 | if (!(*result = psiconv_list_new(sizeof(psiconv_u32)))) |
2039 | goto ERROR1; |
2060 | goto ERROR1; |
2040 | |
2061 | |
2041 | psiconv_progress(lev+2,off+len, |
2062 | psiconv_progress(config,lev+2,off+len, |
2042 | "Going to read the number of elements"); |
2063 | "Going to read the number of elements"); |
2043 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
2064 | listlen = psiconv_read_X(config,buf,lev+2,off+len,&leng,&res); |
2044 | if (res) |
2065 | if (res) |
2045 | goto ERROR2; |
2066 | goto ERROR2; |
2046 | psiconv_debug(lev+2,off+len,"Number of elements: %d",listlen); |
2067 | psiconv_debug(config,lev+2,off+len,"Number of elements: %d",listlen); |
2047 | len += leng; |
2068 | len += leng; |
2048 | |
2069 | |
2049 | psiconv_progress(lev+2,off+len,"Going to read all elements"); |
2070 | psiconv_progress(config,lev+2,off+len,"Going to read all elements"); |
2050 | for (i = 0; i < listlen; i++) { |
2071 | for (i = 0; i < listlen; i++) { |
2051 | psiconv_progress(lev+3,off+len,"Going to read element %d",i); |
2072 | psiconv_progress(config,lev+3,off+len,"Going to read element %d",i); |
2052 | nr = psiconv_read_u32(buf,lev+3,off+len,&res); |
2073 | nr = psiconv_read_u32(config,buf,lev+3,off+len,&res); |
2053 | if (res) |
2074 | if (res) |
2054 | goto ERROR2; |
2075 | goto ERROR2; |
2055 | if ((res = psiconv_list_add(*result,&nr))) |
2076 | if ((res = psiconv_list_add(*result,&nr))) |
2056 | goto ERROR2; |
2077 | goto ERROR2; |
2057 | len += leng; |
2078 | len += leng; |
2058 | } |
2079 | } |
2059 | |
2080 | |
2060 | if (length) |
2081 | if (length) |
2061 | *length = len; |
2082 | *length = len; |
2062 | |
2083 | |
2063 | psiconv_progress(lev,off+len-1, |
2084 | psiconv_progress(config,lev,off+len-1, |
2064 | "End of sheet grid break list (total length: %08x)", len); |
2085 | "End of sheet grid break list (total length: %08x)", len); |
2065 | return 0; |
2086 | return 0; |
2066 | |
2087 | |
2067 | ERROR2: |
2088 | ERROR2: |
2068 | psiconv_list_free(*result); |
2089 | psiconv_list_free(*result); |
2069 | ERROR1: |
2090 | ERROR1: |
2070 | psiconv_warn(lev+1,off,"Reading of Sheet Grid break List failed"); |
2091 | psiconv_warn(config,lev+1,off,"Reading of Sheet Grid break List failed"); |
2071 | if (length) |
2092 | if (length) |
2072 | *length = 0; |
2093 | *length = 0; |
2073 | if (!res) |
2094 | if (!res) |
2074 | return -PSICONV_E_NOMEM; |
2095 | return -PSICONV_E_NOMEM; |
2075 | else |
2096 | else |