From 8d1aeb01ea025f6644401c3a9e01cb36a8ae367c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 1 Jun 2011 11:39:41 +0100 Subject: overly static --- framework/source/layoutmanager/layoutmanager.cxx | 40 +++++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'framework/source/layoutmanager/layoutmanager.cxx') diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 847766c2a662..a7bc56cbd954 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -90,6 +90,7 @@ #include #include #include +#include #include #include @@ -3212,24 +3213,39 @@ void SAL_CALL LayoutManager::getFastPropertyValue( uno::Any& aValue, sal_Int32 n LayoutManager_PBase::getFastPropertyValue( aValue, nHandle ); } -::cppu::IPropertyArrayHelper& SAL_CALL LayoutManager::getInfoHelper() +namespace detail { - static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL; - - if( pInfoHelper == NULL ) + class InfoHelperBuilder : private ::boost::noncopyable { - osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; - - if( pInfoHelper == NULL ) + private: + ::cppu::OPropertyArrayHelper *m_pInfoHelper; + public: + InfoHelperBuilder(const LayoutManager &rManager) { uno::Sequence< beans::Property > aProperties; - describeProperties( aProperties ); - static ::cppu::OPropertyArrayHelper aInfoHelper( aProperties, sal_True ); - pInfoHelper = &aInfoHelper; + rManager.describeProperties(aProperties); + m_pInfoHelper = new ::cppu::OPropertyArrayHelper(aProperties, sal_True); + } + ~InfoHelperBuilder() + { + delete m_pInfoHelper; } - } - return(*pInfoHelper); + ::cppu::OPropertyArrayHelper& getHelper() { return *m_pInfoHelper; } + }; +} +namespace +{ + struct theInfoHelper : + public rtl::StaticWithArg< detail::InfoHelperBuilder, LayoutManager, + theInfoHelper > + { + }; +} + +::cppu::IPropertyArrayHelper& SAL_CALL LayoutManager::getInfoHelper() +{ + return theInfoHelper::get(*this).getHelper(); } uno::Reference< beans::XPropertySetInfo > SAL_CALL LayoutManager::getPropertySetInfo() throw (uno::RuntimeException) -- cgit