30#include <unordered_map>
33#if defined _MSC_VER && defined __clang__
34#pragma clang diagnostic push
35#pragma clang diagnostic ignored "-Wall"
36#pragma clang diagnostic ignored "-Wattributes"
37#pragma clang diagnostic ignored "-Wdelete-incomplete"
38#pragma clang diagnostic ignored "-Wdynamic-class-memaccess"
39#pragma clang diagnostic ignored "-Wextra"
40#pragma clang diagnostic ignored "-Wint-to-pointer-cast"
41#pragma clang diagnostic ignored "-Winvalid-noreturn"
42#pragma clang diagnostic ignored "-Wmicrosoft"
43#pragma clang diagnostic ignored "-Wnon-pod-varargs"
44#pragma clang diagnostic ignored "-Wnonportable-include-path"
45#pragma clang diagnostic ignored "-Wsequence-point"
46#pragma clang diagnostic ignored "-Wtypename-missing"
50#if defined _MSC_VER && defined __clang__
51#pragma clang diagnostic pop
55#include <osl/diagnose.h>
58#include <rtl/ustring.hxx>
60#include <com/sun/star/beans/MethodConcept.hpp>
61#include <com/sun/star/beans/PropertyConcept.hpp>
62#include <com/sun/star/lang/NoSuchMethodException.hpp>
63#include <com/sun/star/script/CannotConvertException.hpp>
64#include <com/sun/star/script/FailReason.hpp>
65#include <com/sun/star/reflection/theCoreReflection.hpp>
66#include <com/sun/star/reflection/ParamInfo.hpp>
67#include <com/sun/star/beans/XExactName.hpp>
68#include <com/sun/star/container/NoSuchElementException.hpp>
69#include <com/sun/star/container/XEnumeration.hpp>
70#include <com/sun/star/container/XEnumerationAccess.hpp>
72#include <com/sun/star/beans/XMaterialHolder.hpp>
73#include <com/sun/star/script/XInvocation2.hpp>
74#include <com/sun/star/script/MemberType.hpp>
75#include <com/sun/star/reflection/XIdlReflection.hpp>
76#include <ooo/vba/XCollection.hpp>
77#include <ooo/vba/XConnectable.hpp>
78#include <ooo/vba/XConnectionPoint.hpp>
79#include <ooo/vba/XSink.hpp>
80#include <ooo/vba/msforms/XCheckBox.hpp>
81#include <osl/interlck.h>
82#include <com/sun/star/uno/genfunc.h>
105using namespace com::sun::star::bridge::ModelDependent;
118 if (pInfo !=
nullptr)
121 pInfo->bstrSource = SysAllocString(L
"[automation bridge] ");
122 pInfo->bstrDescription = SysAllocString(o3tl::toW(message.getStr()));
129 m_defaultValueType( 0)
146 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::QueryInterface(" << riid <<
")");
153 if(IsEqualIID(riid, IID_IUnknown))
156 *ppv =
static_cast<IUnknown*
>(
static_cast<IDispatch*
>(
this));
157 SAL_INFO(
"extensions.olebridge",
" " << *ppv);
159 else if (IsEqualIID(riid, IID_IDispatch))
162 *ppv =
static_cast<IDispatch*
>(
this);
163 SAL_INFO(
"extensions.olebridge",
" " << *ppv);
165 else if (IsEqualIID(riid, IID_IProvideClassInfo))
168 if (!xConnectable.is())
169 return E_NOINTERFACE;
171 *ppv =
static_cast<IProvideClassInfo*
>(
this);
172 SAL_INFO(
"extensions.olebridge",
" " << *ppv);
174 else if (IsEqualIID(riid, IID_IConnectionPointContainer))
177 if (!xConnectable.is())
178 return E_NOINTERFACE;
180 *ppv =
static_cast<IConnectionPointContainer*
>(
this);
181 SAL_INFO(
"extensions.olebridge",
" " << *ppv);
183 else if( IsEqualIID( riid, __uuidof( IUnoObjectWrapper)))
186 *ppv=
static_cast<IUnoObjectWrapper*
>(
this);
187 SAL_INFO(
"extensions.olebridge",
" " << *ppv);
202COM_DECLSPEC_NOTHROW
STDMETHODIMP_(ULONG) InterfaceOleWrapper::Release()
212 pXInt->set(
static_cast<XWeak*
>(
this), UNO_QUERY);
213 return pXInt->is() ? S_OK : E_FAIL;
230 Any any = xMatHolder->getMaterial();
231 if(
any.getValueTypeClass() == TypeClass_STRUCT)
243 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::GetTypeInfoCount");
255class CXTypeInfo :
public ITypeInfo,
256 public CComObjectRoot
259 enum class Kind { COCLASS, MAIN, OUTGOING };
262#pragma clang diagnostic push
263#pragma clang diagnostic ignored "-Wunused-function"
265 BEGIN_COM_MAP(CXTypeInfo)
267#pragma clang diagnostic pop
269 COM_INTERFACE_ENTRY(ITypeInfo)
271#pragma clang diagnostic push
272#pragma clang diagnostic ignored "-Winconsistent-missing-override"
273#pragma clang diagnostic ignored "-Wunused-function"
277#pragma clang diagnostic pop
280 DECLARE_NOT_AGGREGATABLE(CXTypeInfo)
282 virtual ~CXTypeInfo() {}
285 const OUString& sImplementationName,
289 const OUString& sImplementationName,
293 const OUString& sInterfaceName,
297 virtual HRESULT STDMETHODCALLTYPE GetTypeAttr(TYPEATTR **ppTypeAttr)
override;
298 virtual HRESULT STDMETHODCALLTYPE GetTypeComp(ITypeComp **ppTComp)
override;
299 virtual HRESULT STDMETHODCALLTYPE GetFuncDesc(UINT index,
300 FUNCDESC **ppFuncDesc)
override;
301 virtual HRESULT STDMETHODCALLTYPE GetVarDesc(UINT index,
302 VARDESC **ppVarDesc)
override;
303 virtual HRESULT STDMETHODCALLTYPE GetNames(MEMBERID memid,
306 UINT *pcNames)
override;
307 virtual HRESULT STDMETHODCALLTYPE GetRefTypeOfImplType(UINT index,
308 HREFTYPE *pRefType)
override;
309 virtual HRESULT STDMETHODCALLTYPE GetImplTypeFlags(UINT index,
310 INT *pImplTypeFlags)
override;
311 virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(LPOLESTR *rgszNames,
313 MEMBERID *pMemId)
override;
314 virtual HRESULT STDMETHODCALLTYPE Invoke(PVOID pvInstance,
317 DISPPARAMS *pDispParams,
319 EXCEPINFO *pExcepInfo,
320 UINT *puArgErr)
override;
321 virtual HRESULT STDMETHODCALLTYPE GetDocumentation(MEMBERID memid,
323 BSTR *pBstrDocString,
324 DWORD *pdwHelpContext,
325 BSTR *pBstrHelpFile)
override;
326 virtual HRESULT STDMETHODCALLTYPE GetDllEntry(MEMBERID memid,
330 WORD *pwOrdinal)
override;
331 virtual HRESULT STDMETHODCALLTYPE GetRefTypeInfo(HREFTYPE hRefType,
332 ITypeInfo **ppTInfo)
override;
333 virtual HRESULT STDMETHODCALLTYPE AddressOfMember(MEMBERID memid,
335 PVOID *ppv)
override;
336 virtual HRESULT STDMETHODCALLTYPE
CreateInstance(IUnknown *pUnkOuter,
338 PVOID *ppvObj)
override;
339 virtual HRESULT STDMETHODCALLTYPE GetMops(MEMBERID memid,
340 BSTR *pBstrMops)
override;
341 virtual HRESULT STDMETHODCALLTYPE GetContainingTypeLib(ITypeLib **ppTLib,
342 UINT *pIndex)
override;
343 virtual void STDMETHODCALLTYPE ReleaseTypeAttr(TYPEATTR *pTypeAttr)
override;
344 virtual void STDMETHODCALLTYPE ReleaseFuncDesc(FUNCDESC *pFuncDesc)
override;
345 virtual void STDMETHODCALLTYPE ReleaseVarDesc(VARDESC *pVarDesc)
override;
350 OUString msImplementationName;
351 OUString msInterfaceName;
357class CXTypeLib :
public ITypeLib,
358 public CComObjectRoot
362#pragma clang diagnostic push
363#pragma clang diagnostic ignored "-Wunused-function"
365 BEGIN_COM_MAP(CXTypeLib)
367#pragma clang diagnostic pop
369 COM_INTERFACE_ENTRY(ITypeLib)
371#pragma clang diagnostic push
372#pragma clang diagnostic ignored "-Winconsistent-missing-override"
373#pragma clang diagnostic ignored "-Wunused-function"
377#pragma clang diagnostic pop
380 DECLARE_NOT_AGGREGATABLE(CXTypeLib)
382 virtual ~CXTypeLib() {}
385 const OUString& sImplementationName,
388 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeLib::Init for " << sImplementationName);
394 virtual UINT STDMETHODCALLTYPE GetTypeInfoCount()
override
396 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib::GetTypeInfoCount");
400 virtual HRESULT STDMETHODCALLTYPE
GetTypeInfo(UINT,
401 ITypeInfo **)
override
403 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib::GetTypeInfo: E_NOTIMPL");
407 virtual HRESULT STDMETHODCALLTYPE GetTypeInfoType(UINT,
410 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib::GetTypeInfoType: E_NOTIMPL");
414 virtual HRESULT STDMETHODCALLTYPE GetTypeInfoOfGuid(REFGUID guid,
415 ITypeInfo **ppTInfo)
override
419 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeLib::GetTypeInfoOfGuid(" << guid <<
")");
424 if (!xConnectable.is())
425 return TYPE_E_ELEMENTNOTFOUND;
428 if (SUCCEEDED(IIDFromString(
reinterpret_cast<LPOLESTR
>(xConnectable->getIID().pData->buffer), &aIID)))
430 if (IsEqualIID(guid, aIID))
434 CComObject<CXTypeInfo>* pTypeInfo;
436 ret = CComObject<CXTypeInfo>::CreateInstance(&pTypeInfo);
442 pTypeInfo->InitForCoclass(mxOrigin, msImplementationName, aIID, mxMSF);
444 *ppTInfo = pTypeInfo;
451 ooo::vba::TypeAndIID aTypeAndIID = xConnectable->GetConnectionPoint();
454 if (SUCCEEDED(IIDFromString((LPOLESTR)aTypeAndIID.IID.pData->buffer, &aIID)))
458 CComObject<CXTypeInfo>* pTypeInfo;
460 ret = CComObject<CXTypeInfo>::CreateInstance(&pTypeInfo);
466 pTypeInfo->InitForOutgoing(mxOrigin, msImplementationName, aIID, mxMSF);
468 *ppTInfo = pTypeInfo;
473 SAL_WARN(
"extensions.olebridge",
"Not implemented: GetTypeInfoOfGuid(" << guid <<
")");
476 return TYPE_E_ELEMENTNOTFOUND;
480 virtual HRESULT STDMETHODCALLTYPE GetLibAttr(TLIBATTR **)
override
482 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib::GetLibAttr: E_NOTIMPL");
486 virtual HRESULT STDMETHODCALLTYPE GetTypeComp(ITypeComp **)
override
488 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib::GetTypeComp: E_NOTIMPL");
492 virtual HRESULT STDMETHODCALLTYPE GetDocumentation(INT,
498 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib::GetDocumentation: E_NOTIMPL");
502 virtual HRESULT STDMETHODCALLTYPE IsName(LPOLESTR,
506 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib:IsName: E_NOTIMPL");
510 virtual HRESULT STDMETHODCALLTYPE FindName(LPOLESTR,
516 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib::FindName: E_NOTIMPL");
520 virtual void STDMETHODCALLTYPE ReleaseTLibAttr(TLIBATTR *)
override
522 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeLib::ReleaseTLibAttr: E_NOTIMPL");
527 OUString msImplementationName;
534 const OUString& sImplementationName,
538 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::InitForCoclass(" << sImplementationName <<
"," << rIID <<
")");
539 meKind = Kind::COCLASS;
547 const OUString& sImplementationName,
551 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::InitForClassItself(" << sImplementationName <<
"," << rIID <<
")");
560 const OUString& sInterfaceName,
565 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::InitForOutgoing(" << sInterfaceName <<
"," << rIID <<
")");
566 meKind = Kind::OUTGOING;
568 msInterfaceName = sInterfaceName;
574HRESULT STDMETHODCALLTYPE CXTypeInfo::GetTypeAttr(TYPEATTR **ppTypeAttr)
578 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetTypeAttr");
583 assert(!IsEqualIID(maIID, IID_NULL));
585 TYPEATTR *pTypeAttr =
new TYPEATTR;
586 memset(pTypeAttr, 0,
sizeof(*pTypeAttr));
588 pTypeAttr->guid = maIID;
590 if (meKind == Kind::COCLASS)
592 pTypeAttr->typekind = TKIND_COCLASS;
593 pTypeAttr->cFuncs = 0;
594 pTypeAttr->cVars = 0;
595 pTypeAttr->cImplTypes = 3;
596 pTypeAttr->cbSizeVft = 0;
597 pTypeAttr->cbAlignment = 8;
598 pTypeAttr->wTypeFlags = TYPEFLAG_FCANCREATE;
600 else if (meKind == Kind::MAIN)
602 pTypeAttr->typekind = TKIND_DISPATCH;
603 pTypeAttr->cFuncs = 10;
604 pTypeAttr->cVars = 0;
605 pTypeAttr->cImplTypes = 1;
608 pTypeAttr->cbSizeVft = 7 *
sizeof(
void*);
609 pTypeAttr->cbAlignment = 8;
610 pTypeAttr->wTypeFlags = TYPEFLAG_FHIDDEN|TYPEFLAG_FDISPATCHABLE;
612 else if (meKind == Kind::OUTGOING)
614 pTypeAttr->typekind = TKIND_DISPATCH;
622 auto aMethods = xClass->getMethods();
623 assert(xClass->getTypeClass() == TypeClass_INTERFACE &&
628 pTypeAttr->cFuncs =
aMethods.getLength() - 3 + 3 + 4;
629 pTypeAttr->cVars = 0;
630 pTypeAttr->cImplTypes = 1;
633 pTypeAttr->cbSizeVft = 7 *
sizeof(
void*);
634 pTypeAttr->cbAlignment = 8;
635 pTypeAttr->wTypeFlags = TYPEFLAG_FHIDDEN|TYPEFLAG_FNONEXTENSIBLE|TYPEFLAG_FDISPATCHABLE;
640 pTypeAttr->lcid = LOCALE_USER_DEFAULT;
641 pTypeAttr->memidConstructor = MEMBERID_NIL;
642 pTypeAttr->memidDestructor = MEMBERID_NIL;
644 pTypeAttr->cbSizeInstance =
sizeof(
void*);
645 pTypeAttr->wMajorVerNum = 0;
646 pTypeAttr->wMinorVerNum = 0;
647 pTypeAttr->idldescType.wIDLFlags = IDLFLAG_NONE;
649 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetTypeAttr: " << pTypeAttr);
651 *ppTypeAttr = pTypeAttr;
656HRESULT STDMETHODCALLTYPE CXTypeInfo::GetTypeComp(ITypeComp **)
658 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetTypeComp: E_NOTIMPL");
662HRESULT STDMETHODCALLTYPE CXTypeInfo::GetFuncDesc(UINT index,
663 FUNCDESC **ppFuncDesc)
670 if (meKind != Kind::OUTGOING)
675 *ppFuncDesc =
new FUNCDESC;
676 (*ppFuncDesc)->memid = 0x60000000 +
index;
677 (*ppFuncDesc)->lprgscode =
nullptr;
678 (*ppFuncDesc)->lprgelemdescParam =
nullptr;
679 (*ppFuncDesc)->funckind = FUNC_DISPATCH;
680 (*ppFuncDesc)->invkind = INVOKE_FUNC;
681 (*ppFuncDesc)->callconv = CC_STDCALL;
685 (*ppFuncDesc)->cParams = 2;
686 (*ppFuncDesc)->elemdescFunc.tdesc.lptdesc =
nullptr;
687 (*ppFuncDesc)->elemdescFunc.tdesc.vt = VT_VOID;
690 (*ppFuncDesc)->cParams = 0;
691 (*ppFuncDesc)->elemdescFunc.tdesc.lptdesc =
nullptr;
692 (*ppFuncDesc)->elemdescFunc.tdesc.vt =
VT_UI4;
695 (*ppFuncDesc)->cParams = 1;
696 (*ppFuncDesc)->elemdescFunc.tdesc.lptdesc =
nullptr;
697 (*ppFuncDesc)->elemdescFunc.tdesc.vt =
VT_UI4;
700 (*ppFuncDesc)->cParams = 1;
701 (*ppFuncDesc)->elemdescFunc.tdesc.lptdesc =
nullptr;
702 (*ppFuncDesc)->elemdescFunc.tdesc.vt = VT_VOID;
705 (*ppFuncDesc)->cParams = 3;
706 (*ppFuncDesc)->elemdescFunc.tdesc.lptdesc =
nullptr;
707 (*ppFuncDesc)->elemdescFunc.tdesc.vt = VT_VOID;
710 (*ppFuncDesc)->cParams = 5;
711 (*ppFuncDesc)->elemdescFunc.tdesc.lptdesc =
nullptr;
712 (*ppFuncDesc)->elemdescFunc.tdesc.vt = VT_VOID;
715 (*ppFuncDesc)->cParams = 8;
716 (*ppFuncDesc)->elemdescFunc.tdesc.lptdesc =
nullptr;
717 (*ppFuncDesc)->elemdescFunc.tdesc.vt = VT_VOID;
720 (*ppFuncDesc)->cParamsOpt = 0;
721 (*ppFuncDesc)->oVft =
index *
sizeof(
void*);
722 (*ppFuncDesc)->cScodes = 0;
723 (*ppFuncDesc)->wFuncFlags = FUNCFLAG_FRESTRICTED;
725 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetFuncDesc(" << index <<
"): S_OK: " << *ppFuncDesc);
736 auto aMethods = xClass->getMethods();
737 assert(xClass->getTypeClass() == TypeClass_INTERFACE &&
743 *ppFuncDesc =
new FUNCDESC;
745 (*ppFuncDesc)->memid =
index - 6;
746 (*ppFuncDesc)->lprgscode =
nullptr;
747 (*ppFuncDesc)->lprgelemdescParam =
nullptr;
748 (*ppFuncDesc)->funckind = FUNC_DISPATCH;
749 (*ppFuncDesc)->invkind = INVOKE_FUNC;
750 (*ppFuncDesc)->callconv = CC_STDCALL;
751 (*ppFuncDesc)->cParams =
aMethods[
index - 4]->getParameterInfos().getLength();
752 (*ppFuncDesc)->cParamsOpt = 0;
753 (*ppFuncDesc)->oVft =
index *
sizeof(
void*);
754 (*ppFuncDesc)->cScodes = 0;
755 (*ppFuncDesc)->elemdescFunc.tdesc.lptdesc =
nullptr;
756 (*ppFuncDesc)->elemdescFunc.tdesc.vt = VT_VOID;
757 (*ppFuncDesc)->wFuncFlags = 0;
759 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetFuncDesc(" << index <<
"): S_OK: " << *ppFuncDesc);
764HRESULT STDMETHODCALLTYPE CXTypeInfo::GetVarDesc(UINT,
767 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetVarDesc: E_NOTIMPL");
771HRESULT STDMETHODCALLTYPE CXTypeInfo::GetNames(MEMBERID memid,
778 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetNames(" << memid <<
")");
779 assert(meKind != Kind::COCLASS);
793 if (meKind == Kind::MAIN)
795 SAL_WARN(
"extensions.olebridge",
"GetNames() for MAIN not implemented");
805 auto aMethods = xClass->getMethods();
806 assert(xClass->getTypeClass() == TypeClass_INTERFACE &&
810 if (memid >
aMethods.getLength() - 3)
813 SAL_INFO(
"extensions.olebridge",
"..." <<
this <<
"@CXTypeInfo::GetNames(" << memid <<
"): " << aMethods[memid + 2]->getName());
814 rgBstrNames[0] = SysAllocString(
reinterpret_cast<LPOLESTR
>(aMethods[memid + 2]->getName().
pData->buffer));
820HRESULT STDMETHODCALLTYPE CXTypeInfo::GetRefTypeOfImplType(UINT index,
823 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetRefTypeOfImplType(" << index <<
")");
828 assert(index == 0 || index == 1);
830 *pRefType = 1000+
index;
835HRESULT STDMETHODCALLTYPE CXTypeInfo::GetImplTypeFlags(UINT index,
840 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetImplTypeFlags(" << index <<
")");
845 assert(meKind == Kind::COCLASS);
846 assert(index == 0 || index == 1);
849 *pImplTypeFlags = IMPLTYPEFLAG_FDEFAULT;
851 *pImplTypeFlags = IMPLTYPEFLAG_FDEFAULT|IMPLTYPEFLAG_FSOURCE;
856HRESULT STDMETHODCALLTYPE CXTypeInfo::GetIDsOfNames(LPOLESTR *,
860 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetIDsOfNames: E_NOTIMPL");
864HRESULT STDMETHODCALLTYPE CXTypeInfo::Invoke(PVOID,
872 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::Invoke: E_NOTIMPL");
876HRESULT STDMETHODCALLTYPE CXTypeInfo::GetDocumentation(MEMBERID memid,
878 BSTR *pBstrDocString,
879 DWORD *pdwHelpContext,
884 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetDocumentation(" << memid <<
")");
888 if (memid == MEMBERID_NIL)
890 *pBstrName = SysAllocString(o3tl::toW(msImplementationName.getStr()));
892 else if (memid == DISPID_VALUE)
895 *pBstrName = SysAllocString(L
"Value");
900 *pBstrName = SysAllocString(o3tl::toW(OUString(
"UnknownNameOfMember#" + OUString::number(memid)).getStr()));
904 *pBstrDocString = SysAllocString(L
"");
908 *pBstrHelpFile =
nullptr;
913HRESULT STDMETHODCALLTYPE CXTypeInfo::GetDllEntry(MEMBERID,
919 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetDllEntry: E_NOTIMPL");
923HRESULT STDMETHODCALLTYPE CXTypeInfo::GetRefTypeInfo(HREFTYPE hRefType,
928 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetRefTypeInfo(" << hRefType <<
")");
937 if (!xConnectable.is())
940 ooo::vba::TypeAndIID aTypeAndIID = xConnectable->GetConnectionPoint();
943 if (!SUCCEEDED(IIDFromString(
reinterpret_cast<LPOLESTR
>(aTypeAndIID.IID.pData->buffer), &aIID)))
948 CComObject<CXTypeInfo>* pTypeInfo;
950 ret = CComObject<CXTypeInfo>::CreateInstance(&pTypeInfo);
956 pTypeInfo->InitForOutgoing(mxOrigin, aTypeAndIID.Type.getTypeName(), aIID, mxMSF, aTypeAndIID.Type);
958 *ppTInfo = pTypeInfo;
963HRESULT STDMETHODCALLTYPE CXTypeInfo::AddressOfMember(MEMBERID,
967 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::AddressOfMember: E_NOTIMPL");
971HRESULT STDMETHODCALLTYPE CXTypeInfo::CreateInstance(IUnknown *,
975 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::CreateInstance: E_NOTIMPL");
979HRESULT STDMETHODCALLTYPE CXTypeInfo::GetMops(MEMBERID,
982 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetMops: E_NOTIMPL");
989HRESULT STDMETHODCALLTYPE CXTypeInfo::GetContainingTypeLib(ITypeLib **ppTLib,
994 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::GetContainingTypeLib");
996 if (!ppTLib || !pIndex)
1001 CComObject<CXTypeLib>* pTypeLib;
1003 ret = CComObject<CXTypeLib>::CreateInstance(&pTypeLib);
1009 pTypeLib->Init(mxOrigin, msImplementationName, mxMSF);
1016void STDMETHODCALLTYPE CXTypeInfo::ReleaseTypeAttr(TYPEATTR *pTypeAttr)
1018 SAL_INFO(
"extensions.olebridge",
this <<
"@CXTypeInfo::ReleaseTypeAttr(" << pTypeAttr <<
")");
1023void STDMETHODCALLTYPE CXTypeInfo::ReleaseFuncDesc(FUNCDESC *pFuncDesc)
1025 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::ReleaseFuncDesc(" << pFuncDesc <<
")");
1030void STDMETHODCALLTYPE CXTypeInfo::ReleaseVarDesc(VARDESC *)
1032 SAL_WARN(
"extensions.olebridge",
this <<
"@CXTypeInfo::ReleaseVarDesc: E_NOTIMPL");
1039 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::GetTypeInfo(" << iTInfo <<
")");
1052 if (!xConnectable.is())
1055 OUString sIID = xConnectable->GetIIDForClassItselfNotCoclass();
1057 if (!SUCCEEDED(IIDFromString(
reinterpret_cast<LPOLESTR
>(sIID.pData->buffer), &aIID)))
1062 CComObject<CXTypeInfo>* pTypeInfo;
1064 ret = CComObject<CXTypeInfo>::CreateInstance(&pTypeInfo);
1068 pTypeInfo->AddRef();
1072 *ppTInfo = pTypeInfo;
1078 LPOLESTR * rgszNames,
1088 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::GetIDsOfNames:");
1089 for (
unsigned int i = 0;
i < cNames; ++
i)
1092 rgdispid[
i] = DISPID_UNKNOWN;
1094 SAL_INFO(
"extensions.olebridge",
" " << OUString(o3tl::toU(rgszNames[
i])));
1097 HRESULT ret = DISP_E_UNKNOWNNAME;
1124 OUString
name(o3tl::toU(rgszNames[0]));
1127 bool bIsMethod =
false;
1129 OUString exactName =
name;
1136 if (exactName.isEmpty())
1144 d.flags |= DISPATCH_PROPERTYGET;
1145 d.flags |= DISPATCH_PROPERTYPUT;
1146 d.flags |= DISPATCH_PROPERTYPUTREF;
1151 d.flags |= DISPATCH_METHOD;
1160 if (exactName !=
name)
1169 ret = DISP_E_UNKNOWNNAME;
1170 SAL_INFO(
"extensions.olebridge",
" " <<
name <<
": UNKNOWN");
1174 rgdispid[0] = (*iter).second;
1175 SAL_INFO(
"extensions.olebridge",
" " <<
name <<
": " << rgdispid[0]);
1177 if (bIsMethod && cNames > 1)
1183 if (xIntrospectionAccess.is())
1184 xIdlMethod = xIntrospectionAccess->getMethod(exactName, MethodConcept::ALL);
1186 catch (
const NoSuchMethodException&)
1189 if (xIdlMethod.is())
1191 auto aParamInfos = xIdlMethod->getParameterInfos();
1192 for (
unsigned int i = 1;
i < cNames; ++
i)
1194 bool bFound =
false;
1195 for (
int j = 0; j < aParamInfos.getLength(); ++j)
1197 if (aParamInfos[j].
aName.equalsIgnoreAsciiCase(o3tl::toU(rgszNames[
i])))
1201 SAL_INFO(
"extensions.olebridge",
" " << OUString(o3tl::toU(rgszNames[
i])) <<
": " << rgdispid[
i]);
1206 SAL_INFO(
"extensions.olebridge",
" " << OUString(o3tl::toU(rgszNames[
i])) <<
": NOT FOUND");
1213 for (
i = 0;
i < cNames; ++
i)
1214 if (rgdispid[
i] == DISPID_UNKNOWN)
1279 unsigned short , DISPPARAMS* pdispparams,
Sequence<Any>& rSeq)
1309 const int countIncomingArgs = pdispparams->cArgs;
1312 InvocationInfo info;
1315 "[automation bridge]InterfaceOleWrapper::convertDispparamsArgs \n"
1316 "Could not obtain type information for current call.");
1319 const int expectedArgs = info.aParamTypes.getLength() + (info.eMemberType == MemberType_PROPERTY ? 1 : 0);
1320 rSeq.realloc( expectedArgs );
1321 Any* pParams = rSeq.getArray();
1325 int outgoingArgIndex = 0;
1328 for (
int i = std::max(countIncomingArgs, expectedArgs) - 1;
i >= 0;
i--)
1331 if ( outgoingArgIndex >= expectedArgs && pdispparams->rgvarg[
i].vt ==
VT_EMPTY )
1335 if ( outgoingArgIndex >= expectedArgs )
1338 if (info.eMemberType == MemberType_METHOD &&
1339 info.aParamModes[ outgoingArgIndex ] == ParamMode_OUT)
1345 if (
i < countIncomingArgs)
1349 if (pdispparams->rgvarg[
i].vt ==
VT_ERROR && pdispparams->rgvarg[
i].scode == DISP_E_PARAMNOTFOUND)
1352 pParams[ outgoingArgIndex ] = aEmpty;
1359 pParams[ outgoingArgIndex ] = anyParam;
1377 CComVariant varParam;
1385 if( pdispparams->rgvarg[
i].vt == VT_DISPATCH )
1387 if( info.eMemberType == MemberType_METHOD && info.aParamModes[ outgoingArgIndex ] == ParamMode_INOUT)
1393 IDispatch* pdisp= pdispparams->rgvarg[
i].pdispVal;
1395 OLECHAR
const * sindex= L
"0";
1397 DISPPARAMS noParams= {
nullptr,
nullptr,0,0};
1398 if(SUCCEEDED(
hr= pdisp->GetIDsOfNames( IID_NULL,
const_cast<OLECHAR **
>(&sindex), 1, LOCALE_USER_DEFAULT, &id2)))
1399 hr= pdisp->Invoke( id2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
1400 & noParams, & varParam,
nullptr,
nullptr);
1404 "[automation bridge] Could not determine "
1405 "if the object has a member \"0\". Error: " +
1406 OUString::number(
hr));
1412 varParam= pdispparams->rgvarg[
i];
1414 if(info.eMemberType == MemberType_METHOD)
1416 info.aParamTypes[ outgoingArgIndex ]);
1417 else if(info.eMemberType == MemberType_PROPERTY)
1422 if (outgoingArgIndex < expectedArgs)
1423 pParams[ outgoingArgIndex ]= anyParam;
1430 bool bTypesAvailable=
false;
1445 OUString sMemberName;
1448 [&
id](
const NameToIdMap::value_type& nameToDispId) { return nameToDispId.second == id; });
1450 sMemberName= (*ci1).first;
1456 bool validInfo=
true;
1457 InvocationInfo invInfo;
1459 invInfo= inv2->getInfoForName( sMemberName,
false);
1461 catch(
const IllegalArgumentException&)
1468 invInfo= inv2->getInfoForName( sMemberName,
true);
1470 if( invInfo.aName.pData)
1472 bTypesAvailable=
true;
1476 return bTypesAvailable;
1486 sal_Int16 sourceModelType,
1487 sal_Int16 destModelType)
1491 if( sourceModelType ==
UNO && destModelType ==
OLE &&
1492 modelDepObject.getValueTypeClass() == TypeClass_INTERFACE )
1495 if( modelDepObject >>= xInt )
1499 VARIANT *pVar=
static_cast<VARIANT*
>(CoTaskMemAlloc(
sizeof( VARIANT)));
1502 pVar->vt= VT_DISPATCH;
1503 pVar->pdispVal=
this;
1506 retAny<<= reinterpret_cast< sal_uIntPtr >( pVar);
1530 if (xServiceInfo.is())
1533 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::initialize for "
1561 OUString str(o3tl::toU(
name));
1578 CComVariant varDest( *pDest);
1580 if( SUCCEEDED( varDest.ChangeType(VT_DISPATCH)))
1582 CComPtr<IDispatch> spDispDest(varDest.pdispVal);
1585 CComQIPtr<IJScriptValueObject> spValueDest(spDispDest);
1588 VARIANT_BOOL varBool= VARIANT_FALSE;
1589 if ((SUCCEEDED(
hr = spValueDest->IsOutParam(&varBool))
1590 && varBool == VARIANT_TRUE)
1591 || (SUCCEEDED(
hr = spValueDest->IsInOutParam(&varBool))
1592 && varBool == VARIANT_TRUE))
1594 if( SUCCEEDED( spValueDest->Set( CComVariant(), *pSource)))
1598 else if (pDest->vt == VT_DISPATCH)
1604 CComQIPtr<IDispatchEx> spDispEx( spDispDest);
1607 CComBSTR nullProp(L
"0");
1609 if( SUCCEEDED( spDispEx->GetDispID( nullProp, fdexNameEnsure, &dwDispID)))
1611 DISPPARAMS dispparams = {
nullptr,
nullptr, 1, 1};
1612 dispparams.rgvarg = pSource;
1613 DISPID dispidPut = DISPID_PROPERTYPUT;
1614 dispparams.rgdispidNamedArgs = &dispidPut;
1616 if (pSource->vt == VT_UNKNOWN || pSource->vt == VT_DISPATCH ||
1618 hr = spDispEx->InvokeEx(dwDispID, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUTREF,
1619 &dispparams,
nullptr,
nullptr,
nullptr);
1621 hr= spDispEx->InvokeEx(dwDispID, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
1622 &dispparams,
nullptr,
nullptr,
nullptr);
1647 if ((V_VT(pDest) &
VT_BYREF) != 0 )
1649 VARTYPE oleTypeFlags = V_VT(pSource);
1658 VariantCopy(V_VARIANTREF(pDest), pSource);
1664 if ((V_VT(pDest) & oleTypeFlags) == oleTypeFlags)
1666 if ((oleTypeFlags &
VT_ARRAY) != 0)
1669 if( *V_ARRAYREF(pDest) !=
nullptr)
1670 hr= SafeArrayCopyData( V_ARRAY(pSource), *V_ARRAYREF(pDest));
1673 hr= SafeArrayCopy(V_ARRAY(pSource), V_ARRAYREF(pDest));
1680 switch (V_VT(pSource))
1684 *V_I2REF(pDest) = V_I2(pSource);
1689 *V_I4REF(pDest) = V_I4(pSource);
1693 *V_R4REF(pDest) = V_R4(pSource);
1697 *V_R8REF(pDest) = V_R8(pSource);
1701 *V_CYREF(pDest) = V_CY(pSource);
1705 *V_DATEREF(pDest) = V_DATE(pSource);
1709 SysFreeString( *pDest->pbstrVal);
1711 *V_BSTRREF(pDest) = SysAllocString(V_BSTR(pSource));
1715 if (*V_DISPATCHREF(pDest) !=
nullptr)
1716 (*V_DISPATCHREF(pDest))->Release();
1718 *V_DISPATCHREF(pDest) = V_DISPATCH(pSource);
1720 if (*V_DISPATCHREF(pDest) !=
nullptr)
1721 (*V_DISPATCHREF(pDest))->AddRef();
1726 *V_ERRORREF(pDest) = V_ERROR(pSource);
1730 *V_BOOLREF(pDest) = V_BOOL(pSource);
1734 if (*V_UNKNOWNREF(pDest) !=
nullptr)
1735 (*V_UNKNOWNREF(pDest))->Release();
1737 *V_UNKNOWNREF(pDest) = V_UNKNOWN(pSource);
1739 if (*V_UNKNOWNREF(pDest) !=
nullptr)
1740 (*V_UNKNOWNREF(pDest))->AddRef();
1745 *V_I1REF(pDest) = V_I1(pSource);
1749 *V_UI1REF(pDest) = V_UI1(pSource);
1753 *V_UI2REF(pDest) = V_UI2(pSource);
1757 *V_UI4REF(pDest) = V_UI4(pSource);
1761 *V_INTREF(pDest) = V_INT(pSource);
1765 *V_UINTREF(pDest) = V_UINT(pSource);
1769 memcpy(pDest->pdecVal, pSource,
sizeof(DECIMAL));
1782 && pSource->vt ==
VT_I2)
1787 OLECHAR buff[]= {0,0};
1788 buff[0]= pSource->iVal;
1790 SysFreeString( *pDest->pbstrVal);
1791 *pDest->pbstrVal= SysAllocString( buff);
1804 DISPPARAMS * pdispparams,
1805 VARIANT * pvarResult,
1806 EXCEPINFO * pexcepinfo,
1812#if defined SAL_LOG_INFO
1814 for (
unsigned int i = 0;
i < pdispparams->cArgs; ++
i)
1818 std::stringstream aStringStream;
1819 aStringStream << pdispparams->rgvarg[
i];
1820 sParams += OUString::createFromAscii(aStringStream.str().c_str());
1824 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::Invoke(" << dispidMember <<
"," << sParams <<
")");
1831 bool bHandled=
false;
1832 ret=
InvokeGeneral( dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo,
1833 puArgErr, bHandled);
1840 DWORD flags = wFlags &
d.flags;
1844 if ((flags & DISPATCH_METHOD) != 0)
1846 std::unique_ptr<DISPPARAMS> pNewDispParams;
1847 std::vector<VARIANTARG> vNewArgs;
1849 if (pdispparams->cNamedArgs > 0)
1879 DISPID nLowestNamedArgDispid = 1000000;
1880 DISPID nHighestNamedArgDispid = -1;
1881 for (
unsigned int i = 0;
i < pdispparams->cNamedArgs; ++
i)
1883 if (pdispparams->rgdispidNamedArgs[
i] < nLowestNamedArgDispid)
1884 nLowestNamedArgDispid = pdispparams->rgdispidNamedArgs[
i];
1885 if (pdispparams->rgdispidNamedArgs[
i] > nHighestNamedArgDispid)
1886 nHighestNamedArgDispid = pdispparams->rgdispidNamedArgs[
i];
1892 if (nLowestNamedArgDispid <
static_cast<DISPID
>(pdispparams->cArgs - pdispparams->cNamedArgs))
1893 return DISP_E_NONAMEDARGS;
1896 pNewDispParams.reset(
new DISPPARAMS);
1897 vNewArgs.resize(nHighestNamedArgDispid + 1);
1898 pNewDispParams->rgvarg = vNewArgs.data();
1899 pNewDispParams->rgdispidNamedArgs =
nullptr;
1900 pNewDispParams->cArgs = nHighestNamedArgDispid + 1;
1901 pNewDispParams->cNamedArgs = 0;
1904 for (
int i = 0;
i < nHighestNamedArgDispid; ++
i)
1906 pNewDispParams->rgvarg[
i].vt =
VT_ERROR;
1907 pNewDispParams->rgvarg[
i].scode = DISP_E_PARAMNOTFOUND;
1911 for (
unsigned int i = 0;
i < pdispparams->cNamedArgs; ++
i)
1912 pNewDispParams->rgvarg[nHighestNamedArgDispid - pdispparams->rgdispidNamedArgs[
i]] = pdispparams->rgvarg[
i];
1914 const int nFirstUnnamedArg = pdispparams->cNamedArgs + (nLowestNamedArgDispid-(pdispparams->cArgs - pdispparams->cNamedArgs));
1916 for (
unsigned int i = pdispparams->cNamedArgs; i < pdispparams->cArgs; ++
i)
1917 pNewDispParams->rgvarg[nFirstUnnamedArg + (
i-pdispparams->cNamedArgs)] = pdispparams->rgvarg[
i];
1919 pdispparams = pNewDispParams.get();
1926 ret=
doInvoke(pdispparams, pvarResult,
1927 pexcepinfo, puArgErr,
d.name, params);
1929 else if ((flags & DISPATCH_PROPERTYGET) != 0)
1932 pexcepinfo,
d.name);
1934 else if ((flags & DISPATCH_PROPERTYPUT) != 0 || (flags & DISPATCH_PROPERTYPUTREF) != 0)
1936 if (pdispparams->cArgs != 1)
1937 ret = DISP_E_BADPARAMCOUNT;
1942 if(params.getLength() > 0)
1943 ret=
doSetProperty( pdispparams, pvarResult, pexcepinfo, puArgErr,
d.name, params);
1945 ret = DISP_E_BADVARTYPE;
1950 ret= DISP_E_MEMBERNOTFOUND;
1953 ret = DISP_E_MEMBERNOTFOUND;
1958 ret = DISP_E_EXCEPTION;
1962 OUString message=
"InterfaceOleWrapper::Invoke : \n" +
1965 ret = DISP_E_EXCEPTION;
1969 writeExcepinfo(pexcepinfo,
"InterfaceOleWrapper::Invoke : \nUnexpected exception");
1970 ret = DISP_E_EXCEPTION;
1977 EXCEPINFO * pexcepinfo,
unsigned int * puArgErr, OUString& name,
Sequence<Any>& params)
1988 if (pdispparams->cNamedArgs > 0)
1989 return DISP_E_NONAMEDARGS;
1998 if (outIndex.getLength() > 0)
2000 const sal_Int16* pOutIndex = outIndex.getConstArray();
2001 const Any* pOutParams = outParams.getConstArray();
2003 for (sal_Int32
i = 0;
i < outIndex.getLength();
i++)
2005 CComVariant variant;
2011 int outindex= pOutIndex[
i];
2018 if (pvarResult !=
nullptr)
2021 catch(
const IllegalArgumentException & e)
2024 ret = DISP_E_TYPEMISMATCH;
2026 catch(
const CannotConvertException & e)
2031 catch(
const InvocationTargetException & e)
2033 const Any&
org = e.TargetException;
2037 org.getValueType().getTypeName() +
": " + excTarget.Message;
2039 ret = DISP_E_EXCEPTION;
2041 catch(
const NoSuchMethodException & e)
2044 ret = DISP_E_MEMBERNOTFOUND;
2049 ret = DISP_E_EXCEPTION;
2053 OUString message=
"InterfaceOleWrapper::doInvoke : \n" +
2056 ret = DISP_E_EXCEPTION;
2060 writeExcepinfo(pexcepinfo,
"InterfaceOleWrapper::doInvoke : \nUnexpected exception");
2061 ret = DISP_E_EXCEPTION;
2067 EXCEPINFO * pexcepinfo, OUString& name)
2078 catch(
const UnknownPropertyException& e)
2081 ret = DISP_E_MEMBERNOTFOUND;
2086 ret = DISP_E_EXCEPTION;
2090 OUString message=
"InterfaceOleWrapper::doGetProperty : \n" +
2096 writeExcepinfo(pexcepinfo,
"InterfaceOleWrapper::doInvoke : \nUnexpected exception");
2097 ret = DISP_E_EXCEPTION;
2103 EXCEPINFO * pexcepinfo,
unsigned int * puArgErr, OUString& name,
Sequence<Any> const & params)
2111 catch(
const UnknownPropertyException &)
2113 ret = DISP_E_MEMBERNOTFOUND;
2115 catch(
const CannotConvertException &e)
2119 catch(
const InvocationTargetException &e)
2121 if (pexcepinfo !=
nullptr)
2123 Any org = e.TargetException;
2126 pexcepinfo->bstrSource = SysAllocString(L
"any ONE component");
2127 pexcepinfo->bstrDescription = SysAllocString(
2128 o3tl::toW(
org.getValueType().getTypeName().getStr()));
2130 ret = DISP_E_EXCEPTION;
2134 ret= DISP_E_EXCEPTION;
2141class CXEnumVariant :
public IEnumVARIANT,
2142 public CComObjectRoot
2150 virtual ~CXEnumVariant()
2154#if defined __clang__
2155#pragma clang diagnostic push
2156#pragma clang diagnostic ignored "-Wunused-function"
2158 BEGIN_COM_MAP(CXEnumVariant)
2159#if defined __clang__
2160#pragma clang diagnostic pop
2162 COM_INTERFACE_ENTRY(IEnumVARIANT)
2163#if defined __clang__
2164#pragma clang diagnostic push
2165#pragma clang diagnostic ignored "-Winconsistent-missing-override"
2166#pragma clang diagnostic ignored "-Wunused-function"
2169#if defined __clang__
2170#pragma clang diagnostic pop
2173 DECLARE_NOT_AGGREGATABLE(CXEnumVariant)
2179 mpInterfaceOleWrapper = pInterfaceOleWrapper;
2180 mxCollection = xCollection;
2184 virtual HRESULT STDMETHODCALLTYPE
Clone(IEnumVARIANT **)
override
2186 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumVariant::Clone: E_NOTIMPL");
2190 virtual HRESULT STDMETHODCALLTYPE
Next(ULONG
const celt,
2192 ULONG *pCeltFetched)
override
2201 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumVariant::Next(" << celt <<
"): E_INVALIDARG");
2202 return E_INVALIDARG;
2205 if (rgVar ==
nullptr || (celt != 1 && pCeltFetched ==
nullptr))
2207 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumVariant::Next(" << celt <<
"): E_FAIL");
2211 for (ULONG i = 0;
i < celt;
i++)
2212 VariantInit(&rgVar[i]);
2215 ULONG nReturned = 0;
2218 if (mnIndex > mxCollection->getCount())
2220 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumVariant::Next(" << celt <<
"): got " << nReturned <<
": S_FALSE");
2225 Any aElement = mxCollection->Item(aIndex,
Any());
2226 mpInterfaceOleWrapper->anyToVariant(rgVar, aElement);
2235 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumVariant::Next(" << celt <<
"): S_OK");
2239 virtual HRESULT STDMETHODCALLTYPE
Reset()
override
2241 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumVariant::Reset: S_OK");
2246 virtual HRESULT STDMETHODCALLTYPE STDMETHODCALLTYPE Skip(ULONG
const celt)
override
2254 if (mnIndex > mxCollection->getCount())
2256 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumVariant::Skip(" << celt <<
"): skipped " << nSkipped <<
": S_FALSE");
2262 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumVariant::Skip(" << celt <<
"): S_OK");
2272class Sink :
public cppu::WeakImplHelper<ooo::vba::XSink>
2275 Sink(IUnknown* pUnkSink,
2277 ooo::vba::TypeAndIID aTypeAndIID,
2284 IUnknown* mpUnkSink;
2286 ooo::vba::TypeAndIID maTypeAndIID;
2292Sink::Sink(IUnknown* pUnkSink,
2294 ooo::vba::TypeAndIID aTypeAndIID,
2296 mpUnkSink(pUnkSink),
2298 maTypeAndIID(aTypeAndIID),
2299 mpInterfaceOleWrapper(pInterfaceOleWrapper)
2301 mpUnkSink->AddRef();
2307 SAL_INFO(
"extensions.olebridge",
"Sink::Call(" << Method <<
", " << Arguments.getLength() <<
" arguments)");
2309 IDispatch* pDispatch;
2310 HRESULT nResult = mpUnkSink->QueryInterface(IID_IDispatch,
reinterpret_cast<void **
>(&pDispatch));
2311 if (!SUCCEEDED(nResult))
2313 SAL_WARN(
"extensions.olebridge",
"Sink::Call: Not IDispatch: " << WindowsErrorStringFromHRESULT(nResult));
2321 assert(xClass.is());
2323 auto aMethods = xClass->getMethods();
2324 assert(xClass->getTypeClass() == TypeClass_INTERFACE &&
2328 auto ArgumentsRange = asNonConstRange(Arguments);
2330 for (
int i = 3;
i <
aMethods.getLength();
i++)
2332 if (aMethods[i]->getName() == Method)
2339 auto aParamInfos =
aMethods[
i]->getParameterInfos();
2341 assert(Arguments.getLength() == aParamInfos.getLength());
2343 DISPPARAMS aDispParams;
2344 aDispParams.rgdispidNamedArgs =
nullptr;
2345 aDispParams.cArgs = Arguments.getLength();
2346 aDispParams.cNamedArgs = 0;
2347 aDispParams.rgvarg =
new VARIANT[aDispParams.cArgs];
2348 for (
unsigned j = 0; j < aDispParams.cArgs; j++)
2350 VariantInit(aDispParams.rgvarg+j);
2352 const unsigned nIncomingArgIndex = aDispParams.cArgs - j - 1;
2353 mpInterfaceOleWrapper->anyToVariant(aDispParams.rgvarg+j, Arguments[nIncomingArgIndex]);
2359 if (aParamInfos[nIncomingArgIndex].aMode == ParamMode_OUT ||
2360 aParamInfos[nIncomingArgIndex].aMode == ParamMode_INOUT)
2362 switch (aDispParams.rgvarg[j].vt)
2365 aDispParams.rgvarg[j].byref =
new SHORT(aDispParams.rgvarg[j].iVal);
2366 aDispParams.rgvarg[j].vt |=
VT_BYREF;
2369 aDispParams.rgvarg[j].byref =
new LONG(aDispParams.rgvarg[j].lVal);
2370 aDispParams.rgvarg[j].vt |=
VT_BYREF;
2373 aDispParams.rgvarg[j].byref =
new BSTR(aDispParams.rgvarg[j].bstrVal);
2374 aDispParams.rgvarg[j].vt |=
VT_BYREF;
2377 aDispParams.rgvarg[j].byref =
new VARIANT_BOOL(aDispParams.rgvarg[j].boolVal);
2378 aDispParams.rgvarg[j].vt |=
VT_BYREF;
2381 assert(
false &&
"Not handled yet");
2388 VariantInit(&aVarResult);
2401 SAL_INFO(
"extensions.olebridge",
"Sink::Call(" << Method <<
"): Calling Invoke(" << nMemId <<
")");
2403 nResult = pDispatch->Invoke(nMemId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &aDispParams, &aVarResult,
nullptr, &uArgErr);
2404 SAL_INFO(
"extensions.olebridge",
"Sink::Call(" << Method <<
"): Invoke() returned");
2406 SAL_WARN_IF(!SUCCEEDED(nResult),
"extensions.olebridge",
"Call to " << Method <<
" failed: " << WindowsErrorStringFromHRESULT(nResult));
2409 for (
unsigned j = 0; j < aDispParams.cArgs; j++)
2411 const unsigned nIncomingArgIndex = aDispParams.cArgs - j - 1;
2412 if (aParamInfos[nIncomingArgIndex].aMode == ParamMode_OUT ||
2413 aParamInfos[nIncomingArgIndex].aMode == ParamMode_INOUT)
2415 switch (aDispParams.rgvarg[j].vt)
2419 SHORT *pI =
static_cast<SHORT*
>(aDispParams.rgvarg[j].byref);
2420 ArgumentsRange[nIncomingArgIndex] <<=
static_cast<sal_Int16
>(*pI);
2426 LONG *pL =
static_cast<LONG*
>(aDispParams.rgvarg[j].byref);
2427 ArgumentsRange[nIncomingArgIndex] <<=
static_cast<sal_Int32
>(*pL);
2433 BSTR *pBstr =
static_cast<BSTR*
>(aDispParams.rgvarg[j].byref);
2434 ArgumentsRange[nIncomingArgIndex] <<= OUString(o3tl::toU(*pBstr));
2436 SysFreeString(*pBstr);
2442 VARIANT_BOOL *pBool =
static_cast<VARIANT_BOOL*
>(aDispParams.rgvarg[j].byref);
2443 ArgumentsRange[nIncomingArgIndex] <<= (*pBool != VARIANT_FALSE);
2448 assert(
false &&
"Not handled yet");
2454 switch (aDispParams.rgvarg[j].vt)
2458 SysFreeString(aDispParams.rgvarg[j].bstrVal);
2464 delete[] aDispParams.rgvarg;
2469 SAL_WARN(
"extensions.olebridge",
"Sink::Call: Unknown method '" << Method <<
"'");
2474class CXEnumConnections :
public IEnumConnections,
2475 public CComObjectRoot
2482 virtual ~CXEnumConnections()
2486#if defined __clang__
2487#pragma clang diagnostic push
2488#pragma clang diagnostic ignored "-Wunused-function"
2490 BEGIN_COM_MAP(CXEnumConnections)
2491#if defined __clang__
2492#pragma clang diagnostic pop
2494 COM_INTERFACE_ENTRY(IEnumConnections)
2495#if defined __clang__
2496#pragma clang diagnostic push
2497#pragma clang diagnostic ignored "-Winconsistent-missing-override"
2498#pragma clang diagnostic ignored "-Wunused-function"
2501#if defined __clang__
2502#pragma clang diagnostic pop
2505 DECLARE_NOT_AGGREGATABLE(CXEnumConnections)
2507 void Init(std::vector<IUnknown*>& rUnknowns, std::vector<DWORD>& rCookies)
2509 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumConnections::Init");
2510 SAL_WARN_IF(rUnknowns.size() != rCookies.size(),
"extensions.olebridge",
"Vectors of different size");
2511 mvUnknowns = rUnknowns;
2512 mvCookies = rCookies;
2516 virtual HRESULT STDMETHODCALLTYPE
Next(ULONG cConnections,
2518 ULONG *pcFetched)
override
2524 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumConnections::Next(" << cConnections <<
"): E_POINTER");
2528 if (pcFetched && cConnections != 1)
2530 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumConnections::Next(" << cConnections <<
"): E_INVALIDARG");
2531 return E_INVALIDARG;
2535 while (nFetched < cConnections && mnIndex < mvUnknowns.size())
2537 rgcd[nFetched].pUnk = mvUnknowns[
mnIndex];
2538 rgcd[nFetched].pUnk->AddRef();
2539 rgcd[nFetched].dwCookie = mvCookies[
mnIndex];
2543 if (nFetched != cConnections)
2545 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumConnections::Next(" << cConnections <<
"): S_FALSE");
2547 *pcFetched = nFetched;
2550 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumConnections::Next(" << cConnections <<
"): S_OK");
2552 *pcFetched = nFetched;
2557 virtual HRESULT STDMETHODCALLTYPE Skip(ULONG cConnections)
override
2559 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumConnections::Skip(" << cConnections <<
"): E_NOTIMPL");
2564 virtual HRESULT STDMETHODCALLTYPE
Reset()
override
2566 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumConnections::Reset: E_NOTIMPL");
2571 virtual HRESULT STDMETHODCALLTYPE
Clone(IEnumConnections** )
override
2573 SAL_INFO(
"extensions.olebridge",
this <<
"@CXEnumConnections::Clone: E_NOTIMPL");
2579 std::vector<IUnknown*> mvUnknowns;
2580 std::vector<DWORD> mvCookies;
2584class CXConnectionPoint :
public IConnectionPoint,
2585 public CComObjectRoot
2588#if defined __clang__
2589#pragma clang diagnostic push
2590#pragma clang diagnostic ignored "-Wunused-function"
2592 BEGIN_COM_MAP(CXConnectionPoint)
2593#if defined __clang__
2594#pragma clang diagnostic pop
2596 COM_INTERFACE_ENTRY(IConnectionPoint)
2597#if defined __clang__
2598#pragma clang diagnostic push
2599#pragma clang diagnostic ignored "-Winconsistent-missing-override"
2600#pragma clang diagnostic ignored "-Wunused-function"
2603#if defined __clang__
2604#pragma clang diagnostic pop
2607 DECLARE_NOT_AGGREGATABLE(CXConnectionPoint)
2609 virtual ~CXConnectionPoint() {}
2614 ooo::vba::TypeAndIID aTypeAndIID)
2619 if (SUCCEEDED(QueryInterface(IID_IUnknown,
reinterpret_cast<void **
>(&pUnknown))))
2622 SAL_INFO(
"extensions.olebridge",
" (IUnknown@" << pUnknown <<
")");
2625 mpInterfaceOleWrapper = pInterfaceOleWrapper;
2628 maTypeAndIID = aTypeAndIID;
2631 virtual HRESULT STDMETHODCALLTYPE GetConnectionInterface(IID *pIID)
override
2633 SAL_WARN(
"extensions.olebridge",
this <<
"@CXConnectionPoint::GetConnectionInterface(" << *pIID <<
"): E_NOTIMPL");
2640 virtual HRESULT STDMETHODCALLTYPE GetConnectionPointContainer(IConnectionPointContainer **)
override
2642 SAL_WARN(
"extensions.olebridge",
this <<
"@CXConnectionPoint::GetConnectionInterface: E_NOTIMPL");
2649 virtual HRESULT STDMETHODCALLTYPE Advise(IUnknown *pUnkSink,
2650 DWORD *pdwCookie)
override
2654 SAL_INFO(
"extensions.olebridge",
this <<
"@CXConnectionPoint::Advise(" << pUnkSink <<
")");
2661 mvISinks.push_back(pUnkSink);
2662 *pdwCookie = mvISinks.size();
2664 mvCookies.push_back(mxCP->Advise(xSink));
2666 mvXSinks.push_back(xSink);
2668 SAL_INFO(
"extensions.olebridge",
" *pdwCookie: " << *pdwCookie);
2673 virtual HRESULT STDMETHODCALLTYPE Unadvise(DWORD dwCookie)
override
2677 SAL_INFO(
"extensions.olebridge",
this <<
"@CXConnectionPoint::Unadvise(" << dwCookie <<
")");
2679 if (dwCookie == 0 || dwCookie > mvISinks.size())
2682 mvISinks[dwCookie-1] =
nullptr;
2684 mxCP->Unadvise(mvCookies[dwCookie-1]);
2691 virtual HRESULT STDMETHODCALLTYPE EnumConnections(IEnumConnections **ppEnum)
override
2697 SAL_INFO(
"extensions.olebridge",
this <<
"@CXConnectionPoint::EnumConnections...");
2701 SAL_INFO(
"extensions.olebridge",
"..." <<
this <<
"@CXConnectionPoint::EnumConnections: E_POINTER");
2705 CComObject<CXEnumConnections>* pEnumConnections;
2707 nResult = CComObject<CXEnumConnections>::CreateInstance(&pEnumConnections);
2708 if (FAILED(nResult))
2710 SAL_INFO(
"extensions.olebridge",
"..." <<
this <<
"@CXConnectionPoint::EnumConnections: " << WindowsErrorStringFromHRESULT(nResult));
2714 pEnumConnections->AddRef();
2716 pEnumConnections->Init(mvISinks, mvCookies);
2717 *ppEnum = pEnumConnections;
2719 SAL_INFO(
"extensions.olebridge",
"..." <<
this <<
"@CXConnectionPoint::EnumConnections: S_OK");
2725 std::vector<IUnknown*> mvISinks;
2726 std::vector<Reference<ooo::vba::XSink>> mvXSinks;
2727 std::vector<DWORD> mvCookies;
2730 ooo::vba::TypeAndIID maTypeAndIID;
2736 DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo,
2737 unsigned int * ,
bool& bHandled)
2745 if( dispidMember == DISPID_VALUE && (wFlags & DISPATCH_PROPERTYGET) != 0
2753 Any aValue = xCheckBox->getValue();
2761 pvarResult->vt= VT_DISPATCH;
2762 pvarResult->pdispVal=
this;
2774 CComObject< JScriptValue>* pValue;
2775 if( SUCCEEDED( CComObject<JScriptValue>::CreateInstance( &pValue)))
2778 pvarResult->vt= VT_DISPATCH;
2779 pvarResult->pdispVal= CComQIPtr<IDispatch>(pValue->GetUnknown());
2783 ret= DISP_E_EXCEPTION;
2788 bool bStruct=
false;
2794 if( pdispparams->cArgs == 1 && SUCCEEDED( arg.ChangeType(
VT_BSTR, &pdispparams->rgvarg[0])) )
2797 if( classStruct.is())
2800 classStruct->createObject( anyStruct);
2804 if( var.vt == VT_DISPATCH)
2806 VariantCopy( pvarResult, & var);
2811 ret= bStruct ? S_OK : DISP_E_EXCEPTION;
2820 if( pdispparams->cArgs != 1)
2821 return DISP_E_BADPARAMCOUNT;
2822 if (FAILED( arg.ChangeType(
VT_BSTR, &pdispparams->rgvarg[0])))
2823 return DISP_E_BADVARTYPE;
2829 writeExcepinfo(pexcepinfo, OUString::Concat(
"[automation bridge] A UNO type with the name ") +
2830 o3tl::toU(arg.bstrVal) +
" does not exist!");
2831 return DISP_E_EXCEPTION;
2836 writeExcepinfo(pexcepinfo,
"[automation bridge] InterfaceOleWrapper::InvokeGeneral\n"
2837 "Could not initialize UnoTypeWrapper object!");
2838 return DISP_E_EXCEPTION;
2841 else if (dispidMember == DISPID_NEWENUM)
2848 if (!xCollection.is())
2849 return DISP_E_MEMBERNOTFOUND;
2851 CComObject<CXEnumVariant>* pEnumVar;
2853 ret = CComObject<CXEnumVariant>::CreateInstance(&pEnumVar);
2859 pEnumVar->Init(
this, xCollection);
2861 pvarResult->vt = VT_UNKNOWN;
2862 pvarResult->punkVal =
nullptr;
2864 ret = pEnumVar->QueryInterface(IID_IUnknown,
reinterpret_cast<void**
>(&pvarResult->punkVal));
2867 pEnumVar->Release();
2875 ret = DISP_E_EXCEPTION;
2879 OUString message=
"InterfaceOleWrapper::InvokeGeneral : \n" +
2882 ret = DISP_E_EXCEPTION;
2886 writeExcepinfo(pexcepinfo,
"InterfaceOleWrapper::InvokeGeneral : \nUnexpected exception");
2887 ret = DISP_E_EXCEPTION;
2894 return ResultFromScode(E_NOTIMPL);
2901 DISPPARAMS __RPC_FAR* ,
2902 VARIANT __RPC_FAR* ,
2903 EXCEPINFO __RPC_FAR* ,
2904 IServiceProvider __RPC_FAR* )
2906 return ResultFromScode(E_NOTIMPL);
2913 return ResultFromScode(E_NOTIMPL);
2918 return ResultFromScode(E_NOTIMPL);
2926 return ResultFromScode(E_NOTIMPL);
2933 return ResultFromScode(E_NOTIMPL);
2941 return ResultFromScode(E_NOTIMPL);
2945 IUnknown __RPC_FAR *__RPC_FAR* )
2947 return ResultFromScode(E_NOTIMPL);
2956 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::GetClassInfo");
2965 OUString sIID = xIID->getIID();
2967 if (!SUCCEEDED(IIDFromString(
reinterpret_cast<LPOLESTR
>(sIID.pData->buffer), &aIID)))
2972 CComObject<CXTypeInfo>* pTypeInfo;
2974 ret = CComObject<CXTypeInfo>::CreateInstance(&pTypeInfo);
2978 pTypeInfo->AddRef();
2989 IEnumConnectionPoints **)
2991 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::EnumConnectionPoints");
2992 return ResultFromScode(E_NOTIMPL);
2997 IConnectionPoint **ppCP)
3001 SAL_INFO(
"extensions.olebridge",
this <<
"@InterfaceOleWrapper::FindConnectionPoint(" << riid <<
")");
3009 assert(xConnectable.is());
3010 if (!xConnectable.is())
3013 ooo::vba::TypeAndIID aTypeAndIID = xConnectable->GetConnectionPoint();
3016 if (!SUCCEEDED(IIDFromString(
reinterpret_cast<LPOLESTR
>(aTypeAndIID.IID.pData->buffer), &aIID)))
3017 return E_INVALIDARG;
3019 if (!IsEqualIID(riid, aIID))
3020 return E_INVALIDARG;
3024 return E_INVALIDARG;
3028 CComObject<CXConnectionPoint>* pConnectionPoint;
3030 ret = CComObject<CXConnectionPoint>::CreateInstance(&pConnectionPoint);
3034 pConnectionPoint->AddRef();
3036 pConnectionPoint->Init(
this, xCP,
m_smgr, aTypeAndIID);
3038 *ppCP = pConnectionPoint;
3065 LCID , DISPID * rgdispid )
3071 HRESULT ret = E_UNEXPECTED;
3087 OUString
name(o3tl::toU(rgszNames[0]));
3093 typedef NameToIdMap::iterator ITnames;
3096 if( pair_id.second )
3102 *rgdispid = pair_id.first->second;
3106 ret= DISP_E_UNKNOWNNAME;
3112 DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo,
3120 bool bHandled=
false;
3121 ret=
InvokeGeneral( dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo,
3122 puArgErr, bHandled);
3137 if( wFlags == DISPATCH_METHOD )
3141 if( FAILED( ret=
doInvoke( pdispparams, pvarResult,
3142 pexcepinfo, puArgErr, info.
name, params))
3143 && ret == DISP_E_MEMBERNOTFOUND)
3151 if( !exactName.isEmpty() )
3153 if( SUCCEEDED( ret=
doInvoke( pdispparams, pvarResult,
3154 pexcepinfo, puArgErr, exactName, params)))
3155 info.
name= exactName;
3159 if( SUCCEEDED( ret ) )
3160 info.
flags= DISPATCH_METHOD;
3162 else if( wFlags == DISPATCH_PROPERTYPUT || wFlags == DISPATCH_PROPERTYPUTREF)
3166 pexcepinfo, puArgErr, info.
name, params))
3167 && ret == DISP_E_MEMBERNOTFOUND)
3175 if( !exactName.isEmpty() )
3178 pexcepinfo, puArgErr, exactName, params)))
3179 info.
name= exactName;
3183 if( SUCCEEDED( ret ) )
3184 info.
flags= DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYGET;
3186 else if( wFlags == DISPATCH_PROPERTYGET)
3189 pexcepinfo, info.
name))
3190 && ret == DISP_E_MEMBERNOTFOUND)
3198 if( !exactName.isEmpty() )
3201 pexcepinfo, exactName)))
3202 info.
name= exactName;
3206 if( SUCCEEDED( ret ) )
3207 info.
flags= DISPATCH_PROPERTYGET | DISPATCH_PROPERTYPUT;
3209 else if( wFlags & DISPATCH_METHOD &&
3210 (wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF))
3217 if( FAILED( ret=
doInvoke( pdispparams, pvarResult,
3218 pexcepinfo, puArgErr, info.
name, params))
3219 && ret == DISP_E_MEMBERNOTFOUND)
3226 if( !exactName.isEmpty() )
3228 if( SUCCEEDED( ret=
doInvoke( pdispparams, pvarResult,
3229 pexcepinfo, puArgErr, exactName, params)))
3230 info.
name= exactName;
3234 if( SUCCEEDED( ret ) )
3235 info.
flags= DISPATCH_METHOD;
3238 if( FAILED( ret) && pdispparams->cArgs == 1)
3241 pexcepinfo, puArgErr, info.
name, params))
3242 && ret == DISP_E_MEMBERNOTFOUND)
3245 if( !exactName.isEmpty() )
3248 pexcepinfo, puArgErr, exactName, params)))
3249 info.
name= exactName;
3252 if( SUCCEEDED( ret ) )
3253 info.
flags= DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYGET;
3256 else if( wFlags & DISPATCH_METHOD && wFlags & DISPATCH_PROPERTYGET)
3261 if( FAILED( ret=
doInvoke( pdispparams, pvarResult,
3262 pexcepinfo, puArgErr, info.
name, params))
3263 && ret == DISP_E_MEMBERNOTFOUND)
3270 if( !exactName.isEmpty() )
3272 if( SUCCEEDED( ret=
doInvoke( pdispparams, pvarResult,
3273 pexcepinfo, puArgErr, exactName, params)))
3274 info.
name= exactName;
3278 if( SUCCEEDED( ret ) )
3279 info.
flags= DISPATCH_METHOD;
3282 if( FAILED( ret) && pdispparams->cArgs == 1)
3285 pexcepinfo, info.
name))
3286 && ret == DISP_E_MEMBERNOTFOUND)
3288 if( !exactName.isEmpty() )
3291 pexcepinfo, puArgErr, exactName, params)))
3292 info.
name= exactName;
3295 if( SUCCEEDED( ret ) )
3296 info.
flags= DISPATCH_PROPERTYGET;
3301 if( ret == DISP_E_MEMBERNOTFOUND)
3311 if( wFlags & DISPATCH_METHOD && info.
flags == DISPATCH_METHOD)
3314 ret=
doInvoke( pdispparams, pvarResult,
3315 pexcepinfo, puArgErr, info.
name, params);
3317 else if( (wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF ) &&
3318 info.
flags & DISPATCH_PROPERTYPUT)
3322 pexcepinfo, puArgErr, info.
name, params);
3324 else if( (wFlags & DISPATCH_PROPERTYGET) && ( info.
flags & DISPATCH_PROPERTYGET))
3327 pexcepinfo, info.
name);
3331 ret= DISP_E_MEMBERNOTFOUND;
3336 ret= DISP_E_MEMBERNOTFOUND;
3342 ret = DISP_E_EXCEPTION;
3346 OUString message=
"UnoObjectWrapperRemoteOpt::Invoke : \n" +
3349 ret = DISP_E_EXCEPTION;
3353 writeExcepinfo(pexcepinfo,
"UnoObjectWrapperRemoteOpt::Invoke : \nUnexpected exception");
3354 ret = DISP_E_EXCEPTION;
3370 bool bWriteIndex=
true;
3374 case FailReason::OUT_OF_RANGE:
3375 ret = DISP_E_OVERFLOW;
3377 case FailReason::IS_NOT_NUMBER:
3378 ret = DISP_E_TYPEMISMATCH;
3380 case FailReason::IS_NOT_ENUM:
3381 ret = DISP_E_TYPEMISMATCH;
3383 case FailReason::IS_NOT_BOOL:
3384 ret = DISP_E_TYPEMISMATCH;
3386 case FailReason::NO_SUCH_INTERFACE:
3387 ret = DISP_E_TYPEMISMATCH;
3389 case FailReason::SOURCE_IS_NO_DERIVED_TYPE:
3390 ret = DISP_E_TYPEMISMATCH;
3392 case FailReason::TYPE_NOT_SUPPORTED:
3393 ret = DISP_E_TYPEMISMATCH;
3395 case FailReason::INVALID:
3396 ret = DISP_E_TYPEMISMATCH;
3398 case FailReason::NO_DEFAULT_AVAILABLE:
3399 ret = DISP_E_BADPARAMCOUNT;
3401 case FailReason::UNKNOWN:
3410 if( bWriteIndex && puArgErr !=
nullptr)
3411 *puArgErr = e.ArgumentIndex;
3427 switch (
value.getValueTypeClass())
3429 case TypeClass_STRUCT: ret= VT_DISPATCH;
break;
3430 case TypeClass_INTERFACE: ret= VT_DISPATCH;
break;
constexpr OUStringLiteral sImplementationName
NameToIdMap m_nameToDispIdMap
virtual HRESULT doSetProperty(DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, unsigned int *puArgErr, OUString &name, Sequence< Any > const ¶ms)
virtual HRESULT STDMETHODCALLTYPE FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP) override
virtual Reference< XInterface > createComWrapperInstance() override
InterfaceOleWrapper(Reference< XMultiServiceFactory > const &xFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass)
STDMETHOD() QueryInterface(REFIID riid, void **ppvObj) override
virtual Any SAL_CALL createBridge(const Any &modelDepObject, const Sequence< sal_Int8 > &ProcessId, sal_Int16 sourceModelType, sal_Int16 destModelType) override
virtual Reference< XInterface > createUnoWrapperInstance() override
STDMETHOD() GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid) override
virtual HRESULT InvokeGeneral(DISPID dispidMember, unsigned short wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, unsigned int *puArgErr, bool &bHandled)
virtual HRESULT STDMETHODCALLTYPE DeleteMemberByDispID(DISPID id) override
virtual HRESULT doGetProperty(DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, OUString &name)
const OUString & getImplementationName() const
STDMETHOD() getWrapperXInterface(Reference< XInterface > *pXInt) override
void convertDispparamsArgs(DISPID id, unsigned short wFlags, DISPPARAMS *pdispparams, Sequence< Any > &rSeq)
STDMETHOD() getOriginalUnoStruct(Any *pStruct) override
virtual HRESULT STDMETHODCALLTYPE GetMemberProperties(DISPID id, DWORD grfdexFetch, DWORD __RPC_FAR *pgrfdex) override
STDMETHOD() GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo) override
OUString m_sImplementationName
virtual HRESULT STDMETHODCALLTYPE GetNextDispID(DWORD grfdex, DISPID id, DISPID __RPC_FAR *pid) override
virtual HRESULT STDMETHODCALLTYPE GetMemberName(DISPID id, BSTR __RPC_FAR *pbstrName) override
virtual HRESULT doInvoke(DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, unsigned int *puArgErr, OUString &name, Sequence< Any > ¶ms)
virtual HRESULT STDMETHODCALLTYPE GetDispID(BSTR bstrName, DWORD grfdex, DISPID __RPC_FAR *pid) override
STDMETHOD() getOriginalUnoObject(Reference< XInterface > *pXInt) override
STDMETHOD() Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr) override
Reference< XInterface > m_xOrigin
STDMETHOD() GetTypeInfoCount(UINT *pctinfo) override
~InterfaceOleWrapper() override
virtual HRESULT STDMETHODCALLTYPE EnumConnectionPoints(IEnumConnectionPoints **ppEnum) override
Reference< XInvocation > m_xInvocation
virtual HRESULT STDMETHODCALLTYPE GetNameSpaceParent(IUnknown __RPC_FAR *__RPC_FAR *ppunk) override
bool getInvocationInfoForCall(DISPID id, InvocationInfo &info)
std::vector< MemberInfo > m_MemberInfos
VARTYPE m_defaultValueType
virtual HRESULT STDMETHODCALLTYPE InvokeEx(DISPID id, LCID lcid, WORD wFlags, DISPPARAMS __RPC_FAR *pdp, VARIANT __RPC_FAR *pvarRes, EXCEPINFO __RPC_FAR *pei, IServiceProvider __RPC_FAR *pspCaller) override
virtual HRESULT STDMETHODCALLTYPE GetClassInfo(ITypeInfo **ppTI) override
virtual void SAL_CALL initialize(const Sequence< Any > &aArguments) override
virtual HRESULT STDMETHODCALLTYPE DeleteMemberByName(BSTR bstr, DWORD grfdex) override
Reference< XExactName > m_xExactName
All methods are allowed to throw at least a BridgeRuntimeError.
void anyToVariant(VARIANT *pVariant, const Any &rAny)
converts only into oleautomation types, that is there is no VT_I1, VT_UI2, VT_UI4 a sal_Unicode chara...
bool convertValueObject(const VARIANTARG *var, Any &any)
const sal_uInt8 m_nUnoWrapperClass
void variantToAny(const VARIANT *pVariant, Any &rAny, bool bReduceValueRange=true)
Reference< XMultiServiceFactory > m_smgr
const sal_uInt8 m_nComWrapperClass
UnoObjectWrapperRemoteOpt(Reference< XMultiServiceFactory > const &aFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass)
IdToMemberInfoMap m_idToMemberInfoMap
STDMETHOD() Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr) override
static HRESULT methodInvoke(DISPID dispidMember, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, unsigned int *puArgErr, Sequence< Any > const ¶ms)
~UnoObjectWrapperRemoteOpt() override
virtual Reference< XInterface > createUnoWrapperInstance() override
STDMETHOD() GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid) override
IJScriptValueObject VARIANT value
std::deque< AttacherIndex_Impl > aIndex
Reference< XSingleServiceFactory > xFactory
Sequence< PropertyValue > aArguments
tools::SvRef< SvBaseLink > xSink
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< sal_Int32[]> pData
struct _typelib_TypeDescription typelib_TypeDescription
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
#define UNO_2_OLE_EXCEPTIONCODE
const wchar_t *typedef BOOL
constexpr Method aMethods[]
void SAL_CALL typelib_typedescription_release(typelib_TypeDescription *pTD) SAL_THROW_EXTERN_C()
void SAL_CALL typelib_typedescription_getByName(typelib_TypeDescription **ppRet, rtl_uString *pName) SAL_THROW_EXTERN_C()
VARTYPE getVarType(const Any &value)
bool getType(const BSTR name, Type &type)
COM_DECLSPEC_NOTHROW STDMETHODIMP_(ULONG) InterfaceOleWrapper
static HRESULT mapCannotConvertException(const CannotConvertException &e, unsigned int *puArgErr)
static bool writeBackOutParameter(VARIANTARG *pDest, VARIANT *pSource)
static bool writeBackOutParameter2(VARIANTARG *pDest, VARIANT *pSource)
std::unordered_map< sal_uIntPtr, WeakReference< XInterface > > UnoObjToWrapperMap
static void writeExcepinfo(EXCEPINFO *pInfo, const OUString &message)
#define JSCRIPT_VALUE_FUNC
#define DISPID_GET_STRUCT_FUNC
#define BRIDGE_CREATE_TYPE_FUNC
#define DISPID_CREATE_TYPE_FUNC
#define BRIDGE_GET_STRUCT_FUNC
#define DISPID_JSCRIPT_VALUE_FUNC
#define BRIDGE_VALUE_FUNC
bool createUnoTypeWrapper(BSTR sTypeName, VARIANT *pVar)