Kaydet (Commit) 3e9f0d6f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:flatten (clang-cl, extensions)

Change-Id: I2aceee910e8e39a7c4ebb89282447dc4b26ad3cb
Reviewed-on: https://gerrit.libreoffice.org/42978Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 0a478850
......@@ -933,30 +933,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdUnoTlb(const OUString& sFunctionName,
else if( pMethod->pParams[i].bOut )
{
CComObject<JScriptOutParam>* pParamObject;
if( SUCCEEDED( CComObject<JScriptOutParam>::CreateInstance( &pParamObject)))
{
CComPtr<IUnknown> pUnk(pParamObject->GetUnknown());
CComQIPtr<IDispatch> pDisp( pUnk);
pVarParams[ parameterCount - i -1].vt= VT_DISPATCH;
pVarParams[ parameterCount - i -1].pdispVal= pDisp;
pVarParams[ parameterCount - i -1].pdispVal->AddRef();
// if the param is in/out then put the parameter on index 0
if( pMethod->pParams[i].bIn ) // in / out
{
CComVariant varParam;
anyToVariant( &varParam, Params.getConstArray()[i]);
CComDispatchDriver dispDriver( pDisp);
if(FAILED( dispDriver.PutPropertyByName( L"0", &varParam)))
throw BridgeRuntimeError(
"[automation bridge]IUnknownWrapper_Impl::"
"invokeWithDispIdUnoTlb\n"
"Could not set property \"0\" for the in/out "
"param!");
}
}
else
if( !SUCCEEDED( CComObject<JScriptOutParam>::CreateInstance( &pParamObject)))
{
throw BridgeRuntimeError(
"[automation bridge]IUnknownWrapper_Impl::"
......@@ -965,6 +942,26 @@ Any IUnknownWrapper_Impl::invokeWithDispIdUnoTlb(const OUString& sFunctionName,
OUString::number((sal_Int32) i));
}
CComPtr<IUnknown> pUnk(pParamObject->GetUnknown());
CComQIPtr<IDispatch> pDisp( pUnk);
pVarParams[ parameterCount - i -1].vt= VT_DISPATCH;
pVarParams[ parameterCount - i -1].pdispVal= pDisp;
pVarParams[ parameterCount - i -1].pdispVal->AddRef();
// if the param is in/out then put the parameter on index 0
if( pMethod->pParams[i].bIn ) // in / out
{
CComVariant varParam;
anyToVariant( &varParam, Params.getConstArray()[i]);
CComDispatchDriver dispDriver( pDisp);
if(FAILED( dispDriver.PutPropertyByName( L"0", &varParam)))
throw BridgeRuntimeError(
"[automation bridge]IUnknownWrapper_Impl::"
"invokeWithDispIdUnoTlb\n"
"Could not set property \"0\" for the in/out "
"param!");
}
}
}
}
......@@ -2211,21 +2208,18 @@ void IUnknownWrapper_Impl::getFuncDesc(const OUString & sFuncName, FUNCDESC ** p
{
ITypeInfo* pType= getTypeInfo();
FUNCDESC * pDesc = nullptr;
if (SUCCEEDED(pType->GetFuncDesc(itIndex->second, & pDesc)))
if (!SUCCEEDED(pType->GetFuncDesc(itIndex->second, & pDesc)))
{
if (pDesc->invkind == INVOKE_FUNC)
{
(*pFuncDesc) = pDesc;
}
else
{
pType->ReleaseFuncDesc(pDesc);
}
throw BridgeRuntimeError("[automation bridge] Could not get "
"FUNCDESC for " + sFuncName);
}
if (pDesc->invkind == INVOKE_FUNC)
{
(*pFuncDesc) = pDesc;
}
else
{
throw BridgeRuntimeError("[automation bridge] Could not get "
"FUNCDESC for " + sFuncName);
pType->ReleaseFuncDesc(pDesc);
}
}
//else no entry found for sFuncName, pFuncDesc will not be filled in
......@@ -2464,49 +2458,43 @@ ITypeInfo* IUnknownWrapper_Impl::getTypeInfo()
if( ! m_spTypeInfo)
{
CComPtr< ITypeInfo > spType;
if( SUCCEEDED( m_spDispatch->GetTypeInfo( 0, LOCALE_USER_DEFAULT, &spType.p)))
if( !SUCCEEDED( m_spDispatch->GetTypeInfo( 0, LOCALE_USER_DEFAULT, &spType.p)))
{
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
throw BridgeRuntimeError("[automation bridge]The dispatch object does not "
"support ITypeInfo!");
}
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
//If this is a dual interface then TYPEATTR::typekind is usually TKIND_INTERFACE
//We need to get the type description for TKIND_DISPATCH
TypeAttr typeAttr(spType.p);
if( SUCCEEDED(spType->GetTypeAttr( &typeAttr)))
//If this is a dual interface then TYPEATTR::typekind is usually TKIND_INTERFACE
//We need to get the type description for TKIND_DISPATCH
TypeAttr typeAttr(spType.p);
if( SUCCEEDED(spType->GetTypeAttr( &typeAttr)))
{
if (typeAttr->typekind == TKIND_INTERFACE &&
typeAttr->wTypeFlags & TYPEFLAG_FDUAL)
{
if (typeAttr->typekind == TKIND_INTERFACE &&
typeAttr->wTypeFlags & TYPEFLAG_FDUAL)
{
HREFTYPE refDispatch;
if (SUCCEEDED(spType->GetRefTypeOfImplType(::sal::static_int_cast< UINT, int >( -1 ), &refDispatch)))
{
CComPtr<ITypeInfo> spTypeDisp;
if (SUCCEEDED(spType->GetRefTypeInfo(refDispatch, & spTypeDisp)))
m_spTypeInfo= spTypeDisp;
}
else
{
throw BridgeRuntimeError(
"[automation bridge] Could not obtain type information "
"for dispatch interface." );
}
}
else if (typeAttr->typekind == TKIND_DISPATCH)
{
m_spTypeInfo= spType;
}
else
HREFTYPE refDispatch;
if (!SUCCEEDED(spType->GetRefTypeOfImplType(::sal::static_int_cast< UINT, int >( -1 ), &refDispatch)))
{
throw BridgeRuntimeError(
"[automation bridge] Automation object does not "
"provide type information.");
"[automation bridge] Could not obtain type information "
"for dispatch interface." );
}
CComPtr<ITypeInfo> spTypeDisp;
if (SUCCEEDED(spType->GetRefTypeInfo(refDispatch, & spTypeDisp)))
m_spTypeInfo= spTypeDisp;
}
else if (typeAttr->typekind == TKIND_DISPATCH)
{
m_spTypeInfo= spType;
}
else
{
throw BridgeRuntimeError(
"[automation bridge] Automation object does not "
"provide type information.");
}
}
else
{
throw BridgeRuntimeError("[automation bridge]The dispatch object does not "
"support ITypeInfo!");
}
}
}
......
......@@ -1836,22 +1836,21 @@ Reference<XInterface> UnoConversionUtilities<T>::createAdapter(const Sequence<Ty
if( xAdapterFac.is())
xIntAdapted= xAdapterFac->createAdapter( xInv, seqTypes);
if( xIntAdapted.is())
{
// Put the pointer to the wrapper object and the interface pointer of the adapted interface
// in a global map. Thus we can determine in a call to createUnoObjectWrapper whether the UNO
// object is a wrapped COM object. In that case we extract the original COM object rather than
// creating a wrapper around the UNO object.
typedef std::unordered_map<sal_uInt64,sal_uInt64>::value_type VALUE;
AdapterToWrapperMap.insert( VALUE( reinterpret_cast<sal_uInt64>(xIntAdapted.get()), reinterpret_cast<sal_uInt64>(receiver.get())));
WrapperToAdapterMap.insert( VALUE( reinterpret_cast<sal_uInt64>(receiver.get()), reinterpret_cast<sal_uInt64>(xIntAdapted.get())));
}
else
if( !xIntAdapted.is())
{
throw BridgeRuntimeError(
"[automation bridge]UnoConversionUtilities<T>::createOleObjectWrapper \n"
"Could not create a proxy for COM object! Creation of adapter failed.");
}
// Put the pointer to the wrapper object and the interface pointer of the adapted interface
// in a global map. Thus we can determine in a call to createUnoObjectWrapper whether the UNO
// object is a wrapped COM object. In that case we extract the original COM object rather than
// creating a wrapper around the UNO object.
typedef std::unordered_map<sal_uInt64,sal_uInt64>::value_type VALUE;
AdapterToWrapperMap.insert( VALUE( reinterpret_cast<sal_uInt64>(xIntAdapted.get()), reinterpret_cast<sal_uInt64>(receiver.get())));
WrapperToAdapterMap.insert( VALUE( reinterpret_cast<sal_uInt64>(receiver.get()), reinterpret_cast<sal_uInt64>(xIntAdapted.get())));
return xIntAdapted;
}
// "convertValueObject" converts a JScriptValue object contained in "var" into
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment