44 #include <QtCore/qhash.h> 45 #include <QtCore/quuid.h> 46 #include <QtCore/qfactoryinterface.h> 47 #include <QtCore/qmetaobject.h> 48 #include <QtCore/qstringlist.h> 59 #ifndef QT_NO_WIN_ACTIVEQT 129 #define QAXFACTORY_EXPORT(IMPL, TYPELIB, APPID) \ 131 QAxFactory *qax_instantiate() \ 133 IMPL *impl = new IMPL(QUuid(TYPELIB), QUuid(APPID)); \ 138 #define QAXFACTORY_DEFAULT(Class, IIDClass, IIDInterface, IIDEvents, IIDTypeLib, IIDApp) \ 140 class QAxDefaultFactory : public QAxFactory \ 143 QAxDefaultFactory(const QUuid &app, const QUuid &lib) \ 144 : QAxFactory(app, lib), className(QLatin1String(#Class)) {} \ 145 QStringList featureList() const \ 151 const QMetaObject *metaObject(const QString &key) const \ 153 if (key == className) \ 154 return &Class::staticMetaObject; \ 157 QObject *createObject(const QString &key) \ 159 if (key == className) \ 160 return new Class(0); \ 163 QUuid classID(const QString &key) const \ 165 if (key == className) \ 166 return QUuid(IIDClass); \ 169 QUuid interfaceID(const QString &key) const \ 171 if (key == className) \ 172 return QUuid(IIDInterface); \ 175 QUuid eventsID(const QString &key) const \ 177 if (key == className) \ 178 return QUuid(IIDEvents); \ 185 QAXFACTORY_EXPORT(QAxDefaultFactory, IIDTypeLib, IIDApp) \ 208 #define QAXFACTORY_BEGIN(IDTypeLib, IDApp) \ 210 class QAxFactoryList : public QAxFactory \ 212 QStringList factoryKeys; \ 213 QHash<QString, QAxFactory*> factories; \ 214 QHash<QString, bool> creatable; \ 217 : QAxFactory(IDTypeLib, IDApp) \ 219 QAxFactory *factory = 0; \ 221 QStringList::Iterator it; \ 223 #define QAXCLASS(Class) \ 224 factory = new QAxClass<Class>(typeLibID(), appID()); \ 225 qRegisterMetaType<Class*>(#Class"*"); \ 226 keys = factory->featureList(); \ 227 for (it = keys.begin(); it != keys.end(); ++it) { \ 228 factoryKeys += *it; \ 229 factories.insert(*it, factory); \ 230 creatable.insert(*it, true); \ 233 #define QAXTYPE(Class) \ 234 factory = new QAxClass<Class>(typeLibID(), appID()); \ 235 qRegisterMetaType<Class*>(#Class"*"); \ 236 keys = factory->featureList(); \ 237 for (it = keys.begin(); it != keys.end(); ++it) { \ 238 factoryKeys += *it; \ 239 factories.insert(*it, factory); \ 240 creatable.insert(*it, false); \ 243 #define QAXFACTORY_END() \ 245 ~QAxFactoryList() { qDeleteAll(factories); } \ 246 QStringList featureList() const { return factoryKeys; } \ 247 const QMetaObject *metaObject(const QString&key) const { \ 248 QAxFactory *f = factories[key]; \ 249 return f ? f->metaObject(key) : 0; \ 251 QObject *createObject(const QString &key) { \ 252 if (!creatable.value(key)) \ 254 QAxFactory *f = factories[key]; \ 255 return f ? f->createObject(key) : 0; \ 257 QUuid classID(const QString &key) { \ 258 QAxFactory *f = factories.value(key); \ 259 return f ? f->classID(key) : QUuid(); \ 261 QUuid interfaceID(const QString &key) { \ 262 QAxFactory *f = factories.value(key); \ 263 return f ? f->interfaceID(key) : QUuid(); \ 265 QUuid eventsID(const QString &key) { \ 266 QAxFactory *f = factories.value(key); \ 267 return f ? f->eventsID(key) : QUuid(); \ 269 void registerClass(const QString &key, QSettings *s) const { \ 270 QAxFactory *f = factories.value(key); \ 271 if (f) f->registerClass(key, s); \ 273 void unregisterClass(const QString &key, QSettings *s) const { \ 274 QAxFactory *f = factories.value(key); \ 275 if (f) f->unregisterClass(key, s); \ 277 QString exposeToSuperClass(const QString &key) const { \ 278 QAxFactory *f = factories.value(key); \ 279 return f ? f->exposeToSuperClass(key) : QString(); \ 281 bool stayTopLevel(const QString &key) const { \ 282 QAxFactory *f = factories.value(key); \ 283 return f ? f->stayTopLevel(key) : false; \ 285 bool hasStockEvents(const QString &key) const { \ 286 QAxFactory *f = factories.value(key); \ 287 return f ? f->hasStockEvents(key) : false; \ 290 QAxFactory *qax_instantiate() \ 292 QAxFactoryList *impl = new QAxFactoryList(); \ 299 #ifndef Q_COM_METATYPE_DECLARED 300 #define Q_COM_METATYPE_DECLARED 307 #endif // QT_NO_WIN_ACTIVEQT 311 #endif // QAXFACTORY_H
virtual QUuid typeLibID() const
Reimplement this function to return the ActiveX server's type library identifier. ...
#define QT_END_NAMESPACE
This macro expands to.
QAxFactory * qAxFactory()
The QSettings class provides persistent platform-independent application settings.
static bool stopServer()
Stops the COM server and returns true if successful, otherwise returns false.
The QAxFactory class defines a factory for the creation of COM components.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString serverDirPath()
Returns the directory that contains the server binary.
The QString class provides a Unicode character string.
QStringList featureList() const
Reimplement this function to return a list of the widgets (class names) supported by this factory...
The QObject class is the base class of all Qt objects.
virtual QStringList featureList() const =0
Reimplement this function to return a list of the widgets (class names) supported by this factory...
virtual QString exposeToSuperClass(const QString &key) const
Reimplement this function to return the name of the super class of key up to which methods and proper...
static QString serverFilePath()
Returns the file path of the server binary.
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual ~QAxFactory()
Destroys the QAxFactory object.
virtual bool hasStockEvents(const QString &key) const
Reimplement this function to return true if the ActiveX control key should support the standard Activ...
The QStringList class provides a list of strings.
QObject * createObject(const QString &key)
Reimplement this function to return a new object for key, or 0 if this factory doesn't support the va...
virtual QUuid appID() const
Reimplement this function to return the ActiveX server's application identifier.
virtual QUuid interfaceID(const QString &key) const
Reimplement this function to return the interface identifier for each key returned by the featureList...
virtual bool createObjectWrapper(QObject *object, IDispatch **wrapper)
Reimplement this function to provide the COM object for object in wrapper.
static bool registerActiveObject(QObject *object)
Registers the QObject object with COM as a running object, and returns true if the registration succe...
virtual bool stayTopLevel(const QString &key) const
Reimplement this function to return true if the ActiveX control key should be a top level window...
virtual QUuid eventsID(const QString &key) const
Reimplement this function to return the identifier of the event interface for each key returned by th...
QAxFactory(const QUuid &libId, const QUuid &appId)
Constructs a QAxFactory object that returns libid and appid in the implementation of the respective i...
virtual bool isService() const
Reimplement this function to return true if the server is running as a persistent service (e...
static bool isServer()
Returns true if the application has been started (by COM) as an ActiveX server, otherwise returns fal...
virtual void unregisterClass(const QString &key, QSettings *) const
Unregisters any additional values for the class key from the system registry using the settings objec...
virtual bool validateLicenseKey(const QString &key, const QString &licenseKey) const
Reimplement this function to return true if licenseKey is a valid license for the class key...
static bool startServer(ServerType type=MultipleInstances)
Starts the COM server with type and returns true if successful, otherwise returns false...
ServerType
This enum specifies the different types of servers that can be started with startServer.
const QMetaObject * metaObject(const QString &) const
Reimplement this function to return the QMetaObject corresponding to key, or 0 if this factory doesn'...
bool qax_startServer(QAxFactory::ServerType)
int qstrcmp(const QByteArray &str1, const char *str2)
virtual QObject * createObject(const QString &key)=0
Reimplement this function to return a new object for key, or 0 if this factory doesn't support the va...
QAxClass(const QString &libId, const QString &appId)
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QUuid class stores a Universally Unique Identifier (UUID).
virtual QUuid classID(const QString &key) const
Reimplement this function to return the class identifier for each key returned by the featureList() i...
virtual void registerClass(const QString &key, QSettings *) const
Registers additional values for the class key in the system registry using the settings object...