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 auto pJumpMat = std::make_shared<ScJumpMatrix>(
pCur->
GetOpCode(), nJumpCols, nJumpRows);
1611 pJumpMat->SetAllJumps( 1.0, nStart, nNext, nStop);
1614 for ( sal_uInt16
i=1; i <= nParams && sp > 0; ++
i )
1619 aParams[ nParams -
i ] =
p;
1621 pJumpMat->SetJumpParameters( std::move(aParams) );
1639 switch (
p->GetType())
1653 SetError( FormulaError::UnknownVariable);
1657 SetError( FormulaError::IllegalParameter);
1661 SetError( FormulaError::UnknownStackVariable);
1679 aRet.
mpMat->SetErrorInterpreter(
this);
1695 SetError( FormulaError::UnknownVariable);
1710 xMat->GetDimensions(nCols, nRows);
1715 if ( xMat->IsEmptyPath( 0, 0))
1719 rRetTypeExpr = SvNumFormatType::LOGICAL;
1721 else if ( xMat->IsEmptyResult( 0, 0))
1726 else if ( xMat->IsEmpty( 0, 0))
1735 rRetTypeExpr = SvNumFormatType::TEXT;
1742 if (nErr != FormulaError::NONE)
1747 if ( rRetTypeExpr != SvNumFormatType::LOGICAL )
1748 rRetTypeExpr = SvNumFormatType::NUMBER;
1751 xMat->SetErrorInterpreter(
nullptr);
1754 SetError( FormulaError::UnknownStackVariable);
1764 if (
p &&
p->GetRef() == 1)
1766 p->GetDoubleAsReference() = fVal;
1767 p->SetDoubleType(
static_cast<sal_Int16
>(nFmt) );
1849 sal_uInt16 nFileId,
const OUString& rTabName,
SCCOL nCol,
SCROW nRow,
SCTAB nTab)
1861 sal_uInt16 nFileId,
const OUString& rTabName,
1902 rMat.
mpMat->SetErrorInterpreter(
nullptr);
1909 pMat->SetErrorInterpreter(
nullptr);
1926 PushError( FormulaError::ParameterExpected);
1931 PushError( FormulaError::IllegalParameter);
1936 PushError( FormulaError::IllegalArgument);
1963 SetError(FormulaError::UnknownStackVariable);
1980 SetError(FormulaError::UnknownStackVariable);
2003 assert(
sp >= nParamCount &&
" less stack elements than parameters");
2004 sal_uInt16 nStackParams = std::min<sal_uInt16>(
sp, nParamCount);
2023 SetError( FormulaError::IllegalArgument);
2028 rAdr.
SetCol( sal::static_int_cast<SCCOL>( rRange.
aStart.
Col() + nC ) );
2029 rAdr.
SetRow( sal::static_int_cast<SCROW>( rRange.
aStart.
Row() + nR ) );
2054 double fVal = pMat->GetDoubleWithStringConversion( 0, 0);
2056 if (nErr != FormulaError::NONE)
2066 SCSIZE nCols, nRows, nC, nR;
2067 pMat->GetDimensions( nCols, nRows);
2070 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2072 double fVal = pMat->GetDoubleWithStringConversion( nC, nR);
2074 if (nErr != FormulaError::NONE)
2128 nVal = pToken->GetDouble();
2161 SetError( FormulaError::IllegalParameter);
2174 nResultVal = nDefault;
2180 if (!std::isfinite(fVal))
2187 fVal = rtl::math::approxFloor( fVal);
2190 SetError( FormulaError::IllegalArgument);
2194 else if (fVal < 0.0)
2196 fVal = rtl::math::approxCeil( fVal);
2199 SetError( FormulaError::IllegalArgument);
2203 return static_cast<sal_Int32
>(fVal);
2223 if (!std::isfinite(fVal))
2230 fVal = rtl::math::approxFloor( fVal);
2233 SetError( FormulaError::IllegalArgument);
2237 else if (fVal < 0.0)
2239 fVal = rtl::math::approxCeil( fVal);
2242 SetError( FormulaError::IllegalArgument);
2246 return static_cast<sal_Int16
>(fVal);
2251 double fVal = rtl::math::approxFloor(
GetDouble());
2252 if (!std::isfinite(fVal))
2259 SetError( FormulaError::IllegalArgument);
2262 return static_cast<sal_uInt32
>(fVal);
2267 bool bDouble =
true;
2317 SetError( FormulaError::IllegalParameter);
2383 return pToken->GetString();
2399 SetError( FormulaError::IllegalArgument);
2414 SCSIZE nCols, nRows, nC, nR;
2415 pMat->GetDimensions( nCols, nRows);
2418 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2419 return pMat->GetString( *
pFormatter, nC, nR);
2443 SetError( FormulaError::IllegalParameter);
2454 nMatVal = pMat->Get(0, 0);
2455 nMatValType = nMatVal.
nType;
2459 SCSIZE nCols, nRows, nC, nR;
2460 pMat->GetDimensions( nCols, nRows);
2463 if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) )
2465 nMatVal = pMat->Get( nC, nR);
2466 nMatValType = nMatVal.
nType;
2474 rDouble = nMatVal.
fVal;
2476 if (nError != FormulaError::NONE)
2490 SvNumFormatType::NUMBER,
2499 bool bMissingField =
false;
2500 unique_ptr<ScDBQueryParamBase> pQueryParam(
GetDBParams(bMissingField) );
2508 pQueryParam->mbSkipString =
false;
2511 if (!aValIter.
GetFirst(aValue) || aValue.
mnError != FormulaError::NONE)
2519 if (aValIter.
GetNext(aValNext) && aValNext.
mnError == FormulaError::NONE)
2538 if (pLegacyFuncData)
2543 if (nParamCount < MAXFUNCPARAM && nParamCount == pLegacyFuncData->GetParamCount() - 1)
2555 ppParam[
i] =
nullptr;
2558 pCellArr[
i] =
nullptr;
2561 for (
i = nParamCount; (
i > 0) && (
nGlobalError == FormulaError::NONE);
i--)
2568 SetError( FormulaError::ParameterExpected);
2571 switch (eParamType[
i])
2576 ppParam[
i] = &nVal[
i-1];
2582 osl_getThreadTextEncoding()));
2584 SetError( FormulaError::StringOverflow );
2590 ppParam[
i] = pStr[
i-1];
2602 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2604 if (!
CreateDoubleArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2605 SetError(FormulaError::CodeOverflow);
2607 ppParam[
i] = pCellArr[
i-1];
2618 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2620 if (!
CreateStringArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2621 SetError(FormulaError::CodeOverflow);
2623 ppParam[
i] = pCellArr[
i-1];
2634 PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
2636 if (!
CreateCellArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[
i-1]))
2637 SetError(FormulaError::CodeOverflow);
2639 ppParam[
i] = pCellArr[
i-1];
2643 SetError(FormulaError::IllegalParameter);
2654 switch ( eParamType[0] )
2660 pLegacyFuncData->
Call(ppParam);
2667 ppParam[0] = pcErg.get();
2668 pLegacyFuncData->
Call(ppParam);
2669 OUString aUni( pcErg.get(), strlen(pcErg.get()), osl_getThreadTextEncoding() );
2674 PushError( FormulaError::UnknownState );
2684 pLegacyFuncData->
Call(ppParam);
2711 PushError( FormulaError::UnknownState );
2725 delete[] pCellArr[
i];
2730 while( nParamCount-- > 0)
2743 SetError( FormulaError::IllegalParameter );
2753 aCall.
SetCaller(
static_cast<beans::XPropertySet*
>(
2758 short nPar = nParamCount;
2759 while ( nPar > 0 &&
GetError() == FormulaError::NONE )
2795 switch( nStackType )
2804 uno::Sequence<sal_Int32> aInner( &nVal, 1 );
2805 uno::Sequence< uno::Sequence<sal_Int32> > aOuter( &aInner, 1 );
2815 SetError(FormulaError::IllegalParameter);
2820 SetError(FormulaError::IllegalParameter);
2824 SetError(FormulaError::IllegalParameter);
2829 switch( nStackType )
2836 uno::Sequence<double> aInner( &fVal, 1 );
2837 uno::Sequence< uno::Sequence<double> > aOuter( &aInner, 1 );
2846 SetError(FormulaError::IllegalParameter);
2851 SetError(FormulaError::IllegalParameter);
2855 SetError(FormulaError::IllegalParameter);
2860 switch( nStackType )
2867 uno::Sequence<OUString> aInner( &aString, 1 );
2868 uno::Sequence< uno::Sequence<OUString> > aOuter( &aInner, 1 );
2877 SetError(FormulaError::IllegalParameter);
2882 SetError(FormulaError::IllegalParameter);
2886 SetError(FormulaError::IllegalParameter);
2891 switch( nStackType )
2912 aElem <<=
aStr.getString();
2918 uno::Sequence<uno::Any> aInner( &aElem, 1 );
2919 uno::Sequence< uno::Sequence<uno::Any> > aOuter( &aInner, 1 );
2928 SetError(FormulaError::IllegalParameter);
2933 SetError(FormulaError::IllegalParameter);
2937 SetError(FormulaError::IllegalParameter);
2942 switch( nStackType )
2960 aParam <<=
aStr.getString();
2972 SetError(FormulaError::IllegalParameter);
2977 SetError(FormulaError::IllegalParameter);
2981 SetError(FormulaError::IllegalParameter);
2986 switch( nStackType )
2993 uno::Reference<table::XCellRange> xObj =
2998 SetError(FormulaError::IllegalParameter);
3005 uno::Reference<table::XCellRange> xObj =
3013 SetError(FormulaError::IllegalParameter);
3019 SetError(FormulaError::IllegalParameter);
3025 SetError(FormulaError::IllegalParameter);
3034 if (
GetError() == FormulaError::NONE )
3041 uno::Reference<sheet::XVolatileResult> xRes = aCall.
GetVarRes();
3048 bool bTemporaryListener =
false;
3055 bTemporaryListener =
true;
3068 if (bTemporaryListener)
3074 css::lang::EventObject
aEvent;
3077 catch (
const uno::Exception&)
3083 if ( aCall.
GetErrCode() != FormulaError::NONE )
3105 while( nParamCount-- > 0)
3121#if HAVE_FEATURE_SCRIPTING
3123static uno::Any lcl_getSheetModule(
const uno::Reference<table::XCellRange>& xCellRange,
const ScDocument* pDok )
3125 uno::Reference< sheet::XSheetCellRange > xSheetRange( xCellRange, uno::UNO_QUERY_THROW );
3126 uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW );
3128 xProps->getPropertyValue(
"CodeName") >>= sCodeName;
3136 uno::Reference< uno::XInterface > xIf;
3137 if ( pBasMgr && !pBasMgr->
GetName().isEmpty() )
3139 OUString sProj(
"Standard" );
3162 uno::Reference< uno::XInterface > xVBARange;
3164 uno::Sequence< uno::Any > aArgs{ lcl_getSheetModule( xCellRange, &rDok ),
3167 if ( xVBARange.is() )
3174 catch( uno::Exception& )
3180static bool lcl_isNumericResult(
double& fVal,
const SbxVariable* pVar )
3200 fVal = (pVar->
GetBool() ? 1.0 : 0.0);
3213#if !HAVE_FEATURE_SCRIPTING
3249 SbxVariable* pVar = pRoot ? pRoot->
Find(aMacro, SbxClassType::Method) :
nullptr;
3262 bool bVolatileMacro =
false;
3267 OSL_ENSURE(
dynamic_cast<const StarBASIC *
>(
pObject) !=
nullptr,
"No Basic found!");
3270 if (pRoot && bUseVBAObjects)
3277 aBasicStr =
pObject->GetParent()->GetName();
3287 for( sal_uInt32
i = nParamCount;
i && bOk ;
i-- )
3306 if ( pToken->GetType() ==
svString )
3307 pPar->
PutString( pToken->GetString().getString() );
3308 else if ( pToken->GetType() ==
svDouble )
3312 SetError( FormulaError::IllegalArgument );
3322 if ( bUseVBAObjects )
3325 bOk = lcl_setVBARange( aRange,
mrDoc, pPar );
3341 PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
3342 if( nTab1 != nTab2 )
3344 SetError( FormulaError::IllegalParameter );
3349 if ( bUseVBAObjects )
3351 ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
3352 bOk = lcl_setVBARange( aRange,
mrDoc, pPar );
3357 refArray->AddDim(1, nRow2 - nRow1 + 1);
3358 refArray->AddDim(1, nCol2 - nCol1 + 1);
3360 for(
SCROW nRow = nRow1; bOk && nRow <= nRow2; nRow++ )
3363 sal_Int32 nIdx[ 2 ];
3364 nIdx[ 0 ] = nRow-nRow1+1;
3365 for(
SCCOL nCol = nCol1; bOk && nCol <= nCol2; nCol++ )
3368 nIdx[ 1 ] = nCol-nCol1+1;
3385 pMat->GetDimensions(nC, nR);
3387 refArray->AddDim(1,
static_cast<sal_Int32
>(nR));
3388 refArray->AddDim(1,
static_cast<sal_Int32
>(nC));
3389 for(
SCSIZE nMatRow = 0; nMatRow < nR; nMatRow++ )
3391 sal_Int32 nIdx[ 2 ];
3392 nIdx[ 0 ] =
static_cast<sal_Int32
>(nMatRow+1);
3393 for(
SCSIZE nMatCol = 0; nMatCol < nC; nMatCol++ )
3395 nIdx[ 1 ] =
static_cast<sal_Int32
>(nMatCol+1);
3397 if (pMat->IsStringOrEmpty(nMatCol, nMatRow))
3399 p->PutString( pMat->GetString(nMatCol, nMatRow).getString() );
3403 p->PutDouble( pMat->GetDouble(nMatCol, nMatRow));
3411 SetError( FormulaError::IllegalParameter );
3416 SetError( FormulaError::IllegalParameter );
3446 else if (lcl_isNumericResult( fVal, refRes.
get()))
3464 SbxBase* pElemObj = refRes->GetObject();
3466 sal_Int32 nDim = pDimArray ? pDimArray->
GetDims() : 0;
3467 if ( 1 <= nDim && nDim <= 2 )
3469 sal_Int32 nCs, nCe, nRs;
3475 pDimArray->
GetDim(1, nCs, nCe);
3476 nC =
static_cast<SCSIZE>(nCe - nCs + 1);
3485 pDimArray->
GetDim(1, nRs, nRe);
3486 nR =
static_cast<SCSIZE>(nRe - nRs + 1);
3487 pDimArray->
GetDim(2, nCs, nCe);
3488 nC =
static_cast<SCSIZE>(nCe - nCs + 1);
3496 for (
SCSIZE j=0; j < nR; j++ )
3498 sal_Int32 nIdx[ 2 ];
3501 nIdx[ nRowIdx ] = nRs +
static_cast<sal_Int32
>(j);
3504 nIdx[ nColIdx ] = nCs +
static_cast<sal_Int32
>(
i);
3505 pV = pDimArray->
Get(nIdx);
3506 if ( lcl_isNumericResult( fVal, pV) )
3539#if HAVE_FEATURE_SCRIPTING
3545 if (!aCell.isEmpty())
3549 switch (aCell.getType())
3560 nErr = aCell.getFormula()->GetErrCode();
3561 if( nErr == FormulaError::NONE )
3563 if (aCell.getFormula()->IsValue())
3565 nVal = aCell.getFormula()->GetValue();
3569 pVar->
PutString(aCell.getFormula()->GetString().getString());
3592 if (nParamCount != 3 && nParamCount != 5)
3598 if (nParamCount == 5)
3612 if ( bReuseLastParams )
3626 if ( nParamCount == 5 )
3655 pCell->SetTableOpDirty();
3659 if ( !bReuseLastParams )
3673 pCell->ResetTableOpDirtyVar();
3733 if (
aPos.
Col() == nStartCol )
3736 if ( nStartRow <= nMyRow && nMyRow <= aAbs.
aEnd.
Row())
3738 if ( nMyRow == nStartRow )
3758 if (
aPos.
Row() == nStartRow )
3761 if (nStartCol <= nMyCol && nMyCol <= aAbs.
aEnd.
Col())
3763 if ( nMyCol == nStartCol )
3789 while ( nParamCount-- > 0)
3801 , mpLinkManager(rDoc.GetLinkManager())
3802 , mrStrPool(rDoc.GetSharedStringPool())
3803 , pJumpMatrix(nullptr)
3804 , pMyFormulaCell(pCell)
3805 , pFormatter(rContext.GetFormatTable())
3819 , bCalcAsShown(rDoc.GetDocOptions().IsCalcAsShown())
3820 , meVolatileType(r.IsRecalcModeAlways() ? VOLATILE : NOT_VOLATILE)
3917 return rMat.
mpMat->GetDouble(0, nOffset);
3923 return rMat.
mpMat->GetDouble(nOffset, 0);
3926 return std::numeric_limits<double>::quiet_NaN();
3966 sal_uInt32 nRetIndexExpr = 0;
3967 sal_uInt16 nErrorFunction = 0;
3968 sal_uInt16 nErrorFunctionCount = 0;
3969 std::vector<sal_uInt16> aErrorFunctionStack;
3970 sal_uInt16 nStackBase;
3980 ScTokenMatrixMap::const_iterator aTokenMatrixMapIter;
3994 if (!
pCur || (
nGlobalError != FormulaError::NONE && nErrorFunction > nErrorFunctionCount) )
4004 else if (!FormulaCompiler::IsOpCodeJumpCommand( eOp ) &&
4007 (*aTokenMatrixMapIter).second->GetType() !=
svJumpMatrix)
4014 SAL_WARN(
"sc.core",
"Stack anomaly with calculated path at "
4018 <<
" eOp: " <<
static_cast<int>(eOp)
4020 <<
" nStackBase: " << nStackBase <<
" sp: " <<
sp);
4022 assert(!
"underflow");
4036 if (FormulaCompiler::IsOpCodeJumpCommand( eOp ))
4055 <<
" eOp: " <<
static_cast<int>(eOp)
4057 <<
" nStackBase: " << nStackBase <<
" sp: " <<
sp);
4059 assert(!
"underflow");