Windows: Introduce helper class for implementing COM interfaces
Task-number: QTBUG-43190 Change-Id: I565e3c57631c32a88ac7598758526c349ddf3312 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>bb10
parent
626edf3c2d
commit
c25b13cee0
|
|
@ -61,40 +61,7 @@ static inline T *coTaskMemAllocArray(int size)
|
|||
/**************************************************************\
|
||||
* AccessibleApplication *
|
||||
**************************************************************/
|
||||
// IUnknown
|
||||
HRESULT STDMETHODCALLTYPE AccessibleApplication::QueryInterface(REFIID id, LPVOID *iface)
|
||||
{
|
||||
*iface = 0;
|
||||
if (id == IID_IUnknown) {
|
||||
qCDebug(lcQpaAccessibility) << "AccessibleApplication::QI(): IID_IUnknown";
|
||||
*iface = static_cast<IUnknown *>(this);
|
||||
} else if (id == IID_IAccessibleApplication) {
|
||||
qCDebug(lcQpaAccessibility) << "AccessibleApplication::QI(): IID_IAccessibleApplication";
|
||||
*iface = static_cast<IAccessibleApplication*>(this);
|
||||
}
|
||||
|
||||
if (*iface) {
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AccessibleApplication::AddRef()
|
||||
{
|
||||
return ++m_ref;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AccessibleApplication::Release()
|
||||
{
|
||||
if (!--m_ref) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_ref;
|
||||
}
|
||||
|
||||
/* IAccessibleApplication */
|
||||
HRESULT STDMETHODCALLTYPE AccessibleApplication::get_appName(/* [retval][out] */ BSTR *name)
|
||||
{
|
||||
const QString appName = QGuiApplication::applicationName();
|
||||
|
|
@ -127,40 +94,11 @@ HRESULT STDMETHODCALLTYPE AccessibleApplication::get_toolkitVersion(/* [retval][
|
|||
**************************************************************/
|
||||
AccessibleRelation::AccessibleRelation(const QList<QAccessibleInterface *> &targets,
|
||||
QAccessible::Relation relation)
|
||||
: m_targets(targets), m_relation(relation), m_ref(1)
|
||||
: m_targets(targets), m_relation(relation)
|
||||
{
|
||||
Q_ASSERT(m_targets.count());
|
||||
}
|
||||
|
||||
/* IUnknown */
|
||||
HRESULT STDMETHODCALLTYPE AccessibleRelation::QueryInterface(REFIID id, LPVOID *iface)
|
||||
{
|
||||
*iface = 0;
|
||||
if (id == IID_IUnknown || id == IID_IAccessibleRelation)
|
||||
*iface = static_cast<IUnknown *>(this);
|
||||
|
||||
if (*iface) {
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AccessibleRelation::AddRef()
|
||||
{
|
||||
return ++m_ref;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AccessibleRelation::Release()
|
||||
{
|
||||
if (!--m_ref) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_ref;
|
||||
}
|
||||
|
||||
/* IAccessibleRelation */
|
||||
HRESULT STDMETHODCALLTYPE AccessibleRelation::get_relationType(
|
||||
/* [retval][out] */ BSTR *relationType)
|
||||
|
|
@ -237,56 +175,53 @@ HRESULT STDMETHODCALLTYPE AccessibleRelation::get_targets(
|
|||
**************************************************************/
|
||||
HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryInterface(REFIID id, LPVOID *iface)
|
||||
{
|
||||
*iface = nullptr;
|
||||
QAccessibleInterface *accessible = accessibleInterface();
|
||||
if (!accessible)
|
||||
return E_NOINTERFACE;
|
||||
|
||||
HRESULT hr = QWindowsMsaaAccessible::QueryInterface(id, iface);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
if (id == IID_IServiceProvider) {
|
||||
*iface = static_cast<IServiceProvider *>(this);
|
||||
} else if (id == IID_IAccessible2) {
|
||||
*iface = static_cast<IAccessible2 *>(this);
|
||||
} else if (id == IID_IAccessibleAction) {
|
||||
if (accessible->actionInterface())
|
||||
*iface = static_cast<IAccessibleAction *>(this);
|
||||
} else if (id == IID_IAccessibleComponent) {
|
||||
*iface = static_cast<IAccessibleComponent *>(this);
|
||||
} else if (id == IID_IAccessibleEditableText) {
|
||||
if (accessible->editableTextInterface() ||
|
||||
accessible->role() == QAccessible::EditableText)
|
||||
{
|
||||
*iface = static_cast<IAccessibleEditableText *>(this);
|
||||
}
|
||||
} else if (id == IID_IAccessibleHyperlink) {
|
||||
//*iface = static_cast<IAccessibleHyperlink *>(this);
|
||||
} else if (id == IID_IAccessibleHypertext) {
|
||||
//*iface = static_cast<IAccessibleHypertext *>(this);
|
||||
} else if (id == IID_IAccessibleImage) {
|
||||
//*iface = static_cast<IAccessibleImage *>(this);
|
||||
} else if (id == IID_IAccessibleTable) {
|
||||
//*iface = static_cast<IAccessibleTable *>(this); // not supported
|
||||
} else if (id == IID_IAccessibleTable2) {
|
||||
if (accessible->tableInterface())
|
||||
*iface = static_cast<IAccessibleTable2 *>(this);
|
||||
} else if (id == IID_IAccessibleTableCell) {
|
||||
if (accessible->tableCellInterface())
|
||||
*iface = static_cast<IAccessibleTableCell *>(this);
|
||||
} else if (id == IID_IAccessibleText) {
|
||||
if (accessible->textInterface())
|
||||
*iface = static_cast<IAccessibleText *>(this);
|
||||
} else if (id == IID_IAccessibleValue) {
|
||||
if (accessible->valueInterface())
|
||||
*iface = static_cast<IAccessibleValue *>(this);
|
||||
}
|
||||
if (*iface) {
|
||||
AddRef();
|
||||
hr = S_OK;
|
||||
} else {
|
||||
hr = E_NOINTERFACE;
|
||||
}
|
||||
if (SUCCEEDED(QWindowsMsaaAccessible::QueryInterface(id, iface))
|
||||
|| qWindowsComQueryInterface<IServiceProvider>(this, id, iface)
|
||||
|| qWindowsComQueryInterface<IAccessible2>(this, id, iface)
|
||||
|| qWindowsComQueryInterface<IAccessibleComponent>(this, id, iface)) {
|
||||
return S_OK;
|
||||
}
|
||||
return hr;
|
||||
|
||||
if (id == IID_IAccessibleAction) {
|
||||
if (accessible->actionInterface())
|
||||
*iface = static_cast<IAccessibleAction *>(this);
|
||||
} else if (id == IID_IAccessibleEditableText) {
|
||||
if (accessible->editableTextInterface() ||
|
||||
accessible->role() == QAccessible::EditableText)
|
||||
{
|
||||
*iface = static_cast<IAccessibleEditableText *>(this);
|
||||
}
|
||||
} else if (id == IID_IAccessibleHyperlink) {
|
||||
//*iface = static_cast<IAccessibleHyperlink *>(this);
|
||||
} else if (id == IID_IAccessibleHypertext) {
|
||||
//*iface = static_cast<IAccessibleHypertext *>(this);
|
||||
} else if (id == IID_IAccessibleImage) {
|
||||
//*iface = static_cast<IAccessibleImage *>(this);
|
||||
} else if (id == IID_IAccessibleTable) {
|
||||
//*iface = static_cast<IAccessibleTable *>(this); // not supported
|
||||
} else if (id == IID_IAccessibleTable2) {
|
||||
if (accessible->tableInterface())
|
||||
*iface = static_cast<IAccessibleTable2 *>(this);
|
||||
} else if (id == IID_IAccessibleTableCell) {
|
||||
if (accessible->tableCellInterface())
|
||||
*iface = static_cast<IAccessibleTableCell *>(this);
|
||||
} else if (id == IID_IAccessibleText) {
|
||||
if (accessible->textInterface())
|
||||
*iface = static_cast<IAccessibleText *>(this);
|
||||
} else if (id == IID_IAccessibleValue) {
|
||||
if (accessible->valueInterface())
|
||||
*iface = static_cast<IAccessibleValue *>(this);
|
||||
}
|
||||
if (*iface) {
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include <QtCore/QtConfig>
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
|
||||
#include "qwindowscombase.h"
|
||||
#include "qwindowsmsaaaccessible.h"
|
||||
#include "comutils.h"
|
||||
|
||||
|
|
@ -258,28 +259,18 @@ private:
|
|||
/**************************************************************\
|
||||
* AccessibleApplication *
|
||||
**************************************************************/
|
||||
class AccessibleApplication : public IAccessibleApplication
|
||||
class AccessibleApplication : public QWindowsComBase<IAccessibleApplication>
|
||||
{
|
||||
public:
|
||||
AccessibleApplication() : m_ref(1)
|
||||
{
|
||||
|
||||
}
|
||||
AccessibleApplication() {}
|
||||
|
||||
virtual ~AccessibleApplication() {}
|
||||
|
||||
/* IUnknown */
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID *);
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
ULONG STDMETHODCALLTYPE Release();
|
||||
|
||||
/* IAccessibleApplication */
|
||||
HRESULT STDMETHODCALLTYPE get_appName(/* [retval][out] */ BSTR *name);
|
||||
HRESULT STDMETHODCALLTYPE get_appVersion(/* [retval][out] */ BSTR *version);
|
||||
HRESULT STDMETHODCALLTYPE get_toolkitName(/* [retval][out] */ BSTR *name);
|
||||
HRESULT STDMETHODCALLTYPE get_toolkitVersion(/* [retval][out] */ BSTR *version);
|
||||
private:
|
||||
ULONG m_ref;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -287,7 +278,7 @@ private:
|
|||
/**************************************************************\
|
||||
* AccessibleRelation *
|
||||
**************************************************************/
|
||||
class AccessibleRelation : public IAccessibleRelation
|
||||
class AccessibleRelation : public QWindowsComBase<IAccessibleRelation>
|
||||
{
|
||||
public:
|
||||
AccessibleRelation(const QList<QAccessibleInterface *> &targets,
|
||||
|
|
@ -295,11 +286,6 @@ public:
|
|||
|
||||
virtual ~AccessibleRelation() {}
|
||||
|
||||
/* IUnknown */
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface);
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
ULONG STDMETHODCALLTYPE Release();
|
||||
|
||||
/* IAccessibleRelation */
|
||||
HRESULT STDMETHODCALLTYPE get_relationType(BSTR *relationType);
|
||||
HRESULT STDMETHODCALLTYPE get_localizedRelationType(BSTR *localizedRelationType);
|
||||
|
|
@ -341,7 +327,6 @@ private:
|
|||
|
||||
QList<QAccessibleInterface *> m_targets;
|
||||
QAccessible::Relation m_relation;
|
||||
ULONG m_ref;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "qwindowsmsaaaccessible.h"
|
||||
#include "qwindowsaccessibility.h"
|
||||
#include "qwindowscombase.h"
|
||||
#include <oleacc.h>
|
||||
#include <servprov.h>
|
||||
#include <winuser.h>
|
||||
|
|
@ -71,61 +72,22 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWindowsEnumerate : public IEnumVARIANT
|
||||
class QWindowsEnumerate : public QWindowsComBase<IEnumVARIANT>
|
||||
{
|
||||
public:
|
||||
QWindowsEnumerate(const QVector<int> &a)
|
||||
: ref(0), current(0),array(a)
|
||||
{
|
||||
}
|
||||
|
||||
QWindowsEnumerate(const QVector<int> &a) : QWindowsComBase<IEnumVARIANT>(0), current(0),array(a) {}
|
||||
virtual ~QWindowsEnumerate() {}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID *);
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
ULONG STDMETHODCALLTYPE Release();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Clone(IEnumVARIANT **ppEnum);
|
||||
HRESULT STDMETHODCALLTYPE Next(unsigned long celt, VARIANT FAR* rgVar, unsigned long FAR* pCeltFetched);
|
||||
HRESULT STDMETHODCALLTYPE Reset();
|
||||
HRESULT STDMETHODCALLTYPE Skip(unsigned long celt);
|
||||
|
||||
private:
|
||||
ULONG ref;
|
||||
ULONG current;
|
||||
QVector<int> array;
|
||||
};
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QWindowsEnumerate::QueryInterface(REFIID id, LPVOID *iface)
|
||||
{
|
||||
*iface = 0;
|
||||
if (id == IID_IUnknown)
|
||||
*iface = static_cast<IUnknown *>(this);
|
||||
else if (id == IID_IEnumVARIANT)
|
||||
*iface = static_cast<IEnumVARIANT *>(this);
|
||||
|
||||
if (*iface) {
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE QWindowsEnumerate::AddRef()
|
||||
{
|
||||
return ++ref;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE QWindowsEnumerate::Release()
|
||||
{
|
||||
if (!--ref) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QWindowsEnumerate::Clone(IEnumVARIANT **ppEnum)
|
||||
{
|
||||
QWindowsEnumerate *penum = 0;
|
||||
|
|
@ -193,29 +155,17 @@ void accessibleDebugClientCalls_helper(const char* funcName, const QAccessibleIn
|
|||
**************************************************************/
|
||||
HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::QueryInterface(REFIID id, LPVOID *iface)
|
||||
{
|
||||
*iface = 0;
|
||||
*iface = nullptr;
|
||||
const bool result = qWindowsComQueryUnknownInterfaceMulti<AccessibleBase>(this, id, iface)
|
||||
|| qWindowsComQueryInterface<IDispatch>(this, id, iface)
|
||||
|| qWindowsComQueryInterface<IAccessible>(this, id, iface)
|
||||
|| qWindowsComQueryInterface<IOleWindow>(this, id, iface);
|
||||
|
||||
QByteArray strIID = IIDToString(id);
|
||||
if (!strIID.isEmpty()) {
|
||||
if (result) {
|
||||
qCDebug(lcQpaAccessibility) << "QWindowsIA2Accessible::QI() - IID:"
|
||||
<< strIID << ", iface:" << accessibleInterface();
|
||||
<< IIDToString(id) << ", iface:" << accessibleInterface();
|
||||
}
|
||||
if (id == IID_IUnknown) {
|
||||
*iface = static_cast<IUnknown *>(static_cast<IDispatch *>(this));
|
||||
} else if (id == IID_IDispatch) {
|
||||
*iface = static_cast<IDispatch *>(this);
|
||||
} else if (id == IID_IAccessible) {
|
||||
*iface = static_cast<IAccessible *>(this);
|
||||
} else if (id == IID_IOleWindow) {
|
||||
*iface = static_cast<IOleWindow *>(this);
|
||||
}
|
||||
|
||||
if (*iface) {
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return E_NOINTERFACE;
|
||||
return result ? S_OK : E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE QWindowsMsaaAccessible::AddRef()
|
||||
|
|
|
|||
|
|
@ -72,13 +72,14 @@ QWindow *window_helper(const QAccessibleInterface *iface);
|
|||
/**************************************************************\
|
||||
* QWindowsAccessible *
|
||||
**************************************************************/
|
||||
class QWindowsMsaaAccessible : public
|
||||
#ifdef Q_CC_MINGW
|
||||
IAccessible
|
||||
|
||||
#ifndef Q_CC_MINGW
|
||||
typedef IAccessible2 AccessibleBase;
|
||||
#else
|
||||
IAccessible2
|
||||
typedef IAccessible AccessibleBase;
|
||||
#endif
|
||||
, public IOleWindow
|
||||
|
||||
class QWindowsMsaaAccessible : public AccessibleBase, public IOleWindow
|
||||
{
|
||||
public:
|
||||
QWindowsMsaaAccessible(QAccessibleInterface *a)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWINDOWSCOMBASE_H
|
||||
#define QWINDOWSCOMBASE_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#include <unknwn.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Helper for implementing IUnknown::QueryInterface.
|
||||
template <class DesiredInterface, class Derived>
|
||||
bool qWindowsComQueryInterface(Derived *d, REFIID id, LPVOID *iface)
|
||||
{
|
||||
if (id == __uuidof(DesiredInterface)) {
|
||||
*iface = static_cast<DesiredInterface *>(d);
|
||||
d->AddRef();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Helper for implementing IUnknown::QueryInterface for IUnknown
|
||||
// in the case of multiple inheritance via the first inherited class.
|
||||
template <class FirstInheritedInterface, class Derived>
|
||||
bool qWindowsComQueryUnknownInterfaceMulti(Derived *d, REFIID id, LPVOID *iface)
|
||||
{
|
||||
if (id == __uuidof(IUnknown)) {
|
||||
*iface = static_cast<FirstInheritedInterface *>(d);
|
||||
d->AddRef();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Helper base class to provide IUnknown methods for COM classes (single inheritance)
|
||||
template <class ComInterface> class QWindowsComBase : public ComInterface
|
||||
{
|
||||
Q_DISABLE_COPY(QWindowsComBase)
|
||||
public:
|
||||
explicit QWindowsComBase(ULONG initialRefCount = 1) : m_ref(initialRefCount) {}
|
||||
virtual ~QWindowsComBase() {}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface)
|
||||
{
|
||||
*iface = nullptr;
|
||||
return qWindowsComQueryInterface<IUnknown>(this, id, iface) || qWindowsComQueryInterface<ComInterface>(this, id, iface)
|
||||
? S_OK : E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef() { return ++m_ref; }
|
||||
|
||||
ULONG STDMETHODCALLTYPE Release()
|
||||
{
|
||||
if (!--m_ref) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_ref;
|
||||
}
|
||||
|
||||
private:
|
||||
ULONG m_ref;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWINDOWSCOMBASE_H
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#define _WIN32_WINNT 0x0600
|
||||
|
||||
#include "qwindowscombase.h"
|
||||
#include "qwindowsdialoghelpers.h"
|
||||
|
||||
#include "qwindowscontext.h"
|
||||
|
|
@ -504,33 +505,11 @@ inline void QWindowsFileDialogSharedData::fromOptions(const QSharedPointer<QFile
|
|||
|
||||
class QWindowsNativeFileDialogBase;
|
||||
|
||||
class QWindowsNativeFileDialogEventHandler : public IFileDialogEvents
|
||||
class QWindowsNativeFileDialogEventHandler : public QWindowsComBase<IFileDialogEvents>
|
||||
{
|
||||
public:
|
||||
static IFileDialogEvents *create(QWindowsNativeFileDialogBase *nativeFileDialog);
|
||||
|
||||
// IUnknown methods
|
||||
IFACEMETHODIMP QueryInterface(REFIID riid, void** ppv)
|
||||
{
|
||||
if (riid != IID_IUnknown && riid != IID_IFileDialogEvents) {
|
||||
*ppv = NULL;
|
||||
return ResultFromScode(E_NOINTERFACE);
|
||||
}
|
||||
*ppv = this;
|
||||
AddRef();
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(ULONG) AddRef() { return InterlockedIncrement(&m_ref); }
|
||||
|
||||
IFACEMETHODIMP_(ULONG) Release()
|
||||
{
|
||||
const long ref = InterlockedDecrement(&m_ref);
|
||||
if (!ref)
|
||||
delete this;
|
||||
return ref;
|
||||
}
|
||||
|
||||
// IFileDialogEvents methods
|
||||
IFACEMETHODIMP OnFileOk(IFileDialog *);
|
||||
IFACEMETHODIMP OnFolderChange(IFileDialog *) { return S_OK; }
|
||||
|
|
@ -546,7 +525,6 @@ public:
|
|||
virtual ~QWindowsNativeFileDialogEventHandler() {}
|
||||
|
||||
private:
|
||||
long m_ref = 1;
|
||||
QWindowsNativeFileDialogBase *m_nativeFileDialog;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ static inline Qt::MouseButtons toQtMouseButtons(DWORD keyState)
|
|||
\ingroup qt-lighthouse-win
|
||||
*/
|
||||
|
||||
class QWindowsOleDropSource : public IDropSource
|
||||
class QWindowsOleDropSource : public QWindowsComBase<IDropSource>
|
||||
{
|
||||
public:
|
||||
enum Mode {
|
||||
|
|
@ -228,11 +228,6 @@ public:
|
|||
|
||||
void createCursors();
|
||||
|
||||
// IUnknown methods
|
||||
STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)(void);
|
||||
STDMETHOD_(ULONG,Release)(void);
|
||||
|
||||
// IDropSource methods
|
||||
STDMETHOD(QueryContinueDrag)(BOOL fEscapePressed, DWORD grfKeyState);
|
||||
STDMETHOD(GiveFeedback)(DWORD dwEffect);
|
||||
|
|
@ -257,7 +252,6 @@ private:
|
|||
ActionCursorMap m_cursors;
|
||||
QWindowsDragCursorWindow *m_touchDragWindow;
|
||||
|
||||
ULONG m_refs;
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
friend QDebug operator<<(QDebug, const QWindowsOleDropSource::CursorEntry &);
|
||||
#endif
|
||||
|
|
@ -268,7 +262,6 @@ QWindowsOleDropSource::QWindowsOleDropSource(QWindowsDrag *drag)
|
|||
, m_drag(drag)
|
||||
, m_currentButtons(Qt::NoButton)
|
||||
, m_touchDragWindow(0)
|
||||
, m_refs(1)
|
||||
{
|
||||
qCDebug(lcQpaMime) << __FUNCTION__ << m_mode;
|
||||
}
|
||||
|
|
@ -373,38 +366,6 @@ void QWindowsOleDropSource::createCursors()
|
|||
#endif // !QT_NO_DEBUG_OUTPUT
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// IUnknown Methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
STDMETHODIMP
|
||||
QWindowsOleDropSource::QueryInterface(REFIID iid, void FAR* FAR* ppv)
|
||||
{
|
||||
if (iid == IID_IUnknown || iid == IID_IDropSource) {
|
||||
*ppv = this;
|
||||
++m_refs;
|
||||
return NOERROR;
|
||||
}
|
||||
*ppv = NULL;
|
||||
return ResultFromScode(E_NOINTERFACE);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QWindowsOleDropSource::AddRef(void)
|
||||
{
|
||||
return ++m_refs;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QWindowsOleDropSource::Release(void)
|
||||
{
|
||||
if (--m_refs == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_refs;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Check for cancel.
|
||||
*/
|
||||
|
|
@ -504,34 +465,6 @@ QWindowsOleDropTarget::~QWindowsOleDropTarget()
|
|||
qCDebug(lcQpaMime) << __FUNCTION__ << this;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
QWindowsOleDropTarget::QueryInterface(REFIID iid, void FAR* FAR* ppv)
|
||||
{
|
||||
if (iid == IID_IUnknown || iid == IID_IDropTarget) {
|
||||
*ppv = this;
|
||||
AddRef();
|
||||
return NOERROR;
|
||||
}
|
||||
*ppv = NULL;
|
||||
return ResultFromScode(E_NOINTERFACE);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QWindowsOleDropTarget::AddRef(void)
|
||||
{
|
||||
return ++m_refs;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QWindowsOleDropTarget::Release(void)
|
||||
{
|
||||
if (--m_refs == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_refs;
|
||||
}
|
||||
|
||||
void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState,
|
||||
const QPoint &point, LPDWORD pdwEffect)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#ifndef QWINDOWSDRAG_H
|
||||
#define QWINDOWSDRAG_H
|
||||
|
||||
#include "qwindowscombase.h"
|
||||
#include "qwindowsinternalmimedata.h"
|
||||
|
||||
#include <qpa/qplatformdrag.h>
|
||||
|
|
@ -57,17 +58,12 @@ public:
|
|||
IDataObject *retrieveDataObject() const override;
|
||||
};
|
||||
|
||||
class QWindowsOleDropTarget : public IDropTarget
|
||||
class QWindowsOleDropTarget : public QWindowsComBase<IDropTarget>
|
||||
{
|
||||
public:
|
||||
explicit QWindowsOleDropTarget(QWindow *w);
|
||||
virtual ~QWindowsOleDropTarget();
|
||||
|
||||
// IUnknown methods
|
||||
STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
|
||||
STDMETHOD_(ULONG, AddRef)(void);
|
||||
STDMETHOD_(ULONG, Release)(void);
|
||||
|
||||
// IDropTarget methods
|
||||
STDMETHOD(DragEnter)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
|
||||
STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
|
||||
|
|
@ -77,7 +73,6 @@ public:
|
|||
private:
|
||||
void handleDrag(QWindow *window, DWORD grfKeyState, const QPoint &, LPDWORD pdwEffect);
|
||||
|
||||
ULONG m_refs = 1;
|
||||
QWindow *const m_window;
|
||||
QRect m_answerRect;
|
||||
QPoint m_lastPoint;
|
||||
|
|
|
|||
|
|
@ -99,39 +99,6 @@ DWORD QWindowsOleDataObject::reportedPerformedEffect() const
|
|||
return performedEffect;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// IUnknown Methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
STDMETHODIMP
|
||||
QWindowsOleDataObject::QueryInterface(REFIID iid, void FAR* FAR* ppv)
|
||||
{
|
||||
if (iid == IID_IUnknown || iid == IID_IDataObject) {
|
||||
*ppv = this;
|
||||
AddRef();
|
||||
return NOERROR;
|
||||
}
|
||||
*ppv = NULL;
|
||||
return ResultFromScode(E_NOINTERFACE);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QWindowsOleDataObject::AddRef(void)
|
||||
{
|
||||
return ++m_refs;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QWindowsOleDataObject::Release(void)
|
||||
{
|
||||
if (--m_refs == 0) {
|
||||
releaseQt();
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_refs;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
QWindowsOleDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium)
|
||||
{
|
||||
|
|
@ -323,35 +290,6 @@ bool QWindowsOleEnumFmtEtc::isNull() const
|
|||
return m_isNull;
|
||||
}
|
||||
|
||||
// IUnknown methods
|
||||
STDMETHODIMP
|
||||
QWindowsOleEnumFmtEtc::QueryInterface(REFIID riid, void FAR* FAR* ppvObj)
|
||||
{
|
||||
if (riid == IID_IUnknown || riid == IID_IEnumFORMATETC) {
|
||||
*ppvObj = this;
|
||||
AddRef();
|
||||
return NOERROR;
|
||||
}
|
||||
*ppvObj = NULL;
|
||||
return ResultFromScode(E_NOINTERFACE);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QWindowsOleEnumFmtEtc::AddRef(void)
|
||||
{
|
||||
return ++m_dwRefs;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QWindowsOleEnumFmtEtc::Release(void)
|
||||
{
|
||||
if (--m_dwRefs == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_dwRefs;
|
||||
}
|
||||
|
||||
// IEnumFORMATETC methods
|
||||
STDMETHODIMP
|
||||
QWindowsOleEnumFmtEtc::Next(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetched)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#ifndef QWINDOWSOLE_H
|
||||
#define QWINDOWSOLE_H
|
||||
|
||||
#include "qwindowscombase.h"
|
||||
#include <QtCore/qt_windows.h>
|
||||
|
||||
#include <QtCore/QMap>
|
||||
|
|
@ -53,7 +54,7 @@ QT_BEGIN_NAMESPACE
|
|||
class QMimeData;
|
||||
class QWindow;
|
||||
|
||||
class QWindowsOleDataObject : public IDataObject
|
||||
class QWindowsOleDataObject : public QWindowsComBase<IDataObject>
|
||||
{
|
||||
public:
|
||||
explicit QWindowsOleDataObject(QMimeData *mimeData);
|
||||
|
|
@ -63,11 +64,6 @@ public:
|
|||
QMimeData *mimeData() const;
|
||||
DWORD reportedPerformedEffect() const;
|
||||
|
||||
// IUnknown methods
|
||||
STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)(void);
|
||||
STDMETHOD_(ULONG,Release)(void);
|
||||
|
||||
// IDataObject methods
|
||||
STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
|
||||
STDMETHOD(GetDataHere)(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium);
|
||||
|
|
@ -82,13 +78,12 @@ public:
|
|||
STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR* ppenumAdvise);
|
||||
|
||||
private:
|
||||
ULONG m_refs = 1;
|
||||
QPointer<QMimeData> data;
|
||||
const int CF_PERFORMEDDROPEFFECT;
|
||||
DWORD performedEffect = DROPEFFECT_NONE;
|
||||
};
|
||||
|
||||
class QWindowsOleEnumFmtEtc : public IEnumFORMATETC
|
||||
class QWindowsOleEnumFmtEtc : public QWindowsComBase<IEnumFORMATETC>
|
||||
{
|
||||
public:
|
||||
explicit QWindowsOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs);
|
||||
|
|
@ -97,11 +92,6 @@ public:
|
|||
|
||||
bool isNull() const;
|
||||
|
||||
// IUnknown methods
|
||||
STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
|
||||
STDMETHOD_(ULONG,AddRef)(void);
|
||||
STDMETHOD_(ULONG,Release)(void);
|
||||
|
||||
// IEnumFORMATETC methods
|
||||
STDMETHOD(Next)(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetched);
|
||||
STDMETHOD(Skip)(ULONG celt);
|
||||
|
|
@ -111,7 +101,6 @@ public:
|
|||
private:
|
||||
bool copyFormatEtc(LPFORMATETC dest, const FORMATETC *src) const;
|
||||
|
||||
ULONG m_dwRefs = 1;
|
||||
ULONG m_nIndex = 0;
|
||||
QVector<LPFORMATETC> m_lpfmtetcs;
|
||||
bool m_isNull = false;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ SOURCES += \
|
|||
$$PWD/qwin10helpers.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/qwindowscombase.h \
|
||||
$$PWD/qwindowswindow.h \
|
||||
$$PWD/qwindowsintegration.h \
|
||||
$$PWD/qwindowscontext.h \
|
||||
|
|
|
|||
Loading…
Reference in New Issue