From 03fdec57762b287cb8e0b6b446f5e7ba1b187f88 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 19 Nov 2013 17:24:36 +0100 Subject: winaccessibility: use WeakImplHelper Change-Id: I5872e520ca009a0f9277827d72e72befe3323a06 --- winaccessibility/inc/AccEventListener.hxx | 15 ++++------ winaccessibility/inc/AccTopWindowListener.hxx | 13 +++------ .../source/service/AccEventListener.cxx | 33 ++-------------------- .../source/service/AccTopWindowListener.cxx | 30 ++------------------ 4 files changed, 15 insertions(+), 76 deletions(-) (limited to 'winaccessibility') diff --git a/winaccessibility/inc/AccEventListener.hxx b/winaccessibility/inc/AccEventListener.hxx index 5978dddddd43..263e525b9137 100644 --- a/winaccessibility/inc/AccEventListener.hxx +++ b/winaccessibility/inc/AccEventListener.hxx @@ -22,7 +22,9 @@ #include #include -#include + +#include + #include class AccObjectManagerAgent; @@ -32,12 +34,10 @@ using namespace ::com::sun::star::uno; * procedure of all the event handling and provides the basic support for some simple * methods. */ -class AccEventListener: - public com::sun::star::accessibility::XAccessibleEventListener, - public ::cppu::OWeakObject +class AccEventListener + : public ::cppu::WeakImplHelper1< + com::sun::star::accessibility::XAccessibleEventListener> { -private: - oslInterlockedCount m_refcount; protected: //accessible owner's pointer com::sun::star::accessibility::XAccessible* pAccessible; @@ -74,9 +74,6 @@ public: //for interface virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire() throw (); - virtual void SAL_CALL release() throw (); //get the accessible role of pAccessible virtual short SAL_CALL getRole(); //get the accessible parent's role diff --git a/winaccessibility/inc/AccTopWindowListener.hxx b/winaccessibility/inc/AccTopWindowListener.hxx index 11a6d18be15c..edf83b3b4148 100644 --- a/winaccessibility/inc/AccTopWindowListener.hxx +++ b/winaccessibility/inc/AccTopWindowListener.hxx @@ -23,7 +23,8 @@ #include #include #include -#include + +#include #include "AccObjectManagerAgent.hxx" @@ -34,14 +35,11 @@ * In this method, all the accessible objects (including COM object and Uno objects) are created and * cached into bridge managers, and they are monitored by listeners for later accessible evnet handling. */ -class AccTopWindowListener: - public com::sun::star::awt::XTopWindowListener, - public ::cppu::OWeakObject - +class AccTopWindowListener + : public ::cppu::WeakImplHelper1 { private: AccObjectManagerAgent accManagerAgent; - oslInterlockedCount m_refcount; public: AccTopWindowListener(); virtual ~AccTopWindowListener(); @@ -53,9 +51,6 @@ public: virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire( ) throw (); - virtual void SAL_CALL release( ) throw (); virtual void AddAllListeners(com::sun::star::accessibility::XAccessible* pAccessible,com::sun::star::accessibility::XAccessible* pParentXAcc,HWND pWND ); //for On-Demand load. virtual void handleWindowOpened( com::sun::star::accessibility::XAccessible* pAccessible ); diff --git a/winaccessibility/source/service/AccEventListener.cxx b/winaccessibility/source/service/AccEventListener.cxx index df2a42c7967e..de4d7b4da951 100644 --- a/winaccessibility/source/service/AccEventListener.cxx +++ b/winaccessibility/source/service/AccEventListener.cxx @@ -47,10 +47,9 @@ using namespace cppu; AccEventListener::AccEventListener(com::sun::star::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent) - :pAccessible(pAcc), - pAgent(Agent), - m_isDisposed(false), - m_refcount(0) + : pAccessible(pAcc) + , pAgent(Agent) + , m_isDisposed(false) {} AccEventListener::~AccEventListener() @@ -280,30 +279,4 @@ throw (::com::sun::star::uno::RuntimeException) removeMeFromBroadcaster(); } -//need to investigate further -::com::sun::star::uno::Any SAL_CALL AccEventListener::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException) -{ - if(aType.equals(::getCppuType( (Reference< com::sun::star::accessibility::XAccessibleEventListener> const *)0 ) )) - { - Reference< com::sun::star::accessibility::XAccessibleEventListener> xEventListener( static_cast< com::sun::star::accessibility::XAccessibleEventListener* >(this)); - return makeAny(xEventListener); - } - - return Any(); -} - -void AccEventListener::acquire( ) throw () -{ - ::osl_incrementInterlockedCount( &m_refcount ); -} - -void AccEventListener::release() throw () -{ - // thread-safe decrementation of reference count - if (0 == ::osl_decrementInterlockedCount( &m_refcount )) - { - delete this; // shutdown this object - } -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/source/service/AccTopWindowListener.cxx b/winaccessibility/source/service/AccTopWindowListener.cxx index 5c55cbd3b2a1..fac53d60362f 100644 --- a/winaccessibility/source/service/AccTopWindowListener.cxx +++ b/winaccessibility/source/service/AccTopWindowListener.cxx @@ -117,9 +117,8 @@ void AccTopWindowListener::handleWindowOpened( com::sun::star::accessibility::XA } } -AccTopWindowListener::AccTopWindowListener(): - accManagerAgent(), - m_refcount(1) +AccTopWindowListener::AccTopWindowListener() + : accManagerAgent() { } @@ -272,29 +271,4 @@ void AccTopWindowListener::disposing( const ::com::sun::star::lang::EventObject& { } -//need to investigate further -::com::sun::star::uno::Any SAL_CALL AccTopWindowListener::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException) -{ - if (aType.equals( ::getCppuType( (Reference< com::sun::star::awt::XTopWindowListener> const *)0 ) )) - { - Reference< com::sun::star::awt::XTopWindowListener> xTopListener( static_cast< com::sun::star::awt::XTopWindowListener* >(this)); - return makeAny(xTopListener); - } - return Any(); -} - -void AccTopWindowListener::acquire( ) throw () -{ - ::osl_incrementInterlockedCount( &m_refcount ); -} - -void AccTopWindowListener::release() throw () -{ - // thread-safe decrementation of reference count - if (0 == ::osl_decrementInterlockedCount( &m_refcount )) - { - delete this; // shutdown this object - } -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit