diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-11 23:07:40 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-12 09:10:03 +0100 |
commit | 64541bfe53137af1a5532c334c4bb65bc0dc54bd (patch) | |
tree | 803e9c9b821c0d78c4e9da3d5359bd4b4448638e /svx | |
parent | 06e0aff60a7ac8b3a92253ff30dec55f71e437de (diff) |
can return a ref instead of a pointer, ensure dtor on singleton
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/tbunosearchcontrollers.hxx | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunosearchcontrollers.cxx | 33 |
2 files changed, 20 insertions, 17 deletions
diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx index 47d1897d4837..2bfa26547af1 100644 --- a/svx/inc/tbunosearchcontrollers.hxx +++ b/svx/inc/tbunosearchcontrollers.hxx @@ -80,7 +80,7 @@ public: SearchToolbarControllersManager(); ~SearchToolbarControllersManager(); - static SearchToolbarControllersManager* createControllersManager(); + static SearchToolbarControllersManager& createControllersManager(); void registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ); void freeController ( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ); @@ -88,8 +88,6 @@ public: private: - static SearchToolbarControllersManager* m_pInstance; - typedef ::comphelper::SequenceAsVector< css::beans::PropertyValue > SearchToolbarControllersVec; typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > SearchToolbarControllersMap; SearchToolbarControllersMap aSearchToolbarControllersMap; diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 02bc2a2dc2dd..07d2bc9f5824 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -42,6 +42,7 @@ #include <vcl/toolbox.hxx> #include <vcl/svapp.hxx> #include <osl/mutex.hxx> +#include <rtl/instance.hxx> namespace svx { @@ -208,8 +209,6 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) //----------------------------------------------------------------------------------------------------------- // SearchToolbarControllersManager -SearchToolbarControllersManager* SearchToolbarControllersManager::m_pInstance = 0; - SearchToolbarControllersManager::SearchToolbarControllersManager() { } @@ -218,12 +217,18 @@ SearchToolbarControllersManager::~SearchToolbarControllersManager() { } -SearchToolbarControllersManager* SearchToolbarControllersManager::createControllersManager() +namespace { - if (!m_pInstance) - m_pInstance = new SearchToolbarControllersManager(); + class theSearchToolbarControllersManager + : public rtl::Static<SearchToolbarControllersManager, + theSearchToolbarControllersManager> + { + }; +} - return m_pInstance; +SearchToolbarControllersManager& SearchToolbarControllersManager::createControllersManager() +{ + return theSearchToolbarControllersManager::get(); } void SearchToolbarControllersManager::registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ) @@ -359,7 +364,7 @@ void SAL_CALL FindTextToolbarController::dispose() throw ( css::uno::RuntimeExce { SolarMutexGuard aSolarMutexGuard; - SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); svt::ToolboxController::dispose(); delete m_pFindTextFieldControl; @@ -386,7 +391,7 @@ void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< : } } - SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); } // XToolbarController @@ -523,7 +528,7 @@ void SAL_CALL DownSearchToolboxController::dispose() throw ( css::uno::RuntimeEx { SolarMutexGuard aSolarMutexGuard; - SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); svt::ToolboxController::dispose(); } @@ -532,7 +537,7 @@ void SAL_CALL DownSearchToolboxController::dispose() throw ( css::uno::RuntimeEx void SAL_CALL DownSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) { svt::ToolboxController::initialize( aArguments ); - SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); } // XToolbarController @@ -572,7 +577,7 @@ void SAL_CALL DownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) css::frame::FeatureStateEvent aEvent; aEvent.FeatureURL.Complete = COMMAND_APPENDSEARCHHISTORY; - css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT); + css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager().findController(m_xFrame, COMMAND_FINDTEXT); if (xStatusListener.is()) xStatusListener->statusChanged( aEvent ); } @@ -654,7 +659,7 @@ void SAL_CALL UpSearchToolboxController::dispose() throw ( css::uno::RuntimeExce { SolarMutexGuard aSolarMutexGuard; - SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); svt::ToolboxController::dispose(); } @@ -663,7 +668,7 @@ void SAL_CALL UpSearchToolboxController::dispose() throw ( css::uno::RuntimeExce void SAL_CALL UpSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) { svt::ToolboxController::initialize( aArguments ); - SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); + SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); } // XToolbarController @@ -703,7 +708,7 @@ void SAL_CALL UpSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) th css::frame::FeatureStateEvent aEvent; aEvent.FeatureURL.Complete = COMMAND_APPENDSEARCHHISTORY; - css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT); + css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager().findController(m_xFrame, COMMAND_FINDTEXT); if (xStatusListener.is()) xStatusListener->statusChanged( aEvent ); } |