[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the ActiveQt framework of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:BSD$
|
---|
| 10 | ** You may use this file under the terms of the BSD license as follows:
|
---|
| 11 | **
|
---|
| 12 | ** "Redistribution and use in source and binary forms, with or without
|
---|
| 13 | ** modification, are permitted provided that the following conditions are
|
---|
| 14 | ** met:
|
---|
| 15 | ** * Redistributions of source code must retain the above copyright
|
---|
| 16 | ** notice, this list of conditions and the following disclaimer.
|
---|
| 17 | ** * Redistributions in binary form must reproduce the above copyright
|
---|
| 18 | ** notice, this list of conditions and the following disclaimer in
|
---|
| 19 | ** the documentation and/or other materials provided with the
|
---|
| 20 | ** distribution.
|
---|
| 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
---|
| 22 | ** the names of its contributors may be used to endorse or promote
|
---|
| 23 | ** products derived from this software without specific prior written
|
---|
| 24 | ** permission.
|
---|
| 25 | **
|
---|
| 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
| 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
| 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
---|
| 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
---|
| 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
| 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
| 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
| 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
---|
| 37 | ** $QT_END_LICENSE$
|
---|
| 38 | **
|
---|
| 39 | ****************************************************************************/
|
---|
| 40 |
|
---|
| 41 | #ifndef QAXBASE_H
|
---|
| 42 | #define QAXBASE_H
|
---|
| 43 |
|
---|
| 44 | #include <QtCore/qdatastream.h>
|
---|
| 45 | #include <QtCore/qmap.h>
|
---|
| 46 | #include <QtCore/qobject.h>
|
---|
| 47 | #include <QtCore/qvariant.h>
|
---|
| 48 |
|
---|
| 49 | struct IUnknown;
|
---|
| 50 | struct IDispatch;
|
---|
| 51 |
|
---|
| 52 | QT_BEGIN_HEADER
|
---|
| 53 |
|
---|
| 54 | QT_BEGIN_NAMESPACE
|
---|
| 55 |
|
---|
| 56 | QT_MODULE(ActiveQt)
|
---|
| 57 |
|
---|
| 58 | #ifndef QT_NO_WIN_ACTIVEQT
|
---|
| 59 |
|
---|
| 60 | struct QUuid;
|
---|
| 61 | class QAxEventSink;
|
---|
| 62 | class QAxObject;
|
---|
| 63 | class QAxBasePrivate;
|
---|
| 64 | struct QAxMetaObject;
|
---|
| 65 |
|
---|
| 66 | class QAxBase
|
---|
| 67 | {
|
---|
| 68 | QDOC_PROPERTY(QString control READ control WRITE setControl)
|
---|
| 69 |
|
---|
| 70 | public:
|
---|
| 71 | typedef QMap<QString, QVariant> PropertyBag;
|
---|
| 72 |
|
---|
| 73 | QAxBase(IUnknown *iface = 0);
|
---|
| 74 | virtual ~QAxBase();
|
---|
| 75 |
|
---|
| 76 | QString control() const;
|
---|
| 77 |
|
---|
| 78 | long queryInterface(const QUuid &, void**) const;
|
---|
| 79 |
|
---|
| 80 | QVariant dynamicCall(const char *name, const QVariant &v1 = QVariant(),
|
---|
| 81 | const QVariant &v2 = QVariant(),
|
---|
| 82 | const QVariant &v3 = QVariant(),
|
---|
| 83 | const QVariant &v4 = QVariant(),
|
---|
| 84 | const QVariant &v5 = QVariant(),
|
---|
| 85 | const QVariant &v6 = QVariant(),
|
---|
| 86 | const QVariant &v7 = QVariant(),
|
---|
| 87 | const QVariant &v8 = QVariant());
|
---|
| 88 | QVariant dynamicCall(const char *name, QList<QVariant> &vars);
|
---|
| 89 | QAxObject *querySubObject(const char *name, const QVariant &v1 = QVariant(),
|
---|
| 90 | const QVariant &v2 = QVariant(),
|
---|
| 91 | const QVariant &v3 = QVariant(),
|
---|
| 92 | const QVariant &v4 = QVariant(),
|
---|
| 93 | const QVariant &v5 = QVariant(),
|
---|
| 94 | const QVariant &v6 = QVariant(),
|
---|
| 95 | const QVariant &v7 = QVariant(),
|
---|
| 96 | const QVariant &v8 = QVariant());
|
---|
| 97 | QAxObject* querySubObject(const char *name, QList<QVariant> &vars);
|
---|
| 98 |
|
---|
| 99 | virtual const QMetaObject *metaObject() const;
|
---|
| 100 | virtual int qt_metacall(QMetaObject::Call, int, void **);
|
---|
| 101 |
|
---|
| 102 | virtual QObject *qObject() const = 0;
|
---|
| 103 | virtual const char *className() const = 0;
|
---|
| 104 |
|
---|
| 105 | PropertyBag propertyBag() const;
|
---|
| 106 | void setPropertyBag(const PropertyBag&);
|
---|
| 107 |
|
---|
| 108 | QString generateDocumentation();
|
---|
| 109 |
|
---|
| 110 | virtual bool propertyWritable(const char*) const;
|
---|
| 111 | virtual void setPropertyWritable(const char*, bool);
|
---|
| 112 |
|
---|
| 113 | bool isNull() const;
|
---|
| 114 |
|
---|
| 115 | QStringList verbs() const;
|
---|
| 116 |
|
---|
| 117 | QVariant asVariant() const;
|
---|
| 118 |
|
---|
| 119 | #ifdef qdoc
|
---|
| 120 | Q_SIGNALS:
|
---|
| 121 | void signal(const QString&,int,void*);
|
---|
| 122 | void propertyChanged(const QString&);
|
---|
| 123 | void exception(int,const QString&,const QString&,const QString&);
|
---|
| 124 | #endif
|
---|
| 125 |
|
---|
| 126 | public:
|
---|
| 127 | virtual void clear();
|
---|
| 128 | bool setControl(const QString&);
|
---|
| 129 |
|
---|
| 130 | void disableMetaObject();
|
---|
| 131 | void disableClassInfo();
|
---|
| 132 | void disableEventSink();
|
---|
| 133 |
|
---|
| 134 | protected:
|
---|
| 135 | virtual bool initialize(IUnknown** ptr);
|
---|
| 136 | bool initializeRemote(IUnknown** ptr);
|
---|
| 137 | bool initializeLicensed(IUnknown** ptr);
|
---|
| 138 | bool initializeActive(IUnknown** ptr);
|
---|
| 139 | bool initializeFromFile(IUnknown** ptr);
|
---|
| 140 |
|
---|
| 141 | void internalRelease();
|
---|
| 142 | void initializeFrom(QAxBase *that);
|
---|
| 143 | void connectNotify();
|
---|
| 144 | long indexOfVerb(const QString &verb) const;
|
---|
| 145 |
|
---|
| 146 | private:
|
---|
| 147 | friend class QAxEventSink;
|
---|
| 148 | friend void *qax_createObjectWrapper(int, IUnknown*);
|
---|
| 149 | bool initializeLicensedHelper(void *factory, const QString &key, IUnknown **ptr);
|
---|
| 150 | QAxBasePrivate *d;
|
---|
| 151 | QAxMetaObject *internalMetaObject() const;
|
---|
| 152 |
|
---|
| 153 | virtual const QMetaObject *parentMetaObject() const = 0;
|
---|
| 154 | int internalProperty(QMetaObject::Call, int index, void **v);
|
---|
| 155 | int internalInvoke(QMetaObject::Call, int index, void **v);
|
---|
| 156 | bool dynamicCallHelper(const char *name, void *out, QList<QVariant> &var, QByteArray &type);
|
---|
| 157 |
|
---|
| 158 | static QMetaObject staticMetaObject;
|
---|
| 159 | };
|
---|
| 160 |
|
---|
| 161 | #if defined Q_CC_MSVC && _MSC_VER < 1300
|
---|
| 162 | template <> inline QAxBase *qobject_cast_helper<QAxBase*>(const QObject *o, QAxBase *)
|
---|
| 163 | #else
|
---|
| 164 | template <> inline QAxBase *qobject_cast<QAxBase*>(const QObject *o)
|
---|
| 165 | #endif
|
---|
| 166 | {
|
---|
| 167 | void *result = o ? const_cast<QObject *>(o)->qt_metacast("QAxBase") : 0;
|
---|
| 168 | return (QAxBase*)(result);
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | #if defined Q_CC_MSVC && _MSC_VER < 1300
|
---|
| 172 | template <> inline QAxBase *qobject_cast_helper<QAxBase*>(QObject *o, QAxBase *)
|
---|
| 173 | #else
|
---|
| 174 | template <> inline QAxBase *qobject_cast<QAxBase*>(QObject *o)
|
---|
| 175 | #endif
|
---|
| 176 | {
|
---|
| 177 | void *result = o ? o->qt_metacast("QAxBase") : 0;
|
---|
| 178 | return (QAxBase*)(result);
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | extern QString qax_generateDocumentation(QAxBase *);
|
---|
| 182 |
|
---|
| 183 | inline QString QAxBase::generateDocumentation()
|
---|
| 184 | {
|
---|
| 185 | return qax_generateDocumentation(this);
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | #ifndef QT_NO_DATASTREAM
|
---|
| 189 | inline QDataStream &operator >>(QDataStream &s, QAxBase &c)
|
---|
| 190 | {
|
---|
| 191 | QAxBase::PropertyBag bag;
|
---|
| 192 | c.qObject()->blockSignals(true);
|
---|
| 193 | QString control;
|
---|
| 194 | s >> control;
|
---|
| 195 | c.setControl(control);
|
---|
| 196 | s >> bag;
|
---|
| 197 | c.setPropertyBag(bag);
|
---|
| 198 | c.qObject()->blockSignals(false);
|
---|
| 199 |
|
---|
| 200 | return s;
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 | inline QDataStream &operator <<(QDataStream &s, const QAxBase &c)
|
---|
| 204 | {
|
---|
| 205 | QAxBase::PropertyBag bag = c.propertyBag();
|
---|
| 206 | s << c.control();
|
---|
| 207 | s << bag;
|
---|
| 208 |
|
---|
| 209 | return s;
|
---|
| 210 | }
|
---|
| 211 | #endif // QT_NO_DATASTREAM
|
---|
| 212 |
|
---|
| 213 | QT_END_NAMESPACE
|
---|
| 214 |
|
---|
| 215 | #ifndef Q_COM_METATYPE_DECLARED
|
---|
| 216 | #define Q_COM_METATYPE_DECLARED
|
---|
| 217 |
|
---|
| 218 | Q_DECLARE_METATYPE(IUnknown*)
|
---|
| 219 | Q_DECLARE_METATYPE(IDispatch*)
|
---|
| 220 |
|
---|
| 221 | #endif
|
---|
| 222 |
|
---|
| 223 | #endif // QT_NO_WIN_ACTIVEQT
|
---|
| 224 |
|
---|
| 225 | QT_END_HEADER
|
---|
| 226 |
|
---|
| 227 | #endif // QAXBASE_H
|
---|