20#include <config_features.h>
25#include <rtl/math.hxx>
34#include <osl/thread.h>
42#include <com/sun/star/table/XCellRange.hpp>
43#include <com/sun/star/script/XInvocation.hpp>
44#include <com/sun/star/sheet/XSheetCellRange.hpp>
51#include <document.hxx>
67#include <tokenarray.hxx>
68#include <compiler.hxx>
78using ::std::unique_ptr;
80#define ADDIN_MAXSTRLEN 256
90 for (
size_t i = 0;
i < ListSize; ++
i )
93 if ( rPos == pTOp->
aOld1 )
98 else if ( rPos == pTOp->
aOld2 )
113 for (
size_t i = 0;
i < ListSize; ++
i )
131 nErr = FormulaError::NONE;
138 nErr = FormulaError::NONE;
167 if (nError != FormulaError::NONE)
198 if( nErr == FormulaError::NONE )
285 "Add check for columns > SAL_MAX_UINT16!");
290 sal_uInt16*
p =
reinterpret_cast<sal_uInt16*
>(pCellArr);
291 *
p++ =
static_cast<sal_uInt16
>(nCol1);
292 *
p++ =
static_cast<sal_uInt16
>(nRow1);
293 *
p++ =
static_cast<sal_uInt16
>(nTab1);
294 *
p++ =
static_cast<sal_uInt16
>(nCol2);
295 *
p++ =
static_cast<sal_uInt16
>(nRow2);
296 *
p++ =
static_cast<sal_uInt16
>(nTab2);
297 sal_uInt16* pCount =
p;
299 sal_uInt16
nPos = 14;
302 while (nTab <= nTab2)
306 while (nRow <= nRow2)
310 while (nCol <= nCol2)
340 if ((
nPos + (4 *
sizeof(sal_uInt16)) +
sizeof(
double)) >
MAXARRSIZE)
342 *
p++ =
static_cast<sal_uInt16
>(nCol);
343 *
p++ =
static_cast<sal_uInt16
>(nRow);
344 *
p++ =
static_cast<sal_uInt16
>(nTab);
345 *
p++ =
static_cast<sal_uInt16
>(nErr);
346 memcpy(
p, &nVal,
sizeof(
double));
347 nPos += 8 +
sizeof(double);
348 p =
reinterpret_cast<sal_uInt16*
>( pCellArr +
nPos );
369 "Add check for columns > SAL_MAX_UINT16!");
374 sal_uInt16*
p =
reinterpret_cast<sal_uInt16*
>(pCellArr);
375 *
p++ =
static_cast<sal_uInt16
>(nCol1);
376 *
p++ =
static_cast<sal_uInt16
>(nRow1);
377 *
p++ =
static_cast<sal_uInt16
>(nTab1);
378 *
p++ =
static_cast<sal_uInt16
>(nCol2);
379 *
p++ =
static_cast<sal_uInt16
>(nRow2);
380 *
p++ =
static_cast<sal_uInt16
>(nTab2);
381 sal_uInt16* pCount =
p;
383 sal_uInt16
nPos = 14;
385 while (nTab <= nTab2)
388 while (nRow <= nRow2)
391 while (nCol <= nCol2)
421 osl_getThreadTextEncoding()));
428 sal_uInt16 nStrLen =
static_cast<sal_uInt16
>(aTmp.getLength());
429 sal_uInt16 nLen = ( nStrLen + 2 ) & ~1;
433 *
p++ =
static_cast<sal_uInt16
>(nCol);
434 *
p++ =
static_cast<sal_uInt16
>(nRow);
435 *
p++ =
static_cast<sal_uInt16
>(nTab);
436 *
p++ =
static_cast<sal_uInt16
>(nErr);
438 memcpy(
p, aTmp.getStr(), nStrLen + 1);
439 nPos += 10 + nStrLen + 1;
441 if( (nStrLen & 1) == 0 )
446 p =
reinterpret_cast<sal_uInt16*
>( pCellArr +
nPos );
467 "Add check for columns > SAL_MAX_UINT16!");
472 sal_uInt16*
p =
reinterpret_cast<sal_uInt16*
>(pCellArr);
473 *
p++ =
static_cast<sal_uInt16
>(nCol1);
474 *
p++ =
static_cast<sal_uInt16
>(nRow1);
475 *
p++ =
static_cast<sal_uInt16
>(nTab1);
476 *
p++ =
static_cast<sal_uInt16
>(nCol2);
477 *
p++ =
static_cast<sal_uInt16
>(nRow2);
478 *
p++ =
static_cast<sal_uInt16
>(nTab2);
479 sal_uInt16* pCount =
p;
481 sal_uInt16
nPos = 14;
484 while (nTab <= nTab2)
488 while (nRow <= nRow2)
492 while (nCol <= nCol2)
499 sal_uInt16
nType = 0;
528 *
p++ =
static_cast<sal_uInt16
>(nCol);
529 *
p++ =
static_cast<sal_uInt16
>(nRow);
530 *
p++ =
static_cast<sal_uInt16
>(nTab);
531 *
p++ =
static_cast<sal_uInt16
>(nErr);
538 memcpy(
p, &nVal,
sizeof(
double));
539 nPos +=
sizeof(double);
544 osl_getThreadTextEncoding()));
551 sal_uInt16 nStrLen =
static_cast<sal_uInt16
>(aTmp.getLength());
552 sal_uInt16 nLen = ( nStrLen + 2 ) & ~1;
556 memcpy(
p, aTmp.getStr(), nStrLen + 1);
557 nPos += 2 + nStrLen + 1;
559 if( (nStrLen & 1) == 0 )
566 p =
reinterpret_cast<sal_uInt16*
>( pCellArr +
nPos );
586 SetError( FormulaError::StackOverflow );
602 SetError( FormulaError::StackOverflow );
621 SetError( FormulaError::StackOverflow );
623 p->DeleteIfZeroRef();
637 p->DeleteIfZeroRef();
651 SetError( FormulaError::StackOverflow );
670 SetError( FormulaError::StackOverflow );
693 if (pRetTypeExpr && pRetIndexExpr)
703 if (nErr != FormulaError::NONE)
707 *pRetTypeExpr = SvNumFormatType::UNDEFINED;
717 *pRetTypeExpr = SvNumFormatType::TEXT;
748 SetError(FormulaError::UnknownStackVariable);
762 SetError(FormulaError::UnknownStackVariable);
776 SetError(FormulaError::UnknownStackVariable);
788 switch (
p->GetType())
796 if (
nType != SvNumFormatType::ALL &&
nType != SvNumFormatType::UNDEFINED)
798 return p->GetDouble();
804 SetError( FormulaError::IllegalArgument);
808 SetError( FormulaError::UnknownStackVariable);
820 switch (
p->GetType())
826 return p->GetString();
831 SetError( FormulaError::IllegalArgument);
835 SetError( FormulaError::UnknownStackVariable);
856 for (
const auto& rRef : rRefList)
912 switch (
p->GetType())
930 rAdr.
Set( nCol, nRow, nTab );
936 SetError( FormulaError::IllegalParameter);
940 SetError( FormulaError::UnknownStackVariable);
955 ScRange aRange( rCol1, rRow1, rTab1, rCol2, rRow2, rTab2 );
957 SetError( FormulaError::IllegalParameter );
967 SetError(FormulaError::UnknownStackVariable);
981 ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2));
996 SetError( FormulaError::IllegalParameter);
1009 switch (
p->GetType())
1018 SetError( FormulaError::IllegalParameter);
1022 SetError( FormulaError::UnknownStackVariable);
1026 ScRange & rRange,
bool bDontCheckForTableOp )
1034 rRange.
aEnd.
Set( nCol, nRow, nTab );
1039 SetError( FormulaError::IllegalParameter );
1068 if (rRefInList < pList->
size())
1071 if (++rRefInList < pList->
size())
1083 SetError( FormulaError::IllegalParameter);
1088 SetError( FormulaError::IllegalParameter);
1092 SetError( FormulaError::UnknownStackVariable);
1101 switch (
p->GetType())
1110 SetError( FormulaError::IllegalParameter);
1114 SetError( FormulaError::UnknownStackVariable);
1122 switch (
p->GetType())
1125 return p->GetDoubleRef();
1129 if (rRefInList < pList->
size())
1130 return &(*pList)[rRefInList];
1144 SetError(FormulaError::UnknownStackVariable);
1160 SetError( FormulaError::IllegalParameter);
1164 rFileId =
p->GetIndex();
1165 rTabName =
p->GetString().getString();
1166 rRef = *
p->GetSingleRef();
1195 OSL_FAIL(
"ScCompiler::GetToken: external single reference must have an absolute table reference!");
1203 rFileId, rTabName, aAddr, &
aPos,
nullptr, &aFmt);
1211 if (xNew->GetType() ==
svError)
1223 SetError(FormulaError::UnknownStackVariable);
1239 SetError( FormulaError::IllegalParameter);
1243 rFileId =
p->GetIndex();
1244 rTabName =
p->GetString().getString();
1245 rRef = *
p->GetDoubleRef();
1274 SetError( FormulaError::IllegalParameter);
1277 rMat =
p->GetMatrix();
1279 SetError( FormulaError::UnknownVariable);
1295 OSL_FAIL(
"ScCompiler::GetToken: external double reference must have an absolute table reference!");
1309 nFileId, rTabName, aRange, &
aPos);
1313 SetError(FormulaError::IllegalArgument);
1327 SetError(FormulaError::IllegalArgument);
1334 SetError( FormulaError::IllegalArgument);
1382 const std::vector<ScComplexRefData>* pv = xTok->
GetRefList();
1385 const size_t nEntries = pv->size();
1396 for (
const auto & rRef : *pv)
1398 if (rRef.Ref1 != rRef.Ref2)
1404 for (
size_t i=0;
i < nEntries; ++
i)
1415 xMat->PutEmpty( 0,
i);
1419 xMat->PutDouble( aCell.
getValue(), 0,
i);
1459 OSL_ENSURE( nParams <=
sp,
"ConvertMatrixParameters: stack/param count mismatch");
1460 SCSIZE nJumpCols = 0, nJumpRows = 0;
1461 for ( sal_uInt16
i=1;
i <= nParams &&
i <=
sp; ++
i )
1466 OSL_FAIL(
"ConvertMatrixParameters: not a push");
1470 switch (
p->GetType() )
1484 == formula::ParamClass::Value )
1488 SetError( FormulaError::UnknownVariable);
1492 pMat->GetDimensions( nCols, nRows);
1493 if ( nJumpCols < nCols )
1495 if ( nJumpRows < nRows )
1504 if (
eType != formula::ParamClass::Reference &&
1505 eType != formula::ParamClass::ReferenceOrRefArray &&
1506 eType != formula::ParamClass::ReferenceOrForceArray &&
1521 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
1524 if (
eType == formula::ParamClass::Value )
1527 nJumpCols =
static_cast<SCSIZE>(nCol2 - nCol1 + 1);
1529 nJumpRows =
static_cast<SCSIZE>(nRow2 - nRow1 + 1);
1542 if (
eType == formula::ParamClass::Value ||
eType == formula::ParamClass::Array)
1544 sal_uInt16 nFileId =
p->GetIndex();
1545 OUString aTabName =
p->GetString().getString();
1558 if (
eType == formula::ParamClass::Value)
1578 if (
eType != formula::ParamClass::Reference &&
1579 eType != formula::ParamClass::ReferenceOrRefArray &&
1580 eType != formula::ParamClass::ReferenceOrForceArray &&
1581 eType != formula::ParamClass::ForceArray)
1591 OSL_FAIL(
"ConvertMatrixParameters: unknown parameter type");
1595 if( nJumpCols && nJumpRows )
1598 short nStart = nPC - 1;
1600 short nStop = nPC + 1;
1602 ScTokenMatrixMap::const_iterator aMapIter;
1604 xNew = (*aMapIter).second;
1607 auto pJumpMat = std::make_shared<ScJumpMatrix>(
pCur->
GetOpCode(), nJumpCols, nJumpRows);
1608 pJumpMat->SetAllJumps( 1.0, nStart, nNext, nStop);
1611 for ( sal_uInt16
i=1; i <= nParams && sp > 0; ++
i )
1616 aParams[ nParams -
i ] =
p;
1618 pJumpMat->SetJumpParameters( std::move(aParams) );
1636 switch (
p->GetType())
1650 SetError( FormulaError::UnknownVariable);
1654 SetError( FormulaError::IllegalParameter);
1658 SetError( FormulaError::UnknownStackVariable);
1676 aRet.
mpMat->SetErrorInterpreter(
this);
1692 SetError( FormulaError::UnknownVariable);
1707 xMat->GetDimensions(nCols, nRows);
1712 if ( xMat->IsEmptyPath( 0, 0))
1716 rRetTypeExpr = SvNumFormatType::LOGICAL;
1718 else if ( xMat->IsEmptyResult( 0, 0))
1723 else if ( xMat->IsEmpty( 0, 0))
1732 rRetTypeExpr = SvNumFormatType::TEXT;
1739 if (nErr != FormulaError::NONE)
1744 if ( rRetTypeExpr != SvNumFormatType::LOGICAL )
1745 rRetTypeExpr = SvNumFormatType::NUMBER;
1748 xMat->SetErrorInterpreter(
nullptr);
1751 SetError( FormulaError::UnknownStackVariable);
1761 if (
p &&
p->GetRef() == 1)
1763 p->GetDoubleAsReference() = fVal;
1764 p->SetDoubleType(
static_cast<sal_Int16
>(nFmt) );
1846 sal_uInt16 nFileId,
const OUString& rTabName,
SCCOL nCol,
SCROW nRow,
SCTAB nTab)
1858 sal_uInt16 nFileId,
const OUString& rTabName,
1899 rMat.
mpMat->SetErrorInterpreter(
nullptr);
1906 pMat->SetErrorInterpreter(
nullptr);
1923 PushError( FormulaError::ParameterExpected);
1928 PushError( FormulaError::IllegalParameter);
1933 PushError( FormulaError::IllegalArgument);
1960 SetError(FormulaError::UnknownStackVariable);
1977 SetError(FormulaError::UnknownStackVariable);
2000 assert(
sp >= nParamCount &&
" less stack elements than parameters");
2001 sal_uInt16 nStackParams = std::min<sal_uInt16>(
sp, nParamCount);
2020 SetError( FormulaError::IllegalArgument);
2025 rAdr.
SetCol( sal::static_int_cast<SCCOL>( rRange.
aStart.
Col() + nC ) );
2026 rAdr.
SetRow( sal::static_int_cast<SCROW>( rRange.
aStart.
Row() + nR ) );
2051 double fVal = pMat->GetDoubleWithStringConversion( 0, 0);
2053 if (nErr != FormulaError::NONE)
2063 SCSIZE nCols, nRows, nC, nR;
2064 pMat->GetDimensions( nCols, nRows);
2067 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2069 double fVal = pMat->GetDoubleWithStringConversion( nC, nR);
2071 if (nErr != FormulaError::NONE)
2125 nVal = pToken->GetDouble();
2158 SetError( FormulaError::IllegalParameter);
2171 nResultVal = nDefault;
2177 if (!std::isfinite(fVal))
2184 fVal = rtl::math::approxFloor( fVal);
2187 SetError( FormulaError::IllegalArgument);
2191 else if (fVal < 0.0)
2193 fVal = rtl::math::approxCeil( fVal);
2196 SetError( FormulaError::IllegalArgument);
2200 return static_cast<sal_Int32
>(fVal);
2220 if (!std::isfinite(fVal))
2227 fVal = rtl::math::approxFloor( fVal);
2230 SetError( FormulaError::IllegalArgument);
2234 else if (fVal < 0.0)
2236 fVal = rtl::math::approxCeil( fVal);
2239 SetError( FormulaError::IllegalArgument);
2243 return static_cast<sal_Int16
>(fVal);
2248 double fVal = rtl::math::approxFloor(
GetDouble());
2249 if (!std::isfinite(fVal))
2256 SetError( FormulaError::IllegalArgument);
2259 return static_cast<sal_uInt32
>(fVal);
2264 bool bDouble =
true;
2314 SetError( FormulaError::IllegalParameter);
2380 return pToken->GetString();
2396 SetError( FormulaError::IllegalArgument);
2411 SCSIZE nCols, nRows, nC, nR;
2412 pMat->GetDimensions( nCols, nRows);
2415 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2416 return pMat->GetString( *
pFormatter, nC, nR);
2440 SetError( FormulaError::IllegalParameter);
2451 nMatVal = pMat->Get(0, 0);
2452 nMatValType = nMatVal.
nType;
2456 SCSIZE nCols, nRows, nC, nR;
2457 pMat->GetDimensions( nCols, nRows);
2460 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2462 nMatVal = pMat->Get( nC, nR);
2463 nMatValType = nMatVal.
nType;
2471 rDouble = nMatVal.
fVal;
2473 if (nError != FormulaError::NONE)
2487 SvNumFormatType::NUMBER,
2496 bool bMissingField =
false;
2497 unique_ptr<ScDBQueryParamBase> pQueryParam(
GetDBParams(bMissingField) );
2505 pQueryParam->mbSkipString =
false;
2508 if (!aValIter.
GetFirst(aValue) || aValue.
mnError != FormulaError::NONE)
2516 if (aValIter.
GetNext(aValNext) && aValNext.
mnError == FormulaError::NONE)
2535 if (pLegacyFuncData)
2540 if (nParamCount < MAXFUNCPARAM && nParamCount == pLegacyFuncData->GetParamCount() - 1)
2552 ppParam[
i] =
nullptr;
2555 pCellArr[
i] =
nullptr;
2558 for (
i = nParamCount; (
i > 0) && (
nGlobalError == FormulaError::NONE);
i--)
2565 SetError( FormulaError::ParameterExpected);
2568 switch (eParamType[
i])
2573 ppParam[
i] = &nVal[
i-1];
2579 osl_getThreadTextEncoding()));
2581 SetError( FormulaError::StringOverflow );
2587 ppParam[
i] = pStr[
i-1];
2599 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2601 if (!
CreateDoubleArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2602 SetError(FormulaError::CodeOverflow);
2604 ppParam[
i] = pCellArr[
i-1];
2615 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2617 if (!
CreateStringArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2618 SetError(FormulaError::CodeOverflow);
2620 ppParam[
i] = pCellArr[
i-1];
2631 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2633 if (!
CreateCellArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2634 SetError(FormulaError::CodeOverflow);
2636 ppParam[
i] = pCellArr[
i-1];
2640 SetError(FormulaError::IllegalParameter);
2651 switch ( eParamType[0] )
2657 pLegacyFuncData->
Call(ppParam);
2664 ppParam[0] = pcErg.get();
2665 pLegacyFuncData->
Call(ppParam);
2666 OUString aUni( pcErg.get(), strlen(pcErg.get()), osl_getThreadTextEncoding() );
2671 PushError( FormulaError::UnknownState );
2681 pLegacyFuncData->
Call(ppParam);
2708 PushError( FormulaError::UnknownState );
2722 delete[] pCellArr[
i];
2727 while( nParamCount-- > 0)
2740 SetError( FormulaError::IllegalParameter );
2750 aCall.
SetCaller(
static_cast<beans::XPropertySet*
>(
2755 short nPar = nParamCount;
2756 while ( nPar > 0 &&
GetError() == FormulaError::NONE )
2792 switch( nStackType )
2801 uno::Sequence<sal_Int32> aInner( &nVal, 1 );
2802 uno::Sequence< uno::Sequence<sal_Int32> > aOuter( &aInner, 1 );
2812 SetError(FormulaError::IllegalParameter);
2817 SetError(FormulaError::IllegalParameter);
2821 SetError(FormulaError::IllegalParameter);
2826 switch( nStackType )
2833 uno::Sequence<double> aInner( &fVal, 1 );
2834 uno::Sequence< uno::Sequence<double> > aOuter( &aInner, 1 );
2843 SetError(FormulaError::IllegalParameter);
2848 SetError(FormulaError::IllegalParameter);
2852 SetError(FormulaError::IllegalParameter);
2857 switch( nStackType )
2864 uno::Sequence<OUString> aInner( &aString, 1 );
2865 uno::Sequence< uno::Sequence<OUString> > aOuter( &aInner, 1 );
2874 SetError(FormulaError::IllegalParameter);
2879 SetError(FormulaError::IllegalParameter);
2883 SetError(FormulaError::IllegalParameter);
2888 switch( nStackType )
2909 aElem <<=
aStr.getString();
2915 uno::Sequence<uno::Any> aInner( &aElem, 1 );
2916 uno::Sequence< uno::Sequence<uno::Any> > aOuter( &aInner, 1 );
2925 SetError(FormulaError::IllegalParameter);
2930 SetError(FormulaError::IllegalParameter);
2934 SetError(FormulaError::IllegalParameter);
2939 switch( nStackType )
2957 aParam <<=
aStr.getString();
2969 SetError(FormulaError::IllegalParameter);
2974 SetError(FormulaError::IllegalParameter);
2978 SetError(FormulaError::IllegalParameter);
2983 switch( nStackType )
2990 uno::Reference<table::XCellRange> xObj =
2995 SetError(FormulaError::IllegalParameter);
3002 uno::Reference<table::XCellRange> xObj =
3010 SetError(FormulaError::IllegalParameter);
3016 SetError(FormulaError::IllegalParameter);
3022 SetError(FormulaError::IllegalParameter);
3031 if (
GetError() == FormulaError::NONE )
3038 uno::Reference<sheet::XVolatileResult> xRes = aCall.
GetVarRes();
3045 bool bTemporaryListener =
false;
3052 bTemporaryListener =
true;
3065 if (bTemporaryListener)
3071 css::lang::EventObject
aEvent;
3074 catch (
const uno::Exception&)
3080 if ( aCall.
GetErrCode() != FormulaError::NONE )
3102 while( nParamCount-- > 0)
3118#if HAVE_FEATURE_SCRIPTING
3120static uno::Any lcl_getSheetModule(
const uno::Reference<table::XCellRange>& xCellRange,
const ScDocument* pDok )
3122 uno::Reference< sheet::XSheetCellRange > xSheetRange( xCellRange, uno::UNO_QUERY_THROW );
3123 uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW );
3125 xProps->getPropertyValue(
"CodeName") >>= sCodeName;
3133 uno::Reference< uno::XInterface > xIf;
3134 if ( pBasMgr && !pBasMgr->GetName().isEmpty() )
3136 OUString sProj(
"Standard" );
3159 uno::Reference< uno::XInterface > xVBARange;
3161 uno::Sequence< uno::Any > aArgs{ lcl_getSheetModule( xCellRange, &rDok ),
3164 if ( xVBARange.is() )
3171 catch( uno::Exception& )
3177static bool lcl_isNumericResult(
double& fVal,
const SbxVariable* pVar )
3197 fVal = (pVar->
GetBool() ? 1.0 : 0.0);
3210#if !HAVE_FEATURE_SCRIPTING
3246 SbxVariable* pVar = pRoot ? pRoot->
Find(aMacro, SbxClassType::Method) :
nullptr;
3259 bool bVolatileMacro =
false;
3264 OSL_ENSURE(
dynamic_cast<const StarBASIC *
>(
pObject) !=
nullptr,
"No Basic found!");
3267 if (pRoot && bUseVBAObjects)
3274 aBasicStr =
pObject->GetParent()->GetName();
3284 for( sal_uInt32
i = nParamCount;
i && bOk ;
i-- )
3303 if ( pToken->GetType() ==
svString )
3304 pPar->
PutString( pToken->GetString().getString() );
3305 else if ( pToken->GetType() ==
svDouble )
3309 SetError( FormulaError::IllegalArgument );
3319 if ( bUseVBAObjects )
3322 bOk = lcl_setVBARange( aRange,
mrDoc, pPar );
3338 PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
3339 if( nTab1 != nTab2 )
3341 SetError( FormulaError::IllegalParameter );
3346 if ( bUseVBAObjects )
3348 ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
3349 bOk = lcl_setVBARange( aRange,
mrDoc, pPar );
3354 refArray->AddDim(1, nRow2 - nRow1 + 1);
3355 refArray->AddDim(1, nCol2 - nCol1 + 1);
3357 for(
SCROW nRow = nRow1; bOk && nRow <= nRow2; nRow++ )
3360 sal_Int32 nIdx[ 2 ];
3361 nIdx[ 0 ] = nRow-nRow1+1;
3362 for(
SCCOL nCol = nCol1; bOk && nCol <= nCol2; nCol++ )
3365 nIdx[ 1 ] = nCol-nCol1+1;
3382 pMat->GetDimensions(nC, nR);
3384 refArray->AddDim(1,
static_cast<sal_Int32
>(nR));
3385 refArray->AddDim(1,
static_cast<sal_Int32
>(nC));
3386 for(
SCSIZE nMatRow = 0; nMatRow < nR; nMatRow++ )
3388 sal_Int32 nIdx[ 2 ];
3389 nIdx[ 0 ] =
static_cast<sal_Int32
>(nMatRow+1);
3390 for(
SCSIZE nMatCol = 0; nMatCol < nC; nMatCol++ )
3392 nIdx[ 1 ] =
static_cast<sal_Int32
>(nMatCol+1);
3394 if (pMat->IsStringOrEmpty(nMatCol, nMatRow))
3396 p->PutString( pMat->GetString(nMatCol, nMatRow).getString() );
3400 p->PutDouble( pMat->GetDouble(nMatCol, nMatRow));
3408 SetError( FormulaError::IllegalParameter );
3413 SetError( FormulaError::IllegalParameter );
3443 else if (lcl_isNumericResult( fVal, refRes.
get()))
3461 SbxBase* pElemObj = refRes->GetObject();
3463 sal_Int32 nDim = pDimArray ? pDimArray->
GetDims() : 0;
3464 if ( 1 <= nDim && nDim <= 2 )
3466 sal_Int32 nCs, nCe, nRs;
3472 pDimArray->
GetDim(1, nCs, nCe);
3473 nC =
static_cast<SCSIZE>(nCe - nCs + 1);
3482 pDimArray->
GetDim(1, nRs, nRe);
3483 nR =
static_cast<SCSIZE>(nRe - nRs + 1);
3484 pDimArray->
GetDim(2, nCs, nCe);
3485 nC =
static_cast<SCSIZE>(nCe - nCs + 1);
3493 for (
SCSIZE j=0; j < nR; j++ )
3495 sal_Int32 nIdx[ 2 ];
3498 nIdx[ nRowIdx ] = nRs +
static_cast<sal_Int32
>(j);
3501 nIdx[ nColIdx ] = nCs +
static_cast<sal_Int32
>(
i);
3502 pV = pDimArray->
Get(nIdx);
3503 if ( lcl_isNumericResult( fVal, pV) )
3536#if HAVE_FEATURE_SCRIPTING
3542 if (!aCell.isEmpty())
3546 switch (aCell.getType())
3557 nErr = aCell.getFormula()->GetErrCode();
3558 if( nErr == FormulaError::NONE )
3560 if (aCell.getFormula()->IsValue())
3562 nVal = aCell.getFormula()->GetValue();
3566 pVar->
PutString(aCell.getFormula()->GetString().getString());
3589 if (nParamCount != 3 && nParamCount != 5)
3595 if (nParamCount == 5)
3609 if ( bReuseLastParams )
3623 if ( nParamCount == 5 )
3652 pCell->SetTableOpDirty();
3656 if ( !bReuseLastParams )
3670 pCell->ResetTableOpDirtyVar();
3730 if (
aPos.
Col() == nStartCol )
3733 if ( nStartRow <= nMyRow && nMyRow <= aAbs.
aEnd.
Row())
3735 if ( nMyRow == nStartRow )
3755 if (
aPos.
Row() == nStartRow )
3758 if (nStartCol <= nMyCol && nMyCol <= aAbs.
aEnd.
Col())
3760 if ( nMyCol == nStartCol )
3786 while ( nParamCount-- > 0)
3798 , mpLinkManager(rDoc.GetLinkManager())
3799 , mrStrPool(rDoc.GetSharedStringPool())
3800 , pJumpMatrix(nullptr)
3801 , pMyFormulaCell(pCell)
3802 , pFormatter(rContext.GetFormatTable())
3816 , bCalcAsShown(rDoc.GetDocOptions().IsCalcAsShown())
3817 , meVolatileType(r.IsRecalcModeAlways() ? VOLATILE : NOT_VOLATILE)
3914 return rMat.
mpMat->GetDouble(0, nOffset);
3920 return rMat.
mpMat->GetDouble(nOffset, 0);
3923 return std::numeric_limits<double>::quiet_NaN();
3963 sal_uInt32 nRetIndexExpr = 0;
3964 sal_uInt16 nErrorFunction = 0;
3965 sal_uInt16 nErrorFunctionCount = 0;
3966 std::vector<sal_uInt16> aErrorFunctionStack;
3967 sal_uInt16 nStackBase;
3977 ScTokenMatrixMap::const_iterator aTokenMatrixMapIter;
3991 if (!
pCur || (
nGlobalError != FormulaError::NONE && nErrorFunction > nErrorFunctionCount) )
4001 else if (!FormulaCompiler::IsOpCodeJumpCommand( eOp ) &&
4004 (*aTokenMatrixMapIter).second->GetType() !=
svJumpMatrix)
4008 if ( nStackBase >
sp )
4022 if (FormulaCompiler::IsOpCodeJumpCommand( eOp ))