From 97e0597854a7ffd1d55f8f5c31db709b6533b3e3 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 21 Jan 2011 12:50:42 +0000 Subject: use a weakchangeslistener instead --- framework/inc/helper/mischelper.hxx | 39 +++++++++++++++++++++++++++++++++ framework/inc/services/pathsettings.hxx | 11 ++-------- 2 files changed, 41 insertions(+), 9 deletions(-) (limited to 'framework/inc') diff --git a/framework/inc/helper/mischelper.hxx b/framework/inc/helper/mischelper.hxx index 957164437cab..6d98e53b557f 100644 --- a/framework/inc/helper/mischelper.hxx +++ b/framework/inc/helper/mischelper.hxx @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -190,6 +191,44 @@ class WeakContainerListener : public ::cppu::WeakImplHelper1 +{ + private: + com::sun::star::uno::WeakReference mxOwner; + + public: + WeakChangesListener(com::sun::star::uno::Reference xOwner) + : mxOwner(xOwner) + { + } + + virtual ~WeakChangesListener() + { + } + + // util.XChangesListener + virtual void SAL_CALL changesOccurred(const com::sun::star::util::ChangesEvent& rEvent) + throw(com::sun::star::uno::RuntimeException) + { + com::sun::star::uno::Reference xOwner(mxOwner.get(), + com::sun::star::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->changesOccurred(rEvent); + } + + // lang.XEventListener + virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject& rEvent) + throw(com::sun::star::uno::RuntimeException) + { + com::sun::star::uno::Reference xOwner(mxOwner.get(), + com::sun::star::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + + } // namespace framework #endif // __MISC_HELPER_HXX_ diff --git a/framework/inc/services/pathsettings.hxx b/framework/inc/services/pathsettings.hxx index 35bf79783dec..8e7d1de958d3 100644 --- a/framework/inc/services/pathsettings.hxx +++ b/framework/inc/services/pathsettings.hxx @@ -47,7 +47,6 @@ //_________________________________________________________________________________________________________________ #include #include -#include #include #include #include @@ -71,7 +70,6 @@ namespace framework class PathSettings : public css::lang::XTypeProvider , public css::lang::XServiceInfo , - public css::lang::XComponent , public css::util::XChangesListener , // => XEventListener // base classes // Order is neccessary for right initialization! @@ -161,8 +159,8 @@ class PathSettings : public css::lang::XTypeProvider , /** provides access to the new configuration schema. */ css::uno::Reference< css::container::XNameAccess > m_xCfgNew; - /** container for ALL Listeners. */ - ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; + /** helper to listen for configuration changes without ownership cycle problems */ + css::uno::Reference< css::util::XChangesListener > m_xCfgNewListener; ::cppu::OPropertyArrayHelper* m_pPropHelp; @@ -187,11 +185,6 @@ class PathSettings : public css::lang::XTypeProvider , FWK_DECLARE_XTYPEPROVIDER DECLARE_XSERVICEINFO - // css:lang::XComponent - void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException ); - void SAL_CALL addEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); - void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); - // css::util::XChangesListener virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& aEvent) throw (css::uno::RuntimeException); -- cgit v1.2.3