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