update dev300-m58
[ooovba.git] / sc / source / filter / excel / read.cxx
blob13d048b6856324d0ab62e57baa74b6c842a6300a
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 while( eAkt != Z_Ende )
104 aIn.StartNextRecord();
105 nOpcode = aIn.GetRecId();
107 if( !aIn.IsValid() )
109 // #124240# finalize table if EOF is missing
110 switch( eAkt )
112 case Z_Biff2:
113 case Z_Biff3:
114 case Z_Biff4:
115 case Z_Biff4T:
116 case Z_Biff5TPre:
117 case Z_Biff5T:
118 rNumFmtBfr.CreateScFormats();
119 Eof();
120 break;
121 default:;
123 eAkt = Z_Ende;
124 break;
127 if( eAkt != Z_Biff5TPre && eAkt != Z_Biff5WPre )
128 pProgress->ProgressAbs( aIn.GetSvStreamPos() );
130 switch( eAkt )
132 // ----------------------------------------------------------------
133 case Z_BiffNull: // ------------------------------- Z_BiffNull -
135 switch( nOpcode )
137 case EXC_ID2_BOF:
138 case EXC_ID3_BOF:
139 case EXC_ID4_BOF:
140 case EXC_ID5_BOF:
142 // #i23425# don't rely on the record ID, but on the detected BIFF version
143 switch( GetBiff() )
145 case EXC_BIFF2:
146 Bof2();
147 if( pExcRoot->eDateiTyp == Biff2 )
149 eAkt = Z_Biff2;
150 NeueTabelle();
152 break;
153 case EXC_BIFF3:
154 Bof3();
155 if( pExcRoot->eDateiTyp == Biff3 )
157 eAkt = Z_Biff3;
158 NeueTabelle();
160 break;
161 case EXC_BIFF4:
162 Bof4();
163 if( pExcRoot->eDateiTyp == Biff4 )
165 eAkt = Z_Biff4;
166 NeueTabelle();
168 else if( pExcRoot->eDateiTyp == Biff4W )
170 eAkt = Z_Biff4W;
171 bBiff4Workbook = TRUE;
173 break;
174 case EXC_BIFF5:
175 Bof5();
176 if( pExcRoot->eDateiTyp == Biff5W )
178 eAkt = Z_Biff5WPre;
180 nBdshtTab = 0;
182 aIn.StoreGlobalPosition(); // und Position merken
184 else if( pExcRoot->eDateiTyp == Biff5 )
186 // #i62752# possible to have BIFF5 sheet without globals
187 NeueTabelle();
188 eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
189 nBofLevel = 0;
190 aIn.StoreGlobalPosition(); // und Position merken
192 break;
193 default:
194 DBG_ERROR_BIFF();
197 break;
200 break;
201 // ----------------------------------------------------------------
202 case Z_Biff2: // ---------------------------------- Z_Biff2 -
204 switch( nOpcode )
206 case EXC_ID2_DIMENSIONS:
207 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
208 case EXC_ID2_BLANK:
209 case EXC_ID3_BLANK: ReadBlank(); break;
210 case EXC_ID2_INTEGER: ReadInteger(); break;
211 case EXC_ID2_NUMBER:
212 case EXC_ID3_NUMBER: ReadNumber(); break;
213 case EXC_ID2_LABEL:
214 case EXC_ID3_LABEL: ReadLabel(); break;
215 case EXC_ID2_BOOLERR:
216 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
217 case EXC_ID_RK: ReadRk(); break;
219 case 0x06: Formula25(); break; // FORMULA [ 2 5]
220 case 0x08: Row25(); break; // ROW [ 2 5]
221 case 0x0A: // EOF [ 2345]
222 rNumFmtBfr.CreateScFormats();
223 Eof();
224 eAkt = Z_Ende;
225 break;
226 case 0x14:
227 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
228 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
229 case 0x18: rNameMgr.ReadName( maStrm ); break;
230 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
231 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
232 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
233 case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ]
234 case 0x21: Array25(); break; // ARRAY [ 2 5]
235 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
236 case 0x24: Colwidth(); break; // COLWIDTH [ 2 ]
237 case 0x25: Defrowheight2(); break; // DEFAULTROWHEI[ 2 ]
238 case 0x26:
239 case 0x27:
240 case 0x28:
241 case 0x29: rPageSett.ReadMargin( maStrm ); break;
242 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
243 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
244 case 0x2F: // FILEPASS [ 2345]
245 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
246 if( eLastErr != ERRCODE_NONE )
247 eAkt = Z_Ende;
248 break;
249 case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
250 case EXC_ID_EFONT: rFontBfr.ReadEfont( maStrm ); break;
251 case 0x3E: rTabViewSett.ReadWindow2( maStrm, false );break;
252 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
253 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
254 case 0x43: rXFBfr.ReadXF( maStrm ); break;
255 case 0x44: Ixfe(); break; // IXFE [ 2 ]
258 break;
259 // ----------------------------------------------------------------
260 case Z_Biff3: // ---------------------------------- Z_Biff3 -
262 switch( nOpcode )
264 // skip chart substream
265 case EXC_ID2_BOF:
266 case EXC_ID3_BOF:
267 case EXC_ID4_BOF:
268 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
270 case EXC_ID2_DIMENSIONS:
271 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
272 case EXC_ID2_BLANK:
273 case EXC_ID3_BLANK: ReadBlank(); break;
274 case EXC_ID2_INTEGER: ReadInteger(); break;
275 case EXC_ID2_NUMBER:
276 case EXC_ID3_NUMBER: ReadNumber(); break;
277 case EXC_ID2_LABEL:
278 case EXC_ID3_LABEL: ReadLabel(); break;
279 case EXC_ID2_BOOLERR:
280 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
281 case EXC_ID_RK: ReadRk(); break;
283 case 0x0A: // EOF [ 2345]
284 rNumFmtBfr.CreateScFormats();
285 Eof();
286 eAkt = Z_Ende;
287 break;
288 case 0x14:
289 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
290 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
291 case 0x1A:
292 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
293 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
294 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
295 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
296 case 0x22: Rec1904(); break; // 1904 [ 2345]
297 case 0x26:
298 case 0x27:
299 case 0x28:
300 case 0x29: rPageSett.ReadMargin( maStrm ); break;
301 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
302 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
303 case 0x2F: // FILEPASS [ 2345]
304 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
305 if( eLastErr != ERRCODE_NONE )
306 eAkt = Z_Ende;
307 break;
308 case EXC_ID_FILESHARING: ReadFileSharing(); break;
309 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
310 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
311 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
312 case 0x5D: rObjMgr.ReadObj( maStrm ); break;
313 case 0x7D: Colinfo(); break; // COLINFO [ 345]
314 case 0x8C: Country(); break; // COUNTRY [ 345]
315 case 0x92: rPal.ReadPalette( maStrm ); break;
316 case 0x0206: Formula3(); break; // FORMULA [ 3 ]
317 case 0x0208: Row34(); break; // ROW [ 34 ]
318 case 0x0218: rNameMgr.ReadName( maStrm ); break;
319 case 0x0221: Array34(); break; // ARRAY [ 34 ]
320 case 0x0223: Externname34(); break; // EXTERNNAME [ 34 ]
321 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
322 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
323 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
324 case 0x0243: rXFBfr.ReadXF( maStrm ); break;
325 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
328 break;
329 // ----------------------------------------------------------------
330 case Z_Biff4: // ---------------------------------- Z_Biff4 -
332 switch( nOpcode )
334 // skip chart substream
335 case EXC_ID2_BOF:
336 case EXC_ID3_BOF:
337 case EXC_ID4_BOF:
338 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
340 case EXC_ID2_DIMENSIONS:
341 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
342 case EXC_ID2_BLANK:
343 case EXC_ID3_BLANK: ReadBlank(); break;
344 case EXC_ID2_INTEGER: ReadInteger(); break;
345 case EXC_ID2_NUMBER:
346 case EXC_ID3_NUMBER: ReadNumber(); break;
347 case EXC_ID2_LABEL:
348 case EXC_ID3_LABEL: ReadLabel(); break;
349 case EXC_ID2_BOOLERR:
350 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
351 case EXC_ID_RK: ReadRk(); break;
353 case 0x0A: // EOF [ 2345]
354 rNumFmtBfr.CreateScFormats();
355 Eof();
356 eAkt = Z_Ende;
357 break;
358 case 0x12: SheetProtect(); break; // SHEET PROTECTION
359 case 0x14:
360 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
361 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
362 case 0x1A:
363 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
364 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
365 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
366 case 0x22: Rec1904(); break; // 1904 [ 2345]
367 case 0x26:
368 case 0x27:
369 case 0x28:
370 case 0x29: rPageSett.ReadMargin( maStrm ); break;
371 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
372 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
373 case 0x2F: // FILEPASS [ 2345]
374 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
375 if( eLastErr != ERRCODE_NONE )
376 eAkt = Z_Ende;
377 break;
378 case EXC_ID_FILESHARING: ReadFileSharing(); break;
379 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
380 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
381 case 0x55: DefColWidth(); break;
382 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
383 case 0x5D: rObjMgr.ReadObj( maStrm ); break;
384 case 0x7D: Colinfo(); break; // COLINFO [ 345]
385 case 0x8C: Country(); break; // COUNTRY [ 345]
386 case 0x92: rPal.ReadPalette( maStrm ); break;
387 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
388 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
389 case 0x0208: Row34(); break; // ROW [ 34 ]
390 case 0x0218: rNameMgr.ReadName( maStrm ); break;
391 case 0x0221: Array34(); break; // ARRAY [ 34 ]
392 case 0x0223: Externname34(); break; // EXTERNNAME [ 34 ]
393 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
394 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
395 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
396 case 0x0406: Formula4(); break; // FORMULA [ 4 ]
397 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
398 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
399 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
402 break;
403 // ----------------------------------------------------------------
404 case Z_Biff4W: // --------------------------------- Z_Biff4W -
406 switch( nOpcode )
408 case 0x0A: // EOF [ 2345]
409 eAkt = Z_Ende;
410 break;
411 case 0x12: DocProtect(); break; // PROTECT [ 5]
412 case 0x2F: // FILEPASS [ 2345]
413 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
414 if( eLastErr != ERRCODE_NONE )
415 eAkt = Z_Ende;
416 break;
417 case EXC_ID_FILESHARING: ReadFileSharing(); break;
418 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
419 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
420 case 0x55: DefColWidth(); break;
421 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
422 case 0x8C: Country(); break; // COUNTRY [ 345]
423 case 0x8F: Bundleheader(); break; // BUNDLEHEADER [ 4 ]
424 case 0x92: rPal.ReadPalette( maStrm ); break;
425 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
426 case 0x0218: rNameMgr.ReadName( maStrm ); break;
427 case 0x0223: Externname34(); break; // EXTERNNAME [ 34 ]
428 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
429 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
430 case 0x0409: // BOF [ 4 ]
431 Bof4();
432 if( pExcRoot->eDateiTyp == Biff4 )
434 eAkt = Z_Biff4T;
435 NeueTabelle();
437 else
438 eAkt = Z_Ende;
439 break;
440 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
441 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
442 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
446 break;
447 // ----------------------------------------------------------------
448 case Z_Biff4T: // --------------------------------- Z_Biff4T -
450 switch( nOpcode )
452 // skip chart substream
453 case EXC_ID2_BOF:
454 case EXC_ID3_BOF:
455 case EXC_ID4_BOF:
456 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
458 case EXC_ID2_DIMENSIONS:
459 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
460 case EXC_ID2_BLANK:
461 case EXC_ID3_BLANK: ReadBlank(); break;
462 case EXC_ID2_INTEGER: ReadInteger(); break;
463 case EXC_ID2_NUMBER:
464 case EXC_ID3_NUMBER: ReadNumber(); break;
465 case EXC_ID2_LABEL:
466 case EXC_ID3_LABEL: ReadLabel(); break;
467 case EXC_ID2_BOOLERR:
468 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
469 case EXC_ID_RK: ReadRk(); break;
471 case 0x0A: // EOF [ 2345]
472 Eof();
473 eAkt = Z_Biff4E;
474 break;
475 case 0x12: SheetProtect(); break; // SHEET PROTECTION
476 case 0x14:
477 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
478 case 0x1A:
479 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
480 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
481 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
482 case 0x2F: // FILEPASS [ 2345]
483 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
484 if( eLastErr != ERRCODE_NONE )
485 eAkt = Z_Ende;
486 break;
487 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
488 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
489 case 0x55: DefColWidth(); break;
490 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
491 case 0x5D: rObjMgr.ReadObj( maStrm ); break;
492 case 0x7D: Colinfo(); break; // COLINFO [ 345]
493 case 0x8C: Country(); break; // COUNTRY [ 345]
494 case 0x8F: Bundleheader(); break; // BUNDLEHEADER [ 4 ]
495 case 0x92: rPal.ReadPalette( maStrm ); break;
496 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
497 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
498 case 0x0208: Row34(); break; // ROW [ 34 ]
499 case 0x0218: rNameMgr.ReadName( maStrm ); break;
500 case 0x0221: Array34(); break;
501 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
502 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
503 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
504 case 0x0406: Formula4(); break;
505 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
506 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
507 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
511 break;
512 // ----------------------------------------------------------------
513 case Z_Biff4E: // --------------------------------- Z_Biff4E -
515 switch( nOpcode )
517 case 0x0A: // EOF [ 2345]
518 eAkt = Z_Ende;
519 break;
520 case 0x8F: break; // BUNDLEHEADER [ 4 ]
521 case 0x0409: // BOF [ 4 ]
522 Bof4();
523 NeueTabelle();
524 if( pExcRoot->eDateiTyp == Biff4 )
526 eAkt = Z_Biff4T;
528 else
530 ePrev = eAkt;
531 eAkt = Z_Biffn0;
533 break;
537 break;
538 case Z_Biff5WPre: // ------------------------------ Z_Biff5WPre -
540 switch( nOpcode )
542 case 0x0A: // EOF [ 2345]
543 eAkt = Z_Biff5W;
544 aIn.SeekGlobalPosition(); // und zurueck an alte Position
545 break;
546 case 0x12: DocProtect(); break; // PROTECT [ 5]
547 case 0x2F: // FILEPASS [ 2345]
548 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
549 if( eLastErr != ERRCODE_NONE )
550 eAkt = Z_Ende;
551 break;
552 case EXC_ID_FILESHARING: ReadFileSharing(); break;
553 case 0x3D: Window1(); break;
554 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
555 case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5]
556 case 0x8C: Country(); break; // COUNTRY [ 345]
557 // PALETTE follows XFs, but already needed while reading the XFs
558 case 0x92: rPal.ReadPalette( maStrm ); break;
561 break;
562 case Z_Biff5W: // --------------------------------- Z_Biff5W -
564 switch( nOpcode )
566 case 0x0A: // EOF [ 2345]
567 rNumFmtBfr.CreateScFormats();
568 rXFBfr.CreateUserStyles();
569 eAkt = Z_Biff5E;
570 break;
571 case 0x18: rNameMgr.ReadName( maStrm ); break;
572 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
573 case 0x22: Rec1904(); break; // 1904 [ 2345]
574 case 0x31: rFontBfr.ReadFont( maStrm ); break;
575 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
576 case 0x8D: Hideobj(); break; // HIDEOBJ [ 345]
577 case 0xDE: Olesize(); break;
578 case 0xE0: rXFBfr.ReadXF( maStrm ); break;
579 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
580 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
584 break;
585 // ----------------------------------------------------------------
586 case Z_Biff5TPre: // ------------------------------- Z_Biff5Pre -
588 if( nOpcode == 0x0809 )
589 nBofLevel++;
590 else if( (nOpcode == 0x000A) && nBofLevel )
591 nBofLevel--;
592 else if( !nBofLevel ) // don't read chart records
594 switch( nOpcode )
596 case EXC_ID2_DIMENSIONS:
597 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
598 case 0x08: Row25(); break; // ROW [ 2 5]
599 case 0x0A: // EOF [ 2345]
600 eAkt = Z_Biff5T;
601 aIn.SeekGlobalPosition(); // und zurueck an alte Position
602 break;
603 case 0x12: SheetProtect(); break; // SHEET PROTECTION
604 case 0x1A:
605 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
606 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
607 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
608 case 0x21: Array25(); break; // ARRAY [ 2 5]
609 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
610 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
611 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
612 case 0x55: DefColWidth(); break;
613 case 0x7D: Colinfo(); break; // COLINFO [ 345]
614 case 0x81: Wsbool(); break; // WSBOOL [ 2345]
615 case 0x8C: Country(); break; // COUNTRY [ 345]
616 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
617 case 0x0208: Row34(); break; // ROW [ 34 ]
618 case 0x0221: Array34(); break; // ARRAY [ 34 ]
619 case 0x0223: Externname34(); break; // EXTERNNAME [ 34 ]
620 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
621 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
622 case 0x04BC: Shrfmla(); break; // SHRFMLA [ 5]
626 break;
627 // ----------------------------------------------------------------
628 case Z_Biff5T: // --------------------------------- Z_Biff5T -
630 switch( nOpcode )
632 case EXC_ID2_BLANK:
633 case EXC_ID3_BLANK: ReadBlank(); break;
634 case EXC_ID2_INTEGER: ReadInteger(); break;
635 case EXC_ID2_NUMBER:
636 case EXC_ID3_NUMBER: ReadNumber(); break;
637 case EXC_ID2_LABEL:
638 case EXC_ID3_LABEL: ReadLabel(); break;
639 case EXC_ID2_BOOLERR:
640 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
641 case EXC_ID_RK: ReadRk(); break;
643 case 0x0006:
644 case 0x0206:
645 case 0x0406: Formula25(); break;
646 case 0x0A: Eof(); eAkt = Z_Biff5E; break;
647 case 0x14:
648 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
649 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
650 case 0x1C: rObjMgr.ReadNote( maStrm ); break;
651 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
652 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
653 case 0x26:
654 case 0x27:
655 case 0x28:
656 case 0x29: rPageSett.ReadMargin( maStrm ); break;
657 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
658 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
659 case 0x2F: // FILEPASS [ 2345]
660 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
661 if( eLastErr != ERRCODE_NONE )
662 eAkt = Z_Ende;
663 break;
664 case 0x5D: rObjMgr.ReadObj( maStrm ); break;
665 case 0x83:
666 case 0x84: rPageSett.ReadCenter( maStrm ); break;
667 case 0xA0: rTabViewSett.ReadScl( maStrm ); break;
668 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
669 case 0xBD: Mulrk(); break; // MULRK [ 5]
670 case 0xBE: Mulblank(); break; // MULBLANK [ 5]
671 case 0xD6: Rstring(); break; // RSTRING [ 5]
672 case 0x00E5: Cellmerging(); break; // #i62300#
673 case 0x0236: TableOp(); break; // TABLE [ 5]
674 case 0x0809: // BOF [ 5]
675 XclTools::SkipSubStream( maStrm );
676 break;
680 break;
681 // ----------------------------------------------------------------
682 case Z_Biff5E: // --------------------------------- Z_Biff5E -
684 switch( nOpcode )
686 case 0x0809: // BOF [ 5]
687 Bof5();
688 NeueTabelle();
689 switch( pExcRoot->eDateiTyp )
691 case Biff5:
692 case Biff5M4:
693 eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
694 nBofLevel = 0;
695 aIn.StoreGlobalPosition(); // und Position merken
696 break;
697 case Biff5C: // chart sheet
698 GetObjectManager().ReadTabChart( maStrm );
699 Eof();
700 GetTracer().TraceChartOnlySheet();
701 break;
702 case Biff5V:
703 default:
704 pD->SetVisible( GetCurrScTab(), FALSE );
705 ePrev = eAkt;
706 eAkt = Z_Biffn0;
708 DBG_ASSERT( pExcRoot->eDateiTyp != Biff5W,
709 "+ImportExcel::Read(): Doppel-Whopper-Workbook!" );
711 break;
715 break;
716 case Z_Biffn0: // --------------------------------- Z_Biffn0 -
718 switch( nOpcode )
720 case 0x0A: // EOF [ 2345]
721 eAkt = ePrev;
722 IncCurrScTab();
723 break;
727 break;
728 // ----------------------------------------------------------------
729 case Z_Ende: // ----------------------------------- Z_Ende -
730 DBG_ERROR( "*ImportExcel::Read(): Not possible state!" );
731 break;
732 default: DBG_ERROR( "-ImportExcel::Read(): Zustand vergessen!" );
736 if( eLastErr == eERR_OK )
738 pProgress.reset();
740 AdjustRowHeight();
741 PostDocLoad();
743 pD->CalcAfterLoad();
745 const XclImpAddressConverter& rAddrConv = GetAddressConverter();
746 if( rAddrConv.IsTabTruncated() )
747 eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
748 else if( bTabTruncated || rAddrConv.IsRowTruncated() )
749 eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
750 else if( rAddrConv.IsColTruncated() )
751 eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
754 return eLastErr;
758 //___________________________________________________________________
760 FltError ImportExcel8::Read( void )
762 #if EXC_INCL_DUMPER
764 Biff8RecDumper aDumper( GetRoot(), TRUE );
765 if( aDumper.Dump( aIn ) )
766 return ERRCODE_ABORT;
768 #endif
769 // read the entire BIFF8 stream
770 // don't look too close - this stuff seriously needs to be reworked
772 XclImpPageSettings& rPageSett = GetPageSettings();
773 XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
774 XclImpPalette& rPal = GetPalette();
775 XclImpFontBuffer& rFontBfr = GetFontBuffer();
776 XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
777 XclImpXFBuffer& rXFBfr = GetXFBuffer();
778 XclImpSst& rSst = GetSst();
779 XclImpTabInfo& rTabInfo = GetTabInfo();
780 XclImpNameManager& rNameMgr = GetNameManager();
781 XclImpLinkManager& rLinkMgr = GetLinkManager();
782 XclImpObjectManager& rObjMgr = GetObjectManager();
783 XclImpCondFormatManager& rCondFmtMgr = GetCondFormatManager();
784 XclImpPivotTableManager& rPTableMgr = GetPivotTableManager();
785 XclImpWebQueryBuffer& rWQBfr = GetWebQueryBuffer();
787 bool bInUserView = false; // true = In USERSVIEW(BEGIN|END) record block.
789 enum XclImpReadState
791 EXC_STATE_BEFORE_GLOBALS, /// Before workbook globals (wait for initial BOF).
792 EXC_STATE_GLOBALS_PRE, /// Prefetch for workbook globals.
793 EXC_STATE_GLOBALS, /// Workbook globals.
794 EXC_STATE_BEFORE_SHEET, /// Before worksheet (wait for new worksheet BOF).
795 EXC_STATE_SHEET_PRE, /// Prefetch for worksheet.
796 EXC_STATE_SHEET, /// Worksheet.
797 EXC_STATE_END /// Stop reading.
800 XclImpReadState eAkt = EXC_STATE_BEFORE_GLOBALS;
802 FltError eLastErr = eERR_OK;
804 ::std::auto_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
805 aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
807 bool bSheetHasCodeName = false;
809 std::vector< String > CodeNames;
811 std::vector < SCTAB > nTabsWithNoCodeName;
813 while( eAkt != EXC_STATE_END )
815 aIn.StartNextRecord();
816 if( !aIn.IsValid() )
818 // #124240# #i63591# finalize table if EOF is missing
819 switch( eAkt )
821 case EXC_STATE_SHEET_PRE:
822 eAkt = EXC_STATE_SHEET;
823 aIn.SeekGlobalPosition();
824 continue; // next iteration in while loop
825 // break; // unxsols warning: statement unreachable
826 case EXC_STATE_SHEET:
827 Eof();
828 eAkt = EXC_STATE_END;
829 break;
830 default:
831 eAkt = EXC_STATE_END;
835 if( eAkt == EXC_STATE_END )
836 break;
838 if( eAkt != EXC_STATE_SHEET_PRE && eAkt != EXC_STATE_GLOBALS_PRE )
839 pProgress->ProgressAbs( aIn.GetSvStreamPos() );
841 sal_uInt16 nRecId = aIn.GetRecId();
843 /* #i39464# Ignore records between USERSVIEWBEGIN and USERSVIEWEND
844 completely (user specific view settings). Otherwise view settings
845 and filters are loaded multiple times, which at least causes
846 problems in auto-filters. */
847 switch( nRecId )
849 case EXC_ID_USERSVIEWBEGIN:
850 DBG_ASSERT( !bInUserView, "ImportExcel8::Read - nested user view settings" );
851 bInUserView = true;
852 break;
853 case EXC_ID_USERSVIEWEND:
854 DBG_ASSERT( bInUserView, "ImportExcel8::Read - not in user view settings" );
855 bInUserView = false;
856 break;
859 if( !bInUserView ) switch( eAkt )
861 // ----------------------------------------------------------------
862 // before workbook globals: wait for initial workbook globals BOF
863 case EXC_STATE_BEFORE_GLOBALS:
865 if( nRecId == EXC_ID5_BOF )
867 DBG_ASSERT( GetBiff() == EXC_BIFF8, "ImportExcel8::Read - wrong BIFF version" );
868 Bof5();
869 if( pExcRoot->eDateiTyp == Biff8W )
871 eAkt = EXC_STATE_GLOBALS_PRE;
872 maStrm.StoreGlobalPosition();
873 nBdshtTab = 0;
875 else if( pExcRoot->eDateiTyp == Biff8 )
877 // #i62752# possible to have BIFF8 sheet without globals
878 NeueTabelle();
879 eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
880 bSheetHasCodeName = false; // reset
881 aIn.StoreGlobalPosition();
885 break;
887 // ----------------------------------------------------------------
888 // prefetch for workbook globals
889 case EXC_STATE_GLOBALS_PRE:
891 switch( nRecId )
893 case EXC_ID_EOF:
894 case EXC_ID_EXTSST:
895 /* #i56376# evil hack: if EOF for globals is missing,
896 simulate it. This hack works only for the bugdoc
897 given in the issue, where the sheet substreams
898 start directly after the EXTSST record. A future
899 implementation should be more robust against
900 missing EOFs. */
901 if( (nRecId == EXC_ID_EOF) ||
902 ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
904 eAkt = EXC_STATE_GLOBALS;
905 aIn.SeekGlobalPosition();
907 break;
908 case 0x12: DocProtect(); break; // PROTECT [ 5678]
909 case 0x13: DocPasssword(); break;
910 case 0x19: WinProtection(); break;
911 case 0x2F: // FILEPASS [ 2345 ]
912 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
913 if( eLastErr != ERRCODE_NONE )
914 eAkt = EXC_STATE_END;
915 break;
916 case EXC_ID_FILESHARING: ReadFileSharing(); break;
917 case 0x3D: Window1(); break;
918 case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
919 case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5 ]
920 case 0x8C: Country(); break; // COUNTRY [ 345 ]
922 // PALETTE follows XFs, but already needed while reading the XFs
923 case EXC_ID_PALETTE: rPal.ReadPalette( maStrm ); break;
926 break;
928 // ----------------------------------------------------------------
929 // workbook globals
930 case EXC_STATE_GLOBALS:
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 rNumFmtBfr.CreateScFormats();
946 rXFBfr.CreateUserStyles();
947 rPTableMgr.ReadPivotCaches( maStrm );
948 eAkt = EXC_STATE_BEFORE_SHEET;
950 break;
951 case 0x0E: Precision(); break; // PRECISION
952 case 0x22: Rec1904(); break; // 1904 [ 2345 ]
953 case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
954 case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ]
955 case 0xD3: /*ReadBasic()*/bHasBasic = true; break;
956 // case 0xD3: ReadBasic(); break;
957 case 0xDE: Olesize(); break;
958 case 0x01BA: Codename( TRUE ); break;
960 case EXC_ID_USESELFS: ReadUsesElfs(); break;
962 case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
963 case EXC_ID4_FORMAT: rNumFmtBfr.ReadFormat( maStrm ); break;
964 case EXC_ID5_XF: rXFBfr.ReadXF( maStrm ); break;
965 case EXC_ID_STYLE: rXFBfr.ReadStyle( maStrm ); break;
967 case EXC_ID_SST: rSst.ReadSst( maStrm ); break;
968 case EXC_ID_TABID: rTabInfo.ReadTabid( maStrm ); break;
969 case EXC_ID_NAME: rNameMgr.ReadName( maStrm ); break;
971 case EXC_ID_EXTERNSHEET: rLinkMgr.ReadExternsheet( maStrm ); break;
972 case EXC_ID_SUPBOOK: rLinkMgr.ReadSupbook( maStrm ); break;
973 case EXC_ID_XCT: rLinkMgr.ReadXct( maStrm ); break;
974 case EXC_ID_CRN: rLinkMgr.ReadCrn( maStrm ); break;
975 case EXC_ID_EXTERNNAME: rLinkMgr.ReadExternname( maStrm, pFormConv ); break;
977 case EXC_ID_MSODRAWINGGROUP:rObjMgr.ReadMsoDrawingGroup( maStrm ); break;
979 case EXC_ID_SXIDSTM: rPTableMgr.ReadSxidstm( maStrm ); break;
980 case EXC_ID_SXVS: rPTableMgr.ReadSxvs( maStrm ); break;
981 case EXC_ID_DCONREF: rPTableMgr.ReadDconref( maStrm ); break;
985 break;
987 // ----------------------------------------------------------------
988 // before worksheet: wait for new worksheet BOF
989 case EXC_STATE_BEFORE_SHEET:
991 if( nRecId == EXC_ID5_BOF )
993 // #94191# import only 256 sheets
994 if( GetCurrScTab() > GetScMaxPos().Tab() )
996 XclTools::SkipSubStream( maStrm );
997 // #i29930# show warning box
998 GetAddressConverter().CheckScTab( GetCurrScTab(), true );
999 eAkt = EXC_STATE_END;
1001 else
1003 Bof5();
1004 NeueTabelle();
1005 switch( pExcRoot->eDateiTyp )
1007 case Biff8: // worksheet
1008 case Biff8M4: // macro sheet
1009 eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
1010 aIn.StoreGlobalPosition();
1011 break;
1012 case Biff8C: // chart sheet
1013 rObjMgr.ReadTabChart( maStrm );
1014 Eof();
1015 GetTracer().TraceChartOnlySheet();
1016 break;
1017 case Biff8W: // workbook
1018 DBG_ERRORFILE( "ImportExcel8::Read - double workbook globals" );
1019 // run through
1020 case Biff8V: // VB module
1021 default:
1022 // TODO: do not create a sheet in the Calc document
1023 pD->SetVisible( GetCurrScTab(), FALSE );
1024 XclTools::SkipSubStream( maStrm );
1025 IncCurrScTab();
1030 break;
1032 // ----------------------------------------------------------------
1033 // prefetch for worksheet
1034 case EXC_STATE_SHEET_PRE:
1036 switch( nRecId )
1038 // skip chart substream
1039 case EXC_ID2_BOF:
1040 case EXC_ID3_BOF:
1041 case EXC_ID4_BOF:
1042 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
1044 case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( maStrm, false );break;
1045 case EXC_ID_SCL: rTabViewSett.ReadScl( maStrm ); break;
1046 case EXC_ID_PANE: rTabViewSett.ReadPane( maStrm ); break;
1047 case EXC_ID_SELECTION: rTabViewSett.ReadSelection( maStrm ); break;
1049 case EXC_ID2_DIMENSIONS:
1050 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
1052 case 0x0A: // EOF [ 2345 ]
1054 eAkt = EXC_STATE_SHEET;
1055 String sName;
1056 GetDoc().GetName( GetCurrScTab(), sName );
1057 if ( !bSheetHasCodeName )
1059 nTabsWithNoCodeName.push_back( GetCurrScTab() );
1060 OSL_TRACE("No Codename for %d", GetCurrScTab() );
1062 else
1064 String sCodeName;
1065 GetDoc().GetCodeName( GetCurrScTab(), sCodeName );
1066 OSL_TRACE("Have CodeName %s for SheetName %s",
1067 rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
1068 CodeNames.push_back( sCodeName );
1071 bSheetHasCodeName = false; // reset
1074 aIn.SeekGlobalPosition(); // und zurueck an alte Position
1075 break;
1077 case 0x12: SheetProtect(); break;
1078 case 0x13: SheetPassword(); break;
1079 case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
1080 case 0x55: DefColWidth(); break;
1081 case 0x7D: Colinfo(); break; // COLINFO [ 345 ]
1082 case 0x81: Wsbool(); break; // WSBOOL [ 2345 ]
1083 case 0x8C: Country(); break; // COUNTRY [ 345 ]
1084 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45 ]
1085 case 0x9B: FilterMode(); break; // FILTERMODE
1086 case 0x9D: AutoFilterInfo(); break;// AUTOFILTERINFO
1087 case 0x9E: AutoFilter(); break; // AUTOFILTER
1088 case 0x01BA: Codename( FALSE ); bSheetHasCodeName = true; break;
1089 case 0x0208: Row34(); break; // ROW [ 34 ]
1090 case 0x0021:
1091 case 0x0221: Array34(); break; // ARRAY [ 34 ]
1092 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345 ]
1093 case 0x04BC: Shrfmla(); break; // SHRFMLA [ 5 ]
1094 case 0x0867: SheetProtection(); break; // SHEETPROTECTION
1097 break;
1099 // ----------------------------------------------------------------
1100 // worksheet
1101 case EXC_STATE_SHEET:
1103 switch( nRecId )
1105 // skip unknown substreams
1106 case EXC_ID2_BOF:
1107 case EXC_ID3_BOF:
1108 case EXC_ID4_BOF:
1109 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
1111 case EXC_ID_EOF: Eof(); eAkt = EXC_STATE_BEFORE_SHEET; break;
1113 case EXC_ID2_BLANK:
1114 case EXC_ID3_BLANK: ReadBlank(); break;
1115 case EXC_ID2_INTEGER: ReadInteger(); break;
1116 case EXC_ID2_NUMBER:
1117 case EXC_ID3_NUMBER: ReadNumber(); break;
1118 case EXC_ID2_LABEL:
1119 case EXC_ID3_LABEL: ReadLabel(); break;
1120 case EXC_ID2_BOOLERR:
1121 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
1122 case EXC_ID_RK: ReadRk(); break;
1124 case 0x0006:
1125 case 0x0206:
1126 case 0x0406: Formula25(); break; // FORMULA [ 2 5 ]
1127 case 0x000C: Calccount(); break; // CALCCOUNT
1128 case 0x0010: Delta(); break; // DELTA
1129 case 0x0011: Iteration(); break; // ITERATION
1130 case 0x007E:
1131 case 0x00AE: Scenman(); break; // SCENMAN
1132 case 0x00AF: Scenario(); break; // SCENARIO
1133 case 0x00BD: Mulrk(); break; // MULRK [ 5 ]
1134 case 0x00BE: Mulblank(); break; // MULBLANK [ 5 ]
1135 case 0x00D6: Rstring(); break; // RSTRING [ 5 ]
1136 case 0x00E5: Cellmerging(); break; // CELLMERGING
1137 case 0x00FD: Labelsst(); break; // LABELSST [ 8 ]
1138 case 0x0236: TableOp(); break; // TABLE
1140 case EXC_ID_HORPAGEBREAKS:
1141 case EXC_ID_VERPAGEBREAKS: rPageSett.ReadPageBreaks( maStrm ); break;
1142 case EXC_ID_HEADER:
1143 case EXC_ID_FOOTER: rPageSett.ReadHeaderFooter( maStrm ); break;
1144 case EXC_ID_LEFTMARGIN:
1145 case EXC_ID_RIGHTMARGIN:
1146 case EXC_ID_TOPMARGIN:
1147 case EXC_ID_BOTTOMMARGIN: rPageSett.ReadMargin( maStrm ); break;
1148 case EXC_ID_PRINTHEADERS: rPageSett.ReadPrintHeaders( maStrm ); break;
1149 case EXC_ID_PRINTGRIDLINES: rPageSett.ReadPrintGridLines( maStrm ); break;
1150 case EXC_ID_HCENTER:
1151 case EXC_ID_VCENTER: rPageSett.ReadCenter( maStrm ); break;
1152 case EXC_ID_SETUP: rPageSett.ReadSetup( maStrm ); break;
1153 case EXC_ID8_IMGDATA: rPageSett.ReadImgData( maStrm ); break;
1155 case EXC_ID_MSODRAWING: rObjMgr.ReadMsoDrawing( maStrm ); break;
1156 // #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format
1157 case EXC_ID_OBJ: rObjMgr.ReadObj( maStrm ); break;
1158 case EXC_ID_NOTE: rObjMgr.ReadNote( maStrm ); break;
1160 case EXC_ID_HLINK: XclImpHyperlink::ReadHlink( maStrm ); break;
1161 case EXC_ID_LABELRANGES: XclImpLabelranges::ReadLabelranges( maStrm ); break;
1163 case EXC_ID_CONDFMT: rCondFmtMgr.ReadCondfmt( maStrm ); break;
1164 case EXC_ID_CF: rCondFmtMgr.ReadCF( maStrm ); break;
1166 case EXC_ID_DVAL: XclImpValidation::ReadDval( maStrm ); break;
1167 case EXC_ID_DV: XclImpValidation::ReadDV( maStrm ); break;
1169 case EXC_ID_QSI: rWQBfr.ReadQsi( maStrm ); break;
1170 case EXC_ID_WQSTRING: rWQBfr.ReadWqstring( maStrm ); break;
1171 case EXC_ID_PQRY: rWQBfr.ReadParamqry( maStrm ); break;
1172 case EXC_ID_WQSETT: rWQBfr.ReadWqsettings( maStrm ); break;
1173 case EXC_ID_WQTABLES: rWQBfr.ReadWqtables( maStrm ); break;
1175 case EXC_ID_SXVIEW: rPTableMgr.ReadSxview( maStrm ); break;
1176 case EXC_ID_SXVD: rPTableMgr.ReadSxvd( maStrm ); break;
1177 case EXC_ID_SXVI: rPTableMgr.ReadSxvi( maStrm ); break;
1178 case EXC_ID_SXIVD: rPTableMgr.ReadSxivd( maStrm ); break;
1179 case EXC_ID_SXPI: rPTableMgr.ReadSxpi( maStrm ); break;
1180 case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break;
1181 case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break;
1182 case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break;
1183 case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break;
1185 // 0x0862 (SHEETEXT)
1186 case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break;
1189 break;
1191 // ----------------------------------------------------------------
1192 default:;
1196 if( eLastErr == eERR_OK )
1198 // In some strange circumstances a the codename might be missing
1199 // # Create any missing Sheet CodeNames
1200 std::vector < SCTAB >::iterator it_end = nTabsWithNoCodeName.end();
1201 for ( std::vector < SCTAB >::iterator it = nTabsWithNoCodeName.begin(); it != it_end; ++it )
1203 bool bGotCodeName = false;
1204 SCTAB nTab = 1;
1205 OSL_TRACE("Trying to find suitable codename for %d", *it );
1206 while ( true )
1208 String sTmpName( RTL_CONSTASCII_USTRINGPARAM("Sheet" ) );
1209 sTmpName += String::CreateFromInt32( sal_Int32(nTab++) );
1210 std::vector< String >::iterator codeName_It = CodeNames.begin();
1211 std::vector< String >::iterator codeName_It_end = CodeNames.end();
1212 // search for codename
1213 for ( ; codeName_It != codeName_It_end; ++codeName_It )
1215 if ( *codeName_It == sTmpName )
1216 break;
1219 if ( codeName_It == codeName_It_end ) // generated codename not found
1221 OSL_TRACE("Using generated codename %s", rtl::OUStringToOString( sTmpName, RTL_TEXTENCODING_UTF8 ).getStr() );
1222 // Set new codename
1223 GetDoc().SetCodeName( *it, sTmpName );
1224 // Record newly used codename
1225 CodeNames.push_back( sTmpName );
1226 // Record those we have created so they can be created in
1227 // basic
1228 AutoGeneratedCodeNames.push_back( sTmpName );
1229 break;
1234 // #i45843# Convert pivot tables before calculation, so they are available
1235 // for the GETPIVOTDATA function.
1236 if( GetBiff() == EXC_BIFF8 )
1237 GetPivotTableManager().ConvertPivotTables();
1239 pProgress.reset();
1241 #if 0
1242 // Excel documents look much better without this call; better in the
1243 // sense that the row heights are identical to the original heights in
1244 // Excel.
1245 AdjustRowHeight();
1246 #endif
1247 PostDocLoad();
1249 pD->CalcAfterLoad();
1251 // import change tracking data
1252 XclImpChangeTrack aImpChTr( GetRoot(), maStrm );
1253 aImpChTr.Apply();
1255 const XclImpAddressConverter& rAddrConv = GetAddressConverter();
1256 if( rAddrConv.IsTabTruncated() )
1257 eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
1258 else if( bTabTruncated || rAddrConv.IsRowTruncated() )
1259 eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
1260 else if( rAddrConv.IsColTruncated() )
1261 eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
1263 if( GetBiff() == EXC_BIFF8 )
1264 GetPivotTableManager().MaybeRefreshPivotTables();
1267 return eLastErr;
1270 //___________________________________________________________________