diff options
Diffstat (limited to 'basic/source/classes/sbunoobj.cxx')
-rw-r--r-- | basic/source/classes/sbunoobj.cxx | 417 |
1 files changed, 192 insertions, 225 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index ac6fcf8a2879..5fea3f14179f 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -20,19 +20,19 @@ #include <sal/config.h> #include <o3tl/any.hxx> -#include <osl/mutex.hxx> +#include <o3tl/safeint.hxx> +#include <utility> #include <vcl/svapp.hxx> -#include <vcl/errcode.hxx> +#include <comphelper/errcode.hxx> #include <svl/hint.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/exc_hlp.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <comphelper/extract.hxx> #include <comphelper/processfactory.hxx> #include <cppuhelper/weakref.hxx> -#include <rtl/instance.hxx> #include <rtl/math.hxx> #include <rtl/ustrbuf.hxx> @@ -100,9 +100,9 @@ using namespace cppu; // Identifiers for creating the strings for dbg_Properties -constexpr OUStringLiteral ID_DBG_SUPPORTEDINTERFACES = u"Dbg_SupportedInterfaces"; -constexpr OUStringLiteral ID_DBG_PROPERTIES = u"Dbg_Properties"; -constexpr OUStringLiteral ID_DBG_METHODS = u"Dbg_Methods"; +constexpr OUString ID_DBG_SUPPORTEDINTERFACES = u"Dbg_SupportedInterfaces"_ustr; +constexpr OUString ID_DBG_PROPERTIES = u"Dbg_Properties"_ustr; +constexpr OUString ID_DBG_METHODS = u"Dbg_Methods"_ustr; char const aSeqLevelStr[] = "[]"; @@ -233,22 +233,18 @@ static Reference< XTypeConverter > const & getTypeConverter_Impl() // #111851 factory function to create an OLE object SbUnoObject* createOLEObject_Impl( const OUString& aType ) { - static Reference< XMultiServiceFactory > xOLEFactory; - static bool bNeedsInit = true; - - if( bNeedsInit ) - { - bNeedsInit = false; - + static const Reference<XMultiServiceFactory> xOLEFactory = [] { + Reference<XMultiServiceFactory> xFactory; Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); if( xContext.is() ) { Reference<XMultiComponentFactory> xSMgr = xContext->getServiceManager(); - xOLEFactory.set( + xFactory.set( xSMgr->createInstanceWithContext( "com.sun.star.bridge.OleObjectFactory", xContext ), UNO_QUERY ); } - } + return xFactory; + }(); SbUnoObject* pUnoObj = nullptr; if( xOLEFactory.is() ) @@ -284,13 +280,13 @@ namespace } } -static void implAppendExceptionMsg( OUStringBuffer& _inout_rBuffer, const Exception& _e, const OUString& _rExceptionType, sal_Int32 _nLevel ) +static void implAppendExceptionMsg( OUStringBuffer& _inout_rBuffer, const Exception& _e, std::u16string_view _rExceptionType, sal_Int32 _nLevel ) { _inout_rBuffer.append( "\n" ); lcl_indent( _inout_rBuffer, _nLevel ); _inout_rBuffer.append( "Type: " ); - if ( _rExceptionType.isEmpty() ) + if ( _rExceptionType.empty() ) _inout_rBuffer.append( "Unknown" ); else _inout_rBuffer.append( _rExceptionType ); @@ -303,7 +299,7 @@ static void implAppendExceptionMsg( OUStringBuffer& _inout_rBuffer, const Except } // construct an error message for the exception -static OUString implGetExceptionMsg( const Exception& e, const OUString& aExceptionType_ ) +static OUString implGetExceptionMsg( const Exception& e, std::u16string_view aExceptionType_ ) { OUStringBuffer aMessageBuf; implAppendExceptionMsg( aMessageBuf, e, aExceptionType_, 0 ); @@ -338,7 +334,7 @@ static Any convertAny( const Any& rVal, const Type& aDestType ) catch( const CannotConvertException& e2 ) { StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, - implGetExceptionMsg( e2, "com.sun.star.lang.IllegalArgumentException" ) ); + implGetExceptionMsg( e2, u"com.sun.star.lang.IllegalArgumentException" ) ); return aConvertedVal; } return aConvertedVal; @@ -453,30 +449,28 @@ typedef std::vector< ObjectItem > NativeObjectWrapperVector; namespace { -class GaNativeObjectWrapperVector : public rtl::Static<NativeObjectWrapperVector, GaNativeObjectWrapperVector> {}; +NativeObjectWrapperVector gaNativeObjectWrapperVector; } void clearNativeObjectWrapperVector() { - GaNativeObjectWrapperVector::get().clear(); + gaNativeObjectWrapperVector.clear(); } static sal_uInt32 lcl_registerNativeObjectWrapper( SbxObject* pNativeObj ) { - NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get(); - sal_uInt32 nIndex = rNativeObjectWrapperVector.size(); - rNativeObjectWrapperVector.emplace_back( pNativeObj ); + sal_uInt32 nIndex = gaNativeObjectWrapperVector.size(); + gaNativeObjectWrapperVector.emplace_back( pNativeObj ); return nIndex; } static SbxObject* lcl_getNativeObject( sal_uInt32 nIndex ) { SbxObjectRef xRetObj; - NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get(); - if( nIndex < rNativeObjectWrapperVector.size() ) + if( nIndex < gaNativeObjectWrapperVector.size() ) { - ObjectItem& rItem = rNativeObjectWrapperVector[ nIndex ]; + ObjectItem& rItem = gaNativeObjectWrapperVector[ nIndex ]; xRetObj = rItem.m_xNativeObj; } return xRetObj.get(); @@ -548,6 +542,7 @@ static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int sal_Int32 nLen = xIdlArray->getLen( aValue ); for ( sal_Int32 index = 0; index < nLen; ++index ) { + auto pindices = indices.getArray(); Any aElementAny = xIdlArray->get( aValue, static_cast<sal_uInt32>(index) ); // This detects the dimension were currently processing if ( dimCopy == dimension ) @@ -556,15 +551,16 @@ static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int if ( sizes.getLength() < dimCopy ) { sizes.realloc( sizes.getLength() + 1 ); - sizes[ sizes.getLength() - 1 ] = nLen; + sizes.getArray()[ sizes.getLength() - 1 ] = nLen; indices.realloc( indices.getLength() + 1 ); + pindices = indices.getArray(); } } if ( bIsZeroIndex ) - indices[ dimCopy - 1 ] = index; + pindices[ dimCopy - 1 ] = index; else - indices[ dimCopy - 1] = index + 1; + pindices[ dimCopy - 1] = index + 1; implSequenceToMultiDimArray( pArray, indices, sizes, aElementAny, dimCopy, bIsZeroIndex, &aElementType ); } @@ -592,9 +588,9 @@ static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int for ( sal_Int32 index = 0; index < nIndexLen; ++index ) { if ( bIsZeroIndex ) - pArray->unoAddDim32( 0, sizes[ index ] - 1); + pArray->unoAddDim(0, sizes[index] - 1); else - pArray->unoAddDim32( 1, sizes[ index ] ); + pArray->unoAddDim(1, sizes[index]); } } @@ -605,7 +601,7 @@ static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int unoToSbxValue( xVar.get(), aValue ); sal_Int32* pIndices = indices.getArray(); - pArray->Put32( xVar.get(), pIndices ); + pArray->Put(xVar.get(), pIndices); } } @@ -768,7 +764,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) xArray = new SbxDimArray( eSbxElementType ); if( nLen > 0 ) { - xArray->unoAddDim32( 0, nLen - 1 ); + xArray->unoAddDim(0, nLen - 1); // register the elements as variables for( i = 0 ; i < nLen ; i++ ) @@ -779,12 +775,12 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) unoToSbxValue( xVar.get(), aElementAny ); // put into the Array - xArray->Put32( xVar.get(), &i ); + xArray->Put(xVar.get(), &i); } } else { - xArray->unoAddDim32( 0, -1 ); + xArray->unoAddDim(0, -1); } // return the Array @@ -873,13 +869,13 @@ static Type getUnoTypeForSbxValue( const SbxValue* pVal ) if( auto pArray = dynamic_cast<SbxDimArray*>( xObj.get() ) ) { - sal_Int32 nDims = pArray->GetDims32(); + sal_Int32 nDims = pArray->GetDims(); Type aElementType = getUnoTypeForSbxBaseType( static_cast<SbxDataType>(pArray->GetType() & 0xfff) ); TypeClass eElementTypeClass = aElementType.getTypeClass(); // Normal case: One dimensional array sal_Int32 nLower, nUpper; - if( nDims == 1 && pArray->GetDim32( 1, nLower, nUpper ) ) + if (nDims == 1 && pArray->GetDim(1, nLower, nUpper)) { if( eElementTypeClass == TypeClass_VOID || eElementTypeClass == TypeClass_ANY ) { @@ -889,7 +885,7 @@ static Type getUnoTypeForSbxValue( const SbxValue* pVal ) for (sal_Int32 aIdx[1] = { nLower }; aIdx[0] <= nUpper; ++aIdx[0]) { - SbxVariableRef xVar = pArray->Get32(aIdx); + SbxVariableRef xVar = pArray->Get(aIdx); Type aType = getUnoTypeForSbxValue( xVar.get() ); if( bNeedsInit ) { @@ -921,12 +917,12 @@ static Type getUnoTypeForSbxValue( const SbxValue* pVal ) if( eElementTypeClass == TypeClass_VOID || eElementTypeClass == TypeClass_ANY ) { // For this check the array's dim structure does not matter - sal_uInt32 nFlatArraySize = pArray->Count32(); + sal_uInt32 nFlatArraySize = pArray->Count(); bool bNeedsInit = true; for( sal_uInt32 i = 0 ; i < nFlatArraySize ; i++ ) { - SbxVariableRef xVar = pArray->SbxArray::Get32( i ); + SbxVariableRef xVar = pArray->SbxArray::Get(i); Type aType = getUnoTypeForSbxValue( xVar.get() ); if( bNeedsInit ) { @@ -973,6 +969,12 @@ static Type getUnoTypeForSbxValue( const SbxValue* pVal ) // No object, convert basic type else { + if (eBaseType == SbxBYTE && pVal->GetByte() > 127) + { + // Basic Byte type is unsigned; cppu::UnoType<sal_uInt8> corresponds to UNO boolean, + // so values 128-255 are only representable starting with UNO short types + eBaseType = SbxUSHORT; + } aRetType = getUnoTypeForSbxBaseType( eBaseType ); } return aRetType; @@ -1053,19 +1055,10 @@ static Any sbxToUnoValueImpl( const SbxValue* pVar, bool bBlockConversionToSmall aType = ::cppu::UnoType<sal_Int16>::get(); break; } - case TypeClass_UNSIGNED_SHORT: - { - sal_uInt16 n = pVar->GetUShort(); - if( n <= 255 ) - aType = cppu::UnoType<sal_uInt8>::get(); - break; - } case TypeClass_UNSIGNED_LONG: { sal_uInt32 n = pVar->GetLong(); - if( n <= 255 ) - aType = cppu::UnoType<sal_uInt8>::get(); - else if( n <= SbxMAXUINT ) + if( n <= SbxMAXUINT ) aType = cppu::UnoType<cppu::UnoUnsignedShortType>::get(); break; } @@ -1118,7 +1111,7 @@ static Any implRekMultiDimArrayToSequence( SbxDimArray* pArray, } else { - SbxVariable* pSource = pArray->Get32( pActualIndices ); + SbxVariable* pSource = pArray->Get(pActualIndices); aElementVal = sbxToUnoValue( pSource, aElemType ); } @@ -1304,11 +1297,11 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property const * pUn SbxBaseRef xObj = pVar->GetObject(); if( auto pArray = dynamic_cast<SbxDimArray*>( xObj.get() ) ) { - sal_Int32 nDims = pArray->GetDims32(); + sal_Int32 nDims = pArray->GetDims(); // Normal case: One dimensional array sal_Int32 nLower, nUpper; - if( nDims == 1 && pArray->GetDim32( 1, nLower, nUpper ) ) + if (nDims == 1 && pArray->GetDim(1, nLower, nUpper)) { sal_Int32 nSeqSize = nUpper - nLower + 1; @@ -1330,7 +1323,7 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property const * pUn aIdx[0] = nLower; for (sal_Int32 i = 0 ; i < nSeqSize; ++i, ++aIdx[0]) { - SbxVariableRef xVar = pArray->Get32(aIdx); + SbxVariableRef xVar = pArray->Get(aIdx); // Convert the value of Sbx to Uno Any aAnyValue = sbxToUnoValue( xVar.get(), aElemType ); @@ -1385,7 +1378,7 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property const * pUn for(sal_Int32 i = 1 ; i <= nDims ; i++ ) { sal_Int32 lBound, uBound; - pArray->GetDim32( i, lBound, uBound ); + pArray->GetDim(i, lBound, uBound); sal_Int32 j = i - 1; pActualIndices[j] = pLowerBounds[j] = lBound; @@ -1472,7 +1465,7 @@ static void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, s { sal_uInt32 iSbx = i + 1; - aValAny = sbxToUnoValueImpl( pParams->Get32( iSbx ), + aValAny = sbxToUnoValueImpl(pParams->Get(iSbx), bBlockConversionToSmallestType ); OUString aParamName = pNames[iSbx]; @@ -1493,7 +1486,7 @@ static void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, s { for( i = 0 ; i < nParamCount ; i++ ) { - pAnyArgs[i] = sbxToUnoValueImpl(pParams->Get32(i + 1), + pAnyArgs[i] = sbxToUnoValueImpl(pParams->Get(i + 1), bBlockConversionToSmallestType ); } } @@ -1539,9 +1532,9 @@ static Any invokeAutomationMethod( const OUString& Name, Sequence< Any > const & for( sal_uInt32 j = 0 ; j < nLen ; j++ ) { sal_Int16 iTarget = pIndices[ j ]; - if( iTarget >= static_cast<sal_Int16>(nParamCount) ) + if( o3tl::make_unsigned(iTarget) >= nParamCount ) break; - unoToSbxValue( pParams->Get32(j + 1), pNewValues[ j ] ); + unoToSbxValue(pParams->Get(j + 1), pNewValues[j]); } } return aRetAny; @@ -1612,9 +1605,7 @@ static OUString getDbgObjectName(SbUnoObject& rUnoObj) { aRet.append( "\n" ); } - aRet.append( "\"" ); - aRet.append( aName ); - aRet.append( "\":" ); + aRet.append( "\"" + aName + "\":" ); return aRet.makeStringAndClear(); } @@ -1746,16 +1737,16 @@ static OUString Impl_GetSupportedInterfaces(SbUnoObject& rUnoObj) auto x = o3tl::tryAccess<Reference<XInterface>>(aToInspectObj); if( !x ) { - aRet.append( ID_DBG_SUPPORTEDINTERFACES ); - aRet.append( " not available.\n(TypeClass is not TypeClass_INTERFACE)\n" ); + aRet.append( ID_DBG_SUPPORTEDINTERFACES + + " not available.\n(TypeClass is not TypeClass_INTERFACE)\n" ); } else { Reference< XTypeProvider > xTypeProvider( *x, UNO_QUERY ); - aRet.append( "Supported interfaces by object " ); - aRet.append(getDbgObjectName(rUnoObj)); - aRet.append( "\n" ); + aRet.append( "Supported interfaces by object " + + getDbgObjectName(rUnoObj) + + "\n" ); if( xTypeProvider.is() ) { // get the interfaces of the implementation @@ -1776,9 +1767,9 @@ static OUString Impl_GetSupportedInterfaces(SbUnoObject& rUnoObj) typelib_TypeDescription * pTD = nullptr; rType.getDescription( &pTD ); - aRet.append( "*** ERROR: No IdlClass for type \"" ); - aRet.append( pTD->pTypeName ); - aRet.append( "\"\n*** Please check type library\n" ); + aRet.append( OUString::Concat("*** ERROR: No IdlClass for type \"") + + OUString::unacquired(&pTD->pTypeName) + + "\"\n*** Please check type library\n" ); } } } @@ -1834,9 +1825,7 @@ static OUString Dbg_SbxDataType2String( SbxDataType eType ) // Debugging help method to display the properties of a SbUnoObjects static OUString Impl_DumpProperties(SbUnoObject& rUnoObj) { - OUStringBuffer aRet; - aRet.append("Properties of object "); - aRet.append(getDbgObjectName(rUnoObj)); + OUStringBuffer aRet("Properties of object " + getDbgObjectName(rUnoObj)); // analyse the Uno-Infos to recognise the arrays Reference< XIntrospectionAccess > xAccess = rUnoObj.getIntrospectionAccess(); @@ -1857,11 +1846,11 @@ static OUString Impl_DumpProperties(SbUnoObject& rUnoObj) const Property* pUnoProps = props.getConstArray(); SbxArray* pProps = rUnoObj.GetProperties(); - sal_uInt32 nPropCount = pProps->Count32(); + sal_uInt32 nPropCount = pProps->Count(); sal_uInt32 nPropsPerLine = 1 + nPropCount / 30; for( sal_uInt32 i = 0; i < nPropCount; i++ ) { - SbxVariable* pVar = pProps->Get32( i ); + SbxVariable* pVar = pProps->Get(i); if( pVar ) { OUStringBuffer aPropStr; @@ -1894,15 +1883,14 @@ static OUString Impl_DumpProperties(SbUnoObject& rUnoObj) aPropStr.append( Dbg_SbxDataType2String( eType ) ); if( bMaybeVoid ) aPropStr.append( "/void" ); - aPropStr.append( " " ); - aPropStr.append( pVar->GetName() ); + aPropStr.append( " " + pVar->GetName() ); if( i == nPropCount - 1 ) aPropStr.append( "\n" ); else aPropStr.append( "; " ); - aRet.append( aPropStr.makeStringAndClear() ); + aRet.append( aPropStr ); } } return aRet.makeStringAndClear(); @@ -1911,9 +1899,7 @@ static OUString Impl_DumpProperties(SbUnoObject& rUnoObj) // Debugging help method to display the methods of an SbUnoObjects static OUString Impl_DumpMethods(SbUnoObject& rUnoObj) { - OUStringBuffer aRet; - aRet.append("Methods of object "); - aRet.append(getDbgObjectName(rUnoObj)); + OUStringBuffer aRet("Methods of object " + getDbgObjectName(rUnoObj)); // XIntrospectionAccess, so that the types of the parameter could be outputted Reference< XIntrospectionAccess > xAccess = rUnoObj.getIntrospectionAccess(); @@ -1933,7 +1919,7 @@ static OUString Impl_DumpMethods(SbUnoObject& rUnoObj) const Reference< XIdlMethod >* pUnoMethods = methods.getConstArray(); SbxArray* pMethods = rUnoObj.GetMethods(); - sal_uInt32 nMethodCount = pMethods->Count32(); + sal_uInt32 nMethodCount = pMethods->Count(); if( !nMethodCount ) { aRet.append( "\nNo methods found\n" ); @@ -1942,7 +1928,7 @@ static OUString Impl_DumpMethods(SbUnoObject& rUnoObj) sal_uInt32 nPropsPerLine = 1 + nMethodCount / 30; for( sal_uInt32 i = 0; i < nMethodCount; i++ ) { - SbxVariable* pVar = pMethods->Get32( i ); + SbxVariable* pVar = pMethods->Get(i); if( pVar ) { if( (i % nPropsPerLine) == 0 ) @@ -1960,10 +1946,8 @@ static OUString Impl_DumpMethods(SbUnoObject& rUnoObj) eType = SbxDataType( SbxOBJECT | SbxARRAY ); } // output the name and the type - aRet.append( Dbg_SbxDataType2String( eType ) ); - aRet.append( " " ); - aRet.append ( pVar->GetName() ); - aRet.append( " ( " ); + aRet.append( Dbg_SbxDataType2String( eType ) + + " " + pVar->GetName() + " ( " ); // the get-method mustn't have a parameter Sequence< Reference< XIdlClass > > aParamsSeq = rxMethod->getParameterTypes(); @@ -2057,7 +2041,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { if ( pProp->isUnoStruct() ) { - SbUnoStructRefObject* pSbUnoObject = new SbUnoStructRefObject( pProp->GetName(), aMember ); + SbUnoStructRefObject* pSbUnoObject = new SbUnoStructRefObject( pProp->GetName(), std::move(aMember) ); SbxObjectRef xWrapper = static_cast<SbxObject*>(pSbUnoObject); pVar->PutObject( xWrapper.get() ); } @@ -2089,7 +2073,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { try { - sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0; + sal_uInt32 nParamCount = pParams ? (pParams->Count() - 1) : 0; bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() ); Any aRetAny; if ( bCanBeConsideredAMethod && nParamCount ) @@ -2136,7 +2120,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) aMember.setValue( aAnyValue ); } return; - } + } // take over the value from Uno to Sbx Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp ); try @@ -2175,7 +2159,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) if( pHint->GetId() == SfxHintId::BasicDataWanted ) { // number of Parameter -1 because of Param0 == this - sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0; + sal_uInt32 nParamCount = pParams ? (pParams->Count() - 1) : 0; Sequence<Any> args; bool bOutParams = false; @@ -2227,7 +2211,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) css::uno::Type aType( rxClass->getTypeClass(), rxClass->getName() ); // ATTENTION: Don't forget for Sbx-Parameter the offset! - pAnyArgs[i] = sbxToUnoValue( pParams->Get32(i + 1), aType ); + pAnyArgs[i] = sbxToUnoValue(pParams->Get(i + 1), aType); // If it is not certain check whether the out-parameter are available. if( !bOutParams ) @@ -2270,7 +2254,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) const ParamInfo& rInfo = pParamInfos[j]; ParamMode aParamMode = rInfo.aMode; if( aParamMode != ParamMode_IN ) - unoToSbxValue( pParams->Get32(j + 1), pAnyArgs[ j ] ); + unoToSbxValue(pParams->Get(j + 1), pAnyArgs[j]); } } } @@ -2317,12 +2301,9 @@ SbUnoObject::SbUnoObject( const OUString& aName_, const Any& aUnoObj_ ) return; } - Reference< XTypeProvider > xTypeProvider; // Did the object have an invocation itself? mxInvocation.set( x, UNO_QUERY ); - xTypeProvider.set( x, UNO_QUERY ); - if( mxInvocation.is() ) { @@ -2330,6 +2311,7 @@ SbUnoObject::SbUnoObject( const OUString& aName_, const Any& aUnoObj_ ) mxExactNameInvocation.set( mxInvocation, UNO_QUERY ); // The remainder refers only to the introspection + Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY ); if( !xTypeProvider.is() ) { bNeedIntrospection = false; @@ -2442,11 +2424,11 @@ void SbUnoObject::doIntrospection() // Start of a list of all SbUnoMethod-Instances -static SbUnoMethod* pFirst = nullptr; +static SbUnoMethod* s_pFirst = nullptr; void clearUnoMethodsForBasic( StarBASIC const * pBasic ) { - SbUnoMethod* pMeth = pFirst; + SbUnoMethod* pMeth = s_pFirst; while( pMeth ) { SbxObject* pObject = pMeth->GetParent(); @@ -2461,8 +2443,8 @@ void clearUnoMethodsForBasic( StarBASIC const * pBasic ) // set the new StarBASIC as the parent of the module // pObject->SetParent( NULL ); - if( pMeth == pFirst ) - pFirst = pMeth->pNext; + if( pMeth == s_pFirst ) + s_pFirst = pMeth->pNext; else if( pMeth->pPrev ) pMeth->pPrev->pNext = pMeth->pNext; if( pMeth->pNext ) @@ -2475,7 +2457,7 @@ void clearUnoMethodsForBasic( StarBASIC const * pBasic ) pObject->SbxValue::Clear(); // start from the beginning after object clearing, the cycle will end since the method is removed each time - pMeth = pFirst; + pMeth = s_pFirst; } else pMeth = pMeth->pNext; @@ -2487,7 +2469,7 @@ void clearUnoMethodsForBasic( StarBASIC const * pBasic ) void clearUnoMethods() { - SbUnoMethod* pMeth = pFirst; + SbUnoMethod* pMeth = s_pFirst; while( pMeth ) { pMeth->SbxValue::Clear(); @@ -2510,9 +2492,9 @@ SbUnoMethod::SbUnoMethod pParamInfoSeq = nullptr; // enregister the method in a list - pNext = pFirst; + pNext = s_pFirst; pPrev = nullptr; - pFirst = this; + s_pFirst = this; if( pNext ) pNext->pPrev = this; } @@ -2521,8 +2503,8 @@ SbUnoMethod::~SbUnoMethod() { pParamInfoSeq.reset(); - if( this == pFirst ) - pFirst = pNext; + if( this == s_pFirst ) + s_pFirst = pNext; else if( pPrev ) pPrev->pNext = pNext; if( pNext ) @@ -2571,13 +2553,13 @@ SbUnoProperty::SbUnoProperty const OUString& aName_, SbxDataType eSbxType, SbxDataType eRealSbxType, - const Property& aUnoProp_, + Property aUnoProp_, sal_Int32 nId_, bool bInvocation, bool bUnoStruct ) : SbxProperty( aName_, eSbxType ) - , aUnoProp( aUnoProp_ ) + , aUnoProp(std::move( aUnoProp_ )) , nId( nId_ ) , mbInvocation( bInvocation ) , mRealType( eRealSbxType ) @@ -2761,15 +2743,15 @@ void SbUnoObject::implCreateDbgProperties() Property aProp; // Id == -1: display the implemented interfaces corresponding the ClassProvider - auto xVarRef = tools::make_ref<SbUnoProperty>( OUString(ID_DBG_SUPPORTEDINTERFACES), SbxSTRING, SbxSTRING, aProp, -1, false, false ); + auto xVarRef = tools::make_ref<SbUnoProperty>( ID_DBG_SUPPORTEDINTERFACES, SbxSTRING, SbxSTRING, aProp, -1, false, false ); QuickInsert( xVarRef.get() ); // Id == -2: output the properties - xVarRef = tools::make_ref<SbUnoProperty>( OUString(ID_DBG_PROPERTIES), SbxSTRING, SbxSTRING, aProp, -2, false, false ); + xVarRef = tools::make_ref<SbUnoProperty>( ID_DBG_PROPERTIES, SbxSTRING, SbxSTRING, aProp, -2, false, false ); QuickInsert( xVarRef.get() ); // Id == -3: output the Methods - xVarRef = tools::make_ref<SbUnoProperty>( OUString(ID_DBG_METHODS), SbxSTRING, SbxSTRING, aProp, -3, false, false ); + xVarRef = tools::make_ref<SbUnoProperty>( ID_DBG_METHODS, SbxSTRING, SbxSTRING, aProp, -3, false, false ); QuickInsert( xVarRef.get() ); } @@ -2852,7 +2834,7 @@ Any SbUnoObject::getUnoAny() } // help method to create a Uno-Struct per CoreReflection -static SbUnoObject* Impl_CreateUnoStruct( const OUString& aClassName ) +static SbUnoObjectRef Impl_CreateUnoStruct( const OUString& aClassName ) { // get CoreReflection Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl(); @@ -2877,21 +2859,21 @@ static SbUnoObject* Impl_CreateUnoStruct( const OUString& aClassName ) Any aNewAny; xClass->createObject( aNewAny ); // make a SbUnoObject out of it - SbUnoObject* pUnoObj = new SbUnoObject( aClassName, aNewAny ); + SbUnoObjectRef pUnoObj = new SbUnoObject( aClassName, aNewAny ); return pUnoObj; } // Factory-Class to create Uno-Structs per DIM AS NEW -SbxBase* SbUnoFactory::Create( sal_uInt16, sal_uInt32 ) +SbxBaseRef SbUnoFactory::Create( sal_uInt16, sal_uInt32 ) { // Via SbxId nothing works in Uno return nullptr; } -SbxObject* SbUnoFactory::CreateObject( const OUString& rClassName ) +SbxObjectRef SbUnoFactory::CreateObject( const OUString& rClassName ) { - return Impl_CreateUnoStruct( rClassName ); + return Impl_CreateUnoStruct( rClassName ).get(); } @@ -2924,14 +2906,14 @@ void createAllObjectProperties( SbxObject* pObj ) void RTL_Impl_CreateUnoStruct( SbxArray& rPar ) { // We need 1 parameter minimum - if ( rPar.Count32() < 2 ) + if (rPar.Count() < 2) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } // get the name of the class of the struct - OUString aClassName = rPar.Get32(1)->GetOUString(); + OUString aClassName = rPar.Get(1)->GetOUString(); // try to create Struct with the same name SbUnoObjectRef xUnoObj = Impl_CreateUnoStruct( aClassName ); @@ -2940,21 +2922,21 @@ void RTL_Impl_CreateUnoStruct( SbxArray& rPar ) return; } // return the object - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); refVar->PutObject( xUnoObj.get() ); } void RTL_Impl_CreateUnoService( SbxArray& rPar ) { // We need 1 Parameter minimum - if ( rPar.Count32() < 2 ) + if (rPar.Count() < 2) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } // get the name of the class of the struct - OUString aServiceName = rPar.Get32(1)->GetOUString(); + OUString aServiceName = rPar.Get(1)->GetOUString(); // search for the service and instantiate it Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() ); @@ -2968,7 +2950,7 @@ void RTL_Impl_CreateUnoService( SbxArray& rPar ) implHandleAnyException( ::cppu::getCaughtException() ); } - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); if( xInterface.is() ) { // Create a SbUnoObject out of it and return it @@ -2992,15 +2974,15 @@ void RTL_Impl_CreateUnoService( SbxArray& rPar ) void RTL_Impl_CreateUnoServiceWithArguments( SbxArray& rPar ) { // We need 2 parameter minimum - if ( rPar.Count32() < 3 ) + if (rPar.Count() < 3) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } // get the name of the class of the struct - OUString aServiceName = rPar.Get32(1)->GetOUString(); - Any aArgAsAny = sbxToUnoValue( rPar.Get32(2), + OUString aServiceName = rPar.Get(1)->GetOUString(); + Any aArgAsAny = sbxToUnoValue(rPar.Get(2), cppu::UnoType<Sequence<Any>>::get() ); Sequence< Any > aArgs; aArgAsAny >>= aArgs; @@ -3017,7 +2999,7 @@ void RTL_Impl_CreateUnoServiceWithArguments( SbxArray& rPar ) implHandleAnyException( ::cppu::getCaughtException() ); } - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); if( xInterface.is() ) { // Create a SbUnoObject out of it and return it @@ -3040,7 +3022,7 @@ void RTL_Impl_CreateUnoServiceWithArguments( SbxArray& rPar ) void RTL_Impl_GetProcessServiceManager( SbxArray& rPar ) { - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); // get the global service manager Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() ); @@ -3053,7 +3035,7 @@ void RTL_Impl_GetProcessServiceManager( SbxArray& rPar ) void RTL_Impl_HasInterfaces( SbxArray& rPar ) { // We need 2 parameter minimum - sal_uInt32 nParCount = rPar.Count32(); + sal_uInt32 nParCount = rPar.Count(); if( nParCount < 3 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -3061,11 +3043,11 @@ void RTL_Impl_HasInterfaces( SbxArray& rPar ) } // variable for the return value - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); refVar->PutBool( false ); // get the Uno-Object - SbxBaseRef pObj = rPar.Get32( 1 )->GetObject(); + SbxBaseRef pObj = rPar.Get(1)->GetObject(); auto obj = dynamic_cast<SbUnoObject*>( pObj.get() ); if( obj == nullptr ) { @@ -3087,7 +3069,7 @@ void RTL_Impl_HasInterfaces( SbxArray& rPar ) for( sal_uInt32 i = 2 ; i < nParCount ; i++ ) { // get the name of the interface of the struct - OUString aIfaceName = rPar.Get32( i )->GetOUString(); + OUString aIfaceName = rPar.Get(i)->GetOUString(); // search for the class Reference< XIdlClass > xClass = xCoreReflection->forName( aIfaceName ); @@ -3111,18 +3093,18 @@ void RTL_Impl_HasInterfaces( SbxArray& rPar ) void RTL_Impl_IsUnoStruct( SbxArray& rPar ) { // We need 1 parameter minimum - if ( rPar.Count32() < 2 ) + if (rPar.Count() < 2) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } // variable for the return value - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); refVar->PutBool( false ); // get the Uno-Object - SbxVariableRef xParam = rPar.Get32( 1 ); + SbxVariableRef xParam = rPar.Get(1); if( !xParam->IsObject() ) { return; @@ -3144,18 +3126,18 @@ void RTL_Impl_IsUnoStruct( SbxArray& rPar ) void RTL_Impl_EqualUnoObjects( SbxArray& rPar ) { - if ( rPar.Count32() < 3 ) + if (rPar.Count() < 3) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } // variable for the return value - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); refVar->PutBool( false ); // get the Uno-Objects - SbxVariableRef xParam1 = rPar.Get32( 1 ); + SbxVariableRef xParam1 = rPar.Get(1); if( !xParam1->IsObject() ) { return; @@ -3175,7 +3157,7 @@ void RTL_Impl_EqualUnoObjects( SbxArray& rPar ) Reference< XInterface > x1; aAny1 >>= x1; - SbxVariableRef xParam2 = rPar.Get32( 2 ); + SbxVariableRef xParam2 = rPar.Get(2); if( !xParam2->IsObject() ) { return; @@ -3277,14 +3259,14 @@ void VBAConstantHelper::init() } bool -VBAConstantHelper::isVBAConstantType( const OUString& rName ) +VBAConstantHelper::isVBAConstantType( std::u16string_view rName ) { init(); bool bConstant = false; for (auto const& elem : aConstCache) { - if( rName.equalsIgnoreAsciiCase(elem) ) + if( o3tl::equalsIgnoreAsciiCase(rName, elem) ) { bConstant = true; break; @@ -3541,7 +3523,7 @@ void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) if( pUnoCtor && pHint->GetId() == SfxHintId::BasicDataWanted ) { // Parameter count -1 because of Param0 == this - sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0; + sal_uInt32 nParamCount = pParams ? (pParams->Count() - 1) : 0; Sequence<Any> args; Reference< XServiceConstructorDescription > xCtor = pUnoCtor->getServiceCtorDesc(); @@ -3572,7 +3554,7 @@ void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { // Check if first parameter is a context and use it // then in createInstanceWithArgumentsAndContext - Any aArg0 = sbxToUnoValue( pParams->Get32( nSbxParameterOffset ) ); + Any aArg0 = sbxToUnoValue(pParams->Get(nSbxParameterOffset)); if( (aArg0 >>= xFirstParamContext) && xFirstParamContext.is() ) nParameterOffsetByContext = 1; } @@ -3624,7 +3606,7 @@ void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) css::uno::Type aType( xParamTypeDesc->getTypeClass(), xParamTypeDesc->getName() ); // sbx parameter needs offset 1 - pAnyArgs[i] = sbxToUnoValue( pParams->Get32( iSbx ), aType ); + pAnyArgs[i] = sbxToUnoValue(pParams->Get(iSbx), aType); // Check for out parameter if not already done if( !bOutParams && xParam->isOut() ) @@ -3632,7 +3614,7 @@ void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) } else { - pAnyArgs[i] = sbxToUnoValue( pParams->Get32( iSbx ) ); + pAnyArgs[i] = sbxToUnoValue(pParams->Get(iSbx)); } } } @@ -3670,7 +3652,7 @@ void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) continue; if( xParam->isOut() ) - unoToSbxValue( pParams->Get32(j + 1), pAnyArgs[ j ] ); + unoToSbxValue(pParams->Get(j + 1), pAnyArgs[j]); } } } @@ -3735,7 +3717,7 @@ void SbUnoSingleton::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { SbxVariable* pVar = pHint->GetVar(); SbxArray* pParams = pVar->GetParameters(); - sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0; + sal_uInt32 nParamCount = pParams ? (pParams->Count() - 1) : 0; sal_uInt32 nAllowedParamCount = 1; Reference < XComponentContext > xContextToUse; @@ -3743,7 +3725,7 @@ void SbUnoSingleton::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { // Check if first parameter is a context and use it then Reference < XComponentContext > xFirstParamContext; - Any aArg1 = sbxToUnoValue( pParams->Get32( 1 ) ); + Any aArg1 = sbxToUnoValue(pParams->Get(1)); if( (aArg1 >>= xFirstParamContext) && xFirstParamContext.is() ) xContextToUse = xFirstParamContext; } @@ -3789,7 +3771,7 @@ public: SbxObjectRef xSbxObj; OUString aPrefixName; - explicit BasicAllListener_Impl( const OUString& aPrefixName ); + explicit BasicAllListener_Impl( OUString aPrefixName ); // Methods of XAllListener virtual void SAL_CALL firing(const AllEventObject& Event) override; @@ -3801,8 +3783,8 @@ public: } -BasicAllListener_Impl::BasicAllListener_Impl(const OUString& aPrefixName_) - : aPrefixName( aPrefixName_ ) +BasicAllListener_Impl::BasicAllListener_Impl(OUString aPrefixName_) + : aPrefixName(std::move( aPrefixName_ )) { } @@ -3831,7 +3813,7 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet // Convert elements SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); unoToSbxValue( xVar.get(), pArgs[i] ); - xSbxArray->Put32( xVar.get(), i + 1 ); + xSbxArray->Put(xVar.get(), i + 1); } pLib->Call( aMethodName, xSbxArray.get() ); @@ -3839,7 +3821,7 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet // get the return value from the Param-Array, if requested if( pRet ) { - SbxVariable* pVar = xSbxArray->Get32( 0 ); + SbxVariable* pVar = xSbxArray->Get(0); if( pVar ) { // #95792 Avoid a second call @@ -3887,7 +3869,7 @@ class InvocationToAllListenerMapper : public WeakImplHelper< XInvocation > { public: InvocationToAllListenerMapper( const Reference< XIdlClass >& ListenerType, - const Reference< XAllListener >& AllListener, const Any& Helper ); + const Reference< XAllListener >& AllListener, Any Helper ); // XInvocation virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() override; @@ -3928,10 +3910,10 @@ static Reference< XInterface > createAllListenerAdapter // InvocationToAllListenerMapper InvocationToAllListenerMapper::InvocationToAllListenerMapper - ( const Reference< XIdlClass >& ListenerType, const Reference< XAllListener >& AllListener, const Any& Helper ) + ( const Reference< XIdlClass >& ListenerType, const Reference< XAllListener >& AllListener, Any Helper ) : m_xAllListener( AllListener ) , m_xListenerType( ListenerType ) - , m_Helper( Helper ) + , m_Helper(std::move( Helper )) { } @@ -3978,7 +3960,7 @@ Any SAL_CALL InvocationToAllListenerMapper::invoke(const OUString& FunctionName, } AllEventObject aAllEvent; - aAllEvent.Source = static_cast<OWeakObject*>(this); + aAllEvent.Source = getXWeak(); aAllEvent.Helper = m_Helper; aAllEvent.ListenerType = Type(m_xListenerType->getTypeClass(), m_xListenerType->getName() ); aAllEvent.MethodName = FunctionName; @@ -4021,15 +4003,15 @@ sal_Bool SAL_CALL InvocationToAllListenerMapper::hasProperty(const OUString& Nam void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool) { // We need 2 parameters - if ( rPar.Count32() != 3 ) + if (rPar.Count() != 3) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } // get the name of the class of the struct - OUString aPrefixName = rPar.Get32(1)->GetOUString(); - OUString aListenerClassName = rPar.Get32(2)->GetOUString(); + OUString aPrefixName = rPar.Get(1)->GetOUString(); + OUString aListenerClassName = rPar.Get(2)->GetOUString(); // get the CoreReflection Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl(); @@ -4048,8 +4030,7 @@ void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool) Reference< XInvocationAdapterFactory2 > xInvocationAdapterFactory = InvocationAdapterFactory::create( xContext ); - BasicAllListener_Impl * p; - Reference< XAllListener > xAllLst = p = new BasicAllListener_Impl( aPrefixName ); + rtl::Reference<BasicAllListener_Impl> xAllLst = new BasicAllListener_Impl( aPrefixName ); Any aTmp; Reference< XInterface > xLst = createAllListenerAdapter( xInvocationAdapterFactory, xClass, xAllLst, aTmp ); if( !xLst.is() ) @@ -4062,16 +4043,16 @@ void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool) return; SbUnoObject* pUnoObj = new SbUnoObject( aListenerClassName, aTmp ); - p->xSbxObj = pUnoObj; - p->xSbxObj->SetParent( pBasic ); + xAllLst->xSbxObj = pUnoObj; + xAllLst->xSbxObj->SetParent( pBasic ); // #100326 Register listener object to set Parent NULL in Dtor SbxArrayRef xBasicUnoListeners = pBasic->getUnoListeners(); - xBasicUnoListeners->Insert32( pUnoObj, xBasicUnoListeners->Count32() ); + xBasicUnoListeners->Insert(pUnoObj, xBasicUnoListeners->Count()); // return the object - SbxVariableRef refVar = rPar.Get32(0); - refVar->PutObject( p->xSbxObj.get() ); + SbxVariableRef refVar = rPar.Get(0); + refVar->PutObject( xAllLst->xSbxObj.get() ); } @@ -4079,7 +4060,7 @@ void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool) // in the Basic runtime system. void RTL_Impl_GetDefaultContext( SbxArray& rPar ) { - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); Any aContextAny( comphelper::getProcessComponentContext() ); @@ -4093,15 +4074,15 @@ void RTL_Impl_GetDefaultContext( SbxArray& rPar ) void RTL_Impl_CreateUnoValue( SbxArray& rPar ) { // 2 parameters needed - if ( rPar.Count32() != 3 ) + if (rPar.Count() != 3) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } // get the name of the class of the struct - OUString aTypeName = rPar.Get32(1)->GetOUString(); - SbxVariable* pVal = rPar.Get32(2); + OUString aTypeName = rPar.Get(1)->GetOUString(); + SbxVariable* pVal = rPar.Get(2); if( aTypeName == "type" ) { @@ -4132,9 +4113,8 @@ void RTL_Impl_CreateUnoValue( SbxArray& rPar ) bool bSuccess = implGetTypeByName( aValTypeName, aType ); if( bSuccess ) { - Any aTypeAny( aType ); - SbxVariableRef refVar = rPar.Get32(0); - SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aTypeAny ); + SbxVariableRef refVar = rPar.Get(0); + SbxObjectRef xUnoAnyObject = new SbUnoAnyObject(Any(aType)); refVar->PutObject( xUnoAnyObject.get() ); } return; @@ -4150,7 +4130,7 @@ void RTL_Impl_CreateUnoValue( SbxArray& rPar ) catch( const NoSuchElementException& e1 ) { StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, - implGetExceptionMsg( e1, "com.sun.star.container.NoSuchElementException" ) ); + implGetExceptionMsg( e1, u"com.sun.star.container.NoSuchElementException" ) ); return; } Reference< XTypeDescription > xTypeDesc; @@ -4163,7 +4143,7 @@ void RTL_Impl_CreateUnoValue( SbxArray& rPar ) Any aVal = sbxToUnoValueImpl( pVal ); Any aConvertedVal = convertAny( aVal, aDestType ); - SbxVariableRef refVar = rPar.Get32(0); + SbxVariableRef refVar = rPar.Get(0); SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aConvertedVal ); refVar->PutObject( xUnoAnyObject.get() ); } @@ -4172,12 +4152,12 @@ namespace { class ModuleInvocationProxy : public WeakImplHelper< XInvocation, XComponent > { - ::osl::Mutex m_aMutex; + std::mutex m_aMutex; OUString m_aPrefix; SbxObjectRef m_xScopeObj; bool m_bProxyIsClassModuleObject; - ::comphelper::OInterfaceContainerHelper2 m_aListeners; + ::comphelper::OInterfaceContainerHelper4<XEventListener> m_aListeners; public: ModuleInvocationProxy( std::u16string_view aPrefix, SbxObjectRef const & xScopeObj ); @@ -4203,10 +4183,8 @@ public: } ModuleInvocationProxy::ModuleInvocationProxy( std::u16string_view aPrefix, SbxObjectRef const & xScopeObj ) - : m_aMutex() - , m_aPrefix( OUString::Concat(aPrefix) + "_" ) + : m_aPrefix( OUString::Concat(aPrefix) + "_" ) , m_xScopeObj( xScopeObj ) - , m_aListeners( m_aMutex ) { m_bProxyIsClassModuleObject = xScopeObj.is() && dynamic_cast<const SbClassModuleObject*>( xScopeObj.get() ) != nullptr; } @@ -4240,7 +4218,7 @@ void SAL_CALL ModuleInvocationProxy::setValue(const OUString& rProperty, const A SbxArrayRef xArray = new SbxArray; SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); unoToSbxValue( xVar.get(), rValue ); - xArray->Put32( xVar.get(), 1 ); + xArray->Put(xVar.get(), 1); // Call property method SbxVariableRef xValue = new SbxVariable; @@ -4307,17 +4285,13 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const OUString& rFunction, OUString aFunctionName = m_aPrefix + rFunction; - bool bSetRescheduleBack = false; - bool bOldReschedule = true; + bool bOldReschedule = false; SbiInstance* pInst = GetSbData()->pInst; if( pInst && pInst->IsCompatibility() ) { bOldReschedule = pInst->IsReschedule(); if ( bOldReschedule ) - { pInst->EnableReschedule( false ); - bSetRescheduleBack = true; - } } SbxVariable* p = xScopeObj->Find( aFunctionName, SbxClassType::Method ); @@ -4340,7 +4314,7 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const OUString& rFunction, { SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); unoToSbxValue( xVar.get(), pArgs[i] ); - xArray->Put32( xVar.get(), sal::static_int_cast< sal_uInt16 >(i+1) ); + xArray->Put(xVar.get(), sal::static_int_cast<sal_uInt16>(i + 1)); } } @@ -4352,7 +4326,7 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const OUString& rFunction, aRet = sbxToUnoValue( xValue.get() ); pMeth->SetParameters( nullptr ); - if( bSetRescheduleBack ) + if (bOldReschedule) pInst->EnableReschedule( bOldReschedule ); // TODO: OutParameter? @@ -4362,22 +4336,24 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const OUString& rFunction, void SAL_CALL ModuleInvocationProxy::dispose() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); EventObject aEvent( static_cast<XComponent*>(this) ); - m_aListeners.disposeAndClear( aEvent ); + m_aListeners.disposeAndClear( aGuard, aEvent ); m_xScopeObj = nullptr; } void SAL_CALL ModuleInvocationProxy::addEventListener( const Reference< XEventListener >& xListener ) { - m_aListeners.addInterface( xListener ); + std::unique_lock aGuard( m_aMutex ); + m_aListeners.addInterface( aGuard, xListener ); } void SAL_CALL ModuleInvocationProxy::removeEventListener( const Reference< XEventListener >& xListener ) { - m_aListeners.removeInterface( xListener ); + std::unique_lock aGuard( m_aMutex ); + m_aListeners.removeInterface( aGuard, xListener ); } @@ -4393,10 +4369,7 @@ Reference< XInterface > createComListener( const Any& aControlAny, const OUStrin Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPrefix, xScopeObj ); - Sequence<Any> args( 3 ); - args[0] = aControlAny; - args[1] <<= aVBAType; - args[2] <<= xProxy; + Sequence<Any> args{ aControlAny, Any(aVBAType), Any(xProxy) }; try { @@ -4464,7 +4437,7 @@ void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic ) { StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic ); SbxArray* pArray = pItem->m_pRegisteredVariables.get(); - pArray->Put32( pVar, pArray->Count32() ); + pArray->Put(pVar, pArray->Count()); } void disposeComVariablesForBasic( StarBASIC const * pBasic ) @@ -4476,10 +4449,10 @@ void disposeComVariablesForBasic( StarBASIC const * pBasic ) StarBasicDisposeItem* pItem = *it; SbxArray* pArray = pItem->m_pRegisteredVariables.get(); - sal_uInt32 nCount = pArray->Count32(); + sal_uInt32 nCount = pArray->Count(); for( sal_uInt32 i = 0 ; i < nCount ; ++i ) { - SbxVariable* pVar = pArray->Get32( i ); + SbxVariable* pVar = pArray->Get(i); pVar->ClearComListener(); } @@ -4516,10 +4489,10 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP bool bSuccess = false; SbxArray* pModIfaces = pClassData->mxIfaces.get(); - sal_uInt32 nCount = pModIfaces->Count32(); + sal_uInt32 nCount = pModIfaces->Count(); for( sal_uInt32 i = 0 ; i < nCount ; ++i ) { - SbxVariable* pVar = pModIfaces->Get32( i ); + SbxVariable* pVar = pModIfaces->Get(i); const OUString& aIfaceName = pVar->GetName(); if( !aIfaceName.isEmpty() ) @@ -4532,9 +4505,7 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP } Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPureIfaceName, pProxyClassModuleObject ); - Sequence<Any> args( 2 ); - args[0] <<= aIfaceName; - args[1] <<= xProxy; + Sequence<Any> args{ Any(aIfaceName), Any(xProxy) }; Reference< XInterface > xRet; try @@ -4570,7 +4541,7 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP break; } } - } + } return bSuccess; } @@ -4643,7 +4614,7 @@ TypeClass StructRefInfo::getTypeClass() const return maType.getTypeClass(); } -SbUnoStructRefObject::SbUnoStructRefObject( const OUString& aName_, const StructRefInfo& rMemberInfo ) : SbxObject( aName_ ), maMemberInfo( rMemberInfo ), mbMemberCacheInit( false ) +SbUnoStructRefObject::SbUnoStructRefObject( const OUString& aName_, StructRefInfo aMemberInfo ) : SbxObject( aName_ ), maMemberInfo(std::move( aMemberInfo )), mbMemberCacheInit( false ) { SetClassName( maMemberInfo.getTypeName() ); } @@ -4691,7 +4662,8 @@ SbxVariable* SbUnoStructRefObject::Find( const OUString& rName, SbxClassType t ) Property aProp; aProp.Name = rName; aProp.Type = css::uno::Type( it->second->getTypeClass(), it->second->getTypeName() ); - SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, aProp, 0, false, ( aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT) ); + const bool bIsStruct = aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT; + SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, std::move(aProp), 0, false, bIsStruct ); SbxVariableRef xVarRef = pProp; QuickInsert( xVarRef.get() ); pRes = xVarRef.get(); @@ -4729,7 +4701,7 @@ void SbUnoStructRefObject::implCreateDbgProperties() QuickInsert( xVarRef.get() ); // Id == -3: output the Methods - xVarRef = new SbUnoProperty( ID_DBG_METHODS, SbxSTRING, SbxSTRING, aProp, -3, false, false ); + xVarRef = new SbUnoProperty( ID_DBG_METHODS, SbxSTRING, SbxSTRING, std::move(aProp), -3, false, false ); QuickInsert( xVarRef.get() ); } @@ -4751,7 +4723,8 @@ void SbUnoStructRefObject::implCreateAll() Property aProp; aProp.Name = rName; aProp.Type = css::uno::Type( field.second->getTypeClass(), field.second->getTypeName() ); - SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, aProp, 0, false, ( aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT) ); + const bool bIsStruct = aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT; + SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, std::move(aProp), 0, false, bIsStruct ); SbxVariableRef xVarRef = pProp; QuickInsert( xVarRef.get() ); } @@ -4768,15 +4741,13 @@ Any SbUnoStructRefObject::getUnoAny() OUString SbUnoStructRefObject::Impl_DumpProperties() { - OUStringBuffer aRet; - aRet.append("Properties of object "); - aRet.append( getDbgObjectName() ); + OUStringBuffer aRet("Properties of object " + getDbgObjectName() ); - sal_uInt32 nPropCount = pProps->Count32(); + sal_uInt32 nPropCount = pProps->Count(); sal_uInt32 nPropsPerLine = 1 + nPropCount / 30; for( sal_uInt32 i = 0; i < nPropCount; i++ ) { - SbxVariable* pVar = pProps->Get32( i ); + SbxVariable* pVar = pProps->Get(i); if( pVar ) { OUStringBuffer aPropStr; @@ -4803,10 +4774,8 @@ OUString SbUnoStructRefObject::Impl_DumpProperties() } } } - aPropStr.append( Dbg_SbxDataType2String( eType ) ); - - aPropStr.append( " " ); - aPropStr.append( pVar->GetName() ); + aPropStr.append( Dbg_SbxDataType2String( eType ) + + " " + pVar->GetName() ); if( i == nPropCount - 1 ) { @@ -4816,7 +4785,7 @@ OUString SbUnoStructRefObject::Impl_DumpProperties() { aPropStr.append( "; " ); } - aRet.append( aPropStr.makeStringAndClear() ); + aRet.append( aPropStr ); } } return aRet.makeStringAndClear(); @@ -4845,7 +4814,7 @@ void SbUnoStructRefObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) // Id == -1: Display implemented interfaces according the ClassProvider if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES" { - OUString aRet = OUStringLiteral( ID_DBG_SUPPORTEDINTERFACES ) + OUString aRet = OUString::Concat( ID_DBG_SUPPORTEDINTERFACES ) + " not available.\n(TypeClass is not TypeClass_INTERFACE)\n"; pVar->PutString( aRet ); @@ -4927,9 +4896,7 @@ OUString SbUnoStructRefObject::getDbgObjectName() const { aRet.append( "\n" ); } - aRet.append( "\"" ); - aRet.append( aName ); - aRet.append( "\":" ); + aRet.append( "\"" + aName + "\":" ); return aRet.makeStringAndClear(); } |