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.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2023-03-23 11:11:48 +02:00
committed by Noel Grandin
parent 462ebbd10b
commit e7dbef922a
19 changed files with 182 additions and 189 deletions

View File

@@ -245,13 +245,15 @@ IMPL_STATIC_LINK(MissingPluginInstaller, launchUi, void *, p, void)
} }
struct TheMissingPluginInstaller: MissingPluginInstaller& TheMissingPluginInstaller()
public rtl::Static<MissingPluginInstaller, TheMissingPluginInstaller> {
{}; static MissingPluginInstaller theInstaller;
return theInstaller;
}
void MissingPluginInstallerThread::execute() { void MissingPluginInstallerThread::execute() {
MissingPluginInstaller & inst = TheMissingPluginInstaller::get(); MissingPluginInstaller & inst = TheMissingPluginInstaller();
for (;;) { for (;;) {
std::vector<OString> details; std::vector<OString> details;
{ {
@@ -330,7 +332,7 @@ Player::~Player()
void SAL_CALL Player::disposing() void SAL_CALL Player::disposing()
{ {
TheMissingPluginInstaller::get().detach(this); TheMissingPluginInstaller().detach(this);
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
@@ -532,7 +534,7 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message )
maSizeCondition.set(); maSizeCondition.set();
} }
} else if (gst_is_missing_plugin_message(message)) { } else if (gst_is_missing_plugin_message(message)) {
TheMissingPluginInstaller::get().report(this, message); TheMissingPluginInstaller().report(this, message);
if( mnWidth == 0 ) { if( mnWidth == 0 ) {
// an error occurred, set condition so that OOo thread doesn't wait for us // an error occurred, set condition so that OOo thread doesn't wait for us
maSizeCondition.set(); maSizeCondition.set();

View File

@@ -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) if (rPar.Count() == 2)
{ {
int nSeed = static_cast<int>(rPar.Get(1)->GetInteger()); 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 // 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 else
{ {
std::uniform_real_distribution<double> dist(0.0, 1.0); 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); rPar.Get(0)->PutDouble(tmp);
} }
} }

View File

@@ -188,22 +188,11 @@ namespace dxcanvas
return uno::Any(); 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 uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const
{ {
// always the same // always the same
return DeviceColorSpace::get(); static uno::Reference<rendering::XColorSpace> theSpace = vcl::unotools::createStandardColorSpace();
return theSpace;
} }
} }

View File

@@ -62,15 +62,17 @@ using namespace ::com::sun::star::uno;
namespace dp_misc { namespace dp_misc {
namespace { namespace {
struct UnoRc : public rtl::StaticWithInit< std::shared_ptr<rtl::Bootstrap> & UnoRc()
std::shared_ptr<rtl::Bootstrap>, UnoRc> { {
std::shared_ptr<rtl::Bootstrap> operator () () { static std::shared_ptr<rtl::Bootstrap> theRc = []()
{
OUString unorc( "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("louno") ); OUString unorc( "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("louno") );
::rtl::Bootstrap::expandMacros( unorc ); ::rtl::Bootstrap::expandMacros( unorc );
auto ret = std::make_shared<::rtl::Bootstrap>( unorc ); auto ret = std::make_shared<::rtl::Bootstrap>( unorc );
OSL_ASSERT( ret->getHandle() != nullptr ); OSL_ASSERT( ret->getHandle() != nullptr );
return ret; return ret;
} }();
return theRc;
}; };
OUString generateOfficePipeId() OUString generateOfficePipeId()
@@ -293,7 +295,7 @@ OUString makeURLAppendSysPathSegment( std::u16string_view baseURL, OUString cons
OUString expandUnoRcTerm( OUString const & term_ ) OUString expandUnoRcTerm( OUString const & term_ )
{ {
OUString term(term_); OUString term(term_);
UnoRc::get()->expandMacrosFrom( term ); UnoRc()->expandMacrosFrom( term );
return term; return term;
} }
@@ -318,7 +320,7 @@ OUString expandUnoRcUrl( OUString const & url )
rcurl = ::rtl::Uri::decode( rcurl = ::rtl::Uri::decode(
rcurl, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); rcurl, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
// expand macro string: // expand macro string:
UnoRc::get()->expandMacrosFrom( rcurl ); UnoRc()->expandMacrosFrom( rcurl );
return rcurl; return rcurl;
} }
else { else {

View File

@@ -32,36 +32,39 @@ namespace dp_misc
{ {
namespace namespace
{ {
struct StrOperatingSystem : const OUString & StrOperatingSystem()
public rtl::StaticWithInit<OUString, StrOperatingSystem> { {
OUString operator () () { static const OUString theOS = []()
{
OUString os( "$_OS" ); OUString os( "$_OS" );
::rtl::Bootstrap::expandMacros( os ); ::rtl::Bootstrap::expandMacros( os );
return os; return os;
} }();
return theOS;
}; };
struct StrCPU : const OUString & StrCPU()
public rtl::StaticWithInit<OUString, StrCPU> { {
OUString operator () () { static const OUString theCPU = []()
{
OUString arch( "$_ARCH" ); OUString arch( "$_ARCH" );
::rtl::Bootstrap::expandMacros( arch ); ::rtl::Bootstrap::expandMacros( arch );
return arch; return arch;
} }();
return theCPU;
}; };
struct StrPlatform : public rtl::StaticWithInit< const OUString & StrPlatform()
OUString, StrPlatform> { {
OUString operator () () { static const OUString thePlatform = StrOperatingSystem() + "_" + StrCPU();
return StrOperatingSystem::get() + "_" + StrCPU::get(); return thePlatform;
}
}; };
bool checkOSandCPU(std::u16string_view os, std::u16string_view cpu) bool checkOSandCPU(std::u16string_view os, std::u16string_view cpu)
{ {
return (os == StrOperatingSystem::get()) return (os == StrOperatingSystem())
&& (cpu == StrCPU::get()); && (cpu == StrCPU());
} }
bool isPlatformSupported( std::u16string_view token ) bool isPlatformSupported( std::u16string_view token )
@@ -161,7 +164,7 @@ namespace
OUString const & getPlatformString() OUString const & getPlatformString()
{ {
return StrPlatform::get(); return StrPlatform();
} }
bool platform_fits( std::u16string_view platform_string ) 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( const std::u16string_view token(
o3tl::trim(o3tl::getToken(platform_string, 0, ',', index )) ); o3tl::trim(o3tl::getToken(platform_string, 0, ',', index )) );
// check if this platform: // 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 */ (token.find( '_' ) == std::u16string_view::npos && /* check OS part only */
o3tl::equalsIgnoreAsciiCase( token, StrOperatingSystem::get() ))) o3tl::equalsIgnoreAsciiCase( token, StrOperatingSystem() )))
{ {
return true; return true;
} }

View File

@@ -46,7 +46,7 @@ LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContex
// the configuration for the backend would create another instance of the // the configuration for the backend would create another instance of the
// backend, which would try and read the configuration which would... // 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); osl::MutexGuard aInitGuard(aInitMutex);
static bool bReentrantCall; // = false static bool bReentrantCall; // = false

View File

@@ -65,7 +65,11 @@ struct TSharedStorages final
a) shared root storages a) shared root storages
b) shared "inbetween" storages b) shared "inbetween" storages
of the share and user layer. */ 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 Otherwise we will disconnect all other open configuration access
objects which base on these storages. objects which base on these storages.
*/ */
auto & sharedStorages = SharedStorages::get(); auto & sharedStorages = SharedStorages();
sharedStorages.m_lStoragesShare.closePath(m_sRelPathShare); sharedStorages.m_lStoragesShare.closePath(m_sRelPathShare);
sharedStorages.m_lStoragesUser.closePath (m_sRelPathUser ); sharedStorages.m_lStoragesUser.closePath (m_sRelPathUser );
@@ -169,7 +173,7 @@ void lcl_throwCorruptedUIConfigurationException(
css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageShare() 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(); css::uno::Reference< css::embed::XStorage > xRoot = sharedStorages.m_lStoragesShare.getRootStorage();
if (xRoot.is()) if (xRoot.is())
return xRoot; return xRoot;
@@ -228,7 +232,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag
css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageUser() 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(); css::uno::Reference< css::embed::XStorage > xRoot = sharedStorages.m_lStoragesUser.getRootStorage();
if (xRoot.is()) if (xRoot.is())
return xRoot; return xRoot;
@@ -287,7 +291,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageShare
xWorking = m_xWorkingStorageShare; xWorking = m_xWorkingStorageShare;
} }
return SharedStorages::get().m_lStoragesShare.getParentStorage(xWorking); return SharedStorages().m_lStoragesShare.getParentStorage(xWorking);
} }
css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageUser() css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageUser()
@@ -298,7 +302,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageUser(
xWorking = m_xWorkingStorageUser; xWorking = m_xWorkingStorageUser;
} }
return SharedStorages::get().m_lStoragesUser.getParentStorage(xWorking); return SharedStorages().m_lStoragesUser.getParentStorage(xWorking);
} }
void PresetHandler::connectToResource( PresetHandler::EConfigType eConfigType , void PresetHandler::connectToResource( PresetHandler::EConfigType eConfigType ,
@@ -538,7 +542,7 @@ void PresetHandler::commitUserChanges()
case E_GLOBAL : case E_GLOBAL :
case E_MODULES : case E_MODULES :
{ {
auto & sharedStorages = SharedStorages::get(); auto & sharedStorages = SharedStorages();
sPath = sharedStorages.m_lStoragesUser.getPathOfStorage(xWorking); sPath = sharedStorages.m_lStoragesUser.getPathOfStorage(xWorking);
sharedStorages.m_lStoragesUser.commitPath(sPath); sharedStorages.m_lStoragesUser.commitPath(sPath);
sharedStorages.m_lStoragesUser.notifyPath(sPath); sharedStorages.m_lStoragesUser.notifyPath(sPath);
@@ -573,7 +577,7 @@ void PresetHandler::addStorageListener(XMLBasedAcceleratorConfiguration* pListen
case E_GLOBAL : case E_GLOBAL :
case E_MODULES : case E_MODULES :
{ {
SharedStorages::get().m_lStoragesUser.addStorageListener(pListener, sRelPath); SharedStorages().m_lStoragesUser.addStorageListener(pListener, sRelPath);
} }
break; break;
@@ -603,7 +607,7 @@ void PresetHandler::removeStorageListener(XMLBasedAcceleratorConfiguration* pLis
case E_GLOBAL : case E_GLOBAL :
case E_MODULES : case E_MODULES :
{ {
SharedStorages::get().m_lStoragesUser.removeStorageListener(pListener, sRelPath); SharedStorages().m_lStoragesUser.removeStorageListener(pListener, sRelPath);
} }
break; break;
@@ -623,9 +627,9 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring
try try
{ {
if (bShare) if (bShare)
xPath = SharedStorages::get().m_lStoragesShare.openPath(sPath, eMode); xPath = SharedStorages().m_lStoragesShare.openPath(sPath, eMode);
else else
xPath = SharedStorages::get().m_lStoragesUser.openPath(sPath, eMode); xPath = SharedStorages().m_lStoragesUser.openPath(sPath, eMode);
} }
catch(const css::uno::RuntimeException&) catch(const css::uno::RuntimeException&)
{ throw; } { throw; }

View File

@@ -159,7 +159,11 @@ PresetColorsPool::PresetColorsPool() :
maHighlightColors[static_cast<size_t>(nEntry.first)] = nEntry.second; 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 DEC_GAMMA = 2.3;
const double INC_GAMMA = 1.0 / DEC_GAMMA; const double INC_GAMMA = 1.0 / DEC_GAMMA;
@@ -264,7 +268,7 @@ Color::Color() :
/* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be
able to catch the existing vector entries without corresponding XML able to catch the existing vector entries without corresponding XML
token identifier. */ 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; return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb;
} }
@@ -273,7 +277,7 @@ Color::Color() :
/* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be
able to catch the existing vector entries without corresponding XML able to catch the existing vector entries without corresponding XML
token identifier. */ 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; return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb;
} }
@@ -282,7 +286,7 @@ Color::Color() :
/* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be
able to catch the existing vector entries without corresponding XML able to catch the existing vector entries without corresponding XML
token identifier. */ 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; return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb;
} }

View File

@@ -30,9 +30,10 @@
namespace { namespace {
struct StaticDebugBaseAddressFilter const std::vector<OString>& StaticDebugBaseAddressFilter()
: rtl::StaticWithInit<std::vector<OString>, StaticDebugBaseAddressFilter> { {
std::vector<OString> operator()() const { static const std::vector<OString> theFilter = []()
{
std::vector<OString> vec; std::vector<OString> vec;
rtl_uString * pStr = nullptr; rtl_uString * pStr = nullptr;
OUString const name( OUString const name(
@@ -49,7 +50,8 @@ struct StaticDebugBaseAddressFilter
while (nIndex >= 0); while (nIndex >= 0);
} }
return vec; return vec;
} }();
return theFilter;
}; };
bool isSubStr( char const* pStr, OString const& subStr ) 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 ) bool SAL_CALL osl_detail_ObjectRegistry_storeAddresses( char const* pName )
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
std::vector<OString> const& rVec = StaticDebugBaseAddressFilter::get(); std::vector<OString> const& rVec = StaticDebugBaseAddressFilter();
if (rVec.empty()) if (rVec.empty())
return false; return false;
// check for "all": // check for "all":

View File

@@ -67,12 +67,10 @@ public:
namespace namespace
{ {
//thread-safe double-locked class to ensure createNonDocMSPs is called once //thread-safe method to ensure createNonDocMSPs is called once
class theNonDocMSPCreator : public rtl::StaticWithArg<NonDocMSPCreator, ActiveMSPList*, theNonDocMSPCreator> {};
void ensureNonDocMSPs(ActiveMSPList *pList) void ensureNonDocMSPs(ActiveMSPList *pList)
{ {
theNonDocMSPCreator::get(pList); static NonDocMSPCreator theCreator(pList);
} }
} }

View File

@@ -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 & uno::Reference<rendering::XIntegerBitmapColorSpace> const &
getOGLColorSpace() getOGLColorSpace()
{ {
return OGLColorSpaceHolder::get(); static uno::Reference<rendering::XIntegerBitmapColorSpace> theSpace = new OGLColorSpace();
return theSpace;
} }
void buildMipmaps( void buildMipmaps(

View File

@@ -72,15 +72,13 @@ namespace
SmCmdBoxWrapper::RegisterChildWindow(true); SmCmdBoxWrapper::RegisterChildWindow(true);
} }
struct theSmDLLInstance : public rtl::Static<SmDLL, theSmDLLInstance> {};
} }
namespace SmGlobals namespace SmGlobals
{ {
void ensure() void ensure()
{ {
theSmDLLInstance::get(); static SmDLL theDll;
} }
} }

View File

@@ -338,13 +338,17 @@ namespace {
// global // global
std::weak_ptr<SvtCTLOptions_Impl> g_pCTLOptions; 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 ) SvtCTLOptions::SvtCTLOptions( bool bDontLoad )
{ {
// Global access, must be guarded (multithreading) // Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( CTLMutex::get() ); ::osl::MutexGuard aGuard( CTLMutex() );
m_pImpl = g_pCTLOptions.lock(); m_pImpl = g_pCTLOptions.lock();
if ( !m_pImpl ) if ( !m_pImpl )
@@ -364,7 +368,7 @@ SvtCTLOptions::SvtCTLOptions( bool bDontLoad )
SvtCTLOptions::~SvtCTLOptions() SvtCTLOptions::~SvtCTLOptions()
{ {
// Global access, must be guarded (multithreading) // Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( CTLMutex::get() ); ::osl::MutexGuard aGuard( CTLMutex() );
m_pImpl->RemoveListener(this); m_pImpl->RemoveListener(this);
m_pImpl.reset(); m_pImpl.reset();

View File

@@ -84,7 +84,11 @@ public:
void AddEntry( const OUString& rString, const LanguageType eType); 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 ) OUString ApplyLreOrRleEmbedding( const OUString &rText )
@@ -224,7 +228,7 @@ bool SvtLanguageTableImpl::HasType( const LanguageType eType ) const
bool SvtLanguageTable::HasLanguageType( const LanguageType eType ) bool SvtLanguageTable::HasLanguageType( const LanguageType eType )
{ {
return theLanguageTable::get().HasType( eType ); return theLanguageTable().HasType( eType );
} }
OUString SvtLanguageTableImpl::GetString( const LanguageType eType ) const OUString SvtLanguageTableImpl::GetString( const LanguageType eType ) const
@@ -251,7 +255,7 @@ OUString SvtLanguageTableImpl::GetString( const LanguageType eType ) const
OUString SvtLanguageTable::GetLanguageString( const LanguageType eType ) OUString SvtLanguageTable::GetLanguageString( const LanguageType eType )
{ {
return theLanguageTable::get().GetString( eType ); return theLanguageTable().GetString( eType );
} }
LanguageType SvtLanguageTableImpl::GetType( std::u16string_view rStr ) const 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 ) LanguageType SvtLanguageTable::GetLanguageType( std::u16string_view rStr )
{ {
return theLanguageTable::get().GetType( rStr ); return theLanguageTable().GetType( rStr );
} }
sal_uInt32 SvtLanguageTableImpl::GetEntryCount() const sal_uInt32 SvtLanguageTableImpl::GetEntryCount() const
@@ -282,7 +286,7 @@ sal_uInt32 SvtLanguageTableImpl::GetEntryCount() const
sal_uInt32 SvtLanguageTable::GetLanguageEntryCount() 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 ) LanguageType SvtLanguageTable::GetLanguageTypeAtIndex( sal_uInt32 nIndex )
{ {
return theLanguageTable::get().GetTypeAtIndex( nIndex); return theLanguageTable().GetTypeAtIndex( nIndex);
} }
void SvtLanguageTableImpl::AddEntry( const OUString& rString, const LanguageType eType ) 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 ) 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -59,7 +59,11 @@ namespace
} }
}; };
struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {}; SwDLLInstance& theSwDLLInstance()
{
static SwDLLInstance aInstance;
return aInstance;
}
} }
namespace SwGlobals namespace SwGlobals
@@ -67,12 +71,12 @@ namespace SwGlobals
void ensure() void ensure()
{ {
// coverity[side_effect_free : FALSE] - not actually side-effect-free // coverity[side_effect_free : FALSE] - not actually side-effect-free
theSwDLLInstance::get(); theSwDLLInstance();
} }
sw::Filters & getFilters() sw::Filters & getFilters()
{ {
return theSwDLLInstance::get()->getFilters(); return theSwDLLInstance()->getFilters();
} }
} }

View File

@@ -343,14 +343,10 @@ std::vector< SvtCompatibilityEntry > SvtCompatibilityOptions::GetList() const
return m_pImpl->GetOptions(); return m_pImpl->GetOptions();
} }
namespace
{
class theCompatibilityOptionsMutex : public rtl::Static<osl::Mutex, theCompatibilityOptionsMutex>{};
}
Mutex& SvtCompatibilityOptions::GetOwnStaticMutex() Mutex& SvtCompatibilityOptions::GetOwnStaticMutex()
{ {
return theCompatibilityOptionsMutex::get(); static osl::Mutex aMutex;
return aMutex;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -613,17 +613,10 @@ void SvtFilterOptions::SetVisio2Draw(bool bFlag)
SetModified(); SetModified();
} }
namespace
{
class theFilterOptions
: public rtl::Static<SvtFilterOptions, theFilterOptions>
{
};
}
SvtFilterOptions& SvtFilterOptions::Get() SvtFilterOptions& SvtFilterOptions::Get()
{ {
return theFilterOptions::get(); static SvtFilterOptions aOptions;
return aOptions;
} }
bool SvtFilterOptions::IsEnablePPTPreview() const bool SvtFilterOptions::IsEnablePPTPreview() const

View File

@@ -385,20 +385,13 @@ private:
return false; 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 virtual uno::Reference< rendering::XColorSpace > SAL_CALL getColorSpace( ) override
{ {
// this is the method from XBitmapPalette. Return palette color // this is the method from XBitmapPalette. Return palette color
// space here // space here
return PaletteColorSpaceHolder::get(); static uno::Reference<rendering::XColorSpace> aColorSpace =
vcl::unotools::createStandardColorSpace();
return aColorSpace;
} }
// XIntegerBitmapColorSpace // XIntegerBitmapColorSpace

View File

@@ -70,10 +70,9 @@ void XMLPropStyleContext::SetAttribute( sal_Int32 nElement,
namespace namespace
{ {
struct theStandardSet : const OldFillStyleDefinitionSet & theStandardSet()
public rtl::StaticWithInit<OldFillStyleDefinitionSet, theStandardSet>
{ {
OldFillStyleDefinitionSet operator () () static const OldFillStyleDefinitionSet theSet = []()
{ {
OldFillStyleDefinitionSet aSet; OldFillStyleDefinitionSet aSet;
aSet.insert("BackColorRGB"); aSet.insert("BackColorRGB");
@@ -84,12 +83,12 @@ namespace
aSet.insert("BackGraphicLocation"); aSet.insert("BackGraphicLocation");
aSet.insert("BackGraphicTransparency"); aSet.insert("BackGraphicTransparency");
return aSet; return aSet;
} }();
return theSet;
}; };
struct theHeaderSet : const OldFillStyleDefinitionSet & theHeaderSet()
public rtl::StaticWithInit<OldFillStyleDefinitionSet, theHeaderSet>
{ {
OldFillStyleDefinitionSet operator () () static const OldFillStyleDefinitionSet theSet = []()
{ {
OldFillStyleDefinitionSet aSet; OldFillStyleDefinitionSet aSet;
aSet.insert("HeaderBackColorRGB"); aSet.insert("HeaderBackColorRGB");
@@ -100,12 +99,12 @@ namespace
aSet.insert("HeaderBackGraphicLocation"); aSet.insert("HeaderBackGraphicLocation");
aSet.insert("HeaderBackGraphicTransparency"); aSet.insert("HeaderBackGraphicTransparency");
return aSet; return aSet;
} }();
return theSet;
}; };
struct theFooterSet : const OldFillStyleDefinitionSet & theFooterSet()
public rtl::StaticWithInit<OldFillStyleDefinitionSet, theFooterSet>
{ {
OldFillStyleDefinitionSet operator () () static const OldFillStyleDefinitionSet theSet = []()
{ {
OldFillStyleDefinitionSet aSet; OldFillStyleDefinitionSet aSet;
aSet.insert("FooterBackColorRGB"); aSet.insert("FooterBackColorRGB");
@@ -116,12 +115,12 @@ namespace
aSet.insert("FooterBackGraphicLocation"); aSet.insert("FooterBackGraphicLocation");
aSet.insert("FooterBackGraphicTransparency"); aSet.insert("FooterBackGraphicTransparency");
return aSet; return aSet;
} }();
return theSet;
}; };
struct theParaSet : const OldFillStyleDefinitionSet & theParaSet()
public rtl::StaticWithInit<OldFillStyleDefinitionSet, theParaSet>
{ {
OldFillStyleDefinitionSet operator () () static const OldFillStyleDefinitionSet theSet = []()
{ {
OldFillStyleDefinitionSet aSet; OldFillStyleDefinitionSet aSet;
// Caution: here it is *not* 'ParaBackColorRGB' as it should be, but indeed // Caution: here it is *not* 'ParaBackColorRGB' as it should be, but indeed
@@ -136,7 +135,8 @@ namespace
// aSet.insert("ParaBackColorTransparency"); // aSet.insert("ParaBackColorTransparency");
// aSet.insert("ParaBackGraphicTransparency"); // aSet.insert("ParaBackGraphicTransparency");
return aSet; return aSet;
} }();
return theSet;
}; };
} }
@@ -159,17 +159,17 @@ XMLPropStyleContext::~XMLPropStyleContext()
const OldFillStyleDefinitionSet& XMLPropStyleContext::getStandardSet() const OldFillStyleDefinitionSet& XMLPropStyleContext::getStandardSet()
{ {
return theStandardSet::get(); return theStandardSet();
} }
const OldFillStyleDefinitionSet& XMLPropStyleContext::getHeaderSet() const OldFillStyleDefinitionSet& XMLPropStyleContext::getHeaderSet()
{ {
return theHeaderSet::get(); return theHeaderSet();
} }
const OldFillStyleDefinitionSet& XMLPropStyleContext::getFooterSet() const OldFillStyleDefinitionSet& XMLPropStyleContext::getFooterSet()
{ {
return theFooterSet::get(); return theFooterSet();
} }
css::uno::Reference< css::xml::sax::XFastContextHandler > XMLPropStyleContext::createFastChildContext( css::uno::Reference< css::xml::sax::XFastContextHandler > XMLPropStyleContext::createFastChildContext(
@@ -272,7 +272,7 @@ void XMLPropStyleContext::CreateAndInsert( bool bOverwrite )
if(doNewDrawingLayerFillStyleDefinitionsExist(s_FillStyle)) if(doNewDrawingLayerFillStyleDefinitionsExist(s_FillStyle))
{ {
deactivateOldFillStyleDefinitions(theParaSet::get()); deactivateOldFillStyleDefinitions(theParaSet());
bDrawingLayerFillStylesUsed = true; bDrawingLayerFillStylesUsed = true;
} }
} }