LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / source / filter / excel / read.cxx
blobcf9465a37c95f7d9e9e6ffa4ce6cd775d8197931
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <document.hxx>
21 #include <scerrors.hxx>
22 #include <fprogressbar.hxx>
23 #include <globstr.hrc>
24 #include <xlcontent.hxx>
25 #include <xltracer.hxx>
26 #include <xltable.hxx>
27 #include <xihelper.hxx>
28 #include <xipage.hxx>
29 #include <xiview.hxx>
30 #include <xilink.hxx>
31 #include <xiname.hxx>
32 #include <xlname.hxx>
33 #include <xicontent.hxx>
34 #include <xiescher.hxx>
35 #include <xipivot.hxx>
36 #include <xistyle.hxx>
37 #include <XclImpChangeTrack.hxx>
38 #include <documentimport.hxx>
40 #include <root.hxx>
41 #include <imp_op.hxx>
42 #include <excimp8.hxx>
44 #include <unotools/configmgr.hxx>
46 #include <memory>
48 namespace
50 bool TryStartNextRecord(XclImpStream& rIn, std::size_t nProgressBasePos)
52 bool bValid = true;
53 // i#115255 fdo#40304 BOUNDSHEET doesn't point to a valid
54 // BOF record position. Scan the records manually (from
55 // the BOUNDSHEET position) until we find a BOF. Some 3rd
56 // party Russian programs generate invalid xls docs with
57 // this kind of silliness.
58 if (rIn.PeekRecId(nProgressBasePos) == EXC_ID5_BOF)
59 // BOUNDSHEET points to a valid BOF record. Good.
60 rIn.StartNextRecord(nProgressBasePos);
61 else
63 while (bValid && rIn.GetRecId() != EXC_ID5_BOF)
64 bValid = rIn.StartNextRecord();
66 return bValid;
70 ErrCode ImportExcel::Read()
72 XclImpPageSettings& rPageSett = GetPageSettings();
73 XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
74 XclImpPalette& rPal = GetPalette();
75 XclImpFontBuffer& rFontBfr = GetFontBuffer();
76 XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
77 XclImpXFBuffer& rXFBfr = GetXFBuffer();
78 XclImpNameManager& rNameMgr = GetNameManager();
79 // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
81 enum STATE {
82 Z_BiffNull, // not a valid Biff-Format
83 Z_Biff2, // Biff2: only one table
85 Z_Biff3, // Biff3: only one table
87 Z_Biff4, // Biff4: only one table
88 Z_Biff4W, // Biff4 Workbook: Globals
89 Z_Biff4T, // Biff4 Workbook: a table itself
90 Z_Biff4E, // Biff4 Workbook: between tables
92 Z_Biff5WPre,// Biff5: Prefetch Workbook
93 Z_Biff5W, // Biff5: Globals
94 Z_Biff5TPre,// Biff5: Prefetch for Shrfmla/Array Formula
95 Z_Biff5T, // Biff5: a table itself
96 Z_Biff5E, // Biff5: between tables
97 Z_Biffn0, // all Biffs: skip table till next EOF
98 Z_End };
100 STATE eCurrent = Z_BiffNull, ePrev = Z_BiffNull;
102 ErrCode eLastErr = ERRCODE_NONE;
103 sal_uInt16 nOpcode;
104 sal_uInt16 nBofLevel = 0;
106 std::unique_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
107 aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
109 /* #i104057# Need to track a base position for progress bar calculation,
110 because sheet substreams may not be in order of sheets. */
111 std::size_t nProgressBasePos = 0;
112 std::size_t nProgressBaseSize = 0;
114 for (; eCurrent != Z_End; mnLastRecId = nOpcode)
116 if( eCurrent == Z_Biff5E )
118 sal_uInt16 nScTab = GetCurrScTab();
119 if( nScTab < maSheetOffsets.size() )
121 nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
122 nProgressBasePos = maSheetOffsets[ nScTab ];
124 bool bValid = TryStartNextRecord(aIn, nProgressBasePos);
125 if (!bValid)
127 // Safeguard ourselves from potential infinite loop.
128 eCurrent = Z_End;
131 else
132 eCurrent = Z_End;
134 else
135 aIn.StartNextRecord();
137 nOpcode = aIn.GetRecId();
139 if( !aIn.IsValid() )
141 // finalize table if EOF is missing
142 switch( eCurrent )
144 case Z_Biff2:
145 case Z_Biff3:
146 case Z_Biff4:
147 case Z_Biff4T:
148 case Z_Biff5TPre:
149 case Z_Biff5T:
150 rNumFmtBfr.CreateScFormats();
151 Eof();
152 break;
153 default:;
155 break;
158 if( eCurrent == Z_End )
159 break;
161 if( eCurrent != Z_Biff5TPre && eCurrent != Z_Biff5WPre )
162 pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
164 switch( eCurrent )
167 case Z_BiffNull: // ------------------------------- Z_BiffNull -
169 switch( nOpcode )
171 case EXC_ID2_BOF:
172 case EXC_ID3_BOF:
173 case EXC_ID4_BOF:
174 case EXC_ID5_BOF:
176 // #i23425# don't rely on the record ID, but on the detected BIFF version
177 switch( GetBiff() )
179 case EXC_BIFF2:
180 Bof2();
181 if( pExcRoot->eDateiTyp == Biff2 )
183 eCurrent = Z_Biff2;
184 NewTable();
186 break;
187 case EXC_BIFF3:
188 Bof3();
189 if( pExcRoot->eDateiTyp == Biff3 )
191 eCurrent = Z_Biff3;
192 NewTable();
194 break;
195 case EXC_BIFF4:
196 Bof4();
197 if( pExcRoot->eDateiTyp == Biff4 )
199 eCurrent = Z_Biff4;
200 NewTable();
202 else if( pExcRoot->eDateiTyp == Biff4W )
203 eCurrent = Z_Biff4W;
204 break;
205 case EXC_BIFF5:
206 Bof5();
207 if( pExcRoot->eDateiTyp == Biff5W )
209 eCurrent = Z_Biff5WPre;
211 nBdshtTab = 0;
213 aIn.StoreGlobalPosition(); // store position
215 else if( pExcRoot->eDateiTyp == Biff5 )
217 // #i62752# possible to have BIFF5 sheet without globals
218 NewTable();
219 eCurrent = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
220 nBofLevel = 0;
221 aIn.StoreGlobalPosition(); // store position
223 break;
224 default:
225 DBG_ERROR_BIFF();
228 break;
231 break;
233 case Z_Biff2: // ---------------------------------- Z_Biff2 -
235 switch( nOpcode )
237 case EXC_ID2_DIMENSIONS:
238 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
239 case EXC_ID2_BLANK:
240 case EXC_ID3_BLANK: ReadBlank(); break;
241 case EXC_ID2_INTEGER: ReadInteger(); break;
242 case EXC_ID2_NUMBER:
243 case EXC_ID3_NUMBER: ReadNumber(); break;
244 case EXC_ID2_LABEL:
245 case EXC_ID3_LABEL: ReadLabel(); break;
246 case EXC_ID2_BOOLERR:
247 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
248 case EXC_ID_RK: ReadRk(); break;
250 case 0x06: Formula25(); break; // FORMULA [ 2 5]
251 case 0x08: Row25(); break; // ROW [ 2 5]
252 case 0x0A: // EOF [ 2345]
253 rNumFmtBfr.CreateScFormats();
254 rNameMgr.ConvertAllTokens();
255 Eof();
256 eCurrent = Z_End;
257 break;
258 case 0x14:
259 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
260 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
261 case 0x18: rNameMgr.ReadName( maStrm ); break;
262 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
263 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
264 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
265 case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ]
266 case 0x21: Array25(); break; // ARRAY [ 2 5]
267 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
268 case 0x24: Colwidth(); break; // COLWIDTH [ 2 ]
269 case 0x25: Defrowheight2(); break; // DEFAULTROWHEI[ 2 ]
270 case 0x26:
271 case 0x27:
272 case 0x28:
273 case 0x29: rPageSett.ReadMargin( maStrm ); break;
274 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
275 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
276 case 0x2F: // FILEPASS [ 2345]
277 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
278 if( eLastErr != ERRCODE_NONE )
279 eCurrent = Z_End;
280 break;
281 case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
282 case EXC_ID_EFONT: rFontBfr.ReadEfont( maStrm ); break;
283 case 0x3E: rTabViewSett.ReadWindow2( maStrm, false );break;
284 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
285 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
286 case 0x43: rXFBfr.ReadXF( maStrm ); break;
287 case 0x44: Ixfe(); break; // IXFE [ 2 ]
290 break;
292 case Z_Biff3: // ---------------------------------- Z_Biff3 -
294 switch( nOpcode )
296 // skip chart substream
297 case EXC_ID2_BOF:
298 case EXC_ID3_BOF:
299 case EXC_ID4_BOF:
300 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
302 case EXC_ID2_DIMENSIONS:
303 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
304 case EXC_ID2_BLANK:
305 case EXC_ID3_BLANK: ReadBlank(); break;
306 case EXC_ID2_INTEGER: ReadInteger(); break;
307 case EXC_ID2_NUMBER:
308 case EXC_ID3_NUMBER: ReadNumber(); break;
309 case EXC_ID2_LABEL:
310 case EXC_ID3_LABEL: ReadLabel(); break;
311 case EXC_ID2_BOOLERR:
312 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
313 case EXC_ID_RK: ReadRk(); break;
315 case 0x0A: // EOF [ 2345]
316 rNumFmtBfr.CreateScFormats();
317 rNameMgr.ConvertAllTokens();
318 Eof();
319 eCurrent = Z_End;
320 break;
321 case 0x14:
322 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
323 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
324 case 0x1A:
325 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
326 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
327 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
328 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
329 case 0x22: Rec1904(); break; // 1904 [ 2345]
330 case 0x26:
331 case 0x27:
332 case 0x28:
333 case 0x29: rPageSett.ReadMargin( maStrm ); break;
334 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
335 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
336 case 0x2F: // FILEPASS [ 2345]
337 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
338 if( eLastErr != ERRCODE_NONE )
339 eCurrent = Z_End;
340 break;
341 case EXC_ID_FILESHARING: ReadFileSharing(); break;
342 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
343 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
344 case 0x56: break; // BUILTINFMTCNT[ 34 ]
345 case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
346 case 0x7D: Colinfo(); break; // COLINFO [ 345]
347 case 0x8C: Country(); break; // COUNTRY [ 345]
348 case 0x92: rPal.ReadPalette( maStrm ); break;
349 case 0x0206: Formula3(); break; // FORMULA [ 3 ]
350 case 0x0208: Row34(); break; // ROW [ 34 ]
351 case 0x0218: rNameMgr.ReadName( maStrm ); break;
352 case 0x0221: Array34(); break; // ARRAY [ 34 ]
353 case 0x0223: break; // EXTERNNAME [ 34 ]
354 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
355 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
356 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
357 case 0x0243: rXFBfr.ReadXF( maStrm ); break;
358 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
361 break;
363 case Z_Biff4: // ---------------------------------- Z_Biff4 -
365 switch( nOpcode )
367 // skip chart substream
368 case EXC_ID2_BOF:
369 case EXC_ID3_BOF:
370 case EXC_ID4_BOF:
371 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
373 case EXC_ID2_DIMENSIONS:
374 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
375 case EXC_ID2_BLANK:
376 case EXC_ID3_BLANK: ReadBlank(); break;
377 case EXC_ID2_INTEGER: ReadInteger(); break;
378 case EXC_ID2_NUMBER:
379 case EXC_ID3_NUMBER: ReadNumber(); break;
380 case EXC_ID2_LABEL:
381 case EXC_ID3_LABEL: ReadLabel(); break;
382 case EXC_ID2_BOOLERR:
383 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
384 case EXC_ID_RK: ReadRk(); break;
386 case 0x0A: // EOF [ 2345]
387 rNumFmtBfr.CreateScFormats();
388 rNameMgr.ConvertAllTokens();
389 Eof();
390 eCurrent = Z_End;
391 break;
392 case 0x12: SheetProtect(); break; // SHEET PROTECTION
393 case 0x14:
394 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
395 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
396 case 0x1A:
397 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
398 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
399 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
400 case 0x22: Rec1904(); break; // 1904 [ 2345]
401 case 0x26:
402 case 0x27:
403 case 0x28:
404 case 0x29: rPageSett.ReadMargin( maStrm ); break;
405 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
406 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
407 case 0x2F: // FILEPASS [ 2345]
408 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
409 if( eLastErr != ERRCODE_NONE )
410 eCurrent = Z_End;
411 break;
412 case EXC_ID_FILESHARING: ReadFileSharing(); break;
413 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
414 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
415 case 0x55: DefColWidth(); break;
416 case 0x56: break; // BUILTINFMTCNT[ 34 ]
417 case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
418 case 0x7D: Colinfo(); break; // COLINFO [ 345]
419 case 0x8C: Country(); break; // COUNTRY [ 345]
420 case 0x92: rPal.ReadPalette( maStrm ); break;
421 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
422 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
423 case 0x0208: Row34(); break; // ROW [ 34 ]
424 case 0x0218: rNameMgr.ReadName( maStrm ); break;
425 case 0x0221: Array34(); break; // ARRAY [ 34 ]
426 case 0x0223: break; // EXTERNNAME [ 34 ]
427 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
428 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
429 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
430 case 0x0406: Formula4(); break; // FORMULA [ 4 ]
431 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
432 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
433 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
436 break;
438 case Z_Biff4W: // --------------------------------- Z_Biff4W -
440 switch( nOpcode )
442 case 0x0A: // EOF [ 2345]
443 rNameMgr.ConvertAllTokens();
444 eCurrent = Z_End;
445 break;
446 case 0x12: DocProtect(); break; // PROTECT [ 5]
447 case 0x2F: // FILEPASS [ 2345]
448 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
449 if( eLastErr != ERRCODE_NONE )
450 eCurrent = Z_End;
451 break;
452 case EXC_ID_FILESHARING: ReadFileSharing(); break;
453 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
454 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
455 case 0x55: DefColWidth(); break;
456 case 0x56: break; // BUILTINFMTCNT[ 34 ]
457 case 0x8C: Country(); break; // COUNTRY [ 345]
458 case 0x8F: break; // BUNDLEHEADER [ 4 ]
459 case 0x92: rPal.ReadPalette( maStrm ); break;
460 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
461 case 0x0218: rNameMgr.ReadName( maStrm ); break;
462 case 0x0223: break; // EXTERNNAME [ 34 ]
463 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
464 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
465 case EXC_ID4_BOF: // BOF [ 4 ]
466 Bof4();
467 if( pExcRoot->eDateiTyp == Biff4 )
469 eCurrent = Z_Biff4T;
470 NewTable();
472 else
473 eCurrent = Z_End;
474 break;
475 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
476 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
477 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
481 break;
483 case Z_Biff4T: // --------------------------------- Z_Biff4T -
485 switch( nOpcode )
487 // skip chart substream
488 case EXC_ID2_BOF:
489 case EXC_ID3_BOF:
490 case EXC_ID4_BOF:
491 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
493 case EXC_ID2_DIMENSIONS:
494 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
495 case EXC_ID2_BLANK:
496 case EXC_ID3_BLANK: ReadBlank(); break;
497 case EXC_ID2_INTEGER: ReadInteger(); break;
498 case EXC_ID2_NUMBER:
499 case EXC_ID3_NUMBER: ReadNumber(); break;
500 case EXC_ID2_LABEL:
501 case EXC_ID3_LABEL: ReadLabel(); break;
502 case EXC_ID2_BOOLERR:
503 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
504 case EXC_ID_RK: ReadRk(); break;
506 case 0x0A: // EOF [ 2345]
507 rNameMgr.ConvertAllTokens();
508 Eof();
509 eCurrent = Z_Biff4E;
510 break;
511 case 0x12: SheetProtect(); break; // SHEET PROTECTION
512 case 0x14:
513 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
514 case 0x1A:
515 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
516 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
517 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
518 case 0x2F: // FILEPASS [ 2345]
519 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
520 if( eLastErr != ERRCODE_NONE )
521 eCurrent = Z_End;
522 break;
523 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
524 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
525 case 0x55: DefColWidth(); break;
526 case 0x56: break; // BUILTINFMTCNT[ 34 ]
527 case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
528 case 0x7D: Colinfo(); break; // COLINFO [ 345]
529 case 0x8C: Country(); break; // COUNTRY [ 345]
530 case 0x8F: break; // BUNDLEHEADER [ 4 ]
531 case 0x92: rPal.ReadPalette( maStrm ); break;
532 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
533 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
534 case 0x0208: Row34(); break; // ROW [ 34 ]
535 case 0x0218: rNameMgr.ReadName( maStrm ); break;
536 case 0x0221: Array34(); break;
537 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
538 case 0x0231: rFontBfr.ReadFont( maStrm ); break;
539 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
540 case 0x0406: Formula4(); break;
541 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
542 case 0x0443: rXFBfr.ReadXF( maStrm ); break;
543 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
547 break;
549 case Z_Biff4E: // --------------------------------- Z_Biff4E -
551 switch( nOpcode )
553 case 0x0A: // EOF [ 2345]
554 eCurrent = Z_End;
555 break;
556 case 0x8F: break; // BUNDLEHEADER [ 4 ]
557 case EXC_ID4_BOF: // BOF [ 4 ]
558 Bof4();
559 NewTable();
560 if( pExcRoot->eDateiTyp == Biff4 )
562 eCurrent = Z_Biff4T;
564 else
566 ePrev = eCurrent;
567 eCurrent = Z_Biffn0;
569 break;
573 break;
574 case Z_Biff5WPre: // ------------------------------ Z_Biff5WPre -
576 switch( nOpcode )
578 case 0x0A: // EOF [ 2345]
579 eCurrent = Z_Biff5W;
580 aIn.SeekGlobalPosition(); // and back to old position
581 break;
582 case 0x12: DocProtect(); break; // PROTECT [ 5]
583 case 0x2F: // FILEPASS [ 2345]
584 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
585 if( eLastErr != ERRCODE_NONE )
586 eCurrent = Z_End;
587 break;
588 case EXC_ID_FILESHARING: ReadFileSharing(); break;
589 case 0x3D: Window1(); break;
590 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
591 case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5]
592 case 0x8C: Country(); break; // COUNTRY [ 345]
593 // PALETTE follows XFs, but already needed while reading the XFs
594 case 0x92: rPal.ReadPalette( maStrm ); break;
597 break;
598 case Z_Biff5W: // --------------------------------- Z_Biff5W -
600 switch( nOpcode )
602 case 0x0A: // EOF [ 2345]
603 rNumFmtBfr.CreateScFormats();
604 rXFBfr.CreateUserStyles();
605 rNameMgr.ConvertAllTokens();
606 eCurrent = Z_Biff5E;
607 break;
608 case 0x18: rNameMgr.ReadName( maStrm ); break;
609 case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
610 case 0x22: Rec1904(); break; // 1904 [ 2345]
611 case 0x31: rFontBfr.ReadFont( maStrm ); break;
612 case 0x56: break; // BUILTINFMTCNT[ 34 ]
613 case 0x8D: Hideobj(); break; // HIDEOBJ [ 345]
614 case 0xDE: Olesize(); break;
615 case 0xE0: rXFBfr.ReadXF( maStrm ); break;
616 case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
617 case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
621 break;
623 case Z_Biff5TPre: // ------------------------------- Z_Biff5Pre -
625 if (nOpcode == EXC_ID5_BOF)
626 nBofLevel++;
627 else if( (nOpcode == 0x000A) && nBofLevel )
628 nBofLevel--;
629 else if( !nBofLevel ) // don't read chart records
631 switch( nOpcode )
633 case EXC_ID2_DIMENSIONS:
634 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
635 case 0x08: Row25(); break; // ROW [ 2 5]
636 case 0x0A: // EOF [ 2345]
637 eCurrent = Z_Biff5T;
638 aIn.SeekGlobalPosition(); // and back to old position
639 break;
640 case 0x12: SheetProtect(); break; // SHEET PROTECTION
641 case 0x1A:
642 case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
643 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
644 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
645 case 0x21: Array25(); break; // ARRAY [ 2 5]
646 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
647 case 0x41: rTabViewSett.ReadPane( maStrm ); break;
648 case 0x42: Codepage(); break; // CODEPAGE [ 2345]
649 case 0x55: DefColWidth(); break;
650 case 0x7D: Colinfo(); break; // COLINFO [ 345]
651 case 0x81: Wsbool(); break; // WSBOOL [ 2345]
652 case 0x8C: Country(); break; // COUNTRY [ 345]
653 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
654 case 0x0208: Row34(); break; // ROW [ 34 ]
655 case 0x0221: Array34(); break; // ARRAY [ 34 ]
656 case 0x0223: break; // EXTERNNAME [ 34 ]
657 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
658 case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
662 break;
664 case Z_Biff5T: // --------------------------------- Z_Biff5T -
666 switch( nOpcode )
668 case EXC_ID2_BLANK:
669 case EXC_ID3_BLANK: ReadBlank(); break;
670 case EXC_ID2_INTEGER: ReadInteger(); break;
671 case EXC_ID2_NUMBER:
672 case EXC_ID3_NUMBER: ReadNumber(); break;
673 case EXC_ID2_LABEL:
674 case EXC_ID3_LABEL: ReadLabel(); break;
675 case EXC_ID2_BOOLERR:
676 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
677 case EXC_ID_RK: ReadRk(); break;
679 case EXC_ID2_FORMULA:
680 case EXC_ID3_FORMULA:
681 case EXC_ID4_FORMULA: Formula25(); break;
682 case EXC_ID_SHRFMLA: Shrfmla(); break;
683 case 0x0A: Eof(); eCurrent = Z_Biff5E; break;
684 case 0x14:
685 case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
686 case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
687 case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
688 case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
689 case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
690 case 0x26:
691 case 0x27:
692 case 0x28:
693 case 0x29: rPageSett.ReadMargin( maStrm ); break;
694 case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
695 case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
696 case 0x2F: // FILEPASS [ 2345]
697 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
698 if( eLastErr != ERRCODE_NONE )
699 eCurrent = Z_End;
700 break;
701 case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
702 case 0x83:
703 case 0x84: rPageSett.ReadCenter( maStrm ); break;
704 case 0xA0: rTabViewSett.ReadScl( maStrm ); break;
705 case 0xA1: rPageSett.ReadSetup( maStrm ); break;
706 case 0xBD: Mulrk(); break; // MULRK [ 5]
707 case 0xBE: Mulblank(); break; // MULBLANK [ 5]
708 case 0xD6: Rstring(); break; // RSTRING [ 5]
709 case 0x00E5: Cellmerging(); break; // #i62300#
710 case 0x0236: TableOp(); break; // TABLE [ 5]
711 case EXC_ID5_BOF: // BOF [ 5]
712 XclTools::SkipSubStream( maStrm );
713 break;
717 break;
719 case Z_Biff5E: // --------------------------------- Z_Biff5E -
721 switch( nOpcode )
723 case EXC_ID5_BOF: // BOF [ 5]
724 Bof5();
725 NewTable();
726 switch( pExcRoot->eDateiTyp )
728 case Biff5:
729 case Biff5M4:
730 eCurrent = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
731 nBofLevel = 0;
732 aIn.StoreGlobalPosition(); // store position
733 break;
734 case Biff5C: // chart sheet
735 GetCurrSheetDrawing().ReadTabChart( maStrm );
736 Eof();
737 GetTracer().TraceChartOnlySheet();
738 break;
739 case Biff5V:
740 default:
741 rD.SetVisible( GetCurrScTab(), false );
742 ePrev = eCurrent;
743 eCurrent = Z_Biffn0;
745 OSL_ENSURE( pExcRoot->eDateiTyp != Biff5W,
746 "+ImportExcel::Read(): Doppel-Whopper-Workbook!" );
748 break;
752 break;
753 case Z_Biffn0: // --------------------------------- Z_Biffn0 -
755 switch( nOpcode )
757 case 0x0A: // EOF [ 2345]
758 eCurrent = ePrev;
759 IncCurrScTab();
760 break;
764 break;
766 case Z_End: // ----------------------------------- Z_End -
767 OSL_FAIL( "*ImportExcel::Read(): Not possible state!" );
768 break;
769 default: OSL_FAIL( "-ImportExcel::Read(): state forgotten!" );
773 if( eLastErr == ERRCODE_NONE )
775 pProgress.reset();
777 GetDocImport().finalize();
778 if (!utl::ConfigManager::IsFuzzing())
779 AdjustRowHeight();
780 PostDocLoad();
782 rD.CalcAfterLoad(false);
784 const XclImpAddressConverter& rAddrConv = GetAddressConverter();
785 if( rAddrConv.IsTabTruncated() )
786 eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
787 else if( bTabTruncated || rAddrConv.IsRowTruncated() )
788 eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
789 else if( rAddrConv.IsColTruncated() )
790 eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
793 return eLastErr;
796 ErrCode ImportExcel8::Read()
798 #ifdef EXC_INCL_DUMPER
800 Biff8RecDumper aDumper( GetRoot(), sal_True );
801 if( aDumper.Dump( aIn ) )
802 return ERRCODE_ABORT;
804 #endif
805 // read the entire BIFF8 stream
806 // don't look too close - this stuff seriously needs to be reworked
808 XclImpPageSettings& rPageSett = GetPageSettings();
809 XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
810 XclImpPalette& rPal = GetPalette();
811 XclImpFontBuffer& rFontBfr = GetFontBuffer();
812 XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
813 XclImpXFBuffer& rXFBfr = GetXFBuffer();
814 XclImpSst& rSst = GetSst();
815 XclImpTabInfo& rTabInfo = GetTabInfo();
816 XclImpNameManager& rNameMgr = GetNameManager();
817 XclImpLinkManager& rLinkMgr = GetLinkManager();
818 XclImpObjectManager& rObjMgr = GetObjectManager();
819 // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
820 XclImpCondFormatManager& rCondFmtMgr = GetCondFormatManager();
821 XclImpValidationManager& rValidMgr = GetValidationManager();
822 XclImpPivotTableManager& rPTableMgr = GetPivotTableManager();
823 XclImpWebQueryBuffer& rWQBfr = GetWebQueryBuffer();
825 bool bInUserView = false; // true = In USERSVIEW(BEGIN|END) record block.
827 enum XclImpReadState
829 EXC_STATE_BEFORE_GLOBALS, /// Before workbook globals (wait for initial BOF).
830 EXC_STATE_GLOBALS_PRE, /// Prefetch for workbook globals.
831 EXC_STATE_GLOBALS, /// Workbook globals.
832 EXC_STATE_BEFORE_SHEET, /// Before worksheet (wait for new worksheet BOF).
833 EXC_STATE_SHEET_PRE, /// Prefetch for worksheet.
834 EXC_STATE_SHEET, /// Worksheet.
835 EXC_STATE_END /// Stop reading.
838 XclImpReadState eCurrent = EXC_STATE_BEFORE_GLOBALS;
840 ErrCode eLastErr = ERRCODE_NONE;
842 std::unique_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
843 aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
845 /* #i104057# Need to track a base position for progress bar calculation,
846 because sheet substreams may not be in order of sheets. */
847 std::size_t nProgressBasePos = 0;
848 std::size_t nProgressBaseSize = 0;
850 bool bSheetHasCodeName = false;
852 std::vector<OUString> aCodeNames;
853 std::vector < SCTAB > nTabsWithNoCodeName;
855 sal_uInt16 nRecId = 0;
857 for (; eCurrent != EXC_STATE_END; mnLastRecId = nRecId)
859 if( eCurrent == EXC_STATE_BEFORE_SHEET )
861 sal_uInt16 nScTab = GetCurrScTab();
862 if( nScTab < maSheetOffsets.size() )
864 nProgressBaseSize += (maStrm.GetSvStreamPos() - nProgressBasePos);
865 nProgressBasePos = maSheetOffsets[ nScTab ];
867 bool bValid = TryStartNextRecord(aIn, nProgressBasePos);
868 if (!bValid)
870 // Safeguard ourselves from potential infinite loop.
871 eCurrent = EXC_STATE_END;
874 // import only 256 sheets
875 if( nScTab > GetScMaxPos().Tab() )
877 if( maStrm.GetRecId() != EXC_ID_EOF )
878 XclTools::SkipSubStream( maStrm );
879 // #i29930# show warning box
880 GetAddressConverter().CheckScTab( nScTab );
881 eCurrent = EXC_STATE_END;
883 else
885 // #i109800# SHEET record may point to any record inside the
886 // sheet substream
887 bool bIsBof = maStrm.GetRecId() == EXC_ID5_BOF;
888 if( bIsBof )
889 Bof5(); // read the BOF record
890 else
891 pExcRoot->eDateiTyp = Biff8; // on missing BOF, assume a standard worksheet
892 NewTable();
893 switch( pExcRoot->eDateiTyp )
895 case Biff8: // worksheet
896 case Biff8M4: // macro sheet
897 eCurrent = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
898 // go to next record
899 if( bIsBof ) maStrm.StartNextRecord();
900 maStrm.StoreGlobalPosition();
901 break;
902 case Biff8C: // chart sheet
903 GetCurrSheetDrawing().ReadTabChart( maStrm );
904 Eof();
905 GetTracer().TraceChartOnlySheet();
906 break;
907 case Biff8W: // workbook
908 OSL_FAIL( "ImportExcel8::Read - double workbook globals" );
909 [[fallthrough]];
910 case Biff8V: // VB module
911 default:
912 // TODO: do not create a sheet in the Calc document
913 rD.SetVisible( nScTab, false );
914 XclTools::SkipSubStream( maStrm );
915 IncCurrScTab();
919 else
920 eCurrent = EXC_STATE_END;
922 else
923 aIn.StartNextRecord();
925 if( !aIn.IsValid() )
927 // #i63591# finalize table if EOF is missing
928 switch( eCurrent )
930 case EXC_STATE_SHEET_PRE:
931 eCurrent = EXC_STATE_SHEET;
932 aIn.SeekGlobalPosition();
933 continue; // next iteration in while loop
934 case EXC_STATE_SHEET:
935 Eof();
936 eCurrent = EXC_STATE_END;
937 break;
938 default:
939 eCurrent = EXC_STATE_END;
943 if( eCurrent == EXC_STATE_END )
944 break;
946 if( eCurrent != EXC_STATE_SHEET_PRE && eCurrent != EXC_STATE_GLOBALS_PRE )
947 pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
949 nRecId = aIn.GetRecId();
951 /* #i39464# Ignore records between USERSVIEWBEGIN and USERSVIEWEND
952 completely (user specific view settings). Otherwise view settings
953 and filters are loaded multiple times, which at least causes
954 problems in auto-filters. */
955 switch( nRecId )
957 case EXC_ID_USERSVIEWBEGIN:
958 OSL_ENSURE( !bInUserView, "ImportExcel8::Read - nested user view settings" );
959 bInUserView = true;
960 break;
961 case EXC_ID_USERSVIEWEND:
962 OSL_ENSURE( bInUserView, "ImportExcel8::Read - not in user view settings" );
963 bInUserView = false;
964 break;
967 if( !bInUserView ) switch( eCurrent )
970 // before workbook globals: wait for initial workbook globals BOF
971 case EXC_STATE_BEFORE_GLOBALS:
973 if( nRecId == EXC_ID5_BOF )
975 OSL_ENSURE( GetBiff() == EXC_BIFF8, "ImportExcel8::Read - wrong BIFF version" );
976 Bof5();
977 if( pExcRoot->eDateiTyp == Biff8W )
979 eCurrent = EXC_STATE_GLOBALS_PRE;
980 maStrm.StoreGlobalPosition();
981 nBdshtTab = 0;
983 else if( pExcRoot->eDateiTyp == Biff8 )
985 // #i62752# possible to have BIFF8 sheet without globals
986 NewTable();
987 eCurrent = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
988 bSheetHasCodeName = false; // reset
989 aIn.StoreGlobalPosition();
993 break;
995 // prefetch for workbook globals
996 case EXC_STATE_GLOBALS_PRE:
998 switch( nRecId )
1000 case EXC_ID_EOF:
1001 case EXC_ID_EXTSST:
1002 /* #i56376# evil hack: if EOF for globals is missing,
1003 simulate it. This hack works only for the bugdoc
1004 given in the issue, where the sheet substreams
1005 start directly after the EXTSST record. A future
1006 implementation should be more robust against
1007 missing EOFs. */
1008 if( (nRecId == EXC_ID_EOF) ||
1009 ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
1011 eCurrent = EXC_STATE_GLOBALS;
1012 aIn.SeekGlobalPosition();
1014 break;
1015 case 0x12: DocProtect(); break; // PROTECT [ 5678]
1016 case 0x13: DocPassword(); break;
1017 case 0x19: WinProtection(); break;
1018 case 0x2F: // FILEPASS [ 2345 ]
1019 eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
1020 if( eLastErr != ERRCODE_NONE )
1021 eCurrent = EXC_STATE_END;
1022 break;
1023 case EXC_ID_FILESHARING: ReadFileSharing(); break;
1024 case 0x3D: Window1(); break;
1025 case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
1026 case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5 ]
1027 case 0x8C: Country(); break; // COUNTRY [ 345 ]
1029 // PALETTE follows XFs, but already needed while reading the XFs
1030 case EXC_ID_PALETTE: rPal.ReadPalette( maStrm ); break;
1033 break;
1035 // workbook globals
1036 case EXC_STATE_GLOBALS:
1038 switch( nRecId )
1040 case EXC_ID_EOF:
1041 case EXC_ID_EXTSST:
1042 /* #i56376# evil hack: if EOF for globals is missing,
1043 simulate it. This hack works only for the bugdoc
1044 given in the issue, where the sheet substreams
1045 start directly after the EXTSST record. A future
1046 implementation should be more robust against
1047 missing EOFs. */
1048 if( (nRecId == EXC_ID_EOF) ||
1049 ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
1051 rNumFmtBfr.CreateScFormats();
1052 rXFBfr.CreateUserStyles();
1053 rPTableMgr.ReadPivotCaches( maStrm );
1054 rNameMgr.ConvertAllTokens();
1055 eCurrent = EXC_STATE_BEFORE_SHEET;
1057 break;
1058 case 0x0E: Precision(); break; // PRECISION
1059 case 0x22: Rec1904(); break; // 1904 [ 2345 ]
1060 case 0x56: break; // BUILTINFMTCNT[ 34 ]
1061 case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ]
1062 case 0xD3: SetHasBasic(); break;
1063 case 0xDE: Olesize(); break;
1065 case EXC_ID_CODENAME: ReadCodeName( aIn, true ); break;
1066 case EXC_ID_USESELFS: ReadUsesElfs(); break;
1068 case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
1069 case EXC_ID4_FORMAT: rNumFmtBfr.ReadFormat( maStrm ); break;
1070 case EXC_ID5_XF: rXFBfr.ReadXF( maStrm ); break;
1071 case EXC_ID_STYLE: rXFBfr.ReadStyle( maStrm ); break;
1073 case EXC_ID_SST: rSst.ReadSst( maStrm ); break;
1074 case EXC_ID_TABID: rTabInfo.ReadTabid( maStrm ); break;
1075 case EXC_ID_NAME: rNameMgr.ReadName( maStrm ); break;
1077 case EXC_ID_EXTERNSHEET: rLinkMgr.ReadExternsheet( maStrm ); break;
1078 case EXC_ID_SUPBOOK: rLinkMgr.ReadSupbook( maStrm ); break;
1079 case EXC_ID_XCT: rLinkMgr.ReadXct( maStrm ); break;
1080 case EXC_ID_CRN: rLinkMgr.ReadCrn( maStrm ); break;
1081 case EXC_ID_EXTERNNAME: rLinkMgr.ReadExternname( maStrm, pFormConv.get() ); break;
1083 case EXC_ID_MSODRAWINGGROUP:rObjMgr.ReadMsoDrawingGroup( maStrm ); break;
1085 case EXC_ID_SXIDSTM: rPTableMgr.ReadSxidstm( maStrm ); break;
1086 case EXC_ID_SXVS: rPTableMgr.ReadSxvs( maStrm ); break;
1087 case EXC_ID_DCONREF: rPTableMgr.ReadDconref( maStrm ); break;
1088 case EXC_ID_DCONNAME: rPTableMgr.ReadDConName( maStrm ); break;
1092 break;
1094 // prefetch for worksheet
1095 case EXC_STATE_SHEET_PRE:
1097 switch( nRecId )
1099 // skip chart substream
1100 case EXC_ID2_BOF:
1101 case EXC_ID3_BOF:
1102 case EXC_ID4_BOF:
1103 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
1105 case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( maStrm, false );break;
1106 case EXC_ID_SCL: rTabViewSett.ReadScl( maStrm ); break;
1107 case EXC_ID_PANE: rTabViewSett.ReadPane( maStrm ); break;
1108 case EXC_ID_SELECTION: rTabViewSett.ReadSelection( maStrm ); break;
1110 case EXC_ID2_DIMENSIONS:
1111 case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
1113 case EXC_ID_CODENAME: ReadCodeName( aIn, false ); bSheetHasCodeName = true; break;
1115 case 0x0A: // EOF [ 2345 ]
1117 eCurrent = EXC_STATE_SHEET;
1118 OUString sName;
1119 GetDoc().GetName( GetCurrScTab(), sName );
1120 if ( !bSheetHasCodeName )
1122 nTabsWithNoCodeName.push_back( GetCurrScTab() );
1124 else
1126 OUString sCodeName;
1127 GetDoc().GetCodeName( GetCurrScTab(), sCodeName );
1128 aCodeNames.push_back( sCodeName );
1131 bSheetHasCodeName = false; // reset
1133 aIn.SeekGlobalPosition(); // and back to old position
1134 break;
1136 case 0x12: SheetProtect(); break;
1137 case 0x13: SheetPassword(); break;
1138 case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
1139 case 0x55: DefColWidth(); break;
1140 case 0x7D: Colinfo(); break; // COLINFO [ 345 ]
1141 case 0x81: Wsbool(); break; // WSBOOL [ 2345 ]
1142 case 0x8C: Country(); break; // COUNTRY [ 345 ]
1143 case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45 ]
1144 case 0x9B: FilterMode(); break; // FILTERMODE
1145 case EXC_ID_AUTOFILTERINFO: AutoFilterInfo(); break;// AUTOFILTERINFO
1146 case EXC_ID_AUTOFILTER: AutoFilter(); break; // AUTOFILTER
1147 case 0x0208: Row34(); break; // ROW [ 34 ]
1148 case EXC_ID2_ARRAY:
1149 case EXC_ID3_ARRAY: Array34(); break; // ARRAY [ 34 ]
1150 case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345 ]
1151 case 0x0867: FeatHdr(); break; // FEATHDR
1152 case 0x0868: Feat(); break; // FEAT
1155 break;
1157 // worksheet
1158 case EXC_STATE_SHEET:
1160 switch( nRecId )
1162 // skip unknown substreams
1163 case EXC_ID2_BOF:
1164 case EXC_ID3_BOF:
1165 case EXC_ID4_BOF:
1166 case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
1168 case EXC_ID_EOF: Eof(); eCurrent = EXC_STATE_BEFORE_SHEET; break;
1170 case EXC_ID2_BLANK:
1171 case EXC_ID3_BLANK: ReadBlank(); break;
1172 case EXC_ID2_INTEGER: ReadInteger(); break;
1173 case EXC_ID2_NUMBER:
1174 case EXC_ID3_NUMBER: ReadNumber(); break;
1175 case EXC_ID2_LABEL:
1176 case EXC_ID3_LABEL: ReadLabel(); break;
1177 case EXC_ID2_BOOLERR:
1178 case EXC_ID3_BOOLERR: ReadBoolErr(); break;
1179 case EXC_ID_RK: ReadRk(); break;
1181 case EXC_ID2_FORMULA:
1182 case EXC_ID3_FORMULA:
1183 case EXC_ID4_FORMULA: Formula25(); break;
1184 case EXC_ID_SHRFMLA: Shrfmla(); break;
1185 case 0x000C: Calccount(); break; // CALCCOUNT
1186 case 0x0010: Delta(); break; // DELTA
1187 case 0x0011: Iteration(); break; // ITERATION
1188 case 0x007E:
1189 case 0x00AE: Scenman(); break; // SCENMAN
1190 case 0x00AF: Scenario(); break; // SCENARIO
1191 case 0x00BD: Mulrk(); break; // MULRK [ 5 ]
1192 case 0x00BE: Mulblank(); break; // MULBLANK [ 5 ]
1193 case 0x00D6: Rstring(); break; // RSTRING [ 5 ]
1194 case 0x00E5: Cellmerging(); break; // CELLMERGING
1195 case 0x00FD: Labelsst(); break; // LABELSST [ 8 ]
1196 case 0x0236: TableOp(); break; // TABLE
1198 case EXC_ID_HORPAGEBREAKS:
1199 case EXC_ID_VERPAGEBREAKS: rPageSett.ReadPageBreaks( maStrm ); break;
1200 case EXC_ID_HEADER:
1201 case EXC_ID_FOOTER: rPageSett.ReadHeaderFooter( maStrm ); break;
1202 case EXC_ID_LEFTMARGIN:
1203 case EXC_ID_RIGHTMARGIN:
1204 case EXC_ID_TOPMARGIN:
1205 case EXC_ID_BOTTOMMARGIN: rPageSett.ReadMargin( maStrm ); break;
1206 case EXC_ID_PRINTHEADERS: rPageSett.ReadPrintHeaders( maStrm ); break;
1207 case EXC_ID_PRINTGRIDLINES: rPageSett.ReadPrintGridLines( maStrm ); break;
1208 case EXC_ID_HCENTER:
1209 case EXC_ID_VCENTER: rPageSett.ReadCenter( maStrm ); break;
1210 case EXC_ID_SETUP: rPageSett.ReadSetup( maStrm ); break;
1211 case EXC_ID8_IMGDATA: rPageSett.ReadImgData( maStrm ); break;
1213 case EXC_ID_MSODRAWING: GetCurrSheetDrawing().ReadMsoDrawing( maStrm ); break;
1214 // #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format
1215 case EXC_ID_OBJ: GetCurrSheetDrawing().ReadObj( maStrm ); break;
1216 case EXC_ID_NOTE: GetCurrSheetDrawing().ReadNote( maStrm ); break;
1218 case EXC_ID_HLINK: XclImpHyperlink::ReadHlink( maStrm ); break;
1219 case EXC_ID_LABELRANGES: XclImpLabelranges::ReadLabelranges( maStrm ); break;
1221 case EXC_ID_CONDFMT: rCondFmtMgr.ReadCondfmt( maStrm ); break;
1222 case EXC_ID_CF: rCondFmtMgr.ReadCF( maStrm ); break;
1224 case EXC_ID_DVAL: XclImpValidationManager::ReadDval( maStrm ); break;
1225 case EXC_ID_DV: rValidMgr.ReadDV( maStrm ); break;
1227 case EXC_ID_QSI: rWQBfr.ReadQsi( maStrm ); break;
1228 case EXC_ID_WQSTRING: rWQBfr.ReadWqstring( maStrm ); break;
1229 case EXC_ID_PQRY: rWQBfr.ReadParamqry( maStrm ); break;
1230 case EXC_ID_WQSETT: rWQBfr.ReadWqsettings( maStrm ); break;
1231 case EXC_ID_WQTABLES: rWQBfr.ReadWqtables( maStrm ); break;
1233 case EXC_ID_SXVIEW: rPTableMgr.ReadSxview( maStrm ); break;
1234 case EXC_ID_SXVD: rPTableMgr.ReadSxvd( maStrm ); break;
1235 case EXC_ID_SXVI: rPTableMgr.ReadSxvi( maStrm ); break;
1236 case EXC_ID_SXIVD: rPTableMgr.ReadSxivd( maStrm ); break;
1237 case EXC_ID_SXPI: rPTableMgr.ReadSxpi( maStrm ); break;
1238 case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break;
1239 case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break;
1240 case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break;
1241 case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break;
1242 case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break;
1243 case EXC_ID_SXADDL: rPTableMgr.ReadSxAddl( maStrm ); break;
1246 break;
1248 default:;
1252 if( eLastErr == ERRCODE_NONE )
1254 // In some strange circumstances the codename might be missing
1255 // # Create any missing Sheet CodeNames
1256 for ( const auto& rTab : nTabsWithNoCodeName )
1258 SCTAB nTab = 1;
1259 while ( true )
1261 OUStringBuffer aBuf;
1262 aBuf.append("Sheet");
1263 aBuf.append(static_cast<sal_Int32>(nTab++));
1264 OUString sTmpName = aBuf.makeStringAndClear();
1266 if ( std::find(aCodeNames.begin(), aCodeNames.end(), sTmpName) == aCodeNames.end() ) // generated codename not found
1268 // Set new codename
1269 GetDoc().SetCodeName( rTab, sTmpName );
1270 // Record newly used codename
1271 aCodeNames.push_back(sTmpName);
1272 break;
1276 // #i45843# Convert pivot tables before calculation, so they are available
1277 // for the GETPIVOTDATA function.
1278 if( GetBiff() == EXC_BIFF8 )
1279 GetPivotTableManager().ConvertPivotTables();
1281 ScDocumentImport& rDoc = GetDocImport();
1282 rDoc.finalize();
1283 pProgress.reset();
1284 #if 0
1285 // Excel documents look much better without this call; better in the
1286 // sense that the row heights are identical to the original heights in
1287 // Excel.
1288 if ( !rD.IsAdjustHeightLocked())
1289 AdjustRowHeight();
1290 #endif
1291 PostDocLoad();
1293 rD.CalcAfterLoad(false);
1295 // import change tracking data
1296 XclImpChangeTrack aImpChTr( GetRoot(), maStrm );
1297 aImpChTr.Apply();
1299 const XclImpAddressConverter& rAddrConv = GetAddressConverter();
1300 if( rAddrConv.IsTabTruncated() )
1301 eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
1302 else if( bTabTruncated || rAddrConv.IsRowTruncated() )
1303 eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
1304 else if( rAddrConv.IsColTruncated() )
1305 eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
1307 if( GetBiff() == EXC_BIFF8 )
1308 GetPivotTableManager().MaybeRefreshPivotTables();
1311 return eLastErr;
1314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */