From 9265b53978e1ed5a61db9941b5661b88d0efd31b Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 29 Oct 2021 09:37:07 +0300 Subject: Prepare for removal of non-const operator[] from Sequence in extensions Change-Id: Id57b187aaa669d4b9a35ab726a6df1a9b4823f1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124364 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- extensions/source/ole/oleobjw.cxx | 14 +++++++++----- extensions/source/ole/unoconversionutilities.hxx | 5 +++-- extensions/source/ole/unoobjw.cxx | 9 +++++---- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'extensions/source/ole') diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index ba33772c171a..85f410c54604 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -1018,7 +1018,9 @@ Any IUnknownWrapper::invokeWithDispIdUnoTlb(const OUString& sFunctionName, if( outParameterCount && pMethod) { OutParamIndex.realloc( outParameterCount); + auto pOutParamIndex = OutParamIndex.getArray(); OutParam.realloc( outParameterCount); + auto pOutParam = OutParam.getArray(); sal_Int32 outIndex=0; int i = 0; try @@ -1027,13 +1029,13 @@ Any IUnknownWrapper::invokeWithDispIdUnoTlb(const OUString& sFunctionName, { if( pMethod->pParams[i].bOut ) { - OutParamIndex[outIndex]= static_cast(i); + pOutParamIndex[outIndex]= static_cast(i); Any outAny; if( !bJScriptObject) { variantToAny( &pVarParamsRef[outIndex], outAny, Type(pMethod->pParams[i].pTypeRef), false); - OutParam[outIndex++]= outAny; + pOutParam[outIndex++]= outAny; } else //JScriptObject { @@ -1047,7 +1049,7 @@ Any IUnknownWrapper::invokeWithDispIdUnoTlb(const OUString& sFunctionName, { variantToAny( &varOut, outAny, Type(pMethod->pParams[parameterCount - 1 - i].pTypeRef), false); - OutParam[outParameterCount - 1 - outIndex++]= outAny; + pOutParam[outParameterCount - 1 - outIndex++]= outAny; } else bConvRet= false; @@ -1985,6 +1987,8 @@ Any IUnknownWrapper::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, // Convert out params if (outParamsCount) { + auto pOutParamIndex = OutParamIndex.getArray(); + auto pOutParam = OutParam.getArray(); int outParamIndex=0; for (int paramIndex = 0; paramIndex < nUnoArgs; paramIndex ++) { @@ -2021,8 +2025,8 @@ Any IUnknownWrapper::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, e.ArgumentIndex = paramIndex; throw; } - OutParam[outParamIndex] = outAny; - OutParamIndex[outParamIndex] = ::sal::static_int_cast< sal_Int16, int >( paramIndex ); + pOutParam[outParamIndex] = outAny; + pOutParamIndex[outParamIndex] = ::sal::static_int_cast< sal_Int16, int >( paramIndex ); outParamIndex++; } OutParam.realloc(outParamIndex); diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx index 338d85b622da..6cf3dc961731 100644 --- a/extensions/source/ole/unoconversionutilities.hxx +++ b/extensions/source/ole/unoconversionutilities.hxx @@ -1280,7 +1280,7 @@ void UnoConversionUtilities::getElementCountAndTypeOfSequence( const Any& rS { sal_Int32 dimCount= (*static_cast(rSeq.getValue()))->nElements; if( dimCount > seqElementCounts[ dim-1]) - seqElementCounts[ dim-1]= dimCount; + seqElementCounts.getArray()[ dim-1]= dimCount; // we need the element type to construct the any that is // passed into getElementCountAndTypeOfSequence again @@ -2331,11 +2331,12 @@ Sequence UnoConversionUtilities::getImplementedInterfaces(IUnknown* pUn if( anyNames >>= seqAny) { seqTypes.realloc( seqAny.getLength()); + auto pseqTypes = seqTypes.getArray(); for( sal_Int32 i=0; i < seqAny.getLength(); i++) { OUString typeName; seqAny[i] >>= typeName; - seqTypes[i]= Type( TypeClass_INTERFACE, typeName); + pseqTypes[i]= Type( TypeClass_INTERFACE, typeName); } } } diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index 81fbae1a0aca..034d7cec62a1 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -2326,6 +2326,7 @@ Sink::Call( const OUString& Method, Sequence< Any >& Arguments ) aMethods.getLength() > 0); int nMemId = 1; + auto ArgumentsRange = asNonConstRange(Arguments); // Skip the three XInterface methods for (int i = 3; i < aMethods.getLength(); i++) { @@ -2419,21 +2420,21 @@ Sink::Call( const OUString& Method, Sequence< Any >& Arguments ) case VT_BYREF|VT_I2: { SHORT *pI = static_cast(aDispParams.rgvarg[j].byref); - Arguments[nIncomingArgIndex] <<= static_cast(*pI); + ArgumentsRange[nIncomingArgIndex] <<= static_cast(*pI); delete pI; } break; case VT_BYREF|VT_I4: { LONG *pL = static_cast(aDispParams.rgvarg[j].byref); - Arguments[nIncomingArgIndex] <<= static_cast(*pL); + ArgumentsRange[nIncomingArgIndex] <<= static_cast(*pL); delete pL; } break; case VT_BYREF|VT_BSTR: { BSTR *pBstr = static_cast(aDispParams.rgvarg[j].byref); - Arguments[nIncomingArgIndex] <<= OUString(o3tl::toU(*pBstr)); + ArgumentsRange[nIncomingArgIndex] <<= OUString(o3tl::toU(*pBstr)); // Undo SysAllocString() done in anyToVariant() SysFreeString(*pBstr); delete pBstr; @@ -2443,7 +2444,7 @@ Sink::Call( const OUString& Method, Sequence< Any >& Arguments ) { VARIANT_BOOL *pBool = static_cast(aDispParams.rgvarg[j].byref); // SAL_ DEBUG("===> VT_BOOL: byref is now " << aDispParams.rgvarg[j].byref << ", " << (int)*pBool); - Arguments[nIncomingArgIndex] <<= (*pBool != VARIANT_FALSE); + ArgumentsRange[nIncomingArgIndex] <<= (*pBool != VARIANT_FALSE); delete pBool; } break; -- cgit