Windows QPA: Remove debug helper QWindowsMsaaAccessible::IIDToString()

The virtual function was used to output known IIDs by name for
debugging purposes. Add a debug operator for GUID and a wrapper
class with a special debug operator for the accessiblity IIDs.

Change-Id: I24787c6914f5cb0847782928fadb8ed4d3b808a1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
bb10
Friedemann Kleint 2017-02-16 14:59:07 +01:00
parent c25b13cee0
commit 5c3fede153
6 changed files with 94 additions and 53 deletions

View File

@ -1528,7 +1528,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryService(REFGUID guidServic
return E_POINTER;
Q_UNUSED(guidService);
*iface = 0;
qCDebug(lcQpaAccessibility) << "QWindowsIA2Accessible::QS(): " << IIDToString(riid);
qCDebug(lcQpaAccessibility) << "QWindowsIA2Accessible::QS(): " << QWindowsAccessibleGuid(riid);
if (guidService == IID_IAccessible) {
@ -1627,45 +1627,6 @@ HRESULT QWindowsIA2Accessible::wrapListOfCells(const QList<QAccessibleInterface*
return count > 0 ? S_OK : S_FALSE;
}
#define IF_EQUAL_RETURN_IIDSTRING(id, iid) if (id == iid) return QByteArray(#iid)
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);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IOleWindow);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IServiceProvider);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessible2);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleAction);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleApplication);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleComponent);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleEditableText);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleHyperlink);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleHypertext);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleImage);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleRelation);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleTable);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleTable2);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleTableCell);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleText);
IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleValue);
// else...
#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);
strGuid.reserve(40);
::WideCharToMultiByte(CP_UTF8, 0, szGuid, 39, strGuid.data(), 39, NULL, NULL);
strGuid[38] = '\0';
#endif
return strGuid;
}
// Q_STATIC_ASSERT(IA2_ROLE_CANVAS == QAccessible::Canvas); // ### Qt 6: make them the same
Q_STATIC_ASSERT(IA2_ROLE_COLOR_CHOOSER == static_cast<IA2Role>(QAccessible::ColorChooser));
Q_STATIC_ASSERT(IA2_ROLE_FOOTER == static_cast<IA2Role>(QAccessible::Footer));

View File

@ -250,7 +250,6 @@ private:
HRESULT getRelationsHelper(IAccessibleRelation **relations, int startIndex, long maxRelations, long *nRelations = 0);
HRESULT wrapListOfCells(const QList<QAccessibleInterface*> &inputCells, IUnknown ***outputAccessibles, long *nCellCount);
QByteArray IIDToString(REFIID id);
QString textForRange(int startOffset, int endOffset) const;
void replaceTextFallback(long startOffset, long endOffset, const QString &txt);

View File

@ -162,8 +162,8 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::QueryInterface(REFIID id, LPVO
|| qWindowsComQueryInterface<IOleWindow>(this, id, iface);
if (result) {
qCDebug(lcQpaAccessibility) << "QWindowsIA2Accessible::QI() - IID:"
<< IIDToString(id) << ", iface:" << accessibleInterface();
qCDebug(lcQpaAccessibility) << "QWindowsIA2Accessible::QI() - "
<< QWindowsAccessibleGuid(id) << ", iface:" << accessibleInterface();
}
return result ? S_OK : E_NOINTERFACE;
}
@ -1159,17 +1159,67 @@ 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)
const char *QWindowsAccessibleGuid::iidToString(const GUID &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();
const char *result = nullptr;
if (id == IID_IUnknown)
result = "IID_IUnknown";
else if (id == IID_IDispatch)
result = "IID_IDispatch";
else if (id == IID_IAccessible)
result = "IID_IAccessible";
else if (id == IID_IOleWindow)
result = "IID_IOleWindow";
else if (id == IID_IServiceProvider)
result = "IID_IServiceProvider";
#ifndef Q_CC_MINGW
else if (id == IID_IAccessible2)
result = "IID_IAccessible2";
else if (id == IID_IAccessibleAction)
result = "IID_IAccessibleAction";
else if (id == IID_IAccessibleApplication)
result = "IID_IAccessibleApplication";
else if (id == IID_IAccessibleComponent)
result = "IID_IAccessibleComponent";
else if (id == IID_IAccessibleEditableText)
result = "IID_IAccessibleEditableText";
else if (id == IID_IAccessibleHyperlink)
result = "IID_IAccessibleHyperlink";
else if (id == IID_IAccessibleHypertext)
result = "IID_IAccessibleHypertext";
else if (id == IID_IAccessibleImage)
result = "IID_IAccessibleImage";
else if (id == IID_IAccessibleRelation)
result = "IID_IAccessibleRelation";
else if (id == IID_IAccessibleTable)
result = "IID_IAccessibleTable";
else if (id == IID_IAccessibleTable2)
result = "IID_IAccessibleTable2";
else if (id == IID_IAccessibleTableCell)
result = "IID_IAccessibleTableCell";
else if (id == IID_IAccessibleText)
result = "IID_IAccessibleText";
else if (id == IID_IAccessibleValue)
result = "IID_IAccessibleValue";
#endif // !Q_CC_MINGW
return result;
}
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug, const GUID &);
QDebug operator<<(QDebug d, const QWindowsAccessibleGuid &aguid)
{
QDebugStateSaver saver(d);
d.nospace();
if (const char *ids = QWindowsAccessibleGuid::iidToString(aguid.guid()))
d << ids;
else
d << aguid.guid();
return d;
}
#endif // !QT_NO_DEBUG_STREAM
QT_END_NAMESPACE
#endif //QT_NO_ACCESSIBILITY

View File

@ -69,6 +69,21 @@ void accessibleDebugClientCalls_helper(const char* funcName, const QAccessibleIn
QWindow *window_helper(const QAccessibleInterface *iface);
class QWindowsAccessibleGuid // Helper for QDebug, outputs known ids by name.
{
public:
explicit QWindowsAccessibleGuid(const GUID &g) : m_guid(g) {}
GUID guid () const { return m_guid; }
static const char *iidToString(const GUID &id);
private:
GUID m_guid;
};
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const QWindowsAccessibleGuid &aguid);
#endif
/**************************************************************\
* QWindowsAccessible *
**************************************************************/
@ -133,8 +148,6 @@ public:
HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
protected:
virtual QByteArray IIDToString(REFIID id);
QAccessible::Id id;
QAccessibleInterface *accessibleInterface() const

View File

@ -220,6 +220,23 @@ QDebug operator<<(QDebug d, const WINDOWPLACEMENT &wp)
<< ", rcNormalPosition=" << wp.rcNormalPosition;
return d;
}
QDebug operator<<(QDebug d, const GUID &guid)
{
QDebugStateSaver saver(d);
d.nospace();
d << '{' << hex << uppercasedigits << qSetPadChar(QLatin1Char('0'))
<< qSetFieldWidth(8) << guid.Data1
<< qSetFieldWidth(0) << '-' << qSetFieldWidth(4)
<< guid.Data2 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4)
<< guid.Data3 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4)
<< qSetFieldWidth(2) << guid.Data4[0] << guid.Data4[1]
<< qSetFieldWidth(0) << '-' << qSetFieldWidth(2);
for (int i = 2; i < 8; ++i)
d << guid.Data4[i];
d << qSetFieldWidth(0) << '}';
return d;
}
#endif // !QT_NO_DEBUG_STREAM
// QTBUG-43872, for windows that do not have WS_EX_TOOLWINDOW set, WINDOWPLACEMENT

View File

@ -357,6 +357,7 @@ QDebug operator<<(QDebug d, const MINMAXINFO &i);
QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p);
QDebug operator<<(QDebug d, const WINDOWPLACEMENT &);
QDebug operator<<(QDebug d, const WINDOWPOS &);
QDebug operator<<(QDebug d, const GUID &guid);
#endif // !QT_NO_DEBUG_STREAM
// ---------- QWindowsGeometryHint inline functions.