Minor cleanup of the header file.

Move inline implementations to iaccessible2.cpp.
Makes it easier to read and navigate the source code.

Change-Id: I8da44ba0d40395356f612ff6b3ce2a808105838a
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
Jan-Arve Saether 2012-04-11 07:58:20 +02:00 committed by Qt by Nokia
parent bfcfbc592c
commit 6fc44c5926
2 changed files with 78 additions and 70 deletions

View File

@ -114,6 +114,68 @@ HRESULT STDMETHODCALLTYPE AccessibleApplication::get_toolkitVersion(/* [retval][
} }
/**************************************************************\
* AccessibleRelation *
**************************************************************/
AccessibleRelation::AccessibleRelation(const QList<QAccessibleInterface *> &targets,
QAccessible::Relation relation)
: m_targets(targets), m_relation(relation), m_ref(1)
{
Q_ASSERT(m_targets.count());
}
/* IUnknown */
HRESULT STDMETHODCALLTYPE AccessibleRelation::QueryInterface(REFIID id, LPVOID *iface)
{
*iface = 0;
if (id == IID_IUnknown)
*iface = (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)
{
*relationType = relationToBSTR(m_relation);
return S_OK;
}
HRESULT STDMETHODCALLTYPE AccessibleRelation::get_localizedRelationType(
/* [retval][out] */ BSTR *localizedRelationType)
{
// Who ever needs this???
*localizedRelationType = relationToBSTR(m_relation);
return S_OK;
}
HRESULT STDMETHODCALLTYPE AccessibleRelation::get_nTargets(
/* [retval][out] */ long *nTargets)
{
// ### always one target
*nTargets = m_targets.count();
return S_OK;
}
/*! /*!
\internal \internal
@ -140,7 +202,7 @@ HRESULT STDMETHODCALLTYPE AccessibleRelation::get_target(
(see "Special Consideration when using Arrays", in Accessible2.idl) (see "Special Consideration when using Arrays", in Accessible2.idl)
*/ */
HRESULT STDMETHODCALLTYPE AccessibleRelation::get_targets( HRESULT STDMETHODCALLTYPE AccessibleRelation::get_targets(
/* [in] */ long maxTargets, // Hmmm, ignore ??? /* [in] */ long maxTargets,
/* [length_is][size_is][out] */ IUnknown **targets, /* [length_is][size_is][out] */ IUnknown **targets,
/* [retval][out] */ long *nTargets) /* [retval][out] */ long *nTargets)
{ {
@ -215,6 +277,10 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryInterface(REFIID id, LPVOI
return hr; return hr;
} }
/* Note that IUnknown is inherited from several interfaces. Therefore we must reimplement all its
functions in the concrete class to avoid ambiguity.
*/
ULONG STDMETHODCALLTYPE QWindowsIA2Accessible::AddRef() ULONG STDMETHODCALLTYPE QWindowsIA2Accessible::AddRef()
{ {
return QWindowsMsaaAccessible::AddRef(); return QWindowsMsaaAccessible::AddRef();

View File

@ -298,85 +298,27 @@ private:
/**************************************************************\ /**************************************************************\
* IAccessibleRelation * * AccessibleRelation *
**************************************************************/ **************************************************************/
struct AccessibleRelation : public IAccessibleRelation class AccessibleRelation : public IAccessibleRelation
{ {
public:
AccessibleRelation(const QList<QAccessibleInterface *> &targets, AccessibleRelation(const QList<QAccessibleInterface *> &targets,
QAccessible::Relation relation) QAccessible::Relation relation);
: m_targets(targets), m_relation(relation), m_ref(1)
{
Q_ASSERT(m_targets.count());
}
virtual ~AccessibleRelation() {} virtual ~AccessibleRelation() {}
/* IUnknown */ /* IUnknown */
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface) HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface);
{ ULONG STDMETHODCALLTYPE AddRef();
*iface = 0; ULONG STDMETHODCALLTYPE Release();
if (id == IID_IUnknown)
*iface = (IUnknown*)this;
if (*iface) {
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef()
{
return ++m_ref;
}
ULONG STDMETHODCALLTYPE Release()
{
if (!--m_ref) {
delete this;
return 0;
}
return m_ref;
}
/* IAccessibleRelation */ /* IAccessibleRelation */
HRESULT STDMETHODCALLTYPE get_relationType( HRESULT STDMETHODCALLTYPE get_relationType(BSTR *relationType);
/* [retval][out] */ BSTR *relationType) HRESULT STDMETHODCALLTYPE get_localizedRelationType(BSTR *localizedRelationType);
{ HRESULT STDMETHODCALLTYPE get_nTargets(long *nTargets);
*relationType = relationToBSTR(m_relation);
return S_OK;
}
HRESULT STDMETHODCALLTYPE get_localizedRelationType(
/* [retval][out] */ BSTR *localizedRelationType)
{
// Who ever needs this???
*localizedRelationType = relationToBSTR(m_relation);
return S_OK;
}
HRESULT STDMETHODCALLTYPE get_nTargets(
/* [retval][out] */ long *nTargets)
{
// ### always one target
*nTargets = m_targets.count();
return S_OK;
}
HRESULT STDMETHODCALLTYPE get_target(long targetIndex, IUnknown **target); HRESULT STDMETHODCALLTYPE get_target(long targetIndex, IUnknown **target);
HRESULT STDMETHODCALLTYPE get_targets(long maxTargets, IUnknown **targets, long *nTargets);
/*!
\internal
Client allocates and deallocates \a targets array
(see "Special Consideration when using Arrays", in Accessible2.idl)
*/
HRESULT STDMETHODCALLTYPE get_targets(
/* [in] */ long maxTargets, // Hmmm, ignore ???
/* [length_is][size_is][out] */ IUnknown **targets,
/* [retval][out] */ long *nTargets);
private: private:
static BSTR relationToBSTR(QAccessible::Relation relation) static BSTR relationToBSTR(QAccessible::Relation relation)