diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-03-27 16:19:29 +0200 |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2012-03-27 19:22:48 +0200 |
commit | d236fe2214340164bec4f34cb27dea4a634ee0de (patch) | |
tree | cda4ebbcc91717b37e5a2dbccb9ee46c2a1d3885 /src/plugins/platforms/windows | |
parent | 2b17b0235b70f89d15d3b91a14c3297d38377f94 (diff) | |
parent | cbc883da6910b3357a4e03d0e2dfa841da1a03e8 (diff) |
Merge master into api_changes
Conflicts:
src/corelib/global/qisenum.h
src/dbus/qdbusconnection_p.h
src/widgets/kernel/qwidget.cpp
tests/auto/other/qaccessibility/tst_qaccessibility.cpp
Change-Id: I85102515d5fec835832cc20ffdc5c1ba578bd01d
Diffstat (limited to 'src/plugins/platforms/windows')
6 files changed, 193 insertions, 97 deletions
diff --git a/src/plugins/platforms/windows/accessible/accessible.pri b/src/plugins/platforms/windows/accessible/accessible.pri index 1671c67d17..3069c2dda3 100644 --- a/src/plugins/platforms/windows/accessible/accessible.pri +++ b/src/plugins/platforms/windows/accessible/accessible.pri @@ -1,19 +1,16 @@ SOURCES += \ - $$PWD/qwindowsaccessibility.cpp + $$PWD/qwindowsmsaaaccessible.cpp \ + $$PWD/qwindowsaccessibility.cpp \ + $$PWD/comutils.cpp HEADERS += \ - $$PWD/qwindowsaccessibility.h - -!*g++* { - SOURCES += \ - $$PWD/qwindowsmsaaaccessible.cpp \ - $$PWD/iaccessible2.cpp \ - $$PWD/comutils.cpp - - HEADERS += \ - $$PWD/qwindowsmsaaaccessible.h \ - $$PWD/iaccessible2.h \ - $$PWD/comutils.h + $$PWD/qwindowsmsaaaccessible.h \ + $$PWD/qwindowsaccessibility.h \ + $$PWD/comutils.h +!*g++: { + SOURCES += $$PWD/iaccessible2.cpp + HEADERS += $$PWD/iaccessible2.h include(../../../../3rdparty/iaccessible2/iaccessible2.pri) -} # !g++ +} + diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index f22349714f..c3d5c543cf 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -167,81 +167,62 @@ HRESULT STDMETHODCALLTYPE AccessibleRelation::get_targets( **************************************************************/ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryInterface(REFIID id, LPVOID *iface) { - *iface = 0; - - QByteArray strIID = IIDToString(id); - if (!strIID.isEmpty()) { - QString ss; QDebug dbg(&ss); dbg << accessible; - accessibleDebug("QWindowsIA2Accessible::QI() - IID:%s, iface:%s ", strIID.constData(), qPrintable(ss)); - } - if (id == IID_IUnknown) { - *iface = (IUnknown*)(IDispatch*)this; - } else if (id == IID_IDispatch) { - *iface = (IDispatch*)this; - } else if (id == IID_IAccessible) { - *iface = (IAccessible*)this; - } else if (id == IID_IOleWindow) { - *iface = (IOleWindow*)this; - } else if (id == IID_IServiceProvider) { - *iface = (IServiceProvider*)this; - } else if (id == IID_IAccessible2) { - *iface = (IAccessible2*)this; - } else if (id == IID_IAccessibleAction) { - if (accessible->actionInterface()) - *iface = (IAccessibleAction*)this; - } else if (id == IID_IAccessibleComponent) { - *iface = (IAccessibleComponent*)this; - } else if (id == IID_IAccessibleEditableText) { - //if (accessible->editableTextInterface()) { - //*iface = (IAccessibleEditableText*)this; - //} - } else if (id == IID_IAccessibleHyperlink) { - //*iface = (IAccessibleHyperlink*)this; - } else if (id == IID_IAccessibleHypertext) { - //*iface = (IAccessibleHypertext*)this; - } else if (id == IID_IAccessibleImage) { - //*iface = (IAccessibleImage*)this; - } else if (id == IID_IAccessibleRelation) { - *iface = (IAccessibleRelation*)this; - } else if (id == IID_IAccessibleTable) { - //*iface = (IAccessibleTable*)this; // not supported - } else if (id == IID_IAccessibleTable2) { - if (accessible->tableInterface()) - *iface = (IAccessibleTable2*)this; - } else if (id == IID_IAccessibleTableCell) { - if (accessible->tableCellInterface()) - *iface = (IAccessibleTableCell*)this; - } else if (id == IID_IAccessibleText) { - if (accessible->textInterface()) - *iface = (IAccessibleText*)this; - } else if (id == IID_IAccessibleValue) { - if (accessible->valueInterface()) - *iface = (IAccessibleValue*)this; - } - if (*iface) { - AddRef(); - return S_OK; + HRESULT hr = QWindowsMsaaAccessible::QueryInterface(id, iface); + if (!SUCCEEDED(hr)) { + if (id == IID_IAccessible2) { + *iface = (IAccessible2*)this; + } else if (id == IID_IAccessibleAction) { + if (accessible->actionInterface()) + *iface = (IAccessibleAction*)this; + } else if (id == IID_IAccessibleComponent) { + *iface = (IAccessibleComponent*)this; + } else if (id == IID_IAccessibleEditableText) { + //if (accessible->editableTextInterface()) { + //*iface = (IAccessibleEditableText*)this; + //} + } else if (id == IID_IAccessibleHyperlink) { + //*iface = (IAccessibleHyperlink*)this; + } else if (id == IID_IAccessibleHypertext) { + //*iface = (IAccessibleHypertext*)this; + } else if (id == IID_IAccessibleImage) { + //*iface = (IAccessibleImage*)this; + } else if (id == IID_IAccessibleRelation) { + *iface = (IAccessibleRelation*)this; + } else if (id == IID_IAccessibleTable) { + //*iface = (IAccessibleTable*)this; // not supported + } else if (id == IID_IAccessibleTable2) { + if (accessible->tableInterface()) + *iface = (IAccessibleTable2*)this; + } else if (id == IID_IAccessibleTableCell) { + if (accessible->tableCellInterface()) + *iface = (IAccessibleTableCell*)this; + } else if (id == IID_IAccessibleText) { + if (accessible->textInterface()) + *iface = (IAccessibleText*)this; + } else if (id == IID_IAccessibleValue) { + if (accessible->valueInterface()) + *iface = (IAccessibleValue*)this; + } + if (*iface) { + AddRef(); + hr = S_OK; + } else { + hr = E_NOINTERFACE; + } } - - return E_NOINTERFACE; + return hr; } ULONG STDMETHODCALLTYPE QWindowsIA2Accessible::AddRef() { - return ++ref; + return QWindowsMsaaAccessible::AddRef(); } ULONG STDMETHODCALLTYPE QWindowsIA2Accessible::Release() { - if (!--ref) { - delete this; - return 0; - } - return ref; + return QWindowsMsaaAccessible::Release(); } - - /**************************************************************\ * * * IAccessible2 * @@ -1028,6 +1009,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_caretOffset(long *offset) return E_FAIL; } + HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_characterExtents(long offset, enum IA2CoordinateType coordType, long *x, @@ -1037,9 +1019,8 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_characterExtents(long offse { accessibleDebugClientCalls(accessible); if (QAccessibleTextInterface *text = textInterface()) { - const QRect rect = text->characterRect(offset, (QAccessible2::CoordinateType)coordType); - *x = rect.x(); - *y = rect.y(); + QRect rect = text->characterRect(offset); + mapFromScreenPos(coordType, rect.topLeft(), x, y); *width = rect.width(); *height = rect.height(); return S_OK; @@ -1064,7 +1045,8 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_offsetAtPoint(long x, { accessibleDebugClientCalls(accessible); if (QAccessibleTextInterface *text = textInterface()) { - *offset = text->offsetAtPoint(QPoint(x,y), (QAccessible2::CoordinateType)coordType); + QPoint screenPos = mapToScreenPos(coordType, x, y); + *offset = text->offsetAtPoint(screenPos); return (*offset >=0 ? S_OK : S_FALSE); } return E_FAIL; @@ -1429,6 +1411,10 @@ uint QWindowsIA2Accessible::uniqueID() const QByteArray QWindowsIA2Accessible::IIDToString(REFIID id) { + QByteArray strGuid = QWindowsMsaaAccessible::IIDToString(id); + if (!strGuid.isEmpty()) + return strGuid; + IF_EQUAL_RETURN_IIDSTRING(id, IID_IUnknown); IF_EQUAL_RETURN_IIDSTRING(id, IID_IDispatch); IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessible); @@ -1450,7 +1436,6 @@ QByteArray QWindowsIA2Accessible::IIDToString(REFIID id) IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleValue); // else... - QByteArray strGuid; #if 0 // Can be useful for debugging, but normally we'd like to reduce the noise a bit... OLECHAR szGuid[39]={0}; ::StringFromGUID2(id, szGuid, 39); diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.h b/src/plugins/platforms/windows/accessible/iaccessible2.h index a59263fba1..9b8a1ad3a6 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.h +++ b/src/plugins/platforms/windows/accessible/iaccessible2.h @@ -66,9 +66,7 @@ #include "AccessibleRole.h" #include "AccessibleStates.h" -#ifdef Q_CC_MINGW -# include <servprov.h> -#endif +#include <servprov.h> QT_BEGIN_NAMESPACE @@ -229,14 +227,45 @@ private: return accessible->tableCellInterface(); } + /*! + \internal + \a screenPos is in screen relative position + \a x and \y (out) is in parent relative position if coordType == IA2_COORDTYPE_PARENT_RELATIVE + */ + void mapFromScreenPos(enum IA2CoordinateType coordType, const QPoint &screenPos, long *x, long *y) const { + if (coordType == IA2_COORDTYPE_PARENT_RELATIVE) { + // caller wants relative to parent + if (QAccessibleInterface *parent = accessible->parent()) { + const QRect parentScreenRect = parent->rect(); + *x = parentScreenRect.x() - screenPos.x(); + *y = parentScreenRect.y() - screenPos.y(); + return; + } + } + *x = screenPos.x(); + *y = screenPos.y(); + } + + /*! + \internal + \a x and \y is in parent relative position if coordType == IA2_COORDTYPE_PARENT_RELATIVE + \return a screen relative position + */ + QPoint mapToScreenPos(enum IA2CoordinateType coordType, long x, long y) const { + if (coordType == IA2_COORDTYPE_PARENT_RELATIVE) { + if (QAccessibleInterface *parent = accessible->parent()) { + const QRect parentScreenRect = parent->rect(); + return QPoint(parentScreenRect.x() + x, parentScreenRect.y() + y); + } + } + return QPoint(x,y); + } + HRESULT getRelationsHelper(IAccessibleRelation **relations, int startIndex, long maxRelations, long *nRelations = 0); HRESULT wrapListOfCells(const QList<QAccessibleInterface*> &inputCells, IUnknown ***outputAccessibles, long *nCellCount); uint uniqueID() const; QByteArray IIDToString(REFIID id); -private: - ULONG ref; - }; /**************************************************************\ diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index 4f92b910b2..bd928399c8 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -56,11 +56,11 @@ #include <QtGui/qguiapplication.h> #include "qwindowsaccessibility.h" - -#ifndef Q_CC_MINGW -# include "iaccessible2.h" -#endif // !Q_CC_MINGW - +#ifdef Q_CC_MINGW +# include "qwindowsmsaaaccessible.h" +#else +# include "iaccessible2.h" +#endif #include "comutils.h" #include <oleacc.h> @@ -237,7 +237,11 @@ IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc) #else if (!acc) return 0; +#ifdef Q_CC_MINGW + QWindowsMsaaAccessible *wacc = new QWindowsMsaaAccessible(acc); +#else QWindowsIA2Accessible *wacc = new QWindowsIA2Accessible(acc); +#endif IAccessible *iacc = 0; wacc->QueryInterface(IID_IAccessible, (void**)&iacc); return iacc; diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 8791bbdcfb..6c4d217cb4 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -224,6 +224,53 @@ void accessibleDebugClientCalls_helper(const char* funcName, const QAccessibleIn } #endif +/**************************************************************\ + * * + * IUnknown * + * * + **************************************************************/ +HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::QueryInterface(REFIID id, LPVOID *iface) +{ + *iface = 0; + + QByteArray strIID = IIDToString(id); + if (!strIID.isEmpty()) { + QString ss; QDebug dbg(&ss); dbg << accessible; + accessibleDebug("QWindowsIA2Accessible::QI() - IID:%s, iface:%s ", strIID.constData(), qPrintable(ss)); + } + if (id == IID_IUnknown) { + *iface = (IUnknown*)(IDispatch*)this; + } else if (id == IID_IDispatch) { + *iface = (IDispatch*)this; + } else if (id == IID_IAccessible) { + *iface = (IAccessible*)this; + } else if (id == IID_IOleWindow) { + *iface = (IOleWindow*)this; + } + + if (*iface) { + AddRef(); + return S_OK; + } + + return E_NOINTERFACE; +} + +ULONG STDMETHODCALLTYPE QWindowsMsaaAccessible::AddRef() +{ + return ++ref; +} + +ULONG STDMETHODCALLTYPE QWindowsMsaaAccessible::Release() +{ + if (!--ref) { + delete this; + return 0; + } + return ref; +} + + /* IDispatch */ @@ -1208,6 +1255,17 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::ContextSensitiveHelp(BOOL) return S_OK; } +#define IF_EQUAL_RETURN_IIDSTRING(id, iid) if (id == iid) return QByteArray(#iid) +QByteArray QWindowsMsaaAccessible::IIDToString(REFIID id) +{ + IF_EQUAL_RETURN_IIDSTRING(id, IID_IUnknown); + IF_EQUAL_RETURN_IIDSTRING(id, IID_IDispatch); + IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessible); + IF_EQUAL_RETURN_IIDSTRING(id, IID_IOleWindow); + + return QByteArray(); +} + QT_END_NAMESPACE #endif //QT_NO_ACCESSIBILITY diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h index 9cb56c954c..d7dda6b3e2 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h @@ -43,12 +43,19 @@ #include <QtCore/QtConfig> #ifndef QT_NO_ACCESSIBILITY +#include <QtCore/qglobal.h> #include "../qtwindows_additional.h" -#include <oleacc.h> -#include "Accessible2.h" #include <QtCore/qsharedpointer.h> #include <QtGui/qaccessible.h> +#ifndef Q_CC_MINGW +# include <oleacc.h> +# include "Accessible2.h" // IAccessible2 inherits from IAccessible +#else + // MinGW +# include <basetyps.h> +# include <oleacc.h> +#endif QT_BEGIN_NAMESPACE @@ -74,7 +81,13 @@ QWindow *window_helper(const QAccessibleInterface *iface); /**************************************************************\ * QWindowsAccessible * **************************************************************/ -class QWindowsMsaaAccessible : public IAccessible2, public IOleWindow +class QWindowsMsaaAccessible : public +#ifdef Q_CC_MINGW + IAccessible +#else + IAccessible2 +#endif + , public IOleWindow { public: QWindowsMsaaAccessible(QAccessibleInterface *a) @@ -87,6 +100,10 @@ public: delete accessible; } + /* IUnknown */ + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID *); + ULONG STDMETHODCALLTYPE AddRef(); + ULONG STDMETHODCALLTYPE Release(); /* IDispatch */ HRESULT STDMETHODCALLTYPE GetTypeInfoCount(unsigned int *); @@ -124,12 +141,18 @@ public: HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode); protected: + virtual QByteArray IIDToString(REFIID id); + QAccessibleInterface *accessible; QAIPointer childPointer(VARIANT varID) { return QAIPointer(accessible->child(varID.lVal - 1)); } + +private: + ULONG ref; + }; QT_END_NAMESPACE |