20#include <config_features.h>
26#include <rtl/math.hxx>
35#include <osl/thread.h>
43#include <com/sun/star/table/XCellRange.hpp>
44#include <com/sun/star/script/XInvocation.hpp>
45#include <com/sun/star/sheet/XSheetCellRange.hpp>
52#include <document.hxx>
68#include <tokenarray.hxx>
69#include <compiler.hxx>
79using ::std::unique_ptr;
81#define ADDIN_MAXSTRLEN 256
91 for (
size_t i = 0;
i < ListSize; ++
i )
94 if ( rPos == pTOp->
aOld1 )
99 else if ( rPos == pTOp->
aOld2 )
114 for (
size_t i = 0;
i < ListSize; ++
i )
132 nErr = FormulaError::NONE;
139 nErr = FormulaError::NONE;
168 if (nError != FormulaError::NONE)
199 if( nErr == FormulaError::NONE )
286 "Add check for columns > SAL_MAX_UINT16!");
291 sal_uInt16*
p =
reinterpret_cast<sal_uInt16*
>(pCellArr);
292 *
p++ =
static_cast<sal_uInt16
>(nCol1);
293 *
p++ =
static_cast<sal_uInt16
>(nRow1);
294 *
p++ =
static_cast<sal_uInt16
>(nTab1);
295 *
p++ =
static_cast<sal_uInt16
>(nCol2);
296 *
p++ =
static_cast<sal_uInt16
>(nRow2);
297 *
p++ =
static_cast<sal_uInt16
>(nTab2);
298 sal_uInt16* pCount =
p;
300 sal_uInt16
nPos = 14;
303 while (nTab <= nTab2)
307 while (nRow <= nRow2)
311 while (nCol <= nCol2)
341 if ((
nPos + (4 *
sizeof(sal_uInt16)) +
sizeof(
double)) >
MAXARRSIZE)
343 *
p++ =
static_cast<sal_uInt16
>(nCol);
344 *
p++ =
static_cast<sal_uInt16
>(nRow);
345 *
p++ =
static_cast<sal_uInt16
>(nTab);
346 *
p++ =
static_cast<sal_uInt16
>(nErr);
347 memcpy(
p, &nVal,
sizeof(
double));
348 nPos += 8 +
sizeof(double);
349 p =
reinterpret_cast<sal_uInt16*
>( pCellArr +
nPos );
370 "Add check for columns > SAL_MAX_UINT16!");
375 sal_uInt16*
p =
reinterpret_cast<sal_uInt16*
>(pCellArr);
376 *
p++ =
static_cast<sal_uInt16
>(nCol1);
377 *
p++ =
static_cast<sal_uInt16
>(nRow1);
378 *
p++ =
static_cast<sal_uInt16
>(nTab1);
379 *
p++ =
static_cast<sal_uInt16
>(nCol2);
380 *
p++ =
static_cast<sal_uInt16
>(nRow2);
381 *
p++ =
static_cast<sal_uInt16
>(nTab2);
382 sal_uInt16* pCount =
p;
384 sal_uInt16
nPos = 14;
386 while (nTab <= nTab2)
389 while (nRow <= nRow2)
392 while (nCol <= nCol2)
422 osl_getThreadTextEncoding()));
429 sal_uInt16 nStrLen =
static_cast<sal_uInt16
>(aTmp.getLength());
430 sal_uInt16 nLen = ( nStrLen + 2 ) & ~1;
434 *
p++ =
static_cast<sal_uInt16
>(nCol);
435 *
p++ =
static_cast<sal_uInt16
>(nRow);
436 *
p++ =
static_cast<sal_uInt16
>(nTab);
437 *
p++ =
static_cast<sal_uInt16
>(nErr);
439 memcpy(
p, aTmp.getStr(), nStrLen + 1);
440 nPos += 10 + nStrLen + 1;
442 if( (nStrLen & 1) == 0 )
447 p =
reinterpret_cast<sal_uInt16*
>( pCellArr +
nPos );
468 "Add check for columns > SAL_MAX_UINT16!");
473 sal_uInt16*
p =
reinterpret_cast<sal_uInt16*
>(pCellArr);
474 *
p++ =
static_cast<sal_uInt16
>(nCol1);
475 *
p++ =
static_cast<sal_uInt16
>(nRow1);
476 *
p++ =
static_cast<sal_uInt16
>(nTab1);
477 *
p++ =
static_cast<sal_uInt16
>(nCol2);
478 *
p++ =
static_cast<sal_uInt16
>(nRow2);
479 *
p++ =
static_cast<sal_uInt16
>(nTab2);
480 sal_uInt16* pCount =
p;
482 sal_uInt16
nPos = 14;
485 while (nTab <= nTab2)
489 while (nRow <= nRow2)
493 while (nCol <= nCol2)
500 sal_uInt16
nType = 0;
529 *
p++ =
static_cast<sal_uInt16
>(nCol);
530 *
p++ =
static_cast<sal_uInt16
>(nRow);
531 *
p++ =
static_cast<sal_uInt16
>(nTab);
532 *
p++ =
static_cast<sal_uInt16
>(nErr);
539 memcpy(
p, &nVal,
sizeof(
double));
540 nPos +=
sizeof(double);
545 osl_getThreadTextEncoding()));
552 sal_uInt16 nStrLen =
static_cast<sal_uInt16
>(aTmp.getLength());
553 sal_uInt16 nLen = ( nStrLen + 2 ) & ~1;
557 memcpy(
p, aTmp.getStr(), nStrLen + 1);
558 nPos += 2 + nStrLen + 1;
560 if( (nStrLen & 1) == 0 )
567 p =
reinterpret_cast<sal_uInt16*
>( pCellArr +
nPos );
587 SetError( FormulaError::StackOverflow );
603 SetError( FormulaError::StackOverflow );
622 SetError( FormulaError::StackOverflow );
624 p->DeleteIfZeroRef();
638 p->DeleteIfZeroRef();
652 SetError( FormulaError::StackOverflow );
671 SetError( FormulaError::StackOverflow );
694 if (pRetTypeExpr && pRetIndexExpr)
704 if (nErr != FormulaError::NONE)
708 *pRetTypeExpr = SvNumFormatType::UNDEFINED;
718 *pRetTypeExpr = SvNumFormatType::TEXT;
749 SetError(FormulaError::UnknownStackVariable);
763 SetError(FormulaError::UnknownStackVariable);
777 SetError(FormulaError::UnknownStackVariable);
789 switch (
p->GetType())
797 if (
nType != SvNumFormatType::ALL &&
nType != SvNumFormatType::UNDEFINED)
799 return p->GetDouble();
805 SetError( FormulaError::IllegalArgument);
809 SetError( FormulaError::UnknownStackVariable);
821 switch (
p->GetType())
827 return p->GetString();
832 SetError( FormulaError::IllegalArgument);
836 SetError( FormulaError::UnknownStackVariable);
857 for (
const auto& rRef : rRefList)
913 switch (
p->GetType())
931 rAdr.
Set( nCol, nRow, nTab );
937 SetError( FormulaError::IllegalParameter);
941 SetError( FormulaError::UnknownStackVariable);
956 ScRange aRange( rCol1, rRow1, rTab1, rCol2, rRow2, rTab2 );
958 SetError( FormulaError::IllegalParameter );
968 SetError(FormulaError::UnknownStackVariable);
982 ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2));
997 SetError( FormulaError::IllegalParameter);
1010 switch (
p->GetType())
1019 SetError( FormulaError::IllegalParameter);
1023 SetError( FormulaError::UnknownStackVariable);
1027 ScRange & rRange,
bool bDontCheckForTableOp )
1035 rRange.
aEnd.
Set( nCol, nRow, nTab );
1040 SetError( FormulaError::IllegalParameter );
1069 if (rRefInList < pList->
size())
1072 if (++rRefInList < pList->
size())
1084 SetError( FormulaError::IllegalParameter);
1089 SetError( FormulaError::IllegalParameter);
1093 SetError( FormulaError::UnknownStackVariable);
1102 switch (
p->GetType())
1111 SetError( FormulaError::IllegalParameter);
1115 SetError( FormulaError::UnknownStackVariable);
1123 switch (
p->GetType())
1126 return p->GetDoubleRef();
1130 if (rRefInList < pList->
size())
1131 return &(*pList)[rRefInList];
1145 SetError(FormulaError::UnknownStackVariable);
1161 SetError( FormulaError::IllegalParameter);
1165 rFileId =
p->GetIndex();
1166 rTabName =
p->GetString().getString();
1167 rRef = *
p->GetSingleRef();
1196 OSL_FAIL(
"ScCompiler::GetToken: external single reference must have an absolute table reference!");
1204 rFileId, rTabName, aAddr, &
aPos,
nullptr, &aFmt);
1212 if (xNew->GetType() ==
svError)
1224 SetError(FormulaError::UnknownStackVariable);
1240 SetError( FormulaError::IllegalParameter);
1244 rFileId =
p->GetIndex();
1245 rTabName =
p->GetString().getString();
1246 rRef = *
p->GetDoubleRef();
1275 SetError( FormulaError::IllegalParameter);
1278 rMat =
p->GetMatrix();
1280 SetError( FormulaError::UnknownVariable);
1296 OSL_FAIL(
"ScCompiler::GetToken: external double reference must have an absolute table reference!");
1310 nFileId, rTabName, aRange, &
aPos);
1314 SetError(FormulaError::IllegalArgument);
1328 SetError(FormulaError::IllegalArgument);
1335 SetError( FormulaError::IllegalArgument);
1383 const std::vector<ScComplexRefData>* pv = xTok->
GetRefList();
1386 const size_t nEntries = pv->size();
1397 for (
const auto & rRef : *pv)
1399 if (rRef.Ref1 != rRef.Ref2)
1405 for (
size_t i=0;
i < nEntries; ++
i)
1416 xMat->PutEmpty( 0,
i);
1420 xMat->PutDouble( aCell.
getValue(), 0,
i);
1460 SAL_WARN_IF( nParams >
sp,
"sc.core",
"ConvertMatrixParameters: stack/param count mismatch: eOp: "
1461 <<
static_cast<int>(
pCur->
GetOpCode()) <<
" sp: " <<
sp <<
" nParams: " << nParams);
1462 assert(nParams <=
sp);
1463 SCSIZE nJumpCols = 0, nJumpRows = 0;
1464 for ( sal_uInt16
i=1;
i <= nParams &&
i <=
sp; ++
i )
1469 assert(!
"ConvertMatrixParameters: not a push");
1473 switch (
p->GetType() )
1487 == formula::ParamClass::Value )
1491 SetError( FormulaError::UnknownVariable);
1495 pMat->GetDimensions( nCols, nRows);
1496 if ( nJumpCols < nCols )
1498 if ( nJumpRows < nRows )
1507 if (
eType != formula::ParamClass::Reference &&
1508 eType != formula::ParamClass::ReferenceOrRefArray &&
1509 eType != formula::ParamClass::ReferenceOrForceArray &&
1524 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
1527 if (
eType == formula::ParamClass::Value )
1530 nJumpCols =
static_cast<SCSIZE>(nCol2 - nCol1 + 1);
1532 nJumpRows =
static_cast<SCSIZE>(nRow2 - nRow1 + 1);
1545 if (
eType == formula::ParamClass::Value ||
eType == formula::ParamClass::Array)
1547 sal_uInt16 nFileId =
p->GetIndex();
1548 OUString aTabName =
p->GetString().getString();
1561 if (
eType == formula::ParamClass::Value)
1581 if (
eType != formula::ParamClass::Reference &&
1582 eType != formula::ParamClass::ReferenceOrRefArray &&
1583 eType != formula::ParamClass::ReferenceOrForceArray &&
1584 eType != formula::ParamClass::ForceArray)
1594 assert(!
"ConvertMatrixParameters: unknown parameter type");
1598 if( nJumpCols && nJumpRows )
1601 short nStart = nPC - 1;
1603 short nStop = nPC + 1;
1605 ScTokenMatrixMap::const_iterator aMapIter;
1607 xNew = (*aMapIter).second;
1610 std::shared_ptr<ScJumpMatrix> pJumpMat;
1613 pJumpMat = std::make_shared<ScJumpMatrix>(
pCur->
GetOpCode(), nJumpCols, nJumpRows);
1615 catch (
const std::bad_alloc&)
1617 SAL_WARN(
"sc.core",
"std::bad_alloc in ScJumpMatrix ctor with " << nJumpCols <<
" columns and " << nJumpRows <<
" rows");
1620 pJumpMat->SetAllJumps( 1.0, nStart, nNext, nStop);
1623 for ( sal_uInt16
i=1; i <= nParams && sp > 0; ++
i )
1628 aParams[ nParams -
i ] =
p;
1630 pJumpMat->SetJumpParameters( std::move(aParams) );
1648 switch (
p->GetType())
1662 SetError( FormulaError::UnknownVariable);
1666 SetError( FormulaError::IllegalParameter);
1670 SetError( FormulaError::UnknownStackVariable);
1688 aRet.
mpMat->SetErrorInterpreter(
this);
1704 SetError( FormulaError::UnknownVariable);
1719 xMat->GetDimensions(nCols, nRows);
1724 if ( xMat->IsEmptyPath( 0, 0))
1728 rRetTypeExpr = SvNumFormatType::LOGICAL;
1730 else if ( xMat->IsEmptyResult( 0, 0))
1735 else if ( xMat->IsEmpty( 0, 0))
1744 rRetTypeExpr = SvNumFormatType::TEXT;
1751 if (nErr != FormulaError::NONE)
1756 if ( rRetTypeExpr != SvNumFormatType::LOGICAL )
1757 rRetTypeExpr = SvNumFormatType::NUMBER;
1760 xMat->SetErrorInterpreter(
nullptr);
1763 SetError( FormulaError::UnknownStackVariable);
1773 if (
p &&
p->GetRef() == 1)
1775 p->GetDoubleAsReference() = fVal;
1776 p->SetDoubleType(
static_cast<sal_Int16
>(nFmt) );
1858 sal_uInt16 nFileId,
const OUString& rTabName,
SCCOL nCol,
SCROW nRow,
SCTAB nTab)
1870 sal_uInt16 nFileId,
const OUString& rTabName,
1911 rMat.
mpMat->SetErrorInterpreter(
nullptr);
1918 pMat->SetErrorInterpreter(
nullptr);
1935 PushError( FormulaError::ParameterExpected);
1940 PushError( FormulaError::IllegalParameter);
1945 PushError( FormulaError::IllegalArgument);
1972 SetError(FormulaError::UnknownStackVariable);
1989 SetError(FormulaError::UnknownStackVariable);
2012 assert(
sp >= nParamCount &&
" less stack elements than parameters");
2013 sal_uInt16 nStackParams = std::min<sal_uInt16>(
sp, nParamCount);
2032 SetError( FormulaError::IllegalArgument);
2037 rAdr.
SetCol( sal::static_int_cast<SCCOL>( rRange.
aStart.
Col() + nC ) );
2038 rAdr.
SetRow( sal::static_int_cast<SCROW>( rRange.
aStart.
Row() + nR ) );
2063 double fVal = pMat->GetDoubleWithStringConversion( 0, 0);
2065 if (nErr != FormulaError::NONE)
2075 SCSIZE nCols, nRows, nC, nR;
2076 pMat->GetDimensions( nCols, nRows);
2079 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2081 double fVal = pMat->GetDoubleWithStringConversion( nC, nR);
2083 if (nErr != FormulaError::NONE)
2137 nVal = pToken->GetDouble();
2170 SetError( FormulaError::IllegalParameter);
2183 nResultVal = nDefault;
2189 if (!std::isfinite(fVal))
2196 fVal = rtl::math::approxFloor( fVal);
2199 SetError( FormulaError::IllegalArgument);
2203 else if (fVal < 0.0)
2205 fVal = rtl::math::approxCeil( fVal);
2208 SetError( FormulaError::IllegalArgument);
2212 return static_cast<sal_Int32
>(fVal);
2232 if (!std::isfinite(fVal))
2239 fVal = rtl::math::approxFloor( fVal);
2242 SetError( FormulaError::IllegalArgument);
2246 else if (fVal < 0.0)
2248 fVal = rtl::math::approxCeil( fVal);
2251 SetError( FormulaError::IllegalArgument);
2255 return static_cast<sal_Int16
>(fVal);
2260 double fVal = rtl::math::approxFloor(
GetDouble());
2261 if (!std::isfinite(fVal))
2268 SetError( FormulaError::IllegalArgument);
2271 return static_cast<sal_uInt32
>(fVal);
2276 bool bDouble =
true;
2326 SetError( FormulaError::IllegalParameter);
2392 return pToken->GetString();
2408 SetError( FormulaError::IllegalArgument);
2423 SCSIZE nCols, nRows, nC, nR;
2424 pMat->GetDimensions( nCols, nRows);
2427 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2428 return pMat->GetString( *
pFormatter, nC, nR);
2452 SetError( FormulaError::IllegalParameter);
2463 nMatVal = pMat->Get(0, 0);
2464 nMatValType = nMatVal.
nType;
2468 SCSIZE nCols, nRows, nC, nR;
2469 pMat->GetDimensions( nCols, nRows);
2472 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2474 nMatVal = pMat->Get( nC, nR);
2475 nMatValType = nMatVal.
nType;
2483 rDouble = nMatVal.
fVal;
2485 if (nError != FormulaError::NONE)
2499 SvNumFormatType::NUMBER,
2508 bool bMissingField =
false;
2509 unique_ptr<ScDBQueryParamBase> pQueryParam(
GetDBParams(bMissingField) );
2517 pQueryParam->mbSkipString =
false;
2520 if (!aValIter.
GetFirst(aValue) || aValue.
mnError != FormulaError::NONE)
2528 if (aValIter.
GetNext(aValNext) && aValNext.
mnError == FormulaError::NONE)
2547 if (pLegacyFuncData)
2552 if (nParamCount < MAXFUNCPARAM && nParamCount == pLegacyFuncData->GetParamCount() - 1)
2564 ppParam[
i] =
nullptr;
2567 pCellArr[
i] =
nullptr;
2570 for (
i = nParamCount; (
i > 0) && (
nGlobalError == FormulaError::NONE);
i--)
2577 SetError( FormulaError::ParameterExpected);
2580 switch (eParamType[
i])
2585 ppParam[
i] = &nVal[
i-1];
2591 osl_getThreadTextEncoding()));
2593 SetError( FormulaError::StringOverflow );
2599 ppParam[
i] = pStr[
i-1];
2611 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2613 if (!
CreateDoubleArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2614 SetError(FormulaError::CodeOverflow);
2616 ppParam[
i] = pCellArr[
i-1];
2627 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2629 if (!
CreateStringArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2630 SetError(FormulaError::CodeOverflow);
2632 ppParam[
i] = pCellArr[
i-1];
2643 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2645 if (!
CreateCellArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2646 SetError(FormulaError::CodeOverflow);
2648 ppParam[
i] = pCellArr[
i-1];
2652 SetError(FormulaError::IllegalParameter);
2663 switch ( eParamType[0] )
2669 pLegacyFuncData->
Call(ppParam);
2676 ppParam[0] = pcErg.get();
2677 pLegacyFuncData->
Call(ppParam);
2678 OUString aUni( pcErg.get(), strlen(pcErg.get()), osl_getThreadTextEncoding() );
2683 PushError( FormulaError::UnknownState );
2693 pLegacyFuncData->
Call(ppParam);
2720 PushError( FormulaError::UnknownState );
2734 delete[] pCellArr[
i];
2739 while( nParamCount-- > 0)
2752 SetError( FormulaError::IllegalParameter );
2762 aCall.
SetCaller(
static_cast<beans::XPropertySet*
>(
2767 short nPar = nParamCount;
2768 while ( nPar > 0 &&
GetError() == FormulaError::NONE )
2804 switch( nStackType )
2813 uno::Sequence<sal_Int32> aInner( &nVal, 1 );
2814 uno::Sequence< uno::Sequence<sal_Int32> > aOuter( &aInner, 1 );
2824 SetError(FormulaError::IllegalParameter);
2829 SetError(FormulaError::IllegalParameter);
2833 SetError(FormulaError::IllegalParameter);
2838 switch( nStackType )
2845 uno::Sequence<double> aInner( &fVal, 1 );
2846 uno::Sequence< uno::Sequence<double> > aOuter( &aInner, 1 );
2855 SetError(FormulaError::IllegalParameter);
2860 SetError(FormulaError::IllegalParameter);
2864 SetError(FormulaError::IllegalParameter);
2869 switch( nStackType )
2876 uno::Sequence<OUString> aInner( &aString, 1 );
2877 uno::Sequence< uno::Sequence<OUString> > aOuter( &aInner, 1 );
2886 SetError(FormulaError::IllegalParameter);
2891 SetError(FormulaError::IllegalParameter);
2895 SetError(FormulaError::IllegalParameter);
2900 switch( nStackType )
2921 aElem <<=
aStr.getString();
2927 uno::Sequence<uno::Any> aInner( &aElem, 1 );
2928 uno::Sequence< uno::Sequence<uno::Any> > aOuter( &aInner, 1 );
2937 SetError(FormulaError::IllegalParameter);
2942 SetError(FormulaError::IllegalParameter);
2946 SetError(FormulaError::IllegalParameter);
2951 switch( nStackType )
2969 aParam <<=
aStr.getString();
2981 SetError(FormulaError::IllegalParameter);
2986 SetError(FormulaError::IllegalParameter);
2990 SetError(FormulaError::IllegalParameter);
2995 switch( nStackType )
3002 uno::Reference<table::XCellRange> xObj =
3007 SetError(FormulaError::IllegalParameter);
3014 uno::Reference<table::XCellRange> xObj =
3022 SetError(FormulaError::IllegalParameter);
3028 SetError(FormulaError::IllegalParameter);
3034 SetError(FormulaError::IllegalParameter);
3043 if (
GetError() == FormulaError::NONE )
3050 uno::Reference<sheet::XVolatileResult> xRes = aCall.
GetVarRes();
3057 bool bTemporaryListener =
false;
3064 bTemporaryListener =
true;
3077 if (bTemporaryListener)
3083 css::lang::EventObject
aEvent;
3086 catch (
const uno::Exception&)
3092 if ( aCall.
GetErrCode() != FormulaError::NONE )
3114 while( nParamCount-- > 0)
3130#if HAVE_FEATURE_SCRIPTING
3132static uno::Any lcl_getSheetModule(
const uno::Reference<table::XCellRange>& xCellRange,
const ScDocument* pDok )
3134 uno::Reference< sheet::XSheetCellRange > xSheetRange( xCellRange, uno::UNO_QUERY_THROW );
3135 uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW );
3137 xProps->getPropertyValue(
"CodeName") >>= sCodeName;
3145 uno::Reference< uno::XInterface > xIf;
3146 if ( pBasMgr && !pBasMgr->
GetName().isEmpty() )
3148 OUString sProj(
"Standard" );
3171 uno::Reference< uno::XInterface > xVBARange;
3173 uno::Sequence< uno::Any > aArgs{ lcl_getSheetModule( xCellRange, &rDok ),
3176 if ( xVBARange.is() )
3183 catch( uno::Exception& )
3189static bool lcl_isNumericResult(
double& fVal,
const SbxVariable* pVar )
3209 fVal = (pVar->
GetBool() ? 1.0 : 0.0);
3222#if !HAVE_FEATURE_SCRIPTING
3258 SbxVariable* pVar = pRoot ? pRoot->
Find(aMacro, SbxClassType::Method) :
nullptr;
3271 bool bVolatileMacro =
false;
3276 OSL_ENSURE(
dynamic_cast<const StarBASIC *
>(
pObject) !=
nullptr,
"No Basic found!");
3279 if (pRoot && bUseVBAObjects)
3286 aBasicStr =
pObject->GetParent()->GetName();
3296 for( sal_uInt32
i = nParamCount;
i && bOk ;
i-- )
3315 if ( pToken->GetType() ==
svString )
3316 pPar->
PutString( pToken->GetString().getString() );
3317 else if ( pToken->GetType() ==
svDouble )
3321 SetError( FormulaError::IllegalArgument );
3331 if ( bUseVBAObjects )
3334 bOk = lcl_setVBARange( aRange,
mrDoc, pPar );
3350 PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
3351 if( nTab1 != nTab2 )
3353 SetError( FormulaError::IllegalParameter );
3358 if ( bUseVBAObjects )
3360 ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
3361 bOk = lcl_setVBARange( aRange,
mrDoc, pPar );
3366 refArray->AddDim(1, nRow2 - nRow1 + 1);
3367 refArray->AddDim(1, nCol2 - nCol1 + 1);
3369 for(
SCROW nRow = nRow1; bOk && nRow <= nRow2; nRow++ )
3372 sal_Int32 nIdx[ 2 ];
3373 nIdx[ 0 ] = nRow-nRow1+1;
3374 for(
SCCOL nCol = nCol1; bOk && nCol <= nCol2; nCol++ )
3377 nIdx[ 1 ] = nCol-nCol1+1;
3394 pMat->GetDimensions(nC, nR);
3396 refArray->AddDim(1,
static_cast<sal_Int32
>(nR));
3397 refArray->AddDim(1,
static_cast<sal_Int32
>(nC));
3398 for(
SCSIZE nMatRow = 0; nMatRow < nR; nMatRow++ )
3400 sal_Int32 nIdx[ 2 ];
3401 nIdx[ 0 ] =
static_cast<sal_Int32
>(nMatRow+1);
3402 for(
SCSIZE nMatCol = 0; nMatCol < nC; nMatCol++ )
3404 nIdx[ 1 ] =
static_cast<sal_Int32
>(nMatCol+1);
3406 if (pMat->IsStringOrEmpty(nMatCol, nMatRow))
3408 p->PutString( pMat->GetString(nMatCol, nMatRow).getString() );
3412 p->PutDouble( pMat->GetDouble(nMatCol, nMatRow));
3420 SetError( FormulaError::IllegalParameter );
3425 SetError( FormulaError::IllegalParameter );
3455 else if (lcl_isNumericResult( fVal, refRes.
get()))
3473 SbxBase* pElemObj = refRes->GetObject();
3475 sal_Int32 nDim = pDimArray ? pDimArray->
GetDims() : 0;
3476 if ( 1 <= nDim && nDim <= 2 )
3478 sal_Int32 nCs, nCe, nRs;
3484 pDimArray->
GetDim(1, nCs, nCe);
3485 nC =
static_cast<SCSIZE>(nCe - nCs + 1);
3494 pDimArray->
GetDim(1, nRs, nRe);
3495 nR =
static_cast<SCSIZE>(nRe - nRs + 1);
3496 pDimArray->
GetDim(2, nCs, nCe);
3497 nC =
static_cast<SCSIZE>(nCe - nCs + 1);
3505 for (
SCSIZE j=0; j < nR; j++ )
3507 sal_Int32 nIdx[ 2 ];
3510 nIdx[ nRowIdx ] = nRs +
static_cast<sal_Int32
>(j);
3513 nIdx[ nColIdx ] = nCs +
static_cast<sal_Int32
>(
i);
3514 pV = pDimArray->
Get(nIdx);
3515 if ( lcl_isNumericResult( fVal, pV) )
3548#if HAVE_FEATURE_SCRIPTING
3554 if (!aCell.isEmpty())
3558 switch (aCell.getType())
3569 nErr = aCell.getFormula()->GetErrCode();
3570 if( nErr == FormulaError::NONE )
3572 if (aCell.getFormula()->IsValue())
3574 nVal = aCell.getFormula()->GetValue();
3578 pVar->
PutString(aCell.getFormula()->GetString().getString());
3601 if (nParamCount != 3 && nParamCount != 5)
3607 if (nParamCount == 5)
3621 if ( bReuseLastParams )
3635 if ( nParamCount == 5 )
3664 pCell->SetTableOpDirty();
3668 if ( !bReuseLastParams )
3682 pCell->ResetTableOpDirtyVar();
3742 if (
aPos.
Col() == nStartCol )
3745 if ( nStartRow <= nMyRow && nMyRow <= aAbs.
aEnd.
Row())
3747 if ( nMyRow == nStartRow )
3767 if (
aPos.
Row() == nStartRow )
3770 if (nStartCol <= nMyCol && nMyCol <= aAbs.
aEnd.
Col())
3772 if ( nMyCol == nStartCol )
3798 while ( nParamCount-- > 0)
3810 , mpLinkManager(rDoc.GetLinkManager())
3811 , mrStrPool(rDoc.GetSharedStringPool())
3812 , pJumpMatrix(nullptr)
3813 , pMyFormulaCell(pCell)
3814 , pFormatter(rContext.GetFormatTable())
3828 , bCalcAsShown(rDoc.GetDocOptions().IsCalcAsShown())
3829 , meVolatileType(r.IsRecalcModeAlways() ? VOLATILE : NOT_VOLATILE)
3926 return rMat.
mpMat->GetDouble(0, nOffset);
3932 return rMat.
mpMat->GetDouble(nOffset, 0);
3935 return std::numeric_limits<double>::quiet_NaN();
3975 sal_uInt32 nRetIndexExpr = 0;
3976 sal_uInt16 nErrorFunction = 0;
3977 sal_uInt16 nErrorFunctionCount = 0;
3978 std::vector<sal_uInt16> aErrorFunctionStack;
3979 sal_uInt16 nStackBase;
3989 ScTokenMatrixMap::const_iterator aTokenMatrixMapIter;
4003 if (!
pCur || (
nGlobalError != FormulaError::NONE && nErrorFunction > nErrorFunctionCount) )
4013 else if (!FormulaCompiler::IsOpCodeJumpCommand( eOp ) &&
4016 (*aTokenMatrixMapIter).second->GetType() !=
svJumpMatrix)
4023 SAL_WARN(
"sc.core",
"Stack anomaly with calculated path at "
4027 <<
" eOp: " <<
static_cast<int>(eOp)
4029 <<
" nStackBase: " << nStackBase <<
" sp: " <<
sp);
4031 assert(!
"underflow");
4045 if (FormulaCompiler::IsOpCodeJumpCommand( eOp ))
4064 <<
" eOp: " <<
static_cast<int>(eOp)
4066 <<
" nStackBase: " << nStackBase <<
" sp: " <<
sp);
4068 assert(!
"underflow");