Qt 4.8
qaxobject.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the ActiveQt framework of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
19 ** distribution.
20 ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21 ** of its contributors may be used to endorse or promote products derived
22 ** from this software without specific prior written permission.
23 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 #include "qaxobject.h"
42 
43 #ifndef QT_NO_WIN_ACTIVEQT
44 
45 #include <quuid.h>
46 #include <qmetaobject.h>
47 #include <qstringlist.h>
48 
49 #include <windows.h>
50 
52 
94 : QObject(parent)
95 {
96 }
97 
105 : QObject(parent)
106 {
107  setControl(c);
108 }
109 
115 : QObject(parent), QAxBase(iface)
116 {
117 }
118 
124 {
125  clear();
126 }
127 
132 {
133  return QAxBase::metaObject();
134 }
135 
140 {
142 }
143 
147 void *QAxObject::qt_metacast(const char *cname)
148 {
149  if (!qstrcmp(cname, "QAxObject")) return (void*)this;
150  if (!qstrcmp(cname, "QAxBase")) return (QAxBase*)this;
151  return QObject::qt_metacast(cname);
152 }
153 
157 const char *QAxObject::className() const
158 {
159  return "QAxObject";
160 }
161 
165 int QAxObject::qt_metacall(QMetaObject::Call call, int id, void **v)
166 {
167  id = QObject::qt_metacall(call, id, v);
168  if (id < 0)
169  return id;
170  return QAxBase::qt_metacall(call, id, v);
171 }
172 
181 void QAxObject::connectNotify(const char *)
182 {
184 }
185 
197 bool QAxObject::doVerb(const QString &verb)
198 {
199  if (!verbs().contains(verb))
200  return false;
201  IOleObject *ole = 0;
202  queryInterface(IID_IOleObject, (void**)&ole);
203  if (!ole)
204  return false;
205 
206  LONG index = indexOfVerb(verb);
207 
208  HRESULT hres = ole->DoVerb(index, 0, 0, 0, 0, 0);
209 
210  ole->Release();
211 
212  return hres == S_OK;
213 }
214 
216 #endif // QT_NO_WIN_ACTIVEQT
QStringList verbs() const
Returns the list of verbs that the COM object can execute.
Definition: qaxbase.cpp:1137
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual const QMetaObject * metaObject() const
The metaobject is generated on the fly from the information provided by the IDispatch and ITypeInfo i...
Definition: qaxbase.cpp:3245
QAxObject(QObject *parent=0)
Creates an empty COM object and propagates parent to the QObject constructor.
Definition: qaxobject.cpp:93
int qt_metacall(QMetaObject::Call, int, void **)
Definition: qaxobject.cpp:165
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
bool doVerb(const QString &verb)
Requests the COM object to perform the action verb.
Definition: qaxobject.cpp:197
const QMetaObject * metaObject() const
Definition: qaxobject.cpp:131
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual int qt_metacall(QMetaObject::Call, int, void **)
Definition: qaxbase.cpp:3705
void connectNotify()
Connects to all event interfaces of the object.
Definition: qaxbase.cpp:3282
bool setControl(const QString &)
Definition: qaxbase.cpp:975
void * qt_metacast(const char *)
Definition: qaxobject.cpp:147
long HRESULT
long indexOfVerb(const QString &verb) const
Definition: qaxbase.cpp:1172
const char * className() const
Definition: qaxobject.cpp:157
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
quint16 index
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
long queryInterface(const QUuid &, void **) const
Requests the interface uuid from the COM object and sets the value of iface to the provided interface...
Definition: qaxbase.cpp:1479
virtual void clear()
Disconnects and destroys the COM object.
Definition: qaxbase.cpp:1095
~QAxObject()
Releases the COM object and destroys the QAxObject, cleaning up all allocated resources.
Definition: qaxobject.cpp:123
The QAxBase class is an abstract class that provides an API to initialize and access a COM object...
Definition: qaxbase.h:66
const QMetaObject * parentMetaObject() const
Definition: qaxobject.cpp:139