Replace QWindowsComBase with QComObject
Currently with have two base classes for COM-objects that implement basic IUnknown functionality and the idea is to remove duplication and keep just one. Since QComObject supports more features than QWindowsComBase, such as multiple inheritance and intermediate interface querying, we should switch to the former one. Change-Id: Ief6567496de9f547b936de91d634c6998ba59a75 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 4a705f5f29aa5ffce8db87fe54f7e70c08124d80)
This commit is contained in:
parent
f5738ab463
commit
4baeef91d3
@ -4,7 +4,6 @@
|
||||
#define QT_NO_URL_CAST_FROM_STRING 1
|
||||
|
||||
#include <QtCore/qt_windows.h>
|
||||
#include "qwindowscombase.h"
|
||||
#include "qwindowsdialoghelpers.h"
|
||||
|
||||
#include "qwindowscontext.h"
|
||||
@ -33,6 +32,7 @@
|
||||
#include <QtCore/qtemporaryfile.h>
|
||||
#include <QtCore/private/qfunctions_win_p.h>
|
||||
#include <QtCore/private/qsystemerror_p.h>
|
||||
#include <QtCore/private/qcomobject_p.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
@ -423,7 +423,7 @@ inline void QWindowsFileDialogSharedData::fromOptions(const QSharedPointer<QFile
|
||||
|
||||
class QWindowsNativeFileDialogBase;
|
||||
|
||||
class QWindowsNativeFileDialogEventHandler : public QWindowsComBase<IFileDialogEvents>
|
||||
class QWindowsNativeFileDialogEventHandler : public QComObject<IFileDialogEvents>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsNativeFileDialogEventHandler)
|
||||
public:
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QtCore/qbuffer.h>
|
||||
#include <QtCore/qpoint.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/private/qcomobject_p.h>
|
||||
|
||||
#include <shlobj.h>
|
||||
|
||||
@ -168,7 +169,7 @@ static Qt::MouseButtons lastButtons = Qt::NoButton;
|
||||
\internal
|
||||
*/
|
||||
|
||||
class QWindowsOleDropSource : public QWindowsComBase<IDropSource>
|
||||
class QWindowsOleDropSource : public QComObject<IDropSource>
|
||||
{
|
||||
public:
|
||||
enum Mode {
|
||||
|
@ -4,12 +4,12 @@
|
||||
#ifndef QWINDOWSDRAG_H
|
||||
#define QWINDOWSDRAG_H
|
||||
|
||||
#include "qwindowscombase.h"
|
||||
#include "qwindowsinternalmimedata.h"
|
||||
|
||||
#include <qpa/qplatformdrag.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtGui/qdrag.h>
|
||||
#include <QtCore/private/qcomobject_p.h>
|
||||
|
||||
struct IDropTargetHelper;
|
||||
|
||||
@ -23,7 +23,7 @@ public:
|
||||
IDataObject *retrieveDataObject() const override;
|
||||
};
|
||||
|
||||
class QWindowsOleDropTarget : public QWindowsComBase<IDropTarget>
|
||||
class QWindowsOleDropTarget : public QComObject<IDropTarget>
|
||||
{
|
||||
public:
|
||||
explicit QWindowsOleDropTarget(QWindow *w);
|
||||
|
@ -4,12 +4,12 @@
|
||||
#ifndef QWINDOWSOLE_H
|
||||
#define QWINDOWSOLE_H
|
||||
|
||||
#include "qwindowscombase.h"
|
||||
#include <QtCore/qt_windows.h>
|
||||
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/private/qcomobject_p.h>
|
||||
|
||||
#include <objidl.h>
|
||||
|
||||
@ -18,7 +18,7 @@ QT_BEGIN_NAMESPACE
|
||||
class QMimeData;
|
||||
class QWindow;
|
||||
|
||||
class QWindowsOleDataObject : public QWindowsComBase<IDataObject>
|
||||
class QWindowsOleDataObject : public QComObject<IDataObject>
|
||||
{
|
||||
public:
|
||||
explicit QWindowsOleDataObject(QMimeData *mimeData);
|
||||
@ -47,7 +47,7 @@ private:
|
||||
DWORD performedEffect = DROPEFFECT_NONE;
|
||||
};
|
||||
|
||||
class QWindowsOleEnumFmtEtc : public QWindowsComBase<IEnumFORMATETC>
|
||||
class QWindowsOleEnumFmtEtc : public QComObject<IEnumFORMATETC>
|
||||
{
|
||||
public:
|
||||
explicit QWindowsOleEnumFmtEtc(const QList<FORMATETC> &fmtetcs);
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include <QtGui/qaccessible.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
#include <qwindowscombase.h>
|
||||
#include <QtGui/private/qwindowsuiawrapper_p.h>
|
||||
#include <QtCore/private/qcomobject_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -13,7 +13,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Expand/Collapse control pattern provider. Used for menu items with submenus.
|
||||
class QWindowsUiaExpandCollapseProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<IExpandCollapseProvider>
|
||||
public QComObject<IExpandCollapseProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaExpandCollapseProvider)
|
||||
public:
|
||||
|
@ -13,7 +13,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Grid Item control pattern provider. Used by items within a table/tree.
|
||||
class QWindowsUiaGridItemProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<IGridItemProvider>
|
||||
public QComObject<IGridItemProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaGridItemProvider)
|
||||
public:
|
||||
|
@ -12,8 +12,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Grid control pattern provider. Used by tables/trees.
|
||||
class QWindowsUiaGridProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<IGridProvider>
|
||||
class QWindowsUiaGridProvider : public QWindowsUiaBaseProvider, public QComObject<IGridProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaGridProvider)
|
||||
public:
|
||||
|
@ -12,8 +12,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Invoke control pattern provider.
|
||||
class QWindowsUiaInvokeProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<IInvokeProvider>
|
||||
class QWindowsUiaInvokeProvider : public QWindowsUiaBaseProvider, public QComObject<IInvokeProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaInvokeProvider)
|
||||
public:
|
||||
|
@ -13,7 +13,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Range Value control pattern provider.
|
||||
class QWindowsUiaRangeValueProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<IRangeValueProvider>
|
||||
public QComObject<IRangeValueProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaRangeValueProvider)
|
||||
public:
|
||||
|
@ -13,7 +13,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Selection Item control pattern provider. Used for List items and radio buttons.
|
||||
class QWindowsUiaSelectionItemProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<ISelectionItemProvider>
|
||||
public QComObject<ISelectionItemProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaSelectionItemProvider)
|
||||
public:
|
||||
|
@ -11,27 +11,28 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtPrivate {
|
||||
|
||||
template <>
|
||||
struct QComObjectTraits<ISelectionProvider2>
|
||||
{
|
||||
static constexpr bool isGuidOf(REFIID riid) noexcept
|
||||
{
|
||||
return QComObjectTraits<ISelectionProvider2, ISelectionProvider>::isGuidOf(riid);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace QtPrivate
|
||||
|
||||
// Implements the Selection control pattern provider. Used for Lists.
|
||||
class QWindowsUiaSelectionProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<ISelectionProvider2>
|
||||
public QComObject<ISelectionProvider2>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaSelectionProvider)
|
||||
public:
|
||||
explicit QWindowsUiaSelectionProvider(QAccessible::Id id);
|
||||
virtual ~QWindowsUiaSelectionProvider();
|
||||
|
||||
// override to support ISelectionProvider and ISelectionProvider2 at the same time
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface) override
|
||||
{
|
||||
HRESULT res = QWindowsComBase<ISelectionProvider2>::QueryInterface(id, iface);
|
||||
// QWindowsComBase<ISelectionProvider2>::QueryInterface doesn't handle ISelectionProvider,
|
||||
// from which ISelectionProvider2 inherits
|
||||
if (res == E_NOINTERFACE)
|
||||
res = qWindowsComQueryInterface<ISelectionProvider>(this, id, iface) ? S_OK : E_NOINTERFACE;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
// ISelectionProvider
|
||||
HRESULT STDMETHODCALLTYPE GetSelection(SAFEARRAY **pRetVal) override;
|
||||
HRESULT STDMETHODCALLTYPE get_CanSelectMultiple(BOOL *pRetVal) override;
|
||||
|
@ -13,7 +13,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Table Item control pattern provider. Used by items within a table/tree.
|
||||
class QWindowsUiaTableItemProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<ITableItemProvider>
|
||||
public QComObject<ITableItemProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaTableItemProvider)
|
||||
public:
|
||||
|
@ -12,8 +12,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Table control pattern provider. Used by tables/trees.
|
||||
class QWindowsUiaTableProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<ITableProvider>
|
||||
class QWindowsUiaTableProvider : public QWindowsUiaBaseProvider, public QComObject<ITableProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaTableProvider)
|
||||
public:
|
||||
|
@ -26,20 +26,6 @@ QWindowsUiaTextProvider::~QWindowsUiaTextProvider()
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::QueryInterface(REFIID iid, LPVOID *iface)
|
||||
{
|
||||
qCDebug(lcQpaUiAutomation) << __FUNCTION__ << this;
|
||||
|
||||
if (!iface)
|
||||
return E_INVALIDARG;
|
||||
*iface = nullptr;
|
||||
|
||||
const bool result = qWindowsComQueryUnknownInterfaceMulti<ITextProvider>(this, iid, iface)
|
||||
|| qWindowsComQueryInterface<ITextProvider>(this, iid, iface)
|
||||
|| qWindowsComQueryInterface<ITextProvider2>(this, iid, iface);
|
||||
return result ? S_OK : E_NOINTERFACE;
|
||||
}
|
||||
|
||||
// Returns an array of providers for the selected text ranges.
|
||||
HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::GetSelection(SAFEARRAY **pRetVal)
|
||||
{
|
||||
|
@ -12,18 +12,27 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtPrivate {
|
||||
|
||||
template <>
|
||||
struct QComObjectTraits<ITextProvider2>
|
||||
{
|
||||
static constexpr bool isGuidOf(REFIID riid) noexcept
|
||||
{
|
||||
return QComObjectTraits<ITextProvider2, ITextProvider>::isGuidOf(riid);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace QtPrivate
|
||||
|
||||
// Implements the Text control pattern provider. Used for text controls.
|
||||
class QWindowsUiaTextProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<ITextProvider2>
|
||||
class QWindowsUiaTextProvider : public QWindowsUiaBaseProvider, public QComObject<ITextProvider2>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaTextProvider)
|
||||
public:
|
||||
explicit QWindowsUiaTextProvider(QAccessible::Id id);
|
||||
~QWindowsUiaTextProvider();
|
||||
|
||||
// IUnknown overrides
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface) override;
|
||||
|
||||
// ITextProvider
|
||||
HRESULT STDMETHODCALLTYPE GetSelection(SAFEARRAY **pRetVal) override;
|
||||
HRESULT STDMETHODCALLTYPE GetVisibleRanges(SAFEARRAY **pRetVal) override;
|
||||
|
@ -13,7 +13,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Text Range control pattern provider. Used for text controls.
|
||||
class QWindowsUiaTextRangeProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<ITextRangeProvider>
|
||||
public QComObject<ITextRangeProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaTextRangeProvider)
|
||||
public:
|
||||
|
@ -12,8 +12,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Toggle control pattern provider. Used for checkboxes.
|
||||
class QWindowsUiaToggleProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<IToggleProvider>
|
||||
class QWindowsUiaToggleProvider : public QWindowsUiaBaseProvider, public QComObject<IToggleProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaToggleProvider)
|
||||
public:
|
||||
|
@ -13,8 +13,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
// Implements the Value control pattern provider.
|
||||
// Supported for all controls that can return text(QAccessible::Value).
|
||||
class QWindowsUiaValueProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<IValueProvider>
|
||||
class QWindowsUiaValueProvider : public QWindowsUiaBaseProvider, public QComObject<IValueProvider>
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsUiaValueProvider)
|
||||
public:
|
||||
|
@ -11,8 +11,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWindowsUiaWindowProvider : public QWindowsUiaBaseProvider,
|
||||
public QWindowsComBase<IWindowProvider>
|
||||
class QWindowsUiaWindowProvider : public QWindowsUiaBaseProvider, public QComObject<IWindowProvider>
|
||||
{
|
||||
Q_DISABLE_COPY(QWindowsUiaWindowProvider)
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user