24#include <unordered_map>
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/container/XEnumerationAccess.hpp>
28#include <com/sun/star/container/XIndexAccess.hpp>
29#include <com/sun/star/script/XDefaultMethod.hpp>
30#include <com/sun/star/uno/Any.hxx>
31#include <com/sun/star/util/SearchAlgorithms2.hpp>
45#include <rtl/math.hxx>
46#include <rtl/ustrbuf.hxx>
47#include <rtl/character.hxx>
89class ScopedWritableGuard
92 ScopedWritableGuard(
const SbxVariableRef& rVar,
bool bMakeWritable)
94 , m_bReset(bMakeWritable && !rVar->CanWrite())
101 ~ScopedWritableGuard()
335 , bCompatibility(false)
356 for(
int i = nSize - 1 ;
i >= 0 ; --
i )
359 if( xDlgComponent.is() )
360 xDlgComponent->dispose();
366 TOOLS_WARN_EXCEPTION(
"basic",
"SbiInstance::~SbiInstance: caught an exception while disposing the components" );
405 sal_uInt32 &rnStdTimeIdx, sal_uInt32 &rnStdDateTimeIdx,
409 if( peFormatterLangType )
411 eLangType = *peFormatterLangType;
418 if( peFormatterDateOrder )
420 eDate = *peFormatterDateOrder;
440 sal_Int32 nCheckPos = 0;
442 rnStdTimeIdx =
pNumberFormatter->GetStandardFormat( SvNumFormatType::TIME, eLangType );
456 case DateOrder::MDY: aDateStr =
"MM/DD/YYYY";
break;
457 case DateOrder::DMY: aDateStr =
"DD/MM/YYYY";
break;
458 case DateOrder::YMD: aDateStr =
"YYYY/MM/DD";
break;
460 OUString
aStr( aDateStr );
464 aDateStr +=
" HH:MM:SS";
580 while( nLevel-- &&
p )
584 return p ?
p->GetCaller() :
nullptr;
593 pMod( pm ), pMeth( pe ), pImg( pMod->pImage.
get() )
629 SbxInfo* pInfo = pVar->
GetInfo() ? pVar->
GetInfo() :
new SbxInfo();
651 sal_uInt32 nParamCount = pParams ? pParams->
Count() : 1;
652 assert(nParamCount <= std::numeric_limits<sal_uInt16>::max());
653 if( nParamCount > 1 )
655 for( sal_uInt32
i = 1 ;
i < nParamCount ;
i++ )
657 const SbxParamInfo*
p = pInfo ? pInfo->GetParam( sal::static_int_cast<sal_uInt16>(
i) ) :
nullptr;
663 sal_uInt32 nParamArrayParamCount = nParamCount -
i;
664 pArray->
unoAddDim(0, nParamArrayParamCount - 1);
665 for (sal_uInt32 j =
i; j < nParamCount ; ++j)
668 sal_Int32 aDimIndex[1];
669 aDimIndex[0] = j -
i;
670 pArray->
Put(
v, aDimIndex);
684 bool bByVal =
dynamic_cast<const SbxMethod *
>(
v) !=
nullptr;
686 bool bTargetTypeIsArray =
false;
697 (!
v->IsFixed() ||
static_cast<SbxDataType>(
v->GetType() & 0x0FFF ) !=
t) )
707 if( bTargetTypeIsArray && !
IsMissing(
v, 1 ) )
749 const SbxParamInfo*
p = pInfo->GetParam(sal::static_int_cast<sal_uInt16>(nParamCount));
768 static sal_uInt32 nLastTime = osl_getGlobalTimer();
773 sal_uInt32 nTime = osl_getGlobalTimer();
774 if (nTime - nLastTime > 5)
787 nLastTime = osl_getGlobalTimer();
806 sal_uInt32 nOp2 = *
pCode++; nOp2 |= *
pCode++ << 8; nOp2 |= *
pCode++ << 16; nOp2 |= *
pCode++ << 24;
840 bool bLetParentHandleThis =
false;
857 bLetParentHandleThis =
true;
862 bLetParentHandleThis =
true;
865 if ( bLetParentHandleThis )
873 while( (pRt = pRt->
pNext) !=
nullptr )
890 if( pRt != pRtErrHdl )
926 if( pGlobErr !=
nullptr )
961 Error( _errCode, _details );
976 sal_Int32 nVBAErrorNumber = ( nVBErrorCode == 0 ) ? sal_uInt32(
nError) : nVBErrorCode;
977 return nVBAErrorNumber;
1003 SAL_INFO_IF( xVar->GetName() ==
"Cells",
"basic",
"PopVar: Name equals 'Cells'" );
1005 if(
dynamic_cast<const SbxMethod *
>(xVar.
get()) !=
nullptr )
1007 xVar->SetParameters(
nullptr);
1035 return refExprStk->Get(
static_cast<sal_uInt32
>(
n));
1044 p->Broadcast( SfxHintId::BasicDataWanted );
1050 pDflt->
Broadcast( SfxHintId::BasicDataWanted );
1060 else if(
p->GetRefCount() != 1 )
1135 ScopedWritableGuard aGuard(
p->refVar,
p->refVar.get() ==
pMeth);
1136 *(
p->refVar) = *xBgn;
1163 sal_Int32 nDims = pArray->GetDims();
1164 p->pArrayLowerBounds.reset(
new sal_Int32[nDims] );
1165 p->pArrayUpperBounds.reset(
new sal_Int32[nDims] );
1166 p->pArrayCurIndices.reset(
new sal_Int32[nDims] );
1167 sal_Int32 lBound, uBound;
1168 for( sal_Int32
i = 0 ;
i < nDims ;
i++ )
1170 pArray->GetDim(
i + 1, lBound, uBound);
1171 p->pArrayCurIndices[
i] =
p->pArrayLowerBounds[
i] = lBound;
1172 p->pArrayUpperBounds[
i] = uBound;
1178 p->refEnd = pCollection;
1179 p->nCurCollectionIndex = 0;
1184 Any aAny = pUnoObj->getUnoAny();
1187 if( aAny >>= xEnumerationAccess )
1189 p->xEnumeration = xEnumerationAccess->createEnumeration();
1193 else if (aAny >>= xIndexAccess)
1196 p->xIndexAccess = xIndexAccess;
1197 p->nCurCollectionIndex = 0;
1199 else if (
isVBAEnabled() && pUnoObj->isNativeCOMObject() )
1201 uno::Reference< script::XInvocation >
xInvocation;
1209 catch(
const uno::Exception& )
1245 SbxVariable* pVar =
p->refEnd.is() ?
p->refEnd.get() :
nullptr;
1261 ( std::u16string_view aFuncName,
1262 std::u16string_view aDLLName,
1269 ErrCode nErr = pDllMgr->
Call( aFuncName, aDLLName, pArgs, *pRes, bCDecl );
1320 p->Compute( eOp, *
p );
1342 p1->Broadcast( SfxHintId::BasicDataWanted );
1343 p1Type = p1->GetType();
1347 p2->Broadcast( SfxHintId::BasicDataWanted );
1348 p2Type = p2->GetType();
1350 if ( p1Type == p2Type )
1363 p1->Broadcast( SfxHintId::BasicDataWanted );
1369 p2->Broadcast( SfxHintId::BasicDataWanted );
1379 if (
bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) )
1389 else if( p2->Compare( eOp, *p1 ) )
1439 if(!rtl::isAscii(cCode))
1461 OUString VBALikeToRegexp(
const OUString &rIn)
1463 OUStringBuffer sResult;
1469 sResult.append(
'^');
1476 sResult.append(
'.');
1480 sResult.append(
".*");
1484 sResult.append(
"[0-9]");
1488 sResult.append(
'\\');
1489 sResult.append(*start++);
1492 sResult.append(*start++);
1494 if (start < end && *start ==
'!')
1496 sResult.append(
'^');
1499 while (start < end && !seenright)
1506 sResult.append(
'\\');
1507 sResult.append(*start);
1510 sResult.append(*start);
1514 if (NeedEsc(*start))
1516 sResult.append(
'\\');
1518 sResult.append(*start);
1525 if (NeedEsc(*start))
1527 sResult.append(
'\\');
1529 sResult.append(*start++);
1533 sResult.append(
'$');
1535 return sResult.makeStringAndClear();
1544 OUString pattern = VBALikeToRegexp(refVar1->GetOUString());
1545 OUString
value = refVar2->GetOUString();
1549 aSearchOpt.
AlgorithmType2 = css::util::SearchAlgorithms2::REGEXP;
1554 bool bTextMode(
true);
1556 if( bCompatibility )
1566 sal_Int32 nStart=0, nEnd=
value.getLength();
1584 refVar1->Broadcast( SfxHintId::BasicDataWanted );
1585 eType1 = refVar1->GetType();
1589 refVar2->Broadcast( SfxHintId::BasicDataWanted );
1590 eType2 = refVar2->GetType();
1598 bRes = ( bRes && refVar1->GetObject() == refVar2->GetObject() );
1609 p->Broadcast( SfxHintId::BasicDataWanted );
1625 if ( ( bVBA && ( eVarType ==
SbxEMPTY ) ) || !refVar->CanWrite() )
1634 if ( refVar->IsFixed() )
1650 if ( pUnoVal || pUnoStructVal )
1654 if ( aAny.getValueType().getTypeClass() != TypeClass_STRUCT )
1674 if ( pUnoStructObj )
1684 refVar->PutObject( pNewUnoObj );
1697 bool bFlagsChanged =
false;
1701 bFlagsChanged =
true;
1702 n = refVar->GetFlags();
1717 bool bObjAssign =
false;
1718 if ( refVar->GetType() ==
SbxEMPTY )
1719 refVar->Broadcast( SfxHintId::BasicDataWanted );
1722 if (
dynamic_cast<const SbxMethod *
>(refVar.
get()) !=
nullptr || ! refVar->GetParent() )
1732 if ( refVal->GetType() ==
SbxOBJECT && !bObjAssign && (
dynamic_cast<const SbxMethod *
>(refVal.
get()) !=
nullptr || ! refVal->GetParent() ) )
1744 refVar->SetFlags(
n );
1750struct DimAsNewRecoverItem
1752 OUString m_aObjClass;
1753 OUString m_aObjName;
1757 DimAsNewRecoverItem()
1758 : m_pObjParent( nullptr )
1759 , m_pClassModule( nullptr )
1762 DimAsNewRecoverItem( OUString aObjClass, OUString aObjName,
1764 : m_aObjClass(
std::move( aObjClass ))
1765 , m_aObjName(
std::move( aObjName ))
1766 , m_pObjParent( pObjParent )
1767 , m_pClassModule( pClassModule )
1773struct SbxVariablePtrHash
1776 {
return reinterpret_cast<size_t>(pVar); }
1781typedef std::unordered_map<
SbxVariable*, DimAsNewRecoverItem,
1792 DimAsNewRecoverHash::iterator it = gaDimAsNewRecoverHash.find( pVar );
1793 if( it != gaDimAsNewRecoverHash.end() )
1795 gaDimAsNewRecoverHash.erase( it );
1811 if( !bHandleDefaultProp && eVarType !=
SbxOBJECT && !(eVarType &
SbxARRAY) && refVar->IsFixed() )
1819 if( !bHandleDefaultProp && eValType !=
SbxOBJECT && !(eValType &
SbxARRAY) && refVal->IsFixed() )
1827 if ( !bHandleDefaultProp || eValType ==
SbxOBJECT )
1830 SbxBase* pObjVarObj = refVal->GetObject();
1835 if( refObjVal.
is() )
1855 bool bFlagsChanged =
false;
1859 bFlagsChanged =
true;
1860 n = refVar->GetFlags();
1866 pProcProperty->
setSet(
true );
1868 if ( bHandleDefaultProp )
1877 bool bObjAssign =
false;
1880 if (
dynamic_cast<const SbxMethod *
>(refVar.
get()) !=
nullptr || ! refVar->GetParent() )
1900 if ( !pObj && refVar->GetType() ==
SbxOBJECT )
1902 SbxBase* pObjVarObj = refVar->GetObject();
1903 pObj =
dynamic_cast<SbxObject*
>( pObjVarObj );
1906 if ( pObj && !bObjAssign )
1923 xPrevVarObj = refVar->GetObject();
1931 SbxBase* pObj = refVal->GetObject();
1933 if( pUnoObj !=
nullptr )
1936 OUString aDeclareClassName = refVar->GetDeclareClassName();
1937 OUString aPrefix = refVar->GetName();
1939 xComListener =
createComListener( aControlAny, aDeclareClassName, aPrefix, xScopeObj );
1941 refVal->SetDeclareClassName( aDeclareClassName );
1942 refVal->SetComListener( xComListener, &
rBasic );
1958 if(
dynamic_cast<const SbxObject*
>( refVar.
get() ) ==
nullptr )
1960 SbxBase* pValObjBase = refVal->GetObject();
1961 if( pValObjBase ==
nullptr )
1963 if( xPrevVarObj.
is() )
1966 DimAsNewRecoverHash::iterator it = gaDimAsNewRecoverHash.find( refVar.
get() );
1967 if( it != gaDimAsNewRecoverHash.end() )
1969 const DimAsNewRecoverItem& rItem = it->second;
1970 if( rItem.m_pClassModule !=
nullptr )
1972 SbClassModuleObject* pNewObj =
new SbClassModuleObject( rItem.m_pClassModule );
1973 pNewObj->SetName( rItem.m_aObjName );
1974 pNewObj->SetParent( rItem.m_pObjParent );
1975 refVar->PutObject( pNewObj );
1977 else if( rItem.m_aObjClass.equalsIgnoreAsciiCase(
pCollectionStr ) )
1980 pNewCollection->
SetName( rItem.m_aObjName );
1981 pNewCollection->
SetParent( rItem.m_pObjParent );
1982 refVar->PutObject( pNewCollection );
1990 bool bFirstInit = !xPrevVarObj.
is();
1995 if( pValObj !=
nullptr )
1999 SbClassModuleObject* pClassModuleObj =
dynamic_cast<SbClassModuleObject*
>( pValObjBase );
2000 if( pClassModuleObj !=
nullptr )
2002 SbModule* pClassModule = pClassModuleObj->getClassModule();
2003 gaDimAsNewRecoverHash[refVar.
get()] =
2004 DimAsNewRecoverItem( aObjClass, pValObj->
GetName(), pValObj->
GetParent(), pClassModule );
2006 else if( aObjClass.equalsIgnoreAsciiCase(
"Collection" ) )
2008 gaDimAsNewRecoverHash[refVar.
get()] =
2009 DimAsNewRecoverItem( aObjClass, pValObj->
GetName(), pValObj->
GetParent(),
nullptr );
2019 refVar->SetFlags(
n );
2056 OUString aRefVarString = refVar->GetOUString();
2057 OUString aRefValString = refVal->GetOUString();
2059 sal_Int32 nVarStrLen = aRefVarString.getLength();
2060 sal_Int32 nValStrLen = aRefValString.getLength();
2062 if( nVarStrLen > nValStrLen )
2064 OUStringBuffer buf(aRefValString);
2066 aNewStr = buf.makeStringAndClear();
2070 aNewStr = aRefValString.copy( 0, nVarStrLen );
2073 refVar->PutString(aNewStr);
2074 refVar->SetFlags(
n );
2093 OUString aRefVarString = refVar->GetOUString();
2094 OUString aRefValString = refVal->GetOUString();
2095 sal_Int32 nVarStrLen = aRefVarString.getLength();
2096 sal_Int32 nValStrLen = aRefValString.getLength();
2098 OUStringBuffer aNewStr(nVarStrLen);
2099 if (nVarStrLen > nValStrLen)
2102 aNewStr.append(aRefValString);
2106 aNewStr.append(aRefValString.subView(0, nVarStrLen));
2108 refVar->PutString(aNewStr.makeStringAndClear());
2110 refVar->SetFlags(
n );
2151 SbxArray* pDims = refVar->GetParameters();
2154 if (pDims && !(pDims->
Count() & 1))
2167 for (sal_uInt32
i = 1;
i < pDims->
Count();)
2191 refVar->PutObject( pArray );
2192 refVar->SetFlags( nSavFlags );
2193 refVar->SetParameters(
nullptr );
2211 sal_Int32 nActualDim, sal_Int32* pActualIndices, sal_Int32* pLowerBounds, sal_Int32* pUpperBounds )
2213 sal_Int32& ri = pActualIndices[nActualDim];
2214 for( ri = pLowerBounds[nActualDim] ; ri <= pUpperBounds[nActualDim] ; ri++ )
2216 if( nActualDim < nMaxDimIndex )
2219 pActualIndices, pLowerBounds, pUpperBounds );
2227 pNewArray->
Put(pSource, pActualIndices);
2236 bool bResult =
false;
2238 *pbWasError =
false;
2239 if (rrefRedimpArray)
2242 const sal_Int32 nDimsNew = pNewArray->
GetDims();
2243 const sal_Int32 nDimsOld = pOldArray->
GetDims();
2245 if (nDimsOld != nDimsNew)
2251 else if (nDimsNew > 0)
2254 std::unique_ptr<sal_Int32[]> pLowerBounds(
new sal_Int32[nDimsNew]);
2255 std::unique_ptr<sal_Int32[]> pUpperBounds(
new sal_Int32[nDimsNew]);
2256 std::unique_ptr<sal_Int32[]> pActualIndices(
new sal_Int32[nDimsNew]);
2257 bool bNeedsPreallocation =
true;
2260 for (sal_Int32
i = 1;
i <= nDimsNew;
i++)
2262 sal_Int32 lBoundNew, uBoundNew;
2263 sal_Int32 lBoundOld, uBoundOld;
2264 pNewArray->
GetDim(
i, lBoundNew, uBoundNew);
2265 pOldArray->
GetDim(
i, lBoundOld, uBoundOld);
2266 lBoundNew = std::max(lBoundNew, lBoundOld);
2267 uBoundNew = std::min(uBoundNew, uBoundOld);
2268 sal_Int32 j =
i - 1;
2269 pActualIndices[j] = pLowerBounds[j] = lBoundNew;
2270 pUpperBounds[j] = uBoundNew;
2271 if (lBoundNew > uBoundNew)
2272 bNeedsPreallocation =
false;
2276 if (bNeedsPreallocation)
2277 pNewArray->
Put(
nullptr, pUpperBounds.get());
2282 implCopyDimArray(pNewArray, pOldArray, nDimsNew - 1, 0, pActualIndices.get(),
2283 pLowerBounds.get(), pUpperBounds.get());
2287 rrefRedimpArray.
clear();
2320 SbxBase* pElemObj = refVar->GetObject();
2328 else if( refVar->IsFixed() )
2343 refVar->SetFlags( nSavFlags );
2354 SbxBase* pElemObj = refVar->GetObject();
2361 pDimArray->SbxArray::Clear();
2387 else if( refVar->IsFixed() )
2459 if(
dynamic_cast<const SbxMethod*
>( pVal.
get() ) !=
nullptr
2482 if(
ch !=
' ' &&
ch !=
'\t' &&
ch !=
'\n' )
2490 char sep = (
ch ==
'"' ) ?
ch : 0;
2505 else if( !sep && (
ch ==
',' ||
ch ==
'\n') )
2513 if(
ch ==
' ' ||
ch ==
'\t' )
2517 if(
ch !=
' ' &&
ch !=
'\t' &&
ch !=
'\n' )
2527 OUString s = sin.makeStringAndClear();
2531 if( !pVar->IsFixed() || pVar->IsNumeric() )
2533 sal_uInt16 nLen = 0;
2534 if( !pVar->Scan( s, &nLen ) )
2540 else if( nLen != s.getLength() && !pVar->PutString( s ) )
2545 else if( nLen != s.getLength() && pVar->IsNumeric() )
2557 pVar->PutString( s );
2592 p->PutString(OStringToOUString(aInput, osl_getThreadTextEncoding()));
2697 short nChan = pChan->GetInteger();
2710 OUString s1 =
p->GetOUString();
2724 OUString s1 =
p->GetOUString();
2741 switch (
p->GetType() )
2752 s += OUStringChar(
ch);
2754 s +=
p->GetOUString();
2757 s += OUStringChar(
ch);
2767 OUString aDest = pTos1->GetOUString();
2768 OUString aSource = pTos->GetOUString();
2805 xVar->PutErr( 448 );
2816 sal_uInt16
n = refCode->GetUShort();
2837 sal_Int32 iComma =
aStr.indexOf(
',');
2842 sal_Int32 nParseEnd = 0;
2843 rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
2844 double n = ::rtl::math::stringToDouble(
aStr,
'.',
',', &eStatus, &nParseEnd );
2848 if ( nParseEnd <
aStr.getLength() )
2852 switch (
aStr[nParseEnd] )
2891 p->PutInteger(
static_cast<sal_Int16
>( nOp1 ) );
2906 (
dynamic_cast<const SbxMethod*
>( pVal.
get()) !=
nullptr
2912 pVal->Broadcast( SfxHintId::BasicDataWanted );
2930 bool bByVal = (nOp1 & 0x8000) != 0;
2972 OUString s =
p->GetOUString();
2973 sal_Int32 nLen(nOp1);
2974 if( s.getLength() == nLen )
2977 OUStringBuffer
aBuf(s);
2978 if (
aBuf.getLength() > nLen)
2986 s =
aBuf.makeStringAndClear();
3019 if ( tos->IsObject() )
3024 return tos->GetObject();
3028 return tos->GetBool();
3063 sal_Int16
n =
p->GetInteger();
3070 n =
static_cast<sal_Int16
>( nOp1 + 1 );
3104 bool bEndLoop =
false;
3124 else if (
p->pArrayCurIndices ==
nullptr)
3131 sal_Int32 nDims = pArray->
GetDims();
3134 if( nDims == 1 &&
p->pArrayLowerBounds[0] >
p->pArrayUpperBounds[0] )
3140 *(
p->refVar) = *pVal;
3142 bool bFoundNext =
false;
3143 for(sal_Int32
i = 0 ;
i < nDims ;
i++ )
3145 if(
p->pArrayCurIndices[
i] <
p->pArrayUpperBounds[
i] )
3148 p->pArrayCurIndices[
i]++;
3149 for( sal_Int32 j =
i - 1 ; j >= 0 ; j-- )
3150 p->pArrayCurIndices[j] =
p->pArrayLowerBounds[j];
3156 p->pArrayCurIndices.reset();
3172 sal_Int32
nCount = xItemArray->Count();
3188 if (!
p->xEnumeration)
3193 else if (
p->xEnumeration->hasMoreElements())
3195 Any aElem =
p->xEnumeration->nextElement();
3210 if (!
p->xIndexAccess)
3255 if( *xCase >= *xFrom && *xCase <= *xTo )
3337 if( !aClass.isEmpty() )
3339 bRet = pObj->
IsClass( aClass );
3341 bRet = aClass.equalsIgnoreAsciiCase(
"object" );
3349 if (pClassData !=
nullptr )
3352 bRet = (pClassVar !=
nullptr);
3361 const OUString& aClass,
bool bRaiseErrors,
bool bDefault )
3363 bool bOk = bDefault;
3372 t = pProp->getRealType();
3380 pObj =
dynamic_cast<SbxObject*
>(refVal->GetObject());
3396 if ( !bOk && bRaiseErrors )
3403 SbClassModuleObject* pClassModuleObject =
dynamic_cast<SbClassModuleObject*
>( pObj );
3404 if( pClassModuleObject !=
nullptr )
3405 pClassModuleObject->triggerInitializeEvent();
3470 bool bCompatible = ((nOp1 & 0x8000) != 0);
3471 sal_uInt16 uBase =
static_cast<sal_uInt16
>(nOp1 & 1);
3478 ScopedWritableGuard aGuard(x2, x2.
get() ==
pMeth);
3489 ErrCode nNotFound,
bool bLocal,
bool bStatic )
3495 if( pMSOMacroRuntimeLib !=
nullptr )
3509 bool bFatalError =
false;
3514 if ( bIsVBAInterOp &&
aName.startsWith(
"[") )
3519 OUString sArg =
aName.copy( 1,
aName.getLength() - 2 );
3521 p->PutString( sArg );
3524 nOp1 = nOp1 | 0x8000;
3529 if ( bStatic &&
pMeth )
3546 if( bLocal && pElem )
3561 if( bLocal && !pElem )
3563 bool bSetName =
true;
3590 aRes.
pObj = pUnoClass;
3591 pElem->SbxVariable::Put( aRes );
3695 pElem->SbxValue::Clear();
3738 if( !
pMod || rName.isEmpty() )
3746 if ( !pElem &&
pMeth )
3763 if( !pElem &&
pMeth )
3768 sal_uInt32 nParamCount =
refParams->Count();
3769 assert(nParamCount <= std::numeric_limits<sal_uInt16>::max());
3774 if( pParam->
aName.equalsIgnoreAsciiCase( rName ) )
3776 if( j >= nParamCount )
3780 pElem->
PutString(
"<missing parameter>");
3788 pParam = pInfo->GetParam( ++j );
3813 bool bHasNamed =
false;
3815 sal_uInt32 nArgCount =
refArgv->Count();
3816 for(
i = 1 ;
i < nArgCount ;
i++ )
3818 if (!
refArgv->GetAlias(
i).isEmpty())
3820 bHasNamed =
true;
break;
3825 SbxInfo* pInfo =
p->GetInfo();
3828 bool bError_ =
true;
3832 if( pUnoMethod || pUnoProperty )
3844 sal_uInt32 nCurPar = 1;
3847 OUString* pNames = pArg->
getNames().getArray();
3848 for(
i = 1 ;
i < nArgCount ;
i++ )
3852 if (!
aName.isEmpty())
3856 pArg->
Put(pVar, nCurPar++);
3868 Any aAny = pUnoObj->getUnoAny();
3870 if( aAny.getValueType().getTypeClass() == TypeClass_INTERFACE )
3874 OUString sDefaultMethod;
3875 if ( xDfltMethod.is() )
3877 sDefaultMethod = xDfltMethod->getDefaultMethodName();
3879 if ( !sDefaultMethod.isEmpty() )
3882 if( meth !=
nullptr )
3901 sal_uInt32 nCurPar = 1;
3903 for(
i = 1 ;
i < nArgCount ;
i++ )
3907 if (!
aName.isEmpty())
3914 if( pParam->
aName.equalsIgnoreAsciiCase(
aName ) )
3919 pParam = pInfo->GetParam( ++j );
3926 pArg->
Put(pVar, nCurPar++);
3938 p->SetParameters(
nullptr );
3957 pElem = pDimArray->
Get( pPar );
3979 pPar->
Put(
nullptr, 0);
3984 dynamic_cast<const SbxMethod*
>( pElem) ==
nullptr &&
3996 Any aAny = pUnoObj->getUnoAny();
3998 if( aAny.getValueType().getTypeClass() == TypeClass_INTERFACE )
4003 if( xIndexAccess.is() )
4005 sal_uInt32 nParamCount = pPar->
Count() - 1;
4006 if( nParamCount != 1 )
4017 Any aAny2 = xIndexAccess->getByIndex(
nIndex );
4020 catch (
const IndexOutOfBoundsException&)
4055 pDflt->
Broadcast( SfxHintId::BasicDataWanted );
4062 Any aUnoAny = pUnoObj->getUnoAny();
4064 if( aUnoAny.getValueType().getTypeClass() == TypeClass_INTERFACE )
4070 OUString sDefaultMethod;
4074 if ( xDfltMethod.is() )
4076 sDefaultMethod = xDfltMethod->getDefaultMethodName();
4078 else if( xIndexAccess.is() )
4080 sDefaultMethod =
"getByIndex";
4082 if ( !sDefaultMethod.isEmpty() )
4097 pPar->
Put(
nullptr, 0);
4102 pPar->
Put(pElem, 0);
4103 pCol->CollItem( pPar );
4128 ErrCode nNotFound,
bool bStatic )
4147 SbClassModuleObject* pClassModuleObject =
dynamic_cast<SbClassModuleObject*
>(
pMod );
4148 if( pClassModuleObject )
4154 if( pClassModuleObject )
4175 SbxBase* pObjVarObj = pObjVar->GetObject();
4176 pObj =
dynamic_cast<SbxObject*
>( pObjVarObj );
4204 sal_uInt16 nIdx =
static_cast<sal_uInt16
>( nOp1 & 0x7FFF );
4209 sal_uInt32 nParamCount =
refParams->Count();
4210 if( nIdx >= nParamCount )
4212 sal_uInt16 iLoop = nIdx;
4213 while( iLoop >= nParamCount )
4241 sal_uInt16 nDefaultId =
static_cast<sal_uInt16
>(pParam->
nUserData & 0x0ffff);
4242 if( nDefaultId > 0 )
4248 OUString aDefaultStr =
pImg->
GetString( nDefaultId, &eTypeStr );
4291 if( xCase->Compare(
static_cast<SbxOperator>(nOp2), *xComp ) )
4342 bool bFatalExpr =
false;
4343 OUString sUnknownMethodName;
4351 if(
p->GetRefCount() > 1 &&
4354 sUnknownMethodName =
p->GetName();
4371 sal_uInt16 nOld =
nLine;
4372 nLine =
static_cast<short>( nOp1 );
4375 nCol1 =
static_cast<short>( nOp2 & 0xFF );
4396 sal_uInt16 nExpectedForLevel =
static_cast<sal_uInt16
>( nOp2 / 0x100 );
4399 nExpectedForLevel = nExpectedForLevel +
pGosubStk.back().nStartForLvl;
4404 while(
nForLvl > nExpectedForLevel )
4421 else if( ( nOp1 != nOld )
4423 &&
pMod->
IsBP(
static_cast<sal_uInt16
>( nOp1 ) ) )
4442 short nBlkLen = pLen->GetInteger();
4443 short nChan = pChan->GetInteger();
4463 pObj->SetName(
aName );
4465 pObj->SetParent( &
rBasic );
4467 pNew->PutObject( pObj.
get() );
4490 SbxBase* pObj = refVar->GetObject();
4501 const sal_Int32 nDims = pArray->
GetDims();
4502 sal_Int32 nTotalSize = nDims > 0 ? 1 : 0;
4505 sal_Int32 nLower, nUpper;
4506 for( sal_Int32
i = 0 ;
i < nDims ; ++
i )
4508 pArray->
GetDim(
i + 1, nLower, nUpper);
4509 const sal_Int32 nSize = nUpper - nLower + 1;
4510 nTotalSize *= nSize;
4515 pArray->SbxArray::GetRef(nTotalSize - 1);
4518 bool bWasError =
false;
4526 for( sal_Int32
i = 0 ;
i < nTotalSize ; ++
i )
4528 if (!bRestored || !pArray->SbxArray::GetRef(
i))
4538 if (
aName.isEmpty())
4540 pClassObj->SetName(
aName);
4542 pClassObj->SetParent(&
rBasic);
4543 pArray->SbxArray::Put(pClassObj.
get(),
i);
4557 pCopyObj->SetName(
aName );
4560 pNew->PutObject( pCopyObj.
get() );
4561 pNew->SetDeclareClassName( aClass );
4580 sal_uInt16
nCount =
static_cast<sal_uInt16
>( nOp2 >> 17 );
4626 if( !bUsedForClassModule )
4738 OUString
const & aName,
SbxDataType t, sal_uInt32 nOp2 )
const LanguageTag & GetLanguageTag() const
static const AllSettings & GetSettings()
static bool Reschedule(bool bHandleAllCurrentEvents=false)
css::uno::Sequence< OUString > & getNames()
static bool IsExtendedTypeDeclaration()
ErrCode IgnoreWarning() const
LanguageType getLanguageType(bool bResolveSystem=true) const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
DateOrder getDateOrder() const
virtual SbxInfo * GetInfo() override
BasicDebugFlags GetDebugFlags() const
SAL_DLLPRIVATE const sal_uInt8 * FindNextStmnt(const sal_uInt8 *, sal_uInt16 &, sal_uInt16 &) const
SAL_DLLPRIVATE bool IsBP(sal_uInt16 nLine) const
virtual SAL_DLLPRIVATE SbxVariable * Find(const OUString &, SbxClassType) override
SAL_DLLPRIVATE SbProperty * GetProperty(const OUString &, SbxDataType)
std::unique_ptr< SbiImage > pImage
SAL_DLLPRIVATE void AddVarName(const OUString &aName)
std::unique_ptr< SbClassData > pClassData
bool IsVBASupport() const
css::uno::Any getUnoAny()
const StructRefInfo & getStructInfo() const
css::uno::Any getUnoAny()
ErrCode Call(std::u16string_view function, std::u16string_view library, SbxArray *arguments, SbxVariable &result, bool cdeclConvention)
OUString GetString(sal_uInt32 nId, SbxDataType *eType=nullptr) const
const sal_uInt8 * GetCode() const
sal_uInt16 GetBase() const
sal_uInt32 GetCodeSize() const
bool IsFlag(SbiImageFlags n) const
std::shared_ptr< SvNumberFormatter > pNumberFormatter
const OUString & GetErrorMsg() const
void CalcBreakCallLevel(BasicDebugFlags nFlags)
SbiIoSystem * GetIoSystem()
bool IsReschedule() const
SbModule * GetActiveModule()
bool IsCompatibility() const
void ErrorVB(sal_Int32 nVBNumber, const OUString &rMsg)
sal_uInt32 nStdDateTimeIdx
static std::shared_ptr< SvNumberFormatter > PrepareNumberFormatter(sal_uInt32 &rnStdDateIdx, sal_uInt32 &rnStdTimeIdx, sal_uInt32 &rnStdDateTimeIdx, LanguageType const *peFormatterLangType=nullptr, DateOrder const *peFormatterDateOrder=nullptr)
std::unique_ptr< SbiDllMgr > pDllMgr
std::shared_ptr< SvNumberFormatter > const & GetNumberFormatter()
LanguageType meFormatterLangType
ComponentVector_t ComponentVector
DateOrder meFormatterDateOrder
void setErrorVB(sal_Int32 nVBNumber)
SbMethod * GetCaller(sal_uInt16)
void Write(std::u16string_view)
void SetPrompt(const OString &r)
void Open(short, std::string_view, StreamMode, SbiStreamFlags, short)
void StepPRCHAR(sal_uInt32)
void(SbiRuntime::* pStep0)()
void StepGLOBAL_P(sal_uInt32, sal_uInt32)
void SetupArgs(SbxVariable *, sal_uInt32)
SbxVariable * CheckArray(SbxVariable *)
std::vector< SbiArgv > pArgvStk
void DllCall(std::u16string_view, std::u16string_view, SbxArray *, SbxDataType, bool)
void StepGLOBAL(sal_uInt32, sal_uInt32)
void StepJUMP(sal_uInt32)
static bool isVBAEnabled()
static sal_Int32 translateErrorToVba(ErrCode nError, OUString &rMsg)
void StepVBASETCLASS(sal_uInt32)
SbiForStack * FindForStackItemForCollection(class BasicCollection const *pCollection)
SbxBase * FindElementExtern(const OUString &rName)
bool EvaluateTopOfStackAsBool()
SbxVariable * StepSTATIC_Impl(OUString const &aName, SbxDataType t, sal_uInt32 nOp2)
void StepCLOSE(sal_uInt32)
void StepCASETO(sal_uInt32)
static void SetIsMissing(SbxVariable *)
sal_uInt16 GetBase() const
static const pStep2 aStep2[]
void StepSTATIC(sal_uInt32, sal_uInt32)
void StepDCREATE(sal_uInt32, sal_uInt32)
void SetVBAEnabled(bool bEnabled)
void StepFIND_G(sal_uInt32, sal_uInt32)
void StepARGTYP(sal_uInt32)
SbxArrayRef refRedimpArray
void StepCREATE(sal_uInt32, sal_uInt32)
void SetParameters(SbxArray *)
void StepGOSUB(sal_uInt32)
void StepFIND_CM(sal_uInt32, sal_uInt32)
void StepDCREATE_IMPL(sal_uInt32, sal_uInt32)
static void implHandleSbxFlags(SbxVariable *pVar, SbxDataType t, sal_uInt32 nOp2)
void DimImpl(const SbxVariableRef &refVar)
void StepSETCLASS(sal_uInt32)
void StepPUBLIC(sal_uInt32, sal_uInt32)
void PushVar(SbxVariable *)
bool checkClass_Impl(const SbxVariableRef &refVal, const OUString &aClass, bool bRaiseErrors, bool bDefault)
void StepCompare(SbxOperator)
void StepTESTCLASS(sal_uInt32)
void StepPUBLIC_Impl(sal_uInt32, sal_uInt32, bool bUsedForClassModule)
const sal_uInt8 * pErrStmnt
void StepFIND_STATIC(sal_uInt32, sal_uInt32)
void StepCALLC(sal_uInt32, sal_uInt32)
void StepTESTFOR(sal_uInt32)
static bool implIsClass(SbxObject const *pObj, const OUString &aClass)
void Error(ErrCode, bool bVBATranslationAlreadyDone=false)
void StepUnary(SbxOperator)
void StepELEM(sal_uInt32, sal_uInt32)
SbxVariable * mpExtCaller
void StepLOADNC(sal_uInt32)
void StepJUMPF(sal_uInt32)
std::vector< SbxVariableRef > aRefSaved
static const pStep0 aStep0[]
void StepFIND_Impl(SbxObject *pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, ErrCode, bool bStatic=false)
void StepCASEIS(sal_uInt32, sal_uInt32)
void StepPARAM(sal_uInt32, sal_uInt32)
Loading of a parameter (+offset+type) If the data type is wrong, create a copy and search for optiona...
void StepBASED(sal_uInt32)
static const pStep1 aStep1[]
void StepCALL(sal_uInt32, sal_uInt32)
void StepFIND(sal_uInt32, sal_uInt32)
void StepSTMNT(sal_uInt32, sal_uInt32)
void PushGosub(const sal_uInt8 *)
void StepRETURN(sal_uInt32)
void StepSET_Impl(SbxVariableRef &refVal, SbxVariableRef &refVar, bool bDefaultHandling=false)
void StepArith(SbxOperator)
bool IsImageFlag(SbiImageFlags n) const
SbiRuntime(SbModule *, SbMethod *, sal_uInt32)
void StepLOADI(sal_uInt32)
void StepERRHDL(sal_uInt32)
void StepJUMPT(sal_uInt32)
const sal_uInt8 * pRestart
static bool IsMissing(SbxVariable *, sal_uInt16)
void StepONJUMP(sal_uInt32)
void StepRESUME(sal_uInt32)
const sal_uInt8 * pErrCode
void StepSETCLASS_impl(sal_uInt32 nOp1, bool bHandleDflt)
void StepARGN(sal_uInt32)
void(SbiRuntime::* pStep1)(sal_uInt32 nOp1)
void StepRTL(sal_uInt32, sal_uInt32)
void StepLOADSC(sal_uInt32)
void StepLOCAL(sal_uInt32, sal_uInt32)
std::vector< SbiGosub > pGosubStk
void StepPUBLIC_P(sal_uInt32, sal_uInt32)
void StepOPEN(sal_uInt32, sal_uInt32)
void StepTCREATE(sal_uInt32, sal_uInt32)
void StepDCREATE_REDIMP(sal_uInt32, sal_uInt32)
void(SbiRuntime::* pStep2)(sal_uInt32 nOp1, sal_uInt32 nOp2)
SbxVariable * FindElement(SbxObject *pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, ErrCode, bool bLocal, bool bStatic=false)
SbxVariable * Find(const OUString &, SbxClassType)
virtual void Clear() override
SbxVariable * Get(sal_uInt32)
void Put(SbxVariable *, sal_uInt32)
static void SetError(ErrCode)
void SetFlags(SbxFlagBits n)
static ErrCode const & GetError()
bool IsSet(SbxFlagBits n) const
void SetFlag(SbxFlagBits n)
SbxFlagBits GetFlags() const
static SbxObjectRef CreateObject(const OUString &)
void ResetFlag(SbxFlagBits n)
virtual void Clear() override
bool GetDim(sal_Int32, sal_Int32 &, sal_Int32 &) const
SbxVariable * Get(SbxArray *)
void AddDim(sal_Int32, sal_Int32)
sal_Int32 GetDims() const
bool hasFixedSize() const
void setHasFixedSize(bool bHasFixedSize)
void unoAddDim(sal_Int32, sal_Int32)
void Put(SbxVariable *, const sal_Int32 *)
void setNumberAndDescription(::sal_Int32 _number, const OUString &_description)
static SbxVariableRef const & getErrObject()
static css::uno::Reference< ooo::vba::XErrObject > const & getUnoErrObject()
virtual SbxVariable * Find(const OUString &, SbxClassType)
const OUString & GetClassName() const
void SetClassName(const OUString &rNew)
void Remove(const OUString &, SbxClassType)
SbxVariable * Make(const OUString &, SbxClassType, SbxDataType, bool bIsRuntimeFunction=false)
virtual bool IsClass(const OUString &) const
bool Compute(SbxOperator, const SbxValue &)
bool PutString(const OUString &)
SbxBase * GetObject() const
bool PutInteger(sal_Int16)
bool PutObject(SbxBase *)
bool Convert(SbxDataType)
sal_Int32 GetLong() const
sal_Int16 GetInteger() const
bool SetType(SbxDataType)
const SbxObject * GetParent() const
void SetName(const OUString &)
virtual void Broadcast(SfxHintId nHintId) override
void SetParameters(SbxArray *p)
virtual SbxDataType GetType() const override
SbxArray * GetParameters() const
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
virtual SbxInfo * GetInfo()
virtual void SetParent(SbxObject *)
BASIC_DLLPRIVATE BasicDebugFlags StepPoint(sal_Int32 nLine, sal_Int32 nCol1, sal_Int32 nCol2)
static ErrCode GetSfxFromVBError(sal_uInt16 nError)
static SbModule * GetActiveModule()
static const OUString & GetErrorText()
BASIC_DLLPRIVATE BasicDebugFlags BreakPoint(sal_Int32 nLine, sal_Int32 nCol1, sal_Int32 nCol2)
static void Error(ErrCode, const OUString &rMsg={})
BASIC_DLLPRIVATE bool RTError(ErrCode, const OUString &rMsg, sal_Int32, sal_Int32, sal_Int32)
bool isVBAEnabled() const
static void MakeErrorText(ErrCode, std::u16string_view aMsg)
static void FatalError(ErrCode)
void SetVBAEnabled(bool bEnabled)
static sal_uInt16 GetVBErrorCode(ErrCode nError)
SbxVariable * VBAFind(const OUString &rName, SbxClassType t)
void setValue(const css::uno::Any &)
unsigned int GetRefCount() const
const LocaleDataWrapper & GetLocaleData() const
SbxVariable * getVBAConstant(const OUString &rName)
static VBAConstantHelper & instance()
bool SearchForward(const OUString &rStr, sal_Int32 *pStart, sal_Int32 *pEnd, css::util::SearchResult *pRes=nullptr)
#define PARAM_INFO_WITHBRACKETS
#define PARAM_INFO_PARAMARRAY
#define TOOLS_WARN_EXCEPTION(area, stream)
#define LANGUAGE_DONTKNOW
#define LANGUAGE_ENGLISH_US
#define SAL_INFO_IF(condition, area, stream)
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0')
OUStringBuffer & truncateToLength(OUStringBuffer &rBuffer, sal_Int32 nLength)
Reference< XComponentContext > getProcessComponentContext()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Reference< XInvocation2 > xInvocation
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
static void implCopyDimArray(SbxDimArray *pNewArray, SbxDimArray *pOldArray, sal_Int32 nMaxDimIndex, sal_Int32 nActualDim, sal_Int32 *pActualIndices, sal_Int32 *pLowerBounds, sal_Int32 *pUpperBounds)
static void lcl_clearImpl(SbxVariableRef const &refVar, SbxDataType const &eType)
void removeDimAsNewRecoverItem(SbxVariable *pVar)
void setBasicWatchMode(bool bOn)
static bool implRestorePreservedArray(SbxDimArray *pNewArray, SbxArrayRef &rrefRedimpArray, bool *pbWasError=nullptr)
std::unordered_map< SbxVariable *, DimAsNewRecoverItem, SbxVariablePtrHash > DimAsNewRecoverHash
constexpr OUStringLiteral pCollectionStr
StarBASIC * GetCurrentBasic(StarBASIC *pRTBasic)
static bool checkUnoStructCopy(bool bVBA, SbxVariableRef const &refVal, SbxVariableRef const &refVar)
static void lcl_eraseImpl(SbxVariableRef const &refVar, bool bVBAEnabled)
void implStepRenameUCB(const OUString &aSource, const OUString &aDest)
void implStepRenameOSL(const OUString &aSource, const OUString &aDest)
void checkArithmeticOverflow(double d)
SbxObjectRef createUserTypeImpl(const OUString &rClassName)
#define ERRCODE_BASIC_USER_ABORT
#define ERRCODE_BASIC_INVALID_OBJECT
#define ERRCODE_BASIC_NO_METHOD
#define ERRCODE_BASIC_BAD_PARAMETERS
#define ERRCODE_BASIC_NO_OBJECT
#define ERRCODE_BASIC_BAD_PARAMETER
#define ERRCODE_BASIC_PROC_UNDEFINED
#define ERRCODE_BASIC_OUT_OF_RANGE
#define ERRCODE_BASIC_NO_GOSUB
#define ERRCODE_BASIC_VAR_UNDEFINED
#define ERRCODE_BASIC_COMPAT
#define ERRCODE_BASIC_NAMED_NOT_FOUND
#define ERRCODE_BASIC_CONVERSION
#define ERRCODE_BASIC_BAD_ARGUMENT
#define ERRCODE_BASIC_INTERNAL_ERROR
#define ERRCODE_BASIC_BAD_RESUME
#define ERRCODE_BASIC_NOT_OPTIONAL
#define ERRCODE_BASIC_NO_NAMED_ARGS
#define ERRCODE_BASIC_NEEDS_OBJECT
#define ERRCODE_BASIC_STACK_OVERFLOW
#define ERRCODE_BASIC_INVALID_USAGE_OBJECT
SbUnoClass * findUnoClass(const OUString &rName)
void unoToSbxValue(SbxVariable *pVar, const Any &aValue)
SbxVariable * getDefaultProp(SbxVariable *pRef)
Reference< XInterface > createComListener(const Any &aControlAny, const OUString &aVBAType, std::u16string_view aPrefix, const SbxObjectRef &xScopeObj)
bool checkUnoObjectType(SbUnoObject &rUnoObj, const OUString &rClass)
const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG
const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG
const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG
const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG
SbiArgv(SbxArrayRef refArgv_, short nArgc_)
sal_Int32 nCurCollectionIndex
StarBASIC * pMSOMacroRuntimLib
SbiGosub(const sal_uInt8 *pCode_, sal_uInt16 nStartForLvl_)
TransliterationFlags transliterateFlags