LCOV - code coverage report
Current view: top level - sc/source/core/inc - interpre.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 61 82 74.4 %
Date: 2012-08-25 Functions: 27 32 84.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 39 64 60.9 %

           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                 :            : #ifndef SC_INTERPRE_HXX
      30                 :            : #define SC_INTERPRE_HXX
      31                 :            : 
      32                 :            : #include <math.h>
      33                 :            : #include <rtl/math.hxx>
      34                 :            : #include <rtl/ustring.hxx>
      35                 :            : #include "formula/errorcodes.hxx"
      36                 :            : #include "cell.hxx"
      37                 :            : #include "scdll.hxx"
      38                 :            : #include "document.hxx"
      39                 :            : #include "scmatrix.hxx"
      40                 :            : #include "externalrefmgr.hxx"
      41                 :            : #include "calcconfig.hxx"
      42                 :            : 
      43                 :            : #include <math.h>
      44                 :            : #include <map>
      45                 :            : 
      46                 :            : class ScDocument;
      47                 :            : class SbxVariable;
      48                 :            : class ScBaseCell;
      49                 :            : class ScFormulaCell;
      50                 :            : class SvNumberFormatter;
      51                 :            : class ScDBRangeBase;
      52                 :            : struct ScQueryParam;
      53                 :            : struct ScDBQueryParamBase;
      54                 :            : struct ScQueryEntry;
      55                 :            : 
      56                 :            : struct ScCompare;
      57                 :            : struct ScCompareOptions;
      58                 :            : 
      59                 :            : class ScToken;
      60                 :            : 
      61                 :            : #define MAXSTACK      (4096 / sizeof(formula::FormulaToken*))
      62                 :            : 
      63                 :            : class ScTokenStack
      64                 :            : {
      65                 :            : public:
      66 [ +  - ][ +  - ]:        686 :     DECL_FIXEDMEMPOOL_NEWDEL( ScTokenStack )
      67                 :            :     formula::FormulaToken* pPointer[ MAXSTACK ];
      68                 :            : };
      69                 :            : 
      70                 :            : enum ScIterFunc {
      71                 :            :     ifSUM,                              // Add up
      72                 :            :     ifSUMSQ,                            // Sums of squares
      73                 :            :     ifPRODUCT,                          // Product
      74                 :            :     ifAVERAGE,                          // Average
      75                 :            :     ifCOUNT,                            // Count Values
      76                 :            :     ifCOUNT2,                           // Count Values (not empty)
      77                 :            :     ifMIN,                              // Minimum
      78                 :            :     ifMAX                               // Maximum
      79                 :            : };
      80                 :            : 
      81                 :            : struct FormulaTokenRef_less
      82                 :            : {
      83                 :        678 :     bool operator () ( const formula::FormulaConstTokenRef& r1, const formula::FormulaConstTokenRef& r2 ) const
      84                 :        678 :         { return r1.get() < r2.get(); }
      85                 :            : };
      86                 :            : typedef ::std::map< const formula::FormulaConstTokenRef, formula::FormulaTokenRef, FormulaTokenRef_less> ScTokenMatrixMap;
      87                 :            : 
      88                 :            : class ScInterpreter
      89                 :            : {
      90                 :            :     // distibution function objects need the GetxxxDist methods
      91                 :            :     friend class ScGammaDistFunction;
      92                 :            :     friend class ScBetaDistFunction;
      93                 :            :     friend class ScTDistFunction;
      94                 :            :     friend class ScFDistFunction;
      95                 :            :     friend class ScChiDistFunction;
      96                 :            :     friend class ScChiSqDistFunction;
      97                 :            : 
      98                 :            : public:
      99                 :            : 
     100 [ +  - ][ +  - ]:       5238 :     DECL_FIXEDMEMPOOL_NEWDEL( ScInterpreter )
     101                 :            : 
     102                 :            :     static void SetGlobalConfig(const ScCalcConfig& rConfig);
     103                 :            :     static const ScCalcConfig& GetGlobalConfig();
     104                 :            : 
     105                 :            :     static void GlobalExit();           // aus ScGlobal::Clear() gerufen
     106                 :            : 
     107                 :            :     /// Could string be a regular expression?
     108                 :            :     /// If pDoc!=NULL the document options are taken into account and if
     109                 :            :     /// RegularExpressions are disabled the function returns false regardless
     110                 :            :     /// of the string content.
     111                 :            :     static bool MayBeRegExp( const OUString& rStr, const ScDocument* pDoc );
     112                 :            : 
     113                 :            :     /// Fail safe division, returning an errDivisionByZero coded into a double
     114                 :            :     /// if denominator is 0.0
     115                 :            :     static inline double div( const double& fNumerator, const double& fDenominator );
     116                 :            : 
     117                 :            :     ScMatrixRef GetNewMat(SCSIZE nC, SCSIZE nR, bool bEmpty = false);
     118                 :            : 
     119                 :            :     enum VolatileType {
     120                 :            :         VOLATILE,
     121                 :            :         VOLATILE_MACRO,
     122                 :            :         NOT_VOLATILE
     123                 :            :     };
     124                 :            : 
     125                 :            :     VolatileType GetVolatileType() const;
     126                 :            : 
     127                 :            : private:
     128                 :            :     static ScCalcConfig maGlobalConfig;
     129                 :            : 
     130                 :            :     static ScTokenStack*    pGlobalStack;
     131                 :            :     static bool             bGlobalStackInUse;
     132                 :            : 
     133                 :            :     formula::FormulaTokenIterator aCode;
     134                 :            :     ScAddress   aPos;
     135                 :            :     ScTokenArray& rArr;
     136                 :            :     ScDocument* pDok;
     137                 :            :     formula::FormulaTokenRef  xResult;
     138                 :            :     ScJumpMatrix*   pJumpMatrix;        // currently active array condition, if any
     139                 :            :     ScTokenMatrixMap* pTokenMatrixMap;  // map ScToken* to formula::FormulaTokenRef if in array condition
     140                 :            :     ScFormulaCell* pMyFormulaCell;      // the cell of this formula expression
     141                 :            :     SvNumberFormatter* pFormatter;
     142                 :            : 
     143                 :            :     const formula::FormulaToken*
     144                 :            :                 pCur;                   // current token
     145                 :            :     String      aTempStr;               // for GetString()
     146                 :            :     ScTokenStack* pStackObj;            // contains the stacks
     147                 :            :     formula::FormulaToken**   pStack;   // the current stack
     148                 :            :     sal_uInt16  nGlobalError;           // global (local to this formula expression) error
     149                 :            :     sal_uInt16  sp;                     // stack pointer
     150                 :            :     sal_uInt16  maxsp;                  // the maximal used stack pointer
     151                 :            :     sal_uLong   nFuncFmtIndex;          // NumberFormatIndex of a function
     152                 :            :     sal_uLong   nCurFmtIndex;           // current NumberFormatIndex
     153                 :            :     sal_uLong   nRetFmtIndex;           // NumberFormatIndex of an expression, if any
     154                 :            :     short       nFuncFmtType;           // NumberFormatType of a function
     155                 :            :     short       nCurFmtType;            // current NumberFormatType
     156                 :            :     short       nRetFmtType;            // NumberFormatType of an expression
     157                 :            :     sal_uInt16  mnStringNoValueError;   // the error set in ConvertStringToValue() if no value
     158                 :            :     bool        glSubTotal;             // flag for subtotal functions
     159                 :            :     sal_uInt8   cPar;                   // current count of parameters
     160                 :            :     bool        bCalcAsShown;           // precision as shown
     161                 :            :     bool        bMatrixFormula;         // formula cell is a matrix formula
     162                 :            : 
     163                 :            :     VolatileType meVolatileType;
     164                 :            : 
     165                 :            : //---------------------------------Funktionen in interpre.cxx---------
     166                 :            : // nMust <= nAct <= nMax ? ok : PushError
     167                 :            : inline bool MustHaveParamCount( short nAct, short nMust );
     168                 :            : inline bool MustHaveParamCount( short nAct, short nMust, short nMax );
     169                 :            : inline bool MustHaveParamCountMin( short nAct, short nMin );
     170                 :            : void PushParameterExpected();
     171                 :            : void PushIllegalParameter();
     172                 :            : void PushIllegalArgument();
     173                 :            : void PushNoValue();
     174                 :            : void PushNA();
     175                 :            : //-------------------------------------------------------------------------
     176                 :            : // Funktionen fuer den Zugriff auf das Document
     177                 :            : //-------------------------------------------------------------------------
     178                 :            : void ReplaceCell( ScAddress& );     // for TableOp
     179                 :            : void ReplaceCell( SCCOL& rCol, SCROW& rRow, SCTAB& rTab );  // for TableOp
     180                 :            : bool IsTableOpInRange( const ScRange& );
     181                 :            : sal_uLong GetCellNumberFormat( const ScAddress&, const ScBaseCell* );
     182                 :            : double ConvertStringToValue( const String& );
     183                 :            : double GetCellValue( const ScAddress&, const ScBaseCell* );
     184                 :            : double GetCellValueOrZero( const ScAddress&, const ScBaseCell* );
     185                 :            : double GetValueCellValue( const ScAddress&, const ScValueCell* );
     186                 :       2149 : ScBaseCell* GetCell( const ScAddress& rPos )
     187                 :       2149 :     { return pDok->GetCell( rPos ); }
     188                 :            : void GetCellString( String& rStr, const ScBaseCell* pCell );
     189                 :         72 : inline sal_uInt16 GetCellErrCode( const ScBaseCell* pCell )
     190         [ +  - ]:         72 :     { return pCell ? pCell->GetErrorCode() : 0; }
     191                 :        135 : inline CellType GetCellType( const ScBaseCell* pCell )
     192         [ +  - ]:        135 :     { return pCell ? pCell->GetCellType() : CELLTYPE_NONE; }
     193                 :            : /// Really empty or inherited emptiness.
     194                 :        286 : inline bool HasCellEmptyData( const ScBaseCell* pCell )
     195         [ +  - ]:        286 :     { return pCell ? pCell->HasEmptyData() : true; }
     196                 :            : /// This includes inherited emptiness, which usually is regarded as value!
     197                 :        453 : inline bool HasCellValueData( const ScBaseCell* pCell )
     198         [ +  - ]:        453 :     { return pCell ? pCell->HasValueData() : false; }
     199                 :            : /// Not empty and not value.
     200                 :         99 : inline bool HasCellStringData( const ScBaseCell* pCell )
     201         [ +  - ]:         99 :     { return pCell ? pCell->HasStringData() : false; }
     202                 :            : 
     203                 :            : bool CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     204                 :            :                      SCCOL nCol2, SCROW nRow2, SCTAB nTab2, sal_uInt8* pCellArr);
     205                 :            : bool CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     206                 :            :                      SCCOL nCol2, SCROW nRow2, SCTAB nTab2, sal_uInt8* pCellArr);
     207                 :            : bool CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     208                 :            :                    SCCOL nCol2, SCROW nRow2, SCTAB nTab2, sal_uInt8* pCellArr);
     209                 :            : 
     210                 :            : //-----------------------------------------------------------------------------
     211                 :            : // Stack operations
     212                 :            : //-----------------------------------------------------------------------------
     213                 :            : 
     214                 :            : /** Does substitute with formula::FormulaErrorToken in case nGlobalError is set and the token
     215                 :            :     passed is not formula::FormulaErrorToken.
     216                 :            :     Increments RefCount of the original token if not substituted. */
     217                 :            : void Push( formula::FormulaToken& r );
     218                 :            : 
     219                 :            : /** Does not substitute with formula::FormulaErrorToken in case nGlobalError is set.
     220                 :            :     Used to push RPN tokens or from within Push() or tokens that are already
     221                 :            :     explicit formula::FormulaErrorToken. Increments RefCount. */
     222                 :            : void PushWithoutError( formula::FormulaToken& r );
     223                 :            : 
     224                 :            : /** Clones the token to be pushed or substitutes with formula::FormulaErrorToken if
     225                 :            :     nGlobalError is set and the token passed is not formula::FormulaErrorToken. */
     226                 :            : void PushTempToken( const formula::FormulaToken& );
     227                 :            : 
     228                 :            : /** Does substitute with formula::FormulaErrorToken in case nGlobalError is set and the token
     229                 :            :     passed is not formula::FormulaErrorToken.
     230                 :            :     Increments RefCount of the original token if not substituted.
     231                 :            :     ATTENTION! The token had to be allocated with `new' and must not be used
     232                 :            :     after this call if no RefCount was set because possibly it gets immediately
     233                 :            :     deleted in case of an errStackOverflow or if substituted with formula::FormulaErrorToken! */
     234                 :            : void PushTempToken( formula::FormulaToken* );
     235                 :            : 
     236                 :            : /** Does not substitute with formula::FormulaErrorToken in case nGlobalError is set.
     237                 :            :     Used to push tokens from within PushTempToken() or tokens that are already
     238                 :            :     explicit formula::FormulaErrorToken. Increments RefCount.
     239                 :            :     ATTENTION! The token had to be allocated with `new' and must not be used
     240                 :            :     after this call if no RefCount was set because possibly it gets immediately
     241                 :            :     decremented again and thus deleted in case of an errStackOverflow! */
     242                 :            : void PushTempTokenWithoutError( formula::FormulaToken* );
     243                 :            : 
     244                 :            : /** If nGlobalError is set push formula::FormulaErrorToken.
     245                 :            :     If nGlobalError is not set do nothing.
     246                 :            :     Used in PushTempToken() and alike to simplify handling.
     247                 :            :     @return: <TRUE/> if nGlobalError. */
     248                 :       2628 : inline bool IfErrorPushError()
     249                 :            : {
     250         [ +  + ]:       2628 :     if (nGlobalError)
     251                 :            :     {
     252         [ +  - ]:         27 :         PushTempTokenWithoutError( new formula::FormulaErrorToken( nGlobalError));
     253                 :         27 :         return true;
     254                 :            :     }
     255                 :       2628 :     return false;
     256                 :            : }
     257                 :            : 
     258                 :            : /** Obtain cell result / content from address and push as temp token.
     259                 :            :     bDisplayEmptyAsString is passed to ScEmptyCell in case of an empty cell
     260                 :            :     result. Also obtain number format and type if _both_, type and index
     261                 :            :     pointer, are not NULL. */
     262                 :            : void PushCellResultToken( bool bDisplayEmptyAsString, const ScAddress & rAddress,
     263                 :            :         short * pRetTypeExpr, sal_uLong * pRetIndexExpr );
     264                 :            : 
     265                 :            : formula::FormulaTokenRef PopToken();
     266                 :            : void Pop();
     267                 :            : void PopError();
     268                 :            : double PopDouble();
     269                 :            : const String& PopString();
     270                 :            : void ValidateRef( const ScSingleRefData & rRef );
     271                 :            : void ValidateRef( const ScComplexRefData & rRef );
     272                 :            : void ValidateRef( const ScRefList & rRefList );
     273                 :            : void SingleRefToVars( const ScSingleRefData & rRef, SCCOL & rCol, SCROW & rRow, SCTAB & rTab );
     274                 :            : void PopSingleRef( ScAddress& );
     275                 :            : void PopSingleRef(SCCOL& rCol, SCROW &rRow, SCTAB& rTab);
     276                 :            : void DoubleRefToRange( const ScComplexRefData&, ScRange&, bool bDontCheckForTableOp = false );
     277                 :            : /** If formula::StackVar formula::svDoubleRef pop ScDoubleRefToken and return values of
     278                 :            :     ScComplexRefData.
     279                 :            :     Else if StackVar svRefList return values of the ScComplexRefData where
     280                 :            :     rRefInList is pointing to. rRefInList is incremented. If rRefInList was the
     281                 :            :     last element in list pop ScRefListToken and set rRefInList to 0, else
     282                 :            :     rParam is incremented (!) to allow usage as in
     283                 :            :     while(nParamCount--) PopDoubleRef(aRange,nParamCount,nRefInList);
     284                 :            :   */
     285                 :            : void PopDoubleRef( ScRange & rRange, short & rParam, size_t & rRefInList );
     286                 :            : void PopDoubleRef( ScRange&, bool bDontCheckForTableOp = false );
     287                 :            : void DoubleRefToVars( const ScToken* p,
     288                 :            :         SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1,
     289                 :            :         SCCOL& rCol2, SCROW &rRow2, SCTAB& rTab2,
     290                 :            :         bool bDontCheckForTableOp = false );
     291                 :            : ScDBRangeBase* PopDBDoubleRef();
     292                 :            : void PopDoubleRef(SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1,
     293                 :            :                           SCCOL& rCol2, SCROW &rRow2, SCTAB& rTab2,
     294                 :            :                           bool bDontCheckForTableOp = false );
     295                 :            : void PopExternalSingleRef(sal_uInt16& rFileId, String& rTabName, ScSingleRefData& rRef);
     296                 :            : void PopExternalSingleRef(ScExternalRefCache::TokenRef& rToken, ScExternalRefCache::CellFormat* pFmt = NULL);
     297                 :            : void PopExternalSingleRef(sal_uInt16& rFileId, String& rTabName, ScSingleRefData& rRef,
     298                 :            :                           ScExternalRefCache::TokenRef& rToken, ScExternalRefCache::CellFormat* pFmt = NULL);
     299                 :            : void PopExternalDoubleRef(sal_uInt16& rFileId, String& rTabName, ScComplexRefData& rRef);
     300                 :            : void PopExternalDoubleRef(ScExternalRefCache::TokenArrayRef& rArray);
     301                 :            : void PopExternalDoubleRef(ScMatrixRef& rMat);
     302                 :            : void GetExternalDoubleRef(sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& aData, ScExternalRefCache::TokenArrayRef& rArray);
     303                 :            : bool PopDoubleRefOrSingleRef( ScAddress& rAdr );
     304                 :            : void PopDoubleRefPushMatrix();
     305                 :            : // If MatrixFormula: convert formula::svDoubleRef to svMatrix, create JumpMatrix.
     306                 :            : // Else convert area reference parameters marked as ForceArray to array.
     307                 :            : // Returns true if JumpMatrix created.
     308                 :            : bool ConvertMatrixParameters();
     309                 :            : inline void MatrixDoubleRefToMatrix();      // if MatrixFormula: PopDoubleRefPushMatrix
     310                 :            : // If MatrixFormula or ForceArray: ConvertMatrixParameters()
     311                 :            : inline bool MatrixParameterConversion();
     312                 :            : ScMatrixRef PopMatrix();
     313                 :            : void QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_uLong& rRetIndexExpr);
     314                 :            : //void PushByte(BYTE nVal);
     315                 :            : void PushDouble(double nVal);
     316                 :            : void PushInt( int nVal );
     317                 :            : void PushStringBuffer( const sal_Unicode* pString );
     318                 :            : void PushString( const String& rString );
     319                 :            : void PushSingleRef(SCCOL nCol, SCROW nRow, SCTAB nTab);
     320                 :            : void PushDoubleRef(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     321                 :            :                    SCCOL nCol2, SCROW nRow2, SCTAB nTab2);
     322                 :            : void PushExternalSingleRef(sal_uInt16 nFileId, const String& rTabName,
     323                 :            :                            SCCOL nCol, SCROW nRow, SCTAB nTab);
     324                 :            : void PushExternalDoubleRef(sal_uInt16 nFileId, const String& rTabName,
     325                 :            :                            SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     326                 :            :                            SCCOL nCol2, SCROW nRow2, SCTAB nTab2);
     327                 :            : void PushMatrix(const ScMatrixRef& pMat);
     328                 :            : void PushError( sal_uInt16 nError );
     329                 :            : /// Raw stack type without default replacements.
     330                 :            : formula::StackVar GetRawStackType();
     331                 :            : /// Stack type with replacement of defaults, e.g. svMissing and formula::svEmptyCell will result in formula::svDouble.
     332                 :            : formula::StackVar GetStackType();
     333                 :            : // peek StackType of Parameter, Parameter 1 == TOS, 2 == TOS-1, ...
     334                 :            : formula::StackVar GetStackType( sal_uInt8 nParam );
     335                 :       1154 : sal_uInt8 GetByte() { return cPar; }
     336                 :            : // generiert aus DoubleRef positionsabhaengige SingleRef
     337                 :            : bool DoubleRefToPosSingleRef( const ScRange& rRange, ScAddress& rAdr );
     338                 :            : double GetDoubleFromMatrix(const ScMatrixRef& pMat);
     339                 :            : double GetDouble();
     340                 :            : double GetDoubleWithDefault(double nDefault);
     341                 :            : bool IsMissing();
     342                 :        117 : bool GetBool() { return GetDouble() != 0.0; }
     343                 :            : const String& GetString();
     344                 :            : const String& GetStringFromMatrix(const ScMatrixRef& pMat);
     345                 :            : // pop matrix and obtain one element, upper left or according to jump matrix
     346                 :            : ScMatValType GetDoubleOrStringFromMatrix( double& rDouble, String& rString );
     347                 :            : ScMatrixRef CreateMatrixFromDoubleRef( const formula::FormulaToken* pToken,
     348                 :            :         SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     349                 :            :         SCCOL nCol2, SCROW nRow2, SCTAB nTab2 );
     350                 :            : inline ScTokenMatrixMap& GetTokenMatrixMap();
     351                 :            : ScTokenMatrixMap* CreateTokenMatrixMap();
     352                 :            : ScMatrixRef GetMatrix();
     353                 :            : void ScTableOp();                                       // Mehrfachoperationen
     354                 :            : void ScErrCell();                                       // Sonderbehandlung
     355                 :            :                                                         // Fehlerzelle
     356                 :            : //-----------------------------allgemeine Hilfsfunktionen
     357                 :            : void SetMaxIterationCount(sal_uInt16 n);
     358                 :          0 : inline void CurFmtToFuncFmt()
     359                 :          0 :     { nFuncFmtType = nCurFmtType; nFuncFmtIndex = nCurFmtIndex; }
     360                 :            : // Check for String overflow of rResult+rAdd and set error and erase rResult
     361                 :            : // if so. Return true if ok, false if overflow
     362                 :            : inline bool CheckStringResultLen( String& rResult, const String& rAdd );
     363                 :            : // Set error according to rVal, and set rVal to 0.0 if there was an error.
     364                 :            : inline void TreatDoubleError( double& rVal );
     365                 :            : // Lookup using ScLookupCache, @returns true if found and result address
     366                 :            : bool LookupQueryWithCache( ScAddress & o_rResultPos,
     367                 :            :         const ScQueryParam & rParam ) const;
     368                 :            : 
     369                 :            : //---------------------------------Funktionen in interpr1.cxx---------
     370                 :            : void ScIfJump();
     371                 :            : void ScChoseJump();
     372                 :            : 
     373                 :            : // Be sure to only call this if pStack[sp-nStackLevel] really contains a
     374                 :            : // ScJumpMatrixToken, no further checks are applied!
     375                 :            : // Returns true if last jump was executed and result matrix pushed.
     376                 :            : bool JumpMatrix( short nStackLevel );
     377                 :            : 
     378                 :            : /** @param pOptions
     379                 :            :         NULL means case sensitivity document option is to be used!
     380                 :            :  */
     381                 :            : double CompareFunc( const ScCompare& rComp, ScCompareOptions* pOptions = NULL );
     382                 :            : double Compare();
     383                 :            : /** @param pOptions
     384                 :            :         NULL means case sensitivity document option is to be used!
     385                 :            :  */
     386                 :            : ScMatrixRef CompareMat( ScCompareOptions* pOptions = NULL );
     387                 :            : ScMatrixRef QueryMat( const ScMatrixRef& pMat, ScCompareOptions& rOptions );
     388                 :            : void ScEqual();
     389                 :            : void ScNotEqual();
     390                 :            : void ScLess();
     391                 :            : void ScGreater();
     392                 :            : void ScLessEqual();
     393                 :            : void ScGreaterEqual();
     394                 :            : void ScAnd();
     395                 :            : void ScOr();
     396                 :            : void ScXor();
     397                 :            : void ScNot();
     398                 :            : void ScNeg();
     399                 :            : void ScPercentSign();
     400                 :            : void ScIntersect();
     401                 :            : void ScRangeFunc();
     402                 :            : void ScUnionFunc();
     403                 :            : void ScPi();
     404                 :            : void ScRandom();
     405                 :            : void ScTrue();
     406                 :            : void ScFalse();
     407                 :            : void ScDeg();
     408                 :            : void ScRad();
     409                 :            : void ScSin();
     410                 :            : void ScCos();
     411                 :            : void ScTan();
     412                 :            : void ScCot();
     413                 :            : void ScArcSin();
     414                 :            : void ScArcCos();
     415                 :            : void ScArcTan();
     416                 :            : void ScArcCot();
     417                 :            : void ScSinHyp();
     418                 :            : void ScCosHyp();
     419                 :            : void ScTanHyp();
     420                 :            : void ScCotHyp();
     421                 :            : void ScArcSinHyp();
     422                 :            : void ScArcCosHyp();
     423                 :            : void ScArcTanHyp();
     424                 :            : void ScArcCotHyp();
     425                 :            : void ScCosecant();
     426                 :            : void ScSecant();
     427                 :            : void ScCosecantHyp();
     428                 :            : void ScSecantHyp();
     429                 :            : void ScExp();
     430                 :            : void ScLn();
     431                 :            : void ScLog10();
     432                 :            : void ScSqrt();
     433                 :            : void ScIsEmpty();
     434                 :            : short IsString();
     435                 :            : void ScIsString();
     436                 :            : void ScIsNonString();
     437                 :            : void ScIsLogical();
     438                 :            : void ScType();
     439                 :            : void ScCell();
     440                 :            : void ScCellExternal();
     441                 :            : void ScIsRef();
     442                 :            : void ScIsValue();
     443                 :            : void ScIsFormula();
     444                 :            : void ScFormula();
     445                 :            : void ScRoman();
     446                 :            : void ScArabic();
     447                 :            : void ScIsNV();
     448                 :            : void ScIsErr();
     449                 :            : void ScIsError();
     450                 :            : short IsEven();
     451                 :            : void ScIsEven();
     452                 :            : void ScIsOdd();
     453                 :            : void ScN();
     454                 :            : void ScCode();
     455                 :            : void ScTrim();
     456                 :            : void ScUpper();
     457                 :            : void ScPropper();
     458                 :            : void ScLower();
     459                 :            : void ScLen();
     460                 :            : void ScT();
     461                 :            : void ScValue();
     462                 :            : void ScClean();
     463                 :            : void ScChar();
     464                 :            : void ScJis();
     465                 :            : void ScAsc();
     466                 :            : void ScUnicode();
     467                 :            : void ScUnichar();
     468                 :            : void ScMin( bool bTextAsZero = false );
     469                 :            : void ScMax( bool bTextAsZero = false );
     470                 :            : double IterateParameters( ScIterFunc, bool bTextAsZero = false );
     471                 :            : void ScSumSQ();
     472                 :            : void ScSum();
     473                 :            : void ScProduct();
     474                 :            : void ScAverage( bool bTextAsZero = false );
     475                 :            : void ScCount();
     476                 :            : void ScCount2();
     477                 :            : void GetStVarParams( double& rVal, double& rValCount, bool bTextAsZero = false );
     478                 :            : void ScVar( bool bTextAsZero = false );
     479                 :            : void ScVarP( bool bTextAsZero = false );
     480                 :            : void ScStDev( bool bTextAsZero = false );
     481                 :            : void ScStDevP( bool bTextAsZero = false );
     482                 :            : void ScColumns();
     483                 :            : void ScRows();
     484                 :            : void ScTables();
     485                 :            : void ScColumn();
     486                 :            : void ScRow();
     487                 :            : void ScTable();
     488                 :            : void ScMatch();
     489                 :            : void ScCountIf();
     490                 :            : void ScSumIf();
     491                 :            : void ScCountEmptyCells();
     492                 :            : void ScLookup();
     493                 :            : void ScHLookup();
     494                 :            : void ScVLookup();
     495                 :            : void ScSubTotal();
     496                 :            : 
     497                 :            : // If upon call rMissingField==true then the database field parameter may be
     498                 :            : // missing (Xcl DCOUNT() syntax), or may be faked as missing by having the
     499                 :            : // value 0.0 or being exactly the entire database range reference (old SO
     500                 :            : // compatibility). If this was the case then rMissingField is set to true upon
     501                 :            : // return. If rMissingField==false upon call all "missing cases" are considered
     502                 :            : // to be an error.
     503                 :            : ScDBQueryParamBase* GetDBParams( bool& rMissingField );
     504                 :            : 
     505                 :            : void DBIterator( ScIterFunc );
     506                 :            : void ScDBSum();
     507                 :            : void ScDBCount();
     508                 :            : void ScDBCount2();
     509                 :            : void ScDBAverage();
     510                 :            : void ScDBGet();
     511                 :            : void ScDBMax();
     512                 :            : void ScDBMin();
     513                 :            : void ScDBProduct();
     514                 :            : void GetDBStVarParams( double& rVal, double& rValCount );
     515                 :            : void ScDBStdDev();
     516                 :            : void ScDBStdDevP();
     517                 :            : void ScDBVar();
     518                 :            : void ScDBVarP();
     519                 :            : void ScIndirect();
     520                 :            : void ScAddressFunc();
     521                 :            : void ScOffset();
     522                 :            : void ScIndex();
     523                 :            : void ScMultiArea();
     524                 :            : void ScAreas();
     525                 :            : void ScCurrency();
     526                 :            : void ScReplace();
     527                 :            : void ScFixed();
     528                 :            : void ScFind();
     529                 :            : void ScExact();
     530                 :            : void ScLeft();
     531                 :            : void ScRight();
     532                 :            : void ScSearch();
     533                 :            : void ScMid();
     534                 :            : void ScText();
     535                 :            : void ScSubstitute();
     536                 :            : void ScRept();
     537                 :            : void ScConcat();
     538                 :            : void ScExternal();
     539                 :            : void ScMissing();
     540                 :            : void ScMacro();
     541                 :            : bool SetSbxVariable( SbxVariable* pVar, const ScAddress& );
     542                 :            : bool SetSbxVariable( SbxVariable* pVar, SCCOL nCol, SCROW nRow, SCTAB nTab );
     543                 :            : void ScErrorType();
     544                 :            : void ScDBArea();
     545                 :            : void ScColRowNameAuto();
     546                 :            : void ScGetPivotData();
     547                 :            : void ScHyperLink();
     548                 :            : void ScBahtText();
     549                 :            : void ScBitAnd();
     550                 :            : void ScBitOr();
     551                 :            : void ScBitXor();
     552                 :            : void ScBitRshift();
     553                 :            : void ScBitLshift();
     554                 :            : void ScTTT();
     555                 :            : 
     556                 :            : //----------------Funktionen in interpr2.cxx---------------
     557                 :            : 
     558                 :            : /** Obtain the date serial number for a given date.
     559                 :            :     @param bStrict
     560                 :            :         If FALSE, nYear < 100 takes the two-digit year setting into account,
     561                 :            :         and rollover of invalid calendar dates takes place, e.g. 1999-02-31 =>
     562                 :            :         1999-03-03.
     563                 :            :         If TRUE, the date passed must be a valid Gregorian calendar date. No
     564                 :            :         two-digit expanding or rollover is done.
     565                 :            : 
     566                 :            :     @param bCheckGregorian
     567                 :            :         If TRUE, date must be Gregorian, i.e. >= 1582-10-15.
     568                 :            :         If FALSE, don't care, any valid date >= 0-1-1 will do.
     569                 :            :  */
     570                 :            : double GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, bool bStrict, bool bCheckGregorian );
     571                 :            : 
     572                 :            : void ScGetActDate();
     573                 :            : void ScGetActTime();
     574                 :            : void ScGetYear();
     575                 :            : void ScGetMonth();
     576                 :            : void ScGetDay();
     577                 :            : void ScGetDayOfWeek();
     578                 :            : void ScGetWeekOfYear();
     579                 :            : void ScEasterSunday();
     580                 :            : void ScGetHour();
     581                 :            : void ScGetMin();
     582                 :            : void ScGetSec();
     583                 :            : void ScPlusMinus();
     584                 :            : void ScAbs();
     585                 :            : void ScInt();
     586                 :            : void ScEven();
     587                 :            : void ScOdd();
     588                 :            : void ScCeil();
     589                 :            : void ScFloor();
     590                 :            : void RoundNumber( rtl_math_RoundingMode eMode );
     591                 :            : void ScRound();
     592                 :            : void ScRoundUp();
     593                 :            : void ScRoundDown();
     594                 :            : void ScGetDateValue();
     595                 :            : void ScGetTimeValue();
     596                 :            : void ScArcTan2();
     597                 :            : void ScLog();
     598                 :            : void ScGetDate();
     599                 :            : void ScGetTime();
     600                 :            : void ScGetDiffDate();
     601                 :            : void ScGetDiffDate360();
     602                 :            : void ScGetDateDif();
     603                 :            : void ScPower();
     604                 :            : void ScAmpersand();
     605                 :            : void ScAdd();
     606                 :            : void ScSub();
     607                 :            : void ScMul();
     608                 :            : void ScDiv();
     609                 :            : void ScPow();
     610                 :            : void ScCurrent();
     611                 :            : void ScStyle();
     612                 :            : void ScDde();
     613                 :            : void ScBase();
     614                 :            : void ScDecimal();
     615                 :            : void ScConvert();
     616                 :            : void ScEuroConvert();
     617                 :            : 
     618                 :            : //----------------------- Finanzfunktionen ------------------------------------
     619                 :            : void ScNPV();
     620                 :            : void ScIRR();
     621                 :            : void ScMIRR();
     622                 :            : void ScISPMT();
     623                 :            : 
     624                 :            : double ScGetBw(double fZins, double fZzr, double fRmz,
     625                 :            :                       double fZw, double fF);
     626                 :            : void ScBW();
     627                 :            : void ScDIA();
     628                 :            : double ScGetGDA(double fWert, double fRest, double fDauer,
     629                 :            :                        double fPeriode, double fFaktor);
     630                 :            : void ScGDA();
     631                 :            : void ScGDA2();
     632                 :            : double ScInterVDB(double fWert,double fRest,double fDauer,double fDauer1,
     633                 :            :                 double fPeriode,double fFaktor);
     634                 :            : void ScVDB();
     635                 :            : void ScLaufz();
     636                 :            : void ScLIA();
     637                 :            : double ScGetRmz(double fZins, double fZzr, double fBw,
     638                 :            :                        double fZw, double fF);
     639                 :            : void ScRMZ();
     640                 :            : void ScZGZ();
     641                 :            : double ScGetZw(double fZins, double fZzr, double fRmz,
     642                 :            :                       double fBw, double fF);
     643                 :            : void ScZW();
     644                 :            : void ScZZR();
     645                 :            : bool RateIteration(double fNper, double fPayment, double fPv,
     646                 :            :                                 double fFv, double fPayType, double& fGuess);
     647                 :            : void ScZins();
     648                 :            : double ScGetZinsZ(double fZins, double fZr, double fZzr, double fBw,
     649                 :            :                          double fZw, double fF, double& fRmz);
     650                 :            : void ScZinsZ();
     651                 :            : void ScKapz();
     652                 :            : void ScKumZinsZ();
     653                 :            : void ScKumKapZ();
     654                 :            : void ScEffektiv();
     655                 :            : void ScNominal();
     656                 :            : void ScMod();
     657                 :            : void ScBackSolver();
     658                 :            : void ScIntercept();
     659                 :            : //-------------------------Funktionen in interpr5.cxx--------------------------
     660                 :            : double ScGetGCD(double fx, double fy);
     661                 :            : void ScGCD();
     662                 :            : void ScLCM();
     663                 :            : //-------------------------- Matrixfunktionen ---------------------------------
     664                 :            : 
     665                 :            : void ScMatValue();
     666                 :            : void MEMat(const ScMatrixRef& mM, SCSIZE n);
     667                 :            : void ScMatDet();
     668                 :            : void ScMatInv();
     669                 :            : void ScMatMult();
     670                 :            : void ScMatTrans();
     671                 :            : void ScEMat();
     672                 :            : void ScMatRef();
     673                 :            : ScMatrixRef MatConcat(const ScMatrixRef& pMat1, const ScMatrixRef& pMat2);
     674                 :            : void ScSumProduct();
     675                 :            : void ScSumX2MY2();
     676                 :            : void ScSumX2DY2();
     677                 :            : void ScSumXMY2();
     678                 :            : void ScGrowth();
     679                 :            : bool CalculateSkew(double& fSum,double& fCount,double& vSum,std::vector<double>& values);
     680                 :            : void CalculateSlopeIntercept(bool bSlope);
     681                 :            : void CalculateSmallLarge(bool bSmall);
     682                 :            : void CalculatePearsonCovar(bool _bPearson,bool _bStexy);
     683                 :            : bool CalculateTest( bool _bTemplin
     684                 :            :                    ,const SCSIZE nC1, const SCSIZE nC2,const SCSIZE nR1,const SCSIZE nR2
     685                 :            :                    ,const ScMatrixRef& pMat1,const ScMatrixRef& pMat2
     686                 :            :                    ,double& fT,double& fF);
     687                 :            : void CalculateLookup(bool HLookup);
     688                 :            : bool FillEntry(ScQueryEntry& rEntry);
     689                 :            : void CalculateAddSub(bool _bSub);
     690                 :            : void CalculateTrendGrowth(bool _bGrowth);
     691                 :            : void CalulateRGPRKP(bool _bRKP);
     692                 :            : void CalculateSumX2MY2SumX2DY2(bool _bSumX2DY2);
     693                 :            : void CalculateMatrixValue(const ScMatrix* pMat,SCSIZE nC,SCSIZE nR);
     694                 :            : bool CheckMatrix(bool _bLOG,sal_uInt8& nCase,SCSIZE& nCX,SCSIZE& nCY,SCSIZE& nRX,SCSIZE& nRY,SCSIZE& M,SCSIZE& N,ScMatrixRef& pMatX,ScMatrixRef& pMatY);
     695                 :            : void ScRGP();
     696                 :            : void ScRKP();
     697                 :            : void ScForecast();
     698                 :            : //------------------------- Functions in interpr3.cxx -------------------------
     699                 :            : void ScNoName();
     700                 :            : void ScBadName();
     701                 :            : // Statistik:
     702                 :            : double phi(double x);
     703                 :            : double integralPhi(double x);
     704                 :            : double taylor(double* pPolynom, sal_uInt16 nMax, double x);
     705                 :            : double gauss(double x);
     706                 :            : double gaussinv(double x);
     707                 :            : double GetBetaDist(double x, double alpha, double beta);  //cumulative distribution function
     708                 :            : double GetBetaDistPDF(double fX, double fA, double fB); //probability density function)
     709                 :            : double GetChiDist(double fChi, double fDF);     // for LEGACY.CHIDIST, returns right tail
     710                 :            : double GetChiSqDistCDF(double fX, double fDF);  // for CHISQDIST, returns left tail
     711                 :            : double GetChiSqDistPDF(double fX, double fDF);  // probability density function
     712                 :            : double GetFDist(double x, double fF1, double fF2);
     713                 :            : double GetTDist(double T, double fDF);
     714                 :            : double Fakultaet(double x);
     715                 :            : double BinomKoeff(double n, double k);
     716                 :            : double GetGamma(double x);
     717                 :            : double GetLogGamma(double x);
     718                 :            : double GetBeta(double fAlpha, double fBeta);
     719                 :            : double GetLogBeta(double fAlpha, double fBeta);
     720                 :            : void ScLogGamma();
     721                 :            : void ScGamma();
     722                 :            : void ScPhi();
     723                 :            : void ScGauss();
     724                 :            : void ScStdNormDist();
     725                 :            : void ScFisher();
     726                 :            : void ScFisherInv();
     727                 :            : void ScFact();
     728                 :            : void ScNormDist();
     729                 :            : void ScGammaDist();
     730                 :            : void ScGammaInv();
     731                 :            : void ScExpDist();
     732                 :            : void ScBinomDist();
     733                 :            : void ScPoissonDist();
     734                 :            : void ScKombin();
     735                 :            : void ScKombin2();
     736                 :            : void ScVariationen();
     737                 :            : void ScVariationen2();
     738                 :            : void ScB();
     739                 :            : void ScHypGeomDist();
     740                 :            : void ScLogNormDist();
     741                 :            : void ScLogNormInv();
     742                 :            : void ScTDist();
     743                 :            : void ScFDist();
     744                 :            : void ScChiDist();   // for LEGACY.CHIDIST, returns right tail
     745                 :            : void ScChiSqDist(); // returns left tail or density
     746                 :            : void ScChiSqInv(); //invers to CHISQDIST
     747                 :            : void ScWeibull();
     748                 :            : void ScBetaDist();
     749                 :            : void ScFInv();
     750                 :            : void ScTInv();
     751                 :            : void ScChiInv();
     752                 :            : void ScBetaInv();
     753                 :            : void ScCritBinom();
     754                 :            : void ScNegBinomDist();
     755                 :            : void ScKurt();
     756                 :            : void ScHarMean();
     757                 :            : void ScGeoMean();
     758                 :            : void ScStandard();
     759                 :            : void ScSkew();
     760                 :            : void ScMedian();
     761                 :            : double GetMedian( ::std::vector<double> & rArray );
     762                 :            : double GetPercentile( ::std::vector<double> & rArray, double fPercentile );
     763                 :            : void GetNumberSequenceArray( sal_uInt8 nParamCount, ::std::vector<double>& rArray );
     764                 :            : void GetSortArray(sal_uInt8 nParamCount, ::std::vector<double>& rSortArray, ::std::vector<long>* pIndexOrder = NULL);
     765                 :            : void QuickSort(::std::vector<double>& rSortArray, ::std::vector<long>* pIndexOrder = NULL);
     766                 :            : void ScModalValue();
     767                 :            : void ScAveDev();
     768                 :            : void ScDevSq();
     769                 :            : void ScZTest();
     770                 :            : void ScTTest();
     771                 :            : void ScFTest();
     772                 :            : void ScChiTest();
     773                 :            : void ScRank();
     774                 :            : void ScPercentile();
     775                 :            : void ScPercentrank();
     776                 :            : void ScLarge();
     777                 :            : void ScSmall();
     778                 :            : void ScFrequency();
     779                 :            : void ScQuartile();
     780                 :            : void ScNormInv();
     781                 :            : void ScSNormInv();
     782                 :            : void ScConfidence();
     783                 :            : void ScTrimMean();
     784                 :            : void ScProbability();
     785                 :            : void ScCorrel();
     786                 :            : void ScCovar();
     787                 :            : void ScPearson();
     788                 :            : void ScRSQ();
     789                 :            : void ScSTEXY();
     790                 :            : void ScSlope();
     791                 :            : void ScTrend();
     792                 :            : void ScInfo();
     793                 :            : 
     794                 :            : //------------------------ Functions in interpr6.cxx -------------------------
     795                 :            : 
     796                 :            : static const double fMaxGammaArgument;  // defined in interpr3.cxx
     797                 :            : 
     798                 :            : double GetGammaContFraction(double fA,double fX);
     799                 :            : double GetGammaSeries(double fA,double fX);
     800                 :            : double GetLowRegIGamma(double fA,double fX);    // lower regularized incomplete gamma function, GAMMAQ
     801                 :            : double GetUpRegIGamma(double fA,double fX);     // upper regularized incomplete gamma function, GAMMAP
     802                 :            : // probability density function; fLambda is "scale" parameter
     803                 :            : double GetGammaDistPDF(double fX, double fAlpha, double fLambda);
     804                 :            : // cumulative distribution function; fLambda is "scale" parameter
     805                 :            : double GetGammaDist(double fX, double fAlpha, double fLambda);
     806                 :            : 
     807                 :            : public:
     808                 :            :     ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
     809                 :            :                     const ScAddress&, ScTokenArray& );
     810                 :            :     ~ScInterpreter();
     811                 :            : 
     812                 :            :     formula::StackVar Interpret();
     813                 :            : 
     814                 :       1586 :     void SetError(sal_uInt16 nError)
     815 [ +  + ][ +  + ]:       1586 :             { if (nError && !nGlobalError) nGlobalError = nError; }
     816                 :            : 
     817                 :      10569 :     sal_uInt16                  GetError() const            { return nGlobalError; }
     818                 :          0 :     formula::StackVar           GetResultType() const       { return xResult->GetType(); }
     819                 :          0 :     const String&               GetStringResult() const     { return xResult->GetString(); }
     820                 :          0 :     double                      GetNumResult() const        { return xResult->GetDouble(); }
     821                 :       2835 :     formula::FormulaTokenRef    GetResultToken() const      { return xResult; }
     822                 :       2806 :     short                       GetRetFormatType() const    { return nRetFmtType; }
     823                 :       2619 :     sal_uLong                   GetRetFormatIndex() const   { return nRetFmtIndex; }
     824                 :            : };
     825                 :            : 
     826                 :            : 
     827                 :         66 : inline void ScInterpreter::MatrixDoubleRefToMatrix()
     828                 :            : {
     829 [ +  + ][ -  + ]:         66 :     if ( bMatrixFormula && GetStackType() == formula::svDoubleRef )
                 [ -  + ]
     830                 :            :     {
     831                 :          0 :         GetTokenMatrixMap();    // make sure it exists, create if not.
     832                 :          0 :         PopDoubleRefPushMatrix();
     833                 :            :     }
     834                 :         66 : }
     835                 :            : 
     836                 :            : 
     837                 :       2810 : inline bool ScInterpreter::MatrixParameterConversion()
     838                 :            : {
     839 [ +  + ][ -  + ]:       2810 :     if ( (bMatrixFormula || pCur->HasForceArray()) && !pJumpMatrix && sp > 0 )
         [ +  - ][ +  + ]
                 [ +  + ]
     840                 :        246 :         return ConvertMatrixParameters();
     841                 :       2810 :     return false;
     842                 :            : }
     843                 :            : 
     844                 :            : 
     845                 :         72 : inline ScTokenMatrixMap& ScInterpreter::GetTokenMatrixMap()
     846                 :            : {
     847         [ +  + ]:         72 :     if (!pTokenMatrixMap)
     848                 :         36 :         pTokenMatrixMap = CreateTokenMatrixMap();
     849                 :         72 :     return *pTokenMatrixMap;
     850                 :            : }
     851                 :            : 
     852                 :            : 
     853                 :        390 : inline bool ScInterpreter::MustHaveParamCount( short nAct, short nMust )
     854                 :            : {
     855         [ +  - ]:        390 :     if ( nAct == nMust )
     856                 :        390 :         return true;
     857         [ #  # ]:          0 :     if ( nAct < nMust )
     858                 :          0 :         PushParameterExpected();
     859                 :            :     else
     860                 :          0 :         PushIllegalParameter();
     861                 :        390 :     return false;
     862                 :            : }
     863                 :            : 
     864                 :            : 
     865                 :        416 : inline bool ScInterpreter::MustHaveParamCount( short nAct, short nMust, short nMax )
     866                 :            : {
     867 [ +  - ][ +  - ]:        416 :     if ( nMust <= nAct && nAct <= nMax )
     868                 :        416 :         return true;
     869         [ #  # ]:          0 :     if ( nAct < nMust )
     870                 :          0 :         PushParameterExpected();
     871                 :            :     else
     872                 :          0 :         PushIllegalParameter();
     873                 :        416 :     return false;
     874                 :            : }
     875                 :            : 
     876                 :            : 
     877                 :         73 : inline bool ScInterpreter::MustHaveParamCountMin( short nAct, short nMin )
     878                 :            : {
     879         [ +  - ]:         73 :     if ( nAct >= nMin )
     880                 :         73 :         return true;
     881                 :          0 :     PushParameterExpected();
     882                 :         73 :     return false;
     883                 :            : }
     884                 :            : 
     885                 :            : 
     886                 :          0 : inline bool ScInterpreter::CheckStringResultLen( String& rResult, const String& rAdd )
     887                 :            : {
     888         [ #  # ]:          0 :     if ( (sal_uLong) rResult.Len() + rAdd.Len() > STRING_MAXLEN )
     889                 :            :     {
     890                 :          0 :         SetError( errStringOverflow );
     891                 :          0 :         rResult.Erase();
     892                 :          0 :         return false;
     893                 :            :     }
     894                 :          0 :     return true;
     895                 :            : }
     896                 :            : 
     897                 :            : 
     898                 :       1892 : inline void ScInterpreter::TreatDoubleError( double& rVal )
     899                 :            : {
     900         [ +  + ]:       1892 :     if ( !::rtl::math::isFinite( rVal ) )
     901                 :            :     {
     902                 :         14 :         sal_uInt16 nErr = GetDoubleErrorValue( rVal );
     903         [ +  - ]:         14 :         if ( nErr )
     904                 :         14 :             SetError( nErr );
     905                 :            :         else
     906                 :          0 :             SetError( errNoValue );
     907                 :         14 :         rVal = 0.0;
     908                 :            :     }
     909                 :       1892 : }
     910                 :            : 
     911                 :            : 
     912                 :         65 : inline double ScInterpreter::div( const double& fNumerator, const double& fDenominator )
     913                 :            : {
     914                 :            :     return (fDenominator != 0.0) ? (fNumerator / fDenominator) :
     915         [ +  + ]:         65 :         CreateDoubleError( errDivisionByZero);
     916                 :            : }
     917                 :            : 
     918                 :            : #endif
     919                 :            : 
     920                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10