LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/excel - excform.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 127 888 14.3 %
Date: 2012-12-17 Functions: 12 25 48.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "excform.hxx"
      21             : #include <osl/endian.h>
      22             : 
      23             : #include "cell.hxx"
      24             : #include "document.hxx"
      25             : #include "rangenam.hxx"
      26             : #include "global.hxx"
      27             : #include "formula/errorcodes.hxx"
      28             : 
      29             : #include "imp_op.hxx"
      30             : #include "root.hxx"
      31             : #include "xltracer.hxx"
      32             : #include "xihelper.hxx"
      33             : #include "xilink.hxx"
      34             : #include "xiname.hxx"
      35             : 
      36             : using ::std::vector;
      37             : 
      38             : const sal_uInt16 ExcelToSc::nRowMask = 0x3FFF;
      39             : const sal_uInt16 ExcelToSc::nLastInd = 399;
      40             : 
      41             : 
      42        4858 : void ImportExcel::Formula25()
      43             : {
      44        4858 :     XclAddress aXclPos;
      45        4858 :     sal_uInt16  nXF = 0, nFormLen;
      46             :     double  fCurVal;
      47             :     sal_uInt8   nFlag0;
      48             :     sal_Bool    bShrFmla;
      49             : 
      50        4858 :     aIn >> aXclPos;
      51             : 
      52        4858 :     if( GetBiff() == EXC_BIFF2 )
      53             :     {//                     BIFF2
      54             :         sal_uInt8 nDummy;
      55             : 
      56           0 :         aIn.Ignore( 3 );
      57             : 
      58           0 :         aIn >> fCurVal;
      59           0 :         aIn.Ignore( 1 );
      60           0 :         aIn >> nDummy;
      61           0 :         nFormLen = nDummy;
      62           0 :         bShrFmla = false;
      63             :     }
      64             :     else
      65             :     {//                     BIFF5
      66        4858 :         aIn >> nXF >> fCurVal >> nFlag0;
      67        4858 :         aIn.Ignore( 5 );
      68             : 
      69        4858 :         aIn >> nFormLen;
      70             : 
      71        4858 :         bShrFmla = nFlag0 & 0x08;   // shared or not shared
      72             :     }
      73             : 
      74        4858 :     Formula( aXclPos, nXF, nFormLen, fCurVal, bShrFmla );
      75        4858 : }
      76             : 
      77             : 
      78           0 : void ImportExcel::Formula3()
      79             : {
      80           0 :     Formula4();
      81           0 : }
      82             : 
      83             : 
      84           0 : void ImportExcel::Formula4()
      85             : {
      86           0 :     XclAddress aXclPos;
      87             :     sal_uInt16  nXF, nFormLen;
      88             :     double  fCurVal;
      89             :     sal_uInt8   nFlag0;
      90             : 
      91           0 :     aIn >> aXclPos >> nXF >> fCurVal >> nFlag0;
      92           0 :     aIn.Ignore( 1 );
      93           0 :     aIn >> nFormLen;
      94             : 
      95           0 :     Formula( aXclPos, nXF, nFormLen, fCurVal, false );
      96           0 : }
      97             : 
      98             : 
      99        4858 : void ImportExcel::Formula(
     100             :     const XclAddress& rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen, double fCurVal, bool bShrFmla)
     101             : {
     102        4858 :     ConvErr eErr = ConvOK;
     103             : 
     104        4858 :     ScAddress aScPos( ScAddress::UNINITIALIZED );
     105        4858 :     if( GetAddressConverter().ConvertAddress( aScPos, rXclPos, GetCurrScTab(), true ) )
     106             :     {
     107             :         // Formula will be read next, length in nFormLen
     108        4858 :         const ScTokenArray* pResult = NULL;
     109        4858 :         bool bConvert = false;
     110             : 
     111        4858 :         pFormConv->Reset( aScPos );
     112             : 
     113        4858 :         if( bShrFmla )
     114         656 :             bConvert = !pFormConv->GetShrFmla( pResult, maStrm, nFormLen );
     115             :         else
     116        4202 :             bConvert = true;
     117             : 
     118        4858 :         if( bConvert )
     119        4698 :             eErr = pFormConv->Convert( pResult, maStrm, nFormLen, true, FT_CellFormula);
     120             : 
     121        4858 :         ScFormulaCell* pCell = NULL;
     122             : 
     123        4858 :         if (pResult)
     124             :         {
     125        4826 :             pCell = new ScFormulaCell( pD, aScPos, pResult );
     126        4826 :             pD->PutCell( aScPos.Col(), aScPos.Row(), aScPos.Tab(), pCell, true );
     127             :         }
     128             :         else
     129             :         {
     130             :             CellType        eCellType;
     131             :             ScBaseCell*     pBaseCell;
     132          32 :             pD->GetCellType( aScPos.Col(), aScPos.Row(), aScPos.Tab(), eCellType );
     133          32 :             if( eCellType == CELLTYPE_FORMULA )
     134             :             {
     135          32 :                 pD->GetCell( aScPos.Col(), aScPos.Row(), aScPos.Tab(), pBaseCell );
     136          32 :                 pCell = ( ScFormulaCell* ) pBaseCell;
     137          32 :                 if( pCell )
     138          32 :                     pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE );
     139             :             }
     140             :         }
     141             : 
     142        4858 :         if (pCell)
     143             :         {
     144        4858 :             if( eErr != ConvOK )
     145           2 :                 ExcelToSc::SetError( *pCell, eErr );
     146             : 
     147        4858 :             if (!rtl::math::isNan(fCurVal))
     148        4850 :                 pCell->SetResultDouble(fCurVal);
     149             :         }
     150             : 
     151        4858 :         GetXFRangeBuffer().SetXF( aScPos, nXF );
     152             :     }
     153        4858 : }
     154             : 
     155             : 
     156             : 
     157             : 
     158          88 : ExcelToSc::ExcelToSc( const XclImpRoot& rRoot ) :
     159             :     ExcelConverterBase( 512 ),
     160             :     XclImpRoot( rRoot ),
     161             :     maFuncProv( rRoot ),
     162          88 :     meBiff( rRoot.GetBiff() )
     163             : {
     164          88 : }
     165             : 
     166         132 : ExcelToSc::~ExcelToSc()
     167             : {
     168         132 : }
     169             : 
     170           0 : void ExcelToSc::GetDummy( const ScTokenArray*& pErgebnis )
     171             : {
     172           0 :     aPool.Store( CREATE_STRING( "Dummy()" ) );
     173           0 :     aPool >> aStack;
     174           0 :     pErgebnis = aPool[ aStack.Get() ];
     175           0 : }
     176             : 
     177             : 
     178             : // if bAllowArrays is false stream seeks to first byte after <nFormulaLen>
     179             : // otherwise it will seek to the first byte after the additional content (eg
     180             : // inline arrays) following <nFormulaLen>
     181           0 : ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, sal_Size nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT )
     182             : {
     183           0 :     RootData&       rR = GetOldRoot();
     184             :     sal_uInt8           nOp, nLen, nByte;
     185             :     sal_uInt16          nUINT16;
     186             :     sal_Int16           nINT16;
     187             :     double          fDouble;
     188           0 :     String          aString;
     189           0 :     sal_Bool            bError = false;
     190           0 :     sal_Bool            bArrayFormula = false;
     191           0 :     TokenId         nMerk0;
     192           0 :     const sal_Bool      bRangeName = eFT == FT_RangeName;
     193           0 :     const sal_Bool      bSharedFormula = eFT == FT_SharedFormula;
     194           0 :     const sal_Bool      bRNorSF = bRangeName || bSharedFormula;
     195             : 
     196             :     ScSingleRefData     aSRD;
     197             :     ScComplexRefData        aCRD;
     198           0 :     ExtensionTypeVec    aExtensions;
     199             : 
     200           0 :     bExternName = false;
     201             : 
     202           0 :     if( eStatus != ConvOK )
     203             :     {
     204           0 :         aIn.Ignore( nFormulaLen );
     205           0 :         return eStatus;
     206             :     }
     207             : 
     208           0 :     if( nFormulaLen == 0 )
     209             :     {
     210           0 :         aPool.Store( CREATE_STRING( "-/-" ) );
     211           0 :         aPool >> aStack;
     212           0 :         pErgebnis = aPool[ aStack.Get() ];
     213           0 :         return ConvOK;
     214             :     }
     215             : 
     216           0 :     sal_Size nEndPos = aIn.GetRecPos() + nFormulaLen;
     217             : 
     218           0 :     while( (aIn.GetRecPos() < nEndPos) && !bError )
     219             :     {
     220           0 :         aIn >> nOp;
     221             : 
     222             :         // always reset flags
     223           0 :         aSRD.InitFlags();
     224           0 :         aCRD.InitFlags();
     225             : 
     226           0 :         switch( nOp )   //                              book page:
     227             :         {           //                                      SDK4 SDK5
     228             :             case 0x01: // Array Formula                         [325    ]
     229             :                        // Array Formula or Shared Formula       [    277]
     230             :             case 0x02: // Data Table                            [325 277]
     231           0 :                 nUINT16 = 3;
     232             : 
     233           0 :                 if( meBiff != EXC_BIFF2 )
     234           0 :                     nUINT16++;
     235             : 
     236           0 :                 aIn.Ignore( nUINT16 );
     237             : 
     238           0 :                 bArrayFormula = sal_True;
     239           0 :                 break;
     240             :             case 0x03: // Addition                              [312 264]
     241           0 :                 aStack >> nMerk0;
     242           0 :                 aPool <<  aStack << ocAdd << nMerk0;
     243           0 :                 aPool >> aStack;
     244           0 :                 break;
     245             :             case 0x04: // Subtraction                           [313 264]
     246             :                 // SECOND-TOP minus TOP
     247           0 :                 aStack >> nMerk0;
     248           0 :                 aPool << aStack << ocSub << nMerk0;
     249           0 :                 aPool >> aStack;
     250           0 :                 break;
     251             :             case 0x05: // Multiplication                        [313 264]
     252           0 :                 aStack >> nMerk0;
     253           0 :                 aPool << aStack << ocMul << nMerk0;
     254           0 :                 aPool >> aStack;
     255           0 :                 break;
     256             :             case 0x06: // Division                              [313 264]
     257             :                 // divide TOP by SECOND-TOP
     258           0 :                 aStack >> nMerk0;
     259           0 :                 aPool << aStack << ocDiv << nMerk0;
     260           0 :                 aPool >> aStack;
     261           0 :                 break;
     262             :             case 0x07: // Exponentiation                            [313 265]
     263             :                 // raise SECOND-TOP to power of TOP
     264           0 :                 aStack >> nMerk0;
     265           0 :                 aPool << aStack << ocPow << nMerk0;
     266           0 :                 aPool >> aStack;
     267           0 :                 break;
     268             :             case 0x08: // Concatenation                         [313 265]
     269             :                 // append TOP to SECOND-TOP
     270           0 :                 aStack >> nMerk0;
     271           0 :                 aPool << aStack << ocAmpersand << nMerk0;
     272           0 :                 aPool >> aStack;
     273           0 :                 break;
     274             :             case 0x09: // Less Than                             [313 265]
     275             :                 // SECOND-TOP < TOP
     276           0 :                 aStack >> nMerk0;
     277           0 :                 aPool << aStack << ocLess << nMerk0;
     278           0 :                 aPool >> aStack;
     279           0 :                 break;
     280             :             case 0x0A: // Less Than or Equal                    [313 265]
     281             :                 // SECOND-TOP <= TOP
     282           0 :                 aStack >> nMerk0;
     283           0 :                 aPool << aStack << ocLessEqual << nMerk0;
     284           0 :                 aPool >> aStack;
     285           0 :                 break;
     286             :             case 0x0B: // Equal                                 [313 265]
     287             :                 // SECOND-TOP == TOP
     288           0 :                 aStack >> nMerk0;
     289           0 :                 aPool << aStack << ocEqual << nMerk0;
     290           0 :                 aPool >> aStack;
     291           0 :                 break;
     292             :             case 0x0C: // Greater Than or Equal                 [313 265]
     293             :                 // SECOND-TOP >= TOP
     294           0 :                 aStack >> nMerk0;
     295           0 :                 aPool << aStack << ocGreaterEqual << nMerk0;
     296           0 :                 aPool >> aStack;
     297           0 :                 break;
     298             :             case 0x0D: // Greater Than                          [313 265]
     299             :                 // SECOND-TOP > TOP
     300           0 :                 aStack >> nMerk0;
     301           0 :                 aPool << aStack << ocGreater << nMerk0;
     302           0 :                 aPool >> aStack;
     303           0 :                 break;
     304             :             case 0x0E: // Not Equal                             [313 265]
     305             :                 // SECOND-TOP != TOP
     306           0 :                 aStack >> nMerk0;
     307           0 :                 aPool << aStack << ocNotEqual << nMerk0;
     308           0 :                 aPool >> aStack;
     309           0 :                 break;
     310             :             case 0x0F: // Intersection                          [314 265]
     311           0 :                 aStack >> nMerk0;
     312           0 :                 aPool << aStack << ocIntersect << nMerk0;
     313           0 :                 aPool >> aStack;
     314           0 :                 break;
     315             :             case 0x10: // Union                                 [314 265]
     316             :                 // ocSep instead of 'ocUnion'
     317           0 :                 aStack >> nMerk0;
     318           0 :                 aPool << aStack << ocSep << nMerk0;
     319             :                     // doesn't fit exactly, but is more Excel-like
     320           0 :                 aPool >> aStack;
     321           0 :                 break;
     322             :             case 0x11: // Range                                 [314 265]
     323           0 :                 aStack >> nMerk0;
     324           0 :                 aPool << aStack << ocRange << nMerk0;
     325           0 :                 aPool >> aStack;
     326           0 :                 break;
     327             :             case 0x12: // Unary Plus                            [312 264]
     328           0 :                 aPool << ocAdd << aStack;
     329           0 :                 aPool >> aStack;
     330           0 :                 break;
     331             :             case 0x13: // Unary Minus                           [312 264]
     332           0 :                 aPool << ocNegSub << aStack;
     333           0 :                 aPool >> aStack;
     334           0 :                 break;
     335             :             case 0x14: // Percent Sign                          [312 264]
     336           0 :                 aPool << aStack << ocPercentSign;
     337           0 :                 aPool >> aStack;
     338           0 :                 break;
     339             :             case 0x15: // Parenthesis                           [326 278]
     340           0 :                 aPool << ocOpen << aStack << ocClose;
     341           0 :                 aPool >> aStack;
     342           0 :                 break;
     343             :             case 0x16: // Missing Argument                      [314 266]
     344           0 :                 aPool << ocMissing;
     345           0 :                 aPool >> aStack;
     346           0 :                 GetTracer().TraceFormulaMissingArg();
     347           0 :                 break;
     348             :             case 0x17: // String Constant                       [314 266]
     349           0 :                 aIn >> nLen;
     350           0 :                 aString = aIn.ReadRawByteString( nLen );
     351             : 
     352           0 :                 aStack << aPool.Store( aString );
     353           0 :                 break;
     354             :             case 0x19: // Special Attribute                     [327 279]
     355             :             {
     356             :                 sal_uInt16  nData, nFakt;
     357             :                 sal_uInt8   nOpt;
     358             : 
     359           0 :                 aIn >> nOpt;
     360             : 
     361           0 :                 if( meBiff == EXC_BIFF2 )
     362             :                 {
     363           0 :                     nData = aIn.ReaduInt8();
     364           0 :                     nFakt = 1;
     365             :                 }
     366             :                 else
     367             :                 {
     368           0 :                     aIn >> nData;
     369           0 :                     nFakt = 2;
     370             :                 }
     371             : 
     372           0 :                 if( nOpt & 0x04 )
     373             :                 {// nFakt -> skip bytes or words    AttrChoose
     374           0 :                     nData++;
     375           0 :                     aIn.Ignore( nData * nFakt );
     376             :                 }
     377           0 :                 else if( nOpt & 0x10 )                      // AttrSum
     378           0 :                     DoMulArgs( ocSum, 1 );
     379             :             }
     380           0 :                 break;
     381             :             case 0x1A: // External Reference                    [330    ]
     382           0 :                 switch( meBiff )
     383             :                 {
     384           0 :                     case EXC_BIFF2: aIn.Ignore( 7 );    break;
     385             :                     case EXC_BIFF3:
     386           0 :                     case EXC_BIFF4: aIn.Ignore( 10 );   break;
     387             :                     case EXC_BIFF5:
     388             :                         DBG_WARNING( "-ExcelToSc::Convert(): 0x1A does not exist in Biff5!" );
     389             :                     default:
     390             :                         DBG_WARNING( "-ExcelToSc::Convert(): A little oblivious?" );
     391             :                 }
     392           0 :                 break;
     393             :             case 0x1B: // End External Reference                [330    ]
     394           0 :                 switch( meBiff )
     395             :                 {
     396           0 :                     case EXC_BIFF2: aIn.Ignore( 3 );    break;
     397             :                     case EXC_BIFF3:
     398           0 :                     case EXC_BIFF4: aIn.Ignore( 4 );    break;
     399             :                     case EXC_BIFF5:
     400             :                         DBG_WARNING( "-ExcelToSc::Convert(): 0x1B does not exist in Biff5!" );
     401             :                     default:
     402             :                         DBG_WARNING( "-ExcelToSc::Convert(): A little oblivious?" );
     403             :                 }
     404           0 :                 break;
     405             :             case 0x1C: // Error Value                           [314 266]
     406             :             {
     407           0 :                 aIn >> nByte;
     408             :                 DefTokenId          eOc;
     409           0 :                 switch( nByte )
     410             :                 {
     411             :                     case EXC_ERR_NULL:
     412             :                     case EXC_ERR_DIV0:
     413             :                     case EXC_ERR_VALUE:
     414             :                     case EXC_ERR_REF:
     415             :                     case EXC_ERR_NAME:
     416           0 :                     case EXC_ERR_NUM:   eOc = ocStop;       break;
     417           0 :                     case EXC_ERR_NA:    eOc = ocNotAvail;   break;
     418           0 :                     default:            eOc = ocNoName;
     419             :                 }
     420           0 :                 aPool << eOc;
     421           0 :                 if( eOc != ocStop )
     422           0 :                     aPool << ocOpen << ocClose;
     423           0 :                 aPool >> aStack;
     424             :             }
     425           0 :                 break;
     426             :             case 0x1D: // Boolean                               [315 266]
     427           0 :                 aIn >> nByte;
     428           0 :                 if( nByte == 0 )
     429           0 :                     aPool << ocFalse << ocOpen << ocClose;
     430             :                 else
     431           0 :                     aPool << ocTrue << ocOpen << ocClose;
     432           0 :                 aPool >> aStack;
     433           0 :                 break;
     434             :             case 0x1E: // Integer                               [315 266]
     435           0 :                 aIn >> nUINT16;
     436           0 :                 aStack << aPool.Store( ( double ) nUINT16 );
     437           0 :                 break;
     438             :             case 0x1F: // Number                                [315 266]
     439           0 :                 aIn >> fDouble;
     440           0 :                 aStack << aPool.Store( fDouble );
     441           0 :                 break;
     442             :             case 0x40:
     443             :             case 0x60:
     444             :             case 0x20: // Array Constant                        [317 268]
     445           0 :                 aIn >> nByte >> nUINT16;
     446           0 :                 aIn.Ignore( (meBiff == EXC_BIFF2) ? 3 : 4 );
     447           0 :                 if( bAllowArrays )
     448             :                 {
     449           0 :                     aStack << aPool.StoreMatrix();
     450           0 :                     aExtensions.push_back( EXTENSION_ARRAY );
     451             :                 }
     452             :                 else
     453             :                 {
     454           0 :                     aPool << ocBad;
     455           0 :                     aPool >> aStack;
     456             :                 }
     457           0 :                 break;
     458             :             case 0x41:
     459             :             case 0x61:
     460             :             case 0x21: // Function, Fixed Number of Arguments   [333 282]
     461             :             {
     462             :                 sal_uInt16 nXclFunc;
     463           0 :                 if( meBiff <= EXC_BIFF3 )
     464           0 :                     nXclFunc = aIn.ReaduInt8();
     465             :                 else
     466           0 :                     aIn >> nXclFunc;
     467           0 :                 if( const XclFunctionInfo* pFuncInfo = maFuncProv.GetFuncInfoFromXclFunc( nXclFunc ) )
     468           0 :                     DoMulArgs( pFuncInfo->meOpCode, pFuncInfo->mnMaxParamCount );
     469             :                 else
     470           0 :                     DoMulArgs( ocNoName, 0 );
     471             :             }
     472           0 :             break;
     473             :             case 0x42:
     474             :             case 0x62:
     475             :             case 0x22: // Function, Variable Number of Arg.     [333 283]
     476             :             {
     477             :                 sal_uInt16 nXclFunc;
     478             :                 sal_uInt8 nParamCount;
     479           0 :                 aIn >> nParamCount;
     480           0 :                 nParamCount &= 0x7F;
     481           0 :                 if( meBiff <= EXC_BIFF3 )
     482           0 :                     nXclFunc = aIn.ReaduInt8();
     483             :                 else
     484           0 :                     aIn >> nXclFunc;
     485           0 :                 if( const XclFunctionInfo* pFuncInfo = maFuncProv.GetFuncInfoFromXclFunc( nXclFunc ) )
     486           0 :                     DoMulArgs( pFuncInfo->meOpCode, nParamCount );
     487             :                 else
     488           0 :                     DoMulArgs( ocNoName, 0 );
     489             :             }
     490           0 :             break;
     491             :             case 0x43:
     492             :             case 0x63:
     493             :             case 0x23: // Name                                  [318 269]
     494             :             {
     495           0 :                 aIn >> nUINT16;
     496           0 :                 switch( meBiff )
     497             :                 {
     498           0 :                     case EXC_BIFF2: aIn.Ignore( 5 );    break;
     499             :                     case EXC_BIFF3:
     500           0 :                     case EXC_BIFF4: aIn.Ignore( 8 );    break;
     501           0 :                     case EXC_BIFF5: aIn.Ignore( 12 );   break;
     502             :                     default:
     503             :                         OSL_FAIL(
     504             :                         "-ExcelToSc::Convert(): A little oblivious?" );
     505             :                 }
     506           0 :                 const XclImpName* pName = GetNameManager().GetName( nUINT16 );
     507           0 :                 if(pName && !pName->GetScRangeData())
     508           0 :                     aStack << aPool.Store( ocMacro, pName->GetXclName() );
     509             :                 else
     510           0 :                     aStack << aPool.StoreName(nUINT16, true);
     511             :             }
     512           0 :                 break;
     513             :             case 0x44:
     514             :             case 0x64:
     515             :             case 0x24: // Cell Reference                        [319 270]
     516             :             case 0x4A:
     517             :             case 0x6A:
     518             :             case 0x2A: // Deleted Cell Reference                [323 273]
     519           0 :                 aIn >> nUINT16 >> nByte;
     520           0 :                 aSRD.nCol = static_cast<SCsCOL>(nByte);
     521           0 :                 aSRD.nRow = nUINT16 & 0x3FFF;
     522           0 :                 aSRD.nRelTab = 0;
     523           0 :                 aSRD.SetTabRel( sal_True );
     524           0 :                 aSRD.SetFlag3D( bRangeName );
     525             : 
     526           0 :                 ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName );
     527             : 
     528           0 :                 switch ( nOp )
     529             :                 {
     530             :                     case 0x4A:
     531             :                     case 0x6A:
     532             :                     case 0x2A: // Deleted Cell Reference        [323 273]
     533             :                         // no information which part is deleted, set both
     534           0 :                         aSRD.SetColDeleted( sal_True );
     535           0 :                         aSRD.SetRowDeleted( sal_True );
     536             :                 }
     537             : 
     538           0 :                 aStack << aPool.Store( aSRD );
     539           0 :                 break;
     540             :             case 0x45:
     541             :             case 0x65:
     542             :             case 0x25: // Area Reference                        [320 270]
     543             :             case 0x4B:
     544             :             case 0x6B:
     545             :             case 0x2B: // Deleted Area Refernce                 [323 273]
     546             :             {
     547             :                 sal_uInt16          nRowFirst, nRowLast;
     548             :                 sal_uInt8           nColFirst, nColLast;
     549           0 :                 ScSingleRefData&    rSRef1 = aCRD.Ref1;
     550           0 :                 ScSingleRefData&    rSRef2 = aCRD.Ref2;
     551             : 
     552           0 :                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
     553             : 
     554           0 :                 rSRef1.nRelTab = rSRef2.nRelTab = 0;
     555           0 :                 rSRef1.SetTabRel( sal_True );
     556           0 :                 rSRef2.SetTabRel( sal_True );
     557           0 :                 rSRef1.SetFlag3D( bRangeName );
     558           0 :                 rSRef2.SetFlag3D( bRangeName );
     559             : 
     560           0 :                 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
     561           0 :                 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
     562             : 
     563           0 :                 if( IsComplColRange( nColFirst, nColLast ) )
     564           0 :                     SetComplCol( aCRD );
     565           0 :                 else if( IsComplRowRange( nRowFirst, nRowLast ) )
     566           0 :                     SetComplRow( aCRD );
     567             : 
     568           0 :                 switch ( nOp )
     569             :                 {
     570             :                     case 0x4B:
     571             :                     case 0x6B:
     572             :                     case 0x2B: // Deleted Area Refernce         [323 273]
     573             :                         // no information which part is deleted, set all
     574           0 :                         rSRef1.SetColDeleted( sal_True );
     575           0 :                         rSRef1.SetRowDeleted( sal_True );
     576           0 :                         rSRef2.SetColDeleted( sal_True );
     577           0 :                         rSRef2.SetRowDeleted( sal_True );
     578             :                 }
     579             : 
     580           0 :                 aStack << aPool.Store( aCRD );
     581             :             }
     582           0 :                 break;
     583             :             case 0x46:
     584             :             case 0x66:
     585             :             case 0x26: // Constant Reference Subexpression      [321 271]
     586           0 :                 aExtensions.push_back( EXTENSION_MEMAREA );
     587             :                 // fall through
     588             : 
     589             :             case 0x47:
     590             :             case 0x67:
     591             :             case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
     592             :             case 0x48:
     593             :             case 0x68:
     594             :             case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
     595           0 :                 aIn.Ignore( (meBiff == EXC_BIFF2) ? 4 : 6 );
     596           0 :                 break;
     597             :             case 0x4C:
     598             :             case 0x6C:
     599             :             case 0x2C: // Cell Reference Within a Name          [323    ]
     600             :                        // Cell Reference Within a Shared Formula[    273]
     601             :             {
     602           0 :                 aIn >> nUINT16 >> nByte;    // >> Attribute, Row >> Col
     603             : 
     604           0 :                 aSRD.nRelTab = 0;
     605           0 :                 aSRD.SetTabRel( sal_True );
     606           0 :                 aSRD.SetFlag3D( bRangeName );
     607             : 
     608           0 :                 ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF );
     609             : 
     610           0 :                 aStack << aPool.Store( aSRD );
     611             :             }
     612           0 :                 break;
     613             :             case 0x4D:
     614             :             case 0x6D:
     615             :             case 0x2D: // Area Reference Within a Name          [324    ]
     616             :             {      // Area Reference Within a Shared Formula[    274]
     617             :                 sal_uInt16                  nRowFirst, nRowLast;
     618             :                 sal_uInt8                   nColFirst, nColLast;
     619             : 
     620           0 :                 aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
     621           0 :                 aCRD.Ref1.SetTabRel( sal_True );
     622           0 :                 aCRD.Ref2.SetTabRel( sal_True );
     623           0 :                 aCRD.Ref1.SetFlag3D( bRangeName );
     624           0 :                 aCRD.Ref2.SetFlag3D( bRangeName );
     625             : 
     626           0 :                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
     627             : 
     628           0 :                 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRNorSF );
     629           0 :                 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRNorSF );
     630             : 
     631           0 :                 if( IsComplColRange( nColFirst, nColLast ) )
     632           0 :                     SetComplCol( aCRD );
     633           0 :                 else if( IsComplRowRange( nRowFirst, nRowLast ) )
     634           0 :                     SetComplRow( aCRD );
     635             : 
     636           0 :                 aStack << aPool.Store( aCRD );
     637             :             }
     638           0 :                 break;
     639             :             case 0x49:
     640             :             case 0x69:
     641             :             case 0x29: // Variable Reference Subexpression      [331 281]
     642             :             case 0x4E:
     643             :             case 0x6E:
     644             :             case 0x2E: // Reference Subexpression Within a Name [332 282]
     645             :             case 0x4F:
     646             :             case 0x6F:
     647             :             case 0x2F: // Incomplete Reference Subexpression... [332 282]
     648           0 :                 aIn.Ignore( (meBiff == EXC_BIFF2) ? 1 : 2 );
     649           0 :                 break;
     650             :             case 0x58:
     651             :             case 0x78:
     652             :             case 0x38: // Command-Equivalent Function           [333    ]
     653           0 :                 aString.AssignAscii( "COMM_EQU_FUNC" );
     654           0 :                 aIn >> nByte;
     655           0 :                 aString += String::CreateFromInt32( nByte );
     656           0 :                 aIn >> nByte;
     657           0 :                 aStack << aPool.Store( aString );
     658           0 :                 DoMulArgs( ocPush, nByte + 1 );
     659           0 :                 break;
     660             :             case 0x59:
     661             :             case 0x79:
     662             :             case 0x39: // Name or External Name                 [    275]
     663           0 :                 aIn >> nINT16;
     664           0 :                 aIn.Ignore( 8 );
     665           0 :                 aIn >> nUINT16;
     666           0 :                 if( nINT16 >= 0 )
     667             :                 {
     668           0 :                     const ExtName* pExtName = rR.pExtNameBuff->GetNameByIndex( nINT16, nUINT16 );
     669           0 :                     if( pExtName && pExtName->IsDDE() &&
     670           0 :                         rR.pExtSheetBuff->IsLink( ( sal_uInt16 ) nINT16 ) )
     671             :                     {
     672           0 :                         String          aAppl, aExtDoc;
     673           0 :                         TokenId         nPar1, nPar2;
     674             : 
     675           0 :                         rR.pExtSheetBuff->GetLink( ( sal_uInt16 ) nINT16 , aAppl, aExtDoc );
     676           0 :                         nPar1 = aPool.Store( aAppl );
     677           0 :                         nPar2 = aPool.Store( aExtDoc );
     678           0 :                         nMerk0 = aPool.Store( pExtName->aName );
     679           0 :                         aPool   << ocDde << ocOpen << nPar1 << ocSep << nPar2 << ocSep
     680           0 :                                 << nMerk0 << ocClose;
     681             : 
     682           0 :                         GetDoc().CreateDdeLink( aAppl, aExtDoc, pExtName->aName, SC_DDE_DEFAULT, ScMatrixRef() );
     683             :                     }
     684             :                     else
     685           0 :                         aPool << ocBad;
     686             : 
     687           0 :                     aPool >> aStack;
     688             :                 }
     689             :                 else
     690           0 :                     aStack << aPool.StoreName( nUINT16, true );
     691           0 :                 aIn.Ignore( 12 );
     692           0 :                 break;
     693             :             case 0x5A:
     694             :             case 0x7A:
     695             :             case 0x3A: // 3-D Cell Reference                    [    275]
     696             :             case 0x5C:
     697             :             case 0x7C:
     698             :             case 0x3C: // Deleted 3-D Cell Reference            [    277]
     699             :             {
     700             :                 sal_uInt16          nTabFirst, nTabLast, nRow;
     701             :                 sal_Int16           nExtSheet;
     702             :                 sal_uInt8           nCol;
     703             : 
     704           0 :                 aIn >> nExtSheet;
     705           0 :                 aIn.Ignore( 8 );
     706           0 :                 aIn >> nTabFirst >> nTabLast >> nRow >> nCol;
     707             : 
     708           0 :                 if( nExtSheet >= 0 )
     709             :                 {   // from external
     710           0 :                     if( rR.pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
     711             :                     {
     712           0 :                         nTabFirst = nTabLast;
     713           0 :                         nExtSheet = 0;      // found
     714             :                     }
     715             :                     else
     716             :                     {
     717           0 :                         aPool << ocBad;
     718           0 :                         aPool >> aStack;
     719           0 :                         nExtSheet = 1;      // don't create a SingleRef
     720             :                     }
     721             :                 }
     722             : 
     723           0 :                 if( nExtSheet <= 0 )
     724             :                 {   // in current Workbook
     725           0 :                     aSRD.nTab = static_cast<SCTAB>(nTabFirst);
     726           0 :                     aSRD.SetFlag3D( sal_True );
     727           0 :                     aSRD.SetTabRel( false );
     728             : 
     729           0 :                     ExcRelToScRel( nRow, nCol, aSRD, bRangeName );
     730             : 
     731           0 :                     switch ( nOp )
     732             :                     {
     733             :                         case 0x5C:
     734             :                         case 0x7C:
     735             :                         case 0x3C: // Deleted 3-D Cell Reference    [    277]
     736             :                             // no information which part is deleted, set both
     737           0 :                             aSRD.SetColDeleted( sal_True );
     738           0 :                             aSRD.SetRowDeleted( sal_True );
     739             :                     }
     740           0 :                     if ( !ValidTab(static_cast<SCTAB>(nTabFirst)) )
     741           0 :                         aSRD.SetTabDeleted( sal_True );
     742             : 
     743           0 :                     if( nTabLast != nTabFirst )
     744             :                     {
     745           0 :                         aCRD.Ref1 = aCRD.Ref2 = aSRD;
     746           0 :                         aCRD.Ref2.nTab = static_cast<SCTAB>(nTabLast);
     747           0 :                         aCRD.Ref2.SetTabDeleted( !ValidTab(static_cast<SCTAB>(nTabLast)) );
     748           0 :                         aStack << aPool.Store( aCRD );
     749             :                     }
     750             :                     else
     751           0 :                         aStack << aPool.Store( aSRD );
     752             :                 }
     753             :             }
     754             : 
     755           0 :                 break;
     756             :             case 0x5B:
     757             :             case 0x7B:
     758             :             case 0x3B: // 3-D Area Reference                    [    276]
     759             :             case 0x5D:
     760             :             case 0x7D:
     761             :             case 0x3D: // Deleted 3-D Area Reference            [    277]
     762             :             {
     763             :                 sal_uInt16      nTabFirst, nTabLast, nRowFirst, nRowLast;
     764             :                 sal_Int16       nExtSheet;
     765             :                 sal_uInt8       nColFirst, nColLast;
     766             : 
     767           0 :                 aIn >> nExtSheet;
     768           0 :                 aIn.Ignore( 8 );
     769           0 :                 aIn >> nTabFirst >> nTabLast >> nRowFirst >> nRowLast
     770           0 :                     >> nColFirst >> nColLast;
     771             : 
     772           0 :                 if( nExtSheet >= 0 )
     773             :                     // von extern
     774             :                 {
     775           0 :                     if( rR.pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
     776             :                     {
     777           0 :                         nTabFirst = nTabLast;
     778           0 :                         nExtSheet = 0;      // found
     779             :                     }
     780             :                     else
     781             :                     {
     782           0 :                         aPool << ocBad;
     783           0 :                         aPool >> aStack;
     784           0 :                         nExtSheet = 1;      // don't create a CompleteRef
     785             :                     }
     786             :                 }
     787             : 
     788           0 :                 if( nExtSheet <= 0 )
     789             :                 {// in current Workbook
     790             :                     // first part of range
     791           0 :                     ScSingleRefData&    rR1 = aCRD.Ref1;
     792           0 :                     ScSingleRefData&    rR2 = aCRD.Ref2;
     793             : 
     794           0 :                     rR1.nTab = static_cast<SCTAB>(nTabFirst);
     795           0 :                     rR2.nTab = static_cast<SCTAB>(nTabLast);
     796           0 :                     rR1.SetFlag3D( sal_True );
     797           0 :                     rR1.SetTabRel( false );
     798           0 :                     rR2.SetFlag3D( nTabFirst != nTabLast );
     799           0 :                     rR2.SetTabRel( false );
     800             : 
     801           0 :                     ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
     802           0 :                     ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
     803             : 
     804           0 :                     if( IsComplColRange( nColFirst, nColLast ) )
     805           0 :                         SetComplCol( aCRD );
     806           0 :                     else if( IsComplRowRange( nRowFirst, nRowLast ) )
     807           0 :                         SetComplRow( aCRD );
     808             : 
     809           0 :                     switch ( nOp )
     810             :                     {
     811             :                         case 0x5D:
     812             :                         case 0x7D:
     813             :                         case 0x3D: // Deleted 3-D Area Reference    [    277]
     814             :                                // no information which part is deleted, set all
     815           0 :                             rR1.SetColDeleted( sal_True );
     816           0 :                             rR1.SetRowDeleted( sal_True );
     817           0 :                             rR2.SetColDeleted( sal_True );
     818           0 :                             rR2.SetRowDeleted( sal_True );
     819             :                     }
     820           0 :                     if ( !ValidTab(static_cast<SCTAB>(nTabFirst)) )
     821           0 :                         rR1.SetTabDeleted( sal_True );
     822           0 :                     if ( !ValidTab(static_cast<SCTAB>(nTabLast)) )
     823           0 :                         rR2.SetTabDeleted( sal_True );
     824             : 
     825           0 :                     aStack << aPool.Store( aCRD );
     826             :                 }//END in current Workbook
     827             :             }
     828           0 :                 break;
     829           0 :             default: bError = sal_True;
     830             :         }
     831           0 :         bError |= !aIn.IsValid();
     832             :     }
     833             : 
     834             :     ConvErr eRet;
     835             : 
     836           0 :     if( bError )
     837             :     {
     838           0 :         aPool << ocBad;
     839           0 :         aPool >> aStack;
     840           0 :         pErgebnis = aPool[ aStack.Get() ];
     841           0 :         eRet = ConvErrNi;
     842             :     }
     843           0 :     else if( aIn.GetRecPos() != nEndPos )
     844             :     {
     845           0 :         aPool << ocBad;
     846           0 :         aPool >> aStack;
     847           0 :         pErgebnis = aPool[ aStack.Get() ];
     848           0 :         eRet = ConvErrCount;
     849             :     }
     850           0 :     else if( bExternName )
     851             :     {
     852           0 :         pErgebnis = aPool[ aStack.Get() ];
     853           0 :         eRet = ConvErrExternal;
     854             :     }
     855           0 :     else if( bArrayFormula )
     856             :     {
     857           0 :         pErgebnis = NULL;
     858           0 :         eRet = ConvOK;
     859             :     }
     860             :     else
     861             :     {
     862           0 :         pErgebnis = aPool[ aStack.Get() ];
     863           0 :         eRet = ConvOK;
     864             :     }
     865             : 
     866           0 :     aIn.Seek( nEndPos );
     867             : 
     868           0 :     if( eRet == ConvOK )
     869           0 :         ReadExtensions( aExtensions, aIn );
     870             : 
     871           0 :     return eRet;
     872             : }
     873             : 
     874             : 
     875             : // stream seeks to first byte after <nFormulaLen>
     876           0 : ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal_Size nFormulaLen,
     877             :                             SCsTAB nTab, const FORMULA_TYPE eFT )
     878             : {
     879           0 :     RootData&       rR = GetOldRoot();
     880             :     sal_uInt8           nOp, nLen;
     881             :     sal_Size        nIgnore;
     882             :     sal_uInt16          nUINT16;
     883             :     sal_uInt8           nByte;
     884           0 :     sal_Bool            bError = false;
     885           0 :     const sal_Bool      bRangeName = eFT == FT_RangeName;
     886           0 :     const sal_Bool      bSharedFormula = eFT == FT_SharedFormula;
     887           0 :     const sal_Bool      bRNorSF = bRangeName || bSharedFormula;
     888             : 
     889             :     ScSingleRefData aSRD;
     890             :     ScComplexRefData    aCRD;
     891           0 :     aCRD.Ref1.nTab = aCRD.Ref2.nTab = aEingPos.Tab();
     892             : 
     893           0 :     bExternName = false;
     894             : 
     895           0 :     if( eStatus != ConvOK )
     896             :     {
     897           0 :         aIn.Ignore( nFormulaLen );
     898           0 :         return eStatus;
     899             :     }
     900             : 
     901           0 :     if( nFormulaLen == 0 )
     902           0 :         return ConvOK;
     903             : 
     904           0 :     sal_Size nEndPos = aIn.GetRecPos() + nFormulaLen;
     905             : 
     906           0 :     while( (aIn.GetRecPos() < nEndPos) && !bError )
     907             :     {
     908           0 :         aIn >> nOp;
     909           0 :         nIgnore = 0;
     910             : 
     911             :         // always reset flags
     912           0 :         aSRD.InitFlags();
     913           0 :         aCRD.InitFlags();
     914             : 
     915           0 :         switch( nOp )   //                              book page:
     916             :         {           //                                      SDK4 SDK5
     917             :             case 0x01: // Array Formula                         [325    ]
     918             :                        // Array Formula or Shared Formula       [    277]
     919           0 :                 nIgnore = (meBiff == EXC_BIFF2) ? 3 : 4;
     920           0 :                 break;
     921             :             case 0x02: // Data Table                            [325 277]
     922           0 :                 nIgnore = (meBiff == EXC_BIFF2) ? 3 : 4;
     923           0 :                 break;
     924             :             case 0x03: // Addition                              [312 264]
     925             :             case 0x04: // Subtraction                           [313 264]
     926             :             case 0x05: // Multiplication                        [313 264]
     927             :             case 0x06: // Division                              [313 264]
     928             :             case 0x07: // Exponetiation                         [313 265]
     929             :             case 0x08: // Concatenation                         [313 265]
     930             :             case 0x09: // Less Than                             [313 265]
     931             :             case 0x0A: // Less Than or Equal                    [313 265]
     932             :             case 0x0B: // Equal                                 [313 265]
     933             :             case 0x0C: // Greater Than or Equal                 [313 265]
     934             :             case 0x0D: // Greater Than                          [313 265]
     935             :             case 0x0E: // Not Equal                             [313 265]
     936             :             case 0x0F: // Intersection                          [314 265]
     937             :             case 0x10: // Union                                 [314 265]
     938             :             case 0x11: // Range                                 [314 265]
     939             :             case 0x12: // Unary Plus                            [312 264]
     940             :             case 0x13: // Unary Minus                           [312 264]
     941             :             case 0x14: // Percent Sign                          [312 264]
     942             :             case 0x15: // Parenthesis                           [326 278]
     943             :             case 0x16: // Missing Argument                      [314 266]
     944           0 :                 break;
     945             :             case 0x17: // String Constant                       [314 266]
     946           0 :                 aIn >> nLen;
     947           0 :                 nIgnore = nLen;
     948           0 :                 break;
     949             :             case 0x19: // Special Attribute                     [327 279]
     950             :             {
     951             :                 sal_uInt16 nData, nFakt;
     952             :                 sal_uInt8 nOpt;
     953             : 
     954           0 :                 aIn >> nOpt;
     955             : 
     956           0 :                 if( meBiff == EXC_BIFF2 )
     957             :                 {
     958           0 :                     nData = aIn.ReaduInt8();
     959           0 :                     nFakt = 1;
     960             :                 }
     961             :                 else
     962             :                 {
     963           0 :                     aIn >> nData;
     964           0 :                     nFakt = 2;
     965             :                 }
     966             : 
     967           0 :                 if( nOpt & 0x04 )
     968             :                 {// nFakt -> skip bytes or words    AttrChoose
     969           0 :                     nData++;
     970           0 :                     aIn.Ignore( nData * nFakt );
     971             :                 }
     972             :             }
     973           0 :                 break;
     974             :             case 0x1A: // External Reference                    [330    ]
     975           0 :                 switch( meBiff )
     976             :                 {
     977           0 :                     case EXC_BIFF2: nIgnore = 7;    break;
     978             :                     case EXC_BIFF3:
     979           0 :                     case EXC_BIFF4: nIgnore = 10;   break;
     980             :                     case EXC_BIFF5: DBG_WARNING( "-ExcelToSc::Convert(): 0x1A does not exist in Biff5!" );
     981             :                     default:        DBG_WARNING( "-ExcelToSc::Convert(): A little oblivious?" );
     982             :                 }
     983           0 :                 break;
     984             :             case 0x1B: // End External Reference                [330    ]
     985           0 :                 switch( meBiff )
     986             :                 {
     987           0 :                     case EXC_BIFF2: nIgnore = 3;        break;
     988             :                     case EXC_BIFF3:
     989           0 :                     case EXC_BIFF4: nIgnore = 4;        break;
     990             :                     case EXC_BIFF5: DBG_WARNING( "-ExcelToSc::Convert(): 0x1B does not exist in Biff5!" );
     991             :                     default:        DBG_WARNING( "-ExcelToSc::Convert(): A little oblivious?" );
     992             :                 }
     993           0 :                 break;
     994             :             case 0x1C: // Error Value                           [314 266]
     995             :             case 0x1D: // Boolean                               [315 266]
     996           0 :                 nIgnore = 1;
     997           0 :                 break;
     998             :             case 0x1E: // Integer                               [315 266]
     999           0 :                 nIgnore = 2;
    1000           0 :                 break;
    1001             :             case 0x1F: // Number                                [315 266]
    1002           0 :                 nIgnore = 8;
    1003           0 :                 break;
    1004             :             case 0x40:
    1005             :             case 0x60:
    1006             :             case 0x20: // Array Constant                        [317 268]
    1007           0 :                 nIgnore = (meBiff == EXC_BIFF2) ? 6 : 7;
    1008           0 :                 break;
    1009             :             case 0x41:
    1010             :             case 0x61:
    1011             :             case 0x21: // Function, Fixed Number of Arguments   [333 282]
    1012           0 :                 nIgnore = (meBiff <= EXC_BIFF3) ? 1 : 2;
    1013           0 :                 break;
    1014             :             case 0x42:
    1015             :             case 0x62:
    1016             :             case 0x22: // Function, Variable Number of Arg.     [333 283]
    1017           0 :                 nIgnore = (meBiff <= EXC_BIFF3) ? 2 : 3;
    1018           0 :                 break;
    1019             :             case 0x43:
    1020             :             case 0x63:
    1021             :             case 0x23: // Name                                  [318 269]
    1022           0 :                 switch( meBiff )
    1023             :                 {
    1024           0 :                     case EXC_BIFF2: nIgnore = 7;    break;
    1025             :                     case EXC_BIFF3:
    1026           0 :                     case EXC_BIFF4: nIgnore = 10;   break;
    1027           0 :                     case EXC_BIFF5: nIgnore = 14;   break;
    1028             :                     default:        OSL_FAIL( "-ExcelToSc::Convert(): A little oblivious?" );
    1029             :                 }
    1030           0 :                 break;
    1031             :             case 0x44:
    1032             :             case 0x64:
    1033             :             case 0x24: // Cell Reference                        [319 270]
    1034           0 :                 aIn >> nUINT16 >> nByte;
    1035           0 :                 aSRD.nCol = static_cast<SCsCOL>(nByte);
    1036           0 :                 aSRD.nRow = nUINT16 & 0x3FFF;
    1037           0 :                 aSRD.nRelTab = 0;
    1038           0 :                 aSRD.SetTabRel( sal_True );
    1039           0 :                 aSRD.SetFlag3D( bRangeName );
    1040             : 
    1041           0 :                 ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName );
    1042             : 
    1043           0 :                 rRangeList.Append( aSRD, nTab );
    1044           0 :                 break;
    1045             :             case 0x45:
    1046             :             case 0x65:
    1047             :             case 0x25: // Area Reference                        [320 270]
    1048             :             {
    1049             :                 sal_uInt16          nRowFirst, nRowLast;
    1050             :                 sal_uInt8           nColFirst, nColLast;
    1051           0 :                 ScSingleRefData &rSRef1 = aCRD.Ref1;
    1052           0 :                 ScSingleRefData &rSRef2 = aCRD.Ref2;
    1053             : 
    1054           0 :                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
    1055             : 
    1056           0 :                 rSRef1.nRelTab = rSRef2.nRelTab = 0;
    1057           0 :                 rSRef1.SetTabRel( sal_True );
    1058           0 :                 rSRef2.SetTabRel( sal_True );
    1059           0 :                 rSRef1.SetFlag3D( bRangeName );
    1060           0 :                 rSRef2.SetFlag3D( bRangeName );
    1061             : 
    1062           0 :                 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
    1063           0 :                 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
    1064             : 
    1065           0 :                 if( IsComplColRange( nColFirst, nColLast ) )
    1066           0 :                     SetComplCol( aCRD );
    1067           0 :                 else if( IsComplRowRange( nRowFirst, nRowLast ) )
    1068           0 :                     SetComplRow( aCRD );
    1069             : 
    1070           0 :                 rRangeList.Append( aCRD, nTab );
    1071             :             }
    1072           0 :                 break;
    1073             :             case 0x46:
    1074             :             case 0x66:
    1075             :             case 0x26: // Constant Reference Subexpression      [321 271]
    1076             :             case 0x47:
    1077             :             case 0x67:
    1078             :             case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
    1079             :             case 0x48:
    1080             :             case 0x68:
    1081             :             case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
    1082           0 :                 nIgnore = (meBiff == EXC_BIFF2) ? 4 : 6;
    1083           0 :                 break;
    1084             :             case 0x4A:
    1085             :             case 0x6A:
    1086             :             case 0x2A: // Deleted Cell Reference                [323 273]
    1087           0 :                 nIgnore = 3;
    1088           0 :                 break;
    1089             :             case 0x4B:
    1090             :             case 0x6B:
    1091             :             case 0x2B: // Deleted Area Refernce                 [323 273]
    1092           0 :                 nIgnore = 6;
    1093           0 :                 break;
    1094             :             case 0x4C:
    1095             :             case 0x6C:
    1096             :             case 0x2C: // Cell Reference Within a Name          [323    ]
    1097             :                        // Cell Reference Within a Shared Formula[    273]
    1098             :             {
    1099           0 :                 aIn >> nUINT16 >> nByte;    // >> Attribute, Row >> Col
    1100             : 
    1101           0 :                 aSRD.nRelTab = 0;
    1102           0 :                 aSRD.SetTabRel( sal_True );
    1103           0 :                 aSRD.SetFlag3D( bRangeName );
    1104             : 
    1105           0 :                 ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF );
    1106             : 
    1107           0 :                 rRangeList.Append( aSRD, nTab );
    1108             :             }
    1109           0 :                 break;
    1110             :             case 0x4D:
    1111             :             case 0x6D:
    1112             :             case 0x2D: // Area Reference Within a Name          [324    ]
    1113             :             {      // Area Reference Within a Shared Formula[    274]
    1114             :                 sal_uInt16                  nRowFirst, nRowLast;
    1115             :                 sal_uInt8                   nColFirst, nColLast;
    1116             : 
    1117           0 :                 aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
    1118           0 :                 aCRD.Ref1.SetTabRel( sal_True );
    1119           0 :                 aCRD.Ref2.SetTabRel( sal_True );
    1120           0 :                 aCRD.Ref1.SetFlag3D( bRangeName );
    1121           0 :                 aCRD.Ref2.SetFlag3D( bRangeName );
    1122             : 
    1123           0 :                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
    1124             : 
    1125           0 :                 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRNorSF );
    1126           0 :                 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRNorSF );
    1127             : 
    1128           0 :                 if( IsComplColRange( nColFirst, nColLast ) )
    1129           0 :                     SetComplCol( aCRD );
    1130           0 :                 else if( IsComplRowRange( nRowFirst, nRowLast ) )
    1131           0 :                     SetComplRow( aCRD );
    1132             : 
    1133           0 :                 rRangeList.Append( aCRD, nTab );
    1134             :             }
    1135           0 :                 break;
    1136             :             case 0x49:
    1137             :             case 0x69:
    1138             :             case 0x29: // Variable Reference Subexpression      [331 281]
    1139             :             case 0x4E:
    1140             :             case 0x6E:
    1141             :             case 0x2E: // Reference Subexpression Within a Name [332 282]
    1142             :             case 0x4F:
    1143             :             case 0x6F:
    1144             :             case 0x2F: // Incomplete Reference Subexpression... [332 282]
    1145           0 :                 nIgnore = (meBiff == EXC_BIFF2) ? 1 : 2;
    1146           0 :                 break;
    1147             :             case 0x58:
    1148             :             case 0x78:
    1149             :             case 0x38: // Command-Equivalent Function           [333    ]
    1150           0 :                 nIgnore = 2;
    1151           0 :                 break;
    1152             :             case 0x59:
    1153             :             case 0x79:
    1154             :             case 0x39: // Name or External Name                 [    275]
    1155           0 :                 nIgnore = 24;
    1156           0 :                 break;
    1157             :             case 0x5A:
    1158             :             case 0x7A:
    1159             :             case 0x3A: // 3-D Cell Reference                    [    275]
    1160             :             {
    1161             :                 sal_uInt16          nTabFirst, nTabLast, nRow;
    1162             :                 sal_Int16           nExtSheet;
    1163             :                 sal_uInt8           nCol;
    1164             : 
    1165           0 :                 aIn >> nExtSheet;
    1166           0 :                 aIn.Ignore( 8 );
    1167           0 :                 aIn >> nTabFirst >> nTabLast >> nRow >> nCol;
    1168             : 
    1169           0 :                 if( nExtSheet >= 0 )
    1170             :                     // from external
    1171             :                 {
    1172           0 :                     if( rR.pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
    1173             :                     {
    1174           0 :                         nTabFirst = nTabLast;
    1175           0 :                         nExtSheet = 0;      // found
    1176             :                     }
    1177             :                     else
    1178             :                     {
    1179           0 :                         aPool << ocBad;
    1180           0 :                         aPool >> aStack;
    1181           0 :                         nExtSheet = 1;      // don't create a SingleRef
    1182             :                     }
    1183             :                 }
    1184             : 
    1185           0 :                 if( nExtSheet <= 0 )
    1186             :                 {// in current Workbook
    1187           0 :                     sal_Bool b3D = ( static_cast<SCTAB>(nTabFirst) != aEingPos.Tab() ) || bRangeName;
    1188           0 :                     aSRD.nTab = static_cast<SCTAB>(nTabFirst);
    1189           0 :                     aSRD.SetFlag3D( b3D );
    1190           0 :                     aSRD.SetTabRel( false );
    1191             : 
    1192           0 :                     ExcRelToScRel( nRow, nCol, aSRD, bRangeName );
    1193             : 
    1194           0 :                     if( nTabLast != nTabFirst )
    1195             :                     {
    1196           0 :                         aCRD.Ref1 = aSRD;
    1197           0 :                         aCRD.Ref2.nCol = aSRD.nCol;
    1198           0 :                         aCRD.Ref2.nRow = aSRD.nRow;
    1199           0 :                         aCRD.Ref2.nTab = static_cast<SCTAB>(nTabLast);
    1200           0 :                         b3D = ( static_cast<SCTAB>(nTabLast) != aEingPos.Tab() );
    1201           0 :                         aCRD.Ref2.SetFlag3D( b3D );
    1202           0 :                         aCRD.Ref2.SetTabRel( false );
    1203           0 :                         rRangeList.Append( aCRD, nTab );
    1204             :                     }
    1205             :                     else
    1206           0 :                         rRangeList.Append( aSRD, nTab );
    1207             :                 }
    1208             :             }
    1209             : 
    1210           0 :                 break;
    1211             :             case 0x5B:
    1212             :             case 0x7B:
    1213             :             case 0x3B: // 3-D Area Reference                    [    276]
    1214             :             {
    1215             :                 sal_uInt16      nTabFirst, nTabLast, nRowFirst, nRowLast;
    1216             :                 sal_Int16       nExtSheet;
    1217             :                 sal_uInt8       nColFirst, nColLast;
    1218             : 
    1219           0 :                 aIn >> nExtSheet;
    1220           0 :                 aIn.Ignore( 8 );
    1221           0 :                 aIn >> nTabFirst >> nTabLast >> nRowFirst >> nRowLast
    1222           0 :                     >> nColFirst >> nColLast;
    1223             : 
    1224           0 :                 if( nExtSheet >= 0 )
    1225             :                     // from external
    1226             :                 {
    1227           0 :                     if( rR.pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
    1228             :                     {
    1229           0 :                         nTabFirst = nTabLast;
    1230           0 :                         nExtSheet = 0;      // found
    1231             :                     }
    1232             :                     else
    1233             :                     {
    1234           0 :                         aPool << ocBad;
    1235           0 :                         aPool >> aStack;
    1236           0 :                         nExtSheet = 1;      // don't create a CompleteRef
    1237             :                     }
    1238             :                 }
    1239             : 
    1240           0 :                 if( nExtSheet <= 0 )
    1241             :                 {// in current Workbook
    1242             :                     // first part of range
    1243           0 :                     ScSingleRefData &rR1 = aCRD.Ref1;
    1244           0 :                     ScSingleRefData &rR2 = aCRD.Ref2;
    1245             : 
    1246           0 :                     rR1.nTab = static_cast<SCTAB>(nTabFirst);
    1247           0 :                     rR2.nTab = static_cast<SCTAB>(nTabLast);
    1248           0 :                     rR1.SetFlag3D( ( static_cast<SCTAB>(nTabFirst) != aEingPos.Tab() ) || bRangeName );
    1249           0 :                     rR1.SetTabRel( false );
    1250           0 :                     rR2.SetFlag3D( ( static_cast<SCTAB>(nTabLast) != aEingPos.Tab() ) || bRangeName );
    1251           0 :                     rR2.SetTabRel( false );
    1252             : 
    1253           0 :                     ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
    1254           0 :                     ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
    1255             : 
    1256           0 :                     if( IsComplColRange( nColFirst, nColLast ) )
    1257           0 :                         SetComplCol( aCRD );
    1258           0 :                     else if( IsComplRowRange( nRowFirst, nRowLast ) )
    1259           0 :                         SetComplRow( aCRD );
    1260             : 
    1261           0 :                     rRangeList.Append( aCRD, nTab );
    1262             :                 }//END in current Workbook
    1263             :             }
    1264           0 :                 break;
    1265             :             case 0x5C:
    1266             :             case 0x7C:
    1267             :             case 0x3C: // Deleted 3-D Cell Reference            [    277]
    1268           0 :                 nIgnore = 17;
    1269           0 :                 break;
    1270             :             case 0x5D:
    1271             :             case 0x7D:
    1272             :             case 0x3D: // Deleted 3-D Area Reference            [    277]
    1273           0 :                 nIgnore = 20;
    1274           0 :                 break;
    1275           0 :             default: bError = sal_True;
    1276             :         }
    1277           0 :         bError |= !aIn.IsValid();
    1278             : 
    1279           0 :         aIn.Ignore( nIgnore );
    1280             :     }
    1281             : 
    1282             :     ConvErr eRet;
    1283             : 
    1284           0 :     if( bError )
    1285           0 :         eRet = ConvErrNi;
    1286           0 :     else if( aIn.GetRecPos() != nEndPos )
    1287           0 :         eRet = ConvErrCount;
    1288           0 :     else if( bExternName )
    1289           0 :         eRet = ConvErrExternal;
    1290             :     else
    1291           0 :         eRet = ConvOK;
    1292             : 
    1293           0 :     aIn.Seek( nEndPos );
    1294           0 :     return eRet;
    1295             : }
    1296             : 
    1297           0 : ConvErr ExcelToSc::ConvertExternName( const ScTokenArray*& /*rpArray*/, XclImpStream& /*rStrm*/, sal_Size /*nFormulaLen*/,
    1298             :                                       const String& /*rUrl*/, const vector<String>& /*rTabNames*/ )
    1299             : {
    1300             :     // not implemented ...
    1301           0 :     return ConvErrNi;
    1302             : }
    1303             : 
    1304           0 : sal_Bool ExcelToSc::GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, sal_Size nLen )
    1305             : {
    1306             :     OSL_ENSURE_BIFF( GetBiff() == EXC_BIFF5 );
    1307           0 :     if( GetBiff() != EXC_BIFF5 )
    1308           0 :         return false;
    1309             : 
    1310             :     sal_uInt8 nOp;
    1311             :     sal_uInt16 nRow1, nRow2;
    1312             :     sal_uInt8 nCol1, nCol2;
    1313             :     SCTAB nTab1, nTab2;
    1314             :     sal_uInt16 nTabFirst, nTabLast;
    1315             :     sal_Int16 nRefIdx;
    1316             : 
    1317             :     sal_Size nSeek;
    1318           0 :     sal_Size nEndPos = rStrm.GetRecPos() + nLen;
    1319             : 
    1320           0 :     while( rStrm.IsValid() && (rStrm.GetRecPos() < nEndPos) )
    1321             :     {
    1322           0 :         rStrm >> nOp;
    1323           0 :         nSeek = 0;
    1324             : 
    1325           0 :         switch( nOp )
    1326             :         {
    1327             :             case 0x44:
    1328             :             case 0x64:
    1329             :             case 0x24: // Cell Reference                        [319 270]
    1330             :             case 0x4C:
    1331             :             case 0x6C:
    1332             :             case 0x2C: // Cell Reference Within a Name          [323    ]
    1333             :                        // Cell Reference Within a Shared Formula[    273]
    1334           0 :                 rStrm >> nRow1 >> nCol1;
    1335             : 
    1336           0 :                 nRow2 = nRow1;
    1337           0 :                 nCol2 = nCol1;
    1338           0 :                 nTab1 = nTab2 = GetCurrScTab();
    1339           0 :                 goto _common;
    1340             :             case 0x45:
    1341             :             case 0x65:
    1342             :             case 0x25: // Area Reference                        [320 270]
    1343             :             case 0x4D:
    1344             :             case 0x6D:
    1345             :             case 0x2D: // Area Reference Within a Name          [324    ]
    1346             :                        // Area Reference Within a Shared Formula[    274]
    1347           0 :                 rStrm >> nRow1 >> nRow2 >> nCol1 >> nCol2;
    1348             : 
    1349           0 :                 nTab1 = nTab2 = GetCurrScTab();
    1350           0 :                 goto _common;
    1351             :             case 0x5A:
    1352             :             case 0x7A:
    1353             :             case 0x3A: // 3-D Cell Reference                    [    275]
    1354           0 :                 rStrm >> nRefIdx;
    1355           0 :                 rStrm.Ignore( 8 );
    1356           0 :                 rStrm >> nTabFirst >> nTabLast >> nRow1 >> nCol1;
    1357             : 
    1358           0 :                 nRow2 = nRow1;
    1359           0 :                 nCol2 = nCol1;
    1360             : 
    1361           0 :                 goto _3d_common;
    1362             :             case 0x5B:
    1363             :             case 0x7B:
    1364             :             case 0x3B: // 3-D Area Reference                    [    276]
    1365           0 :                 rStrm >> nRefIdx;
    1366           0 :                 rStrm.Ignore( 8 );
    1367           0 :                 rStrm >> nTabFirst >> nTabLast >> nRow1 >> nRow2 >> nCol1 >> nCol2;
    1368             : 
    1369             :     _3d_common:
    1370           0 :                 nTab1 = static_cast< SCTAB >( nTabFirst );
    1371           0 :                 nTab2 = static_cast< SCTAB >( nTabLast );
    1372             : 
    1373             :                 // skip references to deleted sheets
    1374           0 :                 if( (nRefIdx >= 0) || !ValidTab( nTab1 ) || (nTab1 != nTab2) )
    1375           0 :                     break;
    1376             : 
    1377           0 :                 goto _common;
    1378             :     _common:
    1379             :                 // do not check abs/rel flags, linked controls have set them!
    1380             :                 {
    1381           0 :                     ScRange aScRange;
    1382           0 :                     nRow1 &= 0x3FFF;
    1383           0 :                     nRow2 &= 0x3FFF;
    1384           0 :                     if( GetAddressConverter().ConvertRange( aScRange, XclRange( nCol1, nRow1, nCol2, nRow2 ), nTab1, nTab2, true ) )
    1385           0 :                         rRangeList.Append( aScRange );
    1386             :                 }
    1387           0 :                 break;
    1388             : 
    1389             :             case 0x03: // Addition                              [312 264]
    1390             :             case 0x04: // Subtraction                           [313 264]
    1391             :             case 0x05: // Multiplication                        [313 264]
    1392             :             case 0x06: // Division                              [313 264]
    1393             :             case 0x07: // Exponetiation                         [313 265]
    1394             :             case 0x08: // Concatenation                         [313 265]
    1395             :             case 0x09: // Less Than                             [313 265]
    1396             :             case 0x0A: // Less Than or Equal                    [313 265]
    1397             :             case 0x0B: // Equal                                 [313 265]
    1398             :             case 0x0C: // Greater Than or Equal                 [313 265]
    1399             :             case 0x0D: // Greater Than                          [313 265]
    1400             :             case 0x0E: // Not Equal                             [313 265]
    1401             :             case 0x0F: // Intersection                          [314 265]
    1402             :             case 0x10: // Union                                 [314 265]
    1403             :             case 0x11: // Range                                 [314 265]
    1404             :             case 0x12: // Unary Plus                            [312 264]
    1405             :             case 0x13: // Unary Minus                           [312 264]
    1406             :             case 0x14: // Percent Sign                          [312 264]
    1407             :             case 0x15: // Parenthesis                           [326 278]
    1408             :             case 0x16: // Missing Argument                      [314 266]
    1409           0 :                 break;
    1410             :             case 0x1C: // Error Value                           [314 266]
    1411             :             case 0x1D: // Boolean                               [315 266]
    1412           0 :                 nSeek = 1;
    1413           0 :                 break;
    1414             :             case 0x1E: // Integer                               [315 266]
    1415             :             case 0x41:
    1416             :             case 0x61:
    1417             :             case 0x21: // Function, Fixed Number of Arguments   [333 282]
    1418             :             case 0x49:
    1419             :             case 0x69:
    1420             :             case 0x29: // Variable Reference Subexpression      [331 281]
    1421             :             case 0x4E:
    1422             :             case 0x6E:
    1423             :             case 0x2E: // Reference Subexpression Within a Name [332 282]
    1424             :             case 0x4F:
    1425             :             case 0x6F:
    1426             :             case 0x2F: // Incomplete Reference Subexpression... [332 282]
    1427             :             case 0x58:
    1428             :             case 0x78:
    1429             :             case 0x38: // Command-Equivalent Function           [333    ]
    1430           0 :                 nSeek = 2;
    1431           0 :                 break;
    1432             :             case 0x42:
    1433             :             case 0x62:
    1434             :             case 0x22: // Function, Variable Number of Arg.     [333 283]
    1435             :             case 0x4A:
    1436             :             case 0x6A:
    1437             :             case 0x2A: // Deleted Cell Reference                [323 273]
    1438           0 :                 nSeek = 3;
    1439           0 :                 break;
    1440             :             case 0x01: // Array Formula                         [325    ]
    1441             :                        // Array Formula or Shared Formula       [    277]
    1442             :             case 0x02: // Data Table                            [325 277]
    1443           0 :                 nSeek = 4;
    1444           0 :                 break;
    1445             :             case 0x46:
    1446             :             case 0x66:
    1447             :             case 0x26: // Constant Reference Subexpression      [321 271]
    1448             :             case 0x47:
    1449             :             case 0x67:
    1450             :             case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
    1451             :             case 0x48:
    1452             :             case 0x68:
    1453             :             case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
    1454             :             case 0x4B:
    1455             :             case 0x6B:
    1456             :             case 0x2B: // Deleted Area Refernce                 [323 273]
    1457           0 :                 nSeek = 6;
    1458           0 :                 break;
    1459             :             case 0x40:
    1460             :             case 0x60:
    1461             :             case 0x20: // Array Constant                        [317 268]
    1462           0 :                 nSeek = 7;
    1463           0 :                 break;
    1464             :             case 0x1F: // Number                                [315 266]
    1465           0 :                 nSeek = 8;
    1466           0 :                 break;
    1467             :             case 0x43:
    1468             :             case 0x63:
    1469             :             case 0x23: // Name                                  [318 269]
    1470           0 :                 nSeek = 14;
    1471           0 :                 break;
    1472             :             case 0x5C:
    1473             :             case 0x7C:
    1474             :             case 0x3C: // Deleted 3-D Cell Reference            [    277]
    1475           0 :                 nSeek = 17;
    1476           0 :                 break;
    1477             :             case 0x5D:
    1478             :             case 0x7D:
    1479             :             case 0x3D: // Deleted 3-D Area Reference            [    277]
    1480           0 :                 nSeek = 20;
    1481           0 :                 break;
    1482             :             case 0x59:
    1483             :             case 0x79:
    1484             :             case 0x39: // Name or External Name                 [    275]
    1485           0 :                 nSeek = 24;
    1486           0 :                 break;
    1487             :             case 0x17: // String Constant                       [314 266]
    1488           0 :                 nSeek = rStrm.ReaduInt8();
    1489           0 :                 break;
    1490             :             case 0x19: // Special Attribute                     [327 279]
    1491             :             {
    1492             :                 sal_uInt8 nOpt;
    1493             :                 sal_uInt16 nData;
    1494           0 :                 rStrm >> nOpt >> nData;
    1495           0 :                 if( nOpt & 0x04 )
    1496           0 :                     nSeek = nData * 2 + 2;
    1497             :             }
    1498           0 :                 break;
    1499             :         }
    1500             : 
    1501           0 :         rStrm.Ignore( nSeek );
    1502             :     }
    1503           0 :     rStrm.Seek( nEndPos );
    1504             : 
    1505           0 :     return !rRangeList.empty();
    1506             : }
    1507             : 
    1508        6158 : void ExcelToSc::DoMulArgs( DefTokenId eId, sal_uInt8 nAnz )
    1509             : {
    1510        6158 :     TokenId                 eParam[ 256 ];
    1511             :     sal_Int32                   nLauf;
    1512             : 
    1513        6158 :     if( eId == ocCeil || eId == ocFloor )
    1514             :     {
    1515           0 :         aStack << aPool.Store( 1.0 );   // default, because not present in Excel
    1516           0 :         nAnz++;
    1517             :     }
    1518             : 
    1519       17976 :     for( nLauf = 0; aStack.HasMoreTokens() && (nLauf < nAnz); nLauf++ )
    1520       11818 :         aStack >> eParam[ nLauf ];
    1521             :     // #i70925# reduce parameter count, if no more tokens available on token stack
    1522        6158 :     if( nLauf < nAnz )
    1523           0 :         nAnz = static_cast< sal_uInt8 >( nLauf );
    1524             : 
    1525        6158 :     if( nAnz > 0 && eId == ocExternal )
    1526             :     {
    1527           2 :         TokenId             n = eParam[ nAnz - 1 ];
    1528             : //##### GRUETZE FUER BASIC-FUNCS RICHTEN!
    1529           2 :         if( const String* pExt = aPool.GetExternal( n ) )
    1530             :         {
    1531           2 :             if( const XclFunctionInfo* pFuncInfo = maFuncProv.GetFuncInfoFromXclMacroName( *pExt ) )
    1532           0 :                 aPool << pFuncInfo->meOpCode;
    1533             :             else
    1534           2 :                 aPool << n;
    1535           2 :             nAnz--;
    1536             :         }
    1537             :         else
    1538           0 :             aPool << eId;
    1539             :     }
    1540             :     else
    1541        6156 :         aPool << eId;
    1542             : 
    1543        6158 :     aPool << ocOpen;
    1544             : 
    1545        6158 :     if( nAnz > 0 )
    1546             :     {
    1547             :         // attention: 0 = last parameter, nAnz-1 = first parameter
    1548        6158 :         sal_Int16 nSkipEnd = -1;    // skip all parameters <= nSkipEnd
    1549             : 
    1550        6158 :         sal_Int16 nLast = nAnz - 1;
    1551             : 
    1552             :         // functions for which parameters have to be skipped
    1553        6158 :         if( eId == ocPercentrank && nAnz == 3 )
    1554           0 :             nSkipEnd = 0;       // skip last parameter if necessary
    1555             : 
    1556             :         // Joost special cases
    1557        6158 :         else if( eId == ocIf )
    1558             :         {
    1559           2 :             sal_uInt16          nNullParam = 0;
    1560           8 :             for( nLauf = 0 ; nLauf < nAnz ; nLauf++ )
    1561             :             {
    1562           6 :                 if( aPool.IsSingleOp( eParam[ nLauf ], ocMissing ) )
    1563             :                 {
    1564           0 :                     if( !nNullParam )
    1565           0 :                         nNullParam = (sal_uInt16) aPool.Store( ( double ) 0.0 );
    1566           0 :                     eParam[ nLauf ] = nNullParam;
    1567             :                 }
    1568             :             }
    1569             :         }
    1570             : 
    1571             :         // [Parameter{;Parameter}]
    1572        6158 :         if( nLast > nSkipEnd )
    1573             :         {
    1574        6158 :             sal_Int16 nNull = -1;       // skip this parameter
    1575        6158 :             aPool << eParam[ nLast ];
    1576       11816 :             for( nLauf = nLast - 1 ; nLauf > nSkipEnd ; nLauf-- )
    1577             :             {
    1578        5658 :                 if( nLauf != nNull )
    1579        5658 :                     aPool << ocSep << eParam[ nLauf ];
    1580             :             }
    1581             :         }
    1582             :     }
    1583        6158 :     aPool << ocClose;
    1584             : 
    1585        6158 :     aPool >> aStack;
    1586        6158 : }
    1587             : 
    1588             : 
    1589           0 : void ExcelToSc::ExcRelToScRel( sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData &rSRD, const sal_Bool bName )
    1590             : {
    1591           0 :     if( bName )
    1592             :     {
    1593             :         // C O L
    1594           0 :         if( nRow & 0x4000 )
    1595             :         {//                                                         rel Col
    1596           0 :             rSRD.SetColRel( sal_True );
    1597           0 :             rSRD.nRelCol = static_cast<SCsCOL>(static_cast<sal_Int8>(nCol));
    1598             :         }
    1599             :         else
    1600             :         {//                                                         abs Col
    1601           0 :             rSRD.SetColRel( false );
    1602           0 :             rSRD.nCol = static_cast<SCCOL>(nCol);
    1603             :         }
    1604             : 
    1605             :         // R O W
    1606           0 :         if( nRow & 0x8000 )
    1607             :         {//                                                         rel Row
    1608           0 :             rSRD.SetRowRel( sal_True );
    1609           0 :             if( nRow & 0x2000 ) // Bit 13 set?
    1610             :                 //                                              -> Row negative
    1611           0 :                 rSRD.nRelRow = static_cast<SCsROW>(static_cast<sal_Int16>(nRow | 0xC000));
    1612             :             else
    1613             :                 //                                              -> Row positive
    1614           0 :                 rSRD.nRelRow = static_cast<SCsROW>(nRow & nRowMask);
    1615             :         }
    1616             :         else
    1617             :         {//                                                         abs Row
    1618           0 :             rSRD.SetRowRel( false );
    1619           0 :             rSRD.nRow = static_cast<SCROW>(nRow & nRowMask);
    1620             :         }
    1621             : 
    1622             :         // T A B
    1623             :         // abs needed if rel in shared formula for ScCompiler UpdateNameReference
    1624           0 :         if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
    1625           0 :             rSRD.nTab = GetCurrScTab();
    1626             :     }
    1627             :     else
    1628             :     {
    1629             :         // C O L
    1630           0 :         rSRD.SetColRel( ( nRow & 0x4000 ) > 0 );
    1631           0 :         rSRD.nCol = static_cast<SCsCOL>(nCol);
    1632             : 
    1633             :         // R O W
    1634           0 :         rSRD.SetRowRel( ( nRow & 0x8000 ) > 0 );
    1635           0 :         rSRD.nRow = static_cast<SCsROW>(nRow & nRowMask);
    1636             : 
    1637           0 :         if ( rSRD.IsColRel() )
    1638           0 :             rSRD.nRelCol = rSRD.nCol - aEingPos.Col();
    1639           0 :         if ( rSRD.IsRowRel() )
    1640           0 :             rSRD.nRelRow = rSRD.nRow - aEingPos.Row();
    1641             : 
    1642             :         // T A B
    1643             :         // #i10184# abs needed if rel in shared formula for ScCompiler UpdateNameReference
    1644           0 :         if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
    1645           0 :             rSRD.nTab = GetCurrScTab() + rSRD.nRelTab;
    1646             :     }
    1647           0 : }
    1648             : 
    1649             : 
    1650           0 : const ScTokenArray* ExcelToSc::GetBoolErr( XclBoolError eType )
    1651             : {
    1652             :     sal_uInt16                  nError;
    1653           0 :     aPool.Reset();
    1654           0 :     aStack.Reset();
    1655             : 
    1656             :     DefTokenId              eOc;
    1657             : 
    1658           0 :     switch( eType )
    1659             :     {
    1660           0 :         case xlErrNull:     eOc = ocStop;       nError = errNoCode;             break;
    1661           0 :         case xlErrDiv0:     eOc = ocStop;       nError = errDivisionByZero;     break;
    1662           0 :         case xlErrValue:    eOc = ocStop;       nError = errNoValue;            break;
    1663           0 :         case xlErrRef:      eOc = ocStop;       nError = errNoRef;              break;
    1664           0 :         case xlErrName:     eOc = ocStop;       nError = errNoName;             break;
    1665           0 :         case xlErrNum:      eOc = ocStop;       nError = errIllegalFPOperation; break;
    1666           0 :         case xlErrNA:       eOc = ocNotAvail;   nError = NOTAVAILABLE;          break;
    1667           0 :         case xlErrTrue:     eOc = ocTrue;       nError = 0;                     break;
    1668           0 :         case xlErrFalse:    eOc = ocFalse;      nError = 0;                     break;
    1669           0 :         case xlErrUnknown:  eOc = ocStop;       nError = errUnknownState;       break;
    1670             :         default:
    1671             :             OSL_FAIL( "ExcelToSc::GetBoolErr - wrong enum!" );
    1672           0 :             eOc = ocNoName;
    1673           0 :             nError = errUnknownState;
    1674             :     }
    1675             : 
    1676           0 :     aPool << eOc;
    1677           0 :     if( eOc != ocStop )
    1678           0 :         aPool << ocOpen << ocClose;
    1679             : 
    1680           0 :     aPool >> aStack;
    1681             : 
    1682           0 :     const ScTokenArray*     pErgebnis = aPool[ aStack.Get() ];
    1683           0 :     if( nError )
    1684           0 :         ( ( ScTokenArray* ) pErgebnis )->SetCodeError( nError );
    1685             : 
    1686           0 :     ( ( ScTokenArray* ) pErgebnis )->SetRecalcModeNormal();
    1687             : 
    1688           0 :     return pErgebnis;
    1689             : }
    1690             : 
    1691             : 
    1692             : // if a shared formula was found, stream seeks to first byte after <nFormulaLen>,
    1693             : // else stream pointer stays unchanged
    1694         656 : sal_Bool ExcelToSc::GetShrFmla( const ScTokenArray*& rpErgebnis, XclImpStream& aIn, sal_Size nFormulaLen )
    1695             : {
    1696             :     sal_uInt8           nOp;
    1697         656 :     sal_Bool            bRet = sal_True;
    1698             : 
    1699         656 :     if( nFormulaLen == 0 )
    1700           0 :         bRet = false;
    1701             :     else
    1702             :     {
    1703         656 :         aIn.PushPosition();
    1704             : 
    1705         656 :         aIn >> nOp;
    1706             : 
    1707         656 :         if( nOp == 0x01 )   // Shared Formula       [    277]
    1708             :         {
    1709             :             sal_uInt16 nCol, nRow;
    1710             : 
    1711         160 :             aIn >> nRow >> nCol;
    1712             : 
    1713         160 :             aStack << aPool.StoreName( GetOldRoot().pShrfmlaBuff->Find(
    1714         320 :                 ScAddress(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), GetCurrScTab())), true);
    1715             : 
    1716         160 :             bRet = sal_True;
    1717             :         }
    1718             :         else
    1719         496 :             bRet = false;
    1720             : 
    1721         656 :         aIn.PopPosition();
    1722             :     }
    1723             : 
    1724         656 :     if( bRet )
    1725             :     {
    1726         160 :         aIn.Ignore( nFormulaLen );
    1727         160 :         rpErgebnis = aPool[ aStack.Get() ];
    1728             :     }
    1729             :     else
    1730         496 :         rpErgebnis = NULL;
    1731             : 
    1732         656 :     return bRet;
    1733             : }
    1734             : 
    1735             : 
    1736           2 : void ExcelToSc::SetError( ScFormulaCell &rCell, const ConvErr eErr )
    1737             : {
    1738             :     sal_uInt16  nInd;
    1739             : 
    1740           2 :     switch( eErr )
    1741             :     {
    1742           2 :         case ConvErrNi:         nInd = errUnknownToken; break;
    1743           0 :         case ConvErrNoMem:      nInd = errCodeOverflow; break;
    1744           0 :         case ConvErrExternal:   nInd = errNoName; break;
    1745           0 :         case ConvErrCount:      nInd = errCodeOverflow; break;
    1746           0 :         default:                nInd = errNoCode;   // I had no better idea
    1747             :     }
    1748             : 
    1749           2 :     rCell.SetErrCode( nInd );
    1750           2 : }
    1751             : 
    1752             : 
    1753           0 : void ExcelToSc::SetComplCol( ScComplexRefData &rCRD )
    1754             : {
    1755           0 :     ScSingleRefData &rSRD = rCRD.Ref2;
    1756           0 :     if( rSRD.IsColRel() )
    1757           0 :         rSRD.nRelCol = MAXCOL - aEingPos.Col();
    1758             :     else
    1759           0 :         rSRD.nCol = MAXCOL;
    1760           0 : }
    1761             : 
    1762             : 
    1763           0 : void ExcelToSc::SetComplRow( ScComplexRefData &rCRD )
    1764             : {
    1765           0 :     ScSingleRefData &rSRD = rCRD.Ref2;
    1766           0 :     if( rSRD.IsRowRel() )
    1767           0 :         rSRD.nRelRow = MAXROW - aEingPos.Row();
    1768             :     else
    1769           0 :         rSRD.nRow = MAXROW;
    1770           0 : }
    1771             : 
    1772           2 : void ExcelToSc::ReadExtensionArray( unsigned int n, XclImpStream& aIn )
    1773             : {
    1774             :     sal_uInt8        nByte;
    1775             :     sal_uInt16      nUINT16;
    1776             :     double      fDouble;
    1777           2 :     String      aString;
    1778             :     ScMatrix*   pMatrix;
    1779             : 
    1780           2 :     aIn >> nByte >> nUINT16;
    1781             : 
    1782             :     SCSIZE nC, nCols;
    1783             :     SCSIZE nR, nRows;
    1784           2 :     if( GetBiff() == EXC_BIFF8 )
    1785             :     {
    1786           2 :         nCols = nByte + 1;
    1787           2 :         nRows = nUINT16 + 1;
    1788             :     }
    1789             :     else
    1790             :     {
    1791           0 :         nCols = nByte ? nByte : 256;
    1792           0 :         nRows = nUINT16;
    1793             :     }
    1794             : 
    1795           2 :     pMatrix = aPool.GetMatrix( n );
    1796             : 
    1797           2 :     if( NULL != pMatrix )
    1798             :     {
    1799           2 :         pMatrix->Resize(nCols, nRows);
    1800           2 :         pMatrix->GetDimensions( nC, nR);
    1801           2 :         if( nC != nCols || nR != nRows )
    1802             :         {
    1803             :             OSL_FAIL( "ExcelToSc::ReadExtensionArray - matrix size mismatch" );
    1804           0 :             pMatrix = NULL;
    1805             :         }
    1806             :     }
    1807             :     else
    1808             :     {
    1809             :         OSL_FAIL( "ExcelToSc::ReadExtensionArray - missing matrix" );
    1810             :     }
    1811             : 
    1812           6 :     for( nR = 0 ; nR < nRows; nR++ )
    1813             :     {
    1814          16 :         for( nC = 0 ; nC < nCols; nC++ )
    1815             :         {
    1816          12 :             aIn >> nByte;
    1817          12 :             switch( nByte )
    1818             :             {
    1819             :                 case EXC_CACHEDVAL_EMPTY:
    1820           0 :                     aIn.Ignore( 8 );
    1821           0 :                     if( NULL != pMatrix )
    1822             :                     {
    1823           0 :                         pMatrix->PutEmpty( nC, nR );
    1824             :                     }
    1825           0 :                     break;
    1826             : 
    1827             :                 case EXC_CACHEDVAL_DOUBLE:
    1828          12 :                     aIn >> fDouble;
    1829          12 :                     if( NULL != pMatrix )
    1830             :                     {
    1831          12 :                         pMatrix->PutDouble( fDouble, nC, nR );
    1832             :                     }
    1833          12 :                     break;
    1834             : 
    1835             :                 case EXC_CACHEDVAL_STRING:
    1836           0 :                     if( GetBiff() == EXC_BIFF8 )
    1837             :                     {
    1838           0 :                         aIn >> nUINT16;
    1839           0 :                         aString = aIn.ReadUniString( nUINT16 );
    1840             :                     }
    1841             :                     else
    1842             :                     {
    1843           0 :                         aIn >> nByte;
    1844           0 :                         aString = aIn.ReadRawByteString( nByte );
    1845             :                     }
    1846           0 :                     if( NULL != pMatrix )
    1847             :                     {
    1848           0 :                         pMatrix->PutString( aString, nC, nR );
    1849             :                     }
    1850           0 :                     break;
    1851             : 
    1852             :                 case EXC_CACHEDVAL_BOOL:
    1853           0 :                     aIn >> nByte;
    1854           0 :                     aIn.Ignore( 7 );
    1855           0 :                     if( NULL != pMatrix )
    1856             :                     {
    1857           0 :                         pMatrix->PutBoolean( nByte != 0, nC, nR );
    1858             :                     }
    1859           0 :                     break;
    1860             : 
    1861             :                 case EXC_CACHEDVAL_ERROR:
    1862           0 :                     aIn >> nByte;
    1863           0 :                     aIn.Ignore( 7 );
    1864           0 :                     if( NULL != pMatrix )
    1865             :                     {
    1866           0 :                         pMatrix->PutError( XclTools::GetScErrorCode( nByte ), nC, nR );
    1867             :                     }
    1868           0 :                     break;
    1869             :             }
    1870             :         }
    1871           2 :     }
    1872           2 : }
    1873             : 
    1874           0 : void ExcelToSc::ReadExtensionNlr( XclImpStream& aIn )
    1875             : {
    1876             :     sal_uInt32 nFlags;
    1877           0 :     aIn >> nFlags;
    1878             : 
    1879           0 :     sal_uInt32 nCount = nFlags & EXC_TOK_NLR_ADDMASK;
    1880           0 :     aIn.Ignore( nCount * 4 ); // Drop the cell positions
    1881           0 : }
    1882             : 
    1883           0 : void ExcelToSc::ReadExtensionMemArea( XclImpStream& aIn )
    1884             : {
    1885             :     sal_uInt16 nCount;
    1886           0 :     aIn >> nCount;
    1887             : 
    1888           0 :     aIn.Ignore( nCount * ((GetBiff() == EXC_BIFF8) ? 8 : 6) ); // drop the ranges
    1889           0 : }
    1890             : 
    1891        4996 : void ExcelToSc::ReadExtensions( const ExtensionTypeVec& rExtensions,
    1892             :                                 XclImpStream& aIn )
    1893             : {
    1894        4996 :     unsigned int nArray = 0;
    1895             : 
    1896        4998 :     for( unsigned int i = 0 ; i < rExtensions.size() ; i++ )
    1897             :     {
    1898           2 :         ExtensionType eType = rExtensions[i];
    1899             : 
    1900           2 :         switch( eType )
    1901             :         {
    1902             :             case EXTENSION_ARRAY:
    1903           2 :                 ReadExtensionArray( nArray++, aIn );
    1904           2 :                 break;
    1905             : 
    1906             :             case EXTENSION_NLR:
    1907           0 :                 ReadExtensionNlr( aIn );
    1908           0 :                 break;
    1909             : 
    1910             :             case EXTENSION_MEMAREA:
    1911           0 :                 ReadExtensionMemArea( aIn );
    1912           0 :                 break;
    1913             :         }
    1914             :     }
    1915        5020 : }
    1916             : 
    1917             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10