Enable IAccessible for MinGW32, keep IAccessible2 disabled for MinGW

No surprise, the files generated by midl contains code that only
the MS compiler will understand.
However, since the generated files are only needed for IA2, we
can still compile the old IAccessible/MSAA implementation for mingw
(like it was before the introduction of IA2)

I used mingw 4.6.1 to test this.

Change-Id: Iad581f2fee087bd7b796ac5a01548f2fcacbd595
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
bb10
Jan-Arve Saether 2012-03-23 11:11:53 +01:00 committed by Qt by Nokia
parent 015bc43da0
commit 5e9089135b
6 changed files with 154 additions and 93 deletions

View File

@ -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++
}

View File

@ -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));
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;
}
}
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;
}
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 *
@ -1430,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);
@ -1451,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);

View File

@ -66,9 +66,7 @@
#include "AccessibleRole.h"
#include "AccessibleStates.h"
#ifdef Q_CC_MINGW
# include <servprov.h>
#endif
#include <servprov.h>
QT_BEGIN_NAMESPACE
@ -268,9 +266,6 @@ private:
uint uniqueID() const;
QByteArray IIDToString(REFIID id);
private:
ULONG ref;
};
/**************************************************************\

View File

@ -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;

View File

@ -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

View File

@ -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