43 #define QT_CHECK_STATE 47 #ifndef QT_NO_WIN_ACTIVEQT 67 #include "../shared/qaxtypes.h" 86 delete [] (
int*)
d.data;
87 delete [] (
char*)
d.stringdata;
151 if (index > plist.
count() - 1)
158 bool byRef = param.
endsWith(
'&') || param.endsWith(
"**");
160 param.truncate(param.length() - 1);
171 if (dispid == DISPID_UNKNOWN) {
174 OLECHAR *names = (
wchar_t*)unicodeName.
utf16();
175 disp->GetIDsOfNames(IID_NULL, &names, 1, LOCALE_USER_DEFAULT, &dispid);
176 if (dispid != DISPID_UNKNOWN)
191 {
"float",
"double"},
194 {
"QList<int>",
"QVariantList" },
195 {
"QList<uint>",
"QVariantList" },
196 {
"QList<double>",
"QVariantList" },
197 {
"QList<bool>",
"QVariantList" },
198 {
"QList<QDateTime>",
"QVariantList" },
199 {
"QList<qlonglong>",
"QVariantList" },
215 : cpoint(0), ciid(IID_NULL), combase(com), ref(1)
240 void advise(IConnectionPoint *cp, IID iid)
245 cpoint->Advise((IUnknown*)(IDispatch*)
this, &cookie);
253 cpoint->Unadvise(cookie);
262 int pi = signalname.
indexOf(
'(');
276 if (it.
value() == signalname) {
293 return InterlockedIncrement(&ref);
297 LONG refCount = InterlockedDecrement(&ref);
306 if (riid == IID_IUnknown)
307 *ppvObject = (IUnknown*)(IDispatch*)
this;
308 else if (riid == IID_IDispatch)
309 *ppvObject = (IDispatch*)
this;
310 else if (riid == IID_IPropertyNotifySink)
311 *ppvObject = (IPropertyNotifySink*)
this;
312 else if (ciid == riid)
313 *ppvObject = (IDispatch*)
this;
315 return E_NOINTERFACE;
330 DISPPARAMS *pDispParams,
336 if (riid != IID_NULL)
337 return DISP_E_UNKNOWNINTERFACE;
338 if (!(wFlags & DISPATCH_METHOD))
339 return DISP_E_MEMBERNOTFOUND;
345 return DISP_E_MEMBERNOTFOUND;
347 QObject *qobject = combase->qObject();
356 if (signalHasReceivers(qobject,
"signal(QString,int,void*)")) {
361 void *argv[] = {0, &nameString, &pDispParams->cArgs, &pDispParams->rgvarg};
369 if (signalHasReceivers(qobject, signame)) {
377 int argcount = pDispParams->cArgs;
378 if (pcount > argcount)
379 return DISP_E_PARAMNOTOPTIONAL;
380 else if (pcount < argcount)
381 return DISP_E_BADPARAMCOUNT;
390 void **argv_pointer = 0;
396 argv_pointer = static_argv_pointer;
399 argv =
new void*[pcount + 1];
400 argv_pointer =
new void*[pcount + 1];
409 for (p = 0; p < pcount && ok; ++p) {
413 argv_pointer[p + 1] = 0;
414 if (varp[p + 1].isValid()) {
416 argv[p + 1] = varp[p + 1].
data();
417 }
else if (ptype ==
"QVariant") {
418 argv[p + 1] = varp + p + 1;
420 argv[p + 1] =
const_cast<void*
>(varp[p + 1].
constData());
422 argv_pointer[p + 1] = argv[p + 1];
423 argv[p + 1] = argv_pointer + p + 1;
426 }
else if (ptype ==
"QVariant") {
427 argv[p + 1] = varp + p + 1;
437 for (p = 0; p < pcount; ++p) {
441 if (!
QVariantToVARIANT(varp[p + 1], pDispParams->rgvarg[pcount - p - 1], ptype, out))
447 if (argv != static_argv) {
449 delete [] argv_pointer;
452 hres = ok ? S_OK : (ok ? DISP_E_MEMBERNOTFOUND : DISP_E_TYPEMISMATCH);
464 if (dispID == DISPID_UNKNOWN || !combase)
475 QObject *qobject = combase->qObject();
483 void *argv[] = {0, &propnameString};
496 if (signalHasReceivers(qobject, signame)) {
505 void *argv[] = {0, var.
data()};
516 if (dispID == DISPID_UNKNOWN || !combase)
523 return combase->propertyWritable(propname) ? S_OK : S_FALSE;
553 : useEventSink(true), useMetaObject(true), useClassInfo(true),
554 cachedMetaObject(false), initialized(false), tryCache(false),
555 ptr(0), disp(0), metaobj(0)
561 qRegisterMetaType<IUnknown*>(
"IUnknown*", &
ptr);
562 qRegisterMetaType<IDispatch*>(
"IDispatch*", &disp);
577 CoFreeUnusedLibraries();
586 ptr->QueryInterface(IID_IDispatch, (
void**)&disp);
624 if (!propname.isEmpty())
627 IDispatch *dispatch = combase->
d->dispatch();
628 ITypeInfo *typeinfo = 0;
630 dispatch->GetTypeInfo(0, LOCALE_USER_DEFAULT, &typeinfo);
636 typeinfo->GetNames(dispID, &names, 1, &cNames);
639 SysFreeString(names);
649 addProperty(dispID, propname, propsignal);
856 d->initialized =
true;
858 #if defined(Q_OS_WINCE) 859 CoInitializeEx(0, COINIT_MULTITHREADED);
870 #if defined(Q_OS_WINCE) 907 d->ptr = that->
d->
ptr;
910 d->initialized =
true;
917 return d->metaObject();
977 if (c.
toLower() ==
d->ctrl.toLower())
978 return !
d->ctrl.isEmpty();
987 HRESULT res = CLSIDFromProgID((
wchar_t*)c.
utf16(), &clsid);
1012 if (search.
toLower() ==
d->ctrl.toLower())
1013 return !
d->ctrl.isEmpty();
1019 if (!initialize(&
d->ptr))
1020 d->initialized =
true;
1022 qWarning(
"QAxBase::setControl: requested control %s could not be instantiated", c.
toLatin1().
data());
1049 d->useEventSink =
false;
1070 d->useMetaObject =
false;
1071 d->useEventSink =
false;
1072 d->useClassInfo =
false;
1085 d->useClassInfo =
false;
1098 while (it !=
d->eventSink.end()) {
1106 d->eventSink.clear();
1114 d->initialized =
false;
1119 if (!
d->cachedMetaObject)
1142 if (
d->verbs.isEmpty()) {
1143 IOleObject *ole = 0;
1144 d->ptr->QueryInterface(IID_IOleObject, (
void**)&ole);
1146 IEnumOLEVERB *enumVerbs = 0;
1147 ole->EnumVerbs(&enumVerbs);
1152 while (enumVerbs->Next(1, &verb, &c) == S_OK) {
1153 if (!verb.lpszVerbName)
1157 d->verbs.insert(verbName, verb.lVerb);
1159 enumVerbs->Release();
1165 return d->verbs.keys();
1174 return d->verbs.value(verb);
1201 if (*ptr || control().
isEmpty())
1210 res = initializeRemote(ptr);
1212 res = initializeLicensed(ptr);
1214 res = initializeActive(ptr);
1216 res = initializeFromFile(ptr);
1219 HRESULT hres = CoCreateInstance(
QUuid(ctrl), 0, CLSCTX_SERVER, IID_IUnknown, (
void**)ptr);
1247 IClassFactory *factory = 0;
1248 CoGetClassObject(
QUuid(clsid), CLSCTX_SERVER, 0, IID_IClassFactory, (
void**)&factory);
1251 initializeLicensedHelper(factory, key, ptr);
1263 IClassFactory *factory = (IClassFactory*)f;
1264 IClassFactory2 *factory2 = 0;
1265 factory->QueryInterface(IID_IClassFactory2, (
void**)&factory2);
1268 HRESULT hres = factory2->CreateInstanceLic(0, 0, IID_IUnknown, bkey, (
void**)ptr);
1269 SysFreeString(bkey);
1272 licinfo.cbLicInfo =
sizeof(LICINFO);
1273 factory2->GetLicInfo(&licinfo);
1278 if (!licinfo.fLicVerified) {
1279 qWarning(
"Wrong license key specified, and machine is not fully licensed.");
1280 }
else if (licinfo.fRuntimeKeyAvail) {
1282 factory2->RequestLicKey(0, &licenseKey);
1284 SysFreeString(licenseKey);
1285 qWarning(
"Use license key is '%s' to create object on unlicensed machine.",
1288 }
else if (licinfo.fLicVerified) {
1289 qWarning(
"Machine is fully licensed for '%s'", control().toLatin1().constData());
1290 if (licinfo.fRuntimeKeyAvail) {
1292 factory2->RequestLicKey(0, &licenseKey);
1294 SysFreeString(licenseKey);
1296 if (qlicenseKey != key)
1303 factory2->Release();
1305 factory->CreateInstance(0, IID_IUnknown, (
void**)ptr);
1323 #if defined(Q_OS_WINCE) 1330 GetActiveObject(
QUuid(clsid), 0, ptr);
1337 # ifndef OLEPENDER_NONE 1338 # define OLERENDER_NONE 0 1354 #if defined(Q_OS_WINCE) 1358 IStorage *storage = 0;
1359 ILockBytes * bytes = 0;
1360 HRESULT hres = ::CreateILockBytesOnHGlobal(0,
TRUE, &bytes);
1361 hres = ::StgCreateDocfileOnILockBytes(bytes, STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &storage);
1363 hres = OleCreateFromFile(CLSID_NULL, reinterpret_cast<const wchar_t*>(control().utf16()), IID_IUnknown, OLERENDER_NONE, 0, 0, storage, (
void**)ptr);
1368 return hres == S_OK;
1374 #if defined(Q_CC_GNU) && !defined(COAUTHIDENTITY) && !defined(__MINGW64_VERSION_MAJOR) 1375 #define COAUTHIDENTITY AUTH_IDENTITY 1395 QString clsid(control().mid(at+1));
1404 user = server.
left(at);
1405 server = server.
mid(at+1);
1409 passwd = user.
mid(at+1);
1410 user = user.
left(at);
1414 domain = user.
left(at);
1415 user = user.
mid(at+1);
1421 key = clsid.
mid(at+2);
1422 clsid = clsid.
left(at);
1429 COAUTHIDENTITY authIdentity;
1430 authIdentity.UserLength = user.
length();
1431 authIdentity.User = authIdentity.UserLength ? (
ushort*)user.
utf16() : 0;
1432 authIdentity.DomainLength = domain.
length();
1433 authIdentity.Domain = authIdentity.DomainLength ? (
ushort*)domain.
utf16() : 0;
1434 authIdentity.PasswordLength = passwd.
length();
1435 authIdentity.Password = authIdentity.PasswordLength ? (
ushort*)passwd.
utf16() : 0;
1436 authIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
1438 COAUTHINFO authInfo;
1439 authInfo.dwAuthnSvc = RPC_C_AUTHN_WINNT;
1440 authInfo.dwAuthzSvc = RPC_C_AUTHZ_NONE;
1441 authInfo.pwszServerPrincName = 0;
1442 authInfo.dwAuthnLevel = RPC_C_AUTHN_LEVEL_DEFAULT;
1443 authInfo.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
1444 authInfo.pAuthIdentityData = &authIdentity;
1445 authInfo.dwCapabilities = 0;
1447 COSERVERINFO serverInfo;
1448 serverInfo.dwReserved1 = 0;
1449 serverInfo.dwReserved2 = 0;
1450 serverInfo.pAuthInfo = &authInfo;
1451 serverInfo.pwszName = (
wchar_t*)server.
utf16();
1453 IClassFactory *factory = 0;
1454 HRESULT res = CoGetClassObject(
QUuid(clsid), CLSCTX_REMOTE_SERVER, &serverInfo, IID_IClassFactory, (
void**)&factory);
1457 initializeLicensedHelper(factory, key, ptr);
1459 res = factory->CreateInstance(0, IID_IUnknown, (
void**)ptr);
1483 ((
QAxBase*)
this)->initialize(&
d->ptr);
1484 d->initialized =
true;
1488 return d->ptr->QueryInterface(uuid, iface);
1502 void readClassInfo();
1503 void readEnumInfo();
1504 void readInterfaceInfo();
1505 void readFuncsInfo(ITypeInfo *typeinfo,
ushort nFuncs);
1506 void readVarsInfo(ITypeInfo *typeinfo,
ushort nVars);
1507 void readEventInfo();
1508 void readEventInterface(ITypeInfo *eventinfo, IConnectionPoint *cpoint);
1512 classinfo_list.insert(key, value);
1547 RequestingEdit = 0x00400000,
1548 Bindable = 0x00800000
1554 MemberMethod = 0x00,
1555 MemberSignal = 0x04,
1557 MemberCompatibility = 0x10,
1558 MemberCloned = 0x20,
1559 MemberScriptable = 0x40,
1593 for (
int p = 0; p < plist.
count(); ++p) {
1595 if (param != replaceType(param)) {
1598 int paren = proto.
indexOf(
'(');
1615 return classinfo_list.
contains(key);
1629 QByteArray proto(replacePrototype(prototype));
1631 Method &signal = signal_list[proto];
1635 if (proto != prototype)
1643 return signal_list.
contains(prototype);
1649 QByteArray proto = replacePrototype(prototype);
1651 Method &slot = slot_list[proto];
1652 slot.
type = replaceType(type);
1654 slot.
flags = flags | MemberSlot;
1655 if (proto != prototype)
1663 return slot_list.
contains(prototype);
1678 propertyType.
chop(1);
1681 if (!propertyType.
isEmpty() && propertyType !=
"HRESULT") {
1682 prop.
type = replaceType(propertyType);
1683 if (prop.
type != propertyType)
1693 if (prop.
type ==
"QVariant") {
1694 prop.
typeId |= 0xff << 24;
1701 prop.
typeId |= vartype << 24;
1708 return property_list.
contains(name);
1713 return property_list.
value(name).type;
1724 return enum_list.
contains(enumname);
1750 return generator.
metaObject(parentObject,
"EnumInfo");
1759 if (S_OK != typeInfo->GetDocumentation(-1, &bstr, 0, 0, 0))
1763 SysFreeString(bstr);
1775 generator.
addSignal(
"exception(int,QString,QString,QString)",
"code,source,disc,help");
1776 generator.
addSignal(
"propertyChanged(QString)",
"name");
1780 if (S_OK != classInfo->GetDocumentation(-1, &bstr, 0, 0, 0))
1784 SysFreeString(bstr);
1789 classInfo->GetTypeAttr(&typeattr);
1791 int nInterfaces = typeattr->cImplTypes;
1792 classInfo->ReleaseTypeAttr(typeattr);
1796 if (S_OK != classInfo->GetRefTypeOfImplType(
index, &refType))
1800 classInfo->GetImplTypeFlags(
index, &flags);
1801 if (flags & IMPLTYPEFLAG_FRESTRICTED)
1804 ITypeInfo *interfaceInfo = 0;
1805 classInfo->GetRefTypeInfo(refType, &interfaceInfo);
1809 interfaceInfo->GetDocumentation(-1, &bstr, 0, 0, 0);
1811 SysFreeString(bstr);
1814 TYPEATTR *typeattr = 0;
1815 interfaceInfo->GetTypeAttr(&typeattr);
1817 if (flags & IMPLTYPEFLAG_FSOURCE) {
1818 if (typeattr && !(typeattr->wTypeFlags & TYPEFLAG_FHIDDEN))
1822 if (typeattr && !(typeattr->wTypeFlags & TYPEFLAG_FHIDDEN))
1831 interfaceInfo->ReleaseTypeAttr(typeattr);
1832 interfaceInfo->Release();
1840 : that(ax),
d(dptr), disp(0), dispInfo(0),
classInfo(0), typelib(0),
1857 typelib->GetDocumentation(-1, &bstr, 0, 0, 0);
1859 SysFreeString(bstr);
1871 addSignal(
"signal(QString,int,void*)",
"name,argc,argv");
1872 addSignal(
"exception(int,QString,QString,QString)",
"code,source,disc,help");
1873 addSignal(
"propertyChanged(QString)",
"name");
1891 HREFTYPE usertype = tdesc.hreftype;
1892 if (tdesc.vt != VT_USERDEFINED)
1896 ITypeInfo *usertypeinfo = 0;
1897 info->GetRefTypeInfo(usertype, &usertypeinfo);
1899 ITypeLib *usertypelib = 0;
1901 usertypeinfo->GetContainingTypeLib(&usertypelib, &index);
1904 BSTR typelibname = 0;
1905 usertypelib->GetDocumentation(-1, &typelibname, 0, 0, 0);
1907 SysFreeString(typelibname);
1910 BSTR usertypename = 0;
1911 usertypelib->GetDocumentation(index, &usertypename, 0, 0, 0);
1913 SysFreeString(usertypename);
1916 typeName = userTypeName;
1917 else if (userTypeName ==
"OLE_COLOR" || userTypeName ==
"VB_OLE_COLOR")
1918 typeName =
"QColor";
1919 else if (userTypeName ==
"IFontDisp" || userTypeName ==
"IFontDisp*" || userTypeName ==
"IFont" || userTypeName ==
"IFont*")
1921 else if (userTypeName ==
"Picture" || userTypeName ==
"Picture*")
1922 typeName =
"QPixmap";
1925 TYPEATTR *typeattr = 0;
1926 usertypeinfo->GetTypeAttr(&typeattr);
1928 switch(typeattr->typekind) {
1930 userTypeName =
guessTypes(typeattr->tdescAlias, usertypeinfo,
function);
1932 case TKIND_DISPATCH:
1935 userTypeName =
"IDispatch";
1938 userTypeName = typeLibName +
"::" + userTypeName;
1939 if (!qax_qualified_usertypes.
contains(userTypeName))
1940 qax_qualified_usertypes << userTypeName;
1945 userTypeName = typeLibName +
"::" + userTypeName;
1946 if (!qax_qualified_usertypes.
contains(
"enum " + userTypeName))
1947 qax_qualified_usertypes <<
"enum " + userTypeName;
1949 case TKIND_INTERFACE:
1951 userTypeName = typeLibName +
"::" + userTypeName;
1952 if (!qax_qualified_usertypes.
contains(userTypeName))
1953 qax_qualified_usertypes << userTypeName;
1956 if (!qax_qualified_usertypes.
contains(
"struct " + userTypeName))
1957 qax_qualified_usertypes <<
"struct "+ userTypeName;
1964 usertypeinfo->ReleaseTypeAttr(typeattr);
1965 typeName = userTypeName;
1967 usertypelib->Release();
1969 usertypeinfo->Release();
1975 #define VT_UNHANDLED(x) case VT_##x: qWarning("QAxBase: Unhandled type %s", #x); str = #x; break; 2040 str =
guessTypes(*tdesc.lptdesc, info,
function);
2041 switch(tdesc.lptdesc->vt) {
2064 if (str ==
"QFont" || str ==
"QPixmap") {
2067 }
else if (str ==
"void*") {
2073 if (str ==
"QColor")
2075 else if (str ==
"QDateTime")
2077 else if (str ==
"QVariantList")
2079 else if (str ==
"QByteArray")
2081 else if (str ==
"QStringList")
2085 else if (!str.
isEmpty() && str !=
"QFont" && str !=
"QPixmap" && str !=
"QVariant")
2090 switch(tdesc.lpadesc->tdescElem.vt) {
2096 str =
"QStringList";
2099 str =
"QVariantList";
2102 str =
guessTypes(tdesc.lpadesc->tdescElem, info,
function);
2104 str =
"QList<" + str +
'>';
2109 str =
guessTypes(tdesc.lpadesc->tdescElem, info,
function);
2115 case VT_USERDEFINED:
2128 if (tdesc.vt & VT_BYREF)
2138 IProvideClassInfo *provideClassInfo = 0;
2140 d->
ptr->QueryInterface(IID_IProvideClassInfo, (
void**)&provideClassInfo);
2141 if (provideClassInfo) {
2142 provideClassInfo->GetClassInfo(&
classInfo);
2143 TYPEATTR *typeattr = 0;
2149 QUuid clsid(typeattr->guid);
2151 #ifndef QAX_NO_CLASSINFO 2157 if (version !=
"0.0")
2163 provideClassInfo->Release();
2164 provideClassInfo = 0;
2173 disp->GetTypeInfo(index, LOCALE_USER_DEFAULT, &
dispInfo);
2186 while (tlfile.
isEmpty() && vit != versions.
end()) {
2214 TYPEATTR *classAttr;
2217 for (
int i = 0; i < classAttr->cImplTypes; ++i) {
2219 classInfo->GetImplTypeFlags(i, &typeFlags);
2220 if (typeFlags & IMPLTYPEFLAG_FSOURCE)
2224 if (S_OK ==
classInfo->GetRefTypeOfImplType(i, &hrefType))
2227 TYPEATTR *ifaceAttr;
2229 WORD typekind = ifaceAttr->typekind;
2230 dispInfo->ReleaseTypeAttr(ifaceAttr);
2232 if (typekind & TKIND_DISPATCH) {
2247 TYPEATTR *typeattr = 0;
2252 QUuid iid(typeattr->guid);
2255 dispInfo->ReleaseTypeAttr(typeattr);
2271 TLIBATTR *libAttr = 0;
2272 typelib->GetLibAttr(&libAttr);
2274 libUuid =
QUuid(libAttr->guid);
2275 typelib->ReleaseTLibAttr(libAttr);
2286 int enum_serial = 0;
2288 for (UINT i = 0; i <
index; ++i) {
2290 typelib->GetTypeInfoType(i, &typekind);
2291 if (typekind == TKIND_ENUM) {
2293 ITypeInfo *enuminfo = 0;
2294 typelib->GetTypeInfo(i, &enuminfo);
2301 if (
typelib->GetDocumentation(i, &enumname, 0, 0, 0) == S_OK) {
2303 SysFreeString(enumname);
2309 TYPEATTR *typeattr = 0;
2310 enuminfo->GetTypeAttr(&typeattr);
2313 for (UINT vd = 0; vd < (UINT)typeattr->cVars; ++vd) {
2314 VARDESC *vardesc = 0;
2315 enuminfo->GetVarDesc(vd, &vardesc);
2316 if (vardesc && vardesc->varkind == VAR_CONST) {
2317 int value = vardesc->lpvarValue->lVal;
2318 int memid = vardesc->memid;
2323 enuminfo->GetNames(memid, &valuename, 1, &maxNamesOut);
2326 SysFreeString(valuename);
2337 enuminfo->ReleaseVarDesc(vardesc);
2340 enuminfo->ReleaseTypeAttr(typeattr);
2341 enuminfo->Release();
2361 signalName +=
"Changed";
2366 eventSink->
addProperty(memid,
function, signalProto);
2373 if (isupper(prototype.
at(0))) {
2377 prototype[0] = toupper(prototype[0]);
2379 prototype =
set + prototype +
'(' +
propertyType(property) +
')';
2381 addSlot(0, prototype, property);
2391 type =
guessTypes(funcdesc->elemdescFunc.tdesc, typeinfo,
function);
2392 if ((type.
isEmpty() || type == hresult) && funcdesc->invkind == INVOKE_PROPERTYPUT && funcdesc->lprgelemdescParam) {
2393 type =
guessTypes(funcdesc->lprgelemdescParam->tdesc, typeinfo,
function);
2396 prototype =
function +
'(';
2397 if (funcdesc->invkind == INVOKE_FUNC && type == hresult)
2401 for (p = 1; p < names.
count(); ++p) {
2404 bool optional = p > (funcdesc->cParams - funcdesc->cParamsOpt);
2405 TYPEDESC tdesc = funcdesc->lprgelemdescParam[p-1].tdesc;
2406 PARAMDESC pdesc = funcdesc->lprgelemdescParam[p-1].paramdesc;
2409 if (pdesc.wParamFlags & PARAMFLAG_FRETVAL) {
2418 if (pdesc.wParamFlags & PARAMFLAG_FOUT && !ptype.
endsWith(
'&') && !ptype.
endsWith(
"**"))
2420 if (optional || pdesc.wParamFlags & PARAMFLAG_FOPT)
2422 else if (pdesc.wParamFlags & PARAMFLAG_FHASDEFAULT) {
2426 parameters << paramName;
2428 if (p < funcdesc->cParams && !(pdesc.wParamFlags & PARAMFLAG_FRETVAL))
2434 if (funcdesc->invkind == INVOKE_PROPERTYPUT && p == funcdesc->cParams) {
2435 TYPEDESC tdesc = funcdesc->lprgelemdescParam[p-1].tdesc;
2439 parameters <<
"rhs";
2441 prototype[prototype.
length()-1] =
')';
2454 TYPEATTR *typeattr = 0;
2455 typeinfo->GetTypeAttr(&typeattr);
2457 nFuncs = typeattr->cFuncs;
2458 typeinfo->ReleaseTypeAttr(typeattr);
2463 for (
ushort fd = 0; fd < nFuncs ; ++fd) {
2464 FUNCDESC *funcdesc = 0;
2465 typeinfo->GetFuncDesc(fd, &funcdesc);
2475 BSTR bstrNames[256];
2476 UINT maxNames = 255;
2478 typeinfo->GetNames(funcdesc->memid, (BSTR*)&bstrNames, maxNames, &maxNamesOut);
2481 for (p = 0; p < (int)maxNamesOut; ++p) {
2483 SysFreeString(bstrNames[p]);
2487 function = names.
at(0);
2488 if ((maxNamesOut == 3 &&
function ==
"QueryInterface") ||
2489 (maxNamesOut == 1 &&
function ==
"AddRef") ||
2490 (maxNamesOut == 1 &&
function ==
"Release") ||
2491 (maxNamesOut == 9 &&
function ==
"Invoke") ||
2492 (maxNamesOut == 6 &&
function ==
"GetIDsOfNames") ||
2493 (maxNamesOut == 2 &&
function ==
"GetTypeInfoCount") ||
2494 (maxNamesOut == 4 &&
function ==
"GetTypeInfo")) {
2495 typeinfo->ReleaseFuncDesc(funcdesc);
2499 prototype =
createPrototype( funcdesc, typeinfo, names, type, parameters);
2502 switch(funcdesc->invkind) {
2503 case INVOKE_PROPERTYGET:
2504 case INVOKE_PROPERTYPUT:
2505 if (funcdesc->cParams - funcdesc->cParamsOpt <= 1) {
2506 bool dontBreak =
false;
2508 if (funcdesc->invkind == INVOKE_PROPERTYGET && parameters.
count() && funcdesc->cParams - funcdesc->cParamsOpt) {
2512 if (funcdesc->invkind != INVOKE_PROPERTYGET)
2514 if (!(funcdesc->wFuncFlags & (FUNCFLAG_FNONBROWSABLE | FUNCFLAG_FHIDDEN)))
2516 if (!(funcdesc->wFuncFlags & FUNCFLAG_FRESTRICTED))
2518 if (funcdesc->wFuncFlags & FUNCFLAG_FREQUESTEDIT)
2523 if (funcdesc->wFuncFlags & FUNCFLAG_FBINDABLE && funcdesc->invkind == INVOKE_PROPERTYGET) {
2533 if (funcdesc->invkind == INVOKE_PROPERTYGET && funcdesc->cParams)
2537 if (!funcdesc->cParams) {
2543 if (funcdesc->invkind == INVOKE_PROPERTYGET)
2547 if (funcdesc->invkind == INVOKE_PROPERTYPUT &&
hasProperty(
function)) {
2551 }
else if (funcdesc->invkind == INVOKE_PROPERTYPUT &&
hasProperty(
function)) {
2554 if (funcdesc->cParams > 1)
2560 if (funcdesc->invkind == INVOKE_PROPERTYPUT) {
2563 if (funcdesc->cParams - funcdesc->cParamsOpt > 1) {
2567 if (isupper(prototype.
at(0))) {
2571 prototype[0] = toupper(prototype[0]);
2579 bool cloned =
false;
2583 for (p = 0; p < parameters.
count(); ++p) {
2584 pnames += parameters.
at(p);
2585 if (p < parameters.
count() - 1)
2598 if (lastParam == -1)
2599 lastParam = prototype.
indexOf(
'(') + 1;
2610 #if 0 // documentation in metaobject would be cool? 2613 info->GetDocumentation(funcdesc->memid, 0, &bstrDocu, 0, 0);
2615 SysFreeString(bstrDocu);
2617 desc +=
'[' + strDocu +
']';
2620 typeinfo->ReleaseFuncDesc(funcdesc);
2627 TYPEATTR *typeattr = 0;
2628 typeinfo->GetTypeAttr(&typeattr);
2630 nVars = typeattr->cVars;
2631 typeinfo->ReleaseTypeAttr(typeattr);
2636 for (
ushort vd = 0; vd < nVars; ++vd) {
2638 typeinfo->GetVarDesc(vd, &vardesc);
2643 if (vardesc->varkind != VAR_DISPATCH) {
2644 typeinfo->ReleaseVarDesc(vardesc);
2652 typeinfo->GetNames(vardesc->memid, &bstrName, maxNames, &maxNamesOut);
2653 if (maxNamesOut != 1 || !bstrName) {
2654 typeinfo->ReleaseVarDesc(vardesc);
2662 SysFreeString(bstrName);
2665 TYPEDESC typedesc = vardesc->elemdescVar.tdesc;
2666 variableType =
guessTypes(typedesc, typeinfo, variableName);
2671 if (!(vardesc->wVarFlags & VARFLAG_FREADONLY))
2673 if (!(vardesc->wVarFlags & (VARFLAG_FNONBROWSABLE | VARFLAG_FHIDDEN)))
2675 if (!(vardesc->wVarFlags & VARFLAG_FRESTRICTED))
2677 if (vardesc->wVarFlags & VARFLAG_FREQUESTEDIT)
2682 if (vardesc->wVarFlags & VARFLAG_FBINDABLE) {
2690 if (!(vardesc->wVarFlags & VARFLAG_FREADONLY))
2693 #if 0 // documentation in metaobject would be cool? 2696 info->GetDocumentation(vardesc->memid, 0, &bstrDocu, 0, 0);
2698 SysFreeString(bstrDocu);
2700 desc +=
'[' + strDocu +
']';
2703 typeinfo->ReleaseVarDesc(vardesc);
2713 int interface_serial = 0;
2720 typeinfo->GetTypeAttr(&typeattr);
2721 bool interesting =
true;
2724 nFuncs = typeattr->cFuncs;
2725 nVars = typeattr->cVars;
2726 nImpl = typeattr->cImplTypes;
2728 if ((typeattr->typekind == TKIND_DISPATCH || typeattr->typekind == TKIND_INTERFACE) &&
2729 (typeattr->guid != IID_IDispatch && typeattr->guid != IID_IUnknown)) {
2730 #ifndef QAX_NO_CLASSINFO 2733 QUuid uuid(typeattr->guid);
2739 typeinfo->ReleaseTypeAttr(typeattr);
2741 interesting =
false;
2742 typeinfo->ReleaseTypeAttr(typeattr);
2752 typeinfo->Release();
2759 typeinfo->GetRefTypeOfImplType(0, &pRefType);
2760 ITypeInfo *baseInfo = 0;
2761 typeinfo->GetRefTypeInfo(pRefType, &baseInfo);
2762 typeinfo->Release();
2763 if (typeinfo == baseInfo) {
2764 baseInfo->Release();
2768 typeinfo = baseInfo;
2774 TYPEATTR *eventattr;
2775 eventinfo->GetTypeAttr(&eventattr);
2778 if (eventattr->typekind != TKIND_DISPATCH) {
2779 eventinfo->ReleaseTypeAttr(eventattr);
2786 cpoint->GetConnectionInterface(&conniid);
2791 eventSink->
advise(cpoint, conniid);
2796 for (UINT fd = 0; fd < (UINT)eventattr->cFuncs; ++fd) {
2798 eventinfo->GetFuncDesc(fd, &funcdesc);
2801 if (funcdesc->invkind != INVOKE_FUNC ||
2802 funcdesc->funckind != FUNC_DISPATCH) {
2803 eventinfo->ReleaseTypeAttr(eventattr);
2804 eventinfo->ReleaseFuncDesc(funcdesc);
2813 BSTR bstrNames[256];
2814 UINT maxNames = 255;
2816 eventinfo->GetNames(funcdesc->memid, (BSTR*)&bstrNames, maxNames, &maxNamesOut);
2819 for (p = 0; p < (int)maxNamesOut; ++p) {
2821 SysFreeString(bstrNames[p]);
2825 function = names.
at(0);
2827 prototype =
createPrototype( funcdesc, eventinfo, names, type, parameters);
2830 for (p = 0; p < parameters.
count(); ++p) {
2831 pnames += parameters.
at(p);
2832 if (p < parameters.
count() - 1)
2838 eventSink->
addSignal(funcdesc->memid, prototype);
2840 #if 0 // documentation in metaobject would be cool? 2843 eventinfo->GetDocumentation(funcdesc->memid, 0, &bstrDocu, 0, 0);
2845 SysFreeString(bstrDocu);
2847 desc +=
'[' + strDocu +
']';
2850 eventinfo->ReleaseFuncDesc(funcdesc);
2852 eventinfo->ReleaseTypeAttr(eventattr);
2857 int event_serial = 0;
2858 IConnectionPointContainer *cpoints = 0;
2860 d->
ptr->QueryInterface(IID_IConnectionPointContainer, (
void**)&cpoints);
2863 IEnumConnectionPoints *epoints = 0;
2864 cpoints->EnumConnectionPoints(&epoints);
2867 IConnectionPoint *cpoint = 0;
2871 if (cpoint) cpoint->Release();
2873 HRESULT hr = epoints->Next(c, &cpoint, &c);
2874 if (!c || hr != S_OK)
2878 cpoint->GetConnectionInterface(&conniid);
2880 QUuid connuuid(conniid);
2884 #ifndef QAX_NO_CLASSINFO 2893 if (conniid == IID_IPropertyNotifySink) {
2897 eventSink->
advise(cpoint, conniid);
2901 ITypeInfo *eventinfo = 0;
2903 typelib->GetTypeInfoOfGuid(conniid, &eventinfo);
2907 cpointlist.
append(connuuid);
2910 eventinfo->Release();
2913 if (cpoint) cpoint->Release();
2916 TYPEATTR *typeattr = 0;
2919 for (
int i = 0; i < typeattr->cImplTypes; ++i) {
2922 if (!(flags & IMPLTYPEFLAG_FSOURCE))
2925 if (S_OK !=
classInfo->GetRefTypeOfImplType(i, &reference))
2927 ITypeInfo *eventInfo = 0;
2928 classInfo->GetRefTypeInfo(reference, &eventInfo);
2931 TYPEATTR *eventattr = 0;
2932 eventInfo->GetTypeAttr(&eventattr);
2934 IConnectionPoint *cpoint = 0;
2935 cpoints->FindConnectionPoint(eventattr->guid, &cpoint);
2937 if (eventattr->guid == IID_IPropertyNotifySink) {
2941 eventSink->
advise(cpoint, eventattr->guid);
2948 eventInfo->ReleaseTypeAttr(eventattr);
2950 eventInfo->Release();
2966 IConnectionPointContainer *cpoints = 0;
2967 d->
ptr->QueryInterface(IID_IConnectionPointContainer, (
void**)&cpoints);
2974 IConnectionPoint *cpoint = 0;
2975 cpoints->FindConnectionPoint(iid, &cpoint);
2978 sink->
advise(cpoint, iid);
3001 typelib->GetDocumentation(-1, &bstr, 0, 0, 0);
3003 SysFreeString(bstr);
3014 #ifndef QAX_NO_CLASSINFO 3022 uint int_data_size = 1+1+2+2+2+2+1;
3031 int_data_size += (*it).count() * 2;
3034 uint *int_data =
new uint[int_data_size];
3040 int_data[5] = int_data[3] + int_data[2] * 2;
3042 int_data[7] = int_data[5] + int_data[4] * 5;
3044 int_data[9] = int_data[7] + int_data[6] * 3;
3045 int_data[int_data_size - 1] = 0;
3053 uint offset = int_data[3];
3059 int_data[offset++] = stringdata.
length();
3062 int_data[offset++] = stringdata.length();
3063 stringdata += value;
3073 if (!
it.value().realPrototype.isEmpty())
3076 int flags =
it.value().flags;
3078 int_data[offset++] = stringdata.length();
3081 int_data[offset++] = stringdata.
length();
3082 stringdata += parameters;
3084 int_data[offset++] = stringdata.length();
3087 int_data[offset++] = stringdata.length();
3090 int_data[offset++] = flags;
3098 if (!
it.value().realPrototype.isEmpty())
3101 int flags =
it.value().flags;
3103 int_data[offset++] = stringdata.length();
3106 int_data[offset++] = stringdata.
length();
3107 stringdata += parameters;
3109 int_data[offset++] = stringdata.length();
3112 int_data[offset++] = stringdata.length();
3115 int_data[offset++] = flags;
3124 if (!realType.isEmpty() && realType !=
type)
3126 uint flags =
it.value().typeId;
3128 int_data[offset++] = stringdata.length();
3131 int_data[offset++] = stringdata.length();
3134 int_data[offset++] = flags;
3143 int count =
it.value().count();
3145 int_data[offset++] = stringdata.length();
3148 int_data[offset++] = flags;
3149 int_data[offset++] = count;
3150 int_data[offset++] = value_offset;
3151 value_offset += count * 2;
3159 int value = (*it2).second;
3160 int_data[offset++] = stringdata.length();
3163 int_data[offset++] = value;
3166 Q_ASSERT(offset == int_data_size-1);
3168 char *string_data =
new char[stringdata.length()];
3169 memcpy(string_data, stringdata, stringdata.length());
3172 metaobj->
d.
data = int_data;
3212 102, 80, 8, 8, 0x05,
3215 149, 141, 0x0a095103,
3221 "QAxBase\0\0name,argc,argv\0signal(QString,int,void*)\0name\0" 3222 "propertyChanged(QString)\0code,source,desc,help\0" 3223 "exception(int,QString,QString,QString)\0QString\0control\0" 3249 const QMetaObject* parentObject = parentMetaObject();
3256 #ifndef QT_NO_THREAD 3263 if (qObject()->isWidgetType())
3287 IEnumConnectionPoints *epoints = 0;
3289 IConnectionPointContainer *cpoints = 0;
3290 d->
ptr->QueryInterface(IID_IConnectionPointContainer, (
void**)&cpoints);
3294 cpoints->EnumConnectionPoints(&epoints);
3303 ITypeInfo *typeinfo = 0;
3306 disp->GetTypeInfo(0, LOCALE_USER_DEFAULT, &typeinfo);
3308 typeinfo->GetContainingTypeLib(&typelib, &index);
3316 bool haveEnumInfo =
false;
3319 IConnectionPoint *cpoint = 0;
3322 if (cpoint) cpoint->Release();
3324 epoints->Next(c, &cpoint, &c);
3329 cpoint->GetConnectionInterface(&conniid);
3336 ITypeInfo *eventinfo = 0;
3337 typelib->GetTypeInfoOfGuid(conniid, &eventinfo);
3339 TYPEATTR *eventAttr;
3340 eventinfo->GetTypeAttr(&eventAttr);
3342 eventinfo->Release();
3346 TYPEKIND eventKind = eventAttr->typekind;
3347 eventinfo->ReleaseTypeAttr(eventAttr);
3348 if (eventKind != TKIND_DISPATCH) {
3349 eventinfo->Release();
3362 if (!haveEnumInfo) {
3368 haveEnumInfo =
true;
3371 eventSink->
advise(cpoint, conniid);
3373 eventinfo->Release();
3375 if (cpoint) cpoint->Release();
3401 case DISP_E_BADPARAMCOUNT:
3402 qWarning(
"QAxBase: Error calling IDispatch member %s: Bad parameter count", name.
toLatin1().
data());
3404 case DISP_E_BADVARTYPE:
3405 qWarning(
"QAxBase: Error calling IDispatch member %s: Bad variant type", name.
toLatin1().
data());
3407 case DISP_E_EXCEPTION:
3409 bool printWarning =
true;
3410 unsigned short code = -1;
3413 int exceptionSignal = mo->
indexOfSignal(
"exception(int,QString,QString,QString)");
3414 if (exceptionSignal >= 0) {
3415 if (exc->pfnDeferredFillIn)
3416 exc->pfnDeferredFillIn(exc);
3418 code = exc->wCode ? exc->wCode : exc->scode;
3422 uint helpContext = exc->dwHelpContext;
3424 if (helpContext && !help.
isEmpty())
3428 void *argv[] = {0, &code, &source, &desc, &help};
3430 printWarning =
false;
3434 qWarning(
"QAxBase: Error calling IDispatch member %s: Exception thrown by server", name.
toLatin1().
data());
3439 qWarning(
" Connect to the exception(int,QString,QString,QString) signal to catch this exception");
3443 case DISP_E_MEMBERNOTFOUND:
3444 qWarning(
"QAxBase: Error calling IDispatch member %s: Member not found", name.
toLatin1().
data());
3446 case DISP_E_NONAMEDARGS:
3447 qWarning(
"QAxBase: Error calling IDispatch member %s: No named arguments", name.
toLatin1().
data());
3449 case DISP_E_OVERFLOW:
3452 case DISP_E_PARAMNOTFOUND:
3453 qWarning(
"QAxBase: Error calling IDispatch member %s: Parameter %d not found", name.
toLatin1().
data(), argerr);
3455 case DISP_E_TYPEMISMATCH:
3456 qWarning(
"QAxBase: Error calling IDispatch member %s: Type mismatch in parameter %d", name.
toLatin1().
data(), argerr);
3458 case DISP_E_UNKNOWNINTERFACE:
3459 qWarning(
"QAxBase: Error calling IDispatch member %s: Unknown interface", name.
toLatin1().
data());
3461 case DISP_E_UNKNOWNLCID:
3462 qWarning(
"QAxBase: Error calling IDispatch member %s: Unknown locale ID", name.
toLatin1().
data());
3464 case DISP_E_PARAMNOTOPTIONAL:
3465 qWarning(
"QAxBase: Error calling IDispatch member %s: Non-optional parameter missing", name.
toLatin1().
data());
3483 if (propname ==
"control") {
3508 if (dispid == DISPID_UNKNOWN)
3518 EXCEPINFO excepinfo;
3519 memset(&excepinfo, 0,
sizeof(excepinfo));
3528 params.cNamedArgs = 0;
3529 params.rgdispidNamedArgs = 0;
3532 hres = disp->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, ¶ms, &arg, &excepinfo, 0);
3548 DISPID dispidNamed = DISPID_PROPERTYPUT;
3550 params.cNamedArgs = 1;
3551 params.rgdispidNamedArgs = &dispidNamed;
3552 params.rgvarg = &arg;
3555 arg.scode = DISP_E_TYPEMISMATCH;
3576 if (arg.vt == VT_EMPTY || arg.vt == VT_ERROR) {
3577 qWarning(
"QAxBase::setProperty: Unhandled property type %s", prop.
typeName());
3581 hres = disp->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, ¶ms, 0, &excepinfo, &argerr);
3610 slotname.truncate(slotname.indexOf(
'('));
3613 bool isProperty =
false;
3618 if (dispid == DISPID_UNKNOWN && slotname.toLower().startsWith(
"set")) {
3620 slotname = slotname.right(slotname.length() - 3);
3624 if (dispid == DISPID_UNKNOWN)
3632 DISPID dispidNamed = DISPID_PROPERTYPUT;
3634 params.cNamedArgs = isProperty ? 1 : 0;
3635 params.rgdispidNamedArgs = isProperty ? &dispidNamed : 0;
3640 params.rgvarg = static_rgvarg;
3642 params.rgvarg =
new VARIANTARG[params.cArgs];
3646 for (p = 0; p < (int)params.cArgs; ++p) {
3655 if (type ==
"IDispatch*")
3656 qvar.
setValue(*(IDispatch**)v[p+1]);
3657 else if (type ==
"IUnknown*")
3658 qvar.
setValue(*(IUnknown**)v[p+1]);
3659 else if (type ==
"QVariant")
3662 qvar = *(
int*)v[p + 1];
3675 EXCEPINFO excepinfo;
3676 memset(&excepinfo, 0,
sizeof(excepinfo));
3678 WORD wFlags = isProperty ? DISPATCH_PROPERTYPUT : DISPATCH_METHOD | DISPATCH_PROPERTYGET;
3679 hres = disp->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, wFlags, ¶ms, &ret, &excepinfo, &argerr);
3682 if (hres == S_OK && ret.vt != VT_EMPTY)
3686 for (p = 0; p < (int)params.cArgs; ++p) {
3693 for (p = 0; p < (int)params.cArgs; ++p)
3695 if (params.rgvarg != static_rgvarg)
3696 delete [] params.rgvarg;
3709 qWarning(
"QAxBase::qt_metacall: Object is not initialized, or initialization failed");
3722 id = internalInvoke(call,
id, v);
3731 id = internalProperty(call,
id, v);
3747 #ifdef QT_CHECK_STATE 3753 if (disptype == DISPATCH_METHOD) {
3756 for (
int i = 0; i < metaObject->
methodCount(); ++i) {
3765 qWarning(
"QAxBase::dynamicCallHelper: %s: No such property in %s [%s]", name.
data(), that->
control().
toLatin1().
data(), coclass ? coclass:
"unknown");
3768 char f0 =
function.toLower().at(0);
3771 if (!signature.isEmpty() && signature.toLower().at(0) == f0)
3772 qWarning(
"\t\t%s", signature.data());
3787 qWarning(
"QAxBase::dynamicCallHelper: Object is not initialized, or initialization failed");
3793 qWarning(
"QAxBase::dynamicCallHelper: Object does not support automation");
3801 int varc = vars.
count();
3807 VARIANTARG *res = (VARIANTARG*)inout;
3809 unsigned short disptype;
3814 if (
function.contains(
'(')) {
3815 disptype = DISPATCH_METHOD | DISPATCH_PROPERTYGET;
3824 function.truncate(
function.indexOf(
'('));
3825 parse = !varc && normFunction.
length() >
function.length() + 2;
3828 args = args.
mid(
function.length() + 1);
3833 bool inString =
false;
3834 bool inEscape =
false;
3835 while (index < (
int)args.
length()) {
3853 if (!inEscape && inString) {
3860 inString = !inString;
3866 if (!inString && curArg.
isEmpty())
3875 vars << curArg.
mid(1, curArg.
length() - 2);
3878 bool isDouble =
false;
3879 int number = curArg.
toInt(&isNumber);
3880 double dbl = curArg.
toDouble(&isDouble);
3883 }
else if (isDouble) {
3886 bool isEnum =
false;
3887 for (
int enumIndex = 0; enumIndex < mo->
enumeratorCount(); ++enumIndex) {
3909 varc = vars.
count();
3921 disptype = DISPATCH_PROPERTYPUT;
3923 disptype = DISPATCH_PROPERTYGET;
3929 for (
int i = 0; i < varc; ++i) {
3931 VariantInit(arg + (varc - i - 1));
3934 if (disptype == DISPATCH_PROPERTYPUT)
3936 else if (parse || disptype == DISPATCH_PROPERTYGET)
3943 if (enumIndex != -1) {
3949 if (arg[varc - i - 1].vt == VT_EMPTY)
3955 if (dispid == DISPID_UNKNOWN &&
function.toLower().startsWith(
"set")) {
3956 function =
function.mid(3);
3958 disptype = DISPATCH_PROPERTYPUT;
3961 if (dispid == DISPID_UNKNOWN) {
3962 #ifdef QT_CHECK_STATE 3969 DISPID dispidNamed = DISPID_PROPERTYPUT;
3971 params.cArgs = varc;
3972 params.cNamedArgs = (disptype == DISPATCH_PROPERTYPUT) ? 1 : 0;
3973 params.rgdispidNamedArgs = (disptype == DISPATCH_PROPERTYPUT) ? &dispidNamed : 0;
3974 params.rgvarg = arg;
3975 EXCEPINFO excepinfo;
3976 memset(&excepinfo, 0,
sizeof(excepinfo));
3979 HRESULT hres = disp->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, disptype, ¶ms, res, &excepinfo, &argerr);
3981 if (disptype == (DISPATCH_METHOD|DISPATCH_PROPERTYGET) && hres == S_OK && varc) {
3982 for (
int i = 0; i < varc; ++i)
3983 if (arg[varc-i-1].vt & VT_BYREF)
3988 for (
int i = 0; i < varc; ++i)
3990 if (arg && arg != staticarg)
4062 case 2: var = var2;
break;
4063 case 3: var = var3;
break;
4064 case 4: var = var4;
break;
4065 case 5: var = var5;
break;
4066 case 6: var = var6;
break;
4067 case 7: var = var7;
break;
4068 case 8: var = var8;
break;
4073 return dynamicCall(
function, vars);
4097 if (!dynamicCallHelper(
function, &res, vars, rettype))
4146 case 2: var = var2;
break;
4147 case 3: var = var3;
break;
4148 case 4: var = var4;
break;
4149 case 5: var = var5;
break;
4150 case 6: var = var6;
break;
4151 case 7: var = var7;
break;
4152 case 8: var = var8;
break;
4157 return querySubObject(name, vars);
4176 if (!dynamicCallHelper(name, &res, vars, rettype))
4182 if (rettype.
isEmpty() || rettype ==
"IDispatch*" || rettype ==
"QVariant") {
4183 object =
new QAxObject(res.pdispVal, qObject());
4188 res.pdispVal->AddRef();
4191 ((
QAxBase*)
object)->d->tryCache =
true;
4196 if (rettype.
isEmpty() || rettype ==
"IUnknown*") {
4197 object =
new QAxObject(res.punkVal, qObject());
4202 res.punkVal->AddRef();
4205 ((
QAxBase*)
object)->d->tryCache =
true;
4209 #ifdef QT_CHECK_STATE 4212 qWarning(
"QAxBase::querySubObject: %s: Error calling function or property in %s (%s)" 4213 , name, control().toLatin1().
data(), coclass ? coclass:
"unknown");
4218 #ifdef QT_CHECK_STATE 4221 qWarning(
"QAxBase::querySubObject: %s: Method or property is not of interface type in %s (%s)" 4222 , name, control().toLatin1().
data(), coclass ? coclass:
"unknown");
4241 if (iid == IID_IUnknown)
4243 else if (iid == IID_IPropertyBag)
4246 return E_NOINTERFACE;
4253 return InterlockedIncrement(&ref);
4257 LONG refCount = InterlockedDecrement(&ref);
4314 IPersistPropertyBag *persist = 0;
4315 d->
ptr->QueryInterface(IID_IPersistPropertyBag, (
void**)&persist);
4319 persist->Save(pbag,
false,
true);
4350 initialize(&
d->
ptr);
4356 IPersistPropertyBag *persist = 0;
4357 d->
ptr->QueryInterface(IID_IPersistPropertyBag, (
void**)&persist);
4362 persist->Load(pbag, 0);
4370 qObject()->setProperty(
property.name(), var);
4430 if (cn ==
"QAxObject" || cn ==
"QAxWidget" || cn ==
"QAxBase") {
4439 qvar =
QVariant(qRegisterMetaType<QObject*>(cn +
'*'), &
object);
4513 #endif //QT_NO_WIN_ACTIVEQT The QVariant class acts like a union for the most common Qt data types.
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QStringList verbs() const
Returns the list of verbs that the COM object can execute.
static QHash< QString, QAxMetaObject * > mo_cache
HRESULT __stdcall GetIDsOfNames(const _GUID &, wchar_t **, unsigned int, unsigned long, long *)
void chop(int n)
Removes n bytes from the end of the byte array.
bool qax_dispatchEqualsIDispatch
void * qax_createObjectWrapper(int metaType, IUnknown *iface)
void clearVARIANT(VARIANT *var)
HRESULT __stdcall Invoke(DISPID dispIdMember, REFIID riid, LCID, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *, EXCEPINFO *, UINT *)
bool isNull() const
Returns true if there is no COM object loaded by this wrapper; otherwise return false.
void truncate(int pos)
Truncates the byte array at index position pos.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
static mach_timebase_info_data_t info
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
virtual ~QAxBase()
Shuts down the COM object and destroys the QAxBase object.
#define QT_END_NAMESPACE
This macro expands to.
virtual const QMetaObject * metaObject() const
The metaobject is generated on the fly from the information provided by the IDispatch and ITypeInfo i...
const Key key(const T &value) const
Returns the first key with value value.
The QMutex class provides access serialization between threads.
void clear()
Removes all items from the hash.
char * data()
Returns a pointer to the data stored in the byte array.
QVariant dynamicCall(const char *name, const QVariant &v1=QVariant(), const QVariant &v2=QVariant(), const QVariant &v3=QVariant(), const QVariant &v4=QVariant(), const QVariant &v5=QVariant(), const QVariant &v6=QVariant(), const QVariant &v7=QVariant(), const QVariant &v8=QVariant())
Calls the COM object's method function, passing the parameters var1, var1, var2, var3, var4, var5, var6, var7 and var8, and returns the value returned by the method, or an invalid QVariant if the method does not return a value or when the function call failed.
const QChar at(int i) const
Returns the character at the given index position in the string.
QMap< DISPID, QByteArray > sigs
QVariant asVariant() const
Returns a QVariant that wraps the COM object.
bool initializeActive(IUnknown **ptr)
Connects to an active instance running on the current machine, and returns the IUnknown interface to ...
bool dynamicCallHelper(const char *name, void *out, QList< QVariant > &var, QByteArray &type)
void initializeFrom(QAxBase *that)
Used by subclasses generated with dumpcpp to implement cast-operators.
QString control() const
the name of the COM object wrapped by this QAxBase object.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
#define it(className, varName)
bool initializeRemote(IUnknown **ptr)
Creates the instance on a remote server, and returns the IUnknown interface to the object in ptr...
The QSettings class provides persistent platform-independent application settings.
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
QList< QByteArray > qax_qualified_usertypes
virtual QObject * qObject() const =0
unsigned long __stdcall AddRef()
#define at(className, varName)
void internalRelease()
Used by subclasses generated with dumpcpp to balance reference count.
void disableClassInfo()
Disables the class info generation for this ActiveX container.
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
void beginGroup(const QString &prefix)
Appends prefix to the current group.
void advise(IConnectionPoint *cp, IID iid)
static void qax_noSuchFunction(int disptype, const QByteArray &name, const QByteArray &function, const QAxBase *that)
static void clear(QVariant::Private *d)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
HRESULT __stdcall OnChanged(DISPID dispID)
int count(const Key &key) const
Returns the number of items associated with key key.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
void setPropertyBag(const PropertyBag &)
Sets the properties of the COM object to the corresponding values in bag.
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
unsigned long __stdcall Release()
virtual void setPropertyWritable(const char *, bool)
Sets the property prop to writable if ok is true, otherwise sets prop to be read-only.
QByteArray toLower() const
Returns a lowercase copy of the byte array.
static bool checkHRESULT(HRESULT hres, EXCEPINFO *exc, QAxBase *that, const QString &name, uint argerr)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static bool isNumber(char s)
HRESULT __stdcall Read(LPCOLESTR name, VARIANT *var, IErrorLog *)
int count(const T &t) const
Returns the number of occurrences of value in the list.
HRESULT __stdcall GetTypeInfo(UINT, LCID, ITypeInfo **)
HRESULT __stdcall OnRequestEdit(DISPID dispID)
T & value() const
Returns a modifiable reference to the current item's value.
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
The QAxObject class provides a QObject that wraps a COM object.
void setValue(const T &value)
Stores a copy of value.
The QObject class is the base class of all Qt objects.
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
QString toString() const
Returns the string representation of this QUuid.
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
The QChar class provides a 16-bit Unicode character.
const T value(const Key &key) const
Returns the value associated with the key.
bool isNull() const
Returns true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns false...
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
iterator Iterator
Qt-style synonym for QList::iterator.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
QHash< QUuid, QAxEventSink * > eventSink
static QString toString(Register *reg, int type, bool *ok=0)
void append(const T &t)
Inserts value at the end of the list.
unsigned long __stdcall Release()
#define QT_BEGIN_NAMESPACE
This macro expands to.
QAxObject * querySubObject(const char *name, const QVariant &v1=QVariant(), const QVariant &v2=QVariant(), const QVariant &v3=QVariant(), const QVariant &v4=QVariant(), const QVariant &v5=QVariant(), const QVariant &v6=QVariant(), const QVariant &v7=QVariant(), const QVariant &v8=QVariant())
Returns a pointer to a QAxObject wrapping the COM object provided by the method or property name...
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
int lastIndexOf(char c, int from=-1) const
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from.
static bool isEmpty(const char *str)
virtual const char * className() const =0
unsigned long __stdcall AddRef()
int internalProperty(QMetaObject::Call, int index, void **v)
int internalInvoke(QMetaObject::Call, int index, void **v)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
bool contains(const T &value) const
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
static const uint qt_meta_data_QAxBase[]
const QChar * unicode() const
Returns a '\0'-terminated Unicode representation of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
HRESULT __stdcall QueryInterface(REFIID riid, void **ppvObject)
const T value(const Key &key) const
Returns the value associated with the key key.
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
virtual int qt_metacall(QMetaObject::Call, int, void **)
bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeName, bool out)
void addProperty(DISPID propid, const char *name, const char *signal)
Q_CORE_EXPORT void qWarning(const char *,...)
const_iterator insert(const T &value)
IConnectionPoint * cpoint
void addSignal(DISPID memid, const char *name)
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QMetaObject * qax_readEnumInfo(ITypeLib *typeLib, const QMetaObject *parentObject)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QMetaObject * qax_readClassInfo(ITypeLib *typeLib, ITypeInfo *classInfo, const QMetaObject *parentObject)
Type
This enum type defines the types of variable that a QVariant can contain.
void connectNotify()
Connects to all event interfaces of the object.
bool setControl(const QString &)
static QChar fromLatin1(char c)
Converts the Latin-1 character c to its equivalent QChar.
const T * ptr(const T &t)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
virtual bool propertyWritable(const char *) const
Returns true if the property prop is writable; otherwise returns false.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
const char * typeName() const
Returns the name of the type stored in the variant.
bool initializeLicensedHelper(void *factory, const QString &key, IUnknown **ptr)
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
bool initializeFromFile(IUnknown **ptr)
Creates the COM object handling the filename in the control property, and returns the IUnknown interf...
void disableMetaObject()
Disables the meta object generation for this ActiveX container.
QAxEventSink(QAxBase *com)
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
#define TRUE
Synonym for true.
int length() const
Same as size().
bool QVariantToVoidStar(const QVariant &var, void *data, const QByteArray &typeName, uint type)
Copies the data in var into data.
const char * constData() const
Returns a pointer to the data stored in the byte array.
static QByteArray prototype(const QList< QByteArray > ¶meterTypes, const QList< QByteArray > ¶meterNames, bool *ok)
int remove(const Key &key)
Removes all the items that have the key key from the map.
QMap< DISPID, QByteArray > signalMap() const
HRESULT __stdcall QueryInterface(REFIID iid, LPVOID *iface)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
static QMutex cache_mutex
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
static QAuServer & server()
uint qstrlen(const char *str)
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
QByteArray findProperty(DISPID dispID)
QMap< DISPID, QByteArray > propsigs
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
long indexOfVerb(const QString &verb) const
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
QMetaObject * qax_readInterfaceInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QMetaObject *parentObject)
void clear()
Clears the contents of the string and makes it empty.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
static QByteArray paramType(const QByteArray &ptype, bool *out)
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
QAxMetaObject * internalMetaObject() const
Type type() const
Returns the storage type of the value stored in the variant.
PropertyBag propertyBag() const
Returns a name:value map of all the properties exposed by the COM object.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
const void * constData() const
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
static BSTR QStringToBSTR(const QString &str)
static QMetaObject qaxobject_staticMetaObject
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
bool initializeLicensed(IUnknown **ptr)
Creates an instance of a licensed control, and returns the IUnknown interface to the object in ptr...
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
bool isEmpty() const
Returns true if the map contains no items; otherwise returns false.
QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint type)
Returns arg as a QVariant of type type.
static const char *const type_conversion[][2]
HRESULT __stdcall GetTypeInfoCount(unsigned int *)
QMap< DISPID, QByteArray > propertyMap() const
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
QMap< DISPID, QByteArray > propSignalMap() const
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
char toLatin1() const
Returns the Latin-1 character equivalent to the QChar, or 0.
QVariant property(const char *name) const
Returns the value of the object's name property.
void disableEventSink()
Disables the event sink implementation for this ActiveX container.
static const char qt_meta_stringdata_QAxBase[]
static QHash< QUuid, QMap< QByteArray, QList< QPair< QByteArray, int > > > > enum_cache
T takeLast()
Removes the last item in the list and returns it.
int count(const Key &key) const
Returns the number of items associated with the key.
QByteArray & replace(int index, int len, const char *s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
QUuid connectionInterface() const
QMap< DISPID, QByteArray > props
QAxMetaObject * metaObject()
static QMetaObject qaxwidget_staticMetaObject
bool signalsBlocked() const
Returns true if signals are blocked; otherwise returns false.
char at(int i) const
Returns the character at index position i in the byte array.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
void reserve(int size)
Attempts to allocate memory for at least size bytes.
static Type nameToType(const char *name)
Converts the string representation of the storage type given in name, to its enum representation...
IDispatch * dispatch() const
long queryInterface(const QUuid &, void **) const
Requests the interface uuid from the COM object and sets the value of iface to the provided interface...
virtual void clear()
Disconnects and destroys the COM object.
QMap< QByteArray, bool > propWritable
QAxBase(IUnknown *iface=0)
Creates a QAxBase object that wraps the COM object iface.
static bool signalHasReceivers(QObject *qobject, const char *signalName)
virtual bool initialize(IUnknown **ptr)
This virtual function is called by setControl() and creates the requested COM object.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
The QAxBase class is an abstract class that provides an API to initialize and access a COM object...
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
QMap< QString, LONG > verbs
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
HRESULT __stdcall Write(LPCOLESTR name, VARIANT *var)
void clear()
Clears the contents of the byte array and makes it empty.
The QUuid class stores a Universally Unique Identifier (UUID).
The QMap class is a template class that provides a skip-list-based dictionary.
static bool isNull(const QVariant::Private *d)
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
void qErrnoWarning(const char *msg,...)