diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-05-16 11:19:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-05-16 12:04:10 +0100 |
commit | 8512e5c2b3617a2c8d77381788c3864db594ce46 (patch) | |
tree | c7fde308b180a2bce971fc80958d8bd28aa123d0 /sfx2 | |
parent | c7f60050da130eaeab11a53142a65b61c92c34a1 (diff) |
reduce static_initialization_and_destruction chain
Change-Id: I962aeac0c7feeabb7963016d5afcfeca5a48ccfe
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/workwin.cxx | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index 12f858e38bbf..5f6d001ad6e4 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -319,37 +319,45 @@ throw (css::uno::RuntimeException) } } -//==================================================================== - -typedef boost::unordered_map< sal_Int32, rtl::OUString > ToolBarResIdToResourceURLMap; - -static sal_Bool bMapInitialized = sal_False; -static ToolBarResIdToResourceURLMap aResIdToResourceURLMap; - -static rtl::OUString GetResourceURLFromResId( sal_uInt16 nResId ) +namespace { - if ( !bMapInitialized ) + class FilledToolBarResIdToResourceURLMap { - osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; - if ( !bMapInitialized ) + private: + typedef boost::unordered_map< sal_Int32, rtl::OUString > ToolBarResIdToResourceURLMap; + ToolBarResIdToResourceURLMap m_aResIdToResourceURLMap; + public: + FilledToolBarResIdToResourceURLMap() { sal_Int32 nIndex( 0 ); while ( pToolBarResToName[nIndex].nId != 0 ) { rtl::OUString aResourceURL( rtl::OUString::createFromAscii( pToolBarResToName[nIndex].pName )); - aResIdToResourceURLMap.insert( ToolBarResIdToResourceURLMap::value_type( + m_aResIdToResourceURLMap.insert( ToolBarResIdToResourceURLMap::value_type( sal_Int32( pToolBarResToName[nIndex].nId ), aResourceURL )); ++nIndex; } - bMapInitialized = sal_True; } - } - ToolBarResIdToResourceURLMap::const_iterator pIter = aResIdToResourceURLMap.find( nResId ); - if ( pIter != aResIdToResourceURLMap.end() ) - return pIter->second; - else - return rtl::OUString(); + rtl::OUString findURL(sal_uInt16 nResId) const + { + ToolBarResIdToResourceURLMap::const_iterator aIter = m_aResIdToResourceURLMap.find( nResId ); + if ( aIter != m_aResIdToResourceURLMap.end() ) + return aIter->second; + return rtl::OUString(); + } + }; + + class theFilledToolBarResIdToResourceURLMap + : public rtl::Static<FilledToolBarResIdToResourceURLMap, + theFilledToolBarResIdToResourceURLMap> + { + }; +} + +static rtl::OUString GetResourceURLFromResId( sal_uInt16 nResId ) +{ + return theFilledToolBarResIdToResourceURLMap::get().findURL(nResId); } sal_Bool IsAppWorkWinToolbox_Impl( sal_uInt16 nPos ) |