[Libreoffice-commits] core.git: extensions/source
Stephan Bergmann
sbergman at redhat.com
Sun Oct 1 06:57:47 UTC 2017
extensions/source/ole/oleobjw.cxx | 130 ++++++++++-------------
extensions/source/ole/unoconversionutilities.hxx | 21 +--
2 files changed, 69 insertions(+), 82 deletions(-)
New commits:
commit 3e9f0d6f6e99b064bf140212b33a8b6ebce91101
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Sat Sep 30 22:45:16 2017 +0200
loplugin:flatten (clang-cl, extensions)
Change-Id: I2aceee910e8e39a7c4ebb89282447dc4b26ad3cb
Reviewed-on: https://gerrit.libreoffice.org/42978
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx
index ccb4004eabf5..3caab88a4765 100644
--- a/extensions/source/ole/oleobjw.cxx
+++ b/extensions/source/ole/oleobjw.cxx
@@ -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!");
}
}
}
diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index 56ab58a1e9e8..5b5612c42a1b 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -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
More information about the Libreoffice-commits
mailing list