[Libreoffice-commits] core.git: sc/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 28 11:19:34 UTC 2020


 sc/source/filter/excel/read.cxx | 1275 ++++++++++++++++++++--------------------
 1 file changed, 641 insertions(+), 634 deletions(-)

New commits:
commit b0e573f18629d28fe3179c12d0d434653f92fc93
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Dec 27 19:53:34 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Dec 28 12:18:55 2020 +0100

    ofz#29030 Abrt in xlsfuzzer
    
    Change-Id: I78c7dda97668df0f851c8dda48d153f1f5707f08
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108381
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index cf9465a37c95..408485301e05 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -69,727 +69,734 @@ namespace
 
 ErrCode ImportExcel::Read()
 {
-    XclImpPageSettings&     rPageSett       = GetPageSettings();
-    XclImpTabViewSettings&  rTabViewSett    = GetTabViewSettings();
-    XclImpPalette&          rPal            = GetPalette();
-    XclImpFontBuffer&       rFontBfr        = GetFontBuffer();
-    XclImpNumFmtBuffer&     rNumFmtBfr      = GetNumFmtBuffer();
-    XclImpXFBuffer&         rXFBfr          = GetXFBuffer();
-    XclImpNameManager&      rNameMgr        = GetNameManager();
-    // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
-
-    enum STATE {
-        Z_BiffNull, // not a valid Biff-Format
-        Z_Biff2,    // Biff2: only one table
-
-        Z_Biff3,    // Biff3: only one table
-
-        Z_Biff4,    // Biff4: only one table
-        Z_Biff4W,   // Biff4 Workbook: Globals
-        Z_Biff4T,   // Biff4 Workbook: a table itself
-        Z_Biff4E,   // Biff4 Workbook: between tables
-
-        Z_Biff5WPre,// Biff5: Prefetch Workbook
-        Z_Biff5W,   // Biff5: Globals
-        Z_Biff5TPre,// Biff5: Prefetch for Shrfmla/Array Formula
-        Z_Biff5T,   // Biff5: a table itself
-        Z_Biff5E,   // Biff5: between tables
-        Z_Biffn0,   // all Biffs: skip table till next EOF
-        Z_End };
-
-    STATE           eCurrent = Z_BiffNull, ePrev = Z_BiffNull;
-
-    ErrCode         eLastErr = ERRCODE_NONE;
-    sal_uInt16      nOpcode;
-    sal_uInt16      nBofLevel = 0;
-
-    std::unique_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
-        aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
-
-    /*  #i104057# Need to track a base position for progress bar calculation,
-        because sheet substreams may not be in order of sheets. */
-    std::size_t nProgressBasePos = 0;
-    std::size_t nProgressBaseSize = 0;
-
-    for (; eCurrent != Z_End; mnLastRecId = nOpcode)
+    ErrCode eLastErr = ERRCODE_NONE;
+    try
     {
-        if( eCurrent == Z_Biff5E )
+        XclImpPageSettings&     rPageSett       = GetPageSettings();
+        XclImpTabViewSettings&  rTabViewSett    = GetTabViewSettings();
+        XclImpPalette&          rPal            = GetPalette();
+        XclImpFontBuffer&       rFontBfr        = GetFontBuffer();
+        XclImpNumFmtBuffer&     rNumFmtBfr      = GetNumFmtBuffer();
+        XclImpXFBuffer&         rXFBfr          = GetXFBuffer();
+        XclImpNameManager&      rNameMgr        = GetNameManager();
+        // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
+
+        enum STATE {
+            Z_BiffNull, // not a valid Biff-Format
+            Z_Biff2,    // Biff2: only one table
+
+            Z_Biff3,    // Biff3: only one table
+
+            Z_Biff4,    // Biff4: only one table
+            Z_Biff4W,   // Biff4 Workbook: Globals
+            Z_Biff4T,   // Biff4 Workbook: a table itself
+            Z_Biff4E,   // Biff4 Workbook: between tables
+
+            Z_Biff5WPre,// Biff5: Prefetch Workbook
+            Z_Biff5W,   // Biff5: Globals
+            Z_Biff5TPre,// Biff5: Prefetch for Shrfmla/Array Formula
+            Z_Biff5T,   // Biff5: a table itself
+            Z_Biff5E,   // Biff5: between tables
+            Z_Biffn0,   // all Biffs: skip table till next EOF
+            Z_End };
+
+        STATE           eCurrent = Z_BiffNull, ePrev = Z_BiffNull;
+
+        sal_uInt16      nOpcode;
+        sal_uInt16      nBofLevel = 0;
+
+        std::unique_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
+            aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
+
+        /*  #i104057# Need to track a base position for progress bar calculation,
+            because sheet substreams may not be in order of sheets. */
+        std::size_t nProgressBasePos = 0;
+        std::size_t nProgressBaseSize = 0;
+
+        for (; eCurrent != Z_End; mnLastRecId = nOpcode)
         {
-            sal_uInt16 nScTab = GetCurrScTab();
-            if( nScTab < maSheetOffsets.size()  )
+            if( eCurrent == Z_Biff5E )
             {
-                nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
-                nProgressBasePos = maSheetOffsets[ nScTab ];
-
-                bool bValid = TryStartNextRecord(aIn, nProgressBasePos);
-                if (!bValid)
+                sal_uInt16 nScTab = GetCurrScTab();
+                if( nScTab < maSheetOffsets.size()  )
                 {
-                    // Safeguard ourselves from potential infinite loop.
-                    eCurrent = Z_End;
+                    nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
+                    nProgressBasePos = maSheetOffsets[ nScTab ];
+
+                    bool bValid = TryStartNextRecord(aIn, nProgressBasePos);
+                    if (!bValid)
+                    {
+                        // Safeguard ourselves from potential infinite loop.
+                        eCurrent = Z_End;
+                    }
                 }
+                else
+                    eCurrent = Z_End;
             }
             else
-                eCurrent = Z_End;
-        }
-        else
-            aIn.StartNextRecord();
+                aIn.StartNextRecord();
 
-        nOpcode = aIn.GetRecId();
+            nOpcode = aIn.GetRecId();
 
-        if( !aIn.IsValid() )
-        {
-            // finalize table if EOF is missing
-            switch( eCurrent )
+            if( !aIn.IsValid() )
             {
-                case Z_Biff2:
-                case Z_Biff3:
-                case Z_Biff4:
-                case Z_Biff4T:
-                case Z_Biff5TPre:
-                case Z_Biff5T:
-                    rNumFmtBfr.CreateScFormats();
-                    Eof();
+                // finalize table if EOF is missing
+                switch( eCurrent )
+                {
+                    case Z_Biff2:
+                    case Z_Biff3:
+                    case Z_Biff4:
+                    case Z_Biff4T:
+                    case Z_Biff5TPre:
+                    case Z_Biff5T:
+                        rNumFmtBfr.CreateScFormats();
+                        Eof();
+                    break;
+                    default:;
+                }
                 break;
-                default:;
             }
-            break;
-        }
 
-        if( eCurrent == Z_End )
-            break;
+            if( eCurrent == Z_End )
+                break;
 
-        if( eCurrent != Z_Biff5TPre && eCurrent != Z_Biff5WPre )
-            pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
+            if( eCurrent != Z_Biff5TPre && eCurrent != Z_Biff5WPre )
+                pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
 
-        switch( eCurrent )
-        {
-
-            case Z_BiffNull:    // ------------------------------- Z_BiffNull -
+            switch( eCurrent )
             {
-                switch( nOpcode )
+
+                case Z_BiffNull:    // ------------------------------- Z_BiffNull -
                 {
-                    case EXC_ID2_BOF:
-                    case EXC_ID3_BOF:
-                    case EXC_ID4_BOF:
-                    case EXC_ID5_BOF:
+                    switch( nOpcode )
                     {
-                        // #i23425# don't rely on the record ID, but on the detected BIFF version
-                        switch( GetBiff() )
+                        case EXC_ID2_BOF:
+                        case EXC_ID3_BOF:
+                        case EXC_ID4_BOF:
+                        case EXC_ID5_BOF:
                         {
-                            case EXC_BIFF2:
-                                Bof2();
-                                if( pExcRoot->eDateiTyp == Biff2 )
-                                {
-                                    eCurrent = Z_Biff2;
-                                    NewTable();
-                                }
-                            break;
-                            case EXC_BIFF3:
-                                Bof3();
-                                if( pExcRoot->eDateiTyp == Biff3 )
-                                {
-                                    eCurrent = Z_Biff3;
-                                    NewTable();
-                                }
-                            break;
-                            case EXC_BIFF4:
-                                Bof4();
-                                if( pExcRoot->eDateiTyp == Biff4 )
-                                {
-                                    eCurrent = Z_Biff4;
-                                    NewTable();
-                                }
-                                else if( pExcRoot->eDateiTyp == Biff4W )
-                                    eCurrent = Z_Biff4W;
-                            break;
-                            case EXC_BIFF5:
-                                Bof5();
-                                if( pExcRoot->eDateiTyp == Biff5W )
-                                {
-                                    eCurrent = Z_Biff5WPre;
-
-                                    nBdshtTab = 0;
-
-                                    aIn.StoreGlobalPosition(); // store position
-                                }
-                                else if( pExcRoot->eDateiTyp == Biff5 )
-                                {
-                                    // #i62752# possible to have BIFF5 sheet without globals
-                                    NewTable();
-                                    eCurrent = Z_Biff5TPre;  // Shrfmla Prefetch, Row-Prefetch
-                                    nBofLevel = 0;
-                                    aIn.StoreGlobalPosition(); // store position
-                                }
-                            break;
-                            default:
-                                DBG_ERROR_BIFF();
+                            // #i23425# don't rely on the record ID, but on the detected BIFF version
+                            switch( GetBiff() )
+                            {
+                                case EXC_BIFF2:
+                                    Bof2();
+                                    if( pExcRoot->eDateiTyp == Biff2 )
+                                    {
+                                        eCurrent = Z_Biff2;
+                                        NewTable();
+                                    }
+                                break;
+                                case EXC_BIFF3:
+                                    Bof3();
+                                    if( pExcRoot->eDateiTyp == Biff3 )
+                                    {
+                                        eCurrent = Z_Biff3;
+                                        NewTable();
+                                    }
+                                break;
+                                case EXC_BIFF4:
+                                    Bof4();
+                                    if( pExcRoot->eDateiTyp == Biff4 )
+                                    {
+                                        eCurrent = Z_Biff4;
+                                        NewTable();
+                                    }
+                                    else if( pExcRoot->eDateiTyp == Biff4W )
+                                        eCurrent = Z_Biff4W;
+                                break;
+                                case EXC_BIFF5:
+                                    Bof5();
+                                    if( pExcRoot->eDateiTyp == Biff5W )
+                                    {
+                                        eCurrent = Z_Biff5WPre;
+
+                                        nBdshtTab = 0;
+
+                                        aIn.StoreGlobalPosition(); // store position
+                                    }
+                                    else if( pExcRoot->eDateiTyp == Biff5 )
+                                    {
+                                        // #i62752# possible to have BIFF5 sheet without globals
+                                        NewTable();
+                                        eCurrent = Z_Biff5TPre;  // Shrfmla Prefetch, Row-Prefetch
+                                        nBofLevel = 0;
+                                        aIn.StoreGlobalPosition(); // store position
+                                    }
+                                break;
+                                default:
+                                    DBG_ERROR_BIFF();
+                            }
                         }
+                        break;
                     }
-                    break;
                 }
-            }
-                break;
+                    break;
 
-            case Z_Biff2:       // ---------------------------------- Z_Biff2 -
-            {
-                switch( nOpcode )
+                case Z_Biff2:       // ---------------------------------- Z_Biff2 -
                 {
-                    case EXC_ID2_DIMENSIONS:
-                    case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
-                    case EXC_ID2_BLANK:
-                    case EXC_ID3_BLANK:         ReadBlank();            break;
-                    case EXC_ID2_INTEGER:       ReadInteger();          break;
-                    case EXC_ID2_NUMBER:
-                    case EXC_ID3_NUMBER:        ReadNumber();           break;
-                    case EXC_ID2_LABEL:
-                    case EXC_ID3_LABEL:         ReadLabel();            break;
-                    case EXC_ID2_BOOLERR:
-                    case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
-                    case EXC_ID_RK:             ReadRk();               break;
-
-                    case 0x06:  Formula25(); break;     // FORMULA      [ 2  5]
-                    case 0x08:  Row25(); break;         // ROW          [ 2  5]
-                    case 0x0A:                          // EOF          [ 2345]
-                        rNumFmtBfr.CreateScFormats();
-                        rNameMgr.ConvertAllTokens();
-                        Eof();
-                        eCurrent = Z_End;
-                        break;
-                    case 0x14:
-                    case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
-                    case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
-                    case 0x18:  rNameMgr.ReadName( maStrm );            break;
-                    case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
-                    case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
-                    case 0x1E:  rNumFmtBfr.ReadFormat( maStrm );        break;
-                    case 0x20:  Columndefault(); break; // COLUMNDEFAULT[ 2   ]
-                    case 0x21:  Array25(); break;       // ARRAY        [ 2  5]
-                    case 0x23:  Externname25(); break;  // EXTERNNAME   [ 2  5]
-                    case 0x24:  Colwidth(); break;      // COLWIDTH     [ 2   ]
-                    case 0x25:  Defrowheight2(); break; // DEFAULTROWHEI[ 2   ]
-                    case 0x26:
-                    case 0x27:
-                    case 0x28:
-                    case 0x29:  rPageSett.ReadMargin( maStrm );         break;
-                    case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
-                    case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
-                    case 0x2F:                          // FILEPASS     [ 2345]
-                        eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
-                        if( eLastErr != ERRCODE_NONE )
+                    switch( nOpcode )
+                    {
+                        case EXC_ID2_DIMENSIONS:
+                        case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
+                        case EXC_ID2_BLANK:
+                        case EXC_ID3_BLANK:         ReadBlank();            break;
+                        case EXC_ID2_INTEGER:       ReadInteger();          break;
+                        case EXC_ID2_NUMBER:
+                        case EXC_ID3_NUMBER:        ReadNumber();           break;
+                        case EXC_ID2_LABEL:
+                        case EXC_ID3_LABEL:         ReadLabel();            break;
+                        case EXC_ID2_BOOLERR:
+                        case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
+                        case EXC_ID_RK:             ReadRk();               break;
+
+                        case 0x06:  Formula25(); break;     // FORMULA      [ 2  5]
+                        case 0x08:  Row25(); break;         // ROW          [ 2  5]
+                        case 0x0A:                          // EOF          [ 2345]
+                            rNumFmtBfr.CreateScFormats();
+                            rNameMgr.ConvertAllTokens();
+                            Eof();
                             eCurrent = Z_End;
-                        break;
-                    case EXC_ID2_FONT:  rFontBfr.ReadFont( maStrm );    break;
-                    case EXC_ID_EFONT:  rFontBfr.ReadEfont( maStrm );   break;
-                    case 0x3E:  rTabViewSett.ReadWindow2( maStrm, false );break;
-                    case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
-                    case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
-                    case 0x43:  rXFBfr.ReadXF( maStrm );                break;
-                    case 0x44:  Ixfe(); break;          // IXFE         [ 2   ]
+                            break;
+                        case 0x14:
+                        case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
+                        case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
+                        case 0x18:  rNameMgr.ReadName( maStrm );            break;
+                        case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
+                        case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
+                        case 0x1E:  rNumFmtBfr.ReadFormat( maStrm );        break;
+                        case 0x20:  Columndefault(); break; // COLUMNDEFAULT[ 2   ]
+                        case 0x21:  Array25(); break;       // ARRAY        [ 2  5]
+                        case 0x23:  Externname25(); break;  // EXTERNNAME   [ 2  5]
+                        case 0x24:  Colwidth(); break;      // COLWIDTH     [ 2   ]
+                        case 0x25:  Defrowheight2(); break; // DEFAULTROWHEI[ 2   ]
+                        case 0x26:
+                        case 0x27:
+                        case 0x28:
+                        case 0x29:  rPageSett.ReadMargin( maStrm );         break;
+                        case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
+                        case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
+                        case 0x2F:                          // FILEPASS     [ 2345]
+                            eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
+                            if( eLastErr != ERRCODE_NONE )
+                                eCurrent = Z_End;
+                            break;
+                        case EXC_ID2_FONT:  rFontBfr.ReadFont( maStrm );    break;
+                        case EXC_ID_EFONT:  rFontBfr.ReadEfont( maStrm );   break;
+                        case 0x3E:  rTabViewSett.ReadWindow2( maStrm, false );break;
+                        case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
+                        case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
+                        case 0x43:  rXFBfr.ReadXF( maStrm );                break;
+                        case 0x44:  Ixfe(); break;          // IXFE         [ 2   ]
+                    }
                 }
-            }
-                break;
+                    break;
 
-            case Z_Biff3:       // ---------------------------------- Z_Biff3 -
-            {
-                switch( nOpcode )
+                case Z_Biff3:       // ---------------------------------- Z_Biff3 -
                 {
-                    // skip chart substream
-                    case EXC_ID2_BOF:
-                    case EXC_ID3_BOF:
-                    case EXC_ID4_BOF:
-                    case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
+                    switch( nOpcode )
+                    {
+                        // skip chart substream
+                        case EXC_ID2_BOF:
+                        case EXC_ID3_BOF:
+                        case EXC_ID4_BOF:
+                        case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
 
-                    case EXC_ID2_DIMENSIONS:
-                    case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
-                    case EXC_ID2_BLANK:
-                    case EXC_ID3_BLANK:         ReadBlank();            break;
-                    case EXC_ID2_INTEGER:       ReadInteger();          break;
-                    case EXC_ID2_NUMBER:
-                    case EXC_ID3_NUMBER:        ReadNumber();           break;
-                    case EXC_ID2_LABEL:
-                    case EXC_ID3_LABEL:         ReadLabel();            break;
-                    case EXC_ID2_BOOLERR:
-                    case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
-                    case EXC_ID_RK:             ReadRk();               break;
+                        case EXC_ID2_DIMENSIONS:
+                        case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
+                        case EXC_ID2_BLANK:
+                        case EXC_ID3_BLANK:         ReadBlank();            break;
+                        case EXC_ID2_INTEGER:       ReadInteger();          break;
+                        case EXC_ID2_NUMBER:
+                        case EXC_ID3_NUMBER:        ReadNumber();           break;
+                        case EXC_ID2_LABEL:
+                        case EXC_ID3_LABEL:         ReadLabel();            break;
+                        case EXC_ID2_BOOLERR:
+                        case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
+                        case EXC_ID_RK:             ReadRk();               break;
 
-                    case 0x0A:                          // EOF          [ 2345]
-                        rNumFmtBfr.CreateScFormats();
-                        rNameMgr.ConvertAllTokens();
-                        Eof();
-                        eCurrent = Z_End;
-                        break;
-                    case 0x14:
-                    case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
-                    case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
-                    case 0x1A:
-                    case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
-                    case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
-                    case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
-                    case 0x1E:  rNumFmtBfr.ReadFormat( maStrm );        break;
-                    case 0x22:  Rec1904(); break;       // 1904         [ 2345]
-                    case 0x26:
-                    case 0x27:
-                    case 0x28:
-                    case 0x29:  rPageSett.ReadMargin( maStrm );         break;
-                    case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
-                    case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
-                    case 0x2F:                          // FILEPASS     [ 2345]
-                        eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
-                        if( eLastErr != ERRCODE_NONE )
+                        case 0x0A:                          // EOF          [ 2345]
+                            rNumFmtBfr.CreateScFormats();
+                            rNameMgr.ConvertAllTokens();
+                            Eof();
                             eCurrent = Z_End;
-                        break;
-                    case EXC_ID_FILESHARING: ReadFileSharing();         break;
-                    case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
-                    case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
-                    case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
-                    case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
-                    case 0x7D:  Colinfo(); break;       // COLINFO      [  345]
-                    case 0x8C:  Country(); break;       // COUNTRY      [  345]
-                    case 0x92:  rPal.ReadPalette( maStrm );             break;
-                    case 0x0206: Formula3(); break;     // FORMULA      [  3  ]
-                    case 0x0208: Row34(); break;        // ROW          [  34 ]
-                    case 0x0218: rNameMgr.ReadName( maStrm );           break;
-                    case 0x0221: Array34(); break;      // ARRAY        [  34 ]
-                    case 0x0223: break;                 // EXTERNNAME   [  34 ]
-                    case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
-                    case 0x0231: rFontBfr.ReadFont( maStrm );           break;
-                    case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
-                    case 0x0243: rXFBfr.ReadXF( maStrm );               break;
-                    case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
+                            break;
+                        case 0x14:
+                        case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
+                        case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
+                        case 0x1A:
+                        case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
+                        case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
+                        case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
+                        case 0x1E:  rNumFmtBfr.ReadFormat( maStrm );        break;
+                        case 0x22:  Rec1904(); break;       // 1904         [ 2345]
+                        case 0x26:
+                        case 0x27:
+                        case 0x28:
+                        case 0x29:  rPageSett.ReadMargin( maStrm );         break;
+                        case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
+                        case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
+                        case 0x2F:                          // FILEPASS     [ 2345]
+                            eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
+                            if( eLastErr != ERRCODE_NONE )
+                                eCurrent = Z_End;
+                            break;
+                        case EXC_ID_FILESHARING: ReadFileSharing();         break;
+                        case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
+                        case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
+                        case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
+                        case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
+                        case 0x7D:  Colinfo(); break;       // COLINFO      [  345]
+                        case 0x8C:  Country(); break;       // COUNTRY      [  345]
+                        case 0x92:  rPal.ReadPalette( maStrm );             break;
+                        case 0x0206: Formula3(); break;     // FORMULA      [  3  ]
+                        case 0x0208: Row34(); break;        // ROW          [  34 ]
+                        case 0x0218: rNameMgr.ReadName( maStrm );           break;
+                        case 0x0221: Array34(); break;      // ARRAY        [  34 ]
+                        case 0x0223: break;                 // EXTERNNAME   [  34 ]
+                        case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
+                        case 0x0231: rFontBfr.ReadFont( maStrm );           break;
+                        case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
+                        case 0x0243: rXFBfr.ReadXF( maStrm );               break;
+                        case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
+                    }
                 }
-            }
-                break;
+                    break;
 
-            case Z_Biff4:       // ---------------------------------- Z_Biff4 -
-            {
-                switch( nOpcode )
+                case Z_Biff4:       // ---------------------------------- Z_Biff4 -
                 {
-                    // skip chart substream
-                    case EXC_ID2_BOF:
-                    case EXC_ID3_BOF:
-                    case EXC_ID4_BOF:
-                    case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
-
-                    case EXC_ID2_DIMENSIONS:
-                    case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
-                    case EXC_ID2_BLANK:
-                    case EXC_ID3_BLANK:         ReadBlank();            break;
-                    case EXC_ID2_INTEGER:       ReadInteger();          break;
-                    case EXC_ID2_NUMBER:
-                    case EXC_ID3_NUMBER:        ReadNumber();           break;
-                    case EXC_ID2_LABEL:
-                    case EXC_ID3_LABEL:         ReadLabel();            break;
-                    case EXC_ID2_BOOLERR:
-                    case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
-                    case EXC_ID_RK:             ReadRk();               break;
+                    switch( nOpcode )
+                    {
+                        // skip chart substream
+                        case EXC_ID2_BOF:
+                        case EXC_ID3_BOF:
+                        case EXC_ID4_BOF:
+                        case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
 
-                    case 0x0A:                          // EOF          [ 2345]
-                        rNumFmtBfr.CreateScFormats();
-                        rNameMgr.ConvertAllTokens();
-                        Eof();
-                        eCurrent = Z_End;
-                        break;
-                    case 0x12:  SheetProtect(); break;       // SHEET PROTECTION
-                    case 0x14:
-                    case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
-                    case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
-                    case 0x1A:
-                    case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
-                    case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
-                    case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
-                    case 0x22:  Rec1904(); break;       // 1904         [ 2345]
-                    case 0x26:
-                    case 0x27:
-                    case 0x28:
-                    case 0x29:  rPageSett.ReadMargin( maStrm );         break;
-                    case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
-                    case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
-                    case 0x2F:                          // FILEPASS     [ 2345]
-                        eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
-                        if( eLastErr != ERRCODE_NONE )
-                            eCurrent = Z_End;
-                        break;
-                    case EXC_ID_FILESHARING: ReadFileSharing();         break;
-                    case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
-                    case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
-                    case 0x55:  DefColWidth(); break;
-                    case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
-                    case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
-                    case 0x7D:  Colinfo(); break;       // COLINFO      [  345]
-                    case 0x8C:  Country(); break;       // COUNTRY      [  345]
-                    case 0x92:  rPal.ReadPalette( maStrm );             break;
-                    case 0x99:  Standardwidth(); break; // STANDARDWIDTH[   45]
-                    case 0xA1:  rPageSett.ReadSetup( maStrm );          break;
-                    case 0x0208: Row34(); break;        // ROW          [  34 ]
-                    case 0x0218: rNameMgr.ReadName( maStrm );           break;
-                    case 0x0221: Array34(); break;      // ARRAY        [  34 ]
-                    case 0x0223: break;                 // EXTERNNAME   [  34 ]
-                    case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
-                    case 0x0231: rFontBfr.ReadFont( maStrm );           break;
-                    case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
-                    case 0x0406: Formula4(); break;     // FORMULA      [   4 ]
-                    case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
-                    case 0x0443: rXFBfr.ReadXF( maStrm );               break;
-                    case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
-                }
-            }
-                break;
+                        case EXC_ID2_DIMENSIONS:
+                        case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
+                        case EXC_ID2_BLANK:
+                        case EXC_ID3_BLANK:         ReadBlank();            break;
+                        case EXC_ID2_INTEGER:       ReadInteger();          break;
+                        case EXC_ID2_NUMBER:
+                        case EXC_ID3_NUMBER:        ReadNumber();           break;
+                        case EXC_ID2_LABEL:
+                        case EXC_ID3_LABEL:         ReadLabel();            break;
+                        case EXC_ID2_BOOLERR:
+                        case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
+                        case EXC_ID_RK:             ReadRk();               break;
 
-            case Z_Biff4W:      // --------------------------------- Z_Biff4W -
-            {
-                switch( nOpcode )
-                {
-                    case 0x0A:                          // EOF          [ 2345]
-                        rNameMgr.ConvertAllTokens();
-                        eCurrent = Z_End;
-                        break;
-                    case 0x12:  DocProtect(); break;    // PROTECT      [    5]
-                    case 0x2F:                          // FILEPASS     [ 2345]
-                        eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
-                        if( eLastErr != ERRCODE_NONE )
-                            eCurrent = Z_End;
-                        break;
-                    case EXC_ID_FILESHARING: ReadFileSharing();         break;
-                    case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
-                    case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
-                    case 0x55:  DefColWidth(); break;
-                    case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
-                    case 0x8C:  Country(); break;       // COUNTRY      [  345]
-                    case 0x8F:  break;                  // BUNDLEHEADER [   4 ]
-                    case 0x92:  rPal.ReadPalette( maStrm );             break;
-                    case 0x99:  Standardwidth(); break; // STANDARDWIDTH[   45]
-                    case 0x0218: rNameMgr.ReadName( maStrm );           break;
-                    case 0x0223: break;                 // EXTERNNAME   [  34 ]
-                    case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
-                    case 0x0231: rFontBfr.ReadFont( maStrm );           break;
-                    case EXC_ID4_BOF:                   // BOF          [   4 ]
-                        Bof4();
-                        if( pExcRoot->eDateiTyp == Biff4 )
-                        {
-                            eCurrent = Z_Biff4T;
-                            NewTable();
-                        }
-                        else
+                        case 0x0A:                          // EOF          [ 2345]
+                            rNumFmtBfr.CreateScFormats();
+                            rNameMgr.ConvertAllTokens();
+                            Eof();
                             eCurrent = Z_End;
-                        break;
-                    case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
-                    case 0x0443: rXFBfr.ReadXF( maStrm );               break;
-                    case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
+                            break;
+                        case 0x12:  SheetProtect(); break;       // SHEET PROTECTION
+                        case 0x14:
+                        case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
+                        case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
+                        case 0x1A:
+                        case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
+                        case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
+                        case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
+                        case 0x22:  Rec1904(); break;       // 1904         [ 2345]
+                        case 0x26:
+                        case 0x27:
+                        case 0x28:
+                        case 0x29:  rPageSett.ReadMargin( maStrm );         break;
+                        case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
+                        case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
+                        case 0x2F:                          // FILEPASS     [ 2345]
+                            eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
+                            if( eLastErr != ERRCODE_NONE )
+                                eCurrent = Z_End;
+                            break;
+                        case EXC_ID_FILESHARING: ReadFileSharing();         break;
+                        case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
+                        case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
+                        case 0x55:  DefColWidth(); break;
+                        case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
+                        case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
+                        case 0x7D:  Colinfo(); break;       // COLINFO      [  345]
+                        case 0x8C:  Country(); break;       // COUNTRY      [  345]
+                        case 0x92:  rPal.ReadPalette( maStrm );             break;
+                        case 0x99:  Standardwidth(); break; // STANDARDWIDTH[   45]
+                        case 0xA1:  rPageSett.ReadSetup( maStrm );          break;
+                        case 0x0208: Row34(); break;        // ROW          [  34 ]
+                        case 0x0218: rNameMgr.ReadName( maStrm );           break;
+                        case 0x0221: Array34(); break;      // ARRAY        [  34 ]
+                        case 0x0223: break;                 // EXTERNNAME   [  34 ]
+                        case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
+                        case 0x0231: rFontBfr.ReadFont( maStrm );           break;
+                        case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
+                        case 0x0406: Formula4(); break;     // FORMULA      [   4 ]
+                        case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
+                        case 0x0443: rXFBfr.ReadXF( maStrm );               break;
+                        case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
+                    }
                 }
-
-            }
-                break;
-
-            case Z_Biff4T:       // --------------------------------- Z_Biff4T -
-            {
-                switch( nOpcode )
-                {
-                    // skip chart substream
-                    case EXC_ID2_BOF:
-                    case EXC_ID3_BOF:
-                    case EXC_ID4_BOF:
-                    case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
-
-                    case EXC_ID2_DIMENSIONS:
-                    case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
-                    case EXC_ID2_BLANK:
-                    case EXC_ID3_BLANK:         ReadBlank();            break;
-                    case EXC_ID2_INTEGER:       ReadInteger();          break;
-                    case EXC_ID2_NUMBER:
-                    case EXC_ID3_NUMBER:        ReadNumber();           break;
-                    case EXC_ID2_LABEL:
-                    case EXC_ID3_LABEL:         ReadLabel();            break;
-                    case EXC_ID2_BOOLERR:
-                    case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
-                    case EXC_ID_RK:             ReadRk();               break;
-
-                    case 0x0A:                          // EOF          [ 2345]
-                        rNameMgr.ConvertAllTokens();
-                        Eof();
-                        eCurrent = Z_Biff4E;
                     break;
-                    case 0x12:  SheetProtect(); break;       // SHEET PROTECTION
-                    case 0x14:
-                    case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
-                    case 0x1A:
-                    case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
-                    case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
-                    case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
-                    case 0x2F:                          // FILEPASS     [ 2345]
-                        eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
-                        if( eLastErr != ERRCODE_NONE )
-                            eCurrent = Z_End;
-                        break;
-                    case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
-                    case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
-                    case 0x55:  DefColWidth(); break;
-                    case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
-                    case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
-                    case 0x7D:  Colinfo(); break;       // COLINFO      [  345]
-                    case 0x8C:  Country(); break;       // COUNTRY      [  345]
-                    case 0x8F:  break;                  // BUNDLEHEADER [   4 ]
-                    case 0x92:  rPal.ReadPalette( maStrm );             break;
-                    case 0x99:  Standardwidth(); break; // STANDARDWIDTH[   45]
-                    case 0xA1:  rPageSett.ReadSetup( maStrm );          break;
-                    case 0x0208: Row34(); break;        // ROW          [  34 ]
-                    case 0x0218: rNameMgr.ReadName( maStrm );           break;
-                    case 0x0221: Array34(); break;
-                    case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
-                    case 0x0231: rFontBfr.ReadFont( maStrm );           break;
-                    case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
-                    case 0x0406: Formula4(); break;
-                    case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
-                    case 0x0443: rXFBfr.ReadXF( maStrm );               break;
-                    case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
-                }
-
-            }
-                break;
 
-            case Z_Biff4E:      // --------------------------------- Z_Biff4E -
-            {
-                switch( nOpcode )
+                case Z_Biff4W:      // --------------------------------- Z_Biff4W -
                 {
-                    case 0x0A:                          // EOF          [ 2345]
-                        eCurrent = Z_End;
-                        break;
-                    case 0x8F:  break;                  // BUNDLEHEADER [   4 ]
-                    case EXC_ID4_BOF:                   // BOF          [   4 ]
-                        Bof4();
-                        NewTable();
-                        if( pExcRoot->eDateiTyp == Biff4 )
-                        {
-                            eCurrent = Z_Biff4T;
-                        }
-                        else
-                        {
-                            ePrev = eCurrent;
-                            eCurrent = Z_Biffn0;
-                        }
-                        break;
-                }
-
-            }
-                break;
-            case Z_Biff5WPre:   // ------------------------------ Z_Biff5WPre -
-            {
-                switch( nOpcode )
-                {
-                    case 0x0A:                          // EOF          [ 2345]
-                        eCurrent = Z_Biff5W;
-                        aIn.SeekGlobalPosition();  // and back to old position
-                        break;
-                    case 0x12:  DocProtect(); break;    // PROTECT      [    5]
-                    case 0x2F:                          // FILEPASS     [ 2345]
-                        eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
-                        if( eLastErr != ERRCODE_NONE )
+                    switch( nOpcode )
+                    {
+                        case 0x0A:                          // EOF          [ 2345]
+                            rNameMgr.ConvertAllTokens();
                             eCurrent = Z_End;
-                        break;
-                    case EXC_ID_FILESHARING: ReadFileSharing();         break;
-                    case 0x3D:  Window1(); break;
-                    case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
-                    case 0x85:  Boundsheet(); break;    // BOUNDSHEET   [    5]
-                    case 0x8C:  Country(); break;       // COUNTRY      [  345]
-                    // PALETTE follows XFs, but already needed while reading the XFs
-                    case 0x92:  rPal.ReadPalette( maStrm );             break;
-                }
-            }
-                break;
-            case Z_Biff5W:      // --------------------------------- Z_Biff5W -
-            {
-                switch( nOpcode )
-                {
-                    case 0x0A:                          // EOF          [ 2345]
-                        rNumFmtBfr.CreateScFormats();
-                        rXFBfr.CreateUserStyles();
-                        rNameMgr.ConvertAllTokens();
-                        eCurrent = Z_Biff5E;
-                        break;
-                    case 0x18:  rNameMgr.ReadName( maStrm );            break;
-                    case 0x1E:  rNumFmtBfr.ReadFormat( maStrm );        break;
-                    case 0x22:  Rec1904(); break;       // 1904         [ 2345]
-                    case 0x31:  rFontBfr.ReadFont( maStrm );            break;
-                    case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
-                    case 0x8D:  Hideobj(); break;       // HIDEOBJ      [  345]
-                    case 0xDE:  Olesize(); break;
-                    case 0xE0:  rXFBfr.ReadXF( maStrm );                break;
-                    case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
-                    case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
-                }
+                            break;
+                        case 0x12:  DocProtect(); break;    // PROTECT      [    5]
+                        case 0x2F:                          // FILEPASS     [ 2345]
+                            eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
+                            if( eLastErr != ERRCODE_NONE )
+                                eCurrent = Z_End;
+                            break;
+                        case EXC_ID_FILESHARING: ReadFileSharing();         break;
+                        case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
+                        case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
+                        case 0x55:  DefColWidth(); break;
+                        case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
+                        case 0x8C:  Country(); break;       // COUNTRY      [  345]
+                        case 0x8F:  break;                  // BUNDLEHEADER [   4 ]
+                        case 0x92:  rPal.ReadPalette( maStrm );             break;
+                        case 0x99:  Standardwidth(); break; // STANDARDWIDTH[   45]
+                        case 0x0218: rNameMgr.ReadName( maStrm );           break;
+                        case 0x0223: break;                 // EXTERNNAME   [  34 ]
+                        case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
+                        case 0x0231: rFontBfr.ReadFont( maStrm );           break;
+                        case EXC_ID4_BOF:                   // BOF          [   4 ]
+                            Bof4();
+                            if( pExcRoot->eDateiTyp == Biff4 )
+                            {
+                                eCurrent = Z_Biff4T;
+                                NewTable();
+                            }
+                            else
+                                eCurrent = Z_End;
+                            break;
+                        case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
+                        case 0x0443: rXFBfr.ReadXF( maStrm );               break;
+                        case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
+                    }
 
-            }
-                break;
+                }
+                    break;
 
-            case Z_Biff5TPre:   // ------------------------------- Z_Biff5Pre -
-            {
-                if (nOpcode == EXC_ID5_BOF)
-                    nBofLevel++;
-                else if( (nOpcode == 0x000A) && nBofLevel )
-                    nBofLevel--;
-                else if( !nBofLevel )                       // don't read chart records
+                case Z_Biff4T:       // --------------------------------- Z_Biff4T -
                 {
                     switch( nOpcode )
                     {
+                        // skip chart substream
+                        case EXC_ID2_BOF:
+                        case EXC_ID3_BOF:
+                        case EXC_ID4_BOF:
+                        case EXC_ID5_BOF:           XclTools::SkipSubStream( maStrm );  break;
+
                         case EXC_ID2_DIMENSIONS:
                         case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
-                        case 0x08:  Row25(); break;         // ROW          [ 2  5]
+                        case EXC_ID2_BLANK:
+                        case EXC_ID3_BLANK:         ReadBlank();            break;
+                        case EXC_ID2_INTEGER:       ReadInteger();          break;
+                        case EXC_ID2_NUMBER:
+                        case EXC_ID3_NUMBER:        ReadNumber();           break;
+                        case EXC_ID2_LABEL:
+                        case EXC_ID3_LABEL:         ReadLabel();            break;
+                        case EXC_ID2_BOOLERR:
+                        case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
+                        case EXC_ID_RK:             ReadRk();               break;
+
                         case 0x0A:                          // EOF          [ 2345]
-                            eCurrent = Z_Biff5T;
-                            aIn.SeekGlobalPosition(); // and back to old position
-                            break;
+                            rNameMgr.ConvertAllTokens();
+                            Eof();
+                            eCurrent = Z_Biff4E;
+                        break;
                         case 0x12:  SheetProtect(); break;       // SHEET PROTECTION
+                        case 0x14:
+                        case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
                         case 0x1A:
                         case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
+                        case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
                         case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
-                        case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
-                        case 0x21:  Array25(); break;       // ARRAY        [ 2  5]
-                        case 0x23:  Externname25(); break;  // EXTERNNAME   [ 2  5]
+                        case 0x2F:                          // FILEPASS     [ 2345]
+                            eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
+                            if( eLastErr != ERRCODE_NONE )
+                                eCurrent = Z_End;
+                            break;
                         case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
                         case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
                         case 0x55:  DefColWidth(); break;
+                        case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
+                        case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
                         case 0x7D:  Colinfo(); break;       // COLINFO      [  345]
-                        case 0x81:  Wsbool(); break;        // WSBOOL       [ 2345]
                         case 0x8C:  Country(); break;       // COUNTRY      [  345]
+                        case 0x8F:  break;                  // BUNDLEHEADER [   4 ]
+                        case 0x92:  rPal.ReadPalette( maStrm );             break;
                         case 0x99:  Standardwidth(); break; // STANDARDWIDTH[   45]
+                        case 0xA1:  rPageSett.ReadSetup( maStrm );          break;
                         case 0x0208: Row34(); break;        // ROW          [  34 ]
-                        case 0x0221: Array34(); break;      // ARRAY        [  34 ]
-                        case 0x0223: break;                 // EXTERNNAME   [  34 ]
+                        case 0x0218: rNameMgr.ReadName( maStrm );           break;
+                        case 0x0221: Array34(); break;
                         case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
+                        case 0x0231: rFontBfr.ReadFont( maStrm );           break;
                         case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
+                        case 0x0406: Formula4(); break;
+                        case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
+                        case 0x0443: rXFBfr.ReadXF( maStrm );               break;
+                        case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
                     }
+
                 }
-            }
-                break;
+                    break;
 
-            case Z_Biff5T:       // --------------------------------- Z_Biff5T -
-            {
-                switch( nOpcode )
+                case Z_Biff4E:      // --------------------------------- Z_Biff4E -
                 {
-                    case EXC_ID2_BLANK:
-                    case EXC_ID3_BLANK:         ReadBlank();            break;
-                    case EXC_ID2_INTEGER:       ReadInteger();          break;
-                    case EXC_ID2_NUMBER:
-                    case EXC_ID3_NUMBER:        ReadNumber();           break;
-                    case EXC_ID2_LABEL:
-                    case EXC_ID3_LABEL:         ReadLabel();            break;
-                    case EXC_ID2_BOOLERR:
-                    case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
-                    case EXC_ID_RK:             ReadRk();               break;
-
-                    case EXC_ID2_FORMULA:
-                    case EXC_ID3_FORMULA:
-                    case EXC_ID4_FORMULA:       Formula25(); break;
-                    case EXC_ID_SHRFMLA: Shrfmla(); break;
-                    case 0x0A:  Eof(); eCurrent = Z_Biff5E;                 break;
-                    case 0x14:
-                    case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
-                    case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
-                    case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
-                    case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
-                    case 0x23:  Externname25(); break;  // EXTERNNAME   [ 2  5]
-                    case 0x26:
-                    case 0x27:
-                    case 0x28:
-                    case 0x29:  rPageSett.ReadMargin( maStrm );         break;
-                    case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
-                    case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
-                    case 0x2F:                          // FILEPASS     [ 2345]
-                        eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
-                        if( eLastErr != ERRCODE_NONE )
+                    switch( nOpcode )
+                    {
+                        case 0x0A:                          // EOF          [ 2345]
                             eCurrent = Z_End;
-                        break;
-                    case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
-                    case 0x83:
-                    case 0x84:  rPageSett.ReadCenter( maStrm );         break;
-                    case 0xA0:  rTabViewSett.ReadScl( maStrm );         break;
-                    case 0xA1:  rPageSett.ReadSetup( maStrm );          break;
-                    case 0xBD:  Mulrk(); break;         // MULRK        [    5]
-                    case 0xBE:  Mulblank(); break;      // MULBLANK     [    5]
-                    case 0xD6:  Rstring(); break;       // RSTRING      [    5]
-                    case 0x00E5: Cellmerging();          break;  // #i62300#
-                    case 0x0236: TableOp(); break;      // TABLE        [    5]
-                    case EXC_ID5_BOF:                   // BOF          [    5]
-                        XclTools::SkipSubStream( maStrm );
-                        break;
+                            break;
+                        case 0x8F:  break;                  // BUNDLEHEADER [   4 ]
+                        case EXC_ID4_BOF:                   // BOF          [   4 ]
+                            Bof4();
+                            NewTable();
+                            if( pExcRoot->eDateiTyp == Biff4 )
+                            {
+                                eCurrent = Z_Biff4T;
+                            }
+                            else
+                            {
+                                ePrev = eCurrent;
+                                eCurrent = Z_Biffn0;
+                            }
+                            break;
+                    }
+
                 }
+                    break;
+                case Z_Biff5WPre:   // ------------------------------ Z_Biff5WPre -
+                {
+                    switch( nOpcode )
+                    {
+                        case 0x0A:                          // EOF          [ 2345]
+                            eCurrent = Z_Biff5W;
+                            aIn.SeekGlobalPosition();  // and back to old position
+                            break;
+                        case 0x12:  DocProtect(); break;    // PROTECT      [    5]
+                        case 0x2F:                          // FILEPASS     [ 2345]
+                            eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
+                            if( eLastErr != ERRCODE_NONE )
+                                eCurrent = Z_End;
+                            break;
+                        case EXC_ID_FILESHARING: ReadFileSharing();         break;
+                        case 0x3D:  Window1(); break;
+                        case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
+                        case 0x85:  Boundsheet(); break;    // BOUNDSHEET   [    5]
+                        case 0x8C:  Country(); break;       // COUNTRY      [  345]
+                        // PALETTE follows XFs, but already needed while reading the XFs
+                        case 0x92:  rPal.ReadPalette( maStrm );             break;
+                    }
+                }
+                    break;
+                case Z_Biff5W:      // --------------------------------- Z_Biff5W -
+                {
+                    switch( nOpcode )
+                    {
+                        case 0x0A:                          // EOF          [ 2345]
+                            rNumFmtBfr.CreateScFormats();
+                            rXFBfr.CreateUserStyles();
+                            rNameMgr.ConvertAllTokens();
+                            eCurrent = Z_Biff5E;
+                            break;
+                        case 0x18:  rNameMgr.ReadName( maStrm );            break;
+                        case 0x1E:  rNumFmtBfr.ReadFormat( maStrm );        break;
+                        case 0x22:  Rec1904(); break;       // 1904         [ 2345]
+                        case 0x31:  rFontBfr.ReadFont( maStrm );            break;
+                        case 0x56:  break;                  // BUILTINFMTCNT[  34 ]
+                        case 0x8D:  Hideobj(); break;       // HIDEOBJ      [  345]
+                        case 0xDE:  Olesize(); break;
+                        case 0xE0:  rXFBfr.ReadXF( maStrm );                break;
+                        case 0x0293: rXFBfr.ReadStyle( maStrm );            break;
+                        case 0x041E: rNumFmtBfr.ReadFormat( maStrm );       break;
+                    }
 
-            }
-                break;
+                }
+                    break;
 
-            case Z_Biff5E:      // --------------------------------- Z_Biff5E -
-            {
-                switch( nOpcode )
+                case Z_Biff5TPre:   // ------------------------------- Z_Biff5Pre -
                 {
-                    case EXC_ID5_BOF:                   // BOF          [    5]
-                        Bof5();
-                        NewTable();
-                        switch( pExcRoot->eDateiTyp )
+                    if (nOpcode == EXC_ID5_BOF)
+                        nBofLevel++;
+                    else if( (nOpcode == 0x000A) && nBofLevel )
+                        nBofLevel--;
+                    else if( !nBofLevel )                       // don't read chart records
+                    {
+                        switch( nOpcode )
                         {
-                            case Biff5:
-                            case Biff5M4:
-                                eCurrent = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
-                                nBofLevel = 0;
-                                aIn.StoreGlobalPosition(); // store position
+                            case EXC_ID2_DIMENSIONS:
+                            case EXC_ID3_DIMENSIONS:    ReadDimensions();       break;
+                            case 0x08:  Row25(); break;         // ROW          [ 2  5]
+                            case 0x0A:                          // EOF          [ 2345]
+                                eCurrent = Z_Biff5T;
+                                aIn.SeekGlobalPosition(); // and back to old position
+                                break;
+                            case 0x12:  SheetProtect(); break;       // SHEET PROTECTION
+                            case 0x1A:
+                            case 0x1B:  rPageSett.ReadPageBreaks( maStrm );     break;
+                            case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
+                            case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
+                            case 0x21:  Array25(); break;       // ARRAY        [ 2  5]
+                            case 0x23:  Externname25(); break;  // EXTERNNAME   [ 2  5]
+                            case 0x41:  rTabViewSett.ReadPane( maStrm );        break;
+                            case 0x42:  Codepage(); break;      // CODEPAGE     [ 2345]
+                            case 0x55:  DefColWidth(); break;
+                            case 0x7D:  Colinfo(); break;       // COLINFO      [  345]
+                            case 0x81:  Wsbool(); break;        // WSBOOL       [ 2345]
+                            case 0x8C:  Country(); break;       // COUNTRY      [  345]
+                            case 0x99:  Standardwidth(); break; // STANDARDWIDTH[   45]
+                            case 0x0208: Row34(); break;        // ROW          [  34 ]
+                            case 0x0221: Array34(); break;      // ARRAY        [  34 ]
+                            case 0x0223: break;                 // EXTERNNAME   [  34 ]
+                            case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[  345]
+                            case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
+                        }
+                    }
+                }
+                    break;
+
+                case Z_Biff5T:       // --------------------------------- Z_Biff5T -
+                {
+                    switch( nOpcode )
+                    {
+                        case EXC_ID2_BLANK:
+                        case EXC_ID3_BLANK:         ReadBlank();            break;
+                        case EXC_ID2_INTEGER:       ReadInteger();          break;
+                        case EXC_ID2_NUMBER:
+                        case EXC_ID3_NUMBER:        ReadNumber();           break;
+                        case EXC_ID2_LABEL:
+                        case EXC_ID3_LABEL:         ReadLabel();            break;
+                        case EXC_ID2_BOOLERR:
+                        case EXC_ID3_BOOLERR:       ReadBoolErr();          break;
+                        case EXC_ID_RK:             ReadRk();               break;
+
+                        case EXC_ID2_FORMULA:
+                        case EXC_ID3_FORMULA:
+                        case EXC_ID4_FORMULA:       Formula25(); break;
+                        case EXC_ID_SHRFMLA: Shrfmla(); break;
+                        case 0x0A:  Eof(); eCurrent = Z_Biff5E;                 break;
+                        case 0x14:
+                        case 0x15:  rPageSett.ReadHeaderFooter( maStrm );   break;
+                        case 0x17:  Externsheet(); break;   // EXTERNSHEET  [ 2345]
+                        case 0x1C:  GetCurrSheetDrawing().ReadNote( maStrm );break;
+                        case 0x1D:  rTabViewSett.ReadSelection( maStrm );   break;
+                        case 0x23:  Externname25(); break;  // EXTERNNAME   [ 2  5]
+                        case 0x26:
+                        case 0x27:
+                        case 0x28:
+                        case 0x29:  rPageSett.ReadMargin( maStrm );         break;
+                        case 0x2A:  rPageSett.ReadPrintHeaders( maStrm );   break;
+                        case 0x2B:  rPageSett.ReadPrintGridLines( maStrm ); break;
+                        case 0x2F:                          // FILEPASS     [ 2345]
+                            eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
+                            if( eLastErr != ERRCODE_NONE )
+                                eCurrent = Z_End;
                             break;
-                            case Biff5C:    // chart sheet
-                                GetCurrSheetDrawing().ReadTabChart( maStrm );
-                                Eof();
-                                GetTracer().TraceChartOnlySheet();
+                        case 0x5D:  GetCurrSheetDrawing().ReadObj( maStrm );break;
+                        case 0x83:
+                        case 0x84:  rPageSett.ReadCenter( maStrm );         break;
+                        case 0xA0:  rTabViewSett.ReadScl( maStrm );         break;
+                        case 0xA1:  rPageSett.ReadSetup( maStrm );          break;
+                        case 0xBD:  Mulrk(); break;         // MULRK        [    5]
+                        case 0xBE:  Mulblank(); break;      // MULBLANK     [    5]
+                        case 0xD6:  Rstring(); break;       // RSTRING      [    5]
+                        case 0x00E5: Cellmerging();          break;  // #i62300#
+                        case 0x0236: TableOp(); break;      // TABLE        [    5]
+                        case EXC_ID5_BOF:                   // BOF          [    5]
+                            XclTools::SkipSubStream( maStrm );
                             break;
-                            case Biff5V:
-                            default:
-                                rD.SetVisible( GetCurrScTab(), false );
-                                ePrev = eCurrent;
-                                eCurrent = Z_Biffn0;
-                        }
-                        OSL_ENSURE( pExcRoot->eDateiTyp != Biff5W,
-                            "+ImportExcel::Read(): Doppel-Whopper-Workbook!" );
+                    }
 
-                        break;
                 }
+                    break;
 
-            }
-                break;
-            case Z_Biffn0:      // --------------------------------- Z_Biffn0 -
-            {
-                switch( nOpcode )
+                case Z_Biff5E:      // --------------------------------- Z_Biff5E -
                 {
-                    case 0x0A:                          // EOF          [ 2345]
-                        eCurrent = ePrev;
-                        IncCurrScTab();
-                        break;
+                    switch( nOpcode )
+                    {
+                        case EXC_ID5_BOF:                   // BOF          [    5]
+                            Bof5();
+                            NewTable();
+                            switch( pExcRoot->eDateiTyp )
+                            {
+                                case Biff5:
+                                case Biff5M4:
+                                    eCurrent = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
+                                    nBofLevel = 0;
+                                    aIn.StoreGlobalPosition(); // store position
+                                break;
+                                case Biff5C:    // chart sheet
+                                    GetCurrSheetDrawing().ReadTabChart( maStrm );
+                                    Eof();
+                                    GetTracer().TraceChartOnlySheet();
+                                break;
+                                case Biff5V:
+                                default:
+                                    rD.SetVisible( GetCurrScTab(), false );
+                                    ePrev = eCurrent;
+                                    eCurrent = Z_Biffn0;
+                            }
+                            OSL_ENSURE( pExcRoot->eDateiTyp != Biff5W,
+                                "+ImportExcel::Read(): Doppel-Whopper-Workbook!" );
+
+                            break;
+                    }
+
                 }
+                    break;
+                case Z_Biffn0:      // --------------------------------- Z_Biffn0 -
+                {
+                    switch( nOpcode )
+                    {
+                        case 0x0A:                          // EOF          [ 2345]
+                            eCurrent = ePrev;
+                            IncCurrScTab();
+                            break;
+                    }
 
+                }
+                    break;
+
+                case Z_End:        // ----------------------------------- Z_End -
+                    OSL_FAIL( "*ImportExcel::Read(): Not possible state!" );
+                    break;
+                default: OSL_FAIL( "-ImportExcel::Read(): state forgotten!" );
             }
-                break;
+        }
 
-            case Z_End:        // ----------------------------------- Z_End -
-                OSL_FAIL( "*ImportExcel::Read(): Not possible state!" );
-                break;
-            default: OSL_FAIL( "-ImportExcel::Read(): state forgotten!" );
+        if( eLastErr == ERRCODE_NONE )
+        {
+            pProgress.reset();
+
+            GetDocImport().finalize();
+            if (!utl::ConfigManager::IsFuzzing())
+                AdjustRowHeight();
+            PostDocLoad();
+
+            rD.CalcAfterLoad(false);
+
+            const XclImpAddressConverter& rAddrConv = GetAddressConverter();
+            if( rAddrConv.IsTabTruncated() )
+                eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
+            else if( bTabTruncated || rAddrConv.IsRowTruncated() )
+                eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
+            else if( rAddrConv.IsColTruncated() )
+                eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
         }
     }
-
-    if( eLastErr == ERRCODE_NONE )
+    catch (const SvStreamEOFException&)
     {
-        pProgress.reset();
-
-        GetDocImport().finalize();
-        if (!utl::ConfigManager::IsFuzzing())
-            AdjustRowHeight();
-        PostDocLoad();
-
-        rD.CalcAfterLoad(false);
-
-        const XclImpAddressConverter& rAddrConv = GetAddressConverter();
-        if( rAddrConv.IsTabTruncated() )
-            eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
-        else if( bTabTruncated || rAddrConv.IsRowTruncated() )
-            eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
-        else if( rAddrConv.IsColTruncated() )
-            eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
+        SAL_WARN("sc", "EOF");
+        return ERRCODE_IO_CANTREAD;
     }
-
     return eLastErr;
 }
 


More information about the Libreoffice-commits mailing list