Kaydet (Commit) c70fd83a authored tarafından Michael Stahl's avatar Michael Stahl

winaccessibility: clean up global TopLevelWindowListener

Apparently the life-cycle of this global variable is tied to the
MSAAService anyway, so just make it a member of that.
Also it appears that the FreeTopListener function would call release()
but at the place where the global variable is assigned acquire() was
missing.  Using a rtl::Reference should fix this up too.

Change-Id: I6dd305dfd990d7fd4c54b16d971700b88470dc43
üst 07d4ae39
......@@ -20,12 +20,8 @@
#ifndef __G_MSACC_HXX
#define __G_MSACC_HXX
extern void FreeTopWindowListener();
extern void handleWindowOpened_impl(sal_Int64 pAcc);
extern sal_Int64 GetMSComPtr(sal_Int64 hWnd, sal_Int64 lParam, sal_Int64 wParam);
extern AccTopWindowListener* g_pTop;
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -44,29 +44,6 @@ using namespace com::sun::star::awt;
using namespace rtl;
using namespace cppu;
AccTopWindowListener* g_pTop = NULL;
//when proccess exit, call FreeTopWindowListener() in svmain
void FreeTopWindowListener()
{
if( g_pTop )
{
g_pTop->release();
g_pTop = NULL;
}
}
/**
* As a global method to invoke the handleWindowOpened() method
*/
void handleWindowOpened_impl(sal_Int64 pAcc)
{
if( g_pTop && pAcc != 0 )
g_pTop->HandleWindowOpened(
static_cast<com::sun::star::accessibility::XAccessible*>(
reinterpret_cast<void*>(pAcc)));
}
/**
* For the new opened window, generate all the UNO accessible's object, COM object and add
* accessible listener to monitor all these objects.
......
......@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <rtl/ref.hxx>
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
......@@ -35,7 +36,6 @@
#include <windows.h>
#include <postwin.h>
using namespace ::rtl; // for OUString
using namespace ::com::sun::star; // for odk interfaces
using namespace ::com::sun::star::uno; // for basic types
using namespace ::com::sun::star::accessibility;
......@@ -64,12 +64,13 @@ class MSAAServiceImpl : public ::cppu::WeakImplHelper4<
XMSAAService, lang::XServiceInfo,
lang::XInitialization, lang::XComponent >
{
private:
rtl::Reference<AccTopWindowListener> m_pTopWindowListener;
OUString m_arg;
public:
// focus on four interfaces,
// no need to implement XInterface, XTypeProvider, XWeak etc.
MSAAServiceImpl ();
virtual ~MSAAServiceImpl( void );
virtual ~MSAAServiceImpl();
// XInitialization will be called upon createInstanceWithArguments[AndContext]()
virtual void SAL_CALL initialize( Sequence< Any > const & args ) throw (Exception);
......@@ -133,7 +134,13 @@ void MSAAServiceImpl::handleWindowOpened(sal_Int64 nAcc)
SolarMutexGuard g;
SAL_INFO( "iacc2", "Window opened " << nAcc );
handleWindowOpened_impl( nAcc );
if (m_pTopWindowListener.is() && nAcc)
{
m_pTopWindowListener->HandleWindowOpened(
static_cast<com::sun::star::accessibility::XAccessible*>(
reinterpret_cast<void*>(nAcc)));
}
}
OUString MSAAServiceImpl::getImplementationName() throw (RuntimeException)
......@@ -221,7 +228,8 @@ static void AccessBridgeHandleExistingWindow(const Reference< XMSAAService > &xA
assert( xAccMgr.is() );
if ( xAccessible.is() )
{
xAccMgr->handleWindowOpened( (long)xAccessible.get() );
xAccMgr->handleWindowOpened(
reinterpret_cast<sal_Int64>(xAccessible.get()));
SAL_INFO( "iacc2", "Decide whether to register existing window with IAccessible2" );
}
}
......@@ -300,8 +308,8 @@ MSAAServiceImpl::MSAAServiceImpl()
if( xToolkit.is() )
{
g_pTop = new AccTopWindowListener();
Reference< XTopWindowListener> xRef( g_pTop );
m_pTopWindowListener.set(new AccTopWindowListener());
Reference<XTopWindowListener> const xRef(m_pTopWindowListener.get());
xToolkit->addTopWindowListener( xRef );
SAL_INFO( "iacc2", "successfully connected to the toolkit event hose" );
}
......@@ -323,7 +331,7 @@ void MSAAServiceImpl::dispose()
// and substreams which in turn release theirs, etc. When xRootFolder is
// released when this destructor completes, the folder tree should be
// deleted fully (and automagically).
FreeTopWindowListener();
m_pTopWindowListener.clear();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment