summaryrefslogtreecommitdiffstats
path: root/src/activeqt/container/qaxbase_p.h
blob: 265e98f37636ea0d4dd8f6fa57b213702fc4ef5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the ActiveQt framework of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
******************************************************************************/

#ifndef QAXBASE_P_H
#define QAXBASE_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <QtCore/qbytearray.h>
#include <QtCore/qhash.h>
#include <QtCore/qmap.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/quuid.h>
#include <QtCore/qt_windows.h>

struct tagEXCEPINFO;

QT_BEGIN_NAMESPACE

class QAxBase;
class QAxEventSink;

class QAxBasePrivate
{
    Q_DISABLE_COPY_MOVE(QAxBasePrivate)
public:
    using UuidEventSinkHash = QHash<QUuid, QAxEventSink*>;

    explicit QAxBasePrivate();
    ~QAxBasePrivate();

    virtual QObject *qObject() const = 0;
    virtual const char *className() const = 0;
    virtual const QMetaObject *fallbackMetaObject() const = 0;
    virtual const QMetaObject *parentMetaObject() const = 0;

    virtual void emitException(int code, const QString &source, const QString &desc,
                               const QString &help) = 0;
    virtual void emitPropertyChanged(const QString &name) = 0;
    virtual void emitSignal(const QString &name, int argc, void *argv) = 0;

    int qtMetaCall(QMetaObject::Call, int, void **);
    static int qtStaticMetaCall(QAxBase *, QMetaObject::Call, int, void **);

    IDispatch *dispatch() const
    {
        if (disp)
            return disp;

        if (ptr)
            ptr->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(&disp));
        return disp;
    }

    bool checkHRESULT(long hres, tagEXCEPINFO *exc, const QString &name, uint argerr);
    void handleException(tagEXCEPINFO *exc, const QString &name);

    static QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint type = 0);

    QAxBase *q = nullptr;
    QString ctrl;
    UuidEventSinkHash eventSink;
    uint useEventSink       :1;
    uint useMetaObject      :1;
    uint useClassInfo       :1;
    uint cachedMetaObject   :1;
    uint initialized        :1;
    uint tryCache           :1;
    unsigned long classContext = CLSCTX_SERVER;

    IUnknown *ptr = nullptr;
    mutable IDispatch *disp = nullptr;

    QMap<QByteArray, bool> propWritable;

    QMetaObject *metaObject()
    {
        return metaobj;
    }

    mutable QMap<QString, LONG> verbs;

    QMetaObject *metaobj = nullptr;
};

QT_END_NAMESPACE

#endif // QAXBASE_P_H