diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-01-21 12:50:42 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-01-21 14:21:35 +0000 |
commit | 97e0597854a7ffd1d55f8f5c31db709b6533b3e3 (patch) | |
tree | 5c9b9f75abd95fa63cb76ac7af8e49d20688440c /framework/inc | |
parent | ef276ff33dff253c1ebdc5aec38329c959dffdc9 (diff) |
use a weakchangeslistener instead
Diffstat (limited to 'framework/inc')
-rw-r--r-- | framework/inc/helper/mischelper.hxx | 39 | ||||
-rw-r--r-- | framework/inc/services/pathsettings.hxx | 11 |
2 files changed, 41 insertions, 9 deletions
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 <com/sun/star/linguistic2/XLanguageGuessing.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/util/XChangesListener.hpp> #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/frame/XFrame.hpp> @@ -190,6 +191,44 @@ class WeakContainerListener : public ::cppu::WeakImplHelper1<com::sun::star::con } }; +class WeakChangesListener : public ::cppu::WeakImplHelper1<com::sun::star::util::XChangesListener> +{ + private: + com::sun::star::uno::WeakReference<com::sun::star::util::XChangesListener> mxOwner; + + public: + WeakChangesListener(com::sun::star::uno::Reference<com::sun::star::util::XChangesListener> 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<com::sun::star::util::XChangesListener> 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<com::sun::star::util::XChangesListener> 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 <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> -#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/util/XStringSubstitution.hpp> #include <com/sun/star/util/XChangesListener.hpp> #include <com/sun/star/container/XNameAccess.hpp> @@ -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); |