xref: /aoo41x/main/sc/source/filter/excel/read.cxx (revision 96ad0767)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sc.hxx"
24 
25 //------------------------------------------------------------------------
26 
27 #include <stdlib.h>
28 #include <stdio.h>
29 
30 #include "document.hxx"
31 #include "scerrors.hxx"
32 #include "fprogressbar.hxx"
33 #include "xltracer.hxx"
34 #include "xltable.hxx"
35 #include "xihelper.hxx"
36 #include "xipage.hxx"
37 #include "xiview.hxx"
38 #include "xilink.hxx"
39 #include "xiname.hxx"
40 #include "xicontent.hxx"
41 #include "xiescher.hxx"
42 #include "xipivot.hxx"
43 #include "XclImpChangeTrack.hxx"
44 
45 #include "root.hxx"
46 #include "imp_op.hxx"
47 #include "excimp8.hxx"
48 
Read(void)49 FltError ImportExcel::Read( void )
50 {
51     XclImpPageSettings&     rPageSett       = GetPageSettings();
52     XclImpTabViewSettings&  rTabViewSett    = GetTabViewSettings();
53     XclImpPalette&          rPal            = GetPalette();
54     XclImpFontBuffer&       rFontBfr        = GetFontBuffer();
55     XclImpNumFmtBuffer&     rNumFmtBfr      = GetNumFmtBuffer();
56     XclImpXFBuffer&         rXFBfr          = GetXFBuffer();
57     XclImpNameManager&      rNameMgr        = GetNameManager();
58     XclImpObjectManager&    rObjMgr         = GetObjectManager();
59     (void)rObjMgr;
60     // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
61 
62 	enum Zustand {
63 		Z_BiffNull,	// Nicht in gueltigem Biff-Format
64 		Z_Biff2,	// Biff2: nur eine Tabelle
65 
66 		Z_Biff3,	// Biff3: nur eine Tabelle
67 
68 		Z_Biff4,	// Biff4: nur eine Tabelle
69 		Z_Biff4W,	// Biff4 Workbook: Globals
70 		Z_Biff4T,	// Biff4 Workbook: eine Tabelle selbst
71 		Z_Biff4E,	// Biff4 Workbook: zwischen den Tabellen
72 
73 		Z_Biff5WPre,// Biff5: Prefetch Workbook
74 		Z_Biff5W,	// Biff5: Globals
75         Z_Biff5TPre,// Biff5: Prefetch fuer Shrfmla/Array Formula
76 		Z_Biff5T,	// Biff5: eine Tabelle selbst
77 		Z_Biff5E,	// Biff5: zwischen den Tabellen
78 		Z_Biffn0,	// Alle Biffs: Tabelle bis naechstesss EOF ueberlesen
79 		Z_Ende };
80 
81 	Zustand				eAkt = Z_BiffNull, ePrev = Z_BiffNull;
82 
83 	FltError			eLastErr = eERR_OK;
84 	sal_uInt16				nOpcode;
85     sal_uInt16              nBofLevel = 0;
86 
87 	DBG_ASSERT( &aIn != NULL, "-ImportExcel::Read(): Kein Stream - wie dass?!" );
88 
89     ::std::auto_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
90         aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
91 
92     /*  #i104057# Need to track a base position for progress bar calculation,
93         because sheet substreams may not be in order of sheets. */
94     sal_Size nProgressBasePos = 0;
95     sal_Size nProgressBaseSize = 0;
96 
97 	while( eAkt != Z_Ende )
98 	{
99         if( eAkt == Z_Biff5E )
100         {
101             sal_uInt16 nScTab = GetCurrScTab();
102             if( nScTab < maSheetOffsets.size()  )
103             {
104                 nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
105                 nProgressBasePos = maSheetOffsets[ nScTab ];
106                 aIn.StartNextRecord( nProgressBasePos );
107             }
108             else
109                 eAkt = Z_Ende;
110         }
111         else
112             aIn.StartNextRecord();
113 
114         nOpcode = aIn.GetRecId();
115 
116 		if( !aIn.IsValid() )
117 		{
118             // #124240# finalize table if EOF is missing
119             switch( eAkt )
120             {
121                 case Z_Biff2:
122                 case Z_Biff3:
123                 case Z_Biff4:
124                 case Z_Biff4T:
125                 case Z_Biff5TPre:
126                 case Z_Biff5T:
127                     rNumFmtBfr.CreateScFormats();
128                     Eof();
129                 break;
130                 default:;
131             };
132 			eAkt = Z_Ende;
133 			break;
134 		}
135 
136         if( eAkt == Z_Ende )
137             break;
138 
139         if( eAkt != Z_Biff5TPre && eAkt != Z_Biff5WPre )
140             pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
141 
142 		switch( eAkt )
143 		{
144 			// ----------------------------------------------------------------
145 			case Z_BiffNull:	// ------------------------------- Z_BiffNull -
146 			{
147 				switch( nOpcode )
148 				{
149                     case EXC_ID2_BOF:
150                     case EXC_ID3_BOF:
151                     case EXC_ID4_BOF:
152                     case EXC_ID5_BOF:
153                     {
154                         // #i23425# don't rely on the record ID, but on the detected BIFF version
155                         switch( GetBiff() )
156                         {
157                             case EXC_BIFF2:
158                                 Bof2();
159                                 if( pExcRoot->eDateiTyp == Biff2 )
160                                 {
161                                     eAkt = Z_Biff2;
162                                     NeueTabelle();
163                                 }
164                             break;
165                             case EXC_BIFF3:
166                                 Bof3();
167                                 if( pExcRoot->eDateiTyp == Biff3 )
168                                 {
169                                     eAkt = Z_Biff3;
170                                     NeueTabelle();
171                                 }
172                             break;
173                             case EXC_BIFF4:
174                                 Bof4();
175                                 if( pExcRoot->eDateiTyp == Biff4 )
176                                 {
177                                     eAkt = Z_Biff4;
178                                     NeueTabelle();
179                                 }
180                                 else if( pExcRoot->eDateiTyp == Biff4W )
181                                 {
182                                     eAkt = Z_Biff4W;
183                                 }
184                             break;
185                             case EXC_BIFF5:
186                                 Bof5();
187                                 if( pExcRoot->eDateiTyp == Biff5W )
188                                 {
189                                     eAkt = Z_Biff5WPre;
190 
191                                     nBdshtTab = 0;
192 
193                                     aIn.StoreGlobalPosition(); // und Position merken
194                                 }
195                                 else if( pExcRoot->eDateiTyp == Biff5 )
196                                 {
197                                     // #i62752# possible to have BIFF5 sheet without globals
198                                     NeueTabelle();
199                                     eAkt = Z_Biff5TPre;  // Shrfmla Prefetch, Row-Prefetch
200                                     nBofLevel = 0;
201                                     aIn.StoreGlobalPosition(); // und Position merken
202                                 }
203                             break;
204                             default:
205                                 DBG_ERROR_BIFF();
206                         }
207                     }
208                     break;
209 				}
210 			}
211 				break;
212 			// ----------------------------------------------------------------
213 			case Z_Biff2:		// ---------------------------------- Z_Biff2 -
214 			{
215 				switch( nOpcode )
216 				{
217                     case EXC_ID2_DIMENSIONS:
218                     case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
219                     case EXC_ID2_BLANK:
220                     case EXC_ID3_BLANK:         ReadBlank();            break;
221                     case EXC_ID2_INTEGER:       ReadInteger();          break;
222                     case EXC_ID2_NUMBER:
223                     case EXC_ID3_NUMBER:        ReadNumber();           break;
224                     case EXC_ID2_LABEL:
225                     case EXC_ID3_LABEL:         ReadLabel();            break;
226                     case EXC_ID2_BOOLERR:
227                     case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
228                     case EXC_ID_RK:             ReadRk();               break;
229 
230 					case 0x06:	Formula25(); break;		// FORMULA		[ 2  5]
231 					case 0x08:	Row25(); break;			// ROW			[ 2  5]
232 					case 0x0A:							// EOF			[ 2345]
233                         rNumFmtBfr.CreateScFormats();
234                         Eof();
235 						eAkt = Z_Ende;
236 						break;
237                     case 0x14:
238                     case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
239 					case 0x17:	Externsheet(); break;	// EXTERNSHEET	[ 2345]
240                     case 0x18:  rNameMgr.ReadName( maStrm );            break;
241                     case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
242                     case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
243                     case 0x1E:  rNumFmtBfr.ReadFormat( maStrm );        break;
244 					case 0x20:	Columndefault(); break;	// COLUMNDEFAULT[ 2   ]
245 					case 0x21:	Array25(); break;		// ARRAY		[ 2  5]
246 					case 0x23:	Externname25(); break;	// EXTERNNAME	[ 2  5]
247 					case 0x24:	Colwidth(); break;		// COLWIDTH		[ 2   ]
248 					case 0x25:	Defrowheight2(); break;	// DEFAULTROWHEI[ 2   ]
249                     case 0x26:
250                     case 0x27:
251                     case 0x28:
252                     case 0x29:  rPageSett.ReadMargin( maStrm );         break;
253                     case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
254                     case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
255 					case 0x2F:							// FILEPASS		[ 2345]
256                         eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
257                         if( eLastErr != ERRCODE_NONE )
258 							eAkt = Z_Ende;
259 						break;
260                     case EXC_ID2_FONT:  rFontBfr.ReadFont( maStrm );    break;
261                     case EXC_ID_EFONT:  rFontBfr.ReadEfont( maStrm );   break;
262                     case 0x3E:  rTabViewSett.ReadWindow2( maStrm, false );break;
263                     case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
264 					case 0x42:	Codepage(); break;		// CODEPAGE		[ 2345]
265                     case 0x43:  rXFBfr.ReadXF( maStrm );                break;
266 					case 0x44:	Ixfe(); break;			// IXFE			[ 2   ]
267 				}
268 			}
269 				break;
270 			// ----------------------------------------------------------------
271 			case Z_Biff3:		// ---------------------------------- Z_Biff3 -
272 			{
273 				switch( nOpcode )
274 				{
275                     // skip chart substream
276                     case EXC_ID2_BOF:
277                     case EXC_ID3_BOF:
278                     case EXC_ID4_BOF:
279                     case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
280 
281                     case EXC_ID2_DIMENSIONS:
282                     case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
283                     case EXC_ID2_BLANK:
284                     case EXC_ID3_BLANK:         ReadBlank();            break;
285                     case EXC_ID2_INTEGER:       ReadInteger();          break;
286                     case EXC_ID2_NUMBER:
287                     case EXC_ID3_NUMBER:        ReadNumber();           break;
288                     case EXC_ID2_LABEL:
289                     case EXC_ID3_LABEL:         ReadLabel();            break;
290                     case EXC_ID2_BOOLERR:
291                     case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
292                     case EXC_ID_RK:             ReadRk();               break;
293 
294 					case 0x0A:							// EOF			[ 2345]
295                         rNumFmtBfr.CreateScFormats();
296                         Eof();
297 						eAkt = Z_Ende;
298 						break;
299                     case 0x14:
300                     case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
301 					case 0x17:	Externsheet(); break;	// EXTERNSHEET	[ 2345]
302                     case 0x1A:
303                     case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
304                     case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
305                     case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
306                     case 0x1E:  rNumFmtBfr.ReadFormat( maStrm );        break;
307 					case 0x22:	Rec1904(); break;		// 1904			[ 2345]
308                     case 0x26:
309                     case 0x27:
310                     case 0x28:
311                     case 0x29:  rPageSett.ReadMargin( maStrm );         break;
312                     case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
313                     case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
314 					case 0x2F:							// FILEPASS		[ 2345]
315                         eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
316                         if( eLastErr != ERRCODE_NONE )
317                             eAkt = Z_Ende;
318 						break;
319                     case EXC_ID_FILESHARING: ReadFileSharing();         break;
320                     case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
321 					case 0x42:	Codepage(); break;		// CODEPAGE		[ 2345]
322 					case 0x56:	Builtinfmtcnt(); break;	// BUILTINFMTCNT[  34 ]
323                     case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
324 					case 0x7D:	Colinfo(); break;		// COLINFO		[  345]
325 					case 0x8C:	Country(); break;		// COUNTRY		[  345]
326                     case 0x92:  rPal.ReadPalette( maStrm );             break;
327 					case 0x0206: Formula3(); break;		// FORMULA		[  3  ]
328 					case 0x0208: Row34(); break;		// ROW			[  34 ]
329                     case 0x0218: rNameMgr.ReadName( maStrm );           break;
330 					case 0x0221: Array34(); break;		// ARRAY		[  34 ]
331 					case 0x0223: Externname34(); break;	// EXTERNNAME	[  34 ]
332 					case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
333                     case 0x0231: rFontBfr.ReadFont( maStrm );           break;
334                     case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
335                     case 0x0243: rXFBfr.ReadXF( maStrm );               break;
336                     case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
337 				}
338 			}
339 				break;
340 			// ----------------------------------------------------------------
341 			case Z_Biff4:		// ---------------------------------- Z_Biff4 -
342 			{
343 				switch( nOpcode )
344 				{
345                     // skip chart substream
346                     case EXC_ID2_BOF:
347                     case EXC_ID3_BOF:
348                     case EXC_ID4_BOF:
349                     case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
350 
351                     case EXC_ID2_DIMENSIONS:
352                     case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
353                     case EXC_ID2_BLANK:
354                     case EXC_ID3_BLANK:         ReadBlank();            break;
355                     case EXC_ID2_INTEGER:       ReadInteger();          break;
356                     case EXC_ID2_NUMBER:
357                     case EXC_ID3_NUMBER:        ReadNumber();           break;
358                     case EXC_ID2_LABEL:
359                     case EXC_ID3_LABEL:         ReadLabel();            break;
360                     case EXC_ID2_BOOLERR:
361                     case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
362                     case EXC_ID_RK:             ReadRk();               break;
363 
364 					case 0x0A:							// EOF			[ 2345]
365                         rNumFmtBfr.CreateScFormats();
366                         Eof();
367 						eAkt = Z_Ende;
368 						break;
369 					case 0x12:  SheetProtect(); break;       // SHEET PROTECTION
370                     case 0x14:
371                     case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
372 					case 0x17:	Externsheet(); break;	// EXTERNSHEET	[ 2345]
373                     case 0x1A:
374                     case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
375                     case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
376                     case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
377 					case 0x22:	Rec1904(); break;		// 1904			[ 2345]
378                     case 0x26:
379                     case 0x27:
380                     case 0x28:
381                     case 0x29:  rPageSett.ReadMargin( maStrm );         break;
382                     case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
383                     case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
384 					case 0x2F:							// FILEPASS		[ 2345]
385                         eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
386                         if( eLastErr != ERRCODE_NONE )
387                             eAkt = Z_Ende;
388                         break;
389                     case EXC_ID_FILESHARING: ReadFileSharing();         break;
390                     case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
391 					case 0x42:	Codepage(); break;		// CODEPAGE		[ 2345]
392 					case 0x55:	DefColWidth(); break;
393 					case 0x56:	Builtinfmtcnt(); break;	// BUILTINFMTCNT[  34 ]
394                     case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
395 					case 0x7D:	Colinfo(); break;		// COLINFO		[  345]
396 					case 0x8C:	Country(); break;		// COUNTRY		[  345]
397                     case 0x92:  rPal.ReadPalette( maStrm );             break;
398 					case 0x99:	Standardwidth(); break;	// STANDARDWIDTH[   45]
399                     case 0xA1:  rPageSett.ReadSetup( maStrm );          break;
400 					case 0x0208: Row34(); break;		// ROW			[  34 ]
401                     case 0x0218: rNameMgr.ReadName( maStrm );           break;
402 					case 0x0221: Array34(); break;		// ARRAY		[  34 ]
403 					case 0x0223: Externname34(); break;	// EXTERNNAME	[  34 ]
404 					case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
405                     case 0x0231: rFontBfr.ReadFont( maStrm );           break;
406                     case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
407 					case 0x0406: Formula4(); break;		// FORMULA		[   4 ]
408                     case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
409                     case 0x0443: rXFBfr.ReadXF( maStrm );               break;
410                     case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
411 				}
412 			}
413 				break;
414 			// ----------------------------------------------------------------
415 			case Z_Biff4W:		// --------------------------------- Z_Biff4W -
416 			{
417 				switch( nOpcode )
418 				{
419 					case 0x0A:							// EOF			[ 2345]
420 						eAkt = Z_Ende;
421 						break;
422 					case 0x12:	DocProtect(); break;	// PROTECT		[    5]
423 					case 0x2F:							// FILEPASS		[ 2345]
424                         eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
425                         if( eLastErr != ERRCODE_NONE )
426                             eAkt = Z_Ende;
427 						break;
428                     case EXC_ID_FILESHARING: ReadFileSharing();         break;
429                     case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
430 					case 0x42:	Codepage(); break;		// CODEPAGE		[ 2345]
431 					case 0x55:	DefColWidth(); break;
432 					case 0x56:	Builtinfmtcnt(); break;	// BUILTINFMTCNT[  34 ]
433 					case 0x8C:	Country(); break;		// COUNTRY		[  345]
434 					case 0x8F:	Bundleheader(); break;	// BUNDLEHEADER	[   4 ]
435                     case 0x92:  rPal.ReadPalette( maStrm );             break;
436 					case 0x99:	Standardwidth(); break;	// STANDARDWIDTH[   45]
437                     case 0x0218: rNameMgr.ReadName( maStrm );           break;
438 					case 0x0223: Externname34(); break;	// EXTERNNAME	[  34 ]
439 					case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
440                     case 0x0231: rFontBfr.ReadFont( maStrm );           break;
441 					case 0x0409:						// BOF			[   4 ]
442 						Bof4();
443 						if( pExcRoot->eDateiTyp == Biff4 )
444 						{
445                             eAkt = Z_Biff4T;
446 							NeueTabelle();
447 						}
448 						else
449 							eAkt = Z_Ende;
450 						break;
451                     case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
452                     case 0x0443: rXFBfr.ReadXF( maStrm );               break;
453                     case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
454 				}
455 
456 			}
457 				break;
458 			// ----------------------------------------------------------------
459             case Z_Biff4T:       // --------------------------------- Z_Biff4T -
460 			{
461 				switch( nOpcode )
462 				{
463                     // skip chart substream
464                     case EXC_ID2_BOF:
465                     case EXC_ID3_BOF:
466                     case EXC_ID4_BOF:
467                     case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
468 
469                     case EXC_ID2_DIMENSIONS:
470                     case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
471                     case EXC_ID2_BLANK:
472                     case EXC_ID3_BLANK:         ReadBlank();            break;
473                     case EXC_ID2_INTEGER:       ReadInteger();          break;
474                     case EXC_ID2_NUMBER:
475                     case EXC_ID3_NUMBER:        ReadNumber();           break;
476                     case EXC_ID2_LABEL:
477                     case EXC_ID3_LABEL:         ReadLabel();            break;
478                     case EXC_ID2_BOOLERR:
479                     case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
480                     case EXC_ID_RK:             ReadRk();               break;
481 
482 					case 0x0A:							// EOF			[ 2345]
483                         Eof();
484                         eAkt = Z_Biff4E;
485                     break;
486                     case 0x12:  SheetProtect(); break;       // SHEET PROTECTION
487                     case 0x14:
488                     case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
489                     case 0x1A:
490                     case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
491                     case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
492                     case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
493 					case 0x2F:							// FILEPASS		[ 2345]
494                         eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
495                         if( eLastErr != ERRCODE_NONE )
496                             eAkt = Z_Ende;
497 						break;
498                     case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
499 					case 0x42:	Codepage(); break;		// CODEPAGE		[ 2345]
500 					case 0x55:	DefColWidth(); break;
501 					case 0x56:	Builtinfmtcnt(); break;	// BUILTINFMTCNT[  34 ]
502                     case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
503 					case 0x7D:	Colinfo(); break;		// COLINFO		[  345]
504 					case 0x8C:	Country(); break;		// COUNTRY		[  345]
505 					case 0x8F:	Bundleheader(); break;	// BUNDLEHEADER	[   4 ]
506                     case 0x92:  rPal.ReadPalette( maStrm );             break;
507 					case 0x99:	Standardwidth(); break;	// STANDARDWIDTH[   45]
508                     case 0xA1:  rPageSett.ReadSetup( maStrm );          break;
509 					case 0x0208: Row34(); break;		// ROW			[  34 ]
510                     case 0x0218: rNameMgr.ReadName( maStrm );           break;
511                     case 0x0221: Array34(); break;
512 					case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
513                     case 0x0231: rFontBfr.ReadFont( maStrm );           break;
514                     case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
515                     case 0x0406: Formula4(); break;
516                     case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
517                     case 0x0443: rXFBfr.ReadXF( maStrm );               break;
518                     case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
519 				}
520 
521 			}
522 				break;
523 			// ----------------------------------------------------------------
524 			case Z_Biff4E:		// --------------------------------- Z_Biff4E -
525 			{
526 				switch( nOpcode )
527 				{
528 					case 0x0A:							// EOF			[ 2345]
529 						eAkt = Z_Ende;
530 						break;
531 					case 0x8F:	break;					// BUNDLEHEADER	[   4 ]
532 					case 0x0409:						// BOF			[   4 ]
533 						Bof4();
534 						NeueTabelle();
535 						if( pExcRoot->eDateiTyp == Biff4 )
536 						{
537                             eAkt = Z_Biff4T;
538 						}
539 						else
540 						{
541 							ePrev = eAkt;
542 							eAkt = Z_Biffn0;
543 						}
544 						break;
545 				}
546 
547 			}
548 				break;
549 			case Z_Biff5WPre:	// ------------------------------ Z_Biff5WPre -
550 			{
551 				switch( nOpcode )
552 				{
553 					case 0x0A:							// EOF			[ 2345]
554 						eAkt = Z_Biff5W;
555                         aIn.SeekGlobalPosition();  // und zurueck an alte Position
556 						break;
557 					case 0x12:	DocProtect(); break;	// PROTECT		[    5]
558 					case 0x2F:							// FILEPASS		[ 2345]
559                         eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
560                         if( eLastErr != ERRCODE_NONE )
561                             eAkt = Z_Ende;
562 						break;
563                     case EXC_ID_FILESHARING: ReadFileSharing();         break;
564                     case 0x3D:  Window1(); break;
565 					case 0x42:	Codepage(); break;		// CODEPAGE		[ 2345]
566 					case 0x85:	Boundsheet(); break;	// BOUNDSHEET	[    5]
567                     case 0x8C:  Country(); break;       // COUNTRY      [  345]
568                     // PALETTE follows XFs, but already needed while reading the XFs
569                     case 0x92:  rPal.ReadPalette( maStrm );             break;
570 				}
571 			}
572 				break;
573 			case Z_Biff5W:		// --------------------------------- Z_Biff5W -
574 			{
575 				switch( nOpcode )
576 				{
577 					case 0x0A:							// EOF			[ 2345]
578                         rNumFmtBfr.CreateScFormats();
579                         rXFBfr.CreateUserStyles();
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:	Builtinfmtcnt(); 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;
592 				}
593 
594 			}
595 				break;
596             // ----------------------------------------------------------------
597             case Z_Biff5TPre:   // ------------------------------- Z_Biff5Pre -
598             {
599                 if( nOpcode == 0x0809 )
600                     nBofLevel++;
601                 else if( (nOpcode == 0x000A) && nBofLevel )
602                     nBofLevel--;
603                 else if( !nBofLevel )                       // don't read chart records
604                 {
605                     switch( nOpcode )
606                     {
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: Externname34(); break; // EXTERNNAME   [  34 ]
631                         case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
632                         case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
633                         case 0x04BC: Shrfmla(); break;      // SHRFMLA      [    5]
634                     }
635                 }
636             }
637                 break;
638 			// ----------------------------------------------------------------
639             case Z_Biff5T:       // --------------------------------- Z_Biff5T -
640 			{
641 				switch( nOpcode )
642 				{
643                     case EXC_ID2_BLANK:
644                     case EXC_ID3_BLANK:         ReadBlank();            break;
645                     case EXC_ID2_INTEGER:       ReadInteger();          break;
646                     case EXC_ID2_NUMBER:
647                     case EXC_ID3_NUMBER:        ReadNumber();           break;
648                     case EXC_ID2_LABEL:
649                     case EXC_ID3_LABEL:         ReadLabel();            break;
650                     case EXC_ID2_BOOLERR:
651                     case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
652                     case EXC_ID_RK:             ReadRk();               break;
653 
654                     case 0x0006:
655                     case 0x0206:
656                     case 0x0406:  Formula25(); 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;
688 				}
689 
690 			}
691 				break;
692 			// ----------------------------------------------------------------
693 			case Z_Biff5E:		// --------------------------------- Z_Biff5E -
694 			{
695 				switch( nOpcode )
696 				{
697 					case 0x0809:						// BOF			[    5]
698 						Bof5();
699 						NeueTabelle();
700 						switch( pExcRoot->eDateiTyp )
701 						{
702 							case Biff5:
703                             case Biff5M4:
704                                 eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
705                                 nBofLevel = 0;
706                                 aIn.StoreGlobalPosition(); // und Position merken
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(), sal_False );
716 								ePrev = eAkt;
717 								eAkt = Z_Biffn0;
718 						}
719 						DBG_ASSERT( pExcRoot->eDateiTyp != Biff5W,
720 							"+ImportExcel::Read(): Doppel-Whopper-Workbook!" );
721 
722 						break;
723 				}
724 
725 			}
726 				break;
727 			case Z_Biffn0:		// --------------------------------- Z_Biffn0 -
728 			{
729 				switch( nOpcode )
730 				{
731 					case 0x0A:							// EOF			[ 2345]
732 						eAkt = ePrev;
733                         IncCurrScTab();
734 						break;
735 				}
736 
737 			}
738 				break;
739 			// ----------------------------------------------------------------
740 			case Z_Ende:		// ----------------------------------- Z_Ende -
741 				DBG_ERROR( "*ImportExcel::Read(): Not possible state!" );
742 				break;
743 			default: DBG_ERROR( "-ImportExcel::Read(): Zustand vergessen!" );
744 		}
745 	}
746 
747     if( eLastErr == eERR_OK )
748     {
749         pProgress.reset();
750 
751         AdjustRowHeight();
752         PostDocLoad();
753 
754         pD->CalcAfterLoad();
755 
756         const XclImpAddressConverter& rAddrConv = GetAddressConverter();
757         if( rAddrConv.IsTabTruncated() )
758             eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
759         else if( bTabTruncated || rAddrConv.IsRowTruncated() )
760             eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
761         else if( rAddrConv.IsColTruncated() )
762             eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
763     }
764 
765 	return eLastErr;
766 }
767 
768 
769 //___________________________________________________________________
770 
Read(void)771 FltError ImportExcel8::Read( void )
772 {
773 #if EXC_INCL_DUMPER
774     {
775         Biff8RecDumper aDumper( GetRoot(), sal_True );
776         if( aDumper.Dump( aIn ) )
777             return ERRCODE_ABORT;
778     }
779 #endif
780     // read the entire BIFF8 stream
781     // don't look too close - this stuff seriously needs to be reworked
782 
783     XclImpPageSettings&     rPageSett       = GetPageSettings();
784     XclImpTabViewSettings&  rTabViewSett    = GetTabViewSettings();
785     XclImpPalette&          rPal            = GetPalette();
786     XclImpFontBuffer&       rFontBfr        = GetFontBuffer();
787     XclImpNumFmtBuffer&     rNumFmtBfr      = GetNumFmtBuffer();
788     XclImpXFBuffer&         rXFBfr          = GetXFBuffer();
789     XclImpSst&              rSst            = GetSst();
790     XclImpTabInfo&          rTabInfo        = GetTabInfo();
791     XclImpNameManager&      rNameMgr        = GetNameManager();
792     XclImpLinkManager&      rLinkMgr        = GetLinkManager();
793     XclImpObjectManager&    rObjMgr         = GetObjectManager();
794     // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
795     XclImpCondFormatManager& rCondFmtMgr    = GetCondFormatManager();
796     XclImpPivotTableManager& rPTableMgr     = GetPivotTableManager();
797     XclImpWebQueryBuffer&   rWQBfr          = GetWebQueryBuffer();
798 
799     bool bInUserView = false;           // true = In USERSVIEW(BEGIN|END) record block.
800 
801     enum XclImpReadState
802     {
803         EXC_STATE_BEFORE_GLOBALS,       /// Before workbook globals (wait for initial BOF).
804         EXC_STATE_GLOBALS_PRE,          /// Prefetch for workbook globals.
805         EXC_STATE_GLOBALS,              /// Workbook globals.
806         EXC_STATE_BEFORE_SHEET,         /// Before worksheet (wait for new worksheet BOF).
807         EXC_STATE_SHEET_PRE,            /// Prefetch for worksheet.
808         EXC_STATE_SHEET,                /// Worksheet.
809         EXC_STATE_END                   /// Stop reading.
810     };
811 
812     XclImpReadState eAkt = EXC_STATE_BEFORE_GLOBALS;
813 
814     FltError eLastErr = eERR_OK;
815 
816     ::std::auto_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
817         aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
818 
819     /*  #i104057# Need to track a base position for progress bar calculation,
820         because sheet substreams may not be in order of sheets. */
821     sal_Size nProgressBasePos = 0;
822     sal_Size nProgressBaseSize = 0;
823 
824     while( eAkt != EXC_STATE_END )
825 	{
826         if( eAkt == EXC_STATE_BEFORE_SHEET )
827         {
828             sal_uInt16 nScTab = GetCurrScTab();
829             if( nScTab < maSheetOffsets.size() )
830             {
831                 nProgressBaseSize += (maStrm.GetSvStreamPos() - nProgressBasePos);
832                 nProgressBasePos = maSheetOffsets[ nScTab ];
833                 maStrm.StartNextRecord( nProgressBasePos );
834 
835                 // #94191# import only 256 sheets
836                 if( nScTab > GetScMaxPos().Tab() )
837                 {
838                     if( maStrm.GetRecId() != EXC_ID_EOF )
839                         XclTools::SkipSubStream( maStrm );
840                     // #i29930# show warning box
841                     GetAddressConverter().CheckScTab( nScTab, true );
842                     eAkt = EXC_STATE_END;
843                 }
844                 else
845                 {
846                     // #i109800# SHEET record may point to any record inside the sheet substream
847                     bool bIsBof = maStrm.GetRecId() == EXC_ID5_BOF;
848                     if( bIsBof )
849                         Bof5();                         // read the BOF record
850                     else
851                         pExcRoot->eDateiTyp = Biff8;    // on missing BOF, assume a standard worksheet
852 
853                     NeueTabelle();
854                     switch( pExcRoot->eDateiTyp )
855                     {
856                         case Biff8:     // worksheet
857                         case Biff8M4:   // macro sheet
858                             eAkt = EXC_STATE_SHEET_PRE;  // Shrfmla Prefetch, Row-Prefetch
859                             // go to next record
860                             if( bIsBof ) maStrm.StartNextRecord();
861                             maStrm.StoreGlobalPosition();
862                         break;
863                         case Biff8C:    // chart sheet
864                             GetCurrSheetDrawing().ReadTabChart( maStrm );
865                             Eof();
866                             GetTracer().TraceChartOnlySheet();
867                         break;
868                         case Biff8W:    // workbook
869                             DBG_ERRORFILE( "ImportExcel8::Read - double workbook globals" );
870                             // run through
871                         case Biff8V:    // VB module
872                         default:
873                             // TODO: do not create a sheet in the Calc document
874                             pD->SetVisible( GetCurrScTab(), sal_False );
875                             XclTools::SkipSubStream( maStrm );
876                             IncCurrScTab();
877                     }
878                 }
879             }
880             else
881                 eAkt = EXC_STATE_END;
882         }
883         else
884             aIn.StartNextRecord();
885 
886 		if( !aIn.IsValid() )
887 		{
888             // #124240# #i63591# finalize table if EOF is missing
889             switch( eAkt )
890             {
891                 case EXC_STATE_SHEET_PRE:
892                     eAkt = EXC_STATE_SHEET;
893                     aIn.SeekGlobalPosition();
894                     continue;   // next iteration in while loop
895 //                break;    // unxsols warning: statement unreachable
896                 case EXC_STATE_SHEET:
897                     Eof();
898                     eAkt = EXC_STATE_END;
899                 break;
900                 default:
901                     eAkt = EXC_STATE_END;
902             }
903 		}
904 
905         if( eAkt == EXC_STATE_END )
906             break;
907 
908         if( eAkt != EXC_STATE_SHEET_PRE && eAkt != EXC_STATE_GLOBALS_PRE )
909             pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
910 
911         sal_uInt16 nRecId = aIn.GetRecId();
912 
913         /*  #i39464# Ignore records between USERSVIEWBEGIN and USERSVIEWEND
914             completely (user specific view settings). Otherwise view settings
915             and filters are loaded multiple times, which at least causes
916             problems in auto-filters. */
917         switch( nRecId )
918         {
919             case EXC_ID_USERSVIEWBEGIN:
920                 DBG_ASSERT( !bInUserView, "ImportExcel8::Read - nested user view settings" );
921                 bInUserView = true;
922             break;
923             case EXC_ID_USERSVIEWEND:
924                 DBG_ASSERT( bInUserView, "ImportExcel8::Read - not in user view settings" );
925                 bInUserView = false;
926             break;
927         }
928 
929         if( !bInUserView ) switch( eAkt )
930 		{
931             // ----------------------------------------------------------------
932             // before workbook globals: wait for initial workbook globals BOF
933             case EXC_STATE_BEFORE_GLOBALS:
934 			{
935                 if( nRecId == EXC_ID5_BOF )
936                 {
937                     DBG_ASSERT( GetBiff() == EXC_BIFF8, "ImportExcel8::Read - wrong BIFF version" );
938                     Bof5();
939                     if( pExcRoot->eDateiTyp == Biff8W )
940                     {
941                         eAkt = EXC_STATE_GLOBALS_PRE;
942                         maStrm.StoreGlobalPosition();
943                         nBdshtTab = 0;
944                     }
945                     else if( pExcRoot->eDateiTyp == Biff8 )
946                     {
947                         // #i62752# possible to have BIFF8 sheet without globals
948                         NeueTabelle();
949                         eAkt = EXC_STATE_SHEET_PRE;  // Shrfmla Prefetch, Row-Prefetch
950                         aIn.StoreGlobalPosition();
951                     }
952                 }
953 			}
954             break;
955 
956             // ----------------------------------------------------------------
957             // prefetch for workbook globals
958             case EXC_STATE_GLOBALS_PRE:
959 			{
960                 switch( nRecId )
961 				{
962                     case EXC_ID_EOF:
963                     case EXC_ID_EXTSST:
964                         /*  #i56376# evil hack: if EOF for globals is missing,
965                             simulate it. This hack works only for the bugdoc
966                             given in the issue, where the sheet substreams
967                             start directly after the EXTSST record. A future
968                             implementation should be more robust against
969                             missing EOFs. */
970                         if( (nRecId == EXC_ID_EOF) ||
971                             ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
972                         {
973                             eAkt = EXC_STATE_GLOBALS;
974                             aIn.SeekGlobalPosition();
975                         }
976 						break;
977 					case 0x12:	DocProtect(); break;	// PROTECT		[    5678]
978                     case 0x13:  DocPasssword(); break;
979 					case 0x19:  WinProtection(); break;
980 					case 0x2F:							// FILEPASS		[ 2345   ]
981                         eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
982                         if( eLastErr != ERRCODE_NONE )
983                             eAkt = EXC_STATE_END;
984 						break;
985                     case EXC_ID_FILESHARING: ReadFileSharing();         break;
986                     case 0x3D:  Window1(); break;
987 					case 0x42:	Codepage(); break;		// CODEPAGE		[ 2345   ]
988 					case 0x85:	Boundsheet(); break;	// BOUNDSHEET	[    5   ]
989                     case 0x8C:  Country(); break;       // COUNTRY      [  345   ]
990 
991                     // PALETTE follows XFs, but already needed while reading the XFs
992                     case EXC_ID_PALETTE:        rPal.ReadPalette( maStrm );             break;
993 				}
994 			}
995             break;
996 
997             // ----------------------------------------------------------------
998             // workbook globals
999             case EXC_STATE_GLOBALS:
1000 			{
1001                 switch( nRecId )
1002 				{
1003                     case EXC_ID_EOF:
1004                     case EXC_ID_EXTSST:
1005                         /*  #i56376# evil hack: if EOF for globals is missing,
1006                             simulate it. This hack works only for the bugdoc
1007                             given in the issue, where the sheet substreams
1008                             start directly after the EXTSST record. A future
1009                             implementation should be more robust against
1010                             missing EOFs. */
1011                         if( (nRecId == EXC_ID_EOF) ||
1012                             ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
1013                         {
1014                             rNumFmtBfr.CreateScFormats();
1015                             rXFBfr.CreateUserStyles();
1016                             //rPTableMgr.ReadPivotCaches( maStrm );
1017                             eAkt = EXC_STATE_BEFORE_SHEET;
1018                         }
1019                     break;
1020                     case 0x0E:  Precision(); break;     // PRECISION
1021 					case 0x22:	Rec1904(); break;		// 1904			[ 2345   ]
1022 					case 0x56:	Builtinfmtcnt(); break;	// BUILTINFMTCNT[  34    ]
1023 					case 0x8D:	Hideobj(); break;		// HIDEOBJ		[  345   ]
1024 					case 0xD3:	SetHasBasic(); break;
1025                     case 0xDE:  Olesize(); break;
1026 
1027                     case EXC_ID_CODENAME:       ReadCodeName( aIn, true );          break;
1028                     case EXC_ID_USESELFS:       ReadUsesElfs();                     break;
1029 
1030                     case EXC_ID2_FONT:          rFontBfr.ReadFont( maStrm );        break;
1031                     case EXC_ID4_FORMAT:        rNumFmtBfr.ReadFormat( maStrm );    break;
1032                     case EXC_ID5_XF:            rXFBfr.ReadXF( maStrm );            break;
1033                     case EXC_ID_STYLE:          rXFBfr.ReadStyle( maStrm );         break;
1034 
1035                     case EXC_ID_SST:            rSst.ReadSst( maStrm );             break;
1036                     case EXC_ID_TABID:          rTabInfo.ReadTabid( maStrm );       break;
1037                     case EXC_ID_NAME:           rNameMgr.ReadName( maStrm );        break;
1038 
1039                     case EXC_ID_EXTERNSHEET:    rLinkMgr.ReadExternsheet( maStrm ); break;
1040                     case EXC_ID_SUPBOOK:        rLinkMgr.ReadSupbook( maStrm );     break;
1041                     case EXC_ID_XCT:            rLinkMgr.ReadXct( maStrm );         break;
1042                     case EXC_ID_CRN:            rLinkMgr.ReadCrn( maStrm );         break;
1043                     case EXC_ID_EXTERNNAME:     rLinkMgr.ReadExternname( maStrm, pFormConv );  break;
1044 
1045                     case EXC_ID_MSODRAWINGGROUP:rObjMgr.ReadMsoDrawingGroup( maStrm ); break;
1046 
1047                     case EXC_ID_SXIDSTM:        rPTableMgr.ReadSxidstm( maStrm );   break;
1048                     case EXC_ID_SXVS:           rPTableMgr.ReadSxvs( maStrm );      break;
1049                     case EXC_ID_DCONREF:        rPTableMgr.ReadDconref( maStrm );   break;
1050 				}
1051 
1052 			}
1053             break;
1054 
1055             // ----------------------------------------------------------------
1056             // prefetch for worksheet
1057             case EXC_STATE_SHEET_PRE:
1058             {
1059                 switch( nRecId )
1060                 {
1061                     // skip chart substream
1062                     case EXC_ID2_BOF:
1063                     case EXC_ID3_BOF:
1064                     case EXC_ID4_BOF:
1065                     case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );      break;
1066 
1067                     case EXC_ID_WINDOW2:        rTabViewSett.ReadWindow2( maStrm, false );break;
1068                     case EXC_ID_SCL:            rTabViewSett.ReadScl( maStrm );         break;
1069                     case EXC_ID_PANE:           rTabViewSett.ReadPane( maStrm );        break;
1070                     case EXC_ID_SELECTION:      rTabViewSett.ReadSelection( maStrm );   break;
1071 
1072                     case EXC_ID2_DIMENSIONS:
1073                     case EXC_ID3_DIMENSIONS:    ReadDimensions();                       break;
1074 
1075                     case EXC_ID_CODENAME:       ReadCodeName( aIn, false );             break;
1076 
1077                     case 0x0A:                          // EOF          [ 2345   ]
1078                         eAkt = EXC_STATE_SHEET;
1079                         aIn.SeekGlobalPosition();         // und zurueck an alte Position
1080                         break;
1081                     case 0x12:  SheetProtect(); break;
1082                     case 0x13:  SheetPassword(); break;
1083                     case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345   ]
1084                     case 0x55:  DefColWidth(); break;
1085                     case 0x7D:  Colinfo(); break;       // COLINFO      [  345   ]
1086                     case 0x81:  Wsbool(); break;        // WSBOOL       [ 2345   ]
1087                     case 0x8C:  Country(); break;       // COUNTRY      [  345   ]
1088                     case 0x99:  Standardwidth(); break; // STANDARDWIDTH[   45   ]
1089                     case 0x9B:  FilterMode(); break;    // FILTERMODE
1090                     case 0x9D:  AutoFilterInfo(); break;// AUTOFILTERINFO
1091                     case 0x9E:  AutoFilter(); break;    // AUTOFILTER
1092                     case 0x0208: Row34(); break;        // ROW          [  34    ]
1093                     case 0x0021:
1094                     case 0x0221: Array34(); break;      // ARRAY        [  34    ]
1095                     case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345   ]
1096                     case 0x04BC: Shrfmla(); break;      // SHRFMLA      [    5   ]
1097                     case 0x0867: SheetProtection(); break; // SHEETPROTECTION
1098                 }
1099             }
1100             break;
1101 
1102             // ----------------------------------------------------------------
1103             // worksheet
1104             case EXC_STATE_SHEET:
1105 			{
1106                 switch( nRecId )
1107                 {
1108                     // skip unknown substreams
1109                     case EXC_ID2_BOF:
1110                     case EXC_ID3_BOF:
1111                     case EXC_ID4_BOF:
1112                     case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );      break;
1113 
1114                     case EXC_ID_EOF:            Eof(); eAkt = EXC_STATE_BEFORE_SHEET;   break;
1115 
1116                     case EXC_ID2_BLANK:
1117                     case EXC_ID3_BLANK:         ReadBlank();            break;
1118                     case EXC_ID2_INTEGER:       ReadInteger();          break;
1119                     case EXC_ID2_NUMBER:
1120                     case EXC_ID3_NUMBER:        ReadNumber();           break;
1121                     case EXC_ID2_LABEL:
1122                     case EXC_ID3_LABEL:         ReadLabel();            break;
1123                     case EXC_ID2_BOOLERR:
1124                     case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
1125                     case EXC_ID_RK:             ReadRk();               break;
1126 
1127                     case 0x0006:
1128                     case 0x0206:
1129                     case 0x0406:    Formula25();            break;  // FORMULA      [ 2  5   ]
1130                     case 0x000C:    Calccount();            break;  // CALCCOUNT
1131                     case 0x0010:    Delta();                break;  // DELTA
1132                     case 0x0011:    Iteration();            break;  // ITERATION
1133                     case 0x007E:
1134                     case 0x00AE:    Scenman();              break;  // SCENMAN
1135                     case 0x00AF:    Scenario();             break;  // SCENARIO
1136                     case 0x00BD:    Mulrk();                break;  // MULRK        [    5   ]
1137                     case 0x00BE:    Mulblank();             break;  // MULBLANK     [    5   ]
1138                     case 0x00D6:    Rstring();              break;  // RSTRING      [    5   ]
1139                     case 0x00E5:    Cellmerging();          break;  // CELLMERGING
1140                     case 0x00FD:    Labelsst();             break;  // LABELSST     [      8 ]
1141                     case 0x0236:    TableOp();              break;  // TABLE
1142 
1143                     case EXC_ID_HORPAGEBREAKS:
1144                     case EXC_ID_VERPAGEBREAKS:  rPageSett.ReadPageBreaks( maStrm );     break;
1145                     case EXC_ID_HEADER:
1146                     case EXC_ID_FOOTER:         rPageSett.ReadHeaderFooter( maStrm );   break;
1147                     case EXC_ID_LEFTMARGIN:
1148                     case EXC_ID_RIGHTMARGIN:
1149                     case EXC_ID_TOPMARGIN:
1150                     case EXC_ID_BOTTOMMARGIN:   rPageSett.ReadMargin( maStrm );         break;
1151                     case EXC_ID_PRINTHEADERS:   rPageSett.ReadPrintHeaders( maStrm );   break;
1152                     case EXC_ID_PRINTGRIDLINES: rPageSett.ReadPrintGridLines( maStrm ); break;
1153                     case EXC_ID_HCENTER:
1154                     case EXC_ID_VCENTER:        rPageSett.ReadCenter( maStrm );         break;
1155                     case EXC_ID_SETUP:          rPageSett.ReadSetup( maStrm );          break;
1156                     case EXC_ID8_IMGDATA:       rPageSett.ReadImgData( maStrm );        break;
1157 
1158                     case EXC_ID_MSODRAWING:     GetCurrSheetDrawing().ReadMsoDrawing( maStrm ); break;
1159                     // #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format
1160                     case EXC_ID_OBJ:            GetCurrSheetDrawing().ReadObj( maStrm ); break;
1161                     case EXC_ID_NOTE:           GetCurrSheetDrawing().ReadNote( maStrm ); break;
1162 
1163                     case EXC_ID_HLINK:          XclImpHyperlink::ReadHlink( maStrm );   break;
1164                     case EXC_ID_LABELRANGES:    XclImpLabelranges::ReadLabelranges( maStrm ); break;
1165 
1166                     case EXC_ID_CONDFMT:        rCondFmtMgr.ReadCondfmt( maStrm );      break;
1167                     case EXC_ID_CF:             rCondFmtMgr.ReadCF( maStrm );           break;
1168 
1169                     case EXC_ID_DVAL:           XclImpValidation::ReadDval( maStrm );   break;
1170                     case EXC_ID_DV:             XclImpValidation::ReadDV( maStrm );     break;
1171 
1172                     case EXC_ID_QSI:            rWQBfr.ReadQsi( maStrm );               break;
1173                     case EXC_ID_WQSTRING:       rWQBfr.ReadWqstring( maStrm );          break;
1174                     case EXC_ID_PQRY:           rWQBfr.ReadParamqry( maStrm );          break;
1175                     case EXC_ID_WQSETT:         rWQBfr.ReadWqsettings( maStrm );        break;
1176                     case EXC_ID_WQTABLES:       rWQBfr.ReadWqtables( maStrm );          break;
1177 
1178                     case EXC_ID_SXVIEW:         rPTableMgr.ReadSxview( maStrm );    break;
1179                     case EXC_ID_SXVD:           rPTableMgr.ReadSxvd( maStrm );      break;
1180                     case EXC_ID_SXVI:           rPTableMgr.ReadSxvi( maStrm );      break;
1181                     case EXC_ID_SXIVD:          rPTableMgr.ReadSxivd( maStrm );     break;
1182                     case EXC_ID_SXPI:           rPTableMgr.ReadSxpi( maStrm );      break;
1183                     case EXC_ID_SXDI:           rPTableMgr.ReadSxdi( maStrm );      break;
1184                     case EXC_ID_SXVDEX:         rPTableMgr.ReadSxvdex( maStrm );    break;
1185                     case EXC_ID_SXEX:           rPTableMgr.ReadSxex( maStrm );      break;
1186                     case EXC_ID_SHEETEXT:       rTabViewSett.ReadTabBgColor( maStrm, rPal );    break;
1187                     case EXC_ID_SXVIEWEX9:      rPTableMgr.ReadSxViewEx9( maStrm ); break;
1188                 }
1189 			}
1190             break;
1191 
1192 			// ----------------------------------------------------------------
1193             default:;
1194 		}
1195 	}
1196 
1197     if( eLastErr == eERR_OK )
1198     {
1199         // #i45843# Convert pivot tables before calculation, so they are available
1200         // for the GETPIVOTDATA function.
1201         if( GetBiff() == EXC_BIFF8 )
1202 //            GetPivotTableManager().ConvertPivotTables();
1203         {
1204             SCTAB nTabCount = GetDoc().GetTableCount();
1205 
1206             GetPivotTableManager().ConvertPivotTables( maStrm );
1207 
1208             for( SCTAB nDummyTab = GetDoc().GetTableCount() - 1; nDummyTab >= nTabCount; nDummyTab-- )
1209                 GetDoc().DeleteTab( nDummyTab );
1210         }
1211         pProgress.reset();
1212 
1213         if (pD->IsAdjustHeightEnabled())
1214             AdjustRowHeight();
1215 
1216         PostDocLoad();
1217 
1218         pD->CalcAfterLoad();
1219 
1220         // import change tracking data
1221         XclImpChangeTrack aImpChTr( GetRoot(), maStrm );
1222         aImpChTr.Apply();
1223 
1224         const XclImpAddressConverter& rAddrConv = GetAddressConverter();
1225         if( rAddrConv.IsTabTruncated() )
1226             eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
1227         else if( bTabTruncated || rAddrConv.IsRowTruncated() )
1228             eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
1229         else if( rAddrConv.IsColTruncated() )
1230             eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
1231 
1232 // Refreshing pivot tables moves to the end of converting every table
1233 //        if( GetBiff() == EXC_BIFF8 )
1234 //            GetPivotTableManager().MaybeRefreshPivotTables();
1235     }
1236 
1237 	return eLastErr;
1238 }
1239 
1240 //___________________________________________________________________
1241 
1242