summaryrefslogtreecommitdiff
path: root/winaccessibility
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-11-26 19:37:50 +0100
committerMichael Stahl <mstahl@redhat.com>2013-11-28 00:59:50 +0100
commitef3f28d0ce641e9d51d91412b176a1ecbdc69773 (patch)
treef75e024c02daf971dad8d2f1523850c3b32b7505 /winaccessibility
parent576ba8ce8238f6a092c74750a895e2e77297fc7e (diff)
winaccessibility: use rtl::Reference for listener lifecycle
The manual acquire() call was apparently not coupled with a release()? Change-Id: I069c969619e9afce2a4b836642cc1675025b11d0
Diffstat (limited to 'winaccessibility')
-rw-r--r--winaccessibility/inc/AccObject.hxx6
-rw-r--r--winaccessibility/inc/AccObjectWinManager.hxx5
-rw-r--r--winaccessibility/source/service/AccObject.cxx12
-rw-r--r--winaccessibility/source/service/AccObjectWinManager.cxx68
4 files changed, 41 insertions, 50 deletions
diff --git a/winaccessibility/inc/AccObject.hxx b/winaccessibility/inc/AccObject.hxx
index 4f19c0fa8fd4..934b95db1297 100644
--- a/winaccessibility/inc/AccObject.hxx
+++ b/winaccessibility/inc/AccObject.hxx
@@ -25,6 +25,8 @@
#include <oleacc.h>
#include <windows.h>
+#include <rtl/ref.hxx>
+
#include <com/sun/star/accessibility/XAccessible.hpp>
#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
#include <com/sun/star/accessibility/XAccessibleAction.hpp>
@@ -51,7 +53,7 @@ private:
IMAccessible* m_pIMAcc;
AccObject* m_pParentObj;
IAccChildList m_childrenList;
- AccEventListener* m_accListener;
+ ::rtl::Reference<AccEventListener> m_pListener;
IAccSelectionList m_selectionList;
::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > m_xAccRef;
@@ -86,7 +88,7 @@ public:
void SetParentHWND(HWND hWnd);//need to set top window handle when send event to AT
HWND GetParentHWND();
- void SetListener( AccEventListener* Listener );
+ void SetListener(::rtl::Reference<AccEventListener> const& pListener);
AccEventListener* getListener();
void SetParentObj(AccObject* pParentAccObj);
diff --git a/winaccessibility/inc/AccObjectWinManager.hxx b/winaccessibility/inc/AccObjectWinManager.hxx
index ab05a212a8e0..afe4fe0adbc8 100644
--- a/winaccessibility/inc/AccObjectWinManager.hxx
+++ b/winaccessibility/inc/AccObjectWinManager.hxx
@@ -26,7 +26,7 @@
#include <map>
#include <windows.h>
#include <osl/mutex.hxx>
-#include <vcl/dllapi.h>
+#include <rtl/ref.hxx>
#include "ResIDGenerator.hxx"
#include "UAccCOM.h"
@@ -90,7 +90,8 @@ private:
void DeleteFromHwndXAcc(com::sun::star::accessibility::XAccessible* pXAcc );
int UpdateAccSelection(com::sun::star::accessibility::XAccessible* pXAcc);
- AccEventListener* createAccEventListener(com::sun::star::accessibility::XAccessible* pXAcc, AccObjectManagerAgent* Agent);
+ ::rtl::Reference<AccEventListener> CreateAccEventListener(
+ com::sun::star::accessibility::XAccessible* pXAcc);
public:
virtual ~AccObjectWinManager();
sal_Bool InsertAccObj( com::sun::star::accessibility::XAccessible* pXAcc,com::sun::star::accessibility::XAccessible* pParentXAcc,HWND pWnd);
diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx
index 026dcd9f1c4c..ac51a0527348 100644
--- a/winaccessibility/source/service/AccObject.cxx
+++ b/winaccessibility/source/service/AccObject.cxx
@@ -144,12 +144,12 @@ const short ROLE_TABLE[][2] =
* @return.
*/
AccObject::AccObject(XAccessible* pAcc, AccObjectManagerAgent* pAgent,
- AccEventListener* listener) :
+ AccEventListener* pListener) :
m_pIMAcc (NULL),
m_resID (NULL),
m_pParantID (NULL),
m_pParentObj(NULL),
- m_accListener (listener),
+ m_pListener (pListener),
m_bShouldDestroy(sal_False),
m_xAccRef( pAcc )
{
@@ -1161,13 +1161,15 @@ void AccObject::SetParentHWND(HWND hWnd)
{
m_pParantID = hWnd;
}
-void AccObject::SetListener( AccEventListener* Listener )
+
+void AccObject::SetListener(rtl::Reference<AccEventListener> const& pListener)
{
- m_accListener = Listener;
+ m_pListener = pListener;
}
+
AccEventListener* AccObject::getListener()
{
- return m_accListener;
+ return m_pListener.get();
}
long AccObject::GetResID()
diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx
index b17bc818914c..a058683c355d 100644
--- a/winaccessibility/source/service/AccObjectWinManager.cxx
+++ b/winaccessibility/source/service/AccObjectWinManager.cxx
@@ -776,24 +776,16 @@ sal_Bool AccObjectWinManager::InsertAccObj( XAccessible* pXAcc,XAccessible* pPar
}
//end of file name
- AccEventListener* listener = createAccEventListener(pXAcc, pAgent);
- if(listener==NULL)
+ ::rtl::Reference<AccEventListener> const pListener =
+ CreateAccEventListener(pXAcc);
+ if (!pListener.is())
return sal_False;
Reference<XAccessibleComponent> xComponent(pRContext,UNO_QUERY);
Reference<XAccessibleEventBroadcaster> broadcaster(xComponent,UNO_QUERY);
if (broadcaster.is())
{
- Reference <XAccessibleEventListener> pp (
- static_cast< XAccessibleEventListener* >(listener),UNO_QUERY );
- if(pp.is())
- {
- broadcaster->addAccessibleEventListener(pp);
- }
- else
- {
- delete listener;
- return sal_False;
- }
+ Reference<XAccessibleEventListener> const xListener(pListener.get());
+ broadcaster->addAccessibleEventListener(xListener);
}
else
return sal_False;
@@ -805,9 +797,7 @@ sal_Bool AccObjectWinManager::InsertAccObj( XAccessible* pXAcc,XAccessible* pPar
AccObject* pCurObj = GetAccObjByXAcc(pXAcc);
if( pCurObj )
{
- pCurObj->SetListener( listener );
- if(listener != NULL)
- listener->acquire();
+ pCurObj->SetListener(pListener);
}
AccObject* pParentObj = GetAccObjByXAcc(pParentXAcc);
@@ -830,32 +820,29 @@ void AccObjectWinManager::SaveTopWindowHandle(HWND hWnd, com::sun::star::accessi
}
-/**
- * create the corresponding listener.
- * @param pXAcc XAccessible interface.
- * @param Agent The agent kept in all listeners,it's the sole interface by which
- * listener communicate with windows manager.
- * @return
- */
-AccEventListener* AccObjectWinManager::createAccEventListener(XAccessible* pXAcc, AccObjectManagerAgent* /* Agent */ )
+/** Create the corresponding listener.
+ * @param pXAcc XAccessible interface.
+ */
+::rtl::Reference<AccEventListener>
+AccObjectWinManager::CreateAccEventListener(XAccessible* pXAcc)
{
- AccEventListener* listener = NULL;
+ ::rtl::Reference<AccEventListener> pRet;
Reference<XAccessibleContext> xContext(pXAcc->getAccessibleContext(),UNO_QUERY);
if(xContext.is())
{
switch( xContext->getAccessibleRole() )
{
case /*AccessibleRole::*/DIALOG:
- listener = new AccDialogEventListener(pXAcc,pAgent);
+ pRet = new AccDialogEventListener(pXAcc,pAgent);
break;
case /*AccessibleRole::*/FRAME:
- listener = new AccFrameEventListener(pXAcc,pAgent);
+ pRet = new AccFrameEventListener(pXAcc,pAgent);
break;
case /*AccessibleRole::*/WINDOW:
- listener = new AccWindowEventListener(pXAcc,pAgent);
+ pRet = new AccWindowEventListener(pXAcc,pAgent);
break;
case /*AccessibleRole::*/ROOT_PANE:
- listener = new AccFrameEventListener(pXAcc,pAgent);
+ pRet = new AccFrameEventListener(pXAcc,pAgent);
break;
//Container
case /*AccessibleRole::*/CANVAS:
@@ -879,11 +866,11 @@ AccEventListener* AccObjectWinManager::createAccEventListener(XAccessible* pXAcc
case /*AccessibleRole::*/TABLE_CELL:
case /*AccessibleRole::*/TOOL_BAR:
case /*AccessibleRole::*/VIEW_PORT:
- listener = new AccContainerEventListener(pXAcc,pAgent);
+ pRet = new AccContainerEventListener(pXAcc,pAgent);
break;
case /*AccessibleRole::*/PARAGRAPH:
case /*AccessibleRole::*/HEADING:
- listener = new AccParagraphEventListener(pXAcc,pAgent);
+ pRet = new AccParagraphEventListener(pXAcc,pAgent);
break;
//Component
case /*AccessibleRole::*/CHECK_BOX:
@@ -901,15 +888,15 @@ AccEventListener* AccObjectWinManager::createAccEventListener(XAccessible* pXAcc
case /*AccessibleRole::*/TOOL_TIP:
case /*AccessibleRole::*/SPIN_BOX:
case DATE_EDITOR:
- listener = new AccComponentEventListener(pXAcc,pAgent);
+ pRet = new AccComponentEventListener(pXAcc,pAgent);
break;
//text component
case /*AccessibleRole::*/TEXT:
- listener = new AccTextComponentEventListener(pXAcc,pAgent);
+ pRet = new AccTextComponentEventListener(pXAcc,pAgent);
break;
//menu
case /*AccessibleRole::*/MENU:
- listener = new AccMenuEventListener(pXAcc,pAgent);
+ pRet = new AccMenuEventListener(pXAcc,pAgent);
break;
//object container
case /*AccessibleRole::*/SHAPE:
@@ -917,27 +904,26 @@ AccEventListener* AccObjectWinManager::createAccEventListener(XAccessible* pXAcc
case /*AccessibleRole::*/EMBEDDED_OBJECT:
case /*AccessibleRole::*/GRAPHIC:
case /*AccessibleRole::*/TEXT_FRAME:
- listener = new AccObjectContainerEventListener(pXAcc,pAgent);
+ pRet = new AccObjectContainerEventListener(pXAcc,pAgent);
break;
//descendmanager
case /*AccessibleRole::*/LIST:
- listener = new AccListEventListener(pXAcc,pAgent);
+ pRet = new AccListEventListener(pXAcc,pAgent);
break;
case /*AccessibleRole::*/TREE:
- listener = new AccTreeEventListener(pXAcc,pAgent);
+ pRet = new AccTreeEventListener(pXAcc,pAgent);
break;
//special
case /*AccessibleRole::*/COLUMN_HEADER:
case /*AccessibleRole::*/TABLE:
- listener = new AccTableEventListener(pXAcc,pAgent);
+ pRet = new AccTableEventListener(pXAcc,pAgent);
break;
default:
- listener = new AccContainerEventListener(pXAcc,pAgent);
+ pRet = new AccContainerEventListener(pXAcc,pAgent);
break;
}
}
-
- return listener;
+ return pRet;
}
/**