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