diff options
Diffstat (limited to 'src/activeqt')
21 files changed, 1559 insertions, 1559 deletions
diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index 0d5ab65..11c943c 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -239,7 +239,7 @@ static const char *const type_conversion[][2] = \class QAxEventSink \brief The QAxEventSink class implements the event sink for all - IConnectionPoints implemented in the COM object. + IConnectionPoints implemented in the COM object. */ class QAxEventSink : public IDispatch, public IPropertyNotifySink @@ -292,14 +292,14 @@ public: void addSignal(DISPID memid, const char *name) { - QByteArray signalname = name; - int pi = signalname.indexOf('('); + QByteArray signalname = name; + int pi = signalname.indexOf('('); int i = 0; while (type_conversion[i][0]) { int ti = pi; int len = int(strlen(type_conversion[i][0])); while ((ti = signalname.indexOf(type_conversion[i][0], ti)) != -1) - signalname.replace(ti, len, type_conversion[i][1]); + signalname.replace(ti, len, type_conversion[i][1]); ++i; } @@ -627,12 +627,12 @@ public: QString ctrl; QHash<QUuid, QAxEventSink*> eventSink; - uint useEventSink :1; - uint useMetaObject :1; - uint useClassInfo :1; + uint useEventSink :1; + uint useMetaObject :1; + uint useClassInfo :1; uint cachedMetaObject :1; - uint initialized :1; - uint tryCache :1; + uint initialized :1; + uint tryCache :1; IUnknown *ptr; mutable IDispatch *disp; @@ -1089,9 +1089,9 @@ void QAxBase::disableEventSink() */ void QAxBase::disableMetaObject() { - d->useMetaObject = false; - d->useEventSink = false; - d->useClassInfo = false; + d->useMetaObject = false; + d->useEventSink = false; + d->useClassInfo = false; } /*! @@ -2925,8 +2925,8 @@ void MetaObjectGenerator::readEventInfo() if (cpoint) cpoint->Release(); epoints->Release(); } else if (classInfo) { // no enumeration - search source interfaces and ask for those - TYPEATTR *typeattr = 0; - classInfo->GetTypeAttr(&typeattr); + TYPEATTR *typeattr = 0; + classInfo->GetTypeAttr(&typeattr); if (typeattr) { for (int i = 0; i < typeattr->cImplTypes; ++i) { int flags = 0; diff --git a/src/activeqt/container/qaxbase.h b/src/activeqt/container/qaxbase.h index 58efb85..16e8f50 100644 --- a/src/activeqt/container/qaxbase.h +++ b/src/activeqt/container/qaxbase.h @@ -63,15 +63,15 @@ class QAxBase public: typedef QMap<QString, QVariant> PropertyBag; - + QAxBase(IUnknown *iface = 0); virtual ~QAxBase(); - + QString control() const; - + long queryInterface(const QUuid &, void**) const; - - QVariant dynamicCall(const char *name, const QVariant &v1 = QVariant(), + + QVariant dynamicCall(const char *name, const QVariant &v1 = QVariant(), const QVariant &v2 = QVariant(), const QVariant &v3 = QVariant(), const QVariant &v4 = QVariant(), @@ -96,21 +96,21 @@ public: virtual QObject *qObject() const = 0; virtual const char *className() const = 0; - + PropertyBag propertyBag() const; void setPropertyBag(const PropertyBag&); - + QString generateDocumentation(); - + virtual bool propertyWritable(const char*) const; virtual void setPropertyWritable(const char*, bool); - + bool isNull() const; QStringList verbs() const; - + QVariant asVariant() const; - + #ifdef qdoc Q_SIGNALS: void signal(const QString&,int,void*); @@ -153,7 +153,7 @@ private: bool initializeLicensedHelper(void *factory, const QString &key, IUnknown **ptr); QAxBasePrivate *d; QAxMetaObject *internalMetaObject() const; - + virtual const QMetaObject *parentMetaObject() const = 0; int internalProperty(QMetaObject::Call, int index, void **v); int internalInvoke(QMetaObject::Call, int index, void **v); @@ -198,7 +198,7 @@ inline QDataStream &operator >>(QDataStream &s, QAxBase &c) s >> bag; c.setPropertyBag(bag); c.qObject()->blockSignals(false); - + return s; } @@ -207,7 +207,7 @@ inline QDataStream &operator <<(QDataStream &s, const QAxBase &c) QAxBase::PropertyBag bag = c.propertyBag(); s << c.control(); s << bag; - + return s; } #endif // QT_NO_DATASTREAM diff --git a/src/activeqt/container/qaxdump.cpp b/src/activeqt/container/qaxdump.cpp index bad02cb..8bbca6c 100644 --- a/src/activeqt/container/qaxdump.cpp +++ b/src/activeqt/container/qaxdump.cpp @@ -94,7 +94,7 @@ static QByteArray namedPrototype(const QList<QByteArray> ¶meterTypes, const if (p < parameterNames.count()) prototype += ' ' + parameterNames.at(p); - + if (numDefArgs >= parameterTypes.count() - p) prototype += " = 0"; if (p < parameterTypes.count() - 1) @@ -111,7 +111,7 @@ static QByteArray toType(const QByteArray &t) int vartype = QVariant::nameToType(type); if (vartype == QVariant::Invalid) type = "int"; - + if (type.at(0) == 'Q') type = type.mid(1); type[0] = toupper(type.at(0)); @@ -121,7 +121,7 @@ static QByteArray toType(const QByteArray &t) type = "Map"; else if (type == "Uint") type = "UInt"; - + return "to" + type + "()"; } @@ -130,13 +130,13 @@ QString qax_generateDocumentation(QAxBase *that) that->metaObject(); if (that->isNull()) - return QString(); + return QString(); ITypeInfo *typeInfo = 0; IDispatch *dispatch = 0; that->queryInterface(IID_IDispatch, (void**)&dispatch); if (dispatch) - dispatch->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &typeInfo); + dispatch->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &typeInfo); QString docu; QTextStream stream(&docu, QIODevice::WriteOnly); @@ -153,17 +153,17 @@ QString qax_generateDocumentation(QAxBase *that) const char *inter = 0; int interCount = 1; while ((inter = mo->classInfo(mo->indexOfClassInfo("Interface " + QByteArray::number(interCount))).value())) { - stream << "<li>" << inter << endl; - interCount++; + stream << "<li>" << inter << endl; + interCount++; } stream << "</ul>" << endl; stream << "<h3>Event Interfaces</h3>" << endl; stream << "<ul>" << endl; - interCount = 1; + interCount = 1; while ((inter = mo->classInfo(mo->indexOfClassInfo("Event Interface " + QByteArray::number(interCount))).value())) { - stream << "<li>" << inter << endl; - interCount++; + stream << "<li>" << inter << endl; + interCount++; } stream << "</ul>" << endl; @@ -171,12 +171,12 @@ QString qax_generateDocumentation(QAxBase *that) const int slotCount = mo->methodCount(); if (slotCount) { - stream << "<h2>Public Slots:</h2>" << endl; - stream << "<ul>" << endl; + stream << "<h2>Public Slots:</h2>" << endl; + stream << "<ul>" << endl; int defArgCount = 0; - for (int islot = mo->methodOffset(); islot < slotCount; ++islot) { - const QMetaMethod slot = mo->method(islot); + for (int islot = mo->methodOffset(); islot < slotCount; ++islot) { + const QMetaMethod slot = mo->method(islot); if (slot.methodType() != QMetaMethod::Slot) continue; @@ -185,26 +185,26 @@ QString qax_generateDocumentation(QAxBase *that) continue; } - QByteArray returntype(slot.typeName()); + QByteArray returntype(slot.typeName()); if (returntype.isEmpty()) returntype = "void"; QByteArray prototype = namedPrototype(slot.parameterTypes(), slot.parameterNames(), defArgCount); QByteArray signature = slot.methodSignature(); - QByteArray name = signature.left(signature.indexOf('(')); - stream << "<li>" << returntype << " <a href=\"#" << name << "\"><b>" << name << "</b></a>" << prototype << ";</li>" << endl; - + QByteArray name = signature.left(signature.indexOf('(')); + stream << "<li>" << returntype << " <a href=\"#" << name << "\"><b>" << name << "</b></a>" << prototype << ";</li>" << endl; + prototype = namedPrototype(slot.parameterTypes(), slot.parameterNames()); - QString detail = QString::fromLatin1("<h3><a name=") + QString::fromLatin1(name.constData()) + QLatin1String("></a>") + + QString detail = QString::fromLatin1("<h3><a name=") + QString::fromLatin1(name.constData()) + QLatin1String("></a>") + QLatin1String(returntype.constData()) + QLatin1Char(' ') + QLatin1String(name.constData()) + QLatin1Char(' ') + QString::fromLatin1(prototype.constData()) + QLatin1String("<tt> [slot]</tt></h3>\n"); prototype = namedPrototype(slot.parameterTypes(), QList<QByteArray>()); - detail += docuFromName(typeInfo, QString::fromLatin1(name.constData())); - detail += QLatin1String("<p>Connect a signal to this slot:<pre>\n"); - detail += QString::fromLatin1("\tQObject::connect(sender, SIGNAL(someSignal") + QString::fromLatin1(prototype.constData()) + + detail += docuFromName(typeInfo, QString::fromLatin1(name.constData())); + detail += QLatin1String("<p>Connect a signal to this slot:<pre>\n"); + detail += QString::fromLatin1("\tQObject::connect(sender, SIGNAL(someSignal") + QString::fromLatin1(prototype.constData()) + QLatin1String("), object, SLOT(") + QString::fromLatin1(name.constData()) + QString::fromLatin1(prototype.constData()) + QLatin1String("));"); - detail += QLatin1String("</pre>\n"); + detail += QLatin1String("</pre>\n"); if (1) { detail += QLatin1String("<p>Or call the function directly:<pre>\n"); @@ -227,16 +227,16 @@ QString qax_generateDocumentation(QAxBase *that) detail += QLatin1Char(')'); if (returntype != "void" && returntype != "QAxObject *" && returntype != "QVariant") detail += QLatin1Char('.') + QLatin1String(toType(returntype)); - detail += QLatin1String(";</pre>\n"); - } else { - detail += QLatin1String("<p>This function has parameters of unsupported types and cannot be called directly."); - } + detail += QLatin1String(";</pre>\n"); + } else { + detail += QLatin1String("<p>This function has parameters of unsupported types and cannot be called directly."); + } - methodDetails << detail; + methodDetails << detail; defArgCount = 0; - } + } - stream << "</ul>" << endl; + stream << "</ul>" << endl; } int signalCount = mo->methodCount(); if (signalCount) { @@ -248,18 +248,18 @@ QString qax_generateDocumentation(QAxBase *that) } typeInfo = 0; - stream << "<h2>Signals:</h2>" << endl; - stream << "<ul>" << endl; + stream << "<h2>Signals:</h2>" << endl; + stream << "<ul>" << endl; - for (int isignal = mo->methodOffset(); isignal < signalCount; ++isignal) { - const QMetaMethod signal(mo->method(isignal)); + for (int isignal = mo->methodOffset(); isignal < signalCount; ++isignal) { + const QMetaMethod signal(mo->method(isignal)); if (signal.methodType() != QMetaMethod::Signal) continue; QByteArray prototype = namedPrototype(signal.parameterTypes(), signal.parameterNames()); QByteArray signature = signal.methodSignature(); - QByteArray name = signature.left(signature.indexOf('(')); - stream << "<li>void <a href=\"#" << name << "\"><b>" << name << "</b></a>" << prototype << ";</li>" << endl; + QByteArray name = signature.left(signature.indexOf('(')); + stream << "<li>void <a href=\"#" << name << "\"><b>" << name << "</b></a>" << prototype << ";</li>" << endl; QString detail = QLatin1String("<h3><a name=") + QLatin1String(name.constData()) + QLatin1String("></a>void ") + QLatin1String(name.constData()) + QLatin1Char(' ') + @@ -279,18 +279,18 @@ QString qax_generateDocumentation(QAxBase *that) } while (typeInfo); } prototype = namedPrototype(signal.parameterTypes(), QList<QByteArray>()); - detail += QLatin1String("<p>Connect a slot to this signal:<pre>\n"); - detail += QLatin1String("\tQObject::connect(object, SIGNAL(") + QString::fromLatin1(name.constData()) + + detail += QLatin1String("<p>Connect a slot to this signal:<pre>\n"); + detail += QLatin1String("\tQObject::connect(object, SIGNAL(") + QString::fromLatin1(name.constData()) + QString::fromLatin1(prototype.constData()) + QLatin1String("), receiver, SLOT(someSlot") + QString::fromLatin1(prototype.constData()) + QLatin1String("));"); - detail += QLatin1String("</pre>\n"); + detail += QLatin1String("</pre>\n"); - methodDetails << detail; + methodDetails << detail; if (typeInfo) typeInfo->Release(); typeInfo = 0; - } - stream << "</ul>" << endl; + } + stream << "</ul>" << endl; if (typeLib) typeLib->Release(); @@ -299,97 +299,97 @@ QString qax_generateDocumentation(QAxBase *that) const int propCount = mo->propertyCount(); if (propCount) { if (dispatch) - dispatch->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &typeInfo); - stream << "<h2>Properties:</h2>" << endl; - stream << "<ul>" << endl; + dispatch->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &typeInfo); + stream << "<h2>Properties:</h2>" << endl; + stream << "<ul>" << endl; - for (int iprop = 0; iprop < propCount; ++iprop) { - const QMetaProperty prop = mo->property(iprop); - QByteArray name(prop.name()); - QByteArray type(prop.typeName()); + for (int iprop = 0; iprop < propCount; ++iprop) { + const QMetaProperty prop = mo->property(iprop); + QByteArray name(prop.name()); + QByteArray type(prop.typeName()); - stream << "<li>" << type << " <a href=\"#" << name << "\"><b>" << name << "</b></a>;</li>" << endl; - QString detail = QLatin1String("<h3><a name=") + QString::fromLatin1(name.constData()) + QLatin1String("></a>") + + stream << "<li>" << type << " <a href=\"#" << name << "\"><b>" << name << "</b></a>;</li>" << endl; + QString detail = QLatin1String("<h3><a name=") + QString::fromLatin1(name.constData()) + QLatin1String("></a>") + QLatin1String(type.constData()) + - QLatin1Char(' ') + QLatin1String(name.constData()) + QLatin1String("</h3>\n"); - detail += docuFromName(typeInfo, QString::fromLatin1(name)); - QVariant::Type vartype = QVariant::nameToType(type); - if (!prop.isReadable()) - continue; + QLatin1Char(' ') + QLatin1String(name.constData()) + QLatin1String("</h3>\n"); + detail += docuFromName(typeInfo, QString::fromLatin1(name)); + QVariant::Type vartype = QVariant::nameToType(type); + if (!prop.isReadable()) + continue; - if (prop.isEnumType()) - vartype = QVariant::Int; + if (prop.isEnumType()) + vartype = QVariant::Int; if (vartype != QVariant::Invalid) { - detail += QLatin1String("<p>Read this property's value using QObject::property:<pre>\n"); + detail += QLatin1String("<p>Read this property's value using QObject::property:<pre>\n"); if (prop.isEnumType()) - detail += QLatin1String("\tint val = "); + detail += QLatin1String("\tint val = "); else detail += QLatin1Char('\t') + QLatin1String(type.constData()) + QLatin1String(" val = "); - detail += QLatin1String("object->property(\"") + QLatin1String(name.constData()) + + detail += QLatin1String("object->property(\"") + QLatin1String(name.constData()) + QLatin1String("\").") + QLatin1String(toType(type).constData()) + QLatin1String(";\n"); - detail += QLatin1String("</pre>\n"); - } else if (type == "IDispatch*" || type == "IUnknown*") { - detail += QLatin1String("<p>Get the subobject using querySubObject:<pre>\n"); - detail += QLatin1String("\tQAxObject *") + QLatin1String(name.constData()) + + detail += QLatin1String("</pre>\n"); + } else if (type == "IDispatch*" || type == "IUnknown*") { + detail += QLatin1String("<p>Get the subobject using querySubObject:<pre>\n"); + detail += QLatin1String("\tQAxObject *") + QLatin1String(name.constData()) + QLatin1String(" = object->querySubObject(\"") + QLatin1String(name.constData()) + QLatin1String("\");\n"); - detail += QLatin1String("</pre>\n"); - } else { - detail += QLatin1String("<p>This property is of an unsupported type.\n"); - } - if (prop.isWritable()) { - detail += QLatin1String("Set this property' value using QObject::setProperty:<pre>\n"); + detail += QLatin1String("</pre>\n"); + } else { + detail += QLatin1String("<p>This property is of an unsupported type.\n"); + } + if (prop.isWritable()) { + detail += QLatin1String("Set this property' value using QObject::setProperty:<pre>\n"); if (prop.isEnumType()) { detail += QLatin1String("\tint newValue = ... // string representation of values also supported\n"); } else { - detail += QLatin1String("\t") + QString::fromLatin1(type.constData()) + QLatin1String(" newValue = ...\n"); + detail += QLatin1String("\t") + QString::fromLatin1(type.constData()) + QLatin1String(" newValue = ...\n"); } - detail += QLatin1String("\tobject->setProperty(\"") + QString::fromLatin1(name) + QLatin1String("\", newValue);\n"); - detail += QLatin1String("</pre>\n"); - detail += QLatin1String("Or using the "); - QByteArray setterSlot; + detail += QLatin1String("\tobject->setProperty(\"") + QString::fromLatin1(name) + QLatin1String("\", newValue);\n"); + detail += QLatin1String("</pre>\n"); + detail += QLatin1String("Or using the "); + QByteArray setterSlot; if (isupper(name.at(0))) { - setterSlot = "Set" + name; - } else { - QByteArray nameUp = name; - nameUp[0] = toupper(nameUp.at(0)); - setterSlot = "set" + nameUp; - } - detail += QLatin1String("<a href=\"#") + QString::fromLatin1(setterSlot) + QLatin1String("\">") + + setterSlot = "Set" + name; + } else { + QByteArray nameUp = name; + nameUp[0] = toupper(nameUp.at(0)); + setterSlot = "set" + nameUp; + } + detail += QLatin1String("<a href=\"#") + QString::fromLatin1(setterSlot) + QLatin1String("\">") + QString::fromLatin1(setterSlot.constData()) + QLatin1String("</a> slot.\n"); - } - if (prop.isEnumType()) { - detail += QLatin1String("<p>See also <a href=\"#") + QString::fromLatin1(type) + + } + if (prop.isEnumType()) { + detail += QLatin1String("<p>See also <a href=\"#") + QString::fromLatin1(type) + QLatin1String("\">") + QString::fromLatin1(type) + QLatin1String("</a>.\n"); - } + } - propDetails << detail; - } - stream << "</ul>" << endl; + propDetails << detail; + } + stream << "</ul>" << endl; } const int enumCount = mo->enumeratorCount(); if (enumCount) { - stream << "<hr><h2>Member Type Documentation</h2>" << endl; - for (int i = 0; i < enumCount; ++i) { - const QMetaEnum enumdata = mo->enumerator(i); - stream << "<h3><a name=" << enumdata.name() << "></a>" << enumdata.name() << "</h3>" << endl; - stream << "<ul>" << endl; - for (int e = 0; e < enumdata.keyCount(); ++e) { - stream << "<li>" << enumdata.key(e) << "\t=" << enumdata.value(e) << "</li>" << endl; - } - stream << "</ul>" << endl; - } + stream << "<hr><h2>Member Type Documentation</h2>" << endl; + for (int i = 0; i < enumCount; ++i) { + const QMetaEnum enumdata = mo->enumerator(i); + stream << "<h3><a name=" << enumdata.name() << "></a>" << enumdata.name() << "</h3>" << endl; + stream << "<ul>" << endl; + for (int e = 0; e < enumdata.keyCount(); ++e) { + stream << "<li>" << enumdata.key(e) << "\t=" << enumdata.value(e) << "</li>" << endl; + } + stream << "</ul>" << endl; + } } if (methodDetails.count()) { - stream << "<hr><h2>Member Function Documentation</h2>" << endl; - for (int i = 0; i < methodDetails.count(); ++i) - stream << methodDetails.at(i) << endl; + stream << "<hr><h2>Member Function Documentation</h2>" << endl; + for (int i = 0; i < methodDetails.count(); ++i) + stream << methodDetails.at(i) << endl; } if (propDetails.count()) { - stream << "<hr><h2>Property Documentation</h2>" << endl; - for (int i = 0; i < propDetails.count(); ++i) - stream << propDetails.at(i) << endl; + stream << "<hr><h2>Property Documentation</h2>" << endl; + for (int i = 0; i < propDetails.count(); ++i) + stream << propDetails.at(i) << endl; } if (typeInfo) diff --git a/src/activeqt/container/qaxobject.cpp b/src/activeqt/container/qaxobject.cpp index d0b2674..7303e74 100644 --- a/src/activeqt/container/qaxobject.cpp +++ b/src/activeqt/container/qaxobject.cpp @@ -72,9 +72,9 @@ QT_BEGIN_NAMESPACE \warning You can subclass QAxObject, but you cannot use the Q_OBJECT macro in the subclass (the generated moc-file will not compile), so you - cannot add further signals, slots or properties. This limitation is - due to the metaobject information generated in runtime. - To work around this problem, aggregate the QAxObject as a member of + cannot add further signals, slots or properties. This limitation is + due to the metaobject information generated in runtime. + To work around this problem, aggregate the QAxObject as a member of the QObject subclass. \sa QAxBase, QAxWidget, QAxScript, {ActiveQt Framework} diff --git a/src/activeqt/container/qaxobject.h b/src/activeqt/container/qaxobject.h index 8ec2358..ceb96ca 100644 --- a/src/activeqt/container/qaxobject.h +++ b/src/activeqt/container/qaxobject.h @@ -57,7 +57,7 @@ public: QAxObject(const QString &c, QObject *parent = 0); QAxObject(IUnknown *iface, QObject *parent = 0); ~QAxObject(); - + bool doVerb(const QString &verb); protected: diff --git a/src/activeqt/container/qaxscript.cpp b/src/activeqt/container/qaxscript.cpp index 431a82a..c56474d 100644 --- a/src/activeqt/container/qaxscript.cpp +++ b/src/activeqt/container/qaxscript.cpp @@ -232,10 +232,10 @@ HRESULT WINAPI QAxScriptSite::OnScriptTerminate(const VARIANT *result, const EXC emit script->finished(VARIANTToQVariant(*result, 0)); if (exception) emit script->finished(exception->wCode, - QString::fromWCharArray(exception->bstrSource), - QString::fromWCharArray(exception->bstrDescription), - QString::fromWCharArray(exception->bstrHelpFile) - ); + QString::fromWCharArray(exception->bstrSource), + QString::fromWCharArray(exception->bstrDescription), + QString::fromWCharArray(exception->bstrHelpFile) + ); return S_OK; } diff --git a/src/activeqt/container/qaxscript.h b/src/activeqt/container/qaxscript.h index 6885541..84a6702 100644 --- a/src/activeqt/container/qaxscript.h +++ b/src/activeqt/container/qaxscript.h @@ -65,55 +65,55 @@ public: Disconnected = 3, Closed = 4 }; - + QAxScriptEngine(const QString &language, QAxScript *script); ~QAxScriptEngine(); - + bool isValid() const; bool hasIntrospection() const; - + QString scriptLanguage() const; - + State state() const; void setState(State st); - + void addItem(const QString &name); - + long queryInterface(const QUuid &, void**) const; - + protected: bool initialize(IUnknown** ptr); - + private: QAxScript *script_code; IActiveScript *engine; - + QString script_language; }; class QAxScript : public QObject { Q_OBJECT - + public: enum FunctionFlags { FunctionNames = 0, - FunctionSignatures + FunctionSignatures }; - + QAxScript(const QString &name, QAxScriptManager *manager); ~QAxScript(); - + bool load(const QString &code, const QString &language = QString()); - + QStringList functions(FunctionFlags = FunctionNames) const; - + QString scriptCode() const; QString scriptName() const; QAxScriptEngine *scriptEngine() const; - - QVariant call(const QString &function, const QVariant &v1 = QVariant(), - const QVariant &v2 = QVariant(), + + QVariant call(const QString &function, const QVariant &v1 = QVariant(), + const QVariant &v2 = QVariant(), const QVariant &v3 = QVariant(), const QVariant &v4 = QVariant(), const QVariant &v5 = QVariant(), @@ -121,7 +121,7 @@ public: const QVariant &v7 = QVariant(), const QVariant &v8 = QVariant()); QVariant call(const QString &function, QList<QVariant> &arguments); - + Q_SIGNALS: void entered(); void finished(); @@ -129,14 +129,14 @@ Q_SIGNALS: void finished(int code, const QString &source,const QString &description, const QString &help); void stateChanged(int state); void error(int code, const QString &description, int sourcePosition, const QString &sourceText); - + private: friend class QAxScriptSite; friend class QAxScriptEngine; - + void updateObjects(); QAxBase *findObject(const QString &name); - + QString script_name; QString script_code; QAxScriptManager *script_manager; @@ -147,23 +147,23 @@ private: class QAxScriptManager : public QObject { Q_OBJECT - + public: QAxScriptManager(QObject *parent = 0); ~QAxScriptManager(); - + void addObject(QAxBase *object); void addObject(QObject *object); - + QStringList functions(QAxScript::FunctionFlags = QAxScript::FunctionNames) const; QStringList scriptNames() const; QAxScript *script(const QString &name) const; - + QAxScript* load(const QString &code, const QString &name, const QString &language); QAxScript* load(const QString &file, const QString &name); - - QVariant call(const QString &function, const QVariant &v1 = QVariant(), - const QVariant &v2 = QVariant(), + + QVariant call(const QString &function, const QVariant &v1 = QVariant(), + const QVariant &v2 = QVariant(), const QVariant &v3 = QVariant(), const QVariant &v4 = QVariant(), const QVariant &v5 = QVariant(), @@ -171,21 +171,21 @@ public: const QVariant &v7 = QVariant(), const QVariant &v8 = QVariant()); QVariant call(const QString &function, QList<QVariant> &arguments); - + static bool registerEngine(const QString &name, const QString &extension, const QString &code = QString()); static QString scriptFileFilter(); - + Q_SIGNALS: void error(QAxScript *script, int code, const QString &description, int sourcePosition, const QString &sourceText); - + private Q_SLOTS: void objectDestroyed(QObject *o); void scriptError(int code, const QString &description, int sourcePosition, const QString &sourceText); - + private: friend class QAxScript; QAxScriptManagerPrivate *d; - + void updateScript(QAxScript*); QAxScript *scriptForFunction(const QString &function) const; }; @@ -228,7 +228,7 @@ inline void QAxScriptManager::addObject(QObject *object) { QAxBase *wrapper = qax_create_object_wrapper(object); if (!wrapper) { - qWarning("QAxScriptMananger::addObject: Class %s not exposed through the QAxFactory", + qWarning("QAxScriptMananger::addObject: Class %s not exposed through the QAxFactory", object->metaObject()->className()); Q_ASSERT(wrapper); } diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 88f3da9..7c3a0a8 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -1545,9 +1545,9 @@ HRESULT WINAPI QAxClientSite::SetBorderSpace(LPCBORDERWIDTHS pborderwidths) HRESULT WINAPI QAxClientSite::SetActiveObject(IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName) { AX_DEBUG(QAxClientSite::SetActiveObject); - + Q_UNUSED(pszObjName); - // we are ignoring the name of the object, as suggested by MSDN documentation + // we are ignoring the name of the object, as suggested by MSDN documentation // for IOleInPlaceUIWindow::SetActiveObject(). if (m_spInPlaceActiveObject) { diff --git a/src/activeqt/container/qaxwidget.h b/src/activeqt/container/qaxwidget.h index a4ca3f9..2c8817b 100644 --- a/src/activeqt/container/qaxwidget.h +++ b/src/activeqt/container/qaxwidget.h @@ -58,12 +58,12 @@ class QAxWidget : public QWidget, public QAxBase public: QObject* qObject() const { return (QWidget*)this; } const char *className() const; - + QAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); QAxWidget(const QString &c, QWidget *parent = 0, Qt::WindowFlags f = 0); QAxWidget(IUnknown *iface, QWidget *parent = 0, Qt::WindowFlags f = 0); ~QAxWidget(); - + void clear(); bool doVerb(const QString &verb); @@ -76,7 +76,7 @@ protected: bool initialize(IUnknown**); virtual bool createHostWindow(bool); bool createHostWindow(bool, const QByteArray&); - + void changeEvent(QEvent *e); void resizeEvent(QResizeEvent *); diff --git a/src/activeqt/control/control.pro b/src/activeqt/control/control.pro index dfe86ea..3f43f5d 100644 --- a/src/activeqt/control/control.pro +++ b/src/activeqt/control/control.pro @@ -3,7 +3,7 @@ TARGET = QtAxServer QT += core-private gui-private widgets axbase CONFIG += static -DEFINES += QAX_SERVER +DEFINES += QAX_SERVER HEADERS = qaxaggregated.h \ qaxbindable.h \ diff --git a/src/activeqt/control/qaxaggregated.h b/src/activeqt/control/qaxaggregated.h index 5fdc9df..90c8f5a 100644 --- a/src/activeqt/control/qaxaggregated.h +++ b/src/activeqt/control/qaxaggregated.h @@ -62,7 +62,7 @@ protected: inline IUnknown *controllingUnknown() const { return controlling_unknown; } - inline QWidget *widget() const + inline QWidget *widget() const { return qobject_cast<QWidget*>(the_object); } diff --git a/src/activeqt/control/qaxfactory.cpp b/src/activeqt/control/qaxfactory.cpp index 2a4184f..b510f18 100644 --- a/src/activeqt/control/qaxfactory.cpp +++ b/src/activeqt/control/qaxfactory.cpp @@ -493,7 +493,7 @@ bool QAxFactory::registerActiveObject(QObject *object) return false; if (!QString::fromWCharArray(qAxModuleFilename).toLower().endsWith(QLatin1String(".exe"))) - return false; + return false; ActiveObject *active = new ActiveObject(object, qAxFactory()); if (!active->wrapper || !active->cookie) { diff --git a/src/activeqt/control/qaxfactory.h b/src/activeqt/control/qaxfactory.h index 8cf385c..eaf5757 100644 --- a/src/activeqt/control/qaxfactory.h +++ b/src/activeqt/control/qaxfactory.h @@ -60,35 +60,35 @@ class QAxFactory : public QObject public: QAxFactory(const QUuid &libId, const QUuid &appId); virtual ~QAxFactory(); - + virtual QStringList featureList() const = 0; virtual QObject *createObject(const QString &key) = 0; virtual const QMetaObject *metaObject(const QString &key) const = 0; virtual bool createObjectWrapper(QObject *object, IDispatch **wrapper); - + virtual QUuid classID(const QString &key) const; virtual QUuid interfaceID(const QString &key) const; virtual QUuid eventsID(const QString &key) const; - + virtual QUuid typeLibID() const; virtual QUuid appID() const; - + virtual void registerClass(const QString &key, QSettings *) const; virtual void unregisterClass(const QString &key, QSettings *) const; - + virtual bool validateLicenseKey(const QString &key, const QString &licenseKey) const; - + virtual QString exposeToSuperClass(const QString &key) const; virtual bool stayTopLevel(const QString &key) const; virtual bool hasStockEvents(const QString &key) const; virtual bool isService() const; - + enum ServerType { SingleInstance, MultipleInstances }; - + static bool isServer(); static QString serverDirPath(); static QString serverFilePath(); @@ -96,7 +96,7 @@ public: static bool stopServer(); static bool registerActiveObject(QObject *object); - + private: QUuid typelib; QUuid app; @@ -120,12 +120,12 @@ inline bool QAxFactory::stopServer() return qax_stopServer(); } -#define QAXFACTORY_EXPORT(IMPL, TYPELIB, APPID) \ +#define QAXFACTORY_EXPORT(IMPL, TYPELIB, APPID) \ QT_BEGIN_NAMESPACE \ - QAxFactory *qax_instantiate() \ - { \ - IMPL *impl = new IMPL(QUuid(TYPELIB), QUuid(APPID)); \ - return impl; \ + QAxFactory *qax_instantiate() \ + { \ + IMPL *impl = new IMPL(QUuid(TYPELIB), QUuid(APPID)); \ + return impl; \ } \ QT_END_NAMESPACE @@ -185,7 +185,7 @@ public: QAxClass(const QString &libId, const QString &appId) : QAxFactory(libId, appId) {} - + const QMetaObject *metaObject(const QString &) const { return &T::staticMetaObject; } QStringList featureList() const { return QStringList(QString(T::staticMetaObject.className())); } QObject *createObject(const QString &key) @@ -281,10 +281,10 @@ public: return f ? f->hasStockEvents(key) : false; \ } \ }; \ - QAxFactory *qax_instantiate() \ - { \ - QAxFactoryList *impl = new QAxFactoryList(); \ - return impl; \ + QAxFactory *qax_instantiate() \ + { \ + QAxFactoryList *impl = new QAxFactoryList(); \ + return impl; \ } \ QT_END_NAMESPACE diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp index 97a7446..58b3faf 100644 --- a/src/activeqt/control/qaxserver.cpp +++ b/src/activeqt/control/qaxserver.cpp @@ -113,9 +113,9 @@ QString qAxInit() if (initCount++) return libFile; - + InitializeCriticalSection(&qAxModuleSection); - + libFile = QString::fromWCharArray(qAxModuleFilename); libFile = libFile.toLower(); if (LoadTypeLibEx((wchar_t*)libFile.utf16(), REGKIND_NONE, &qAxTypeLibrary) == S_OK) @@ -139,18 +139,18 @@ void qAxCleanup() { if (!initCount) qWarning("qAxInit/qAxCleanup mismatch"); - + if (--initCount) return; delete qax_factory; qax_factory = 0; - + if (qAxTypeLibrary) { qAxTypeLibrary->Release(); qAxTypeLibrary = 0; } - + DeleteCriticalSection(&qAxModuleSection); } @@ -170,7 +170,7 @@ unsigned long qAxUnlock() EnterCriticalSection(&qAxModuleSection); unsigned long ref = --qAxModuleRef; LeaveCriticalSection(&qAxModuleSection); - + if (!ref) qax_shutDown(); return ref; @@ -211,10 +211,10 @@ HRESULT UpdateRegistry(BOOL bRegister) QString path = file.left(file.lastIndexOf(QLatin1Char('\\'))+1); QString module = file.right(file.length() - path.length()); module = module.left(module.lastIndexOf(QLatin1Char('.'))); - + const QString appId = qAxFactory()->appID().toString().toUpper(); const QString libId = qAxFactory()->typeLibID().toString().toUpper(); - + QString libFile = qAxInit(); QString typeLibVersion; @@ -246,7 +246,7 @@ HRESULT UpdateRegistry(BOOL bRegister) keyPath = QLatin1String("HKEY_CURRENT_USER\\Software\\Classes"); QSettings settings(keyPath, QSettings::NativeFormat); - + // we try to create the ActiveX widgets later on... bool delete_qApp = false; if (!qApp) { @@ -254,7 +254,7 @@ HRESULT UpdateRegistry(BOOL bRegister) (void)new QApplication(argc, 0); delete_qApp = true; } - + if (bRegister) { if (qAxOutProcServer) { settings.setValue(QLatin1String("/AppID/") + appId + QLatin1String("/."), module); @@ -286,16 +286,16 @@ HRESULT UpdateRegistry(BOOL bRegister) olemisc |= OLEMISC_INVISIBLEATRUNTIME; else if (object->findChild<QMenuBar*>() && !qax_disable_inplaceframe) olemisc |= OLEMISC_WANTSTOMENUMERGE; - + settings.setValue(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion + QLatin1String("/."), className + QLatin1String(" Class")); settings.setValue(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion + QLatin1String("/CLSID/."), classId); if (insertable) settings.setValue(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion + QLatin1String("/Insertable/."), QVariant(QLatin1String(""))); - + settings.setValue(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1String("/."), className + QLatin1String(" Class")); settings.setValue(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1String("/CLSID/."), classId); settings.setValue(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1String("/CurVer/."), module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion); - + settings.setValue(QLatin1String("/CLSID/") + classId + QLatin1String("/."), className + QLatin1String(" Class")); if (file.endsWith(QLatin1String("exe"), Qt::CaseInsensitive)) settings.setValue(QLatin1String("/CLSID/") + classId + QLatin1String("/AppID"), appId); @@ -361,31 +361,31 @@ HRESULT UpdateRegistry(BOOL bRegister) const QMetaObject *mo = qAxFactory()->metaObject(className); const QString classId = qAxFactory()->classID(className).toString().toUpper(); className = qax_clean_type(className, mo); - + QString classVersion = mo ? QString::fromLatin1(mo->classInfo(mo->indexOfClassInfo("Version")).value()) : QString(); if (classVersion.isNull()) classVersion = QLatin1String("1.0"); const QString classMajorVersion = classVersion.left(classVersion.indexOf(QLatin1Char('.'))); - + qAxFactory()->unregisterClass(*key, &settings); - + settings.remove(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion + QLatin1String("/CLSID/.")); settings.remove(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion + QLatin1String("/Insertable/.")); settings.remove(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion + QLatin1String("/.")); settings.remove(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion); - + settings.remove(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1String("/CLSID/.")); settings.remove(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1String("/CurVer/.")); settings.remove(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1String("/.")); settings.remove(QLatin1Char('/') + module + QLatin1Char('.') + className); - + settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/AppID")); settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/Control/.")); settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/Insertable/.")); settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/InProcServer32/.")); settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/LocalServer32/.")); settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/MiscStatus/1/.")); - settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/MiscStatus/.")); + settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/MiscStatus/.")); settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/Programmable/.")); settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/ToolboxBitmap32/.")); settings.remove(QLatin1String("/CLSID/") + classId + QLatin1String("/TypeLib/.")); @@ -425,7 +425,7 @@ HRESULT UpdateRegistry(BOOL bRegister) } } } - + if (delete_qApp) delete qApp; @@ -446,49 +446,49 @@ static QList<QByteArray> subtypes; static const char* const type_map[][2] = { // QVariant/Qt Value data types - { "QString", "BSTR" }, - { "QCString", "BSTR" }, - { "bool", "VARIANT_BOOL" }, - { "int", "int" }, - { "void", "void" }, - { "uint", "unsigned int" }, - { "double", "double" }, - { "QColor", "OLE_COLOR" }, - { "QDate", "DATE" }, - { "QTime", "DATE" }, - { "QDateTime", "DATE" }, - { "QFont", "IFontDisp*" }, - { "QPixmap", "IPictureDisp*" }, - { "QVariant", "VARIANT" }, - { "QVariantList", "SAFEARRAY(VARIANT)" }, + { "QString", "BSTR" }, + { "QCString", "BSTR" }, + { "bool", "VARIANT_BOOL" }, + { "int", "int" }, + { "void", "void" }, + { "uint", "unsigned int" }, + { "double", "double" }, + { "QColor", "OLE_COLOR" }, + { "QDate", "DATE" }, + { "QTime", "DATE" }, + { "QDateTime", "DATE" }, + { "QFont", "IFontDisp*" }, + { "QPixmap", "IPictureDisp*" }, + { "QVariant", "VARIANT" }, + { "QVariantList", "SAFEARRAY(VARIANT)" }, { "QList<QVariant>", "SAFEARRAY(VARIANT)" }, - { "quint64", "CY" }, - { "qint64", "CY" }, - { "qulonglong", "CY" }, - { "qlonglong", "CY" }, - { "QByteArray", "SAFEARRAY(BYTE)" }, - { "QStringList", "SAFEARRAY(BSTR)" }, + { "quint64", "CY" }, + { "qint64", "CY" }, + { "qulonglong", "CY" }, + { "qlonglong", "CY" }, + { "QByteArray", "SAFEARRAY(BYTE)" }, + { "QStringList", "SAFEARRAY(BSTR)" }, // Userdefined Qt datatypes - some not on Borland though { "QCursor", "enum MousePointer" }, { "Qt::FocusPolicy", "enum FocusPolicy" }, #ifndef Q_CC_BOR # if __REQUIRED_RPCNDR_H_VERSION__ >= Q_REQUIRED_RPCNDR_H_VERSION - { "QRect", "struct QRect" }, - { "QSize", "struct QSize" }, - { "QPoint", "struct QPoint" }, + { "QRect", "struct QRect" }, + { "QSize", "struct QSize" }, + { "QPoint", "struct QPoint" }, # endif #endif // And we support COM data types - { "BOOL", "BOOL" }, - { "BSTR", "BSTR" }, - { "OLE_COLOR", "OLE_COLOR" }, - { "DATE", "DATE" }, - { "VARIANT", "VARIANT" }, - { "IDispatch", "IDispatch*" }, - { "IUnknown", "IUnknown*" }, - { "IDispatch*", "IDispatch*" }, - { "IUnknown*", "IUnknown*" }, - { 0, 0 } + { "BOOL", "BOOL" }, + { "BSTR", "BSTR" }, + { "OLE_COLOR", "OLE_COLOR" }, + { "DATE", "DATE" }, + { "VARIANT", "VARIANT" }, + { "IDispatch", "IDispatch*" }, + { "IUnknown", "IUnknown*" }, + { "IDispatch*", "IDispatch*" }, + { "IUnknown*", "IUnknown*" }, + { 0, 0 } }; static QByteArray convertTypes(const QByteArray &qtype, bool *ok) @@ -497,12 +497,12 @@ static QByteArray convertTypes(const QByteArray &qtype, bool *ok) qRegisterMetaType<IUnknown *>("IUnknown*"); *ok = false; - + int i = 0; while (type_map[i][0]) { if (qtype == type_map[i][0] && type_map[i][1]) { *ok = true; - return type_map[i][1]; + return type_map[i][1]; } ++i; } @@ -528,39 +528,39 @@ static QByteArray convertTypes(const QByteArray &qtype, bool *ok) static const char* const keyword_map[][2] = { - { "aggregatable", "aggregating" }, - { "allocate", "alloc" }, - { "appobject", "appObject" }, - { "arrays", "array" }, - { "async", "asynchronous" }, - { "bindable", "binding" }, - { "Boolean", "boolval" }, - { "boolean", "boolval" }, - { "broadcast", "broadCast" }, - { "callback", "callBack" }, - { "decode", "deCode" }, - { "default", "defaulted" }, - { "defaultbind", "defaultBind" }, - { "defaultvalue", "defaultValue" }, - { "encode" "enCode" }, - { "endpoint", "endPoint" }, - { "hidden", "isHidden" }, - { "ignore", "ignore_" }, - { "local", "local_" }, - { "notify", "notify_" }, - { "object", "object_" }, - { "optimize", "optimize_" }, - { "optional", "optional_" }, - { "out", "out_" }, - { "pipe", "pipe_" }, - { "proxy", "proxy_" }, - { "ptr", "pointer" }, - { "readonly", "readOnly" }, - { "small", "small_" }, - { "source", "source_" }, - { "string", "string_" }, - { "uuid", "uuid_" }, - { 0, 0 } + { "aggregatable", "aggregating" }, + { "allocate", "alloc" }, + { "appobject", "appObject" }, + { "arrays", "array" }, + { "async", "asynchronous" }, + { "bindable", "binding" }, + { "Boolean", "boolval" }, + { "boolean", "boolval" }, + { "broadcast", "broadCast" }, + { "callback", "callBack" }, + { "decode", "deCode" }, + { "default", "defaulted" }, + { "defaultbind", "defaultBind" }, + { "defaultvalue", "defaultValue" }, + { "encode" "enCode" }, + { "endpoint", "endPoint" }, + { "hidden", "isHidden" }, + { "ignore", "ignore_" }, + { "local", "local_" }, + { "notify", "notify_" }, + { "object", "object_" }, + { "optimize", "optimize_" }, + { "optional", "optional_" }, + { "out", "out_" }, + { "pipe", "pipe_" }, + { "proxy", "proxy_" }, + { "ptr", "pointer" }, + { "readonly", "readOnly" }, + { "small", "small_" }, + { "source", "source_" }, + { "string", "string_" }, + { "uuid", "uuid_" }, + { 0, 0 } }; static QByteArray replaceKeyword(const QByteArray &name) @@ -579,7 +579,7 @@ static QMap<QByteArray, int> mapping; static QByteArray renameOverloads(const QByteArray &name) { QByteArray newName = name; - + if (mapping.contains(name)) { int n = mapping.value(name); newName = name + '_' + QByteArray::number(n); @@ -587,7 +587,7 @@ static QByteArray renameOverloads(const QByteArray &name) } else { mapping.insert(name, 1); } - + return newName; } @@ -684,12 +684,12 @@ bool ignoreProps(const char *test) static QByteArray prototype(const QList<QByteArray> ¶meterTypes, const QList<QByteArray> ¶meterNames, bool *ok) { QByteArray prototype; - + for (int p = 0; p < parameterTypes.count() && *ok; ++p) { bool out = false; QByteArray type(parameterTypes.at(p)); QByteArray name(parameterNames.at(p)); - + if (type.endsWith('&')) { out = true; type.truncate(type.length() - 1); @@ -708,18 +708,18 @@ static QByteArray prototype(const QList<QByteArray> ¶meterTypes, const QList prototype += "[in] " + type + ' '; else prototype += "[in,out] " + type + ' '; - + if (out) prototype += '*'; if (name.isEmpty()) prototype += 'p' + QByteArray::number(p); else prototype += "p_" + replaceKeyword(name); - + if (p < parameterTypes.count() - 1) prototype += ", "; } - + return prototype; } @@ -753,32 +753,32 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN int i = 0; if (!mo) return 3; - + QString topclass = qAxFactory()->exposeToSuperClass(className); if (topclass.isEmpty()) topclass = QLatin1String("QObject"); bool hasStockEvents = qAxFactory()->hasStockEvents(className); - + const QMetaObject *pmo = mo; do { pmo = pmo->superClass(); } while (pmo && topclass != QString::fromLatin1(pmo->className())); - + int enumoff = pmo ? pmo->enumeratorOffset() : mo->enumeratorOffset(); int methodoff = pmo ? pmo->methodOffset() : mo->methodOffset(); int propoff = pmo ? pmo->propertyOffset() : mo->propertyOffset(); - + int qtProps = 0; int qtSlots = 0; bool control = false; - + if (o && o->isWidgetType()) { qtProps = QWidget::staticMetaObject.propertyCount(); qtSlots = QWidget::staticMetaObject.methodCount(); control = true; } - + QString classID = qAxFactory()->classID(className).toString().toUpper(); if (QUuid(classID).isNull()) return 4; @@ -790,20 +790,20 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN QString eventsID = qAxFactory()->eventsID(className).toString().toUpper(); bool hasEvents = !QUuid(eventsID).isNull(); STRIPCB(eventsID); - + QString cleanClassName = qax_clean_type(className, mo); QString defProp(QLatin1String(mo->classInfo(mo->indexOfClassInfo("DefaultProperty")).value())); QString defSignal(QLatin1String(mo->classInfo(mo->indexOfClassInfo("DefaultSignal")).value())); - + for (i = enumoff; i < mo->enumeratorCount(); ++i) { const QMetaEnum enumerator = mo->enumerator(i); if (enums.contains(enumerator.name())) continue; - + enums.append(enumerator.name()); - + out << "\tenum " << enumerator.name() << " {" << endl; - + for (int j = 0; j < enumerator.keyCount(); ++j) { QByteArray key(enumerator.key(j)); while (enumValues.contains(key)) { @@ -865,24 +865,24 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN out << "\t]" << endl; out << "\tdispinterface I" << cleanClassName << endl; out << "\t{" << endl; - + out << "\tproperties:" << endl; for (i = propoff; i < mo->propertyCount(); ++i) { const QMetaProperty property = mo->property(i); - /* if (property.testFlags(QMetaProperty::Override)) - continue;*/ + /* if (property.testFlags(QMetaProperty::Override)) + continue;*/ if (i <= qtProps && ignoreProps(property.name())) continue; if (!property.name() || mo->indexOfProperty(property.name()) > i) continue; - + bool ok = true; QByteArray type(convertTypes(property.typeName(), &ok)); QByteArray name(replaceKeyword(property.name())); - + if (!ok) out << "\t/****** Property is of unsupported datatype" << endl; - + out << "\t\t[id(" << id << ')'; if (!property.isWritable()) out << ", readonly"; @@ -895,7 +895,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN if (defProp == QLatin1String(name)) out << ", uidefault"; out << "] " << type << ' ' << name << ';' << endl; - + if (!ok) out << "\t******/" << endl; ++id; @@ -919,7 +919,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN out << outBuffer; outBuffer = QByteArray(); } - + QByteArray signature(slot.methodSignature()); QByteArray name(signature.left(signature.indexOf('('))); if (i <= qtSlots && ignoreSlots(name)) @@ -933,20 +933,20 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN QList<QByteArray> parameterTypes(slot.parameterTypes()); QList<QByteArray> parameterNames(slot.parameterNames()); - + bool ok = true; QByteArray type = slot.typeName(); if (type.isEmpty()) type = "void"; else type = convertTypes(type, &ok); - + QByteArray ptype(prototype(parameterTypes, parameterNames, &ok)); if (!ok) outBuffer += "\t/****** Slot parameter uses unsupported datatype\n"; - + outBuffer += "\t\t[id(" + QString::number(id).toLatin1() + ")] " + type + ' ' + name + '(' + ptype + ");\n"; - + if (!ok) outBuffer += "\t******/\n"; ++id; @@ -961,7 +961,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN mapping.clear(); id = 1; - + if (hasEvents) { out << "\t[" << endl; out << "\t\tuuid(" << eventsID << ")," << endl; @@ -971,7 +971,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN out << "\t{" << endl; out << "\tproperties:" << endl; out << "\tmethods:" << endl; - + if (hasStockEvents) { out << "\t/****** Stock events ******/" << endl; out << "\t\t[id(DISPID_CLICK)] void Click();" << endl; @@ -983,12 +983,12 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN out << "\t\t[id(DISPID_MOUSEMOVE)] void MouseMove(short Button, short Shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);" << endl; out << "\t\t[id(DISPID_MOUSEUP)] void MouseUp(short Button, short Shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);" << endl << endl; } - + for (i = methodoff; i < mo->methodCount(); ++i) { const QMetaMethod signal = mo->method(i); if (signal.methodType() != QMetaMethod::Signal) continue; - + QByteArray signature(signal.methodSignature()); QByteArray name(signature.left(signature.indexOf('('))); signature = signature.mid(name.length() + 1); @@ -996,33 +996,33 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN QList<QByteArray> parameterTypes(signal.parameterTypes()); QList<QByteArray> parameterNames(signal.parameterNames()); - + bool isDefault = defSignal == QLatin1String(name); name = renameOverloads(replaceKeyword(name)); bool ok = true; - + QByteArray type = signal.typeName(); if (!type.isEmpty() && type != "void") // signals with return value not supported continue; - + QByteArray ptype(prototype(parameterTypes, parameterNames, &ok)); if (!ok) out << "\t/****** Signal parameter uses unsupported datatype" << endl; - + out << "\t\t[id(" << id << ')'; if (isDefault) out << ", uidefault"; out << "] void " << name << '(' << ptype << ");" << endl; - + if (!ok) out << "\t******/" << endl; ++id; } out << "\t};" << endl << endl; } - + out << "\t[" << endl; - + if (qstricmp(mo->classInfo(mo->indexOfClassInfo("Aggregatable")).value(), "no")) out << "\t\taggregatable," << endl; if (!qstricmp(mo->classInfo(mo->indexOfClassInfo("RegisterObject")).value(), "yes")) @@ -1053,7 +1053,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN if (hasEvents) out << "\t\t[default, source] dispinterface I" << cleanClassName << "Events;" << endl; out << "\t};" << endl; - + return S_OK; } @@ -1072,10 +1072,10 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) } QFile file(outfile); file.remove(); - + QString filebase = QString::fromWCharArray(qAxModuleFilename); filebase = filebase.left(filebase.lastIndexOf(QLatin1Char('.'))); - + QString appID = qAxFactory()->appID().toString().toUpper(); if (QUuid(appID).isNull()) return 1; @@ -1085,12 +1085,12 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) return 2; STRIPCB(typeLibID); QString typelib = filebase.right(filebase.length() - filebase.lastIndexOf(QLatin1String("\\"))-1); - + if (!file.open(QIODevice::WriteOnly)) return -1; - + out.setDevice(&file); - + QString version(ver.unicode(), ver.length()); while (version.count(QLatin1Char('.')) > 1) { int lastdot = version.lastIndexOf(QLatin1Char('.')); @@ -1098,14 +1098,14 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) } if (version.isEmpty()) version = QLatin1String("1.0"); - + QString idQRect(QUuid(CLSID_QRect).toString()); STRIPCB(idQRect); QString idQSize(QUuid(CLSID_QSize).toString()); STRIPCB(idQSize); QString idQPoint(QUuid(CLSID_QPoint).toString()); STRIPCB(idQPoint); - + out << "/****************************************************************************" << endl; out << "** Interface definition generated for ActiveQt project" << endl; out << "**" << endl; @@ -1115,10 +1115,10 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) out << "**" << endl; out << "** WARNING! All changes made in this file will be lost!" << endl; out << "****************************************************************************/" << endl << endl; - + out << "import \"ocidl.idl\";" << endl; out << "#include <olectl.h>" << endl << endl; - + // dummy application to create widgets bool delete_qApp = false; if (!qApp) { @@ -1126,7 +1126,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) (void)new QApplication(argc, 0); delete_qApp = true; } - + out << '[' << endl; out << "\tuuid(" << typeLibID << ")," << endl; out << "\tversion(" << version << ")," << endl; @@ -1136,17 +1136,17 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) out << '{' << endl; out << "\timportlib(\"stdole32.tlb\");" << endl; out << "\timportlib(\"stdole2.tlb\");" << endl << endl; - + QStringList keys = qAxFactory()->featureList(); QStringList::ConstIterator key; - + out << "\t/************************************************************************" << endl; out << "\t** If this causes a compile error in MIDL you need to upgrade the" << endl; out << "\t** Platform SDK you are using. Download the SDK from msdn.microsoft.com" << endl; out << "\t** and make sure that both the system and the Visual Studio environment" << endl; out << "\t** use the correct files." << endl; out << "\t**" << endl; - + #ifndef Q_CC_BOR #if __REQUIRED_RPCNDR_H_VERSION__ < Q_REQUIRED_RPCNDR_H_VERSION out << "\t** Required version of MIDL could not be verified. QRect, QSize and QPoint" << endl; @@ -1155,7 +1155,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) #else out << "\t************************************************************************/" << endl; #endif - + out << endl; out << "\t[uuid(" << idQRect << ")]" << endl; out << "\tstruct QRect {" << endl; @@ -1164,13 +1164,13 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) out << "\t\tint right;" << endl; out << "\t\tint bottom;" << endl; out << "\t};" << endl << endl; - + out << "\t[uuid(" << idQSize << ")]" << endl; out << "\tstruct QSize {" << endl; out << "\t\tint width;" << endl; out << "\t\tint height;" << endl; out << "\t};" << endl << endl; - + out << "\t[uuid(" << idQPoint << ")]" << endl; out << "\tstruct QPoint {" << endl; out << "\t\tint x;" << endl; @@ -1184,9 +1184,9 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) out << "\t*************************************************************************" << endl; #endif out << endl; - + out << "\t/* Forward declaration of classes that might be used as parameters */" << endl << endl; - + int res = S_OK; for (key = keys.begin(); key != keys.end(); ++key) { QByteArray className = (*key).toLatin1(); @@ -1222,7 +1222,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) out << endl; if (res != S_OK) goto ErrorInClass; - + for (key = keys.begin(); key != keys.end(); ++key) { QByteArray className = (*key).toLatin1(); QObject *o = qAxFactory()->createObject(QString::fromLatin1(className.constData())); @@ -1240,10 +1240,10 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) if (res != S_OK) break; } - + out << "};" << endl; out.flush(); - + ErrorInClass: if (delete_qApp) delete qApp; @@ -1252,7 +1252,7 @@ ErrorInClass: file.close(); file.remove(); } - + return res; } diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index ee49deb..ce57bf1 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -108,7 +108,7 @@ extern bool qax_ownQApp; struct QAxExceptInfo { QAxExceptInfo(int c, const QString &s, const QString &d, const QString &x) - : code(c), src(s), desc(d), context(x) + : code(c), src(s), desc(d), context(x) { } int code; @@ -176,15 +176,15 @@ public: // IUnknown unsigned long WINAPI AddRef() { - if (m_outerUnknown) - return m_outerUnknown->AddRef(); + if (m_outerUnknown) + return m_outerUnknown->AddRef(); return InterlockedIncrement(&ref); } unsigned long WINAPI Release() { - if (m_outerUnknown) - return m_outerUnknown->Release(); + if (m_outerUnknown) + return m_outerUnknown->Release(); LONG refCount = InterlockedDecrement(&ref); if (!refCount) @@ -198,14 +198,14 @@ public: // IAxServerBase IUnknown *clientSite() const { - return m_spClientSite; + return m_spClientSite; } void emitPropertyChanged(const char*); bool emitRequestPropertyChange(const char*); QObject *qObject() const { - return theObject; + return theObject; } void ensureMetaData(); bool isPropertyExposed(int index); @@ -222,8 +222,8 @@ public: STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo); STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid); STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, - LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, - EXCEPINFO* pexcepinfo, UINT* puArgErr); + LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, + EXCEPINFO* pexcepinfo, UINT* puArgErr); // IProvideClassInfo STDMETHOD(GetClassInfo)(ITypeInfo** pptinfo); @@ -256,10 +256,10 @@ public: // IViewObject STDMETHOD(Draw)(DWORD dwAspect, LONG lIndex, void *pvAspect, DVTARGETDEVICE *ptd, - HDC hicTargetDevice, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, - BOOL(__stdcall*pfnContinue)(ULONG_PTR), ULONG_PTR dwContinue); + HDC hicTargetDevice, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, + BOOL(__stdcall*pfnContinue)(ULONG_PTR), ULONG_PTR dwContinue); STDMETHOD(GetColorSet)(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, - HDC hicTargetDev, LOGPALETTE **ppColorSet); + HDC hicTargetDev, LOGPALETTE **ppColorSet); STDMETHOD(Freeze)(DWORD dwAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze); STDMETHOD(Unfreeze)(DWORD dwFreeze); STDMETHOD(SetAdvise)(DWORD aspects, DWORD advf, IAdviseSink *pAdvSink); @@ -299,8 +299,8 @@ public: // IPersist STDMETHOD(GetClassID)(GUID*clsid) { - *clsid = qAxFactory()->classID(class_name); - return S_OK; + *clsid = qAxFactory()->classID(class_name); + return S_OK; } // IPersistStreamInit @@ -359,21 +359,21 @@ private: ConnectionPoints points; union { - QWidget *widget; - QObject *object; + QWidget *widget; + QObject *object; } qt; QPointer<QObject> theObject; - unsigned isWidget :1; - unsigned ownObject :1; - unsigned initNewCalled :1; - unsigned dirtyflag :1; - unsigned hasStockEvents :1; - unsigned stayTopLevel :1; - unsigned isInPlaceActive :1; - unsigned isUIActive :1; - unsigned wasUIActive :1; - unsigned inDesignMode :1; - unsigned canTakeFocus :1; + unsigned isWidget :1; + unsigned ownObject :1; + unsigned initNewCalled :1; + unsigned dirtyflag :1; + unsigned hasStockEvents :1; + unsigned stayTopLevel :1; + unsigned isInPlaceActive :1; + unsigned isUIActive :1; + unsigned wasUIActive :1; + unsigned inDesignMode :1; + unsigned canTakeFocus :1; short freezeEvents; HWND m_hWnd; @@ -415,20 +415,20 @@ class QAxServerAggregate : public IUnknown { public: QAxServerAggregate(const QString &className, IUnknown *outerUnknown) - : m_outerUnknown(outerUnknown), ref(0) + : m_outerUnknown(outerUnknown), ref(0) { - object = new QAxServerBase(className, outerUnknown); - object->registerActiveObject(this); + object = new QAxServerBase(className, outerUnknown); + object->registerActiveObject(this); - InitializeCriticalSection(&refCountSection); - InitializeCriticalSection(&createWindowSection); + InitializeCriticalSection(&refCountSection); + InitializeCriticalSection(&createWindowSection); } ~QAxServerAggregate() { - DeleteCriticalSection(&refCountSection); - DeleteCriticalSection(&createWindowSection); + DeleteCriticalSection(&refCountSection); + DeleteCriticalSection(&createWindowSection); - delete object; + delete object; } // IUnknown @@ -446,14 +446,14 @@ public: } HRESULT WINAPI QueryInterface(REFIID iid, void **iface) { - *iface = 0; - - if (iid == IID_IUnknown) { - *iface = (IUnknown*)this; - AddRef(); - return S_OK; - } - return object->InternalQueryInterface(iid, iface); + *iface = 0; + + if (iid == IID_IUnknown) { + *iface = (IUnknown*)this; + AddRef(); + return S_OK; + } + return object->InternalQueryInterface(iid, iface); } private: @@ -471,7 +471,7 @@ bool QAxFactory::createObjectWrapper(QObject *object, IDispatch **wrapper) QAxServerBase *obj = new QAxServerBase(object); obj->QueryInterface(IID_IDispatch, (void**)wrapper); if (*wrapper) - return true; + return true; delete obj; return false; @@ -489,7 +489,7 @@ public: , current(0) , ref(0) { - InitializeCriticalSection(&refCountSection); + InitializeCriticalSection(&refCountSection); const int count = cpoints.count(); for (int i = 0; i < count; ++i) cpoints.at(i)->AddRef(); @@ -498,8 +498,8 @@ public: : cpoints(old.cpoints) , current(old.current) { - InitializeCriticalSection(&refCountSection); - ref = 0; + InitializeCriticalSection(&refCountSection); + ref = 0; const int count = cpoints.count(); for (int i = 0; i < count; ++i) cpoints.at(i)->AddRef(); @@ -510,7 +510,7 @@ public: for (int i = 0; i < count; ++i) cpoints.at(i)->Release(); - DeleteCriticalSection(&refCountSection); + DeleteCriticalSection(&refCountSection); } unsigned long __stdcall AddRef() @@ -529,16 +529,16 @@ public: { if (!iface) return E_POINTER; - *iface = 0; - if (iid == IID_IUnknown) - *iface = this; - else if (iid == IID_IEnumConnectionPoints) - *iface = this; - else - return E_NOINTERFACE; - - AddRef(); - return S_OK; + *iface = 0; + if (iid == IID_IUnknown) + *iface = this; + else if (iid == IID_IEnumConnectionPoints) + *iface = this; + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; } STDMETHOD(Next)(ULONG cConnections, IConnectionPoint **cpoint, ULONG *pcFetched) { @@ -549,43 +549,43 @@ public: return E_POINTER; const int count = cpoints.count(); - unsigned long i; - for (i = 0; i < cConnections; i++) { - if (current==count) - break; - IConnectionPoint *cp = cpoints.at(current); - cp->AddRef(); - cpoint[i] = cp; - ++current; - } + unsigned long i; + for (i = 0; i < cConnections; i++) { + if (current==count) + break; + IConnectionPoint *cp = cpoints.at(current); + cp->AddRef(); + cpoint[i] = cp; + ++current; + } if (pcFetched) - *pcFetched = i; - return i == cConnections ? S_OK : S_FALSE; + *pcFetched = i; + return i == cConnections ? S_OK : S_FALSE; } STDMETHOD(Skip)(ULONG cConnections) { const int count = cpoints.count(); - while (cConnections) { - if (current == count) - return S_FALSE; - ++current; - --cConnections; - } - return S_OK; + while (cConnections) { + if (current == count) + return S_FALSE; + ++current; + --cConnections; + } + return S_OK; } STDMETHOD(Reset)() { current = 0; - return S_OK; + return S_OK; } STDMETHOD(Clone)(IEnumConnectionPoints **ppEnum) { if (!ppEnum) return E_POINTER; - *ppEnum = new QAxSignalVec(*this); - (*ppEnum)->AddRef(); + *ppEnum = new QAxSignalVec(*this); + (*ppEnum)->AddRef(); - return S_OK; + return S_OK; } QList<IConnectionPoint*> cpoints; @@ -601,7 +601,7 @@ private: Helper class to store and enumerate all connected event listeners. */ class QAxConnection : public IConnectionPoint, - public IEnumConnections + public IEnumConnections { public: typedef QList<CONNECTDATA> Connections; @@ -610,26 +610,26 @@ public: QAxConnection(QAxServerBase *parent, const QUuid &uuid) : that(parent), iid(uuid), current(0), ref(1) { - InitializeCriticalSection(&refCountSection); + InitializeCriticalSection(&refCountSection); } QAxConnection(const QAxConnection &old) : current(old.current) { - InitializeCriticalSection(&refCountSection); - ref = 0; - connections = old.connections; - that = old.that; - iid = old.iid; - QList<CONNECTDATA>::Iterator it = connections.begin(); - while (it != connections.end()) { - CONNECTDATA connection = *it; - ++it; - connection.pUnk->AddRef(); - } + InitializeCriticalSection(&refCountSection); + ref = 0; + connections = old.connections; + that = old.that; + iid = old.iid; + QList<CONNECTDATA>::Iterator it = connections.begin(); + while (it != connections.end()) { + CONNECTDATA connection = *it; + ++it; + connection.pUnk->AddRef(); + } } ~QAxConnection() { - DeleteCriticalSection(&refCountSection); + DeleteCriticalSection(&refCountSection); } unsigned long __stdcall AddRef() @@ -648,48 +648,48 @@ public: { if (!iface) return E_POINTER; - *iface = 0; - if (iid == IID_IUnknown) - *iface = (IConnectionPoint*)this; - else if (iid == IID_IConnectionPoint) - *iface = this; - else if (iid == IID_IEnumConnections) - *iface = this; - else - return E_NOINTERFACE; - - AddRef(); - return S_OK; + *iface = 0; + if (iid == IID_IUnknown) + *iface = (IConnectionPoint*)this; + else if (iid == IID_IConnectionPoint) + *iface = this; + else if (iid == IID_IEnumConnections) + *iface = this; + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; } STDMETHOD(GetConnectionInterface)(IID *pIID) { - *pIID = iid; - return S_OK; + *pIID = iid; + return S_OK; } STDMETHOD(GetConnectionPointContainer)(IConnectionPointContainer **ppCPC) { - return that->QueryInterface(IID_IConnectionPointContainer, (void**)ppCPC); + return that->QueryInterface(IID_IConnectionPointContainer, (void**)ppCPC); } STDMETHOD(Advise)(IUnknown*pUnk, DWORD *pdwCookie) { if (!pUnk || !pdwCookie) return E_POINTER; - { - IDispatch *checkImpl = 0; - pUnk->QueryInterface(iid, (void**)&checkImpl); - if (!checkImpl) - return CONNECT_E_CANNOTCONNECT; - checkImpl->Release(); - } - - CONNECTDATA cd; - cd.dwCookie = connections.count()+1; - cd.pUnk = pUnk; - cd.pUnk->AddRef(); - connections.append(cd); - *pdwCookie = cd.dwCookie; - return S_OK; + { + IDispatch *checkImpl = 0; + pUnk->QueryInterface(iid, (void**)&checkImpl); + if (!checkImpl) + return CONNECT_E_CANNOTCONNECT; + checkImpl->Release(); + } + + CONNECTDATA cd; + cd.dwCookie = connections.count()+1; + cd.pUnk = pUnk; + cd.pUnk->AddRef(); + connections.append(cd); + *pdwCookie = cd.dwCookie; + return S_OK; } STDMETHOD(Unadvise)(DWORD dwCookie) { @@ -702,16 +702,16 @@ public: return S_OK; } } - return CONNECT_E_NOCONNECTION; + return CONNECT_E_NOCONNECTION; } STDMETHOD(EnumConnections)(IEnumConnections **ppEnum) { if (!ppEnum) return E_POINTER; - *ppEnum = this; - AddRef(); + *ppEnum = this; + AddRef(); - return S_OK; + return S_OK; } STDMETHOD(Next)(ULONG cConnections, CONNECTDATA *cd, ULONG *pcFetched) { @@ -723,42 +723,42 @@ public: const int count = connections.count(); - unsigned long i; - for (i = 0; i < cConnections; i++) { - if (current == count) - break; - cd[i] = connections.at(current); - cd[i].pUnk->AddRef(); - ++current; - } - if (pcFetched) - *pcFetched = i; - return i == cConnections ? S_OK : S_FALSE; + unsigned long i; + for (i = 0; i < cConnections; i++) { + if (current == count) + break; + cd[i] = connections.at(current); + cd[i].pUnk->AddRef(); + ++current; + } + if (pcFetched) + *pcFetched = i; + return i == cConnections ? S_OK : S_FALSE; } STDMETHOD(Skip)(ULONG cConnections) { const int count = connections.count(); - while (cConnections) { - if (current == count) - return S_FALSE; - ++current; - --cConnections; - } - return S_OK; + while (cConnections) { + if (current == count) + return S_FALSE; + ++current; + --cConnections; + } + return S_OK; } STDMETHOD(Reset)() { current = 0; - return S_OK; + return S_OK; } STDMETHOD(Clone)(IEnumConnections **ppEnum) { if (!ppEnum) return E_POINTER; - *ppEnum = new QAxConnection(*this); - (*ppEnum)->AddRef(); + *ppEnum = new QAxConnection(*this); + (*ppEnum)->AddRef(); - return S_OK; + return S_OK; } private: @@ -792,12 +792,12 @@ bool QAxWinEventFilter::nativeEventFilter(const QByteArray &, void *message, lon { MSG *pMsg = (MSG*)message; if (pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) - return false; + return false; bool ret = false; QWidget *aqt = QWidget::find(reinterpret_cast<WId>(pMsg->hwnd)); if (!aqt) - return ret; + return ret; // FIXME: 4.10.211: was '::GetParent(hwndForWidget(aqt));' HWND baseHwnd = hwndForWidget(aqt); @@ -809,10 +809,10 @@ bool QAxWinEventFilter::nativeEventFilter(const QByteArray &, void *message, lon axbase = (QAxServerBase*)GetWindowLong(baseHwnd, GWL_USERDATA); #endif - baseHwnd = ::GetParent(baseHwnd); + baseHwnd = ::GetParent(baseHwnd); } if (!axbase) - return ret; + return ret; HRESULT hres = axbase->TranslateAcceleratorW(pMsg); return hres == S_OK; @@ -826,29 +826,29 @@ class QClassFactory : public IClassFactory2 { public: QClassFactory(CLSID clsid) - : ref(0), licensed(false) + : ref(0), licensed(false) { - InitializeCriticalSection(&refCountSection); - - // COM only knows the CLSID, but QAxFactory is class name based... - QStringList keys = qAxFactory()->featureList(); - for (QStringList::Iterator key = keys.begin(); key != keys.end(); ++key) { - if (qAxFactory()->classID(*key) == clsid) { - className = *key; - break; - } - } - - const QMetaObject *mo = qAxFactory()->metaObject(className); - if (mo) { - classKey = QLatin1String(mo->classInfo(mo->indexOfClassInfo("LicenseKey")).value()); - licensed = !classKey.isEmpty(); - } + InitializeCriticalSection(&refCountSection); + + // COM only knows the CLSID, but QAxFactory is class name based... + QStringList keys = qAxFactory()->featureList(); + for (QStringList::Iterator key = keys.begin(); key != keys.end(); ++key) { + if (qAxFactory()->classID(*key) == clsid) { + className = *key; + break; + } + } + + const QMetaObject *mo = qAxFactory()->metaObject(className); + if (mo) { + classKey = QLatin1String(mo->classInfo(mo->indexOfClassInfo("LicenseKey")).value()); + licensed = !classKey.isEmpty(); + } } ~QClassFactory() { - DeleteCriticalSection(&refCountSection); + DeleteCriticalSection(&refCountSection); } // IUnknown @@ -866,31 +866,31 @@ public: } HRESULT WINAPI QueryInterface(REFIID iid, LPVOID *iface) { - *iface = 0; - if (iid == IID_IUnknown) - *iface = (IUnknown*)this; - else if (iid == IID_IClassFactory) - *iface = (IClassFactory*)this; - else if (iid == IID_IClassFactory2 && licensed) - *iface = (IClassFactory2*)this; - else - return E_NOINTERFACE; - - AddRef(); - return S_OK; + *iface = 0; + if (iid == IID_IUnknown) + *iface = (IUnknown*)this; + else if (iid == IID_IClassFactory) + *iface = (IClassFactory*)this; + else if (iid == IID_IClassFactory2 && licensed) + *iface = (IClassFactory2*)this; + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; } HRESULT WINAPI CreateInstanceHelper(IUnknown *pUnkOuter, REFIID iid, void **ppObject) { - if (pUnkOuter) { - if (iid != IID_IUnknown) - return CLASS_E_NOAGGREGATION; - const QMetaObject *mo = qAxFactory()->metaObject(className); - if (mo && !qstricmp(mo->classInfo(mo->indexOfClassInfo("Aggregatable")).value(), "no")) - return CLASS_E_NOAGGREGATION; - } - - // Make sure a QApplication instance is present (inprocess case) + if (pUnkOuter) { + if (iid != IID_IUnknown) + return CLASS_E_NOAGGREGATION; + const QMetaObject *mo = qAxFactory()->metaObject(className); + if (mo && !qstricmp(mo->classInfo(mo->indexOfClassInfo("Aggregatable")).value(), "no")) + return CLASS_E_NOAGGREGATION; + } + + // Make sure a QApplication instance is present (inprocess case) if (!qApp) { qax_ownQApp = true; int argc = 0; @@ -913,81 +913,81 @@ public: if (qax_ownQApp) qApp->processEvents(); - HRESULT res; - // Create the ActiveX wrapper - aggregate if requested - if (pUnkOuter) { - QAxServerAggregate *aggregate = new QAxServerAggregate(className, pUnkOuter); - res = aggregate->QueryInterface(iid, ppObject); - if (FAILED(res)) - delete aggregate; - } else { - QAxServerBase *activeqt = new QAxServerBase(className, pUnkOuter); - res = activeqt->QueryInterface(iid, ppObject); - if (FAILED(res)) - delete activeqt; - else - activeqt->registerActiveObject((IUnknown*)(IDispatch*)activeqt); - } - return res; + HRESULT res; + // Create the ActiveX wrapper - aggregate if requested + if (pUnkOuter) { + QAxServerAggregate *aggregate = new QAxServerAggregate(className, pUnkOuter); + res = aggregate->QueryInterface(iid, ppObject); + if (FAILED(res)) + delete aggregate; + } else { + QAxServerBase *activeqt = new QAxServerBase(className, pUnkOuter); + res = activeqt->QueryInterface(iid, ppObject); + if (FAILED(res)) + delete activeqt; + else + activeqt->registerActiveObject((IUnknown*)(IDispatch*)activeqt); + } + return res; } // IClassFactory HRESULT WINAPI CreateInstance(IUnknown *pUnkOuter, REFIID iid, void **ppObject) { - // class is licensed - if (licensed && !qAxFactory()->validateLicenseKey(className, QString())) - return CLASS_E_NOTLICENSED; + // class is licensed + if (licensed && !qAxFactory()->validateLicenseKey(className, QString())) + return CLASS_E_NOTLICENSED; - return CreateInstanceHelper(pUnkOuter, iid, ppObject); + return CreateInstanceHelper(pUnkOuter, iid, ppObject); } HRESULT WINAPI LockServer(BOOL fLock) { - if (fLock) - qAxLock(); - else - qAxUnlock(); + if (fLock) + qAxLock(); + else + qAxUnlock(); - return S_OK; + return S_OK; } // IClassFactory2 HRESULT WINAPI RequestLicKey(DWORD, BSTR *pKey) { - if (!pKey) - return E_POINTER; - *pKey = 0; + if (!pKey) + return E_POINTER; + *pKey = 0; - // This of course works only on fully licensed machines - if (!qAxFactory()->validateLicenseKey(className, QString())) - return CLASS_E_NOTLICENSED; + // This of course works only on fully licensed machines + if (!qAxFactory()->validateLicenseKey(className, QString())) + return CLASS_E_NOTLICENSED; - *pKey = QStringToBSTR(classKey); - return S_OK; + *pKey = QStringToBSTR(classKey); + return S_OK; } HRESULT WINAPI GetLicInfo(LICINFO *pLicInfo) { - if (!pLicInfo) - return E_POINTER; - pLicInfo->cbLicInfo = sizeof(LICINFO); + if (!pLicInfo) + return E_POINTER; + pLicInfo->cbLicInfo = sizeof(LICINFO); - // class specific license key? - const QMetaObject *mo = qAxFactory()->metaObject(className); - const char *key = mo->classInfo(mo->indexOfClassInfo("LicenseKey")).value(); - pLicInfo->fRuntimeKeyAvail = key && key[0]; + // class specific license key? + const QMetaObject *mo = qAxFactory()->metaObject(className); + const char *key = mo->classInfo(mo->indexOfClassInfo("LicenseKey")).value(); + pLicInfo->fRuntimeKeyAvail = key && key[0]; - // machine fully licensed? - pLicInfo->fLicVerified = qAxFactory()->validateLicenseKey(className, QString()); + // machine fully licensed? + pLicInfo->fLicVerified = qAxFactory()->validateLicenseKey(className, QString()); - return S_OK; + return S_OK; } HRESULT WINAPI CreateInstanceLic(IUnknown *pUnkOuter, IUnknown * /* pUnkReserved */, REFIID iid, BSTR bKey, PVOID *ppObject) { QString licenseKey = QString::fromWCharArray(bKey); - if (!qAxFactory()->validateLicenseKey(className, licenseKey)) - return CLASS_E_NOTLICENSED; - return CreateInstanceHelper(pUnkOuter, iid, ppObject); + if (!qAxFactory()->validateLicenseKey(className, licenseKey)) + return CLASS_E_NOTLICENSED; + return CreateInstanceHelper(pUnkOuter, iid, ppObject); } QString className; @@ -1004,14 +1004,14 @@ HRESULT GetClassObject(REFIID clsid, REFIID iid, void **ppUnk) { QClassFactory *factory = new QClassFactory(clsid); if (!factory) - return E_OUTOFMEMORY; + return E_OUTOFMEMORY; if (factory->className.isEmpty()) { - delete factory; - return E_NOINTERFACE; + delete factory; + return E_NOINTERFACE; } HRESULT res = factory->QueryInterface(iid, ppUnk); if (res != S_OK) - delete factory; + delete factory; return res; } @@ -1050,9 +1050,9 @@ QAxServerBase::QAxServerBase(QObject *o) qt.object = o; if (o) { - theObject = o; - isWidget = false; - class_name = QLatin1String(o->metaObject()->className()); + theObject = o; + isWidget = false; + class_name = QLatin1String(o->metaObject()->className()); } internalBind(); internalConnect(); @@ -1064,17 +1064,17 @@ QAxServerBase::QAxServerBase(QObject *o) void QAxServerBase::init() { qt.object = 0; - isWidget = false; - ownObject = false; - initNewCalled = false; - dirtyflag = false; - hasStockEvents = false; - stayTopLevel = false; - isInPlaceActive = false; - isUIActive = false; - wasUIActive = false; - inDesignMode = false; - canTakeFocus = false; + isWidget = false; + ownObject = false; + initNewCalled = false; + dirtyflag = false; + hasStockEvents = false; + stayTopLevel = false; + isInPlaceActive = false; + isUIActive = false; + wasUIActive = false; + inDesignMode = false; + canTakeFocus = false; freezeEvents = 0; exception = 0; @@ -1114,17 +1114,17 @@ QAxServerBase::~QAxServerBase() revokeActiveObject(); for (QAxServerBase::ConnectionPointsIterator it = points.begin(); it != points.end(); ++it) { - if (it.value()) - (*it)->Release(); + if (it.value()) + (*it)->Release(); } delete aggregatedObject; aggregatedObject = 0; if (theObject) { - qt.object->disconnect(this); - QObject *aqt = qt.object; - qt.object = 0; - if (ownObject) - delete aqt; + qt.object->disconnect(this); + QObject *aqt = qt.object; + qt.object = 0; + if (ownObject) + delete aqt; } if (m_spAdviseSink) m_spAdviseSink->Release(); @@ -1155,17 +1155,17 @@ QAxServerBase::~QAxServerBase() void QAxServerBase::registerActiveObject(IUnknown *object) { if (ole_ref || !qt.object || !qAxOutProcServer) - return; + return; const QMetaObject *mo = qt.object->metaObject(); if (!qstricmp(mo->classInfo(mo->indexOfClassInfo("RegisterObject")).value(), "yes")) - RegisterActiveObject(object, qAxFactory()->classID(class_name), ACTIVEOBJECT_WEAK, &ole_ref); + RegisterActiveObject(object, qAxFactory()->classID(class_name), ACTIVEOBJECT_WEAK, &ole_ref); } void QAxServerBase::revokeActiveObject() { if (!ole_ref) - return; + return; RevokeActiveObject(ole_ref, 0); ole_ref = 0; @@ -1177,7 +1177,7 @@ void QAxServerBase::revokeActiveObject() HRESULT WINAPI QAxServerBase::QueryInterface(REFIID iid, void **iface) { if (m_outerUnknown) - return m_outerUnknown->QueryInterface(iid, iface); + return m_outerUnknown->QueryInterface(iid, iface); return InternalQueryInterface(iid, iface); } @@ -1187,62 +1187,62 @@ HRESULT QAxServerBase::InternalQueryInterface(REFIID iid, void **iface) *iface = 0; if (iid == IID_IUnknown) { - *iface = (IUnknown*)(IDispatch*)this; + *iface = (IUnknown*)(IDispatch*)this; } else { - HRESULT res = S_OK; - if (aggregatedObject) - res = aggregatedObject->queryInterface(iid, iface); - if (*iface) - return res; + HRESULT res = S_OK; + if (aggregatedObject) + res = aggregatedObject->queryInterface(iid, iface); + if (*iface) + return res; } if (!(*iface)) { - if (iid == qAxFactory()->interfaceID(class_name)) - *iface = (IDispatch*)this; - if (iid == IID_IDispatch) - *iface = (IDispatch*)this; - else if (iid == IID_IAxServerBase) - *iface = (IAxServerBase*)this; - else if (iid == IID_IOleObject) - *iface = (IOleObject*)this; - else if (iid == IID_IConnectionPointContainer) - *iface = (IConnectionPointContainer*)this; - else if (iid == IID_IProvideClassInfo) - *iface = (IProvideClassInfo*)this; - else if (iid == IID_IProvideClassInfo2) - *iface = (IProvideClassInfo2*)this; - else if (iid == IID_IPersist) - *iface = (IPersist*)(IPersistStream*)this; - else if (iid == IID_IPersistStream) - *iface = (IPersistStream*)this; - else if (iid == IID_IPersistStreamInit) - *iface = (IPersistStreamInit*)this; - else if (iid == IID_IPersistStorage) - *iface = (IPersistStorage*)this; - else if (iid == IID_IPersistPropertyBag) - *iface = (IPersistPropertyBag*)this; + if (iid == qAxFactory()->interfaceID(class_name)) + *iface = (IDispatch*)this; + if (iid == IID_IDispatch) + *iface = (IDispatch*)this; + else if (iid == IID_IAxServerBase) + *iface = (IAxServerBase*)this; + else if (iid == IID_IOleObject) + *iface = (IOleObject*)this; + else if (iid == IID_IConnectionPointContainer) + *iface = (IConnectionPointContainer*)this; + else if (iid == IID_IProvideClassInfo) + *iface = (IProvideClassInfo*)this; + else if (iid == IID_IProvideClassInfo2) + *iface = (IProvideClassInfo2*)this; + else if (iid == IID_IPersist) + *iface = (IPersist*)(IPersistStream*)this; + else if (iid == IID_IPersistStream) + *iface = (IPersistStream*)this; + else if (iid == IID_IPersistStreamInit) + *iface = (IPersistStreamInit*)this; + else if (iid == IID_IPersistStorage) + *iface = (IPersistStorage*)this; + else if (iid == IID_IPersistPropertyBag) + *iface = (IPersistPropertyBag*)this; else if (iid == IID_IPersistFile && qAxFactory()->metaObject(class_name)->indexOfClassInfo("MIME") != -1) *iface = (IPersistFile*)this; - else if (iid == IID_IViewObject) - *iface = (IViewObject*)this; - else if (iid == IID_IViewObject2) - *iface = (IViewObject2*)this; - else if (isWidget) { - if (iid == IID_IOleControl) - *iface = (IOleControl*)this; - else if (iid == IID_IOleWindow) - *iface = (IOleWindow*)(IOleInPlaceObject*)this; - else if (iid == IID_IOleInPlaceObject) - *iface = (IOleInPlaceObject*)this; - else if (iid == IID_IOleInPlaceActiveObject) - *iface = (IOleInPlaceActiveObject*)this; - else if (iid == IID_IDataObject) - *iface = (IDataObject*)this; - } + else if (iid == IID_IViewObject) + *iface = (IViewObject*)this; + else if (iid == IID_IViewObject2) + *iface = (IViewObject2*)this; + else if (isWidget) { + if (iid == IID_IOleControl) + *iface = (IOleControl*)this; + else if (iid == IID_IOleWindow) + *iface = (IOleWindow*)(IOleInPlaceObject*)this; + else if (iid == IID_IOleInPlaceObject) + *iface = (IOleInPlaceObject*)this; + else if (iid == IID_IOleInPlaceActiveObject) + *iface = (IOleInPlaceActiveObject*)this; + else if (iid == IID_IDataObject) + *iface = (IDataObject*)this; + } } if (!*iface) - return E_NOINTERFACE; + return E_NOINTERFACE; AddRef(); return S_OK; @@ -1255,14 +1255,14 @@ void QAxServerBase::internalBind() { QAxBindable *axb = (QAxBindable*)qt.object->qt_metacast("QAxBindable"); if (axb) { - // no addref; this is aggregated - axb->activex = this; - if (!aggregatedObject) - aggregatedObject = axb->createAggregate(); - if (aggregatedObject) { - aggregatedObject->controlling_unknown = (IUnknown*)(IDispatch*)this; - aggregatedObject->the_object = qt.object; - } + // no addref; this is aggregated + axb->activex = this; + if (!aggregatedObject) + aggregatedObject = axb->createAggregate(); + if (aggregatedObject) { + aggregatedObject->controlling_unknown = (IUnknown*)(IDispatch*)this; + aggregatedObject->the_object = qt.object; + } } } @@ -1273,14 +1273,14 @@ void QAxServerBase::internalConnect() { QUuid eventsID = qAxFactory()->eventsID(class_name); if (!eventsID.isNull()) { - if (!points[eventsID]) - points[eventsID] = new QAxConnection(this, eventsID); + if (!points[eventsID]) + points[eventsID] = new QAxConnection(this, eventsID); - // connect the generic slot to all signals of qt.object - const QMetaObject *mo = qt.object->metaObject(); + // connect the generic slot to all signals of qt.object + const QMetaObject *mo = qt.object->metaObject(); for (int isignal = mo->methodCount()-1; isignal >= 0; --isignal) { if (mo->method(isignal).methodType() == QMetaMethod::Signal) - QMetaObject::connect(qt.object, isignal, this, isignal); + QMetaObject::connect(qt.object, isignal, this, isignal); } } } @@ -1294,12 +1294,12 @@ void QAxServerBase::internalConnect() bool QAxServerBase::internalCreate() { if (qt.object) - return true; + return true; qt.object = qAxFactory()->createObject(class_name); Q_ASSERT(qt.object); if (!qt.object) - return false; + return false; theObject = qt.object; ownObject = true; @@ -1398,20 +1398,20 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM switch (uMsg) { case WM_NCDESTROY: - that->m_hWnd = 0; - break; + that->m_hWnd = 0; + break; case WM_QUERYENDSESSION: case WM_DESTROY: if (that->qt.widget) { that->qt.widget->hide(); } - break; + break; case WM_SHOWWINDOW: - if(wParam) { - that->internalCreate(); - if (!that->stayTopLevel) { + if (wParam) { + that->internalCreate(); + if (!that->stayTopLevel) { // Set this property on window to pass the native handle to platform plugin, // so that it can create the window with proper flags instead of thinking // it is toplevel. @@ -1433,31 +1433,31 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM } that->qt.widget->raise(); that->qt.widget->move(0, 0); - } - that->qt.widget->show(); - } else if (that->qt.widget) { - that->qt.widget->hide(); - } - break; + } + that->qt.widget->show(); + } else if (that->qt.widget) { + that->qt.widget->hide(); + } + break; case WM_ERASEBKGND: - that->updateMask(); - break; + that->updateMask(); + break; case WM_SIZE: that->resize(QSize(LOWORD(lParam), HIWORD(lParam))); - break; + break; case WM_SETFOCUS: - if (that->isInPlaceActive && that->m_spClientSite && !that->inDesignMode && that->canTakeFocus) { - that->DoVerb(OLEIVERB_UIACTIVATE, NULL, that->m_spClientSite, 0, that->m_hWnd, &rcPos); - if (that->isUIActive) { - IOleControlSite *spSite = 0; - that->m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&spSite); - if (spSite) { - spSite->OnFocus(true); - spSite->Release(); - } + if (that->isInPlaceActive && that->m_spClientSite && !that->inDesignMode && that->canTakeFocus) { + that->DoVerb(OLEIVERB_UIACTIVATE, NULL, that->m_spClientSite, 0, that->m_hWnd, &rcPos); + if (that->isUIActive) { + IOleControlSite *spSite = 0; + that->m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&spSite); + if (spSite) { + spSite->OnFocus(true); + spSite->Release(); + } QWidget *candidate = that->qt.widget; while (!(candidate->focusPolicy() & Qt::TabFocus)) { candidate = candidate->nextInFocusChain(); @@ -1472,85 +1472,85 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM if (::GetKeyState(VK_SHIFT) < 0) widget->focusNextPrevChild(false); } - } - } - break; + } + } + break; case WM_KILLFOCUS: - if (that->isInPlaceActive && that->isUIActive && that->m_spClientSite) { - IOleControlSite *spSite = 0; - that->m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&spSite); - if (spSite) { - if (!::IsChild(that->m_hWnd, ::GetFocus())) - spSite->OnFocus(false); - spSite->Release(); - } - } - break; + if (that->isInPlaceActive && that->isUIActive && that->m_spClientSite) { + IOleControlSite *spSite = 0; + that->m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&spSite); + if (spSite) { + if (!::IsChild(that->m_hWnd, ::GetFocus())) + spSite->OnFocus(false); + spSite->Release(); + } + } + break; case WM_MOUSEACTIVATE: - that->DoVerb(OLEIVERB_UIACTIVATE, NULL, that->m_spClientSite, 0, that->m_hWnd, &rcPos); - break; + that->DoVerb(OLEIVERB_UIACTIVATE, NULL, that->m_spClientSite, 0, that->m_hWnd, &rcPos); + break; case WM_INITMENUPOPUP: - if (that->qt.widget) { - that->currentPopup = that->menuMap[(HMENU)wParam]; - if (!that->currentPopup) - break; - const QMetaObject *mo = that->currentPopup->metaObject(); - int index = mo->indexOfSignal("aboutToShow()"); - if (index < 0) - break; - - that->currentPopup->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0); - that->createPopup(that->currentPopup, (HMENU)wParam); - return 0; - } - break; + if (that->qt.widget) { + that->currentPopup = that->menuMap[(HMENU)wParam]; + if (!that->currentPopup) + break; + const QMetaObject *mo = that->currentPopup->metaObject(); + int index = mo->indexOfSignal("aboutToShow()"); + if (index < 0) + break; + + that->currentPopup->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0); + that->createPopup(that->currentPopup, (HMENU)wParam); + return 0; + } + break; case WM_MENUSELECT: case WM_COMMAND: - if (that->qt.widget) { - QMenuBar *menuBar = that->menuBar; - if (!menuBar) - break; + if (that->qt.widget) { + QMenuBar *menuBar = that->menuBar; + if (!menuBar) + break; QObject *menuObject = 0; - bool menuClosed = false; + bool menuClosed = false; if (uMsg == WM_COMMAND) { - menuObject = that->actionMap.value(wParam); + menuObject = that->actionMap.value(wParam); } else if (!lParam) { - menuClosed = true; + menuClosed = true; menuObject = that->currentPopup; } else { menuObject = that->actionMap.value(LOWORD(wParam)); } - if (menuObject) { - const QMetaObject *mo = menuObject->metaObject(); - int index = -1; + if (menuObject) { + const QMetaObject *mo = menuObject->metaObject(); + int index = -1; - if (uMsg == WM_COMMAND) - index = mo->indexOfSignal("activated()"); - else if (menuClosed) - index = mo->indexOfSignal("aboutToHide()"); - else - index = mo->indexOfSignal("hovered()"); + if (uMsg == WM_COMMAND) + index = mo->indexOfSignal("activated()"); + else if (menuClosed) + index = mo->indexOfSignal("aboutToHide()"); + else + index = mo->indexOfSignal("hovered()"); - if (index < 0) - break; + if (index < 0) + break; - menuObject->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0); + menuObject->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0); if (menuClosed || uMsg == WM_COMMAND) that->currentPopup = 0; - return 0; - } - } - break; + return 0; + } + } + break; default: - break; + break; } } @@ -1586,7 +1586,7 @@ HWND QAxServerBase::create(HWND hWndParent, RECT& rcPos) } LeaveCriticalSection(&createWindowSection); if (!atom && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) - return 0; + return 0; Q_ASSERT(!m_hWnd); HWND hWnd = ::CreateWindow((wchar_t*)cn.utf16(), 0, @@ -1611,7 +1611,7 @@ HMENU QAxServerBase::createPopup(QMenu *popup, HMENU oldMenu) menuMap.insert(popupMenu, popup); if (oldMenu) while (GetMenuItemCount(oldMenu)) { - DeleteMenu(oldMenu, 0, MF_BYPOSITION); + DeleteMenu(oldMenu, 0, MF_BYPOSITION); } const QList<QAction*> actions = popup->actions(); @@ -1628,7 +1628,7 @@ HMENU QAxServerBase::createPopup(QMenu *popup, HMENU oldMenu) if (action->isChecked()) flags |= MF_CHECKED; - ushort itemId; + ushort itemId; if (flags & MF_POPUP) { itemId = static_cast<ushort>( reinterpret_cast<quintptr>(createPopup(action->menu())) @@ -1661,21 +1661,21 @@ void QAxServerBase::createMenu(QMenuBar *menuBar) QAction *action = actions.at(i); uint flags = action->isEnabled() ? MF_ENABLED : MF_GRAYED; - if (action->isSeparator()) - flags |= MF_SEPARATOR; - else if (action->menu()) - flags |= MF_POPUP; - else - flags |= MF_STRING; - - if (action->text() == QCoreApplication::translate(qt.widget->metaObject()->className(), "&Edit")) - edit++; - else if (action->text() == QCoreApplication::translate(qt.widget->metaObject()->className(), "&Help")) - help++; - else - object++; - - ushort itemId; + if (action->isSeparator()) + flags |= MF_SEPARATOR; + else if (action->menu()) + flags |= MF_POPUP; + else + flags |= MF_STRING; + + if (action->text() == QCoreApplication::translate(qt.widget->metaObject()->className(), "&Edit")) + edit++; + else if (action->text() == QCoreApplication::translate(qt.widget->metaObject()->className(), "&Help")) + help++; + else + object++; + + ushort itemId; if (flags & MF_POPUP) { itemId = static_cast<ushort>( reinterpret_cast<quintptr>(createPopup(action->menu())) @@ -1690,9 +1690,9 @@ void QAxServerBase::createMenu(QMenuBar *menuBar) OLEMENUGROUPWIDTHS menuWidths = { { 0,edit,0,object,0,help } }; HRESULT hres = m_spInPlaceFrame->InsertMenus(hmenuShared, &menuWidths); if (FAILED(hres)) { - ::DestroyMenu(hmenuShared); - hmenuShared = 0; - return; + ::DestroyMenu(hmenuShared); + hmenuShared = 0; + return; } m_spInPlaceFrame->GetWindow(&hwndMenuOwner); @@ -1700,9 +1700,9 @@ void QAxServerBase::createMenu(QMenuBar *menuBar) holemenu = OleCreateMenuDescriptor(hmenuShared, &menuWidths); hres = m_spInPlaceFrame->SetMenu(hmenuShared, holemenu, m_hWnd); if (FAILED(hres)) { - ::DestroyMenu(hmenuShared); - hmenuShared = 0; - OleDestroyMenuDescriptor(holemenu); + ::DestroyMenu(hmenuShared); + hmenuShared = 0; + OleDestroyMenuDescriptor(holemenu); } } @@ -1712,13 +1712,13 @@ void QAxServerBase::createMenu(QMenuBar *menuBar) void QAxServerBase::removeMenu() { if (hmenuShared) - m_spInPlaceFrame->RemoveMenus(hmenuShared); + m_spInPlaceFrame->RemoveMenus(hmenuShared); holemenu = 0; m_spInPlaceFrame->SetMenu(0, 0, m_hWnd); if (hmenuShared) { - DestroyMenu(hmenuShared); - hmenuShared = 0; - menuMap.clear(); + DestroyMenu(hmenuShared); + hmenuShared = 0; + menuMap.clear(); } hwndMenuOwner = 0; } @@ -1732,8 +1732,8 @@ extern bool ignoreProps(const char *test); void QAxServerBase::ensureMetaData() { if (!m_spTypeInfo) { - qAxTypeLibrary->GetTypeInfoOfGuid(qAxFactory()->interfaceID(class_name), &m_spTypeInfo); - m_spTypeInfo->AddRef(); + qAxTypeLibrary->GetTypeInfoOfGuid(qAxFactory()->interfaceID(class_name), &m_spTypeInfo); + m_spTypeInfo->AddRef(); } } @@ -1745,17 +1745,17 @@ void QAxServerBase::ensureMetaData() bool QAxServerBase::isPropertyExposed(int index) { if (!theObject) - return false; + return false; bool result = false; const QMetaObject *mo = theObject->metaObject(); int qtProps = 0; if (theObject->isWidgetType()) - qtProps = QWidget::staticMetaObject.propertyCount(); + qtProps = QWidget::staticMetaObject.propertyCount(); QMetaProperty property = mo->property(index); if (index <= qtProps && ignoreProps(property.name())) - return result; + return result; BSTR bstrNames = QStringToBSTR(QLatin1String(property.name())); DISPID dispId; @@ -1774,14 +1774,14 @@ bool QAxServerBase::isPropertyExposed(int index) void QAxServerBase::update() { if (isInPlaceActive) { - if (m_hWnd) - ::InvalidateRect(m_hWnd, 0, true); - else if (m_spInPlaceSite) - m_spInPlaceSite->InvalidateRect(NULL, true); + if (m_hWnd) + ::InvalidateRect(m_hWnd, 0, true); + else if (m_spInPlaceSite) + m_spInPlaceSite->InvalidateRect(NULL, true); } else if (m_spAdviseSink) { m_spAdviseSink->OnViewChange(DVASPECT_CONTENT, -1); for (int i = 0; i < adviseSinks.count(); ++i) { - adviseSinks.at(i).pAdvSink->OnViewChange(DVASPECT_CONTENT, -1); + adviseSinks.at(i).pAdvSink->OnViewChange(DVASPECT_CONTENT, -1); } } } @@ -1816,7 +1816,7 @@ void QAxServerBase::resize(const QSize &size) void QAxServerBase::updateGeometry() { if (!isWidget || !qt.widget) - return; + return; const QSize sizeHint = qt.widget->sizeHint(); const QSize size = qt.widget->size(); @@ -1827,11 +1827,11 @@ void QAxServerBase::updateGeometry() } else { // according to sizePolicy rules if already resized QSizePolicy sizePolicy = qt.widget->sizePolicy(); if (sizeHint.width() > size.width() && !(sizePolicy.horizontalPolicy() & QSizePolicy::ShrinkFlag)) - newSize.setWidth(sizeHint.width()); + newSize.setWidth(sizeHint.width()); if (sizeHint.width() < size.width() && !(sizePolicy.horizontalPolicy() & QSizePolicy::GrowFlag)) newSize.setWidth(sizeHint.width()); if (sizeHint.height() > size.height() && !(sizePolicy.verticalPolicy() & QSizePolicy::ShrinkFlag)) - newSize.setHeight(sizeHint.height()); + newSize.setHeight(sizeHint.height()); if (sizeHint.height() < size.height() && !(sizePolicy.verticalPolicy() & QSizePolicy::GrowFlag)) newSize.setHeight(sizeHint.height()); } @@ -1852,7 +1852,7 @@ void QAxServerBase::updateGeometry() void QAxServerBase::updateMask() { if (!isWidget || !qt.widget || qt.widget->mask().isEmpty()) - return; + return; QRegion rgn = qt.widget->mask(); HRGN hrgn = qaxHrgnFromQRegion(rgn); @@ -1869,7 +1869,7 @@ static inline QByteArray paramType(const QByteArray &ptype, bool *out) *out = ptype.endsWith('&') || ptype.endsWith("**"); if (*out) { QByteArray res(ptype); - res.truncate(res.length() - 1); + res.truncate(res.length() - 1); return res; } @@ -2081,38 +2081,38 @@ bool QAxServerBase::emitRequestPropertyChange(const char *property) IConnectionPoint *cpoint = 0; FindConnectionPoint(IID_IPropertyNotifySink, &cpoint); if (cpoint) { - IEnumConnections *clist = 0; - cpoint->EnumConnections(&clist); - if (clist) { - clist->Reset(); - ULONG cc = 1; - CONNECTDATA c[1]; - clist->Next(cc, (CONNECTDATA*)&c, &cc); - if (cc) { - if (dispId == -1) { - BSTR bstr = QStringToBSTR(QLatin1String(property)); - GetIDsOfNames(IID_NULL, &bstr, 1, LOCALE_USER_DEFAULT, &dispId); - SysFreeString(bstr); - } - if (dispId != -1) while (cc) { - if (c->pUnk) { - IPropertyNotifySink *sink = 0; - c->pUnk->QueryInterface(IID_IPropertyNotifySink, (void**)&sink); - bool disallows = sink && sink->OnRequestEdit(dispId) == S_FALSE; - sink->Release(); - c->pUnk->Release(); - if (disallows) { // a client disallows the property to change - clist->Release(); - cpoint->Release(); - return false; - } - } - clist->Next(cc, (CONNECTDATA*)&c, &cc); - } - } - clist->Release(); - } - cpoint->Release(); + IEnumConnections *clist = 0; + cpoint->EnumConnections(&clist); + if (clist) { + clist->Reset(); + ULONG cc = 1; + CONNECTDATA c[1]; + clist->Next(cc, (CONNECTDATA*)&c, &cc); + if (cc) { + if (dispId == -1) { + BSTR bstr = QStringToBSTR(QLatin1String(property)); + GetIDsOfNames(IID_NULL, &bstr, 1, LOCALE_USER_DEFAULT, &dispId); + SysFreeString(bstr); + } + if (dispId != -1) while (cc) { + if (c->pUnk) { + IPropertyNotifySink *sink = 0; + c->pUnk->QueryInterface(IID_IPropertyNotifySink, (void**)&sink); + bool disallows = sink && sink->OnRequestEdit(dispId) == S_FALSE; + sink->Release(); + c->pUnk->Release(); + if (disallows) { // a client disallows the property to change + clist->Release(); + cpoint->Release(); + return false; + } + } + clist->Next(cc, (CONNECTDATA*)&c, &cc); + } + } + clist->Release(); + } + cpoint->Release(); } dirtyflag = true; return true; @@ -2129,35 +2129,35 @@ void QAxServerBase::emitPropertyChanged(const char *property) IConnectionPoint *cpoint = 0; FindConnectionPoint(IID_IPropertyNotifySink, &cpoint); if (cpoint) { - IEnumConnections *clist = 0; - cpoint->EnumConnections(&clist); - if (clist) { - clist->Reset(); - ULONG cc = 1; - CONNECTDATA c[1]; - clist->Next(cc, (CONNECTDATA*)&c, &cc); - if (cc) { - if (dispId == -1) { - BSTR bstr = QStringToBSTR(QLatin1String(property)); - GetIDsOfNames(IID_NULL, &bstr, 1, LOCALE_USER_DEFAULT, &dispId); - SysFreeString(bstr); - } - if (dispId != -1) while (cc) { - if (c->pUnk) { - IPropertyNotifySink *sink = 0; - c->pUnk->QueryInterface(IID_IPropertyNotifySink, (void**)&sink); - if (sink) { - sink->OnChanged(dispId); - sink->Release(); - } - c->pUnk->Release(); - } - clist->Next(cc, (CONNECTDATA*)&c, &cc); - } - } - clist->Release(); - } - cpoint->Release(); + IEnumConnections *clist = 0; + cpoint->EnumConnections(&clist); + if (clist) { + clist->Reset(); + ULONG cc = 1; + CONNECTDATA c[1]; + clist->Next(cc, (CONNECTDATA*)&c, &cc); + if (cc) { + if (dispId == -1) { + BSTR bstr = QStringToBSTR(QLatin1String(property)); + GetIDsOfNames(IID_NULL, &bstr, 1, LOCALE_USER_DEFAULT, &dispId); + SysFreeString(bstr); + } + if (dispId != -1) while (cc) { + if (c->pUnk) { + IPropertyNotifySink *sink = 0; + c->pUnk->QueryInterface(IID_IPropertyNotifySink, (void**)&sink); + if (sink) { + sink->OnChanged(dispId); + sink->Release(); + } + c->pUnk->Release(); + } + clist->Next(cc, (CONNECTDATA*)&c, &cc); + } + } + clist->Release(); + } + cpoint->Release(); } dirtyflag = true; } @@ -2169,11 +2169,11 @@ void QAxServerBase::emitPropertyChanged(const char *property) HRESULT WINAPI QAxServerBase::GetClassInfo(ITypeInfo** pptinfo) { if (!pptinfo) - return E_POINTER; + return E_POINTER; *pptinfo = 0; if (!qAxTypeLibrary) - return DISP_E_BADINDEX; + return DISP_E_BADINDEX; return qAxTypeLibrary->GetTypeInfoOfGuid(qAxFactory()->classID(class_name), pptinfo); } @@ -2185,11 +2185,11 @@ HRESULT WINAPI QAxServerBase::GetClassInfo(ITypeInfo** pptinfo) HRESULT WINAPI QAxServerBase::GetGUID(DWORD dwGuidKind, GUID* pGUID) { if (!pGUID) - return E_POINTER; + return E_POINTER; if (dwGuidKind == GUIDKIND_DEFAULT_SOURCE_DISP_IID) { - *pGUID = qAxFactory()->eventsID(class_name); - return S_OK; + *pGUID = qAxFactory()->eventsID(class_name); + return S_OK; } *pGUID = GUID_NULL; return E_FAIL; @@ -2202,7 +2202,7 @@ HRESULT WINAPI QAxServerBase::GetGUID(DWORD dwGuidKind, GUID* pGUID) HRESULT WINAPI QAxServerBase::GetTypeInfoCount(UINT* pctinfo) { if (!pctinfo) - return E_POINTER; + return E_POINTER; *pctinfo = qAxTypeLibrary ? 1 : 0; return S_OK; @@ -2214,10 +2214,10 @@ HRESULT WINAPI QAxServerBase::GetTypeInfoCount(UINT* pctinfo) HRESULT WINAPI QAxServerBase::GetTypeInfo(UINT /* itinfo */, LCID /*lcid*/, ITypeInfo** pptinfo) { if (!pptinfo) - return E_POINTER; + return E_POINTER; if (!qAxTypeLibrary) - return DISP_E_BADINDEX; + return DISP_E_BADINDEX; ensureMetaData(); @@ -2231,17 +2231,17 @@ HRESULT WINAPI QAxServerBase::GetTypeInfo(UINT /* itinfo */, LCID /*lcid*/, ITyp Provides the names of the methods implemented in this IDispatch implementation. */ HRESULT WINAPI QAxServerBase::GetIDsOfNames(REFIID /* riid */, LPOLESTR* rgszNames, UINT cNames, - LCID /*lcid*/, DISPID* rgdispid) + LCID /*lcid*/, DISPID* rgdispid) { if (!rgszNames || !rgdispid) - return E_POINTER; + return E_POINTER; if (!qAxTypeLibrary) - return DISP_E_UNKNOWNNAME; + return DISP_E_UNKNOWNNAME; ensureMetaData(); if (!m_spTypeInfo) - return DISP_E_UNKNOWNNAME; + return DISP_E_UNKNOWNNAME; return m_spTypeInfo->GetIDsOfNames(rgszNames, cNames, rgdispid); } @@ -2250,13 +2250,13 @@ HRESULT WINAPI QAxServerBase::GetIDsOfNames(REFIID /* riid */, LPOLESTR* rgszNam Map the COM call to the Qt slot/property for \a dispidMember. */ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, - LCID /*lcid*/, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, - EXCEPINFO* pexcepinfo, UINT* puArgErr) + LCID /*lcid*/, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, + EXCEPINFO* pexcepinfo, UINT* puArgErr) { if (riid != IID_NULL) - return DISP_E_UNKNOWNINTERFACE; + return DISP_E_UNKNOWNINTERFACE; if (!theObject) - return E_UNEXPECTED; + return E_UNEXPECTED; HRESULT res = DISP_E_MEMBERNOTFOUND; @@ -2265,7 +2265,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, int index = uniqueIndex ? indexCache.value(dispidMember, -1) : -1; QByteArray name; if (index == -1) { - ensureMetaData(); + ensureMetaData(); // This property or method is invoked when an ActiveX client specifies // the object name without a property or method. We only support property. @@ -2277,75 +2277,75 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, index = mo->indexOfProperty(name); } } else { - BSTR bname; - UINT cname = 0; - if (m_spTypeInfo) - m_spTypeInfo->GetNames(dispidMember, &bname, 1, &cname); - if (!cname) - return res; + BSTR bname; + UINT cname = 0; + if (m_spTypeInfo) + m_spTypeInfo->GetNames(dispidMember, &bname, 1, &cname); + if (!cname) + return res; name = QString::fromWCharArray(bname).toLatin1(); - SysFreeString(bname); + SysFreeString(bname); } } const QMetaObject *mo = qt.object->metaObject(); QSize oldSizeHint; if (isWidget) - oldSizeHint = qt.widget->sizeHint(); + oldSizeHint = qt.widget->sizeHint(); switch (wFlags) { case DISPATCH_PROPERTYGET|DISPATCH_METHOD: case DISPATCH_PROPERTYGET: - { - if (index == -1) { - index = mo->indexOfProperty(name); - if (index == -1 && wFlags == DISPATCH_PROPERTYGET) - return res; - } - - QMetaProperty property; + { + if (index == -1) { + index = mo->indexOfProperty(name); + if (index == -1 && wFlags == DISPATCH_PROPERTYGET) + return res; + } + + QMetaProperty property; if (index < mo->propertyCount()) property = mo->property(index); - if (property.isReadable()) { - if (!pvarResult) - return DISP_E_PARAMNOTOPTIONAL; - if (pDispParams->cArgs || - pDispParams->cNamedArgs) - return DISP_E_BADPARAMCOUNT; - - QVariant var = qt.object->property(property.name()); - if (!var.isValid()) - res = DISP_E_MEMBERNOTFOUND; - else if (!QVariantToVARIANT(var, *pvarResult)) - res = DISP_E_TYPEMISMATCH; - else - res = S_OK; - break; - } else if (wFlags == DISPATCH_PROPERTYGET) { - break; - } - } - // FALLTHROUGH if wFlags == DISPATCH_PROPERTYGET|DISPATCH_METHOD AND not a property. + if (property.isReadable()) { + if (!pvarResult) + return DISP_E_PARAMNOTOPTIONAL; + if (pDispParams->cArgs || + pDispParams->cNamedArgs) + return DISP_E_BADPARAMCOUNT; + + QVariant var = qt.object->property(property.name()); + if (!var.isValid()) + res = DISP_E_MEMBERNOTFOUND; + else if (!QVariantToVARIANT(var, *pvarResult)) + res = DISP_E_TYPEMISMATCH; + else + res = S_OK; + break; + } else if (wFlags == DISPATCH_PROPERTYGET) { + break; + } + } + // FALLTHROUGH if wFlags == DISPATCH_PROPERTYGET|DISPATCH_METHOD AND not a property. case DISPATCH_METHOD: - { + { int nameLength = 0; - if (index == -1) { - nameLength = name.length(); - name += '('; - // no parameter - shortcut - if (!pDispParams->cArgs) - index = mo->indexOfSlot((name + ')')); - // search - if (index == -1) { - for (int i = 0; i < mo->methodCount(); ++i) { + if (index == -1) { + nameLength = name.length(); + name += '('; + // no parameter - shortcut + if (!pDispParams->cArgs) + index = mo->indexOfSlot((name + ')')); + // search + if (index == -1) { + for (int i = 0; i < mo->methodCount(); ++i) { const QMetaMethod slot(mo->method(i)); if (slot.methodType() == QMetaMethod::Slot && slot.methodSignature().startsWith(name)) { - index = i; - break; - } - } + index = i; + break; + } + } // resolve overloads if (index == -1) { QRegExp regexp(QLatin1String("_([0-9])\\(")); @@ -2364,27 +2364,27 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, } } } - if (index == -1) - return res; - } - } + if (index == -1) + return res; + } + } int lookupIndex = index; - // get slot info - QMetaMethod slot(mo->method(index)); - Q_ASSERT(slot.methodType() == QMetaMethod::Slot || slot.methodType() == QMetaMethod::Method); - QByteArray type = slot.typeName(); + // get slot info + QMetaMethod slot(mo->method(index)); + Q_ASSERT(slot.methodType() == QMetaMethod::Slot || slot.methodType() == QMetaMethod::Method); + QByteArray type = slot.typeName(); name = slot.methodSignature(); nameLength = name.indexOf('('); - QByteArray prototype = name.mid(nameLength + 1); - prototype.truncate(prototype.length() - 1); - QList<QByteArray> ptypes; - if (!prototype.isEmpty()) - ptypes = prototype.split(','); - UINT pcount = ptypes.count(); - - // verify parameter count + QByteArray prototype = name.mid(nameLength + 1); + prototype.truncate(prototype.length() - 1); + QList<QByteArray> ptypes; + if (!prototype.isEmpty()) + ptypes = prototype.split(','); + UINT pcount = ptypes.count(); + + // verify parameter count if (pcount > pDispParams->cArgs) { // count cloned slots immediately following the real thing while (index < mo->methodCount()) { @@ -2399,13 +2399,13 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, } // still wrong :( if (pcount > pDispParams->cArgs) - return DISP_E_PARAMNOTOPTIONAL; + return DISP_E_PARAMNOTOPTIONAL; } else if (pcount < pDispParams->cArgs) { - return DISP_E_BADPARAMCOUNT; + return DISP_E_BADPARAMCOUNT; } - // setup parameters (pcount + return) - bool ok = true; + // setup parameters (pcount + return) + bool ok = true; void *static_argv[QAX_NUM_PARAMS + 1]; QVariant static_varp[QAX_NUM_PARAMS + 1]; void *static_argv_pointer[QAX_NUM_PARAMS + 1]; @@ -2414,9 +2414,9 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, if (!type.isEmpty()) ++totalParam; - void **argv = 0; // the actual array passed into qt_metacall + void **argv = 0; // the actual array passed into qt_metacall void **argv_pointer = 0; // in case we need an additional level of indirection - QVariant *varp = 0; // QVariants to hold the temporary Qt data object for us + QVariant *varp = 0; // QVariants to hold the temporary Qt data object for us if (totalParam) { if (totalParam <= QAX_NUM_PARAMS) { @@ -2432,13 +2432,13 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, argv_pointer[0] = 0; } - for (UINT p = 0; p < pcount; ++p) { - // map the VARIANT to the void* - bool out; - QByteArray ptype = paramType(ptypes.at(p), &out); - varp[p + 1] = VARIANTToQVariant(pDispParams->rgvarg[pcount - p - 1], ptype); + for (UINT p = 0; p < pcount; ++p) { + // map the VARIANT to the void* + bool out; + QByteArray ptype = paramType(ptypes.at(p), &out); + varp[p + 1] = VARIANTToQVariant(pDispParams->rgvarg[pcount - p - 1], ptype); argv_pointer[p + 1] = 0; - if (varp[p + 1].isValid()) { + if (varp[p + 1].isValid()) { if (varp[p + 1].type() == QVariant::UserType) { argv[p + 1] = varp[p + 1].data(); } else if (ptype == "QVariant") { @@ -2452,15 +2452,15 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, } } else if (ptype == "QVariant") { argv[p + 1] = varp + p + 1; - } else { - if (puArgErr) - *puArgErr = pcount-p-1; - ok = false; - } - } + } else { + if (puArgErr) + *puArgErr = pcount-p-1; + ok = false; + } + } // return value - if (!type.isEmpty() && type != "void") { + if (!type.isEmpty() && type != "void") { QVariant::Type vt = QVariant::nameToType(type); if (vt == QVariant::UserType) vt = QVariant::Invalid; @@ -2480,46 +2480,46 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, argv_pointer[0] = argv[0]; argv[0] = argv_pointer; } - } - - // call the slot if everthing went fine. - if (ok) { - ++invokeCount; - qt.object->qt_metacall(QMetaObject::InvokeMetaMethod, index, argv); - if (--invokeCount < 0) - invokeCount = 0; - - // update reference parameters and return value - for (UINT p = 0; p < pcount; ++p) { - bool out; - QByteArray ptype = paramType(ptypes.at(p), &out); - if (out) { - if (!QVariantToVARIANT(varp[p + 1], pDispParams->rgvarg[pcount - p - 1], ptype, out)) - ok = false; - } - } + } + + // call the slot if everthing went fine. + if (ok) { + ++invokeCount; + qt.object->qt_metacall(QMetaObject::InvokeMetaMethod, index, argv); + if (--invokeCount < 0) + invokeCount = 0; + + // update reference parameters and return value + for (UINT p = 0; p < pcount; ++p) { + bool out; + QByteArray ptype = paramType(ptypes.at(p), &out); + if (out) { + if (!QVariantToVARIANT(varp[p + 1], pDispParams->rgvarg[pcount - p - 1], ptype, out)) + ok = false; + } + } if (!type.isEmpty() && type != "void" && pvarResult) { if (!varp[0].isValid() && type != "QVariant") varp[0] = QVariant(QMetaType::type(type), argv_pointer); // varp[0].setValue(argv_pointer[0], type); - ok = QVariantToVARIANT(varp[0], *pvarResult, type); + ok = QVariantToVARIANT(varp[0], *pvarResult, type); } - } + } if (argv && argv != static_argv) { delete []argv; delete []argv_pointer; delete []varp; } - res = ok ? S_OK : DISP_E_TYPEMISMATCH; + res = ok ? S_OK : DISP_E_TYPEMISMATCH; // reset in case index changed for default-arg handling index = lookupIndex; - } - break; + } + break; case DISPATCH_PROPERTYPUT: case DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF: - { + { if (index == -1) { index = mo->indexOfProperty(name); if (index == -1) @@ -2551,11 +2551,11 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, } res = S_OK; - } - break; + } + break; default: - break; + break; } // maybe calling a setter? Notify client about changes @@ -2592,46 +2592,46 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, } if (index != -1 && uniqueIndex) - indexCache.insert(dispidMember, index); + indexCache.insert(dispidMember, index); if (exception) { - if (pexcepinfo) { - memset(pexcepinfo, 0, sizeof(EXCEPINFO)); - - pexcepinfo->wCode = exception->code; - if (!exception->src.isNull()) - pexcepinfo->bstrSource = QStringToBSTR(exception->src); - if (!exception->desc.isNull()) - pexcepinfo->bstrDescription = QStringToBSTR(exception->desc); - if (!exception->context.isNull()) { - QString context = exception->context; - int contextID = 0; - int br = context.indexOf(QLatin1Char('[')); - if (br != -1) { - context = context.mid(br+1); - context = context.left(context.length() - 1); - contextID = context.toInt(); - - context = exception->context; - context = context.left(br-1); - } - pexcepinfo->bstrHelpFile = QStringToBSTR(context); - pexcepinfo->dwHelpContext = contextID; - } - } - delete exception; - exception = 0; - return DISP_E_EXCEPTION; + if (pexcepinfo) { + memset(pexcepinfo, 0, sizeof(EXCEPINFO)); + + pexcepinfo->wCode = exception->code; + if (!exception->src.isNull()) + pexcepinfo->bstrSource = QStringToBSTR(exception->src); + if (!exception->desc.isNull()) + pexcepinfo->bstrDescription = QStringToBSTR(exception->desc); + if (!exception->context.isNull()) { + QString context = exception->context; + int contextID = 0; + int br = context.indexOf(QLatin1Char('[')); + if (br != -1) { + context = context.mid(br+1); + context = context.left(context.length() - 1); + contextID = context.toInt(); + + context = exception->context; + context = context.left(br-1); + } + pexcepinfo->bstrHelpFile = QStringToBSTR(context); + pexcepinfo->dwHelpContext = contextID; + } + } + delete exception; + exception = 0; + return DISP_E_EXCEPTION; } else if (isWidget) { - QSize sizeHint = qt.widget->sizeHint(); - if (oldSizeHint != sizeHint) { - updateGeometry(); - if (m_spInPlaceSite) { + QSize sizeHint = qt.widget->sizeHint(); + if (oldSizeHint != sizeHint) { + updateGeometry(); + if (m_spInPlaceSite) { RECT rect = {0, 0, sizeHint.width(), sizeHint.height()}; - m_spInPlaceSite->OnPosRectChange(&rect); - } - } - updateMask(); + m_spInPlaceSite->OnPosRectChange(&rect); + } + } + updateMask(); } return res; @@ -2644,7 +2644,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, HRESULT WINAPI QAxServerBase::EnumConnectionPoints(IEnumConnectionPoints **epoints) { if (!epoints) - return E_POINTER; + return E_POINTER; *epoints = new QAxSignalVec(points); (*epoints)->AddRef(); return S_OK; @@ -2656,13 +2656,13 @@ HRESULT WINAPI QAxServerBase::EnumConnectionPoints(IEnumConnectionPoints **epoin HRESULT WINAPI QAxServerBase::FindConnectionPoint(REFIID iid, IConnectionPoint **cpoint) { if (!cpoint) - return E_POINTER; + return E_POINTER; IConnectionPoint *cp = points[iid]; *cpoint = cp; if (cp) { - cp->AddRef(); - return S_OK; + cp->AddRef(); + return S_OK; } return CONNECT_E_NOCONNECTION; } @@ -2688,12 +2688,12 @@ HRESULT WINAPI QAxServerBase::Load(IStream *pStm) QString streamName = QString::fromWCharArray(stat.pwcsName); CoTaskMemFree(stat.pwcsName); openAsText = streamName == QLatin1String("SomeStreamName"); - if (stat.cbSize.HighPart) // more than 4GB - too large! - return S_FALSE; + if (stat.cbSize.HighPart) // more than 4GB - too large! + return S_FALSE; - qtarray.resize(stat.cbSize.LowPart); + qtarray.resize(stat.cbSize.LowPart); ULONG read; - pStm->Read(qtarray.data(), stat.cbSize.LowPart, &read); + pStm->Read(qtarray.data(), stat.cbSize.LowPart, &read); } else if (hres == E_NOTIMPL) { ULONG read = 0; while (hres != S_FALSE) { @@ -2730,18 +2730,18 @@ HRESULT WINAPI QAxServerBase::Load(IStream *pStm) qtstream >> more; while (!qtbuffer.atEnd() && more) { - QString propname; - QVariant value; - qtstream >> propname; - if (propname.isEmpty()) - break; - qtstream >> value; - qtstream >> more; - - int idx = mo->indexOfProperty(propname.toLatin1()); - QMetaProperty property = mo->property(idx); - if (property.isWritable()) - qt.object->setProperty(propname.toLatin1(), value); + QString propname; + QVariant value; + qtstream >> propname; + if (propname.isEmpty()) + break; + qtstream >> value; + qtstream >> more; + + int idx = mo->indexOfProperty(propname.toLatin1()); + QMetaProperty property = mo->property(idx); + if (property.isWritable()) + qt.object->setProperty(propname.toLatin1(), value); } return S_OK; } @@ -2765,18 +2765,18 @@ HRESULT WINAPI QAxServerBase::Save(IStream *pStm, BOOL clearDirty) qtstream << qtstream.version(); for (int prop = 0; prop < mo->propertyCount(); ++prop) { - if (!isPropertyExposed(prop)) - continue; - QMetaProperty metaprop = mo->property(prop); + if (!isPropertyExposed(prop)) + continue; + QMetaProperty metaprop = mo->property(prop); if (QByteArray(metaprop.typeName()).endsWith('*')) continue; - QString property = QLatin1String(metaprop.name()); - QVariant qvar = qt.object->property(metaprop.name()); - if (qvar.isValid()) { - qtstream << int(1); - qtstream << property; - qtstream << qvar; - } + QString property = QLatin1String(metaprop.name()); + QVariant qvar = qt.object->property(metaprop.name()); + if (qvar.isValid()) { + qtstream << int(1); + qtstream << property; + qtstream << qvar; + } } qtstream << int(0); @@ -2814,21 +2814,21 @@ HRESULT WINAPI QAxServerBase::GetSizeMax(ULARGE_INTEGER *pcbSize) HRESULT WINAPI QAxServerBase::InitNew(IStorage *pStg) { if (initNewCalled) - return CO_E_ALREADYINITIALIZED; + return CO_E_ALREADYINITIALIZED; dirtyflag = false; initNewCalled = true; m_spStorage = pStg; if (m_spStorage) - m_spStorage->AddRef(); + m_spStorage->AddRef(); return S_OK; } HRESULT WINAPI QAxServerBase::Load(IStorage *pStg) { if (InitNew(pStg) != S_OK) - return CO_E_ALREADYINITIALIZED; + return CO_E_ALREADYINITIALIZED; IStream *spStream = 0; QString streamName = QLatin1String(qt.object->metaObject()->className()); @@ -2843,7 +2843,7 @@ HRESULT WINAPI QAxServerBase::Load(IStorage *pStg) if (!spStream) // support for streams saved with 4.1 and earlier pStg->OpenStream(L"SomeStreamName", 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream); if (!spStream) - return E_FAIL; + return E_FAIL; Load(spStream); spStream->Release(); @@ -2864,7 +2864,7 @@ HRESULT WINAPI QAxServerBase::Save(IStorage *pStg, BOOL /* fSameAsLoad */) pStg->CreateStream((const wchar_t *)streamName.utf16(), STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &spStream); if (!spStream) - return E_FAIL; + return E_FAIL; Save(spStream, true); @@ -2875,10 +2875,10 @@ HRESULT WINAPI QAxServerBase::Save(IStorage *pStg, BOOL /* fSameAsLoad */) HRESULT WINAPI QAxServerBase::SaveCompleted(IStorage *pStgNew) { if (pStgNew) { - if (m_spStorage) - m_spStorage->Release(); - m_spStorage = pStgNew; - m_spStorage->AddRef(); + if (m_spStorage) + m_spStorage->Release(); + m_spStorage = pStgNew; + m_spStorage->AddRef(); } return S_OK; } @@ -2898,7 +2898,7 @@ HRESULT WINAPI QAxServerBase::HandsOffStorage() HRESULT WINAPI QAxServerBase::InitNew() { if (initNewCalled) - return CO_E_ALREADYINITIALIZED; + return CO_E_ALREADYINITIALIZED; dirtyflag = false; initNewCalled = true; @@ -2911,27 +2911,27 @@ HRESULT WINAPI QAxServerBase::InitNew() HRESULT WINAPI QAxServerBase::Load(IPropertyBag *bag, IErrorLog * /*log*/) { if (!bag) - return E_POINTER; + return E_POINTER; if (InitNew() != S_OK) - return E_UNEXPECTED; + return E_UNEXPECTED; bool error = false; const QMetaObject *mo = qt.object->metaObject(); for (int prop = 0; prop < mo->propertyCount(); ++prop) { - if (!isPropertyExposed(prop)) - continue; - QMetaProperty property = mo->property(prop); - const char* pname = property.name(); - BSTR bstr = QStringToBSTR(QLatin1String(pname)); - VARIANT var; - var.vt = VT_EMPTY; - HRESULT res = bag->Read(bstr, &var, 0); - if (property.isWritable() && var.vt != VT_EMPTY) { - if (res != S_OK || !qt.object->setProperty(pname, VARIANTToQVariant(var, property.typeName(), property.type()))) - error = true; - } - SysFreeString(bstr); + if (!isPropertyExposed(prop)) + continue; + QMetaProperty property = mo->property(prop); + const char* pname = property.name(); + BSTR bstr = QStringToBSTR(QLatin1String(pname)); + VARIANT var; + var.vt = VT_EMPTY; + HRESULT res = bag->Read(bstr, &var, 0); + if (property.isWritable() && var.vt != VT_EMPTY) { + if (res != S_OK || !qt.object->setProperty(pname, VARIANTToQVariant(var, property.typeName(), property.type()))) + error = true; + } + SysFreeString(bstr); } updateGeometry(); @@ -2946,27 +2946,27 @@ HRESULT WINAPI QAxServerBase::Load(IPropertyBag *bag, IErrorLog * /*log*/) HRESULT WINAPI QAxServerBase::Save(IPropertyBag *bag, BOOL clearDirty, BOOL /*saveAll*/) { if (!bag) - return E_POINTER; + return E_POINTER; if (clearDirty) - dirtyflag = false; + dirtyflag = false; bool error = false; const QMetaObject *mo = qt.object->metaObject(); for (int prop = 0; prop < mo->propertyCount(); ++prop) { - if (!isPropertyExposed(prop)) - continue; - QMetaProperty property = mo->property(prop); + if (!isPropertyExposed(prop)) + continue; + QMetaProperty property = mo->property(prop); if (QByteArray(property.typeName()).endsWith('*')) continue; - BSTR bstr = QStringToBSTR(QLatin1String(property.name())); - QVariant qvar = qt.object->property(property.name()); - if (!qvar.isValid()) - error = true; - VARIANT var; - QVariantToVARIANT(qvar, var); - bag->Write(bstr, &var); - SysFreeString(bstr); + BSTR bstr = QStringToBSTR(QLatin1String(property.name())); + QVariant qvar = qt.object->property(property.name()); + if (!qvar.isValid()) + error = true; + VARIANT var; + QVariantToVARIANT(qvar, var); + bag->Write(bstr, &var); + SysFreeString(bstr); } Q_UNUSED(error) return /*error ? E_FAIL :*/ S_OK; @@ -3098,31 +3098,31 @@ HRESULT WINAPI QAxServerBase::Save(LPCOLESTR fileName, BOOL fRemember) Draws the widget into the provided device context. */ HRESULT WINAPI QAxServerBase::Draw(DWORD dwAspect, LONG /* lindex */, void * /* pvAspect */, DVTARGETDEVICE *ptd, - HDC hicTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL /*lprcWBounds*/, - BOOL(__stdcall* /*pfnContinue*/)(ULONG_PTR), ULONG_PTR /*dwContinue*/) + HDC hicTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL /*lprcWBounds*/, + BOOL(__stdcall* /*pfnContinue*/)(ULONG_PTR), ULONG_PTR /*dwContinue*/) { if (!lprcBounds) - return E_INVALIDARG; + return E_INVALIDARG; internalCreate(); if (!isWidget || !qt.widget) - return OLE_E_BLANK; + return OLE_E_BLANK; switch (dwAspect) { case DVASPECT_CONTENT: case DVASPECT_OPAQUE: case DVASPECT_TRANSPARENT: - break; + break; default: - return DV_E_DVASPECT; + return DV_E_DVASPECT; } if (!ptd) - hicTargetDev = 0; + hicTargetDev = 0; bool bDeleteDC = false; if (!hicTargetDev) { - hicTargetDev = ::CreateDC(L"DISPLAY", NULL, NULL, NULL); - bDeleteDC = (hicTargetDev != hdcDraw); + hicTargetDev = ::CreateDC(L"DISPLAY", NULL, NULL, NULL); + bDeleteDC = (hicTargetDev != hdcDraw); } RECTL rc = *lprcBounds; @@ -3139,7 +3139,7 @@ HRESULT WINAPI QAxServerBase::Draw(DWORD dwAspect, LONG /* lindex */, void * /* DeleteObject(hbm); if (bDeleteDC) - DeleteDC(hicTargetDev); + DeleteDC(hicTargetDev); return S_OK; } @@ -3187,11 +3187,11 @@ HRESULT WINAPI QAxServerBase::SetAdvise(DWORD /*aspects*/, DWORD /*advf*/, IAdvi HRESULT WINAPI QAxServerBase::GetAdvise(DWORD* /*aspects*/, DWORD* /*advf*/, IAdviseSink **ppAdvSink) { if (!ppAdvSink) - return E_POINTER; + return E_POINTER; *ppAdvSink = m_spAdviseSink; if (*ppAdvSink) - (*ppAdvSink)->AddRef(); + (*ppAdvSink)->AddRef(); return S_OK; } @@ -3223,9 +3223,9 @@ HRESULT WINAPI QAxServerBase::FreezeEvents(BOOL bFreeze) { // member of CComControl if (bFreeze) - freezeEvents++; + freezeEvents++; else - freezeEvents--; + freezeEvents--; return S_OK; } @@ -3244,12 +3244,12 @@ HRESULT WINAPI QAxServerBase::OnMnemonic(LPMSG) HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID) { if (!m_spClientSite || !theObject) - return S_OK; + return S_OK; IDispatch *disp = 0; m_spClientSite->QueryInterface(IID_IDispatch, (void**)&disp); if (!disp) - return S_OK; + return S_OK; VARIANT var; VariantInit(&var); @@ -3260,78 +3260,78 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID) switch(dispID) { case DISPID_AMBIENT_APPEARANCE: - break; + break; case DISPID_AMBIENT_AUTOCLIP: - break; + break; case DISPID_AMBIENT_BACKCOLOR: case DISPID_AMBIENT_FORECOLOR: - if (isWidget) { - long rgb; - if (var.vt == VT_UI4) - rgb = var.ulVal; - else if (var.vt == VT_I4) - rgb = var.lVal; - else - break; - QPalette pal = qt.widget->palette(); - pal.setColor(dispID == DISPID_AMBIENT_BACKCOLOR ? QPalette::Window : QPalette::WindowText, - OLEColorToQColor(rgb)); - qt.widget->setPalette(pal); - } - break; + if (isWidget) { + long rgb; + if (var.vt == VT_UI4) + rgb = var.ulVal; + else if (var.vt == VT_I4) + rgb = var.lVal; + else + break; + QPalette pal = qt.widget->palette(); + pal.setColor(dispID == DISPID_AMBIENT_BACKCOLOR ? QPalette::Window : QPalette::WindowText, + OLEColorToQColor(rgb)); + qt.widget->setPalette(pal); + } + break; case DISPID_AMBIENT_DISPLAYASDEFAULT: - break; + break; case DISPID_AMBIENT_DISPLAYNAME: - if (var.vt != VT_BSTR || !isWidget) - break; - qt.widget->setWindowTitle(QString::fromWCharArray(var.bstrVal)); - break; + if (var.vt != VT_BSTR || !isWidget) + break; + qt.widget->setWindowTitle(QString::fromWCharArray(var.bstrVal)); + break; case DISPID_AMBIENT_FONT: - if (var.vt != VT_DISPATCH || !isWidget) - break; - { + if (var.vt != VT_DISPATCH || !isWidget) + break; + { QVariant qvar = VARIANTToQVariant(var, "QFont", QVariant::Font); QFont qfont = qvariant_cast<QFont>(qvar); qt.widget->setFont(qfont); - } - break; + } + break; case DISPID_AMBIENT_LOCALEID: - break; + break; case DISPID_AMBIENT_MESSAGEREFLECT: - if (var.vt != VT_BOOL) - break; - if (var.boolVal) - qt.widget->installEventFilter(this); - else - qt.widget->removeEventFilter(this); - break; + if (var.vt != VT_BOOL) + break; + if (var.boolVal) + qt.widget->installEventFilter(this); + else + qt.widget->removeEventFilter(this); + break; case DISPID_AMBIENT_PALETTE: - break; + break; case DISPID_AMBIENT_SCALEUNITS: - break; + break; case DISPID_AMBIENT_SHOWGRABHANDLES: - break; + break; case DISPID_AMBIENT_SHOWHATCHING: - break; + break; case DISPID_AMBIENT_SUPPORTSMNEMONICS: - break; + break; case DISPID_AMBIENT_TEXTALIGN: - break; + break; case DISPID_AMBIENT_UIDEAD: - if (var.vt != VT_BOOL || !isWidget) - break; - qt.widget->setEnabled(!var.boolVal); - break; + if (var.vt != VT_BOOL || !isWidget) + break; + qt.widget->setEnabled(!var.boolVal); + break; case DISPID_AMBIENT_USERMODE: - if (var.vt != VT_BOOL) - break; - inDesignMode = !var.boolVal; - break; + if (var.vt != VT_BOOL) + break; + inDesignMode = !var.boolVal; + break; case DISPID_AMBIENT_RIGHTTOLEFT: - if (var.vt != VT_BOOL) - break; - qApp->setLayoutDirection(var.boolVal?Qt::RightToLeft:Qt::LeftToRight); - break; + if (var.vt != VT_BOOL) + break; + qApp->setLayoutDirection(var.boolVal?Qt::RightToLeft:Qt::LeftToRight); + break; } return S_OK; @@ -3344,7 +3344,7 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID) HRESULT WINAPI QAxServerBase::GetWindow(HWND *pHwnd) { if (!pHwnd) - return E_POINTER; + return E_POINTER; *pHwnd = m_hWnd; return S_OK; } @@ -3355,9 +3355,9 @@ HRESULT WINAPI QAxServerBase::GetWindow(HWND *pHwnd) HRESULT WINAPI QAxServerBase::ContextSensitiveHelp(BOOL fEnterMode) { if (fEnterMode) - QWhatsThis::enterWhatsThisMode(); + QWhatsThis::enterWhatsThisMode(); else - QWhatsThis::leaveWhatsThisMode(); + QWhatsThis::leaveWhatsThisMode(); return S_OK; } @@ -3368,20 +3368,20 @@ HRESULT WINAPI QAxServerBase::ContextSensitiveHelp(BOOL fEnterMode) HRESULT WINAPI QAxServerBase::InPlaceDeactivate() { if (!isInPlaceActive) - return S_OK; + return S_OK; UIDeactivate(); isInPlaceActive = false; // if we have a window, tell it to go away. if (m_hWnd) { - if (::IsWindow(m_hWnd)) - ::DestroyWindow(m_hWnd); - m_hWnd = 0; + if (::IsWindow(m_hWnd)) + ::DestroyWindow(m_hWnd); + m_hWnd = 0; } if (m_spInPlaceSite) - m_spInPlaceSite->OnInPlaceDeactivate(); + m_spInPlaceSite->OnInPlaceDeactivate(); return S_OK; } @@ -3393,41 +3393,41 @@ HRESULT WINAPI QAxServerBase::UIDeactivate() { // if we're not UIActive, not much to do. if (!isUIActive || !m_spInPlaceSite) - return S_OK; + return S_OK; isUIActive = false; // notify frame windows, if appropriate, that we're no longer ui-active. HWND hwndParent; if (m_spInPlaceSite->GetWindow(&hwndParent) == S_OK) { - if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; - IOleInPlaceUIWindow *spInPlaceUIWindow = 0; + if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); + m_spInPlaceFrame = 0; + IOleInPlaceUIWindow *spInPlaceUIWindow = 0; RECT rcPos, rcClip; OLEINPLACEFRAMEINFO frameInfo; frameInfo.cb = sizeof(OLEINPLACEFRAMEINFO); - m_spInPlaceSite->GetWindowContext(&m_spInPlaceFrame, &spInPlaceUIWindow, &rcPos, &rcClip, &frameInfo); - if (spInPlaceUIWindow) { - spInPlaceUIWindow->SetActiveObject(0, 0); - spInPlaceUIWindow->Release(); - } - if (m_spInPlaceFrame) { - removeMenu(); + m_spInPlaceSite->GetWindowContext(&m_spInPlaceFrame, &spInPlaceUIWindow, &rcPos, &rcClip, &frameInfo); + if (spInPlaceUIWindow) { + spInPlaceUIWindow->SetActiveObject(0, 0); + spInPlaceUIWindow->Release(); + } + if (m_spInPlaceFrame) { + removeMenu(); if (menuBar) { menuBar->removeEventFilter(this); menuBar = 0; } if (statusBar) { statusBar->removeEventFilter(this); - const int index = statusBar->metaObject()->indexOfSignal("messageChanged(QString)"); + const int index = statusBar->metaObject()->indexOfSignal("messageChanged(QString)"); QMetaObject::disconnect(statusBar, index, this, STATUSBAR_MESSAGE_CHANGED_SLOT_INDEX); - statusBar = 0; + statusBar = 0; } - m_spInPlaceFrame->SetActiveObject(0, 0); - m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; - } + m_spInPlaceFrame->SetActiveObject(0, 0); + m_spInPlaceFrame->Release(); + m_spInPlaceFrame = 0; + } } // we don't need to explicitly release the focus here since somebody // else grabbing the focus is usually why we are getting called at all @@ -3442,22 +3442,22 @@ HRESULT WINAPI QAxServerBase::UIDeactivate() HRESULT WINAPI QAxServerBase::SetObjectRects(LPCRECT prcPos, LPCRECT prcClip) { if (prcPos == 0 || prcClip == 0) - return E_POINTER; + return E_POINTER; if (m_hWnd) { - // the container wants us to clip, so figure out if we really need to - RECT rcIXect; - BOOL b = IntersectRect(&rcIXect, prcPos, prcClip); - HRGN tempRgn = 0; - if (b && !EqualRect(&rcIXect, prcPos)) { - OffsetRect(&rcIXect, -(prcPos->left), -(prcPos->top)); - tempRgn = CreateRectRgnIndirect(&rcIXect); - } - - ::SetWindowRgn(m_hWnd, tempRgn, true); - ::SetWindowPos(m_hWnd, 0, prcPos->left, prcPos->top, + // the container wants us to clip, so figure out if we really need to + RECT rcIXect; + BOOL b = IntersectRect(&rcIXect, prcPos, prcClip); + HRGN tempRgn = 0; + if (b && !EqualRect(&rcIXect, prcPos)) { + OffsetRect(&rcIXect, -(prcPos->left), -(prcPos->top)); + tempRgn = CreateRectRgnIndirect(&rcIXect); + } + + ::SetWindowRgn(m_hWnd, tempRgn, true); + ::SetWindowPos(m_hWnd, 0, prcPos->left, prcPos->top, prcPos->right - prcPos->left, prcPos->bottom - prcPos->top, - SWP_NOZORDER | SWP_NOACTIVATE); + SWP_NOZORDER | SWP_NOACTIVATE); } //Save the new extent. @@ -3486,11 +3486,11 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) DWORD dwKeyMod = 0; if (::GetKeyState(VK_SHIFT) < 0) - dwKeyMod |= 1; // KEYMOD_SHIFT + dwKeyMod |= 1; // KEYMOD_SHIFT if (::GetKeyState(VK_CONTROL) < 0) - dwKeyMod |= 2; // KEYMOD_CONTROL + dwKeyMod |= 2; // KEYMOD_CONTROL if (::GetKeyState(VK_MENU) < 0) - dwKeyMod |= 4; // KEYMOD_ALT + dwKeyMod |= 4; // KEYMOD_ALT switch (LOWORD(pMsg->wParam)) { case VK_TAB: @@ -3614,10 +3614,10 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorA(MSG *pMsg) HRESULT WINAPI QAxServerBase::OnFrameWindowActivate(BOOL fActivate) { if (fActivate) { - if (wasUIActive) - ::SetFocus(m_hWnd); + if (wasUIActive) + ::SetFocus(m_hWnd); } else { - wasUIActive = isUIActive; + wasUIActive = isUIActive; } return S_OK; } @@ -3635,7 +3635,7 @@ HRESULT WINAPI QAxServerBase::ResizeBorder(LPCRECT /* prcBorder */, IOleInPlaceU HRESULT WINAPI QAxServerBase::EnableModeless(BOOL fEnable) { if (!isWidget) - return S_OK; + return S_OK; // FIXME: 4.10.2011 Does this work with the parent's HWND? EnableWindow(hwndForWidget(qt.widget), fEnable); @@ -3660,21 +3660,21 @@ static inline LPOLESTR QStringToOLESTR(const QString &qstring) HRESULT WINAPI QAxServerBase::GetUserType(DWORD dwFormOfType, LPOLESTR *pszUserType) { if (!pszUserType) - return E_POINTER; + return E_POINTER; switch (dwFormOfType) { case USERCLASSTYPE_FULL: - *pszUserType = QStringToOLESTR(class_name); - break; + *pszUserType = QStringToOLESTR(class_name); + break; case USERCLASSTYPE_SHORT: - if (!qt.widget || !isWidget || qt.widget->windowTitle().isEmpty()) - *pszUserType = QStringToOLESTR(class_name); - else - *pszUserType = QStringToOLESTR(qt.widget->windowTitle()); - break; + if (!qt.widget || !isWidget || qt.widget->windowTitle().isEmpty()) + *pszUserType = QStringToOLESTR(class_name); + else + *pszUserType = QStringToOLESTR(qt.widget->windowTitle()); + break; case USERCLASSTYPE_APPNAME: - *pszUserType = QStringToOLESTR(qApp->objectName()); - break; + *pszUserType = QStringToOLESTR(qApp->objectName()); + break; } return S_OK; @@ -3706,25 +3706,25 @@ HRESULT WINAPI QAxServerBase::Advise(IAdviseSink* pAdvSink, DWORD* pdwConnection HRESULT WINAPI QAxServerBase::Close(DWORD dwSaveOption) { if (dwSaveOption != OLECLOSE_NOSAVE && m_spClientSite) - m_spClientSite->SaveObject(); + m_spClientSite->SaveObject(); if (isInPlaceActive) { - HRESULT hr = InPlaceDeactivate(); - if (FAILED(hr)) - return hr; + HRESULT hr = InPlaceDeactivate(); + if (FAILED(hr)) + return hr; } if (m_hWnd) { - if (IsWindow(m_hWnd)) - DestroyWindow(m_hWnd); - m_hWnd = 0; - if (m_spClientSite) - m_spClientSite->OnShowWindow(false); + if (IsWindow(m_hWnd)) + DestroyWindow(m_hWnd); + m_hWnd = 0; + if (m_spClientSite) + m_spClientSite->OnShowWindow(false); } if (m_spInPlaceSite) m_spInPlaceSite->Release(); m_spInPlaceSite = 0; if (m_spAdviseSink) - m_spAdviseSink->OnClose(); + m_spAdviseSink->OnClose(); for (int i = 0; i < adviseSinks.count(); ++i) { adviseSinks.at(i).pAdvSink->OnClose(); } @@ -3740,20 +3740,20 @@ bool qax_disable_inplaceframe = true; HRESULT QAxServerBase::internalActivate() { if (!m_spClientSite) - return S_OK; + return S_OK; if (!m_spInPlaceSite) m_spClientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&m_spInPlaceSite); if (!m_spInPlaceSite) - return E_FAIL; + return E_FAIL; HRESULT hr = E_FAIL; if (!isInPlaceActive) { - hr = m_spInPlaceSite->CanInPlaceActivate(); - if (FAILED(hr)) - return hr; - if (hr != S_OK) - return E_FAIL; - m_spInPlaceSite->OnInPlaceActivate(); + hr = m_spInPlaceSite->CanInPlaceActivate(); + if (FAILED(hr)) + return hr; + if (hr != S_OK) + return E_FAIL; + m_spInPlaceSite->OnInPlaceActivate(); } isInPlaceActive = true; @@ -3779,57 +3779,57 @@ HRESULT QAxServerBase::internalActivate() } } - // Gone active by now, take care of UIACTIVATE - canTakeFocus = qt.widget->focusPolicy() != Qt::NoFocus && !inDesignMode; - if (!canTakeFocus && !inDesignMode) { - QList<QWidget*> widgets = qt.widget->findChildren<QWidget*>(); - for (int w = 0; w < widgets.count(); ++w) { - QWidget *widget = widgets[w]; - canTakeFocus = widget->focusPolicy() != Qt::NoFocus; + // Gone active by now, take care of UIACTIVATE + canTakeFocus = qt.widget->focusPolicy() != Qt::NoFocus && !inDesignMode; + if (!canTakeFocus && !inDesignMode) { + QList<QWidget*> widgets = qt.widget->findChildren<QWidget*>(); + for (int w = 0; w < widgets.count(); ++w) { + QWidget *widget = widgets[w]; + canTakeFocus = widget->focusPolicy() != Qt::NoFocus; if (canTakeFocus) break; - } - } - if (!isUIActive && canTakeFocus) { - isUIActive = true; - hr = m_spInPlaceSite->OnUIActivate(); - if (FAILED(hr)) { - if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; - if (spInPlaceUIWindow) spInPlaceUIWindow->Release(); - return hr; - } - - if (isInPlaceActive) { - if (!::IsChild(m_hWnd, ::GetFocus())) - ::SetFocus(m_hWnd); - } - - if (m_spInPlaceFrame) { + } + } + if (!isUIActive && canTakeFocus) { + isUIActive = true; + hr = m_spInPlaceSite->OnUIActivate(); + if (FAILED(hr)) { + if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); + m_spInPlaceFrame = 0; + if (spInPlaceUIWindow) spInPlaceUIWindow->Release(); + return hr; + } + + if (isInPlaceActive) { + if (!::IsChild(m_hWnd, ::GetFocus())) + ::SetFocus(m_hWnd); + } + + if (m_spInPlaceFrame) { hr = m_spInPlaceFrame->SetActiveObject(this, (wchar_t*)class_name.utf16()); - if (!FAILED(hr)) { - menuBar = (qt.widget && !qax_disable_inplaceframe) ? qt.widget->findChild<QMenuBar*>() : 0; - if (menuBar && !menuBar->isVisible()) { - createMenu(menuBar); - menuBar->hide(); - menuBar->installEventFilter(this); - } - statusBar = qt.widget ? qt.widget->findChild<QStatusBar*>() : 0; - if (statusBar && !statusBar->isVisible()) { - const int index = statusBar->metaObject()->indexOfSignal("messageChanged(QString)"); - QMetaObject::connect(statusBar, index, this, STATUSBAR_MESSAGE_CHANGED_SLOT_INDEX); - statusBar->hide(); - statusBar->installEventFilter(this); - } - } - } - if (spInPlaceUIWindow) { + if (!FAILED(hr)) { + menuBar = (qt.widget && !qax_disable_inplaceframe) ? qt.widget->findChild<QMenuBar*>() : 0; + if (menuBar && !menuBar->isVisible()) { + createMenu(menuBar); + menuBar->hide(); + menuBar->installEventFilter(this); + } + statusBar = qt.widget ? qt.widget->findChild<QStatusBar*>() : 0; + if (statusBar && !statusBar->isVisible()) { + const int index = statusBar->metaObject()->indexOfSignal("messageChanged(QString)"); + QMetaObject::connect(statusBar, index, this, STATUSBAR_MESSAGE_CHANGED_SLOT_INDEX); + statusBar->hide(); + statusBar->installEventFilter(this); + } + } + } + if (spInPlaceUIWindow) { spInPlaceUIWindow->SetActiveObject(this, (wchar_t*)class_name.utf16()); - spInPlaceUIWindow->SetBorderSpace(0); - } - } + spInPlaceUIWindow->SetBorderSpace(0); + } + } if (spInPlaceUIWindow) spInPlaceUIWindow->Release(); - ShowWindow(m_hWnd, SW_NORMAL); + ShowWindow(m_hWnd, SW_NORMAL); } m_spClientSite->ShowObject(); @@ -3841,43 +3841,43 @@ HRESULT QAxServerBase::internalActivate() Executes the "verb" \a iVerb. */ HRESULT WINAPI QAxServerBase::DoVerb(LONG iVerb, LPMSG /*lpmsg*/, IOleClientSite* /*pActiveSite*/, LONG /*lindex*/, - HWND /*hwndParent*/, LPCRECT /*prcPosRect*/) + HWND /*hwndParent*/, LPCRECT /*prcPosRect*/) { HRESULT hr = E_NOTIMPL; switch (iVerb) { case OLEIVERB_SHOW: - hr = internalActivate(); - if (SUCCEEDED(hr)) - hr = S_OK; - break; + hr = internalActivate(); + if (SUCCEEDED(hr)) + hr = S_OK; + break; case OLEIVERB_PRIMARY: case OLEIVERB_INPLACEACTIVATE: - hr = internalActivate(); - if (SUCCEEDED(hr)) { - hr = S_OK; - update(); - } - break; + hr = internalActivate(); + if (SUCCEEDED(hr)) { + hr = S_OK; + update(); + } + break; case OLEIVERB_UIACTIVATE: - if (!isUIActive) { - hr = internalActivate(); - if (SUCCEEDED(hr)) - hr = S_OK; - } - break; + if (!isUIActive) { + hr = internalActivate(); + if (SUCCEEDED(hr)) + hr = S_OK; + } + break; case OLEIVERB_HIDE: - UIDeactivate(); - if (m_hWnd) - ::ShowWindow(m_hWnd, SW_HIDE); - hr = S_OK; - return hr; + UIDeactivate(); + if (m_hWnd) + ::ShowWindow(m_hWnd, SW_HIDE); + hr = S_OK; + return hr; default: - break; + break; } return hr; } @@ -3896,7 +3896,7 @@ HRESULT WINAPI QAxServerBase::EnumAdvise(IEnumSTATDATA** /*ppenumAdvise*/) HRESULT WINAPI QAxServerBase::EnumVerbs(IEnumOLEVERB** ppEnumOleVerb) { if (!ppEnumOleVerb) - return E_POINTER; + return E_POINTER; return OleRegEnumVerbs(qAxFactory()->classID(class_name), ppEnumOleVerb); } @@ -3906,10 +3906,10 @@ HRESULT WINAPI QAxServerBase::EnumVerbs(IEnumOLEVERB** ppEnumOleVerb) HRESULT WINAPI QAxServerBase::GetClientSite(IOleClientSite** ppClientSite) { if (!ppClientSite) - return E_POINTER; + return E_POINTER; *ppClientSite = m_spClientSite; if (*ppClientSite) - (*ppClientSite)->AddRef(); + (*ppClientSite)->AddRef(); return S_OK; } @@ -3927,9 +3927,9 @@ HRESULT WINAPI QAxServerBase::GetClipboardData(DWORD, IDataObject**) HRESULT WINAPI QAxServerBase::GetExtent(DWORD dwDrawAspect, SIZEL* psizel) { if (dwDrawAspect != DVASPECT_CONTENT || !isWidget || !qt.widget) - return E_FAIL; + return E_FAIL; if (!psizel) - return E_POINTER; + return E_POINTER; psizel->cx = MAP_PIX_TO_LOGHIM(m_currentExtent.width(), qt.widget->logicalDpiX()); psizel->cy = MAP_PIX_TO_LOGHIM(m_currentExtent.height(), qt.widget->logicalDpiY()); @@ -3950,7 +3950,7 @@ HRESULT WINAPI QAxServerBase::GetMoniker(DWORD, DWORD, IMoniker** ) HRESULT WINAPI QAxServerBase::GetUserClassID(CLSID* pClsid) { if (!pClsid) - return E_POINTER; + return E_POINTER; *pClsid = qAxFactory()->classID(class_name); return S_OK; } @@ -3986,7 +3986,7 @@ HRESULT WINAPI QAxServerBase::SetClientSite(IOleClientSite* pClientSite) m_spClientSite = pClientSite; if (m_spClientSite) { m_spClientSite->AddRef(); - m_spClientSite->QueryInterface(IID_IOleInPlaceSite, (void **)&m_spInPlaceSite); + m_spClientSite->QueryInterface(IID_IOleInPlaceSite, (void **)&m_spInPlaceSite); } return S_OK; @@ -4014,12 +4014,12 @@ bool qt_sendSpontaneousEvent(QObject *o, QEvent *e) HRESULT WINAPI QAxServerBase::SetExtent(DWORD dwDrawAspect, SIZEL* psizel) { if (dwDrawAspect != DVASPECT_CONTENT) - return DV_E_DVASPECT; + return DV_E_DVASPECT; if (!psizel) - return E_POINTER; + return E_POINTER; if (!isWidget || !qt.widget) // nothing to do - return S_OK; + return S_OK; QSize proposedSize(MAP_LOGHIM_TO_PIX(psizel->cx, qt.widget->logicalDpiX()), MAP_LOGHIM_TO_PIX(psizel->cy, qt.widget->logicalDpiY())); @@ -4082,22 +4082,22 @@ HRESULT WINAPI QAxServerBase::Update() HRESULT WINAPI QAxServerBase::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium) { if (!pmedium) - return E_POINTER; + return E_POINTER; if ((pformatetcIn->tymed & TYMED_MFPICT) == 0) - return DATA_E_FORMATETC; + return DATA_E_FORMATETC; internalCreate(); if (!isWidget || !qt.widget) - return E_UNEXPECTED; + return E_UNEXPECTED; // Container wants to draw, but the size is not defined yet - ask container if (m_spInPlaceSite && !qt.widget->testAttribute(Qt::WA_Resized)) { - IOleInPlaceUIWindow *spInPlaceUIWindow = 0; + IOleInPlaceUIWindow *spInPlaceUIWindow = 0; RECT rcPos, rcClip; OLEINPLACEFRAMEINFO frameInfo; frameInfo.cb = sizeof(OLEINPLACEFRAMEINFO); - HRESULT hres = m_spInPlaceSite->GetWindowContext(&m_spInPlaceFrame, &spInPlaceUIWindow, &rcPos, &rcClip, &frameInfo); + HRESULT hres = m_spInPlaceSite->GetWindowContext(&m_spInPlaceFrame, &spInPlaceUIWindow, &rcPos, &rcClip, &frameInfo); if (hres == S_OK) { QSize size(rcPos.right - rcPos.left, rcPos.bottom - rcPos.top); resize(size); @@ -4121,12 +4121,12 @@ HRESULT WINAPI QAxServerBase::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmediu RestoreDC(hdc, -1); HMETAFILE hMF = CloseMetaFile(hdc); if (!hMF) - return E_UNEXPECTED; + return E_UNEXPECTED; HGLOBAL hMem = GlobalAlloc(GMEM_SHARE | GMEM_MOVEABLE, sizeof(METAFILEPICT)); if (!hMem) { - DeleteMetaFile(hMF); - return ResultFromScode(STG_E_MEDIUMFULL); + DeleteMetaFile(hMF); + return ResultFromScode(STG_E_MEDIUMFULL); } LPMETAFILEPICT pMF = (LPMETAFILEPICT)GlobalLock(hMem); @@ -4148,7 +4148,7 @@ HRESULT WINAPI QAxServerBase::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmediu Not implemented. */ HRESULT WINAPI QAxServerBase::DAdvise(FORMATETC *pformatetc, DWORD advf, - IAdviseSink *pAdvSink, DWORD *pdwConnection) + IAdviseSink *pAdvSink, DWORD *pdwConnection) { if (pformatetc->dwAspect != DVASPECT_CONTENT) return E_FAIL; @@ -4225,11 +4225,11 @@ static int mapModifiers(int state) { int ole = 0; if (state & Qt::ShiftModifier) - ole |= 1; + ole |= 1; if (state & Qt::ControlModifier) - ole |= 2; + ole |= 2; if (state & Qt::AltModifier) - ole |= 4; + ole |= 4; return ole; } @@ -4240,128 +4240,128 @@ static int mapModifiers(int state) bool QAxServerBase::eventFilter(QObject *o, QEvent *e) { if (!theObject) - return QObject::eventFilter(o, e); + return QObject::eventFilter(o, e); if ((e->type() == QEvent::Show || e->type() == QEvent::Hide) && (o == statusBar || o == menuBar)) { - if (o == menuBar) { - if (e->type() == QEvent::Hide) { - createMenu(menuBar); - } else if (e->type() == QEvent::Show) { - removeMenu(); - } - } else if (statusBar) { - statusBar->setSizeGripEnabled(false); - } - updateGeometry(); - if (m_spInPlaceSite && qt.widget->sizeHint().isValid()) { + if (o == menuBar) { + if (e->type() == QEvent::Hide) { + createMenu(menuBar); + } else if (e->type() == QEvent::Show) { + removeMenu(); + } + } else if (statusBar) { + statusBar->setSizeGripEnabled(false); + } + updateGeometry(); + if (m_spInPlaceSite && qt.widget->sizeHint().isValid()) { RECT rect = {0, 0, qt.widget->sizeHint().width(), qt.widget->sizeHint().height()}; - m_spInPlaceSite->OnPosRectChange(&rect); - } + m_spInPlaceSite->OnPosRectChange(&rect); + } } switch (e->type()) { case QEvent::ChildAdded: - static_cast<QChildEvent*>(e)->child()->installEventFilter(this); - break; + static_cast<QChildEvent*>(e)->child()->installEventFilter(this); + break; case QEvent::ChildRemoved: - static_cast<QChildEvent*>(e)->child()->removeEventFilter(this); - break; + static_cast<QChildEvent*>(e)->child()->removeEventFilter(this); + break; case QEvent::KeyPress: - if (o == qt.object && hasStockEvents) { - QKeyEvent *ke = (QKeyEvent*)e; - int key = ke->key(); - int state = ke->modifiers(); - void *argv[] = { - 0, - &key, - &state - }; - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_KEYDOWN, argv); - if (!ke->text().isEmpty()) - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_KEYPRESS, argv); - } - break; + if (o == qt.object && hasStockEvents) { + QKeyEvent *ke = (QKeyEvent*)e; + int key = ke->key(); + int state = ke->modifiers(); + void *argv[] = { + 0, + &key, + &state + }; + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_KEYDOWN, argv); + if (!ke->text().isEmpty()) + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_KEYPRESS, argv); + } + break; case QEvent::KeyRelease: - if (o == qt.object && hasStockEvents) { - QKeyEvent *ke = (QKeyEvent*)e; - int key = ke->key(); - int state = ke->modifiers(); - void *argv[] = { - 0, - &key, - &state - }; - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_KEYUP, argv); - } - break; + if (o == qt.object && hasStockEvents) { + QKeyEvent *ke = (QKeyEvent*)e; + int key = ke->key(); + int state = ke->modifiers(); + void *argv[] = { + 0, + &key, + &state + }; + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_KEYUP, argv); + } + break; case QEvent::MouseMove: - if (o == qt.object && hasStockEvents) { - QMouseEvent *me = (QMouseEvent*)e; + if (o == qt.object && hasStockEvents) { + QMouseEvent *me = (QMouseEvent*)e; int button = me->buttons() & Qt::MouseButtonMask; - int state = mapModifiers(me->modifiers()); - int x = me->x(); - int y = me->y(); - void *argv[] = { - 0, - &button, - &state, - &x, - &y - }; - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_MOUSEMOVE, argv); - } - break; + int state = mapModifiers(me->modifiers()); + int x = me->x(); + int y = me->y(); + void *argv[] = { + 0, + &button, + &state, + &x, + &y + }; + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_MOUSEMOVE, argv); + } + break; case QEvent::MouseButtonRelease: - if (o == qt.object && hasStockEvents) { - QMouseEvent *me = (QMouseEvent*)e; - int button = me->button(); - int state = mapModifiers(me->modifiers()); - int x = me->x(); - int y = me->y(); - void *argv[] = { - 0, - &button, - &state, - &x, - &y - }; - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_MOUSEUP, argv); - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_CLICK, 0); - } - break; + if (o == qt.object && hasStockEvents) { + QMouseEvent *me = (QMouseEvent*)e; + int button = me->button(); + int state = mapModifiers(me->modifiers()); + int x = me->x(); + int y = me->y(); + void *argv[] = { + 0, + &button, + &state, + &x, + &y + }; + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_MOUSEUP, argv); + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_CLICK, 0); + } + break; case QEvent::MouseButtonDblClick: - if (o == qt.object && hasStockEvents) { - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_DBLCLICK, 0); - } - break; + if (o == qt.object && hasStockEvents) { + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_DBLCLICK, 0); + } + break; case QEvent::MouseButtonPress: if (m_spInPlaceSite && !isUIActive) { internalActivate(); } - if (o == qt.widget && hasStockEvents) { - QMouseEvent *me = (QMouseEvent*)e; - int button = me->button(); - int state = mapModifiers(me->modifiers()); - int x = me->x(); - int y = me->y(); - void *argv[] = { - 0, - &button, - &state, - &x, - &y - }; - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_MOUSEDOWN, argv); - } - break; + if (o == qt.widget && hasStockEvents) { + QMouseEvent *me = (QMouseEvent*)e; + int button = me->button(); + int state = mapModifiers(me->modifiers()); + int x = me->x(); + int y = me->y(); + void *argv[] = { + 0, + &button, + &state, + &x, + &y + }; + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_MOUSEDOWN, argv); + } + break; case QEvent::Show: - if (m_hWnd && o == qt.widget) - ShowWindow(m_hWnd, SW_SHOW); - updateMask(); - break; + if (m_hWnd && o == qt.widget) + ShowWindow(m_hWnd, SW_SHOW); + updateMask(); + break; case QEvent::Hide: - if (m_hWnd && o == qt.widget) - ShowWindow(m_hWnd, SW_HIDE); - break; + if (m_hWnd && o == qt.widget) + ShowWindow(m_hWnd, SW_HIDE); + break; case QEvent::EnabledChange: if (m_hWnd && o == qt.widget) @@ -4373,22 +4373,22 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) case QEvent::IconTextChange: case QEvent::ModifiedChange: case QEvent::Resize: - updateMask(); - break; + updateMask(); + break; case QEvent::WindowBlocked: { if (!m_spInPlaceFrame) break; m_spInPlaceFrame->EnableModeless(FALSE); MSG msg; // Visual Basic 6.0 posts the message WM_USER+3078 from the EnableModeless(). - // While handling this message, VB will disable all current top-levels. After - // this we have to re-enable the Qt modal widget to receive input events. + // While handling this message, VB will disable all current top-levels. After + // this we have to re-enable the Qt modal widget to receive input events. if (PeekMessage(&msg, 0, WM_USER+3078, WM_USER+3078, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); // FIXME: 4.10.2011 Does this work with the parent's HWND? QWidget *modalWidget = QApplication::activeModalWidget(); - if (modalWidget && modalWidget->isVisible() && modalWidget->isEnabled() + if (modalWidget && modalWidget->isVisible() && modalWidget->isEnabled() && !IsWindowEnabled(hwndForWidget(modalWidget))) EnableWindow(hwndForWidget(modalWidget), TRUE); } @@ -4400,7 +4400,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) m_spInPlaceFrame->EnableModeless(TRUE); break; default: - break; + break; } return QObject::eventFilter(o, e); } diff --git a/src/activeqt/control/qaxserverdll.cpp b/src/activeqt/control/qaxserverdll.cpp index be854cc..f6145f5 100644 --- a/src/activeqt/control/qaxserverdll.cpp +++ b/src/activeqt/control/qaxserverdll.cpp @@ -78,7 +78,7 @@ STDAPI DllGetClassObject(const GUID &clsid, const GUID &iid, void** ppv) if (!qAxThreadId) qAxThreadId = GetCurrentThreadId(); else if (GetCurrentThreadId() != qAxThreadId) - return E_FAIL; + return E_FAIL; GetClassObject(clsid, iid, ppv); if (!*ppv) @@ -94,7 +94,7 @@ STDAPI DllCanUnloadNow() return S_FALSE; if (!qax_ownQApp) return S_OK; - + // check if qApp still runs widgets (in other DLLs) QWidgetList widgets = qApp->allWidgets(); int count = widgets.count(); @@ -106,14 +106,14 @@ STDAPI DllCanUnloadNow() } if (count) return S_FALSE; - + // no widgets left - destroy qApp if (qax_hhook) UnhookWindowsHookEx(qax_hhook); - + delete qApp; qax_ownQApp = false; - + // never allow unloading - safety net for Internet Explorer return S_FALSE; } @@ -128,14 +128,14 @@ EXTERN_C BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpvR qAxInstance = hInstance; qAxIsServer = true; - + if (dwReason == DLL_PROCESS_ATTACH) { DisableThreadLibraryCalls(hInstance); qAxInit(); } else if (dwReason == DLL_PROCESS_DETACH) { qAxCleanup(); } - + return true; } diff --git a/src/activeqt/control/qaxservermain.cpp b/src/activeqt/control/qaxservermain.cpp index fd8dc63..07156f4 100644 --- a/src/activeqt/control/qaxservermain.cpp +++ b/src/activeqt/control/qaxservermain.cpp @@ -96,7 +96,7 @@ static DWORD WINAPI MonitorProc(void* /* pv */) CloseHandle(hEventShutdown); PostThreadMessage(dwThreadID, WM_QUIT, 0, 0); PostQuitMessage(0); - + return 0; } @@ -126,20 +126,20 @@ bool qax_startServer(QAxFactory::ServerType type) { if (qAxIsServer) return true; - + const QStringList keys = qAxFactory()->featureList(); if (!keys.count()) return false; - + if (!qAxFactory()->isService()) StartMonitor(); - + classRegistration = new DWORD[keys.count()]; int object = 0; for (QStringList::ConstIterator key = keys.begin(); key != keys.end(); ++key, ++object) { IUnknown* p = 0; CLSID clsid = qAxFactory()->classID(*key); - + // Create a QClassFactory (implemented in qaxserverbase.cpp) HRESULT hRes = GetClassObject(clsid, IID_IClassFactory, (void**)&p); if (SUCCEEDED(hRes)) @@ -161,19 +161,19 @@ bool qax_stopServer() { if (!qAxIsServer || !classRegistration) return true; - + qAxIsServer = false; - + const QStringList keys = qAxFactory()->featureList(); int object = 0; for (QStringList::ConstIterator key = keys.begin(); key != keys.end(); ++key, ++object) CoRevokeClassObject(classRegistration[object]); - + delete []classRegistration; classRegistration = 0; - + Sleep(dwPause); //wait for any threads to finish - + return true; } @@ -199,7 +199,7 @@ extern "C" int main(int, char **); EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, int nShowCmd) { - QT_USE_NAMESPACE + QT_USE_NAMESPACE qAxOutProcServer = true; GetModuleFileName(0, qAxModuleFilename, MAX_PATH); @@ -237,7 +237,7 @@ EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, else version = "1.0"; } - + nRet = DumpIDL(QString::fromLatin1(outfile.constData()), QString::fromLatin1(version.constData())); } else { qWarning("Wrong commandline syntax: <app> -dumpidl <idl file> [-version <x.y.z>]"); @@ -248,7 +248,7 @@ EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, unprocessed += cmds.at(i) + ' '; } } - + if (run) { if (SUCCEEDED(CoInitialize(0))) { int argc; @@ -266,6 +266,6 @@ EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, nRet = -1; } } - + return nRet; } diff --git a/src/activeqt/doc/snippets/doc_src_qaxserver.cpp b/src/activeqt/doc/snippets/doc_src_qaxserver.cpp index df6ef2b..e9ae716 100644 --- a/src/activeqt/doc/snippets/doc_src_qaxserver.cpp +++ b/src/activeqt/doc/snippets/doc_src_qaxserver.cpp @@ -121,7 +121,7 @@ MyFactory(const QUuid &, const QUuid &); //! [11] HMODULE dll = LoadLibrary("myserver.dll"); typedef HRESULT(__stdcall *DllRegisterServerProc)(); -DllRegisterServerProc DllRegisterServer = +DllRegisterServerProc DllRegisterServer = (DllRegisterServerProc)GetProcAddress(dll, "DllRegisterServer"); HRESULT res = E_FAIL; diff --git a/src/activeqt/doc/snippets/src_activeqt_container_qaxbase.cpp b/src/activeqt/doc/snippets/src_activeqt_container_qaxbase.cpp index a716bc3..23060b7 100644 --- a/src/activeqt/doc/snippets/src_activeqt_container_qaxbase.cpp +++ b/src/activeqt/doc/snippets/src_activeqt_container_qaxbase.cpp @@ -56,7 +56,7 @@ webBrowser->dynamicCall("GoHome()"); //! [3] connect(webBrowser, SIGNAL(TitleChanged(QString)), - this, SLOT(setCaption(QString))); + this, SLOT(setCaption(QString))); //! [3] @@ -175,8 +175,8 @@ QAxWidget outlook("Outlook.Application"); QAxObject *session = outlook.querySubObject("Session"); if (session) { QAxObject *defFolder = session->querySubObject( - "GetDefaultFolder(OlDefaultFolders)", - "olFolderContacts"); + "GetDefaultFolder(OlDefaultFolders)", + "olFolderContacts"); //... } //! [19] @@ -187,13 +187,13 @@ void Receiver::slot(const QString &name, int argc, void *argv) { VARIANTARG *params = (VARIANTARG*)argv; if (name.startsWith("BeforeNavigate2(")) { - IDispatch *pDisp = params[argc-1].pdispVal; - VARIANTARG URL = *params[argc-2].pvarVal; - VARIANTARG Flags = *params[argc-3].pvarVal; - VARIANTARG TargetFrameName = *params[argc-4].pvarVal; - VARIANTARG PostData = *params[argc-5].pvarVal; - VARIANTARG Headers = *params[argc-6].pvarVal; - bool *Cancel = params[argc-7].pboolVal; + IDispatch *pDisp = params[argc-1].pdispVal; + VARIANTARG URL = *params[argc-2].pvarVal; + VARIANTARG Flags = *params[argc-3].pvarVal; + VARIANTARG TargetFrameName = *params[argc-4].pvarVal; + VARIANTARG PostData = *params[argc-5].pvarVal; + VARIANTARG Headers = *params[argc-6].pvarVal; + bool *Cancel = params[argc-7].pboolVal; } } //! [20] diff --git a/src/activeqt/doc/snippets/src_activeqt_control_qaxfactory.cpp b/src/activeqt/doc/snippets/src_activeqt_control_qaxfactory.cpp index 7b4d6a2..67763cc 100644 --- a/src/activeqt/doc/snippets/src_activeqt_control_qaxfactory.cpp +++ b/src/activeqt/doc/snippets/src_activeqt_control_qaxfactory.cpp @@ -89,7 +89,7 @@ QUuid ActiveQtFactory::eventsID(const QString &key) const } QAXFACTORY_EXPORT( - ActiveQtFactory, // factory class + ActiveQtFactory, // factory class "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID ) @@ -114,7 +114,7 @@ QAXFACTORY_END() #include "theactivex.h" QAXFACTORY_DEFAULT( - TheActiveX, // widget class + TheActiveX, // widget class "{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID @@ -165,7 +165,7 @@ if (QAxFactory::isServer()) { #include "theactivex.h" QAXFACTORY_DEFAULT( - TheActiveX, // widget class + TheActiveX, // widget class "{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID @@ -177,7 +177,7 @@ QAXFACTORY_DEFAULT( //! [8] QAXFACTORY_EXPORT( - MyFactory, // factory class + MyFactory, // factory class "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID ) diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp index af14a29..364e680 100644 --- a/src/activeqt/shared/qaxtypes.cpp +++ b/src/activeqt/shared/qaxtypes.cpp @@ -91,7 +91,7 @@ static IFontDisp *QFontToIFont(const QFont &font) fdesc.fUnderline = font.underline(); fdesc.lpstrName = QStringToBSTR(font.family()); fdesc.sWeight = font.weight() * 10; - + IFontDisp *f; HRESULT res = OleCreateFontIndirect(&fdesc, IID_IFontDisp, (void**)&f); if (res != S_OK) { @@ -128,7 +128,7 @@ static QFont IFontToQFont(IFont *f) font.setStrikeOut(strike); font.setUnderline(underline); SysFreeString(name); - + return font; } @@ -139,14 +139,14 @@ static IPictureDisp *QPixmapToIPicture(const QPixmap &pixmap) return 0; #else IPictureDisp *pic = 0; - + PICTDESC desc; desc.cbSizeofstruct = sizeof(PICTDESC); desc.picType = PICTYPE_BITMAP; - + desc.bmp.hbitmap = 0; desc.bmp.hpal = 0; - + if (!pixmap.isNull()) { desc.bmp.hbitmap = qaxPixmapToWinHBITMAP(pixmap); Q_ASSERT(desc.bmp.hbitmap); @@ -184,7 +184,7 @@ static QDateTime DATEToQDateTime(DATE ole) SYSTEMTIME stime; if (ole >= 949998 || VariantTimeToSystemTime(ole, &stime) == false) return QDateTime(); - + QDate date(stime.wYear, stime.wMonth, stime.wDay); QTime time(stime.wHour, stime.wMinute, stime.wSecond, stime.wMilliseconds); return QDateTime(date, time); @@ -194,7 +194,7 @@ static DATE QDateTimeToDATE(const QDateTime &dt) { if (!dt.isValid() || dt.isNull()) return 949998; - + SYSTEMTIME stime; memset(&stime, 0, sizeof(stime)); QDate date = dt.date(); @@ -210,10 +210,10 @@ static DATE QDateTimeToDATE(const QDateTime &dt) stime.wMinute = time.minute(); stime.wHour = time.hour(); } - + double vtime; SystemTimeToVariantTime(&stime, &vtime); - + return vtime; } @@ -285,7 +285,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } } break; - + case QVariant::Int: if (out && arg.vt == (VT_I4|VT_BYREF)) { *arg.plVal = qvar.toInt(); @@ -306,7 +306,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } } break; - + case QVariant::UInt: if (out && (arg.vt == (VT_UINT|VT_BYREF) || arg.vt == (VT_I4|VT_BYREF))) { *arg.puintVal = qvar.toUInt(); @@ -319,7 +319,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } } break; - + case QVariant::LongLong: if (out && arg.vt == (VT_CY|VT_BYREF)) { arg.pcyVal->int64 = qvar.toLongLong(); @@ -345,7 +345,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } #endif break; - + case QVariant::ULongLong: if (out && arg.vt == (VT_CY|VT_BYREF)) { arg.pcyVal->int64 = qvar.toULongLong(); @@ -373,7 +373,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type #endif break; - + case QVariant::Bool: if (out && arg.vt == (VT_BOOL|VT_BYREF)) { *arg.pboolVal = qvar.toBool() ? VARIANT_TRUE : VARIANT_FALSE; @@ -396,7 +396,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type if (out) { if (typeName == "float") { arg.vt = VT_R4; - arg.pfltVal = new float(arg.dblVal); + arg.pfltVal = new float(arg.dblVal); } else { arg.pdblVal = new double(arg.dblVal); } @@ -406,7 +406,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type break; case QVariant::Color: if (out && arg.vt == (VT_COLOR|VT_BYREF)) { - + *arg.plVal = QColorToOLEColor(qvariant_cast<QColor>(qvar)); } else { arg.vt = VT_COLOR; @@ -417,7 +417,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } } break; - + case QVariant::Date: case QVariant::Time: case QVariant::DateTime: @@ -446,7 +446,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } } break; - + case QVariant::Pixmap: if (out && arg.vt == (VT_DISPATCH|VT_BYREF)) { if (*arg.ppdispVal) @@ -498,7 +498,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type #endif } break; - + case QVariant::List: { const QList<QVariant> list = qvar.toList(); @@ -543,7 +543,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } SAFEARRAY *array = 0; bool is2D = false; - // If the first element in the array is a list the whole list is + // If the first element in the array is a list the whole list is // treated as a 2D array. The column count is taken from the 1st element. if (count) { QVariantList col = list.at(0).toList(); @@ -597,7 +597,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } } break; - + case QVariant::StringList: { const QStringList list = qvar.toStringList(); @@ -609,7 +609,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type SafeArrayPutElement(array, &index, bstr); SysFreeString(bstr); } - + if (out && arg.vt == (VT_ARRAY|VT_BSTR|VT_BYREF)) { if (*arg.pparray) SafeArrayDestroy(*arg.pparray); @@ -624,12 +624,12 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } } break; - + case QVariant::ByteArray: { const QByteArray bytes = qvar.toByteArray(); const uint count = bytes.count(); - SAFEARRAY *array = SafeArrayCreateVector(VT_UI1, 0, count); + SAFEARRAY *array = SafeArrayCreateVector(VT_UI1, 0, count); if (count) { const char *data = bytes.constData(); char *dest; @@ -637,7 +637,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type memcpy(dest, data, count); SafeArrayUnaccessData(array); } - + if (out && arg.vt == (VT_ARRAY|VT_UI1|VT_BYREF)) { if (*arg.pparray) SafeArrayDestroy(*arg.pparray); @@ -652,7 +652,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } } break; - + #ifdef QAX_SERVER case QVariant::Rect: case QVariant::Size: @@ -668,7 +668,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } if (!pGetRecordInfoFromTypeInfo) break; - + ITypeInfo *typeInfo = 0; IRecordInfo *recordInfo = 0; CLSID clsid = qvar.type() == QVariant::Rect ? CLSID_QRect @@ -681,7 +681,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type typeInfo->Release(); if (!recordInfo) break; - + void *record = 0; switch (qvar.type()) { case QVariant::Rect: @@ -705,7 +705,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type default: break; } - + arg.vt = VT_RECORD; arg.pRecInfo = recordInfo, arg.pvRecord = record; @@ -792,11 +792,11 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type default: return false; } - + Q_ASSERT(!out || (arg.vt & VT_BYREF)); return true; } - + /*! Returns \a arg as a QVariant of type \a type. @@ -968,7 +968,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint if (arg.pvarVal) var = VARIANTToQVariant(*arg.pvarVal, typeName); break; - + case VT_DISPATCH: case VT_DISPATCH|VT_BYREF: { @@ -1053,12 +1053,12 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint break; case VT_ARRAY|VT_VARIANT: case VT_ARRAY|VT_VARIANT|VT_BYREF: - { - SAFEARRAY *array = 0; - if ( arg.vt & VT_BYREF ) - array = *arg.pparray; - else - array = arg.parray; + { + SAFEARRAY *array = 0; + if ( arg.vt & VT_BYREF ) + array = *arg.pparray; + else + array = arg.parray; UINT cDims = array ? SafeArrayGetDim(array) : 0; switch(cDims) { @@ -1066,19 +1066,19 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint { QVariantList list; - long lBound, uBound; - SafeArrayGetLBound( array, 1, &lBound ); - SafeArrayGetUBound( array, 1, &uBound ); + long lBound, uBound; + SafeArrayGetLBound( array, 1, &lBound ); + SafeArrayGetUBound( array, 1, &uBound ); - for ( long i = lBound; i <= uBound; ++i ) { - VARIANT var; - VariantInit( &var ); - SafeArrayGetElement( array, &i, &var ); + for ( long i = lBound; i <= uBound; ++i ) { + VARIANT var; + VariantInit( &var ); + SafeArrayGetElement( array, &i, &var ); - QVariant qvar = VARIANTToQVariant( var, 0 ); - clearVARIANT( &var ); - list << qvar; - } + QVariant qvar = VARIANTToQVariant( var, 0 ); + clearVARIANT( &var ); + list << qvar; + } var = list; } @@ -1090,24 +1090,24 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint long dimIndices[2]; long xlBound, xuBound, ylBound, yuBound; - SafeArrayGetLBound(array, 1, &xlBound); - SafeArrayGetUBound(array, 1, &xuBound); - SafeArrayGetLBound(array, 2, &ylBound); - SafeArrayGetUBound(array, 2, &yuBound); + SafeArrayGetLBound(array, 1, &xlBound); + SafeArrayGetUBound(array, 1, &xuBound); + SafeArrayGetLBound(array, 2, &ylBound); + SafeArrayGetUBound(array, 2, &yuBound); for (long x = xlBound; x <= xuBound; ++x) { QVariantList list; dimIndices[0] = x; - for (long y = ylBound; y <= yuBound; ++y) { - VARIANT var; - VariantInit(&var); + for (long y = ylBound; y <= yuBound; ++y) { + VARIANT var; + VariantInit(&var); dimIndices[1] = y; - SafeArrayGetElement(array, dimIndices, &var); + SafeArrayGetElement(array, dimIndices, &var); - QVariant qvar = VARIANTToQVariant(var, 0); - clearVARIANT(&var); - list << qvar; + QVariant qvar = VARIANTToQVariant(var, 0); + clearVARIANT(&var); + list << qvar; } listList << QVariant(list); @@ -1119,9 +1119,9 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint var = QVariantList(); break; } - } + } break; - + case VT_ARRAY|VT_BSTR: case VT_ARRAY|VT_BSTR|VT_BYREF: { @@ -1130,28 +1130,28 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint array = *arg.pparray; else array = arg.parray; - + QStringList strings; if (!array || array->cDims != 1) { var = strings; break; } - + long lBound, uBound; SafeArrayGetLBound(array, 1, &lBound); SafeArrayGetUBound(array, 1, &uBound); - + for (long i = lBound; i <= uBound; ++i) { BSTR bstr; SafeArrayGetElement(array, &i, &bstr); strings << QString::fromWCharArray(bstr); SysFreeString(bstr); } - + var = strings; } break; - + case VT_ARRAY|VT_UI1: case VT_ARRAY|VT_UI1|VT_BYREF: { @@ -1160,17 +1160,17 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint array = *arg.pparray; else array = arg.parray; - + QByteArray bytes; if (!array || array->cDims != 1) { var = bytes; break; } - + long lBound, uBound; SafeArrayGetLBound(array, 1, &lBound); SafeArrayGetUBound(array, 1, &uBound); - + if (uBound != -1) { // non-empty array bytes.resize(uBound - lBound + 1); char *data = bytes.data(); @@ -1179,11 +1179,11 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint memcpy(data, src, bytes.size()); SafeArrayUnaccessData(array); } - + var = bytes; } break; - + #if defined(QAX_SERVER) case VT_RECORD: case VT_RECORD|VT_BYREF: @@ -1192,7 +1192,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint void *record = arg.pvRecord; GUID guid; recordInfo->GetGuid(&guid); - + if (guid == CLSID_QRect) { QRect qrect; recordInfo->RecordCopy(record, &qrect); @@ -1211,7 +1211,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint #endif // QAX_SERVER default: #if !defined(Q_OS_WINCE) - // support for any SAFEARRAY(Type) where Type can be converted to a QVariant + // support for any SAFEARRAY(Type) where Type can be converted to a QVariant // -> QVariantList if (arg.vt & VT_ARRAY) { SAFEARRAY *array = 0; @@ -1264,20 +1264,20 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint SafeArrayGetLBound( array, 1, &lBound ); SafeArrayGetUBound( array, 1, &uBound ); - for ( long i = lBound; i <= uBound; ++i ) { + for ( long i = lBound; i <= uBound; ++i ) { variant.vt = vt; - SafeArrayGetElement(array, &i, pElement); - QVariant qvar = VARIANTToQVariant(variant, 0); - clearVARIANT(&variant); - list << qvar; - } + SafeArrayGetElement(array, &i, pElement); + QVariant qvar = VARIANTToQVariant(variant, 0); + clearVARIANT(&variant); + list << qvar; + } var = list; } #endif break; } - + QVariant::Type proptype = (QVariant::Type)type; if (proptype == QVariant::Invalid && !typeName.isEmpty()) { if (typeName != "QVariant") |