LCOV - code coverage report
Current view: top level - sc/source/filter/qpro - qproform.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 287 7.3 %
Date: 2012-08-25 Functions: 2 9 22.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 351 4.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <rtl/strbuf.hxx>
      31                 :            : #include <sal/config.h>
      32                 :            : #include <sal/macros.h>
      33                 :            : #include "qpro.hxx"
      34                 :            : 
      35                 :            : #include "qproform.hxx"
      36                 :            : #include "formel.hxx"
      37                 :            : #include "compiler.hxx"
      38                 :            : #include <tokstack.hxx>
      39                 :            : #include "ftools.hxx"
      40                 :            : 
      41                 :          0 : void QProToSc::ReadSRD( ScSingleRefData& rSRD, sal_Int8 nPage, sal_Int8 nCol, sal_uInt16 nRelBit )
      42                 :            : {
      43                 :          0 :     sal_uInt16 nTmp = nRelBit & 0x1fff;
      44                 :          0 :     rSRD.InitAddress( ScAddress( nCol, (~nTmp + 1), 0 ) );
      45         [ #  # ]:          0 :     if( nRelBit & 0x4000 )
      46                 :            :     {
      47                 :          0 :         rSRD.nRelCol = nCol;
      48                 :          0 :         rSRD.SetColRel( sal_True );
      49                 :            :     }
      50                 :            :     else
      51                 :            :     {
      52                 :          0 :         rSRD.nCol = nCol;
      53                 :          0 :         rSRD.SetColRel( false );
      54                 :            :     }
      55         [ #  # ]:          0 :     if( nRelBit & 0x2000 )
      56                 :            :     {
      57                 :          0 :         rSRD.nRelRow = (~nTmp + 1);
      58                 :          0 :         rSRD.nRelRow = (sal_Int16)(nTmp << 3);
      59                 :          0 :         rSRD.nRelRow /= 8;
      60                 :          0 :         rSRD.SetRowRel( sal_True );
      61                 :            :     }
      62                 :            :     else
      63                 :            :     {
      64                 :          0 :         rSRD.nRow = nTmp;
      65                 :          0 :         rSRD.SetRowRel( false );
      66                 :            :     }
      67         [ #  # ]:          0 :     if( nRelBit & 0x8000 )
      68                 :            :     {
      69                 :          0 :         rSRD.nRelTab = nPage;
      70                 :          0 :         rSRD.SetTabRel( sal_True );
      71                 :            :         // absolute tab needed in caller for comparison in case of DoubleRef
      72                 :          0 :         rSRD.nTab = aEingPos.Tab() + nPage;
      73                 :            :     }
      74                 :            :     else
      75                 :            :     {
      76                 :          0 :         rSRD.nTab = nPage;
      77                 :          0 :         rSRD.SetTabRel( false );
      78                 :            :     }
      79         [ #  # ]:          0 :     if (rSRD.nTab != aEingPos.Tab())
      80                 :          0 :         rSRD.SetFlag3D( sal_True);
      81                 :          0 : }
      82                 :            : 
      83                 :          3 : QProToSc::QProToSc( SvStream& rStream, const ScAddress& rRefPos ) :
      84                 :            :     ConverterBase( 128 ),
      85                 :          3 :     maIn( rStream )
      86                 :            : {
      87                 :          3 :     aEingPos = rRefPos;
      88                 :          3 : }
      89                 :            : 
      90                 :          0 : void QProToSc::DoFunc( DefTokenId eOc, sal_uInt16 nArgs, const sal_Char* pExtString )
      91                 :            : {
      92         [ #  # ]:          0 :     TokenId  eParam[ nBufSize ];
      93                 :            :     sal_Int32    nCount;
      94                 :          0 :     TokenId  nPush, nPush1;
      95                 :            : 
      96                 :          0 :     sal_Bool bAddIn = false;
      97                 :          0 :     sal_Bool bNeg = false;
      98                 :            : 
      99         [ #  # ]:          0 :     if( eOc == ocNoName )
     100                 :            :     {
     101                 :          0 :         bAddIn = sal_True;
     102         [ #  # ]:          0 :         if( pExtString )
     103                 :            :         {
     104         [ #  # ]:          0 :             rtl::OStringBuffer s(RTL_CONSTASCII_STRINGPARAM("QPRO_"));
     105         [ #  # ]:          0 :             s.append(pExtString);
     106 [ #  # ][ #  # ]:          0 :             nPush = aPool.Store(eOc, rtl::OStringToOUString(s.makeStringAndClear(), maIn.GetStreamCharSet()));
         [ #  # ][ #  # ]
     107         [ #  # ]:          0 :             aPool << nPush;
     108                 :            :         }
     109                 :            :         else
     110         [ #  # ]:          0 :             aPool << ocNoName;
     111                 :            :     }
     112                 :            : 
     113         [ #  # ]:          0 :     if( nArgs < nBufSize )
     114                 :            :     {
     115         [ #  # ]:          0 :         for( nCount = 0; nCount < nArgs ; nCount++ )
     116                 :          0 :             aStack >> eParam[ nCount ];
     117                 :            :     }
     118                 :            :     else
     119                 :          0 :         return;
     120                 :            : 
     121   [ #  #  #  # ]:          0 :     switch( eOc )
     122                 :            :     {
     123                 :            :         case ocIndex:
     124                 :          0 :             nPush = eParam[ 0 ];
     125                 :          0 :             eParam[ 0 ] = eParam[ 1 ];
     126                 :          0 :             eParam[ 1 ] = nPush;
     127         [ #  # ]:          0 :             IncToken( eParam[ 0 ] );
     128         [ #  # ]:          0 :             IncToken( eParam[ 1 ] );
     129                 :          0 :             break;
     130                 :            : 
     131                 :            :         case ocIRR:
     132                 :          0 :             nPush = eParam[ 0 ];
     133                 :          0 :             eParam[ 0 ] = eParam[ 1 ];
     134                 :          0 :             eParam[ 1 ] = nPush;
     135                 :          0 :             break;
     136                 :            : 
     137                 :            :         case ocGetYear:
     138         [ #  # ]:          0 :             nPush = aPool.Store( 1900.0 );
     139         [ #  # ]:          0 :             aPool << ocOpen;
     140                 :          0 :             break;
     141                 :            : 
     142                 :            :         default:
     143                 :          0 :             break;
     144                 :            :     }
     145                 :            : 
     146         [ #  # ]:          0 :     if( !bAddIn )
     147         [ #  # ]:          0 :         aPool << eOc;
     148                 :            : 
     149         [ #  # ]:          0 :     aPool << ocOpen;
     150                 :            : 
     151         [ #  # ]:          0 :     if( nArgs> 0 )
     152                 :            :     {
     153                 :          0 :         sal_Int16 nLast = nArgs- 1;
     154                 :            : 
     155         [ #  # ]:          0 :         if( eOc == ocZGZ )
     156 [ #  # ][ #  # ]:          0 :             aPool << eParam[ 2 ] << ocSep << eParam[ 1 ] << ocSep << eParam[ 0 ];
         [ #  # ][ #  # ]
                 [ #  # ]
     157         [ #  # ]:          0 :         if( eOc == ocZinsZ )
     158 [ #  # ][ #  # ]:          0 :             aPool << eParam[ 3 ] << ocSep << eParam[ 2 ] << ocSep << eParam[ 1 ] << ocSep << eParam[ 0 ];
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     159                 :            :         else
     160                 :            :         {
     161                 :          0 :             sal_Int16 nNull = -1;
     162         [ #  # ]:          0 :             aPool << eParam[ nLast ];
     163         [ #  # ]:          0 :             for( nCount = nLast - 1 ; nCount >= 0 ; nCount-- )
     164                 :            :             {
     165         [ #  # ]:          0 :                 if( nCount != nNull )
     166 [ #  # ][ #  # ]:          0 :                     aPool << ocSep << eParam[ nCount ];
     167                 :            :             }
     168                 :            :         }
     169                 :            :     }
     170                 :            : 
     171         [ #  # ]:          0 :     if( eOc == ocGetYear )
     172 [ #  # ][ #  # ]:          0 :         aPool << ocClose << ocSub << nPush;
                 [ #  # ]
     173         [ #  # ]:          0 :     else if( eOc == ocFixed )
     174 [ #  # ][ #  # ]:          0 :         aPool << ocSep << ocTrue << ocOpen << ocClose;
         [ #  # ][ #  # ]
     175                 :            : 
     176         [ #  # ]:          0 :     aPool << ocClose;
     177         [ #  # ]:          0 :     aPool >> aStack;
     178                 :            : 
     179         [ #  # ]:          0 :     if( bNeg )
     180                 :            :     {
     181 [ #  # ][ #  # ]:          0 :         aPool << ocOpen << ocSub << aStack << ocClose;
         [ #  # ][ #  # ]
     182         [ #  # ]:          0 :         aPool >> aStack;
     183                 :            :     }
     184                 :            : }
     185                 :            : 
     186                 :          0 : void QProToSc::IncToken( TokenId &rParam )
     187                 :            : {
     188 [ #  # ][ #  # ]:          0 :     aPool << ocOpen << rParam << mnAddToken;
                 [ #  # ]
     189                 :          0 :     rParam = aPool.Store();
     190                 :          0 : }
     191                 :            : 
     192                 :            : #define SAFEDEC_OR_RET(nRef, amt, ret) \
     193                 :            : do { \
     194                 :            :     if (nRef < amt)\
     195                 :            :         return ret; \
     196                 :            :     nRef-=amt; \
     197                 :            : } while(0)
     198                 :            : 
     199                 :          3 : ConvErr QProToSc::Convert( const ScTokenArray*& pArray, sal_uInt16 /*nLen*/, const FORMULA_TYPE /*eFT*/ )
     200                 :            : {
     201                 :            :     sal_uInt8 nFmla[ nBufSize ], i, nArg, nArgArray[ nBufSize ];
     202                 :            :     sal_Int8 nCol, nPage;
     203                 :          3 :     sal_uInt16 nInt, nIntCount = 0, nStringCount = 0, nFloatCount = 0, nDLLCount = 0, nIntArray[ nBufSize ], nArgCount = 0;
     204 [ +  - ][ +  + ]:       1539 :     String sStringArray[ nBufSize ];
           [ +  -  #  #  
                   #  # ]
     205                 :            :     sal_uInt16 nDummy, nDLLId, nDLLArray[ nBufSize ];
     206                 :            :     sal_uInt16 nNote, nRef, nRelBits;
     207                 :          3 :     TokenId nPush;
     208                 :            :     ScComplexRefData aCRD;
     209                 :            :     ScSingleRefData aSRD;
     210                 :            :     FUNC_TYPE eType;
     211                 :            :     DefTokenId eOc;
     212                 :            :     double nFloatArray[ nBufSize ], nFloat;
     213                 :          3 :     const sal_Char* pExtString = 0;
     214                 :            : 
     215                 :          3 :     aCRD.InitFlags();
     216                 :          3 :     aSRD.InitFlags();
     217         [ +  - ]:          3 :     maIn >> nRef;
     218                 :            : 
     219         [ +  - ]:          3 :     if( nRef < nBufSize )
     220                 :            :     {
     221         [ +  - ]:          3 :         for( i=0; i < nRef; i++)
     222                 :            :         {
     223         [ +  - ]:          3 :             maIn >> nFmla[i];
     224                 :            : 
     225         [ -  + ]:          3 :             if( nFmla[ i ] == 0x05 )
     226                 :            :             {
     227         [ #  # ]:          0 :                 maIn >> nInt;
     228                 :          0 :                 nIntArray[ nIntCount ] = nInt;
     229         [ #  # ]:          0 :         SAFEDEC_OR_RET(nRef, 2, ConvErrCount);
     230                 :          0 :                 nIntCount++;
     231                 :            :             }
     232                 :            : 
     233         [ +  - ]:          3 :             if( nFmla[ i ] == 0x00 )
     234                 :            :             {
     235         [ +  - ]:          3 :                 maIn >> nFloat;
     236                 :          3 :                 nFloatArray[ nFloatCount ] = nFloat;
     237         [ +  - ]:          3 :         SAFEDEC_OR_RET(nRef, 8, ConvErrCount);
     238                 :          0 :                 nFloatCount++;
     239                 :            :             }
     240                 :            : 
     241         [ #  # ]:          0 :             if( nFmla[ i ] == 0x1a )
     242                 :            :             {
     243 [ #  # ][ #  # ]:          0 :                 maIn >> nArg >> nDummy >> nDLLId;
                 [ #  # ]
     244                 :          0 :                 nArgArray[ nArgCount ] = nArg;
     245                 :          0 :                 nDLLArray[ nDLLCount ] = nDLLId;
     246         [ #  # ]:          0 :         SAFEDEC_OR_RET(nRef, 5, ConvErrCount);
     247                 :          0 :                 nDLLCount++;
     248                 :          0 :                 nArgCount++;
     249                 :            :             }
     250         [ #  # ]:          0 :             if( nFmla[ i ] == 0x06 )
     251                 :            :             {
     252 [ #  # ][ #  # ]:          0 :                 String aTmp(::read_zeroTerminated_uInt8s_ToOUString(maIn, maIn.GetStreamCharSet()));
     253         [ #  # ]:          0 :                 sStringArray[ nStringCount ] = aTmp;
     254                 :          0 :                 nStringCount++;
     255 [ #  # ][ #  # ]:          0 :         SAFEDEC_OR_RET(nRef, aTmp.Len() + 1, ConvErrCount);
                 [ #  # ]
     256                 :            :             }
     257                 :            :         }
     258                 :            :     }
     259                 :            :     else
     260                 :          0 :         return ConvErrCount;
     261                 :            : 
     262                 :          0 :     i = 0, nIntCount = 0, nFloatCount = 0, nDLLCount = 0, nArgCount = 0, nStringCount =0;
     263                 :            : 
     264 [ #  # ][ #  # ]:          0 :     while( i < nRef && ( nFmla[ i ] != 0x03 ) )
                 [ #  # ]
     265                 :            :     {
     266                 :          0 :         eType = IndexToType( nFmla[ i ] );
     267                 :          0 :         eOc = IndexToToken( nFmla[ i ] );
     268         [ #  # ]:          0 :         if( eOc == ocNoName )
     269                 :          0 :             pExtString = getString( nFmla[ i ] );
     270                 :            : 
     271   [ #  #  #  #  :          0 :         switch( eType )
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     272                 :            :         {
     273                 :            :             case FT_NotImpl:
     274         [ #  # ]:          0 :                 DoFunc( ocNoName, 0, pExtString );
     275                 :          0 :                 break;
     276                 :            : 
     277                 :            :             case FT_FuncFix0:
     278         [ #  # ]:          0 :                 DoFunc( eOc, 0, NULL );
     279                 :          0 :                 break;
     280                 :            : 
     281                 :            :             case FT_FuncFix1:
     282         [ #  # ]:          0 :                 DoFunc( eOc, 1, NULL );
     283                 :          0 :                 break;
     284                 :            : 
     285                 :            :             case FT_FuncFix2:
     286         [ #  # ]:          0 :                 DoFunc( eOc, 2, NULL );
     287                 :          0 :                 break;
     288                 :            : 
     289                 :            :             case FT_FuncFix3:
     290         [ #  # ]:          0 :                 DoFunc( eOc, 3, NULL );
     291                 :          0 :                 break;
     292                 :            : 
     293                 :            :             case FT_FuncFix4:
     294         [ #  # ]:          0 :                 DoFunc( eOc, 4, NULL );
     295                 :          0 :                 break;
     296                 :            : 
     297                 :            :             case FT_FuncFix5:
     298         [ #  # ]:          0 :                 DoFunc( eOc, 5, NULL );
     299                 :          0 :                 break;
     300                 :            : 
     301                 :            :             case FT_FuncFix6:
     302         [ #  # ]:          0 :                 DoFunc( eOc, 6, NULL );
     303                 :          0 :                 break;
     304                 :            : 
     305                 :            :             case FT_DLL:{
     306                 :          0 :                 eOc = IndexToDLLId( nDLLArray[ nDLLCount ] );
     307                 :          0 :                 sal_uInt8 nPar = nArgArray[ nArgCount ];
     308         [ #  # ]:          0 :                 DoFunc( eOc, nPar, NULL );
     309                 :          0 :                 nDLLCount++;
     310                 :          0 :                 nArgCount++;
     311                 :            :                 }
     312                 :          0 :                 break;
     313                 :            : 
     314                 :            :             case FT_Cref : // Single cell reference
     315 [ #  # ][ #  # ]:          0 :                 maIn >> nNote >> nCol >> nPage >> nRelBits;
         [ #  # ][ #  # ]
     316                 :          0 :                 ReadSRD( aSRD, nPage, nCol, nRelBits );
     317         [ #  # ]:          0 :                 aStack << aPool.Store( aSRD );
     318                 :          0 :                 break;
     319                 :            : 
     320                 :            :             case FT_Range: // Block reference
     321 [ #  # ][ #  # ]:          0 :                 maIn >> nNote >> nCol >> nPage >> nRelBits;
         [ #  # ][ #  # ]
     322                 :          0 :                 ReadSRD( aCRD.Ref1, nPage, nCol, nRelBits );
     323 [ #  # ][ #  # ]:          0 :                 maIn >> nCol >> nPage >> nRelBits;
                 [ #  # ]
     324                 :          0 :                 ReadSRD( aCRD.Ref2, nPage, nCol, nRelBits );
     325                 :            :                 // Sheet name of second corner is not displayed if identical
     326   [ #  #  #  # ]:          0 :                 if (aCRD.Ref1.IsFlag3D() && aCRD.Ref1.nTab == aCRD.Ref2.nTab &&
         [ #  # ][ #  # ]
     327                 :          0 :                         aCRD.Ref1.IsTabRel() == aCRD.Ref2.IsTabRel())
     328                 :          0 :                     aCRD.Ref2.SetFlag3D( false);
     329         [ #  # ]:          0 :                 aStack << aPool.Store( aCRD );
     330                 :          0 :                 break;
     331                 :            : 
     332                 :            :             case FT_FuncVar:{ // Sum of a sequence of numbers
     333                 :            :                 sal_uInt8 nArgs;
     334                 :          0 :                 i++;
     335                 :          0 :                 nArgs = nFmla[ i ];
     336         [ #  # ]:          0 :                 DoFunc( eOc, nArgs, NULL );
     337                 :            :                 }
     338                 :          0 :                 break;
     339                 :            : 
     340                 :            :             case FT_Op: // operators
     341                 :          0 :                 aStack >> nPush;
     342 [ #  # ][ #  # ]:          0 :                 aPool << aStack << eOc << nPush;
                 [ #  # ]
     343         [ #  # ]:          0 :                 aPool >> aStack;
     344                 :          0 :                 break;
     345                 :            : 
     346                 :            :             case FT_Braces:
     347 [ #  # ][ #  # ]:          0 :                 aPool << ocOpen << aStack << ocClose;
                 [ #  # ]
     348         [ #  # ]:          0 :                 aPool >> aStack;
     349                 :          0 :                 break;
     350                 :            : 
     351                 :            :             case FT_ConstInt:{
     352                 :            :                 sal_uInt16 nVal;
     353                 :          0 :                 nVal = nIntArray[ nIntCount ];
     354         [ #  # ]:          0 :                 aStack << aPool.Store( ( double ) nVal );
     355                 :          0 :                 nIntCount++;
     356                 :            :                 }
     357                 :          0 :                 break;
     358                 :            : 
     359                 :            :             case FT_ConstFloat:{
     360                 :            :                 double nVal;
     361                 :          0 :                 nVal = nFloatArray[ nFloatCount ];
     362         [ #  # ]:          0 :                 aStack << aPool.Store( nVal );
     363                 :          0 :                 nFloatCount++;
     364                 :            :                 }
     365                 :          0 :                 break;
     366                 :            : 
     367                 :            :             case FT_ConstString:{
     368         [ #  # ]:          0 :                 String aLabel;
     369         [ #  # ]:          0 :                 aLabel = sStringArray[ nStringCount ];
     370         [ #  # ]:          0 :                 aStack << aPool.Store( aLabel );
     371         [ #  # ]:          0 :                 nStringCount++;
     372                 :            :                 }
     373                 :          0 :                 break;
     374                 :            : 
     375                 :            :             case FT_Neg:
     376 [ #  # ][ #  # ]:          0 :                 aPool <<  ocNegSub << aStack;
     377         [ #  # ]:          0 :                 aPool >> aStack;
     378                 :          0 :                 break;
     379                 :            : 
     380                 :            :             case FT_NOP:    // indicates invalid opcode.
     381                 :            :             case FT_Return: // indicates end of formula
     382                 :          0 :                 break;
     383                 :            :         }
     384                 :          0 :         i++;
     385                 :            :     }
     386         [ #  # ]:          0 :     pArray = aPool[ aStack.Get() ];
     387 [ +  + ][ #  # ]:        771 :     return ConvOK;
     388                 :            : }
     389                 :            : 
     390                 :            : static const struct
     391                 :            : {
     392                 :            :     DefTokenId nToken;
     393                 :            :     FUNC_TYPE   nType;
     394                 :            : } aFuncMap[] = {
     395                 :            :     { ocPush, FT_ConstFloat },
     396                 :            :     { ocPush, FT_Cref },
     397                 :            :     { ocPush, FT_Range },
     398                 :            :     { ocPush, FT_Return },
     399                 :            :     { ocPush, FT_Braces },
     400                 :            :     { ocPush, FT_ConstInt },
     401                 :            :     { ocPush, FT_ConstString },
     402                 :            :     { ocPush, FT_NOP },
     403                 :            :     { ocNegSub, FT_Neg },                       // 0x08
     404                 :            :     { ocAdd, FT_Op },
     405                 :            :     { ocSub, FT_Op },
     406                 :            :     { ocMul, FT_Op },
     407                 :            :     { ocDiv, FT_Op },
     408                 :            :     { ocPow, FT_Op },
     409                 :            :     { ocEqual, FT_Op },
     410                 :            :     { ocNotEqual, FT_Op },
     411                 :            :     { ocLessEqual, FT_Op },                     // 0x10
     412                 :            :     { ocGreaterEqual, FT_Op },
     413                 :            :     { ocLess, FT_Op },
     414                 :            :     { ocGreater, FT_Op },
     415                 :            :     { ocAnd, FT_Op },
     416                 :            :     { ocOr, FT_Op },
     417                 :            :     { ocNot, FT_FuncFix1 },
     418                 :            :     { ocPush, FT_NOP },     // Unary plus
     419                 :            :     { ocAddress, FT_FuncFix4 }, // Address of
     420                 :            :     { ocNoName, FT_NotImpl }, // Halt function
     421                 :            :     { ocNoName, FT_DLL }, // DLL function
     422                 :            :     { ocNoName, FT_NOP }, // Extended operands
     423                 :            :     { ocNoName, FT_NOP }, // Extended operands
     424                 :            :     { ocNoName, FT_NOP }, // Reserved
     425                 :            :     { ocNoName, FT_NOP }, // Reserved
     426                 :            :     { ocNotAvail, FT_FuncFix0 }, // NA
     427                 :            :     { ocNoName, FT_FuncFix0 }, // Error         // 0x20
     428                 :            :     { ocAbs, FT_FuncFix1 },
     429                 :            :     { ocInt, FT_FuncFix1 },
     430                 :            :     { ocSqrt, FT_FuncFix1 },
     431                 :            :     { ocLog10, FT_FuncFix1 },
     432                 :            :     { ocLn, FT_FuncFix1 },
     433                 :            :     { ocPi, FT_FuncFix0 },
     434                 :            :     { ocSin, FT_FuncFix1 },
     435                 :            :     { ocCos, FT_FuncFix1 },
     436                 :            :     { ocTan, FT_FuncFix1 },
     437                 :            :     { ocArcTan2, FT_FuncFix2 },
     438                 :            :     { ocArcTan, FT_FuncFix1 },
     439                 :            :     { ocArcSin, FT_FuncFix1 },
     440                 :            :     { ocArcCos, FT_FuncFix1 },
     441                 :            :     { ocExp, FT_FuncFix1 },
     442                 :            :     { ocMod, FT_FuncFix2 },
     443                 :            :     { ocChose, FT_FuncVar },                    // 0x30
     444                 :            :     { ocIsNA, FT_FuncFix1 },
     445                 :            :     { ocIsError, FT_FuncFix1 },
     446                 :            :     { ocFalse, FT_FuncFix0 },
     447                 :            :     { ocTrue, FT_FuncFix0 },
     448                 :            :     { ocRandom, FT_FuncFix0 },
     449                 :            :     { ocGetDate, FT_FuncFix3 },
     450                 :            :     { ocGetActTime, FT_FuncFix0 },
     451                 :            :     { ocNoName, FT_NotImpl },    // QPro Pmt
     452                 :            :     { ocNoName, FT_NotImpl },    // QPro Pv
     453                 :            :     { ocNoName, FT_NotImpl },    // QPro Fv
     454                 :            :     { ocIf, FT_FuncFix3 },
     455                 :            :     { ocGetDay, FT_FuncFix1 },
     456                 :            :     { ocGetMonth, FT_FuncFix1 },
     457                 :            :     { ocGetYear, FT_FuncFix1 },
     458                 :            :     { ocRound, FT_FuncFix2 },
     459                 :            :     { ocGetTime, FT_FuncFix3 },                  // 0x40
     460                 :            :     { ocGetHour, FT_FuncFix1 },
     461                 :            :     { ocGetMin, FT_FuncFix1 },
     462                 :            :     { ocGetSec, FT_FuncFix1 },
     463                 :            :     { ocIsValue, FT_FuncFix1 },
     464                 :            :     { ocIsString, FT_FuncFix1 },
     465                 :            :     { ocLen, FT_FuncFix1 },
     466                 :            :     { ocValue, FT_FuncFix1 },
     467                 :            :     { ocFixed, FT_FuncFix2 },
     468                 :            :     { ocMid, FT_FuncFix3 },
     469                 :            :     { ocChar, FT_FuncFix1 },
     470                 :            :     { ocCode, FT_FuncFix1 },
     471                 :            :     { ocFind, FT_FuncFix3 },
     472                 :            :     { ocGetDateValue, FT_FuncFix1 },
     473                 :            :     { ocGetTimeValue, FT_FuncFix1 },
     474                 :            :     { ocNoName, FT_NotImpl },
     475                 :            :     { ocSum, FT_FuncVar },                     // 0x50
     476                 :            :     { ocAverage, FT_FuncVar },
     477                 :            :     { ocCount, FT_FuncVar },
     478                 :            :     { ocMin, FT_FuncVar },
     479                 :            :     { ocMax, FT_FuncVar },
     480                 :            :     { ocVLookup, FT_FuncFix3 },
     481                 :            :     { ocNPV, FT_FuncFix2 },
     482                 :            :     { ocVar, FT_FuncVar },
     483                 :            :     { ocNormDist, FT_FuncVar },
     484                 :            :     { ocIRR, FT_FuncFix2 },
     485                 :            :     { ocHLookup, FT_FuncFix3 },
     486                 :            :     { ocDBSum, FT_FuncFix3 },
     487                 :            :     { ocDBAverage, FT_FuncFix3 },
     488                 :            :     { ocDBCount, FT_FuncFix3 },
     489                 :            :     { ocDBMin, FT_FuncFix3 },
     490                 :            :     { ocDBMax, FT_FuncFix3 },
     491                 :            :     { ocDBVar, FT_FuncFix3 },                 // 0x60
     492                 :            :     { ocDBStdDev, FT_FuncFix3 },
     493                 :            :     { ocNoName, FT_NotImpl },
     494                 :            :     { ocColumns, FT_FuncFix1 },
     495                 :            :     { ocRows, FT_FuncFix1 },
     496                 :            :     { ocRept, FT_FuncFix2 },
     497                 :            :     { ocUpper, FT_FuncFix1 },
     498                 :            :     { ocLower, FT_FuncFix1 },
     499                 :            :     { ocLeft, FT_FuncFix2 },
     500                 :            :     { ocRight, FT_FuncFix2 },
     501                 :            :     { ocReplace, FT_FuncFix4 },
     502                 :            :     { ocPropper, FT_FuncFix1 },
     503                 :            :     { ocCell, FT_FuncFix2 },
     504                 :            :     { ocTrim, FT_FuncFix1 },
     505                 :            :     { ocClean, FT_FuncFix1 },
     506                 :            :     { ocNoName, FT_NotImpl },
     507                 :            :     { ocNoName, FT_NotImpl },               // 0x70
     508                 :            :     { ocExact, FT_FuncFix2 },
     509                 :            :     { ocNoName, FT_NotImpl }, // Call()
     510                 :            :     { ocIndirect, FT_FuncFix1 },
     511                 :            :     { ocZGZ, FT_FuncFix3 }, // Interest
     512                 :            :     { ocNoName, FT_NotImpl },
     513                 :            :     { ocNoName, FT_NotImpl },
     514                 :            :     { ocLIA, FT_FuncFix3 },
     515                 :            :     { ocDIA, FT_FuncFix4 },
     516                 :            :     { ocGDA, FT_FuncFix4 },
     517                 :            :     { ocStDevP, FT_FuncVar },
     518                 :            :     { ocVarP, FT_FuncVar },
     519                 :            :     { ocDBStdDevP, FT_FuncVar },
     520                 :            :     { ocDBVarP, FT_FuncVar },
     521                 :            :     { ocBW, FT_FuncFix3 },  // QPro Pval
     522                 :            :     { ocRMZ, FT_FuncFix5 }, // QPro Paymt
     523                 :            :     { ocZW, FT_FuncFix3 },  // QPro Fval   // 0x80
     524                 :            :     { ocZZR, FT_FuncFix5 },
     525                 :            :     { ocZins, FT_FuncFix5 },
     526                 :            :     { ocZinsZ, FT_FuncFix4 },
     527                 :            :     { ocKapz, FT_FuncFix6 },
     528                 :            :     { ocSumProduct, FT_FuncFix2 },
     529                 :            :     { ocNoName, FT_NotImpl },
     530                 :            :     { ocNoName, FT_NotImpl },
     531                 :            :     { ocNoName, FT_NotImpl },
     532                 :            :     { ocNoName, FT_NotImpl },
     533                 :            :     { ocDeg, FT_FuncFix1 },
     534                 :            :     { ocRad, FT_FuncFix1 },
     535                 :            :     { ocNoName, FT_NotImpl },
     536                 :            :     { ocNoName, FT_NotImpl },
     537                 :            :     { ocGetActDate, FT_FuncFix0 },
     538                 :            :     { ocNPV, FT_FuncFix2 },
     539                 :            :     { ocNoName, FT_NotImpl },                // 0x90
     540                 :            :     { ocNoName, FT_NotImpl },
     541                 :            :     { ocNoName, FT_NOP },
     542                 :            :     { ocNoName, FT_NOP }, // 147
     543                 :            :     { ocNoName, FT_NOP }, // 148
     544                 :            :     { ocNoName, FT_NOP }, // 149
     545                 :            :     { ocNoName, FT_NOP }, // 150
     546                 :            :     { ocNoName, FT_NOP }, // 151
     547                 :            :     { ocNoName, FT_NOP }, // 152
     548                 :            :     { ocNoName, FT_NOP }, // 153
     549                 :            :     { ocTable, FT_FuncFix1 },
     550                 :            :     { ocNoName, FT_NOP }, // 155 - opcodes do not represent any function.
     551                 :            :     { ocNoName, FT_NOP }, // 156
     552                 :            :     { ocIndex,  FT_FuncFix4 },
     553                 :            :     { ocNoName, FT_NotImpl },
     554                 :            :     { ocNoName, FT_NotImpl }, // Gives the property of the particular object
     555                 :            :     { ocNoName, FT_NotImpl },  // Dynamic Data Exchange Link // 0x100
     556                 :            :     { ocNoName, FT_NotImpl }   // gives properties of DOS menus
     557                 :            : };
     558                 :            : 
     559                 :            : const int nIndexCount = sizeof( aFuncMap ) / sizeof( aFuncMap[ 0 ] );
     560                 :            : 
     561                 :          0 : DefTokenId QProToSc::IndexToToken( sal_uInt16 nIndex )
     562                 :            : {
     563         [ #  # ]:          0 :     if( nIndex < nIndexCount )
     564                 :          0 :         return aFuncMap[ nIndex ].nToken;
     565                 :          0 :     return ocNoName;
     566                 :            : }
     567                 :            : 
     568                 :          0 : FUNC_TYPE QProToSc::IndexToType( sal_uInt8 nIndex )
     569                 :            : {
     570         [ #  # ]:          0 :     if( nIndex < nIndexCount )
     571                 :          0 :         return aFuncMap[ nIndex ].nType;
     572                 :          0 :     return FT_NotImpl;
     573                 :            : }
     574                 :            : 
     575                 :          0 : DefTokenId QProToSc::IndexToDLLId( sal_uInt16 nIndex )
     576                 :            : {
     577                 :            :     DefTokenId eId;
     578   [ #  #  #  #  :          0 :     switch( nIndex )
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
     579                 :            :     {
     580                 :            :         case 0x0001:
     581                 :          0 :             eId = ocAveDev;
     582                 :          0 :             break;
     583                 :            : 
     584                 :            :         case 0x0024:
     585                 :          0 :             eId = ocGCD;
     586                 :          0 :             break;
     587                 :            : 
     588                 :            :         case 0x0025:
     589                 :          0 :             eId = ocLCM;
     590                 :          0 :             break;
     591                 :            : 
     592                 :            :         case 0x0027:
     593                 :          0 :             eId = ocCeil;
     594                 :          0 :             break;
     595                 :            : 
     596                 :            :         case 0x0028:
     597                 :          0 :             eId = ocEven;
     598                 :          0 :             break;
     599                 :            : 
     600                 :            :         case 0x0022:
     601                 :          0 :             eId = ocFact;
     602                 :          0 :             break;
     603                 :            : 
     604                 :            :         case 0x002a:
     605                 :          0 :             eId = ocFloor;
     606                 :          0 :             break;
     607                 :            : 
     608                 :            :         case 0x002d:
     609                 :          0 :             eId = ocOdd;
     610                 :          0 :             break;
     611                 :            : 
     612                 :            :         case 0x0006:
     613                 :          0 :             eId = ocBetaDist;
     614                 :          0 :             break;
     615                 :            : 
     616                 :            :         case 0x0008:
     617                 :          0 :             eId = ocBetaInv;
     618                 :          0 :             break;
     619                 :            : 
     620                 :            :         case 0x0010:
     621                 :          0 :             eId = ocCovar;
     622                 :          0 :             break;
     623                 :            : 
     624                 :            :         case 0x000b:
     625                 :          0 :             eId = ocChiInv;
     626                 :          0 :             break;
     627                 :            : 
     628                 :            :         case 0x003d:
     629                 :          0 :             eId = ocLaufz;
     630                 :          0 :             break;
     631                 :            : 
     632                 :            :         case 0x0019:
     633                 :          0 :             eId = ocFInv;
     634                 :          0 :             break;
     635                 :            : 
     636                 :            :         case 0x001a:
     637                 :          0 :             eId = ocFisher;
     638                 :          0 :             break;
     639                 :            : 
     640                 :            :         case 0x001b:
     641                 :          0 :             eId = ocFisherInv;
     642                 :          0 :             break;
     643                 :            : 
     644                 :            :         case 0x0030:
     645                 :          0 :             eId = ocMedian;
     646                 :          0 :             break;
     647                 :            : 
     648                 :            :         default:
     649                 :          0 :             eId = ocNoName;
     650                 :          0 :             break;
     651                 :            :     }
     652                 :          0 :     return eId;
     653                 :            : }
     654                 :            : 
     655                 :          0 : const sal_Char* QProToSc::getString( sal_uInt8 nIndex )
     656                 :            : {
     657                 :          0 :     const sal_Char* pExtString = 0;
     658   [ #  #  #  #  :          0 :     switch( nIndex )
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     659                 :            :     {
     660                 :            :         case 57:
     661                 :          0 :             pExtString = "Pv";
     662                 :          0 :             break;
     663                 :            : 
     664                 :            :         case 58:
     665                 :          0 :             pExtString = "Fv";
     666                 :          0 :             break;
     667                 :            : 
     668                 :            :         case 98:
     669                 :          0 :             pExtString = "Index2D";
     670                 :          0 :             break;
     671                 :            : 
     672                 :            :         case 111:
     673                 :          0 :             pExtString = "S";
     674                 :          0 :             break;
     675                 :            : 
     676                 :            :         case 112:
     677                 :          0 :             pExtString = "N";
     678                 :          0 :             break;
     679                 :            : 
     680                 :            :         case 114:
     681                 :          0 :             pExtString = "CALL";
     682                 :          0 :             break;
     683                 :            : 
     684                 :            :         case 117:
     685                 :          0 :             pExtString = "TERM";
     686                 :          0 :             break;
     687                 :            : 
     688                 :            :         case 118:
     689                 :          0 :             pExtString = "CTERM";
     690                 :          0 :             break;
     691                 :            : 
     692                 :            :         case 134:
     693                 :          0 :             pExtString = "MEMAVAIL";
     694                 :          0 :             break;
     695                 :            : 
     696                 :            :         case 135:
     697                 :          0 :             pExtString = "MEMEMSAVAIL";
     698                 :          0 :             break;
     699                 :            : 
     700                 :            :         case 136:
     701                 :          0 :             pExtString = "FILEEXISTS";
     702                 :          0 :             break;
     703                 :            : 
     704                 :            :         case 137:
     705                 :          0 :             pExtString = "CURVALUE";
     706                 :          0 :             break;
     707                 :            : 
     708                 :            :         case 140:
     709                 :          0 :             pExtString = "HEX";
     710                 :          0 :             break;
     711                 :            : 
     712                 :            :         case 141:
     713                 :          0 :             pExtString = "NUM";
     714                 :          0 :             break;
     715                 :            : 
     716                 :            :         case 145:
     717                 :          0 :             pExtString = "VERSION";
     718                 :          0 :             break;
     719                 :            : 
     720                 :            :         case 157:
     721                 :          0 :             pExtString = "INDEX3D";
     722                 :          0 :             break;
     723                 :            : 
     724                 :            :         case 158:
     725                 :          0 :             pExtString = "CELLINDEX3D";
     726                 :          0 :             break;
     727                 :            : 
     728                 :            :         case 159:
     729                 :          0 :             pExtString = "PROPERTY";
     730                 :          0 :             break;
     731                 :            : 
     732                 :            :         case 160:
     733                 :          0 :             pExtString = "DDE";
     734                 :          0 :             break;
     735                 :            : 
     736                 :            :         case 161:
     737                 :          0 :             pExtString = "COMMAND";
     738                 :          0 :             break;
     739                 :            : 
     740                 :            :         default:
     741                 :          0 :             pExtString = NULL;
     742                 :          0 :             break;
     743                 :            :     }
     744                 :          0 :     return pExtString;
     745                 :            : }
     746                 :            : 
     747                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10