avmedia/source/gstreamer/gstplayer.cxx | 14 +- basic/source/runtime/methods.cxx | 10 + canvas/source/directx/dx_devicehelper.cxx | 15 -- desktop/source/deployment/misc/dp_misc.cxx | 24 ++- desktop/source/deployment/misc/dp_platform.cxx | 39 +++--- extensions/source/config/ldap/ldapuserprofilebe.cxx | 2 framework/source/accelerators/presethandler.cxx | 26 ++-- oox/source/drawingml/color.cxx | 12 + sal/osl/all/debugbase.cxx | 12 + scripting/source/provider/ActiveMSPList.cxx | 6 slideshow/source/engine/opengl/TransitionerImpl.cxx | 11 - starmath/source/smdll.cxx | 4 svl/source/config/ctloptions.cxx | 10 + svtools/source/misc/langtab.cxx | 18 +- sw/source/uibase/app/swdll.cxx | 10 + unotools/source/config/compatibility.cxx | 8 - unotools/source/config/fltrcfg.cxx | 11 - vcl/qa/cppunit/canvasbitmaptest.cxx | 13 -- xmloff/source/style/prstylei.cxx | 128 ++++++++++---------- 19 files changed, 183 insertions(+), 190 deletions(-)
New commits: commit e7dbef922a2fc73469f12c520bcc1af54fe038fb Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Mar 23 11:11:48 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Mar 23 19:49:25 2023 +0000 rtl::Static to thread-safe-static Change-Id: Ife02e6d2be3ebfbb08522ab0183ef4aa31a99e19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149415 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index b841c576be17..0bd3485efd9a 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -245,13 +245,15 @@ IMPL_STATIC_LINK(MissingPluginInstaller, launchUi, void *, p, void) } -struct TheMissingPluginInstaller: - public rtl::Static<MissingPluginInstaller, TheMissingPluginInstaller> -{}; +MissingPluginInstaller& TheMissingPluginInstaller() +{ + static MissingPluginInstaller theInstaller; + return theInstaller; +} void MissingPluginInstallerThread::execute() { - MissingPluginInstaller & inst = TheMissingPluginInstaller::get(); + MissingPluginInstaller & inst = TheMissingPluginInstaller(); for (;;) { std::vector<OString> details; { @@ -330,7 +332,7 @@ Player::~Player() void SAL_CALL Player::disposing() { - TheMissingPluginInstaller::get().detach(this); + TheMissingPluginInstaller().detach(this); ::osl::MutexGuard aGuard(m_aMutex); @@ -532,7 +534,7 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message ) maSizeCondition.set(); } } else if (gst_is_missing_plugin_message(message)) { - TheMissingPluginInstaller::get().report(this, message); + TheMissingPluginInstaller().report(this, message); if( mnWidth == 0 ) { // an error occurred, set condition so that OOo thread doesn't wait for us maSizeCondition.set(); diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 2835a4915392..986860c935a3 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -3431,7 +3431,11 @@ struct RandomNumberGenerator } }; -class theRandomNumberGenerator : public rtl::Static<RandomNumberGenerator, theRandomNumberGenerator> {}; +RandomNumberGenerator& theRandomNumberGenerator() +{ + static RandomNumberGenerator theGenerator; + return theGenerator; +} } @@ -3444,7 +3448,7 @@ void SbRtl_Randomize(StarBASIC *, SbxArray & rPar, bool) if (rPar.Count() == 2) { int nSeed = static_cast<int>(rPar.Get(1)->GetInteger()); - theRandomNumberGenerator::get().global_rng.seed(nSeed); + theRandomNumberGenerator().global_rng.seed(nSeed); } // without parameter, no need to do anything - RNG is seeded at first use } @@ -3458,7 +3462,7 @@ void SbRtl_Rnd(StarBASIC *, SbxArray & rPar, bool) else { std::uniform_real_distribution<double> dist(0.0, 1.0); - double const tmp(dist(theRandomNumberGenerator::get().global_rng)); + double const tmp(dist(theRandomNumberGenerator().global_rng)); rPar.Get(0)->PutDouble(tmp); } } diff --git a/canvas/source/directx/dx_devicehelper.cxx b/canvas/source/directx/dx_devicehelper.cxx index 8d984c766b5a..dada6238e0eb 100644 --- a/canvas/source/directx/dx_devicehelper.cxx +++ b/canvas/source/directx/dx_devicehelper.cxx @@ -188,22 +188,11 @@ namespace dxcanvas return uno::Any(); } - namespace - { - struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>, - DeviceColorSpace> - { - uno::Reference<rendering::XColorSpace> operator()() - { - return vcl::unotools::createStandardColorSpace(); - } - }; - } - uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const { // always the same - return DeviceColorSpace::get(); + static uno::Reference<rendering::XColorSpace> theSpace = vcl::unotools::createStandardColorSpace(); + return theSpace; } } diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index ed394382bb5c..15e31b0fe402 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -62,15 +62,17 @@ using namespace ::com::sun::star::uno; namespace dp_misc { namespace { -struct UnoRc : public rtl::StaticWithInit< - std::shared_ptr<rtl::Bootstrap>, UnoRc> { - std::shared_ptr<rtl::Bootstrap> operator () () { - OUString unorc( "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("louno") ); - ::rtl::Bootstrap::expandMacros( unorc ); - auto ret = std::make_shared<::rtl::Bootstrap>( unorc ); - OSL_ASSERT( ret->getHandle() != nullptr ); - return ret; - } +std::shared_ptr<rtl::Bootstrap> & UnoRc() +{ + static std::shared_ptr<rtl::Bootstrap> theRc = []() + { + OUString unorc( "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("louno") ); + ::rtl::Bootstrap::expandMacros( unorc ); + auto ret = std::make_shared<::rtl::Bootstrap>( unorc ); + OSL_ASSERT( ret->getHandle() != nullptr ); + return ret; + }(); + return theRc; }; OUString generateOfficePipeId() @@ -293,7 +295,7 @@ OUString makeURLAppendSysPathSegment( std::u16string_view baseURL, OUString cons OUString expandUnoRcTerm( OUString const & term_ ) { OUString term(term_); - UnoRc::get()->expandMacrosFrom( term ); + UnoRc()->expandMacrosFrom( term ); return term; } @@ -318,7 +320,7 @@ OUString expandUnoRcUrl( OUString const & url ) rcurl = ::rtl::Uri::decode( rcurl, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); // expand macro string: - UnoRc::get()->expandMacrosFrom( rcurl ); + UnoRc()->expandMacrosFrom( rcurl ); return rcurl; } else { diff --git a/desktop/source/deployment/misc/dp_platform.cxx b/desktop/source/deployment/misc/dp_platform.cxx index d42cfe436b90..ad1b5ea13fed 100644 --- a/desktop/source/deployment/misc/dp_platform.cxx +++ b/desktop/source/deployment/misc/dp_platform.cxx @@ -32,36 +32,39 @@ namespace dp_misc { namespace { - struct StrOperatingSystem : - public rtl::StaticWithInit<OUString, StrOperatingSystem> { - OUString operator () () { + const OUString & StrOperatingSystem() + { + static const OUString theOS = []() + { OUString os( "$_OS" ); ::rtl::Bootstrap::expandMacros( os ); return os; - } + }(); + return theOS; }; - struct StrCPU : - public rtl::StaticWithInit<OUString, StrCPU> { - OUString operator () () { + const OUString & StrCPU() + { + static const OUString theCPU = []() + { OUString arch( "$_ARCH" ); ::rtl::Bootstrap::expandMacros( arch ); return arch; - } + }(); + return theCPU; }; - struct StrPlatform : public rtl::StaticWithInit< - OUString, StrPlatform> { - OUString operator () () { - return StrOperatingSystem::get() + "_" + StrCPU::get(); - } + const OUString & StrPlatform() + { + static const OUString thePlatform = StrOperatingSystem() + "_" + StrCPU(); + return thePlatform; }; bool checkOSandCPU(std::u16string_view os, std::u16string_view cpu) { - return (os == StrOperatingSystem::get()) - && (cpu == StrCPU::get()); + return (os == StrOperatingSystem()) + && (cpu == StrCPU()); } bool isPlatformSupported( std::u16string_view token ) @@ -161,7 +164,7 @@ namespace OUString const & getPlatformString() { - return StrPlatform::get(); + return StrPlatform(); } bool platform_fits( std::u16string_view platform_string ) @@ -172,9 +175,9 @@ bool platform_fits( std::u16string_view platform_string ) const std::u16string_view token( o3tl::trim(o3tl::getToken(platform_string, 0, ',', index )) ); // check if this platform: - if (o3tl::equalsIgnoreAsciiCase( token, StrPlatform::get() ) || + if (o3tl::equalsIgnoreAsciiCase( token, StrPlatform() ) || (token.find( '_' ) == std::u16string_view::npos && /* check OS part only */ - o3tl::equalsIgnoreAsciiCase( token, StrOperatingSystem::get() ))) + o3tl::equalsIgnoreAsciiCase( token, StrOperatingSystem() ))) { return true; } diff --git a/extensions/source/config/ldap/ldapuserprofilebe.cxx b/extensions/source/config/ldap/ldapuserprofilebe.cxx index add328205425..a735b5fbd71a 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.cxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.cxx @@ -46,7 +46,7 @@ LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContex // the configuration for the backend would create another instance of the // backend, which would try and read the configuration which would... { - osl::Mutex & aInitMutex = rtl::Static< osl::Mutex, LdapUserProfileBe >::get(); + static osl::Mutex aInitMutex; osl::MutexGuard aInitGuard(aInitMutex); static bool bReentrantCall; // = false diff --git a/framework/source/accelerators/presethandler.cxx b/framework/source/accelerators/presethandler.cxx index 7bd487684555..0572049ab785 100644 --- a/framework/source/accelerators/presethandler.cxx +++ b/framework/source/accelerators/presethandler.cxx @@ -65,7 +65,11 @@ struct TSharedStorages final a) shared root storages b) shared "inbetween" storages of the share and user layer. */ -struct SharedStorages: public rtl::Static<TSharedStorages, SharedStorages> {}; +TSharedStorages& SharedStorages() +{ + static TSharedStorages theStorages; + return theStorages; +} } @@ -103,7 +107,7 @@ PresetHandler::~PresetHandler() Otherwise we will disconnect all other open configuration access objects which base on these storages. */ - auto & sharedStorages = SharedStorages::get(); + auto & sharedStorages = SharedStorages(); sharedStorages.m_lStoragesShare.closePath(m_sRelPathShare); sharedStorages.m_lStoragesUser.closePath (m_sRelPathUser ); @@ -169,7 +173,7 @@ void lcl_throwCorruptedUIConfigurationException( css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageShare() { - auto & sharedStorages = SharedStorages::get(); + auto & sharedStorages = SharedStorages(); css::uno::Reference< css::embed::XStorage > xRoot = sharedStorages.m_lStoragesShare.getRootStorage(); if (xRoot.is()) return xRoot; @@ -228,7 +232,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageUser() { - auto & sharedStorages = SharedStorages::get(); + auto & sharedStorages = SharedStorages(); css::uno::Reference< css::embed::XStorage > xRoot = sharedStorages.m_lStoragesUser.getRootStorage(); if (xRoot.is()) return xRoot; @@ -287,7 +291,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageShare xWorking = m_xWorkingStorageShare; } - return SharedStorages::get().m_lStoragesShare.getParentStorage(xWorking); + return SharedStorages().m_lStoragesShare.getParentStorage(xWorking); } css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageUser() @@ -298,7 +302,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageUser( xWorking = m_xWorkingStorageUser; } - return SharedStorages::get().m_lStoragesUser.getParentStorage(xWorking); + return SharedStorages().m_lStoragesUser.getParentStorage(xWorking); } void PresetHandler::connectToResource( PresetHandler::EConfigType eConfigType , @@ -538,7 +542,7 @@ void PresetHandler::commitUserChanges() case E_GLOBAL : case E_MODULES : { - auto & sharedStorages = SharedStorages::get(); + auto & sharedStorages = SharedStorages(); sPath = sharedStorages.m_lStoragesUser.getPathOfStorage(xWorking); sharedStorages.m_lStoragesUser.commitPath(sPath); sharedStorages.m_lStoragesUser.notifyPath(sPath); @@ -573,7 +577,7 @@ void PresetHandler::addStorageListener(XMLBasedAcceleratorConfiguration* pListen case E_GLOBAL : case E_MODULES : { - SharedStorages::get().m_lStoragesUser.addStorageListener(pListener, sRelPath); + SharedStorages().m_lStoragesUser.addStorageListener(pListener, sRelPath); } break; @@ -603,7 +607,7 @@ void PresetHandler::removeStorageListener(XMLBasedAcceleratorConfiguration* pLis case E_GLOBAL : case E_MODULES : { - SharedStorages::get().m_lStoragesUser.removeStorageListener(pListener, sRelPath); + SharedStorages().m_lStoragesUser.removeStorageListener(pListener, sRelPath); } break; @@ -623,9 +627,9 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring try { if (bShare) - xPath = SharedStorages::get().m_lStoragesShare.openPath(sPath, eMode); + xPath = SharedStorages().m_lStoragesShare.openPath(sPath, eMode); else - xPath = SharedStorages::get().m_lStoragesUser.openPath(sPath, eMode); + xPath = SharedStorages().m_lStoragesUser.openPath(sPath, eMode); } catch(const css::uno::RuntimeException&) { throw; } diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index 592d0734efc2..805ca6c4faed 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -159,7 +159,11 @@ PresetColorsPool::PresetColorsPool() : maHighlightColors[static_cast<size_t>(nEntry.first)] = nEntry.second; } -struct StaticPresetColorsPool : public ::rtl::Static< PresetColorsPool, StaticPresetColorsPool > {}; +PresetColorsPool& StaticPresetColorsPool() +{ + static PresetColorsPool thePool; + return thePool; +} const double DEC_GAMMA = 2.3; const double INC_GAMMA = 1.0 / DEC_GAMMA; @@ -264,7 +268,7 @@ Color::Color() : /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be able to catch the existing vector entries without corresponding XML token identifier. */ - ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool::get().maDmlColors, nToken, API_RGB_TRANSPARENT ); + ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool().maDmlColors, nToken, API_RGB_TRANSPARENT ); return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb; } @@ -273,7 +277,7 @@ Color::Color() : /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be able to catch the existing vector entries without corresponding XML token identifier. */ - ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool::get().maVmlColors, nToken, API_RGB_TRANSPARENT ); + ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool().maVmlColors, nToken, API_RGB_TRANSPARENT ); return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb; } @@ -282,7 +286,7 @@ Color::Color() : /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be able to catch the existing vector entries without corresponding XML token identifier. */ - ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool::get().maHighlightColors, nToken, API_RGB_TRANSPARENT ); + ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool().maHighlightColors, nToken, API_RGB_TRANSPARENT ); return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb; } diff --git a/sal/osl/all/debugbase.cxx b/sal/osl/all/debugbase.cxx index 59848a883c9d..b4b598589a00 100644 --- a/sal/osl/all/debugbase.cxx +++ b/sal/osl/all/debugbase.cxx @@ -30,9 +30,10 @@ namespace { -struct StaticDebugBaseAddressFilter - : rtl::StaticWithInit<std::vector<OString>, StaticDebugBaseAddressFilter> { - std::vector<OString> operator()() const { +const std::vector<OString>& StaticDebugBaseAddressFilter() +{ + static const std::vector<OString> theFilter = []() + { std::vector<OString> vec; rtl_uString * pStr = nullptr; OUString const name( @@ -49,7 +50,8 @@ struct StaticDebugBaseAddressFilter while (nIndex >= 0); } return vec; - } + }(); + return theFilter; }; bool isSubStr( char const* pStr, OString const& subStr ) @@ -81,7 +83,7 @@ osl::Mutex & SAL_CALL osl_detail_ObjectRegistry_getMutex() bool SAL_CALL osl_detail_ObjectRegistry_storeAddresses( char const* pName ) SAL_THROW_EXTERN_C() { - std::vector<OString> const& rVec = StaticDebugBaseAddressFilter::get(); + std::vector<OString> const& rVec = StaticDebugBaseAddressFilter(); if (rVec.empty()) return false; // check for "all": diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx index 4333f78ae3e1..fbd2b2b05331 100644 --- a/scripting/source/provider/ActiveMSPList.cxx +++ b/scripting/source/provider/ActiveMSPList.cxx @@ -67,12 +67,10 @@ public: namespace { - //thread-safe double-locked class to ensure createNonDocMSPs is called once - class theNonDocMSPCreator : public rtl::StaticWithArg<NonDocMSPCreator, ActiveMSPList*, theNonDocMSPCreator> {}; - + //thread-safe method to ensure createNonDocMSPs is called once void ensureNonDocMSPs(ActiveMSPList *pList) { - theNonDocMSPCreator::get(pList); + static NonDocMSPCreator theCreator(pList); } } diff --git a/slideshow/source/engine/opengl/TransitionerImpl.cxx b/slideshow/source/engine/opengl/TransitionerImpl.cxx index 4aab29426013..224d8cdcd808 100644 --- a/slideshow/source/engine/opengl/TransitionerImpl.cxx +++ b/slideshow/source/engine/opengl/TransitionerImpl.cxx @@ -788,18 +788,11 @@ public: } }; -struct OGLColorSpaceHolder : public rtl::StaticWithInit<uno::Reference<rendering::XIntegerBitmapColorSpace>, OGLColorSpaceHolder> -{ - uno::Reference<rendering::XIntegerBitmapColorSpace> operator()() - { - return new OGLColorSpace(); - } -}; - uno::Reference<rendering::XIntegerBitmapColorSpace> const & getOGLColorSpace() { - return OGLColorSpaceHolder::get(); + static uno::Reference<rendering::XIntegerBitmapColorSpace> theSpace = new OGLColorSpace(); + return theSpace; } void buildMipmaps( diff --git a/starmath/source/smdll.cxx b/starmath/source/smdll.cxx index d2fa938d711d..8c9e88bda4c6 100644 --- a/starmath/source/smdll.cxx +++ b/starmath/source/smdll.cxx @@ -72,15 +72,13 @@ namespace SmCmdBoxWrapper::RegisterChildWindow(true); } - - struct theSmDLLInstance : public rtl::Static<SmDLL, theSmDLLInstance> {}; } namespace SmGlobals { void ensure() { - theSmDLLInstance::get(); + static SmDLL theDll; } } diff --git a/svl/source/config/ctloptions.cxx b/svl/source/config/ctloptions.cxx index 38544f758a3a..288761bd9394 100644 --- a/svl/source/config/ctloptions.cxx +++ b/svl/source/config/ctloptions.cxx @@ -338,13 +338,17 @@ namespace { // global std::weak_ptr<SvtCTLOptions_Impl> g_pCTLOptions; - struct CTLMutex : public rtl::Static< osl::Mutex, CTLMutex > {}; + osl::Mutex& CTLMutex() + { + static osl::Mutex aMutex; + return aMutex; + } } SvtCTLOptions::SvtCTLOptions( bool bDontLoad ) { // Global access, must be guarded (multithreading) - ::osl::MutexGuard aGuard( CTLMutex::get() ); + ::osl::MutexGuard aGuard( CTLMutex() ); m_pImpl = g_pCTLOptions.lock(); if ( !m_pImpl ) @@ -364,7 +368,7 @@ SvtCTLOptions::SvtCTLOptions( bool bDontLoad ) SvtCTLOptions::~SvtCTLOptions() { // Global access, must be guarded (multithreading) - ::osl::MutexGuard aGuard( CTLMutex::get() ); + ::osl::MutexGuard aGuard( CTLMutex() ); m_pImpl->RemoveListener(this); m_pImpl.reset(); diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx index 0f5f15257856..a3ed27a3bdf2 100644 --- a/svtools/source/misc/langtab.cxx +++ b/svtools/source/misc/langtab.cxx @@ -84,7 +84,11 @@ public: void AddEntry( const OUString& rString, const LanguageType eType); }; -struct theLanguageTable : public rtl::Static< SvtLanguageTableImpl, theLanguageTable > {}; +SvtLanguageTableImpl& theLanguageTable() +{ + static SvtLanguageTableImpl aTable; + return aTable; +} } OUString ApplyLreOrRleEmbedding( const OUString &rText ) @@ -224,7 +228,7 @@ bool SvtLanguageTableImpl::HasType( const LanguageType eType ) const bool SvtLanguageTable::HasLanguageType( const LanguageType eType ) { - return theLanguageTable::get().HasType( eType ); + return theLanguageTable().HasType( eType ); } OUString SvtLanguageTableImpl::GetString( const LanguageType eType ) const @@ -251,7 +255,7 @@ OUString SvtLanguageTableImpl::GetString( const LanguageType eType ) const OUString SvtLanguageTable::GetLanguageString( const LanguageType eType ) { - return theLanguageTable::get().GetString( eType ); + return theLanguageTable().GetString( eType ); } LanguageType SvtLanguageTableImpl::GetType( std::u16string_view rStr ) const @@ -272,7 +276,7 @@ LanguageType SvtLanguageTableImpl::GetType( std::u16string_view rStr ) const LanguageType SvtLanguageTable::GetLanguageType( std::u16string_view rStr ) { - return theLanguageTable::get().GetType( rStr ); + return theLanguageTable().GetType( rStr ); } sal_uInt32 SvtLanguageTableImpl::GetEntryCount() const @@ -282,7 +286,7 @@ sal_uInt32 SvtLanguageTableImpl::GetEntryCount() const sal_uInt32 SvtLanguageTable::GetLanguageEntryCount() { - return theLanguageTable::get().GetEntryCount(); + return theLanguageTable().GetEntryCount(); } @@ -296,7 +300,7 @@ LanguageType SvtLanguageTableImpl::GetTypeAtIndex( sal_uInt32 nIndex ) const LanguageType SvtLanguageTable::GetLanguageTypeAtIndex( sal_uInt32 nIndex ) { - return theLanguageTable::get().GetTypeAtIndex( nIndex); + return theLanguageTable().GetTypeAtIndex( nIndex); } void SvtLanguageTableImpl::AddEntry( const OUString& rString, const LanguageType eType ) @@ -337,7 +341,7 @@ void SvtLanguageTableImpl::AddEntry( const OUString& rString, const LanguageType void SvtLanguageTable::AddLanguageTag( const LanguageTag& rLanguageTag ) { - theLanguageTable::get().AddEntry( lcl_getDescription(rLanguageTag), rLanguageTag.getLanguageType()); + theLanguageTable().AddEntry( lcl_getDescription(rLanguageTag), rLanguageTag.getLanguageType()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/app/swdll.cxx b/sw/source/uibase/app/swdll.cxx index ad9a3bf3c487..c4564a4741f3 100644 --- a/sw/source/uibase/app/swdll.cxx +++ b/sw/source/uibase/app/swdll.cxx @@ -59,7 +59,11 @@ namespace } }; - struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {}; + SwDLLInstance& theSwDLLInstance() + { + static SwDLLInstance aInstance; + return aInstance; + } } namespace SwGlobals @@ -67,12 +71,12 @@ namespace SwGlobals void ensure() { // coverity[side_effect_free : FALSE] - not actually side-effect-free - theSwDLLInstance::get(); + theSwDLLInstance(); } sw::Filters & getFilters() { - return theSwDLLInstance::get()->getFilters(); + return theSwDLLInstance()->getFilters(); } } diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx index 400666ff34bc..52b0b2e30cbd 100644 --- a/unotools/source/config/compatibility.cxx +++ b/unotools/source/config/compatibility.cxx @@ -343,14 +343,10 @@ std::vector< SvtCompatibilityEntry > SvtCompatibilityOptions::GetList() const return m_pImpl->GetOptions(); } -namespace -{ - class theCompatibilityOptionsMutex : public rtl::Static<osl::Mutex, theCompatibilityOptionsMutex>{}; -} - Mutex& SvtCompatibilityOptions::GetOwnStaticMutex() { - return theCompatibilityOptionsMutex::get(); + static osl::Mutex aMutex; + return aMutex; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx index 323cfe0c38ed..21a540e40409 100644 --- a/unotools/source/config/fltrcfg.cxx +++ b/unotools/source/config/fltrcfg.cxx @@ -613,17 +613,10 @@ void SvtFilterOptions::SetVisio2Draw(bool bFlag) SetModified(); } -namespace -{ - class theFilterOptions - : public rtl::Static<SvtFilterOptions, theFilterOptions> - { - }; -} - SvtFilterOptions& SvtFilterOptions::Get() { - return theFilterOptions::get(); + static SvtFilterOptions aOptions; + return aOptions; } bool SvtFilterOptions::IsEnablePPTPreview() const diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx index d45cd20dff04..27ac06d0d9de 100644 --- a/vcl/qa/cppunit/canvasbitmaptest.cxx +++ b/vcl/qa/cppunit/canvasbitmaptest.cxx @@ -385,20 +385,13 @@ private: return false; } - struct PaletteColorSpaceHolder: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>, - PaletteColorSpaceHolder> - { - uno::Reference<rendering::XColorSpace> operator()() - { - return vcl::unotools::createStandardColorSpace(); - } - }; - virtual uno::Reference< rendering::XColorSpace > SAL_CALL getColorSpace( ) override { // this is the method from XBitmapPalette. Return palette color // space here - return PaletteColorSpaceHolder::get(); + static uno::Reference<rendering::XColorSpace> aColorSpace = + vcl::unotools::createStandardColorSpace(); + return aColorSpace; } // XIntegerBitmapColorSpace diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index a0277bf8a752..3dc8fc7087a3 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -70,73 +70,73 @@ void XMLPropStyleContext::SetAttribute( sal_Int32 nElement, namespace { - struct theStandardSet : - public rtl::StaticWithInit<OldFillStyleDefinitionSet, theStandardSet> + const OldFillStyleDefinitionSet & theStandardSet() { - OldFillStyleDefinitionSet operator () () - { - OldFillStyleDefinitionSet aSet; - aSet.insert("BackColorRGB"); - aSet.insert("BackTransparent"); - aSet.insert("BackColorTransparency"); - aSet.insert("BackGraphic"); - aSet.insert("BackGraphicFilter"); - aSet.insert("BackGraphicLocation"); - aSet.insert("BackGraphicTransparency"); - return aSet; - } + static const OldFillStyleDefinitionSet theSet = []() + { + OldFillStyleDefinitionSet aSet; + aSet.insert("BackColorRGB"); + aSet.insert("BackTransparent"); + aSet.insert("BackColorTransparency"); + aSet.insert("BackGraphic"); + aSet.insert("BackGraphicFilter"); + aSet.insert("BackGraphicLocation"); + aSet.insert("BackGraphicTransparency"); + return aSet; + }(); + return theSet; }; - struct theHeaderSet : - public rtl::StaticWithInit<OldFillStyleDefinitionSet, theHeaderSet> + const OldFillStyleDefinitionSet & theHeaderSet() { - OldFillStyleDefinitionSet operator () () - { - OldFillStyleDefinitionSet aSet; - aSet.insert("HeaderBackColorRGB"); - aSet.insert("HeaderBackTransparent"); - aSet.insert("HeaderBackColorTransparency"); - aSet.insert("HeaderBackGraphic"); - aSet.insert("HeaderBackGraphicFilter"); - aSet.insert("HeaderBackGraphicLocation"); - aSet.insert("HeaderBackGraphicTransparency"); - return aSet; - } + static const OldFillStyleDefinitionSet theSet = []() + { + OldFillStyleDefinitionSet aSet; + aSet.insert("HeaderBackColorRGB"); + aSet.insert("HeaderBackTransparent"); + aSet.insert("HeaderBackColorTransparency"); + aSet.insert("HeaderBackGraphic"); + aSet.insert("HeaderBackGraphicFilter"); + aSet.insert("HeaderBackGraphicLocation"); + aSet.insert("HeaderBackGraphicTransparency"); + return aSet; + }(); + return theSet; }; - struct theFooterSet : - public rtl::StaticWithInit<OldFillStyleDefinitionSet, theFooterSet> + const OldFillStyleDefinitionSet & theFooterSet() { - OldFillStyleDefinitionSet operator () () - { - OldFillStyleDefinitionSet aSet; - aSet.insert("FooterBackColorRGB"); - aSet.insert("FooterBackTransparent"); - aSet.insert("FooterBackColorTransparency"); - aSet.insert("FooterBackGraphic"); - aSet.insert("FooterBackGraphicFilter"); - aSet.insert("FooterBackGraphicLocation"); - aSet.insert("FooterBackGraphicTransparency"); - return aSet; - } + static const OldFillStyleDefinitionSet theSet = []() + { + OldFillStyleDefinitionSet aSet; + aSet.insert("FooterBackColorRGB"); + aSet.insert("FooterBackTransparent"); + aSet.insert("FooterBackColorTransparency"); + aSet.insert("FooterBackGraphic"); + aSet.insert("FooterBackGraphicFilter"); + aSet.insert("FooterBackGraphicLocation"); + aSet.insert("FooterBackGraphicTransparency"); + return aSet; + }(); + return theSet; }; - struct theParaSet : - public rtl::StaticWithInit<OldFillStyleDefinitionSet, theParaSet> + const OldFillStyleDefinitionSet & theParaSet() { - OldFillStyleDefinitionSet operator () () - { - OldFillStyleDefinitionSet aSet; - // Caution: here it is *not* 'ParaBackColorRGB' as it should be, but indeed - // 'ParaBackColor' is used, see aXMLParaPropMap definition (line 313) - aSet.insert("ParaBackColor"); - aSet.insert("ParaBackTransparent"); - aSet.insert("ParaBackGraphicLocation"); - aSet.insert("ParaBackGraphicFilter"); - aSet.insert("ParaBackGraphic"); - - // These are not used in aXMLParaPropMap definition, thus not needed here - // aSet.insert("ParaBackColorTransparency"); - // aSet.insert("ParaBackGraphicTransparency"); - return aSet; - } + static const OldFillStyleDefinitionSet theSet = []() + { + OldFillStyleDefinitionSet aSet; + // Caution: here it is *not* 'ParaBackColorRGB' as it should be, but indeed + // 'ParaBackColor' is used, see aXMLParaPropMap definition (line 313) + aSet.insert("ParaBackColor"); + aSet.insert("ParaBackTransparent"); + aSet.insert("ParaBackGraphicLocation"); + aSet.insert("ParaBackGraphicFilter"); + aSet.insert("ParaBackGraphic"); + + // These are not used in aXMLParaPropMap definition, thus not needed here + // aSet.insert("ParaBackColorTransparency"); + // aSet.insert("ParaBackGraphicTransparency"); + return aSet; + }(); + return theSet; }; } @@ -159,17 +159,17 @@ XMLPropStyleContext::~XMLPropStyleContext() const OldFillStyleDefinitionSet& XMLPropStyleContext::getStandardSet() { - return theStandardSet::get(); + return theStandardSet(); } const OldFillStyleDefinitionSet& XMLPropStyleContext::getHeaderSet() { - return theHeaderSet::get(); + return theHeaderSet(); } const OldFillStyleDefinitionSet& XMLPropStyleContext::getFooterSet() { - return theFooterSet::get(); + return theFooterSet(); } css::uno::Reference< css::xml::sax::XFastContextHandler > XMLPropStyleContext::createFastChildContext( @@ -272,7 +272,7 @@ void XMLPropStyleContext::CreateAndInsert( bool bOverwrite ) if(doNewDrawingLayerFillStyleDefinitionsExist(s_FillStyle)) { - deactivateOldFillStyleDefinitions(theParaSet::get()); + deactivateOldFillStyleDefinitions(theParaSet()); bDrawingLayerFillStylesUsed = true; } }