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

Generated by: LCOV version 1.10