fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / excel / read.cxx
blob02d7078f30f1b128a3891f81eff042fddca3814a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <stdlib.h>
21 #include <stdio.h>
23 #include "document.hxx"
24 #include "scerrors.hxx"
25 #include "fprogressbar.hxx"
26 #include "xltracer.hxx"
27 #include "xltable.hxx"
28 #include "xihelper.hxx"
29 #include "xipage.hxx"
30 #include "xiview.hxx"
31 #include "xilink.hxx"
32 #include "xiname.hxx"
33 #include "xicontent.hxx"
34 #include "xiescher.hxx"
35 #include "xipivot.hxx"
36 #include "XclImpChangeTrack.hxx"
37 #include "documentimport.hxx"
39 #include "root.hxx"
40 #include "imp_op.hxx"
41 #include "excimp8.hxx"
43 #include <boost/scoped_ptr.hpp>
45 FltError ImportExcel::Read()
47 XclImpPageSettings& rPageSett = GetPageSettings();
48 XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
49 XclImpPalette& rPal = GetPalette();
50 XclImpFontBuffer& rFontBfr = GetFontBuffer();
51 XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
52 XclImpXFBuffer& rXFBfr = GetXFBuffer();
53 XclImpNameManager& rNameMgr = GetNameManager();
54 XclImpObjectManager& rObjMgr = GetObjectManager();
55 (void)rObjMgr;
56 // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
58 enum Zustand {
59 Z_BiffNull, // not a valid Biff-Format
60 Z_Biff2, // Biff2: only one table
62 Z_Biff3, // Biff3: only one table
64 Z_Biff4, // Biff4: only one table
65 Z_Biff4W, // Biff4 Workbook: Globals
66 Z_Biff4T, // Biff4 Workbook: a table itself
67 Z_Biff4E, // Biff4 Workbook: between tables
69 Z_Biff5WPre,// Biff5: Prefetch Workbook
70 Z_Biff5W, // Biff5: Globals
71 Z_Biff5TPre,// Biff5: Prefetch for Shrfmla/Array Formula
72 Z_Biff5T, // Biff5: a table itself
73 Z_Biff5E, // Biff5: between tables
74 Z_Biffn0, // all Biffs: skip table till next EOF
75 Z_Ende };
77 Zustand eAkt = Z_BiffNull, ePrev = Z_BiffNull;
79 FltError eLastErr = eERR_OK;
80 sal_uInt16 nOpcode;
81 sal_uInt16 nBofLevel = 0;
83 OSL_ENSURE( &aIn != NULL, "-ImportExcel::Read(): No Stream - what happened?!" );
85 boost::scoped_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
86 aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
88 /* #i104057# Need to track a base position for progress bar calculation,
89 because sheet substreams may not be in order of sheets. */
90 sal_Size nProgressBasePos = 0;
91 sal_Size nProgressBaseSize = 0;
93 for (; eAkt != Z_Ende; mnLastRecId = nOpcode)
95 if( eAkt == Z_Biff5E )
97 sal_uInt16 nScTab = GetCurrScTab();
98 if( nScTab < maSheetOffsets.size() )
100 nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
101 nProgressBasePos = maSheetOffsets[ nScTab ];
102 aIn.StartNextRecord( nProgressBasePos );
104 else
105 eAkt = Z_Ende;
107 else
108 aIn.StartNextRecord();
110 nOpcode = aIn.GetRecId();
112 if( !aIn.IsValid() )
114 // finalize table if EOF is missing
115 switch( eAkt )
117 case Z_Biff2:
118 case Z_Biff3:
119 case Z_Biff4:
120 case Z_Biff4T:
121 case Z_Biff5TPre:
122 case Z_Biff5T:
123 rNumFmtBfr.CreateScFormats();
124 Eof();
125 break;
126 default:;
128 eAkt = Z_Ende;
129 break;
132 if( eAkt == Z_Ende )
133 break;
135 if( eAkt != Z_Biff5TPre && eAkt != Z_Biff5WPre )
136 pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
138 switch( eAkt )
141 case Z_BiffNull: // ------------------------------- Z_BiffNull -
143 switch( nOpcode )
145 case EXC_ID2_BOF:
146 case EXC_ID3_BOF:
147 case EXC_ID4_BOF:
148 case EXC_ID5_BOF:
150 // #i23425# don't rely on the record ID, but on the detected BIFF version
151 switch( GetBiff() )
153 case EXC_BIFF2:
154 Bof2();
155 if( pExcRoot->eDateiTyp == Biff2 )
157 eAkt = Z_Biff2;
158 NewTable();
160 break;
161 case EXC_BIFF3:
162 Bof3();
163 if( pExcRoot->eDateiTyp == Biff3 )
165 eAkt = Z_Biff3;
166 NewTable();
168 break;
169 case EXC_BIFF4:
170 Bof4();
171 if( pExcRoot->eDateiTyp == Biff4 )
173 eAkt = Z_Biff4;
174 NewTable();
176 else if( pExcRoot->eDateiTyp == Biff4W )
177 eAkt = Z_Biff4W;
178 break;
179 case EXC_BIFF5:
180 Bof5();
181 if( pExcRoot->eDateiTyp == Biff5W )
183 eAkt = Z_Biff5WPre;
185 nBdshtTab = 0;
187 aIn.StoreGlobalPosition(); // store position
189 else if( pExcRoot->eDateiTyp == Biff5 )
191 // #i62752# possible to have BIFF5 sheet without globals
192 NewTable();
193 eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
194 nBofLevel = 0;
195 aIn.StoreGlobalPosition(); // store position
197 break;
198 default:
199 DBG_ERROR_BIFF();
202 break;
205 break;
207 case Z_Biff2: // ---------------------------------- Z_Biff2 -
209 switch( nOpcode )
211 case EXC_ID2_DIMENSIONS:
212 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
213 case EXC_ID2_BLANK:
214 case EXC_ID3_BLANK: ReadBlank(); break;
215 case EXC_ID2_INTEGER: ReadInteger(); break;
216 case EXC_ID2_NUMBER:
217 case EXC_ID3_NUMBER: ReadNumber(); break;
218 case EXC_ID2_LABEL:
219 case EXC_ID3_LABEL: ReadLabel(); break;
220 case EXC_ID2_BOOLERR:
221 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
222 case EXC_ID_RK: ReadRk(); break;
224 case 0x06: Formula25(); break; // FORMULA [ 2 5]
225 case 0x08: Row25(); break; // ROW [ 2 5]
226 case 0x0A: // EOF [ 2345]
227 rNumFmtBfr.CreateScFormats();
228 rNameMgr.ConvertAllTokens();
229 Eof();
230 eAkt = Z_Ende;
231 break;
232 case 0x14:
233 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
234 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
235 case 0x18: rNameMgr.ReadName( maStrm ); break;
236 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
237 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
238 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
239 case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ]
240 case 0x21: Array25(); break; // ARRAY [ 2 5]
241 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
242 case 0x24: Colwidth(); break; // COLWIDTH [ 2 ]
243 case 0x25: Defrowheight2(); break; // DEFAULTROWHEI[ 2 ]
244 case 0x26:
245 case 0x27:
246 case 0x28:
247 case 0x29: rPageSett.ReadMargin( maStrm ); break;
248 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
249 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
250 case 0x2F: // FILEPASS [ 2345]
251 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
252 if( eLastErr != ERRCODE_NONE )
253 eAkt = Z_Ende;
254 break;
255 case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
256 case EXC_ID_EFONT: rFontBfr.ReadEfont( maStrm ); break;
257 case 0x3E: rTabViewSett.ReadWindow2( maStrm, false );break;
258 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
259 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
260 case 0x43: rXFBfr.ReadXF( maStrm ); break;
261 case 0x44: Ixfe(); break; // IXFE [ 2 ]
264 break;
266 case Z_Biff3: // ---------------------------------- Z_Biff3 -
268 switch( nOpcode )
270 // skip chart substream
271 case EXC_ID2_BOF:
272 case EXC_ID3_BOF:
273 case EXC_ID4_BOF:
274 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
276 case EXC_ID2_DIMENSIONS:
277 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
278 case EXC_ID2_BLANK:
279 case EXC_ID3_BLANK: ReadBlank(); break;
280 case EXC_ID2_INTEGER: ReadInteger(); break;
281 case EXC_ID2_NUMBER:
282 case EXC_ID3_NUMBER: ReadNumber(); break;
283 case EXC_ID2_LABEL:
284 case EXC_ID3_LABEL: ReadLabel(); break;
285 case EXC_ID2_BOOLERR:
286 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
287 case EXC_ID_RK: ReadRk(); break;
289 case 0x0A: // EOF [ 2345]
290 rNumFmtBfr.CreateScFormats();
291 rNameMgr.ConvertAllTokens();
292 Eof();
293 eAkt = Z_Ende;
294 break;
295 case 0x14:
296 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
297 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
298 case 0x1A:
299 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
300 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
301 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
302 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
303 case 0x22: Rec1904(); break; // 1904 [ 2345]
304 case 0x26:
305 case 0x27:
306 case 0x28:
307 case 0x29: rPageSett.ReadMargin( maStrm ); break;
308 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
309 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
310 case 0x2F: // FILEPASS [ 2345]
311 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
312 if( eLastErr != ERRCODE_NONE )
313 eAkt = Z_Ende;
314 break;
315 case EXC_ID_FILESHARING: ReadFileSharing(); break;
316 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
317 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
318 case 0x56: break; // BUILTINFMTCNT[ 34 ]
319 case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
320 case 0x7D: Colinfo(); break; // COLINFO [ 345]
321 case 0x8C: Country(); break; // COUNTRY [ 345]
322 case 0x92: rPal.ReadPalette( maStrm ); break;
323 case 0x0206: Formula3(); break; // FORMULA [ 3 ]
324 case 0x0208: Row34(); break; // ROW [ 34 ]
325 case 0x0218: rNameMgr.ReadName( maStrm ); break;
326 case 0x0221: Array34(); break; // ARRAY [ 34 ]
327 case 0x0223: break; // EXTERNNAME [ 34 ]
328 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
329 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
330 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
331 case 0x0243: rXFBfr.ReadXF( maStrm ); break;
332 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
335 break;
337 case Z_Biff4: // ---------------------------------- Z_Biff4 -
339 switch( nOpcode )
341 // skip chart substream
342 case EXC_ID2_BOF:
343 case EXC_ID3_BOF:
344 case EXC_ID4_BOF:
345 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
347 case EXC_ID2_DIMENSIONS:
348 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
349 case EXC_ID2_BLANK:
350 case EXC_ID3_BLANK: ReadBlank(); break;
351 case EXC_ID2_INTEGER: ReadInteger(); break;
352 case EXC_ID2_NUMBER:
353 case EXC_ID3_NUMBER: ReadNumber(); break;
354 case EXC_ID2_LABEL:
355 case EXC_ID3_LABEL: ReadLabel(); break;
356 case EXC_ID2_BOOLERR:
357 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
358 case EXC_ID_RK: ReadRk(); break;
360 case 0x0A: // EOF [ 2345]
361 rNumFmtBfr.CreateScFormats();
362 rNameMgr.ConvertAllTokens();
363 Eof();
364 eAkt = Z_Ende;
365 break;
366 case 0x12: SheetProtect(); break; // SHEET PROTECTION
367 case 0x14:
368 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
369 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
370 case 0x1A:
371 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
372 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
373 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
374 case 0x22: Rec1904(); break; // 1904 [ 2345]
375 case 0x26:
376 case 0x27:
377 case 0x28:
378 case 0x29: rPageSett.ReadMargin( maStrm ); break;
379 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
380 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
381 case 0x2F: // FILEPASS [ 2345]
382 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
383 if( eLastErr != ERRCODE_NONE )
384 eAkt = Z_Ende;
385 break;
386 case EXC_ID_FILESHARING: ReadFileSharing(); break;
387 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
388 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
389 case 0x55: DefColWidth(); break;
390 case 0x56: break; // BUILTINFMTCNT[ 34 ]
391 case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
392 case 0x7D: Colinfo(); break; // COLINFO [ 345]
393 case 0x8C: Country(); break; // COUNTRY [ 345]
394 case 0x92: rPal.ReadPalette( maStrm ); break;
395 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
396 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
397 case 0x0208: Row34(); break; // ROW [ 34 ]
398 case 0x0218: rNameMgr.ReadName( maStrm ); break;
399 case 0x0221: Array34(); break; // ARRAY [ 34 ]
400 case 0x0223: break; // EXTERNNAME [ 34 ]
401 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
402 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
403 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
404 case 0x0406: Formula4(); break; // FORMULA [ 4 ]
405 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
406 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
407 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
410 break;
412 case Z_Biff4W: // --------------------------------- Z_Biff4W -
414 switch( nOpcode )
416 case 0x0A: // EOF [ 2345]
417 rNameMgr.ConvertAllTokens();
418 eAkt = Z_Ende;
419 break;
420 case 0x12: DocProtect(); break; // PROTECT [ 5]
421 case 0x2F: // FILEPASS [ 2345]
422 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
423 if( eLastErr != ERRCODE_NONE )
424 eAkt = Z_Ende;
425 break;
426 case EXC_ID_FILESHARING: ReadFileSharing(); break;
427 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
428 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
429 case 0x55: DefColWidth(); break;
430 case 0x56: break; // BUILTINFMTCNT[ 34 ]
431 case 0x8C: Country(); break; // COUNTRY [ 345]
432 case 0x8F: break; // BUNDLEHEADER [ 4 ]
433 case 0x92: rPal.ReadPalette( maStrm ); break;
434 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
435 case 0x0218: rNameMgr.ReadName( maStrm ); break;
436 case 0x0223: break; // EXTERNNAME [ 34 ]
437 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
438 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
439 case 0x0409: // BOF [ 4 ]
440 Bof4();
441 if( pExcRoot->eDateiTyp == Biff4 )
443 eAkt = Z_Biff4T;
444 NewTable();
446 else
447 eAkt = Z_Ende;
448 break;
449 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
450 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
451 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
455 break;
457 case Z_Biff4T: // --------------------------------- Z_Biff4T -
459 switch( nOpcode )
461 // skip chart substream
462 case EXC_ID2_BOF:
463 case EXC_ID3_BOF:
464 case EXC_ID4_BOF:
465 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
467 case EXC_ID2_DIMENSIONS:
468 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
469 case EXC_ID2_BLANK:
470 case EXC_ID3_BLANK: ReadBlank(); break;
471 case EXC_ID2_INTEGER: ReadInteger(); break;
472 case EXC_ID2_NUMBER:
473 case EXC_ID3_NUMBER: ReadNumber(); break;
474 case EXC_ID2_LABEL:
475 case EXC_ID3_LABEL: ReadLabel(); break;
476 case EXC_ID2_BOOLERR:
477 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
478 case EXC_ID_RK: ReadRk(); break;
480 case 0x0A: // EOF [ 2345]
481 rNameMgr.ConvertAllTokens();
482 Eof();
483 eAkt = Z_Biff4E;
484 break;
485 case 0x12: SheetProtect(); break; // SHEET PROTECTION
486 case 0x14:
487 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
488 case 0x1A:
489 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
490 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
491 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
492 case 0x2F: // FILEPASS [ 2345]
493 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
494 if( eLastErr != ERRCODE_NONE )
495 eAkt = Z_Ende;
496 break;
497 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
498 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
499 case 0x55: DefColWidth(); break;
500 case 0x56: break; // BUILTINFMTCNT[ 34 ]
501 case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
502 case 0x7D: Colinfo(); break; // COLINFO [ 345]
503 case 0x8C: Country(); break; // COUNTRY [ 345]
504 case 0x8F: break; // BUNDLEHEADER [ 4 ]
505 case 0x92: rPal.ReadPalette( maStrm ); break;
506 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
507 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
508 case 0x0208: Row34(); break; // ROW [ 34 ]
509 case 0x0218: rNameMgr.ReadName( maStrm ); break;
510 case 0x0221: Array34(); break;
511 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
512 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
513 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
514 case 0x0406: Formula4(); break;
515 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
516 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
517 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
521 break;
523 case Z_Biff4E: // --------------------------------- Z_Biff4E -
525 switch( nOpcode )
527 case 0x0A: // EOF [ 2345]
528 eAkt = Z_Ende;
529 break;
530 case 0x8F: break; // BUNDLEHEADER [ 4 ]
531 case 0x0409: // BOF [ 4 ]
532 Bof4();
533 NewTable();
534 if( pExcRoot->eDateiTyp == Biff4 )
536 eAkt = Z_Biff4T;
538 else
540 ePrev = eAkt;
541 eAkt = Z_Biffn0;
543 break;
547 break;
548 case Z_Biff5WPre: // ------------------------------ Z_Biff5WPre -
550 switch( nOpcode )
552 case 0x0A: // EOF [ 2345]
553 eAkt = Z_Biff5W;
554 aIn.SeekGlobalPosition(); // und zurueck an alte Position
555 break;
556 case 0x12: DocProtect(); break; // PROTECT [ 5]
557 case 0x2F: // FILEPASS [ 2345]
558 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
559 if( eLastErr != ERRCODE_NONE )
560 eAkt = Z_Ende;
561 break;
562 case EXC_ID_FILESHARING: ReadFileSharing(); break;
563 case 0x3D: Window1(); break;
564 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
565 case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5]
566 case 0x8C: Country(); break; // COUNTRY [ 345]
567 // PALETTE follows XFs, but already needed while reading the XFs
568 case 0x92: rPal.ReadPalette( maStrm ); break;
571 break;
572 case Z_Biff5W: // --------------------------------- Z_Biff5W -
574 switch( nOpcode )
576 case 0x0A: // EOF [ 2345]
577 rNumFmtBfr.CreateScFormats();
578 rXFBfr.CreateUserStyles();
579 rNameMgr.ConvertAllTokens();
580 eAkt = Z_Biff5E;
581 break;
582 case 0x18: rNameMgr.ReadName( maStrm ); break;
583 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
584 case 0x22: Rec1904(); break; // 1904 [ 2345]
585 case 0x31: rFontBfr.ReadFont( maStrm ); break;
586 case 0x56: break; // BUILTINFMTCNT[ 34 ]
587 case 0x8D: Hideobj(); break; // HIDEOBJ [ 345]
588 case 0xDE: Olesize(); break;
589 case 0xE0: rXFBfr.ReadXF( maStrm ); break;
590 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
591 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
595 break;
597 case Z_Biff5TPre: // ------------------------------- Z_Biff5Pre -
599 if( nOpcode == 0x0809 )
600 nBofLevel++;
601 else if( (nOpcode == 0x000A) && nBofLevel )
602 nBofLevel--;
603 else if( !nBofLevel ) // don't read chart records
605 switch( nOpcode )
607 case EXC_ID2_DIMENSIONS:
608 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
609 case 0x08: Row25(); break; // ROW [ 2 5]
610 case 0x0A: // EOF [ 2345]
611 eAkt = Z_Biff5T;
612 aIn.SeekGlobalPosition(); // und zurueck an alte Position
613 break;
614 case 0x12: SheetProtect(); break; // SHEET PROTECTION
615 case 0x1A:
616 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
617 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
618 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
619 case 0x21: Array25(); break; // ARRAY [ 2 5]
620 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
621 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
622 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
623 case 0x55: DefColWidth(); break;
624 case 0x7D: Colinfo(); break; // COLINFO [ 345]
625 case 0x81: Wsbool(); break; // WSBOOL [ 2345]
626 case 0x8C: Country(); break; // COUNTRY [ 345]
627 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
628 case 0x0208: Row34(); break; // ROW [ 34 ]
629 case 0x0221: Array34(); break; // ARRAY [ 34 ]
630 case 0x0223: break; // EXTERNNAME [ 34 ]
631 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
632 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
636 break;
638 case Z_Biff5T: // --------------------------------- Z_Biff5T -
640 switch( nOpcode )
642 case EXC_ID2_BLANK:
643 case EXC_ID3_BLANK: ReadBlank(); break;
644 case EXC_ID2_INTEGER: ReadInteger(); break;
645 case EXC_ID2_NUMBER:
646 case EXC_ID3_NUMBER: ReadNumber(); break;
647 case EXC_ID2_LABEL:
648 case EXC_ID3_LABEL: ReadLabel(); break;
649 case EXC_ID2_BOOLERR:
650 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
651 case EXC_ID_RK: ReadRk(); break;
653 case EXC_ID2_FORMULA:
654 case EXC_ID3_FORMULA:
655 case EXC_ID4_FORMULA: Formula25(); break;
656 case EXC_ID_SHRFMLA: Shrfmla(); break;
657 case 0x0A: Eof(); eAkt = Z_Biff5E; break;
658 case 0x14:
659 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
660 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
661 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
662 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
663 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
664 case 0x26:
665 case 0x27:
666 case 0x28:
667 case 0x29: rPageSett.ReadMargin( maStrm ); break;
668 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
669 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
670 case 0x2F: // FILEPASS [ 2345]
671 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
672 if( eLastErr != ERRCODE_NONE )
673 eAkt = Z_Ende;
674 break;
675 case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
676 case 0x83:
677 case 0x84: rPageSett.ReadCenter( maStrm ); break;
678 case 0xA0: rTabViewSett.ReadScl( maStrm ); break;
679 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
680 case 0xBD: Mulrk(); break; // MULRK [ 5]
681 case 0xBE: Mulblank(); break; // MULBLANK [ 5]
682 case 0xD6: Rstring(); break; // RSTRING [ 5]
683 case 0x00E5: Cellmerging(); break; // #i62300#
684 case 0x0236: TableOp(); break; // TABLE [ 5]
685 case 0x0809: // BOF [ 5]
686 XclTools::SkipSubStream( maStrm );
687 break;
691 break;
693 case Z_Biff5E: // --------------------------------- Z_Biff5E -
695 switch( nOpcode )
697 case 0x0809: // BOF [ 5]
698 Bof5();
699 NewTable();
700 switch( pExcRoot->eDateiTyp )
702 case Biff5:
703 case Biff5M4:
704 eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
705 nBofLevel = 0;
706 aIn.StoreGlobalPosition(); // store position
707 break;
708 case Biff5C: // chart sheet
709 GetCurrSheetDrawing().ReadTabChart( maStrm );
710 Eof();
711 GetTracer().TraceChartOnlySheet();
712 break;
713 case Biff5V:
714 default:
715 pD->SetVisible( GetCurrScTab(), false );
716 ePrev = eAkt;
717 eAkt = Z_Biffn0;
719 OSL_ENSURE( pExcRoot->eDateiTyp != Biff5W,
720 "+ImportExcel::Read(): Doppel-Whopper-Workbook!" );
722 break;
726 break;
727 case Z_Biffn0: // --------------------------------- Z_Biffn0 -
729 switch( nOpcode )
731 case 0x0A: // EOF [ 2345]
732 eAkt = ePrev;
733 IncCurrScTab();
734 break;
738 break;
740 case Z_Ende: // ----------------------------------- Z_Ende -
741 OSL_FAIL( "*ImportExcel::Read(): Not possible state!" );
742 break;
743 default: OSL_FAIL( "-ImportExcel::Read(): state forgotten!" );
747 if( eLastErr == eERR_OK )
749 pProgress.reset();
751 GetDocImport().finalize();
752 AdjustRowHeight();
753 PostDocLoad();
755 pD->CalcAfterLoad(false);
757 const XclImpAddressConverter& rAddrConv = GetAddressConverter();
758 if( rAddrConv.IsTabTruncated() )
759 eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
760 else if( bTabTruncated || rAddrConv.IsRowTruncated() )
761 eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
762 else if( rAddrConv.IsColTruncated() )
763 eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
766 return eLastErr;
769 FltError ImportExcel8::Read()
771 #ifdef EXC_INCL_DUMPER
773 Biff8RecDumper aDumper( GetRoot(), sal_True );
774 if( aDumper.Dump( aIn ) )
775 return ERRCODE_ABORT;
777 #endif
778 // read the entire BIFF8 stream
779 // don't look too close - this stuff seriously needs to be reworked
781 XclImpPageSettings& rPageSett = GetPageSettings();
782 XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
783 XclImpPalette& rPal = GetPalette();
784 XclImpFontBuffer& rFontBfr = GetFontBuffer();
785 XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
786 XclImpXFBuffer& rXFBfr = GetXFBuffer();
787 XclImpSst& rSst = GetSst();
788 XclImpTabInfo& rTabInfo = GetTabInfo();
789 XclImpNameManager& rNameMgr = GetNameManager();
790 XclImpLinkManager& rLinkMgr = GetLinkManager();
791 XclImpObjectManager& rObjMgr = GetObjectManager();
792 // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
793 XclImpCondFormatManager& rCondFmtMgr = GetCondFormatManager();
794 XclImpValidationManager& rValidMgr = GetValidationManager();
795 XclImpPivotTableManager& rPTableMgr = GetPivotTableManager();
796 XclImpWebQueryBuffer& rWQBfr = GetWebQueryBuffer();
798 bool bInUserView = false; // true = In USERSVIEW(BEGIN|END) record block.
800 enum XclImpReadState
802 EXC_STATE_BEFORE_GLOBALS, /// Before workbook globals (wait for initial BOF).
803 EXC_STATE_GLOBALS_PRE, /// Prefetch for workbook globals.
804 EXC_STATE_GLOBALS, /// Workbook globals.
805 EXC_STATE_BEFORE_SHEET, /// Before worksheet (wait for new worksheet BOF).
806 EXC_STATE_SHEET_PRE, /// Prefetch for worksheet.
807 EXC_STATE_SHEET, /// Worksheet.
808 EXC_STATE_END /// Stop reading.
811 XclImpReadState eAkt = EXC_STATE_BEFORE_GLOBALS;
813 FltError eLastErr = eERR_OK;
815 boost::scoped_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
816 aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
818 /* #i104057# Need to track a base position for progress bar calculation,
819 because sheet substreams may not be in order of sheets. */
820 sal_Size nProgressBasePos = 0;
821 sal_Size nProgressBaseSize = 0;
823 bool bSheetHasCodeName = false;
825 std::vector<OUString> aCodeNames;
826 std::vector < SCTAB > nTabsWithNoCodeName;
828 sal_uInt16 nRecId = 0;
830 for (; eAkt != EXC_STATE_END; mnLastRecId = nRecId)
832 if( eAkt == EXC_STATE_BEFORE_SHEET )
834 sal_uInt16 nScTab = GetCurrScTab();
835 if( nScTab < maSheetOffsets.size() )
837 nProgressBaseSize += (maStrm.GetSvStreamPos() - nProgressBasePos);
838 nProgressBasePos = maSheetOffsets[ nScTab ];
840 // i#115255 fdo#40304 BOUNDSHEET doesn't point to a valid
841 // BOF record position. Scan the records manually (from
842 // the BOUNDSHEET position) until we find a BOF. Some 3rd
843 // party Russian programs generate invalid xls docs with
844 // this kind of silliness.
845 if (aIn.PeekRecId(nProgressBasePos) == EXC_ID5_BOF)
846 // BOUNDSHEET points to a valid BOF record. Good.
847 aIn.StartNextRecord(nProgressBasePos);
848 else
850 bool bValid = true;
851 while (bValid && aIn.GetRecId() != EXC_ID5_BOF)
852 bValid = aIn.StartNextRecord();
854 if (!bValid)
855 // Safeguard ourselves from potential infinite loop.
856 eAkt = EXC_STATE_END;
859 // import only 256 sheets
860 if( nScTab > GetScMaxPos().Tab() )
862 if( maStrm.GetRecId() != EXC_ID_EOF )
863 XclTools::SkipSubStream( maStrm );
864 // #i29930# show warning box
865 GetAddressConverter().CheckScTab( nScTab, true );
866 eAkt = EXC_STATE_END;
868 else
870 // #i109800# SHEET record may point to any record inside the
871 // sheet substream
872 bool bIsBof = maStrm.GetRecId() == EXC_ID5_BOF;
873 if( bIsBof )
874 Bof5(); // read the BOF record
875 else
876 pExcRoot->eDateiTyp = Biff8; // on missing BOF, assume a standard worksheet
877 NewTable();
878 switch( pExcRoot->eDateiTyp )
880 case Biff8: // worksheet
881 case Biff8M4: // macro sheet
882 eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
883 // go to next record
884 if( bIsBof ) maStrm.StartNextRecord();
885 maStrm.StoreGlobalPosition();
886 break;
887 case Biff8C: // chart sheet
888 GetCurrSheetDrawing().ReadTabChart( maStrm );
889 Eof();
890 GetTracer().TraceChartOnlySheet();
891 break;
892 case Biff8W: // workbook
893 OSL_FAIL( "ImportExcel8::Read - double workbook globals" );
894 // run through
895 case Biff8V: // VB module
896 default:
897 // TODO: do not create a sheet in the Calc document
898 pD->SetVisible( nScTab, false );
899 XclTools::SkipSubStream( maStrm );
900 IncCurrScTab();
904 else
905 eAkt = EXC_STATE_END;
907 else
908 aIn.StartNextRecord();
910 if( !aIn.IsValid() )
912 // #i63591# finalize table if EOF is missing
913 switch( eAkt )
915 case EXC_STATE_SHEET_PRE:
916 eAkt = EXC_STATE_SHEET;
917 aIn.SeekGlobalPosition();
918 continue; // next iteration in while loop
919 case EXC_STATE_SHEET:
920 Eof();
921 eAkt = EXC_STATE_END;
922 break;
923 default:
924 eAkt = EXC_STATE_END;
928 if( eAkt == EXC_STATE_END )
929 break;
931 if( eAkt != EXC_STATE_SHEET_PRE && eAkt != EXC_STATE_GLOBALS_PRE )
932 pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
934 nRecId = aIn.GetRecId();
936 /* #i39464# Ignore records between USERSVIEWBEGIN and USERSVIEWEND
937 completely (user specific view settings). Otherwise view settings
938 and filters are loaded multiple times, which at least causes
939 problems in auto-filters. */
940 switch( nRecId )
942 case EXC_ID_USERSVIEWBEGIN:
943 OSL_ENSURE( !bInUserView, "ImportExcel8::Read - nested user view settings" );
944 bInUserView = true;
945 break;
946 case EXC_ID_USERSVIEWEND:
947 OSL_ENSURE( bInUserView, "ImportExcel8::Read - not in user view settings" );
948 bInUserView = false;
949 break;
952 if( !bInUserView ) switch( eAkt )
955 // before workbook globals: wait for initial workbook globals BOF
956 case EXC_STATE_BEFORE_GLOBALS:
958 if( nRecId == EXC_ID5_BOF )
960 OSL_ENSURE( GetBiff() == EXC_BIFF8, "ImportExcel8::Read - wrong BIFF version" );
961 Bof5();
962 if( pExcRoot->eDateiTyp == Biff8W )
964 eAkt = EXC_STATE_GLOBALS_PRE;
965 maStrm.StoreGlobalPosition();
966 nBdshtTab = 0;
968 else if( pExcRoot->eDateiTyp == Biff8 )
970 // #i62752# possible to have BIFF8 sheet without globals
971 NewTable();
972 eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
973 bSheetHasCodeName = false; // reset
974 aIn.StoreGlobalPosition();
978 break;
980 // prefetch for workbook globals
981 case EXC_STATE_GLOBALS_PRE:
983 switch( nRecId )
985 case EXC_ID_EOF:
986 case EXC_ID_EXTSST:
987 /* #i56376# evil hack: if EOF for globals is missing,
988 simulate it. This hack works only for the bugdoc
989 given in the issue, where the sheet substreams
990 start directly after the EXTSST record. A future
991 implementation should be more robust against
992 missing EOFs. */
993 if( (nRecId == EXC_ID_EOF) ||
994 ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
996 eAkt = EXC_STATE_GLOBALS;
997 aIn.SeekGlobalPosition();
999 break;
1000 case 0x12: DocProtect(); break; // PROTECT [ 5678]
1001 case 0x13: DocPasssword(); break;
1002 case 0x19: WinProtection(); break;
1003 case 0x2F: // FILEPASS [ 2345 ]
1004 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
1005 if( eLastErr != ERRCODE_NONE )
1006 eAkt = EXC_STATE_END;
1007 break;
1008 case EXC_ID_FILESHARING: ReadFileSharing(); break;
1009 case 0x3D: Window1(); break;
1010 case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
1011 case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5 ]
1012 case 0x8C: Country(); break; // COUNTRY [ 345 ]
1014 // PALETTE follows XFs, but already needed while reading the XFs
1015 case EXC_ID_PALETTE: rPal.ReadPalette( maStrm ); break;
1018 break;
1020 // workbook globals
1021 case EXC_STATE_GLOBALS:
1023 switch( nRecId )
1025 case EXC_ID_EOF:
1026 case EXC_ID_EXTSST:
1027 /* #i56376# evil hack: if EOF for globals is missing,
1028 simulate it. This hack works only for the bugdoc
1029 given in the issue, where the sheet substreams
1030 start directly after the EXTSST record. A future
1031 implementation should be more robust against
1032 missing EOFs. */
1033 if( (nRecId == EXC_ID_EOF) ||
1034 ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
1036 rNumFmtBfr.CreateScFormats();
1037 rXFBfr.CreateUserStyles();
1038 rPTableMgr.ReadPivotCaches( maStrm );
1039 rNameMgr.ConvertAllTokens();
1040 eAkt = EXC_STATE_BEFORE_SHEET;
1042 break;
1043 case 0x0E: Precision(); break; // PRECISION
1044 case 0x22: Rec1904(); break; // 1904 [ 2345 ]
1045 case 0x56: break; // BUILTINFMTCNT[ 34 ]
1046 case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ]
1047 case 0xD3: SetHasBasic(); break;
1048 case 0xDE: Olesize(); break;
1050 case EXC_ID_CODENAME: ReadCodeName( aIn, true ); break;
1051 case EXC_ID_USESELFS: ReadUsesElfs(); break;
1053 case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
1054 case EXC_ID4_FORMAT: rNumFmtBfr.ReadFormat( maStrm ); break;
1055 case EXC_ID5_XF: rXFBfr.ReadXF( maStrm ); break;
1056 case EXC_ID_STYLE: rXFBfr.ReadStyle( maStrm ); break;
1058 case EXC_ID_SST: rSst.ReadSst( maStrm ); break;
1059 case EXC_ID_TABID: rTabInfo.ReadTabid( maStrm ); break;
1060 case EXC_ID_NAME: rNameMgr.ReadName( maStrm ); break;
1062 case EXC_ID_EXTERNSHEET: rLinkMgr.ReadExternsheet( maStrm ); break;
1063 case EXC_ID_SUPBOOK: rLinkMgr.ReadSupbook( maStrm ); break;
1064 case EXC_ID_XCT: rLinkMgr.ReadXct( maStrm ); break;
1065 case EXC_ID_CRN: rLinkMgr.ReadCrn( maStrm ); break;
1066 case EXC_ID_EXTERNNAME: rLinkMgr.ReadExternname( maStrm, pFormConv ); break;
1068 case EXC_ID_MSODRAWINGGROUP:rObjMgr.ReadMsoDrawingGroup( maStrm ); break;
1070 case EXC_ID_SXIDSTM: rPTableMgr.ReadSxidstm( maStrm ); break;
1071 case EXC_ID_SXVS: rPTableMgr.ReadSxvs( maStrm ); break;
1072 case EXC_ID_DCONREF: rPTableMgr.ReadDconref( maStrm ); break;
1073 case EXC_ID_DCONNAME: rPTableMgr.ReadDConName( maStrm ); break;
1077 break;
1079 // prefetch for worksheet
1080 case EXC_STATE_SHEET_PRE:
1082 switch( nRecId )
1084 // skip chart substream
1085 case EXC_ID2_BOF:
1086 case EXC_ID3_BOF:
1087 case EXC_ID4_BOF:
1088 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
1090 case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( maStrm, false );break;
1091 case EXC_ID_SCL: rTabViewSett.ReadScl( maStrm ); break;
1092 case EXC_ID_PANE: rTabViewSett.ReadPane( maStrm ); break;
1093 case EXC_ID_SELECTION: rTabViewSett.ReadSelection( maStrm ); break;
1095 case EXC_ID2_DIMENSIONS:
1096 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
1098 case EXC_ID_CODENAME: ReadCodeName( aIn, false ); bSheetHasCodeName = true; break;
1100 case 0x0A: // EOF [ 2345 ]
1102 eAkt = EXC_STATE_SHEET;
1103 OUString sName;
1104 GetDoc().GetName( GetCurrScTab(), sName );
1105 if ( !bSheetHasCodeName )
1107 nTabsWithNoCodeName.push_back( GetCurrScTab() );
1108 OSL_TRACE("No Codename for %d", GetCurrScTab() );
1110 else
1112 OUString sCodeName;
1113 GetDoc().GetCodeName( GetCurrScTab(), sCodeName );
1114 OSL_TRACE("Have CodeName %s for SheetName %s",
1115 OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
1116 aCodeNames.push_back( sCodeName );
1119 bSheetHasCodeName = false; // reset
1121 aIn.SeekGlobalPosition(); // and back to old position
1122 break;
1124 case 0x12: SheetProtect(); break;
1125 case 0x13: SheetPassword(); break;
1126 case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
1127 case 0x55: DefColWidth(); break;
1128 case 0x7D: Colinfo(); break; // COLINFO [ 345 ]
1129 case 0x81: Wsbool(); break; // WSBOOL [ 2345 ]
1130 case 0x8C: Country(); break; // COUNTRY [ 345 ]
1131 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45 ]
1132 case 0x9B: FilterMode(); break; // FILTERMODE
1133 case EXC_ID_AUTOFILTERINFO: AutoFilterInfo(); break;// AUTOFILTERINFO
1134 case EXC_ID_AUTOFILTER: AutoFilter(); break; // AUTOFILTER
1135 case 0x0208: Row34(); break; // ROW [ 34 ]
1136 case EXC_ID2_ARRAY:
1137 case EXC_ID3_ARRAY: Array34(); break; // ARRAY [ 34 ]
1138 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345 ]
1139 case 0x0867: FeatHdr(); break; // FEATHDR
1140 case 0x0868: Feat(); break; // FEAT
1143 break;
1145 // worksheet
1146 case EXC_STATE_SHEET:
1148 switch( nRecId )
1150 // skip unknown substreams
1151 case EXC_ID2_BOF:
1152 case EXC_ID3_BOF:
1153 case EXC_ID4_BOF:
1154 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
1156 case EXC_ID_EOF: Eof(); eAkt = EXC_STATE_BEFORE_SHEET; break;
1158 case EXC_ID2_BLANK:
1159 case EXC_ID3_BLANK: ReadBlank(); break;
1160 case EXC_ID2_INTEGER: ReadInteger(); break;
1161 case EXC_ID2_NUMBER:
1162 case EXC_ID3_NUMBER: ReadNumber(); break;
1163 case EXC_ID2_LABEL:
1164 case EXC_ID3_LABEL: ReadLabel(); break;
1165 case EXC_ID2_BOOLERR:
1166 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
1167 case EXC_ID_RK: ReadRk(); break;
1169 case EXC_ID2_FORMULA:
1170 case EXC_ID3_FORMULA:
1171 case EXC_ID4_FORMULA: Formula25(); break;
1172 case EXC_ID_SHRFMLA: Shrfmla(); break;
1173 case 0x000C: Calccount(); break; // CALCCOUNT
1174 case 0x0010: Delta(); break; // DELTA
1175 case 0x0011: Iteration(); break; // ITERATION
1176 case 0x007E:
1177 case 0x00AE: Scenman(); break; // SCENMAN
1178 case 0x00AF: Scenario(); break; // SCENARIO
1179 case 0x00BD: Mulrk(); break; // MULRK [ 5 ]
1180 case 0x00BE: Mulblank(); break; // MULBLANK [ 5 ]
1181 case 0x00D6: Rstring(); break; // RSTRING [ 5 ]
1182 case 0x00E5: Cellmerging(); break; // CELLMERGING
1183 case 0x00FD: Labelsst(); break; // LABELSST [ 8 ]
1184 case 0x0236: TableOp(); break; // TABLE
1186 case EXC_ID_HORPAGEBREAKS:
1187 case EXC_ID_VERPAGEBREAKS: rPageSett.ReadPageBreaks( maStrm ); break;
1188 case EXC_ID_HEADER:
1189 case EXC_ID_FOOTER: rPageSett.ReadHeaderFooter( maStrm ); break;
1190 case EXC_ID_LEFTMARGIN:
1191 case EXC_ID_RIGHTMARGIN:
1192 case EXC_ID_TOPMARGIN:
1193 case EXC_ID_BOTTOMMARGIN: rPageSett.ReadMargin( maStrm ); break;
1194 case EXC_ID_PRINTHEADERS: rPageSett.ReadPrintHeaders( maStrm ); break;
1195 case EXC_ID_PRINTGRIDLINES: rPageSett.ReadPrintGridLines( maStrm ); break;
1196 case EXC_ID_HCENTER:
1197 case EXC_ID_VCENTER: rPageSett.ReadCenter( maStrm ); break;
1198 case EXC_ID_SETUP: rPageSett.ReadSetup( maStrm ); break;
1199 case EXC_ID8_IMGDATA: rPageSett.ReadImgData( maStrm ); break;
1201 case EXC_ID_MSODRAWING: GetCurrSheetDrawing().ReadMsoDrawing( maStrm ); break;
1202 // #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format
1203 case EXC_ID_OBJ: GetCurrSheetDrawing().ReadObj( maStrm ); break;
1204 case EXC_ID_NOTE: GetCurrSheetDrawing().ReadNote( maStrm ); break;
1206 case EXC_ID_HLINK: XclImpHyperlink::ReadHlink( maStrm ); break;
1207 case EXC_ID_LABELRANGES: XclImpLabelranges::ReadLabelranges( maStrm ); break;
1209 case EXC_ID_CONDFMT: rCondFmtMgr.ReadCondfmt( maStrm ); break;
1210 case EXC_ID_CF: rCondFmtMgr.ReadCF( maStrm ); break;
1212 case EXC_ID_DVAL: XclImpValidationManager::ReadDval( maStrm ); break;
1213 case EXC_ID_DV: rValidMgr.ReadDV( maStrm ); break;
1215 case EXC_ID_QSI: rWQBfr.ReadQsi( maStrm ); break;
1216 case EXC_ID_WQSTRING: rWQBfr.ReadWqstring( maStrm ); break;
1217 case EXC_ID_PQRY: rWQBfr.ReadParamqry( maStrm ); break;
1218 case EXC_ID_WQSETT: rWQBfr.ReadWqsettings( maStrm ); break;
1219 case EXC_ID_WQTABLES: rWQBfr.ReadWqtables( maStrm ); break;
1221 case EXC_ID_SXVIEW: rPTableMgr.ReadSxview( maStrm ); break;
1222 case EXC_ID_SXVD: rPTableMgr.ReadSxvd( maStrm ); break;
1223 case EXC_ID_SXVI: rPTableMgr.ReadSxvi( maStrm ); break;
1224 case EXC_ID_SXIVD: rPTableMgr.ReadSxivd( maStrm ); break;
1225 case EXC_ID_SXPI: rPTableMgr.ReadSxpi( maStrm ); break;
1226 case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break;
1227 case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break;
1228 case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break;
1229 case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break;
1230 case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break;
1233 break;
1235 default:;
1239 if( eLastErr == eERR_OK )
1241 // In some strange circumstances a the codename might be missing
1242 // # Create any missing Sheet CodeNames
1243 std::vector < SCTAB >::iterator it_end = nTabsWithNoCodeName.end();
1244 for ( std::vector < SCTAB >::iterator it = nTabsWithNoCodeName.begin(); it != it_end; ++it )
1246 SCTAB nTab = 1;
1247 OSL_TRACE("Trying to find suitable codename for %d", *it );
1248 while ( true )
1250 OUStringBuffer aBuf;
1251 aBuf.appendAscii("Sheet");
1252 aBuf.append(static_cast<sal_Int32>(nTab++));
1253 OUString sTmpName = aBuf.makeStringAndClear();
1254 std::vector<OUString>::iterator codeName_It = aCodeNames.begin();
1255 std::vector<OUString>::iterator codeName_It_end = aCodeNames.end();
1256 // search for codename
1257 for ( ; codeName_It != codeName_It_end; ++codeName_It )
1259 if ( *codeName_It == sTmpName )
1260 break;
1263 if ( codeName_It == codeName_It_end ) // generated codename not found
1265 OSL_TRACE("Using generated codename %s", OUStringToOString( sTmpName, RTL_TEXTENCODING_UTF8 ).getStr() );
1266 // Set new codename
1267 GetDoc().SetCodeName( *it, sTmpName );
1268 // Record newly used codename
1269 aCodeNames.push_back(sTmpName);
1270 // Record those we have created so they can be created in
1271 // basic
1272 maAutoGeneratedCodeNames.push_back( sTmpName );
1273 break;
1277 // #i45843# Convert pivot tables before calculation, so they are available
1278 // for the GETPIVOTDATA function.
1279 if( GetBiff() == EXC_BIFF8 )
1280 GetPivotTableManager().ConvertPivotTables();
1282 ScDocumentImport& rDoc = GetDocImport();
1283 rDoc.finalize();
1284 pProgress.reset();
1285 #if 0
1286 // Excel documents look much better without this call; better in the
1287 // sense that the row heights are identical to the original heights in
1288 // Excel.
1289 if (pD->IsAdjustHeightEnabled())
1290 AdjustRowHeight();
1291 #endif
1292 PostDocLoad();
1294 pD->CalcAfterLoad(false);
1296 // import change tracking data
1297 XclImpChangeTrack aImpChTr( GetRoot(), maStrm );
1298 aImpChTr.Apply();
1300 const XclImpAddressConverter& rAddrConv = GetAddressConverter();
1301 if( rAddrConv.IsTabTruncated() )
1302 eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
1303 else if( bTabTruncated || rAddrConv.IsRowTruncated() )
1304 eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
1305 else if( rAddrConv.IsColTruncated() )
1306 eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
1308 if( GetBiff() == EXC_BIFF8 )
1309 GetPivotTableManager().MaybeRefreshPivotTables();
1312 return eLastErr;
1315 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */