Update ooo320-m1
[ooovba.git] / sc / source / filter / excel / read.cxx
blob02e9058c004d2de0e603fe8806e4b12f8475639d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: read.cxx,v $
10 * $Revision: 1.70.88.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //------------------------------------------------------------------------
38 #include <stdlib.h>
39 #include <stdio.h>
41 #include "document.hxx"
42 #include "scerrors.hxx"
43 #include "fprogressbar.hxx"
44 #include "xltracer.hxx"
45 #include "xltable.hxx"
46 #include "xihelper.hxx"
47 #include "xipage.hxx"
48 #include "xiview.hxx"
49 #include "xilink.hxx"
50 #include "xiname.hxx"
51 #include "xicontent.hxx"
52 #include "xiescher.hxx"
53 #include "xipivot.hxx"
54 #include "XclImpChangeTrack.hxx"
56 #include "root.hxx"
57 #include "imp_op.hxx"
58 #include "excimp8.hxx"
60 FltError ImportExcel::Read( void )
62 XclImpPageSettings& rPageSett = GetPageSettings();
63 XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
64 XclImpPalette& rPal = GetPalette();
65 XclImpFontBuffer& rFontBfr = GetFontBuffer();
66 XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
67 XclImpXFBuffer& rXFBfr = GetXFBuffer();
68 XclImpNameManager& rNameMgr = GetNameManager();
69 XclImpObjectManager& rObjMgr = GetObjectManager();
71 enum Zustand {
72 Z_BiffNull, // Nicht in gueltigem Biff-Format
73 Z_Biff2, // Biff2: nur eine Tabelle
75 Z_Biff3, // Biff3: nur eine Tabelle
77 Z_Biff4, // Biff4: nur eine Tabelle
78 Z_Biff4W, // Biff4 Workbook: Globals
79 Z_Biff4T, // Biff4 Workbook: eine Tabelle selbst
80 Z_Biff4E, // Biff4 Workbook: zwischen den Tabellen
82 Z_Biff5WPre,// Biff5: Prefetch Workbook
83 Z_Biff5W, // Biff5: Globals
84 Z_Biff5TPre,// Biff5: Prefetch fuer Shrfmla/Array Formula
85 Z_Biff5T, // Biff5: eine Tabelle selbst
86 Z_Biff5E, // Biff5: zwischen den Tabellen
87 Z_Biffn0, // Alle Biffs: Tabelle bis naechstesss EOF ueberlesen
88 Z_Ende };
90 Zustand eAkt = Z_BiffNull, ePrev = Z_BiffNull;
92 FltError eLastErr = eERR_OK;
93 UINT16 nOpcode;
94 UINT16 nBofLevel = 0;
95 BOOL bBiff4Workbook = FALSE;
97 DBG_ASSERT( &aIn != NULL, "-ImportExcel::Read(): Kein Stream - wie dass?!" );
99 ::std::auto_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
100 aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
102 /* #i104057# Need to track a base position for progress bar calculation,
103 because sheet substreams may not be in order of sheets. */
104 sal_Size nProgressBasePos = 0;
105 sal_Size nProgressBaseSize = 0;
107 while( eAkt != Z_Ende )
109 if( eAkt == Z_Biff5E )
111 sal_uInt16 nScTab = GetCurrScTab();
112 if( nScTab < maSheetOffsets.size() )
114 nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
115 nProgressBasePos = maSheetOffsets[ nScTab ];
116 aIn.StartNextRecord( nProgressBasePos );
118 else
119 eAkt = Z_Ende;
121 else
122 aIn.StartNextRecord();
124 nOpcode = aIn.GetRecId();
126 if( !aIn.IsValid() )
128 // #124240# finalize table if EOF is missing
129 switch( eAkt )
131 case Z_Biff2:
132 case Z_Biff3:
133 case Z_Biff4:
134 case Z_Biff4T:
135 case Z_Biff5TPre:
136 case Z_Biff5T:
137 rNumFmtBfr.CreateScFormats();
138 Eof();
139 break;
140 default:;
142 eAkt = Z_Ende;
143 break;
146 if( eAkt == Z_Ende )
147 break;
149 if( eAkt != Z_Biff5TPre && eAkt != Z_Biff5WPre )
150 pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
152 switch( eAkt )
154 // ----------------------------------------------------------------
155 case Z_BiffNull: // ------------------------------- Z_BiffNull -
157 switch( nOpcode )
159 case EXC_ID2_BOF:
160 case EXC_ID3_BOF:
161 case EXC_ID4_BOF:
162 case EXC_ID5_BOF:
164 // #i23425# don't rely on the record ID, but on the detected BIFF version
165 switch( GetBiff() )
167 case EXC_BIFF2:
168 Bof2();
169 if( pExcRoot->eDateiTyp == Biff2 )
171 eAkt = Z_Biff2;
172 NeueTabelle();
174 break;
175 case EXC_BIFF3:
176 Bof3();
177 if( pExcRoot->eDateiTyp == Biff3 )
179 eAkt = Z_Biff3;
180 NeueTabelle();
182 break;
183 case EXC_BIFF4:
184 Bof4();
185 if( pExcRoot->eDateiTyp == Biff4 )
187 eAkt = Z_Biff4;
188 NeueTabelle();
190 else if( pExcRoot->eDateiTyp == Biff4W )
192 eAkt = Z_Biff4W;
193 bBiff4Workbook = TRUE;
195 break;
196 case EXC_BIFF5:
197 Bof5();
198 if( pExcRoot->eDateiTyp == Biff5W )
200 eAkt = Z_Biff5WPre;
202 nBdshtTab = 0;
204 aIn.StoreGlobalPosition(); // und Position merken
206 else if( pExcRoot->eDateiTyp == Biff5 )
208 // #i62752# possible to have BIFF5 sheet without globals
209 NeueTabelle();
210 eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
211 nBofLevel = 0;
212 aIn.StoreGlobalPosition(); // und Position merken
214 break;
215 default:
216 DBG_ERROR_BIFF();
219 break;
222 break;
223 // ----------------------------------------------------------------
224 case Z_Biff2: // ---------------------------------- Z_Biff2 -
226 switch( nOpcode )
228 case EXC_ID2_DIMENSIONS:
229 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
230 case EXC_ID2_BLANK:
231 case EXC_ID3_BLANK: ReadBlank(); break;
232 case EXC_ID2_INTEGER: ReadInteger(); break;
233 case EXC_ID2_NUMBER:
234 case EXC_ID3_NUMBER: ReadNumber(); break;
235 case EXC_ID2_LABEL:
236 case EXC_ID3_LABEL: ReadLabel(); break;
237 case EXC_ID2_BOOLERR:
238 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
239 case EXC_ID_RK: ReadRk(); break;
241 case 0x06: Formula25(); break; // FORMULA [ 2 5]
242 case 0x08: Row25(); break; // ROW [ 2 5]
243 case 0x0A: // EOF [ 2345]
244 rNumFmtBfr.CreateScFormats();
245 Eof();
246 eAkt = Z_Ende;
247 break;
248 case 0x14:
249 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
250 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
251 case 0x18: rNameMgr.ReadName( maStrm ); break;
252 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
253 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
254 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
255 case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ]
256 case 0x21: Array25(); break; // ARRAY [ 2 5]
257 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
258 case 0x24: Colwidth(); break; // COLWIDTH [ 2 ]
259 case 0x25: Defrowheight2(); break; // DEFAULTROWHEI[ 2 ]
260 case 0x26:
261 case 0x27:
262 case 0x28:
263 case 0x29: rPageSett.ReadMargin( maStrm ); break;
264 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
265 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
266 case 0x2F: // FILEPASS [ 2345]
267 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
268 if( eLastErr != ERRCODE_NONE )
269 eAkt = Z_Ende;
270 break;
271 case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
272 case EXC_ID_EFONT: rFontBfr.ReadEfont( maStrm ); break;
273 case 0x3E: rTabViewSett.ReadWindow2( maStrm, false );break;
274 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
275 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
276 case 0x43: rXFBfr.ReadXF( maStrm ); break;
277 case 0x44: Ixfe(); break; // IXFE [ 2 ]
280 break;
281 // ----------------------------------------------------------------
282 case Z_Biff3: // ---------------------------------- Z_Biff3 -
284 switch( nOpcode )
286 // skip chart substream
287 case EXC_ID2_BOF:
288 case EXC_ID3_BOF:
289 case EXC_ID4_BOF:
290 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
292 case EXC_ID2_DIMENSIONS:
293 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
294 case EXC_ID2_BLANK:
295 case EXC_ID3_BLANK: ReadBlank(); break;
296 case EXC_ID2_INTEGER: ReadInteger(); break;
297 case EXC_ID2_NUMBER:
298 case EXC_ID3_NUMBER: ReadNumber(); break;
299 case EXC_ID2_LABEL:
300 case EXC_ID3_LABEL: ReadLabel(); break;
301 case EXC_ID2_BOOLERR:
302 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
303 case EXC_ID_RK: ReadRk(); break;
305 case 0x0A: // EOF [ 2345]
306 rNumFmtBfr.CreateScFormats();
307 Eof();
308 eAkt = Z_Ende;
309 break;
310 case 0x14:
311 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
312 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
313 case 0x1A:
314 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
315 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
316 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
317 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
318 case 0x22: Rec1904(); break; // 1904 [ 2345]
319 case 0x26:
320 case 0x27:
321 case 0x28:
322 case 0x29: rPageSett.ReadMargin( maStrm ); break;
323 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
324 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
325 case 0x2F: // FILEPASS [ 2345]
326 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
327 if( eLastErr != ERRCODE_NONE )
328 eAkt = Z_Ende;
329 break;
330 case EXC_ID_FILESHARING: ReadFileSharing(); break;
331 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
332 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
333 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
334 case 0x5D: rObjMgr.ReadObj( maStrm ); break;
335 case 0x7D: Colinfo(); break; // COLINFO [ 345]
336 case 0x8C: Country(); break; // COUNTRY [ 345]
337 case 0x92: rPal.ReadPalette( maStrm ); break;
338 case 0x0206: Formula3(); break; // FORMULA [ 3 ]
339 case 0x0208: Row34(); break; // ROW [ 34 ]
340 case 0x0218: rNameMgr.ReadName( maStrm ); break;
341 case 0x0221: Array34(); break; // ARRAY [ 34 ]
342 case 0x0223: Externname34(); break; // EXTERNNAME [ 34 ]
343 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
344 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
345 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
346 case 0x0243: rXFBfr.ReadXF( maStrm ); break;
347 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
350 break;
351 // ----------------------------------------------------------------
352 case Z_Biff4: // ---------------------------------- Z_Biff4 -
354 switch( nOpcode )
356 // skip chart substream
357 case EXC_ID2_BOF:
358 case EXC_ID3_BOF:
359 case EXC_ID4_BOF:
360 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
362 case EXC_ID2_DIMENSIONS:
363 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
364 case EXC_ID2_BLANK:
365 case EXC_ID3_BLANK: ReadBlank(); break;
366 case EXC_ID2_INTEGER: ReadInteger(); break;
367 case EXC_ID2_NUMBER:
368 case EXC_ID3_NUMBER: ReadNumber(); break;
369 case EXC_ID2_LABEL:
370 case EXC_ID3_LABEL: ReadLabel(); break;
371 case EXC_ID2_BOOLERR:
372 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
373 case EXC_ID_RK: ReadRk(); break;
375 case 0x0A: // EOF [ 2345]
376 rNumFmtBfr.CreateScFormats();
377 Eof();
378 eAkt = Z_Ende;
379 break;
380 case 0x12: SheetProtect(); break; // SHEET PROTECTION
381 case 0x14:
382 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
383 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
384 case 0x1A:
385 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
386 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
387 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
388 case 0x22: Rec1904(); break; // 1904 [ 2345]
389 case 0x26:
390 case 0x27:
391 case 0x28:
392 case 0x29: rPageSett.ReadMargin( maStrm ); break;
393 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
394 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
395 case 0x2F: // FILEPASS [ 2345]
396 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
397 if( eLastErr != ERRCODE_NONE )
398 eAkt = Z_Ende;
399 break;
400 case EXC_ID_FILESHARING: ReadFileSharing(); break;
401 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
402 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
403 case 0x55: DefColWidth(); break;
404 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
405 case 0x5D: rObjMgr.ReadObj( maStrm ); break;
406 case 0x7D: Colinfo(); break; // COLINFO [ 345]
407 case 0x8C: Country(); break; // COUNTRY [ 345]
408 case 0x92: rPal.ReadPalette( maStrm ); break;
409 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
410 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
411 case 0x0208: Row34(); break; // ROW [ 34 ]
412 case 0x0218: rNameMgr.ReadName( maStrm ); break;
413 case 0x0221: Array34(); break; // ARRAY [ 34 ]
414 case 0x0223: Externname34(); break; // EXTERNNAME [ 34 ]
415 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
416 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
417 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
418 case 0x0406: Formula4(); break; // FORMULA [ 4 ]
419 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
420 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
421 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
424 break;
425 // ----------------------------------------------------------------
426 case Z_Biff4W: // --------------------------------- Z_Biff4W -
428 switch( nOpcode )
430 case 0x0A: // EOF [ 2345]
431 eAkt = Z_Ende;
432 break;
433 case 0x12: DocProtect(); break; // PROTECT [ 5]
434 case 0x2F: // FILEPASS [ 2345]
435 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
436 if( eLastErr != ERRCODE_NONE )
437 eAkt = Z_Ende;
438 break;
439 case EXC_ID_FILESHARING: ReadFileSharing(); break;
440 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
441 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
442 case 0x55: DefColWidth(); break;
443 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
444 case 0x8C: Country(); break; // COUNTRY [ 345]
445 case 0x8F: Bundleheader(); break; // BUNDLEHEADER [ 4 ]
446 case 0x92: rPal.ReadPalette( maStrm ); break;
447 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
448 case 0x0218: rNameMgr.ReadName( maStrm ); break;
449 case 0x0223: Externname34(); break; // EXTERNNAME [ 34 ]
450 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
451 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
452 case 0x0409: // BOF [ 4 ]
453 Bof4();
454 if( pExcRoot->eDateiTyp == Biff4 )
456 eAkt = Z_Biff4T;
457 NeueTabelle();
459 else
460 eAkt = Z_Ende;
461 break;
462 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
463 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
464 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
468 break;
469 // ----------------------------------------------------------------
470 case Z_Biff4T: // --------------------------------- Z_Biff4T -
472 switch( nOpcode )
474 // skip chart substream
475 case EXC_ID2_BOF:
476 case EXC_ID3_BOF:
477 case EXC_ID4_BOF:
478 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
480 case EXC_ID2_DIMENSIONS:
481 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
482 case EXC_ID2_BLANK:
483 case EXC_ID3_BLANK: ReadBlank(); break;
484 case EXC_ID2_INTEGER: ReadInteger(); break;
485 case EXC_ID2_NUMBER:
486 case EXC_ID3_NUMBER: ReadNumber(); break;
487 case EXC_ID2_LABEL:
488 case EXC_ID3_LABEL: ReadLabel(); break;
489 case EXC_ID2_BOOLERR:
490 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
491 case EXC_ID_RK: ReadRk(); break;
493 case 0x0A: // EOF [ 2345]
494 Eof();
495 eAkt = Z_Biff4E;
496 break;
497 case 0x12: SheetProtect(); break; // SHEET PROTECTION
498 case 0x14:
499 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
500 case 0x1A:
501 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
502 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
503 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
504 case 0x2F: // FILEPASS [ 2345]
505 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
506 if( eLastErr != ERRCODE_NONE )
507 eAkt = Z_Ende;
508 break;
509 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
510 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
511 case 0x55: DefColWidth(); break;
512 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
513 case 0x5D: rObjMgr.ReadObj( maStrm ); break;
514 case 0x7D: Colinfo(); break; // COLINFO [ 345]
515 case 0x8C: Country(); break; // COUNTRY [ 345]
516 case 0x8F: Bundleheader(); break; // BUNDLEHEADER [ 4 ]
517 case 0x92: rPal.ReadPalette( maStrm ); break;
518 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
519 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
520 case 0x0208: Row34(); break; // ROW [ 34 ]
521 case 0x0218: rNameMgr.ReadName( maStrm ); break;
522 case 0x0221: Array34(); break;
523 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
524 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
525 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
526 case 0x0406: Formula4(); break;
527 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
528 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
529 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
533 break;
534 // ----------------------------------------------------------------
535 case Z_Biff4E: // --------------------------------- Z_Biff4E -
537 switch( nOpcode )
539 case 0x0A: // EOF [ 2345]
540 eAkt = Z_Ende;
541 break;
542 case 0x8F: break; // BUNDLEHEADER [ 4 ]
543 case 0x0409: // BOF [ 4 ]
544 Bof4();
545 NeueTabelle();
546 if( pExcRoot->eDateiTyp == Biff4 )
548 eAkt = Z_Biff4T;
550 else
552 ePrev = eAkt;
553 eAkt = Z_Biffn0;
555 break;
559 break;
560 case Z_Biff5WPre: // ------------------------------ Z_Biff5WPre -
562 switch( nOpcode )
564 case 0x0A: // EOF [ 2345]
565 eAkt = Z_Biff5W;
566 aIn.SeekGlobalPosition(); // und zurueck an alte Position
567 break;
568 case 0x12: DocProtect(); break; // PROTECT [ 5]
569 case 0x2F: // FILEPASS [ 2345]
570 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
571 if( eLastErr != ERRCODE_NONE )
572 eAkt = Z_Ende;
573 break;
574 case EXC_ID_FILESHARING: ReadFileSharing(); break;
575 case 0x3D: Window1(); break;
576 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
577 case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5]
578 case 0x8C: Country(); break; // COUNTRY [ 345]
579 // PALETTE follows XFs, but already needed while reading the XFs
580 case 0x92: rPal.ReadPalette( maStrm ); break;
583 break;
584 case Z_Biff5W: // --------------------------------- Z_Biff5W -
586 switch( nOpcode )
588 case 0x0A: // EOF [ 2345]
589 rNumFmtBfr.CreateScFormats();
590 rXFBfr.CreateUserStyles();
591 eAkt = Z_Biff5E;
592 break;
593 case 0x18: rNameMgr.ReadName( maStrm ); break;
594 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
595 case 0x22: Rec1904(); break; // 1904 [ 2345]
596 case 0x31: rFontBfr.ReadFont( maStrm ); break;
597 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
598 case 0x8D: Hideobj(); break; // HIDEOBJ [ 345]
599 case 0xDE: Olesize(); break;
600 case 0xE0: rXFBfr.ReadXF( maStrm ); break;
601 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
602 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
606 break;
607 // ----------------------------------------------------------------
608 case Z_Biff5TPre: // ------------------------------- Z_Biff5Pre -
610 if( nOpcode == 0x0809 )
611 nBofLevel++;
612 else if( (nOpcode == 0x000A) && nBofLevel )
613 nBofLevel--;
614 else if( !nBofLevel ) // don't read chart records
616 switch( nOpcode )
618 case EXC_ID2_DIMENSIONS:
619 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
620 case 0x08: Row25(); break; // ROW [ 2 5]
621 case 0x0A: // EOF [ 2345]
622 eAkt = Z_Biff5T;
623 aIn.SeekGlobalPosition(); // und zurueck an alte Position
624 break;
625 case 0x12: SheetProtect(); break; // SHEET PROTECTION
626 case 0x1A:
627 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
628 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
629 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
630 case 0x21: Array25(); break; // ARRAY [ 2 5]
631 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
632 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
633 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
634 case 0x55: DefColWidth(); break;
635 case 0x7D: Colinfo(); break; // COLINFO [ 345]
636 case 0x81: Wsbool(); break; // WSBOOL [ 2345]
637 case 0x8C: Country(); break; // COUNTRY [ 345]
638 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
639 case 0x0208: Row34(); break; // ROW [ 34 ]
640 case 0x0221: Array34(); break; // ARRAY [ 34 ]
641 case 0x0223: Externname34(); break; // EXTERNNAME [ 34 ]
642 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
643 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
644 case 0x04BC: Shrfmla(); break; // SHRFMLA [ 5]
648 break;
649 // ----------------------------------------------------------------
650 case Z_Biff5T: // --------------------------------- Z_Biff5T -
652 switch( nOpcode )
654 case EXC_ID2_BLANK:
655 case EXC_ID3_BLANK: ReadBlank(); break;
656 case EXC_ID2_INTEGER: ReadInteger(); break;
657 case EXC_ID2_NUMBER:
658 case EXC_ID3_NUMBER: ReadNumber(); break;
659 case EXC_ID2_LABEL:
660 case EXC_ID3_LABEL: ReadLabel(); break;
661 case EXC_ID2_BOOLERR:
662 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
663 case EXC_ID_RK: ReadRk(); break;
665 case 0x0006:
666 case 0x0206:
667 case 0x0406: Formula25(); break;
668 case 0x0A: Eof(); eAkt = Z_Biff5E; break;
669 case 0x14:
670 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
671 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
672 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
673 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
674 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
675 case 0x26:
676 case 0x27:
677 case 0x28:
678 case 0x29: rPageSett.ReadMargin( maStrm ); break;
679 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
680 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
681 case 0x2F: // FILEPASS [ 2345]
682 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
683 if( eLastErr != ERRCODE_NONE )
684 eAkt = Z_Ende;
685 break;
686 case 0x5D: rObjMgr.ReadObj( maStrm ); break;
687 case 0x83:
688 case 0x84: rPageSett.ReadCenter( maStrm ); break;
689 case 0xA0: rTabViewSett.ReadScl( maStrm ); break;
690 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
691 case 0xBD: Mulrk(); break; // MULRK [ 5]
692 case 0xBE: Mulblank(); break; // MULBLANK [ 5]
693 case 0xD6: Rstring(); break; // RSTRING [ 5]
694 case 0x00E5: Cellmerging(); break; // #i62300#
695 case 0x0236: TableOp(); break; // TABLE [ 5]
696 case 0x0809: // BOF [ 5]
697 XclTools::SkipSubStream( maStrm );
698 break;
702 break;
703 // ----------------------------------------------------------------
704 case Z_Biff5E: // --------------------------------- Z_Biff5E -
706 switch( nOpcode )
708 case 0x0809: // BOF [ 5]
709 Bof5();
710 NeueTabelle();
711 switch( pExcRoot->eDateiTyp )
713 case Biff5:
714 case Biff5M4:
715 eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
716 nBofLevel = 0;
717 aIn.StoreGlobalPosition(); // und Position merken
718 break;
719 case Biff5C: // chart sheet
720 GetObjectManager().ReadTabChart( maStrm );
721 Eof();
722 GetTracer().TraceChartOnlySheet();
723 break;
724 case Biff5V:
725 default:
726 pD->SetVisible( GetCurrScTab(), FALSE );
727 ePrev = eAkt;
728 eAkt = Z_Biffn0;
730 DBG_ASSERT( pExcRoot->eDateiTyp != Biff5W,
731 "+ImportExcel::Read(): Doppel-Whopper-Workbook!" );
733 break;
737 break;
738 case Z_Biffn0: // --------------------------------- Z_Biffn0 -
740 switch( nOpcode )
742 case 0x0A: // EOF [ 2345]
743 eAkt = ePrev;
744 IncCurrScTab();
745 break;
749 break;
750 // ----------------------------------------------------------------
751 case Z_Ende: // ----------------------------------- Z_Ende -
752 DBG_ERROR( "*ImportExcel::Read(): Not possible state!" );
753 break;
754 default: DBG_ERROR( "-ImportExcel::Read(): Zustand vergessen!" );
758 if( eLastErr == eERR_OK )
760 pProgress.reset();
762 AdjustRowHeight();
763 PostDocLoad();
765 pD->CalcAfterLoad();
767 const XclImpAddressConverter& rAddrConv = GetAddressConverter();
768 if( rAddrConv.IsTabTruncated() )
769 eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
770 else if( bTabTruncated || rAddrConv.IsRowTruncated() )
771 eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
772 else if( rAddrConv.IsColTruncated() )
773 eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
776 return eLastErr;
780 //___________________________________________________________________
782 FltError ImportExcel8::Read( void )
784 #if EXC_INCL_DUMPER
786 Biff8RecDumper aDumper( GetRoot(), TRUE );
787 if( aDumper.Dump( aIn ) )
788 return ERRCODE_ABORT;
790 #endif
791 // read the entire BIFF8 stream
792 // don't look too close - this stuff seriously needs to be reworked
794 XclImpPageSettings& rPageSett = GetPageSettings();
795 XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
796 XclImpPalette& rPal = GetPalette();
797 XclImpFontBuffer& rFontBfr = GetFontBuffer();
798 XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
799 XclImpXFBuffer& rXFBfr = GetXFBuffer();
800 XclImpSst& rSst = GetSst();
801 XclImpTabInfo& rTabInfo = GetTabInfo();
802 XclImpNameManager& rNameMgr = GetNameManager();
803 XclImpLinkManager& rLinkMgr = GetLinkManager();
804 XclImpObjectManager& rObjMgr = GetObjectManager();
805 XclImpCondFormatManager& rCondFmtMgr = GetCondFormatManager();
806 XclImpPivotTableManager& rPTableMgr = GetPivotTableManager();
807 XclImpWebQueryBuffer& rWQBfr = GetWebQueryBuffer();
809 bool bInUserView = false; // true = In USERSVIEW(BEGIN|END) record block.
811 enum XclImpReadState
813 EXC_STATE_BEFORE_GLOBALS, /// Before workbook globals (wait for initial BOF).
814 EXC_STATE_GLOBALS_PRE, /// Prefetch for workbook globals.
815 EXC_STATE_GLOBALS, /// Workbook globals.
816 EXC_STATE_BEFORE_SHEET, /// Before worksheet (wait for new worksheet BOF).
817 EXC_STATE_SHEET_PRE, /// Prefetch for worksheet.
818 EXC_STATE_SHEET, /// Worksheet.
819 EXC_STATE_END /// Stop reading.
822 XclImpReadState eAkt = EXC_STATE_BEFORE_GLOBALS;
824 FltError eLastErr = eERR_OK;
826 ::std::auto_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
827 aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
829 /* #i104057# Need to track a base position for progress bar calculation,
830 because sheet substreams may not be in order of sheets. */
831 sal_Size nProgressBasePos = 0;
832 sal_Size nProgressBaseSize = 0;
834 bool bSheetHasCodeName = false;
836 std::vector< String > CodeNames;
838 std::vector < SCTAB > nTabsWithNoCodeName;
840 while( eAkt != EXC_STATE_END )
842 if( eAkt == EXC_STATE_BEFORE_SHEET )
844 sal_uInt16 nScTab = GetCurrScTab();
845 if( nScTab < maSheetOffsets.size() )
847 nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
848 nProgressBasePos = maSheetOffsets[ nScTab ];
849 aIn.StartNextRecord( nProgressBasePos );
851 else
852 eAkt = EXC_STATE_END;
854 else
855 aIn.StartNextRecord();
857 if( !aIn.IsValid() )
859 // #124240# #i63591# finalize table if EOF is missing
860 switch( eAkt )
862 case EXC_STATE_SHEET_PRE:
863 eAkt = EXC_STATE_SHEET;
864 aIn.SeekGlobalPosition();
865 continue; // next iteration in while loop
866 // break; // unxsols warning: statement unreachable
867 case EXC_STATE_SHEET:
868 Eof();
869 eAkt = EXC_STATE_END;
870 break;
871 default:
872 eAkt = EXC_STATE_END;
876 if( eAkt == EXC_STATE_END )
877 break;
879 if( eAkt != EXC_STATE_SHEET_PRE && eAkt != EXC_STATE_GLOBALS_PRE )
880 pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
882 sal_uInt16 nRecId = aIn.GetRecId();
884 /* #i39464# Ignore records between USERSVIEWBEGIN and USERSVIEWEND
885 completely (user specific view settings). Otherwise view settings
886 and filters are loaded multiple times, which at least causes
887 problems in auto-filters. */
888 switch( nRecId )
890 case EXC_ID_USERSVIEWBEGIN:
891 DBG_ASSERT( !bInUserView, "ImportExcel8::Read - nested user view settings" );
892 bInUserView = true;
893 break;
894 case EXC_ID_USERSVIEWEND:
895 DBG_ASSERT( bInUserView, "ImportExcel8::Read - not in user view settings" );
896 bInUserView = false;
897 break;
900 if( !bInUserView ) switch( eAkt )
902 // ----------------------------------------------------------------
903 // before workbook globals: wait for initial workbook globals BOF
904 case EXC_STATE_BEFORE_GLOBALS:
906 if( nRecId == EXC_ID5_BOF )
908 DBG_ASSERT( GetBiff() == EXC_BIFF8, "ImportExcel8::Read - wrong BIFF version" );
909 Bof5();
910 if( pExcRoot->eDateiTyp == Biff8W )
912 eAkt = EXC_STATE_GLOBALS_PRE;
913 maStrm.StoreGlobalPosition();
914 nBdshtTab = 0;
916 else if( pExcRoot->eDateiTyp == Biff8 )
918 // #i62752# possible to have BIFF8 sheet without globals
919 NeueTabelle();
920 eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
921 bSheetHasCodeName = false; // reset
922 aIn.StoreGlobalPosition();
926 break;
928 // ----------------------------------------------------------------
929 // prefetch for workbook globals
930 case EXC_STATE_GLOBALS_PRE:
932 switch( nRecId )
934 case EXC_ID_EOF:
935 case EXC_ID_EXTSST:
936 /* #i56376# evil hack: if EOF for globals is missing,
937 simulate it. This hack works only for the bugdoc
938 given in the issue, where the sheet substreams
939 start directly after the EXTSST record. A future
940 implementation should be more robust against
941 missing EOFs. */
942 if( (nRecId == EXC_ID_EOF) ||
943 ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
945 eAkt = EXC_STATE_GLOBALS;
946 aIn.SeekGlobalPosition();
948 break;
949 case 0x12: DocProtect(); break; // PROTECT [ 5678]
950 case 0x13: DocPasssword(); break;
951 case 0x19: WinProtection(); break;
952 case 0x2F: // FILEPASS [ 2345 ]
953 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
954 if( eLastErr != ERRCODE_NONE )
955 eAkt = EXC_STATE_END;
956 break;
957 case EXC_ID_FILESHARING: ReadFileSharing(); break;
958 case 0x3D: Window1(); break;
959 case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
960 case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5 ]
961 case 0x8C: Country(); break; // COUNTRY [ 345 ]
963 // PALETTE follows XFs, but already needed while reading the XFs
964 case EXC_ID_PALETTE: rPal.ReadPalette( maStrm ); break;
967 break;
969 // ----------------------------------------------------------------
970 // workbook globals
971 case EXC_STATE_GLOBALS:
973 switch( nRecId )
975 case EXC_ID_EOF:
976 case EXC_ID_EXTSST:
977 /* #i56376# evil hack: if EOF for globals is missing,
978 simulate it. This hack works only for the bugdoc
979 given in the issue, where the sheet substreams
980 start directly after the EXTSST record. A future
981 implementation should be more robust against
982 missing EOFs. */
983 if( (nRecId == EXC_ID_EOF) ||
984 ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
986 rNumFmtBfr.CreateScFormats();
987 rXFBfr.CreateUserStyles();
988 rPTableMgr.ReadPivotCaches( maStrm );
989 eAkt = EXC_STATE_BEFORE_SHEET;
991 break;
992 case 0x0E: Precision(); break; // PRECISION
993 case 0x22: Rec1904(); break; // 1904 [ 2345 ]
994 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
995 case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ]
996 case 0xD3: /*ReadBasic()*/bHasBasic = true; break;
997 // case 0xD3: ReadBasic(); break;
998 case 0xDE: Olesize(); break;
999 case 0x01BA: Codename( TRUE ); break;
1001 case EXC_ID_USESELFS: ReadUsesElfs(); break;
1003 case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
1004 case EXC_ID4_FORMAT: rNumFmtBfr.ReadFormat( maStrm ); break;
1005 case EXC_ID5_XF: rXFBfr.ReadXF( maStrm ); break;
1006 case EXC_ID_STYLE: rXFBfr.ReadStyle( maStrm ); break;
1008 case EXC_ID_SST: rSst.ReadSst( maStrm ); break;
1009 case EXC_ID_TABID: rTabInfo.ReadTabid( maStrm ); break;
1010 case EXC_ID_NAME: rNameMgr.ReadName( maStrm ); break;
1012 case EXC_ID_EXTERNSHEET: rLinkMgr.ReadExternsheet( maStrm ); break;
1013 case EXC_ID_SUPBOOK: rLinkMgr.ReadSupbook( maStrm ); break;
1014 case EXC_ID_XCT: rLinkMgr.ReadXct( maStrm ); break;
1015 case EXC_ID_CRN: rLinkMgr.ReadCrn( maStrm ); break;
1016 case EXC_ID_EXTERNNAME: rLinkMgr.ReadExternname( maStrm, pFormConv ); break;
1018 case EXC_ID_MSODRAWINGGROUP:rObjMgr.ReadMsoDrawingGroup( maStrm ); break;
1020 case EXC_ID_SXIDSTM: rPTableMgr.ReadSxidstm( maStrm ); break;
1021 case EXC_ID_SXVS: rPTableMgr.ReadSxvs( maStrm ); break;
1022 case EXC_ID_DCONREF: rPTableMgr.ReadDconref( maStrm ); break;
1026 break;
1028 // ----------------------------------------------------------------
1029 // before worksheet: wait for new worksheet BOF
1030 case EXC_STATE_BEFORE_SHEET:
1032 if( nRecId == EXC_ID5_BOF )
1034 // #94191# import only 256 sheets
1035 if( GetCurrScTab() > GetScMaxPos().Tab() )
1037 XclTools::SkipSubStream( maStrm );
1038 // #i29930# show warning box
1039 GetAddressConverter().CheckScTab( GetCurrScTab(), true );
1040 eAkt = EXC_STATE_END;
1042 else
1044 Bof5();
1045 NeueTabelle();
1046 switch( pExcRoot->eDateiTyp )
1048 case Biff8: // worksheet
1049 case Biff8M4: // macro sheet
1050 eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
1051 aIn.StoreGlobalPosition();
1052 break;
1053 case Biff8C: // chart sheet
1054 rObjMgr.ReadTabChart( maStrm );
1055 Eof();
1056 GetTracer().TraceChartOnlySheet();
1057 break;
1058 case Biff8W: // workbook
1059 DBG_ERRORFILE( "ImportExcel8::Read - double workbook globals" );
1060 // run through
1061 case Biff8V: // VB module
1062 default:
1063 // TODO: do not create a sheet in the Calc document
1064 pD->SetVisible( GetCurrScTab(), FALSE );
1065 XclTools::SkipSubStream( maStrm );
1066 IncCurrScTab();
1071 break;
1073 // ----------------------------------------------------------------
1074 // prefetch for worksheet
1075 case EXC_STATE_SHEET_PRE:
1077 switch( nRecId )
1079 // skip chart substream
1080 case EXC_ID2_BOF:
1081 case EXC_ID3_BOF:
1082 case EXC_ID4_BOF:
1083 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
1085 case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( maStrm, false );break;
1086 case EXC_ID_SCL: rTabViewSett.ReadScl( maStrm ); break;
1087 case EXC_ID_PANE: rTabViewSett.ReadPane( maStrm ); break;
1088 case EXC_ID_SELECTION: rTabViewSett.ReadSelection( maStrm ); break;
1090 case EXC_ID2_DIMENSIONS:
1091 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
1093 case 0x0A: // EOF [ 2345 ]
1095 eAkt = EXC_STATE_SHEET;
1096 String sName;
1097 GetDoc().GetName( GetCurrScTab(), sName );
1098 if ( !bSheetHasCodeName )
1100 nTabsWithNoCodeName.push_back( GetCurrScTab() );
1101 OSL_TRACE("No Codename for %d", GetCurrScTab() );
1103 else
1105 String sCodeName;
1106 GetDoc().GetCodeName( GetCurrScTab(), sCodeName );
1107 OSL_TRACE("Have CodeName %s for SheetName %s",
1108 rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
1109 CodeNames.push_back( sCodeName );
1112 bSheetHasCodeName = false; // reset
1115 aIn.SeekGlobalPosition(); // und zurueck an alte Position
1116 break;
1118 case 0x12: SheetProtect(); break;
1119 case 0x13: SheetPassword(); break;
1120 case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
1121 case 0x55: DefColWidth(); break;
1122 case 0x7D: Colinfo(); break; // COLINFO [ 345 ]
1123 case 0x81: Wsbool(); break; // WSBOOL [ 2345 ]
1124 case 0x8C: Country(); break; // COUNTRY [ 345 ]
1125 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45 ]
1126 case 0x9B: FilterMode(); break; // FILTERMODE
1127 case 0x9D: AutoFilterInfo(); break;// AUTOFILTERINFO
1128 case 0x9E: AutoFilter(); break; // AUTOFILTER
1129 case 0x01BA: Codename( FALSE ); bSheetHasCodeName = true; break;
1130 case 0x0208: Row34(); break; // ROW [ 34 ]
1131 case 0x0021:
1132 case 0x0221: Array34(); break; // ARRAY [ 34 ]
1133 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345 ]
1134 case 0x04BC: Shrfmla(); break; // SHRFMLA [ 5 ]
1135 case 0x0867: SheetProtection(); break; // SHEETPROTECTION
1138 break;
1140 // ----------------------------------------------------------------
1141 // worksheet
1142 case EXC_STATE_SHEET:
1144 switch( nRecId )
1146 // skip unknown substreams
1147 case EXC_ID2_BOF:
1148 case EXC_ID3_BOF:
1149 case EXC_ID4_BOF:
1150 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
1152 case EXC_ID_EOF: Eof(); eAkt = EXC_STATE_BEFORE_SHEET; break;
1154 case EXC_ID2_BLANK:
1155 case EXC_ID3_BLANK: ReadBlank(); break;
1156 case EXC_ID2_INTEGER: ReadInteger(); break;
1157 case EXC_ID2_NUMBER:
1158 case EXC_ID3_NUMBER: ReadNumber(); break;
1159 case EXC_ID2_LABEL:
1160 case EXC_ID3_LABEL: ReadLabel(); break;
1161 case EXC_ID2_BOOLERR:
1162 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
1163 case EXC_ID_RK: ReadRk(); break;
1165 case 0x0006:
1166 case 0x0206:
1167 case 0x0406: Formula25(); break; // FORMULA [ 2 5 ]
1168 case 0x000C: Calccount(); break; // CALCCOUNT
1169 case 0x0010: Delta(); break; // DELTA
1170 case 0x0011: Iteration(); break; // ITERATION
1171 case 0x007E:
1172 case 0x00AE: Scenman(); break; // SCENMAN
1173 case 0x00AF: Scenario(); break; // SCENARIO
1174 case 0x00BD: Mulrk(); break; // MULRK [ 5 ]
1175 case 0x00BE: Mulblank(); break; // MULBLANK [ 5 ]
1176 case 0x00D6: Rstring(); break; // RSTRING [ 5 ]
1177 case 0x00E5: Cellmerging(); break; // CELLMERGING
1178 case 0x00FD: Labelsst(); break; // LABELSST [ 8 ]
1179 case 0x0236: TableOp(); break; // TABLE
1181 case EXC_ID_HORPAGEBREAKS:
1182 case EXC_ID_VERPAGEBREAKS: rPageSett.ReadPageBreaks( maStrm ); break;
1183 case EXC_ID_HEADER:
1184 case EXC_ID_FOOTER: rPageSett.ReadHeaderFooter( maStrm ); break;
1185 case EXC_ID_LEFTMARGIN:
1186 case EXC_ID_RIGHTMARGIN:
1187 case EXC_ID_TOPMARGIN:
1188 case EXC_ID_BOTTOMMARGIN: rPageSett.ReadMargin( maStrm ); break;
1189 case EXC_ID_PRINTHEADERS: rPageSett.ReadPrintHeaders( maStrm ); break;
1190 case EXC_ID_PRINTGRIDLINES: rPageSett.ReadPrintGridLines( maStrm ); break;
1191 case EXC_ID_HCENTER:
1192 case EXC_ID_VCENTER: rPageSett.ReadCenter( maStrm ); break;
1193 case EXC_ID_SETUP: rPageSett.ReadSetup( maStrm ); break;
1194 case EXC_ID8_IMGDATA: rPageSett.ReadImgData( maStrm ); break;
1196 case EXC_ID_MSODRAWING: rObjMgr.ReadMsoDrawing( maStrm ); break;
1197 // #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format
1198 case EXC_ID_OBJ: rObjMgr.ReadObj( maStrm ); break;
1199 case EXC_ID_NOTE: rObjMgr.ReadNote( maStrm ); break;
1201 case EXC_ID_HLINK: XclImpHyperlink::ReadHlink( maStrm ); break;
1202 case EXC_ID_LABELRANGES: XclImpLabelranges::ReadLabelranges( maStrm ); break;
1204 case EXC_ID_CONDFMT: rCondFmtMgr.ReadCondfmt( maStrm ); break;
1205 case EXC_ID_CF: rCondFmtMgr.ReadCF( maStrm ); break;
1207 case EXC_ID_DVAL: XclImpValidation::ReadDval( maStrm ); break;
1208 case EXC_ID_DV: XclImpValidation::ReadDV( maStrm ); break;
1210 case EXC_ID_QSI: rWQBfr.ReadQsi( maStrm ); break;
1211 case EXC_ID_WQSTRING: rWQBfr.ReadWqstring( maStrm ); break;
1212 case EXC_ID_PQRY: rWQBfr.ReadParamqry( maStrm ); break;
1213 case EXC_ID_WQSETT: rWQBfr.ReadWqsettings( maStrm ); break;
1214 case EXC_ID_WQTABLES: rWQBfr.ReadWqtables( maStrm ); break;
1216 case EXC_ID_SXVIEW: rPTableMgr.ReadSxview( maStrm ); break;
1217 case EXC_ID_SXVD: rPTableMgr.ReadSxvd( maStrm ); break;
1218 case EXC_ID_SXVI: rPTableMgr.ReadSxvi( maStrm ); break;
1219 case EXC_ID_SXIVD: rPTableMgr.ReadSxivd( maStrm ); break;
1220 case EXC_ID_SXPI: rPTableMgr.ReadSxpi( maStrm ); break;
1221 case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break;
1222 case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break;
1223 case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break;
1224 case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break;
1226 // 0x0862 (SHEETEXT)
1227 case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break;
1230 break;
1232 // ----------------------------------------------------------------
1233 default:;
1237 if( eLastErr == eERR_OK )
1239 // In some strange circumstances a the codename might be missing
1240 // # Create any missing Sheet CodeNames
1241 std::vector < SCTAB >::iterator it_end = nTabsWithNoCodeName.end();
1242 for ( std::vector < SCTAB >::iterator it = nTabsWithNoCodeName.begin(); it != it_end; ++it )
1244 bool bGotCodeName = false;
1245 SCTAB nTab = 1;
1246 OSL_TRACE("Trying to find suitable codename for %d", *it );
1247 while ( true )
1249 String sTmpName( RTL_CONSTASCII_USTRINGPARAM("Sheet" ) );
1250 sTmpName += String::CreateFromInt32( sal_Int32(nTab++) );
1251 std::vector< String >::iterator codeName_It = CodeNames.begin();
1252 std::vector< String >::iterator codeName_It_end = CodeNames.end();
1253 // search for codename
1254 for ( ; codeName_It != codeName_It_end; ++codeName_It )
1256 if ( *codeName_It == sTmpName )
1257 break;
1260 if ( codeName_It == codeName_It_end ) // generated codename not found
1262 OSL_TRACE("Using generated codename %s", rtl::OUStringToOString( sTmpName, RTL_TEXTENCODING_UTF8 ).getStr() );
1263 // Set new codename
1264 GetDoc().SetCodeName( *it, sTmpName );
1265 // Record newly used codename
1266 CodeNames.push_back( sTmpName );
1267 // Record those we have created so they can be created in
1268 // basic
1269 AutoGeneratedCodeNames.push_back( sTmpName );
1270 break;
1275 // #i45843# Convert pivot tables before calculation, so they are available
1276 // for the GETPIVOTDATA function.
1277 if( GetBiff() == EXC_BIFF8 )
1278 GetPivotTableManager().ConvertPivotTables();
1280 pProgress.reset();
1282 #if 0
1283 // Excel documents look much better without this call; better in the
1284 // sense that the row heights are identical to the original heights in
1285 // Excel.
1286 AdjustRowHeight();
1287 #endif
1288 PostDocLoad();
1290 pD->CalcAfterLoad();
1292 // import change tracking data
1293 XclImpChangeTrack aImpChTr( GetRoot(), maStrm );
1294 aImpChTr.Apply();
1296 const XclImpAddressConverter& rAddrConv = GetAddressConverter();
1297 if( rAddrConv.IsTabTruncated() )
1298 eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
1299 else if( bTabTruncated || rAddrConv.IsRowTruncated() )
1300 eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
1301 else if( rAddrConv.IsColTruncated() )
1302 eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
1304 if( GetBiff() == EXC_BIFF8 )
1305 GetPivotTableManager().MaybeRefreshPivotTables();
1308 return eLastErr;
1311 //___________________________________________________________________