toolkit/source/controls/geometrycontrolmodel.cxx      |   31 +++++++---------
 tools/source/stream/strmunx.cxx                       |   10 ++---
 unotools/source/config/useroptions.cxx                |    9 +---
 unotools/source/i18n/localedatawrapper.cxx            |   20 ++--------
 unotools/source/ucbhelper/tempfile.cxx                |    7 +--
 vcl/source/control/imp_listbox.cxx                    |   18 +++------
 vcl/source/filter/graphicfilter.cxx                   |    6 +--
 vcl/source/font/font.cxx                              |   10 +++--
 vcl/source/gdi/graph.cxx                              |    9 +---
 vcl/source/gdi/jobset.cxx                             |   12 +++---
 vcl/source/gdi/mapmod.cxx                             |   12 +++---
 vcl/source/helper/canvasbitmap.cxx                    |   17 +--------
 vcl/source/window/errinf.cxx                          |   33 +++++++++---------
 vcl/unx/generic/printer/ppdparser.cxx                 |   13 ++++---
 writerfilter/source/dmapper/TagLogger.cxx             |   11 +-----
 xmlsecurity/source/component/certificatecontainer.cxx |   22 +-----------
 16 files changed, 91 insertions(+), 149 deletions(-)

New commits:
commit 6c7d6924511f3006f64fb9d3eadd289778098571
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Jul 29 11:22:28 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jul 29 14:35:44 2021 +0200

    rtl::Static -> static local
    
    in a handful cases, like a map or a vector, we don't need init on demand
    at all, the default constructor can be laid out at compile time
    
    Change-Id: I2d404584b5aa23db7b1f779e160e04e72dd2aa74
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119656
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx 
b/toolkit/source/controls/geometrycontrolmodel.cxx
index 53a7f02d45ef..ee6dfb6d2a07 100644
--- a/toolkit/source/controls/geometrycontrolmodel.cxx
+++ b/toolkit/source/controls/geometrycontrolmodel.cxx
@@ -21,7 +21,6 @@
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/resource/XStringResourceResolver.hpp>
 #include <osl/diagnose.h>
-#include <rtl/instance.hxx>
 #include <comphelper/sequence.hxx>
 #include <controls/eventcontainer.hxx>
 #include <toolkit/helper/property.hxx>
@@ -438,15 +437,15 @@
     typedef std::vector< ::std::vector< sal_Int32 > > IntArrayArray;
 
     // for creating class-unique PropertySetInfo's, we need some info:
-    namespace { struct ServiceSpecifierMap : public rtl::Static< 
HashMapString2Int, ServiceSpecifierMap > {}; }
+    namespace { HashMapString2Int gServiceSpecifierMap; }
     // this one maps from a String, which is the service specifier for our
     // aggregate, to a unique id
 
-    namespace { struct AggregateProperties : public rtl::Static< PropSeqArray, 
AggregateProperties > {}; }
+    namespace { PropSeqArray gAggregateProperties; }
     // this one contains the properties which belong to all the unique ids
     // in ServiceSpecifierMap
 
-    namespace { struct AmbiguousPropertyIds : public rtl::Static< 
IntArrayArray, AmbiguousPropertyIds > {}; }
+    namespace { IntArrayArray gAmbiguousPropertyIds; }
     // the ids of the properties which we as well as our aggregate supply
     // For such props, we let our base class handle them, and whenever such
     // a prop is set, we forward this to our aggregate.
@@ -470,16 +469,14 @@
             throw IllegalArgumentException();
         }
 
-        HashMapString2Int &rMap = ServiceSpecifierMap::get();
-        HashMapString2Int::iterator aPropMapIdPos = rMap.find( 
m_sServiceSpecifier );
-        if ( rMap.end() == aPropMapIdPos )
+        HashMapString2Int::iterator aPropMapIdPos = gServiceSpecifierMap.find( 
m_sServiceSpecifier );
+        if ( gServiceSpecifierMap.end() == aPropMapIdPos )
         {
-            PropSeqArray &rAggProperties = AggregateProperties::get();
-            m_nPropertyMapId = rAggProperties.size();
-            rAggProperties.push_back( xPI->getProperties() );
-            AmbiguousPropertyIds::get().emplace_back( );
+            m_nPropertyMapId = gAggregateProperties.size();
+            gAggregateProperties.push_back( xPI->getProperties() );
+            gAmbiguousPropertyIds.emplace_back( );
 
-            rMap[ m_sServiceSpecifier ] = m_nPropertyMapId;
+            gServiceSpecifierMap[ m_sServiceSpecifier ] = m_nPropertyMapId;
         }
         else
             m_nPropertyMapId = aPropMapIdPos->second;
@@ -512,18 +509,18 @@
     ::cppu::IPropertyArrayHelper* 
OCommonGeometryControlModel::createArrayHelper( sal_Int32 _nId ) const
     {
         OSL_ENSURE( _nId == m_nPropertyMapId, 
"OCommonGeometryControlModel::createArrayHelper: invalid argument!" );
-        OSL_ENSURE( _nId < 
static_cast<sal_Int32>(AggregateProperties::get().size()), 
"OCommonGeometryControlModel::createArrayHelper: invalid status info (1)!" );
-        OSL_ENSURE( _nId < 
static_cast<sal_Int32>(AmbiguousPropertyIds::get().size()), 
"OCommonGeometryControlModel::createArrayHelper: invalid status info (2)!" );
+        OSL_ENSURE( _nId < 
static_cast<sal_Int32>(gAggregateProperties.size()), 
"OCommonGeometryControlModel::createArrayHelper: invalid status info (1)!" );
+        OSL_ENSURE( _nId < 
static_cast<sal_Int32>(gAmbiguousPropertyIds.size()), 
"OCommonGeometryControlModel::createArrayHelper: invalid status info (2)!" );
 
         // our own properties
         Sequence< Property > aProps;
         OPropertyContainer::describeProperties( aProps );
 
         // the aggregate properties
-        Sequence< Property > aAggregateProps = AggregateProperties::get()[ 
_nId ];
+        Sequence< Property > aAggregateProps = gAggregateProperties[ _nId ];
 
         // look for duplicates, and remember them
-        IntArrayArray::value_type& rDuplicateIds = 
AmbiguousPropertyIds::get()[ _nId ];
+        IntArrayArray::value_type& rDuplicateIds = gAmbiguousPropertyIds[ _nId 
];
         // for this, sort the aggregate properties
         ::std::sort(
             aAggregateProps.begin(),
@@ -589,7 +586,7 @@
         OGeometryControlModel_Base::setFastPropertyValue_NoBroadcast( 
_nHandle, _rValue );
 
         // look if this id is one we recognized as duplicate
-        IntArrayArray::value_type& rDuplicateIds = 
AmbiguousPropertyIds::get()[ m_nPropertyMapId ];
+        IntArrayArray::value_type& rDuplicateIds = gAmbiguousPropertyIds[ 
m_nPropertyMapId ];
 
         if ( std::any_of(rDuplicateIds.begin(), rDuplicateIds.end(), 
Int32Equal( _nHandle )) )
         {
diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index e034f53ac33b..6743993f112e 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -40,7 +40,7 @@ namespace {
 
 struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {};
 
-struct Locks : public rtl::Static< std::map<SvFileStream const *, 
osl::DirectoryItem>, Locks > {};
+std::map<SvFileStream const *, osl::DirectoryItem> gLocks;
 
 bool lockFile( const SvFileStream* pStream )
 {
@@ -61,8 +61,7 @@ bool lockFile( const SvFileStream* pStream )
         return true;
 
     osl::MutexGuard aGuard( LockMutex::get() );
-    auto &rLocks = Locks::get();
-    for( const auto& [rLockStream, rLockItem] : rLocks )
+    for( const auto& [rLockStream, rLockItem] : gLocks )
     {
         if( aItem.isIdenticalTo( rLockItem ) )
         {
@@ -78,15 +77,14 @@ bool lockFile( const SvFileStream* pStream )
             }
         }
     }
-    rLocks[pStream] = aItem;
+    gLocks[pStream] = aItem;
     return true;
 }
 
 void unlockFile( SvFileStream const * pStream )
 {
     osl::MutexGuard aGuard( LockMutex::get() );
-    auto &rLocks = Locks::get();
-    rLocks.erase(pStream);
+    gLocks.erase(pStream);
 }
 
 }
diff --git a/unotools/source/config/useroptions.cxx 
b/unotools/source/config/useroptions.cxx
index bf877b790392..ffe01cca497c 100644
--- a/unotools/source/config/useroptions.cxx
+++ b/unotools/source/config/useroptions.cxx
@@ -23,7 +23,6 @@
 #include <unotools/syslocale.hxx>
 #include <com/sun/star/uno/Any.hxx>
 #include <osl/mutex.hxx>
-#include <rtl/instance.hxx>
 #include "itemholder1.hxx"
 
 #include <cppuhelper/implbase.hxx>
@@ -282,14 +281,10 @@ SvtUserOptions::~SvtUserOptions()
     xImpl->RemoveListener(this);
 }
 
-namespace
-{
-    class theUserOptionsMutex : public rtl::Static<osl::Mutex, 
theUserOptionsMutex>{};
-}
-
 osl::Mutex& SvtUserOptions::GetInitMutex()
 {
-    return theUserOptionsMutex::get();
+    static osl::Mutex gMutex;
+    return gMutex;
 }
 
 OUString SvtUserOptions::GetCompany        () const { return 
GetToken(UserOptToken::Company); }
diff --git a/unotools/source/i18n/localedatawrapper.cxx 
b/unotools/source/i18n/localedatawrapper.cxx
index fb70c0657a73..b6a286a07fc2 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -38,7 +38,6 @@
 
 #include <comphelper/processfactory.hxx>
 #include <comphelper/sequence.hxx>
-#include <rtl/instance.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <rtl/math.hxx>
 
@@ -50,15 +49,8 @@ using namespace ::com::sun::star::uno;
 
 namespace
 {
-    struct InstalledLocales
-        : public rtl::Static<
-            uno::Sequence< lang::Locale >, InstalledLocales >
-    {};
-
-    struct InstalledLanguageTypes
-        : public rtl::Static<
-            std::vector< LanguageType >, InstalledLanguageTypes >
-    {};
+    uno::Sequence< lang::Locale > gInstalledLocales;
+    std::vector< LanguageType > gInstalledLanguageTypes;
 }
 
 sal_uInt8 LocaleDataWrapper::nLocaleDataChecking = 0;
@@ -279,7 +271,7 @@ css::i18n::ForbiddenCharacters 
LocaleDataWrapper::getForbiddenCharacters() const
 
 css::uno::Sequence< css::lang::Locale > 
LocaleDataWrapper::getAllInstalledLocaleNames() const
 {
-    uno::Sequence< lang::Locale > &rInstalledLocales = InstalledLocales::get();
+    uno::Sequence< lang::Locale > &rInstalledLocales = gInstalledLocales;
 
     if ( rInstalledLocales.hasElements() )
         return rInstalledLocales;
@@ -300,8 +292,7 @@ css::uno::Sequence< css::lang::Locale > 
LocaleDataWrapper::getAllInstalledLocale
 // static
 css::uno::Sequence< css::lang::Locale > 
LocaleDataWrapper::getInstalledLocaleNames()
 {
-    const uno::Sequence< lang::Locale > &rInstalledLocales =
-        InstalledLocales::get();
+    const uno::Sequence< lang::Locale > &rInstalledLocales = gInstalledLocales;
 
     if ( !rInstalledLocales.hasElements() )
     {
@@ -314,8 +305,7 @@ css::uno::Sequence< css::lang::Locale > 
LocaleDataWrapper::getInstalledLocaleNam
 // static
 std::vector< LanguageType > LocaleDataWrapper::getInstalledLanguageTypes()
 {
-    std::vector< LanguageType > &rInstalledLanguageTypes =
-        InstalledLanguageTypes::get();
+    std::vector< LanguageType > &rInstalledLanguageTypes = 
gInstalledLanguageTypes;
 
     if ( !rInstalledLanguageTypes.empty() )
         return rInstalledLanguageTypes;
diff --git a/unotools/source/ucbhelper/tempfile.cxx 
b/unotools/source/ucbhelper/tempfile.cxx
index 25c15920d52b..bf41c00e2428 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -41,8 +41,7 @@ using namespace osl;
 
 namespace
 {
-    struct TempNameBase_Impl
-        : public rtl::Static< OUString, TempNameBase_Impl > {};
+    OUString gTempNameBase_Impl;
 }
 
 namespace utl
@@ -143,7 +142,7 @@ static OUString ConstructTempDir_Impl( const OUString* 
pParent, bool bCreatePare
 
     if ( aName.isEmpty() )
     {
-        OUString &rTempNameBase_Impl = TempNameBase_Impl::get();
+        OUString &rTempNameBase_Impl = gTempNameBase_Impl;
         if (rTempNameBase_Impl.isEmpty())
         {
             OUString ustrTempDirURL;
@@ -463,7 +462,7 @@ OUString TempFile::SetTempNameBaseDirectory( const OUString 
&rBaseName )
     if ( bRet )
     {
         // append own internal directory
-        OUString &rTempNameBase_Impl = TempNameBase_Impl::get();
+        OUString &rTempNameBase_Impl = gTempNameBase_Impl;
         rTempNameBase_Impl = rBaseName + "/";
 
         TempFile aBase( nullptr, true );
diff --git a/vcl/source/control/imp_listbox.cxx 
b/vcl/source/control/imp_listbox.cxx
index fab6e6f90c70..322578909b17 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -34,7 +34,6 @@
 
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 
-#include <rtl/instance.hxx>
 #include <sal/log.hxx>
 #include <o3tl/safeint.hxx>
 #include <osl/diagnose.h>
@@ -105,15 +104,12 @@ void ImplEntryList::SelectEntry( sal_Int32 nPos, bool 
bSelect )
 
 namespace
 {
-    struct theSorter
-        : public rtl::StaticWithInit< comphelper::string::NaturalStringSorter, 
theSorter >
+    comphelper::string::NaturalStringSorter& GetSorter()
     {
-        comphelper::string::NaturalStringSorter operator () ()
-        {
-            return comphelper::string::NaturalStringSorter(
-                ::comphelper::getProcessComponentContext(),
-                Application::GetSettings().GetLanguageTag().getLocale());
-        }
+        static comphelper::string::NaturalStringSorter gSorter(
+                    ::comphelper::getProcessComponentContext(),
+                    Application::GetSettings().GetLanguageTag().getLocale());
+        return gSorter;
     };
 }
 
@@ -121,7 +117,7 @@ namespace vcl
 {
     sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB)
     {
-        const comphelper::string::NaturalStringSorter &rSorter = 
theSorter::get();
+        const comphelper::string::NaturalStringSorter &rSorter = GetSorter();
         return rSorter.compare(rA, rB);
     }
 }
@@ -152,7 +148,7 @@ sal_Int32 ImplEntryList::InsertEntry( sal_Int32 nPos, 
ImplEntryType* pNewEntry,
     }
     else
     {
-        const comphelper::string::NaturalStringSorter &rSorter = 
theSorter::get();
+        const comphelper::string::NaturalStringSorter &rSorter = GetSorter();
 
         const OUString& rStr = pNewEntry->maStr;
 
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index 1be4c82e7c4e..55238a09729f 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -73,7 +73,6 @@
 #include <com/sun/star/xml/sax/Writer.hpp>
 #include <unotools/ucbstreamhelper.hxx>
 #include <rtl/bootstrap.hxx>
-#include <rtl/instance.hxx>
 #include <tools/svlibrary.h>
 #include <comphelper/string.hxx>
 #include <unotools/ucbhelper.hxx>
@@ -1919,13 +1918,12 @@ namespace
         }
         GraphicFilter m_aFilter;
     };
-
-    class theGraphicFilter : public rtl::Static<StandardGraphicFilter, 
theGraphicFilter> {};
 }
 
 GraphicFilter& GraphicFilter::GetGraphicFilter()
 {
-    return theGraphicFilter::get().m_aFilter;
+    static StandardGraphicFilter gStandardFilter;
+    return gStandardFilter.m_aFilter;
 }
 
 ErrCode GraphicFilter::LoadGraphic( const OUString &rPath, const OUString 
&rFilterName,
diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx
index d79658894a5b..5da80236aec5 100644
--- a/vcl/source/font/font.cxx
+++ b/vcl/source/font/font.cxx
@@ -35,7 +35,6 @@
 #include <algorithm>
 #include <string_view>
 
-#include <rtl/instance.hxx>
 #include <vcl/TypeSerializer.hxx>
 
 #ifdef _WIN32
@@ -46,11 +45,14 @@ using namespace vcl;
 
 namespace
 {
-    struct theGlobalDefault :
-        public rtl::Static< Font::ImplType, theGlobalDefault > {};
+    Font::ImplType& GetGlobalDefault()
+    {
+        static Font::ImplType gDefault;
+        return gDefault;
+    }
 }
 
-Font::Font() : mpImplFont(theGlobalDefault::get())
+Font::Font() : mpImplFont(GetGlobalDefault())
 {
 }
 
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 352073455e01..283cca42026b 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -557,14 +557,9 @@ OString Graphic::getUniqueID() const
     return aUniqueString;
 }
 
-namespace {
-
-struct Id: public rtl::Static<cppu::OImplementationId, Id> {};
-
-}
-
 css::uno::Sequence<sal_Int8> Graphic::getUnoTunnelId() {
-    return Id::get().getImplementationId();
+    static cppu::OImplementationId gId;
+    return gId.getImplementationId();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx
index 5777e1faa044..04ba708ef9a3 100644
--- a/vcl/source/gdi/jobset.cxx
+++ b/vcl/source/gdi/jobset.cxx
@@ -24,7 +24,6 @@
 #include <vcl/jobset.hxx>
 #include <jobset.h>
 #include <memory>
-#include <rtl/instance.hxx>
 
 #define JOBSET_FILE364_SYSTEM   (sal_uInt16(0xFFFF))
 #define JOBSET_FILE605_SYSTEM   (sal_uInt16(0xFFFE))
@@ -190,11 +189,14 @@ bool ImplJobSetup::operator==( const ImplJobSetup& 
rImplJobSetup ) const
 
 namespace
 {
-    struct theGlobalDefault :
-        public rtl::Static< JobSetup::ImplType, theGlobalDefault > {};
+    JobSetup::ImplType& GetGlobalDefault()
+    {
+        static JobSetup::ImplType gDefault;
+        return gDefault;
+    }
 }
 
-JobSetup::JobSetup() : mpData(theGlobalDefault::get())
+JobSetup::JobSetup() : mpData(GetGlobalDefault())
 {
 }
 
@@ -224,7 +226,7 @@ OUString const & JobSetup::GetPrinterName() const
 
 bool JobSetup::IsDefault() const
 {
-    return mpData.same_object(theGlobalDefault::get());
+    return mpData.same_object(GetGlobalDefault());
 }
 
 SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup )
diff --git a/vcl/source/gdi/mapmod.cxx b/vcl/source/gdi/mapmod.cxx
index 925732a66e39..c79a4392d1a8 100644
--- a/vcl/source/gdi/mapmod.cxx
+++ b/vcl/source/gdi/mapmod.cxx
@@ -23,7 +23,6 @@
 #include <tools/fract.hxx>
 #include <tools/stream.hxx>
 #include <tools/vcompat.hxx>
-#include <rtl/instance.hxx>
 #include <vcl/TypeSerializer.hxx>
 
 struct MapMode::ImplMapMode
@@ -65,11 +64,14 @@ bool MapMode::ImplMapMode::operator==( const ImplMapMode& 
rImpMapMode ) const
 
 namespace
 {
-    struct theGlobalDefault :
-        public rtl::Static< MapMode::ImplType, theGlobalDefault > {};
+    MapMode::ImplType& GetGlobalDefault()
+    {
+        static MapMode::ImplType gDefault;
+        return gDefault;
+    }
 }
 
-MapMode::MapMode() : mpImplMapMode(theGlobalDefault::get())
+MapMode::MapMode() : mpImplMapMode(GetGlobalDefault())
 {
 }
 
@@ -130,7 +132,7 @@ bool MapMode::operator==( const MapMode& rMapMode ) const
 
 bool MapMode::IsDefault() const
 {
-    return mpImplMapMode.same_object(theGlobalDefault::get());
+    return mpImplMapMode.same_object(GetGlobalDefault());
 }
 
 MapUnit MapMode::GetMapUnit() const { return mpImplMapMode->meUnit; }
diff --git a/vcl/source/helper/canvasbitmap.cxx 
b/vcl/source/helper/canvasbitmap.cxx
index 49faf0a73172..1e3edd5f3996 100644
--- a/vcl/source/helper/canvasbitmap.cxx
+++ b/vcl/source/helper/canvasbitmap.cxx
@@ -25,8 +25,6 @@
 #include <com/sun/star/rendering/ColorSpaceType.hpp>
 #include <com/sun/star/rendering/RenderingIntent.hpp>
 
-#include <rtl/instance.hxx>
-
 #include <tools/diagnose_ex.h>
 #include <canvasbitmap.hxx>
 #include <vcl/canvastools.hxx>
@@ -612,23 +610,12 @@ sal_Bool SAL_CALL VclCanvasBitmap::setIndex( const 
uno::Sequence< double >&, sal
     return false; // read-only implementation
 }
 
-namespace
-{
-    struct PaletteColorSpaceHolder: public 
rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,
-                                                               
PaletteColorSpaceHolder>
-    {
-        uno::Reference<rendering::XColorSpace> operator()()
-        {
-            return vcl::unotools::createStandardColorSpace();
-        }
-    };
-}
-
 uno::Reference< rendering::XColorSpace > SAL_CALL 
VclCanvasBitmap::getColorSpace(  )
 {
     // this is the method from XBitmapPalette. Return palette color
     // space here
-    return PaletteColorSpaceHolder::get();
+    static uno::Reference<rendering::XColorSpace> gColorSpace = 
vcl::unotools::createStandardColorSpace();
+    return gColorSpace;
 }
 
 sal_Int8 SAL_CALL VclCanvasBitmap::getType(  )
diff --git a/vcl/source/window/errinf.cxx b/vcl/source/window/errinf.cxx
index d9c4310f0a06..cf829175edff 100644
--- a/vcl/source/window/errinf.cxx
+++ b/vcl/source/window/errinf.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <osl/diagnose.h>
-#include <rtl/instance.hxx>
 #include <sal/log.hxx>
 
 #include <tools/debug.hxx>
@@ -31,13 +30,17 @@ class ErrorHandler;
 
 namespace {
 
-class TheErrorRegistry: public rtl::Static<ErrorRegistry, TheErrorRegistry> {};
+    ErrorRegistry& GetErrorRegistry()
+    {
+        static ErrorRegistry gErrorRegistry;
+        return gErrorRegistry;
+    }
 
 }
 
 bool ErrorStringFactory::CreateString(const ErrorInfo* pInfo, OUString& rStr)
 {
-    for(const ErrorHandler *pHdlr : TheErrorRegistry::get().errorHandlers)
+    for(const ErrorHandler *pHdlr : GetErrorRegistry().errorHandlers)
     {
         if(pHdlr->CreateString(pInfo, rStr))
             return true;
@@ -56,21 +59,21 @@ ErrorRegistry::ErrorRegistry()
 
 void ErrorRegistry::RegisterDisplay(BasicDisplayErrorFunc *aDsp)
 {
-    ErrorRegistry &rData = TheErrorRegistry::get();
+    ErrorRegistry &rData = GetErrorRegistry();
     rData.bIsWindowDsp = false;
     rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
 }
 
 void ErrorRegistry::RegisterDisplay(WindowDisplayErrorFunc *aDsp)
 {
-    ErrorRegistry &rData = TheErrorRegistry::get();
+    ErrorRegistry &rData = GetErrorRegistry();
     rData.bIsWindowDsp = true;
     rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
 }
 
 void ErrorRegistry::Reset()
 {
-    ErrorRegistry &rData = TheErrorRegistry::get();
+    ErrorRegistry &rData = GetErrorRegistry();
     rData = ErrorRegistry();
 }
 
@@ -81,7 +84,7 @@ static void aDspFunc(const OUString &rErr, const OUString 
&rAction)
 
 ErrorHandler::ErrorHandler()
 {
-    ErrorRegistry &rData = TheErrorRegistry::get();
+    ErrorRegistry &rData = GetErrorRegistry();
     rData.errorHandlers.insert(rData.errorHandlers.begin(), this);
 
     if(!rData.pDsp)
@@ -90,7 +93,7 @@ ErrorHandler::ErrorHandler()
 
 ErrorHandler::~ErrorHandler()
 {
-    auto &rErrorHandlers = TheErrorRegistry::get().errorHandlers;
+    auto &rErrorHandlers = GetErrorRegistry().errorHandlers;
     rErrorHandlers.erase( ::std::remove(rErrorHandlers.begin(), 
rErrorHandlers.end(), this),
                           rErrorHandlers.end());
 }
@@ -118,7 +121,7 @@ DialogMask ErrorHandler::HandleError(ErrCode nErrCodeId, 
weld::Window *pParent,
     if (nErrCodeId == ERRCODE_NONE || nErrCodeId == ERRCODE_ABORT)
         return DialogMask::NONE;
 
-    ErrorRegistry &rData = TheErrorRegistry::get();
+    ErrorRegistry &rData = GetErrorRegistry();
     std::unique_ptr<ErrorInfo> pInfo = ErrorInfo::GetErrorInfo(nErrCodeId);
     OUString aAction;
 
@@ -195,18 +198,18 @@ ErrorContext::ErrorContext(weld::Window *pWinP)
     : pImpl( new ImplErrorContext )
 {
     pImpl->pWin = pWinP;
-    
TheErrorRegistry::get().contexts.insert(TheErrorRegistry::get().contexts.begin(),
 this);
+    GetErrorRegistry().contexts.insert(GetErrorRegistry().contexts.begin(), 
this);
 }
 
 ErrorContext::~ErrorContext()
 {
-    auto &rContexts = TheErrorRegistry::get().contexts;
+    auto &rContexts = GetErrorRegistry().contexts;
     rContexts.erase( ::std::remove(rContexts.begin(), rContexts.end(), this), 
rContexts.end());
 }
 
 ErrorContext *ErrorContext::GetContext()
 {
-    return TheErrorRegistry::get().contexts.empty() ? nullptr : 
TheErrorRegistry::get().contexts.front();
+    return GetErrorRegistry().contexts.empty() ? nullptr : 
GetErrorRegistry().contexts.front();
 }
 
 weld::Window* ErrorContext::GetParent()
@@ -236,7 +239,7 @@ private:
 void ImplDynamicErrorInfo::RegisterError(DynamicErrorInfo *pDynErrInfo)
 {
     // Register dynamic identifier
-    ErrorRegistry& rData = TheErrorRegistry::get();
+    ErrorRegistry& rData = GetErrorRegistry();
     nErrId = ErrCode(((sal_uInt32(rData.nNextError) + 1) << 
ERRCODE_DYNAMIC_SHIFT) +
                      sal_uInt32(pDynErrInfo->GetErrorCode()));
 
@@ -251,7 +254,7 @@ void ImplDynamicErrorInfo::RegisterError(DynamicErrorInfo 
*pDynErrInfo)
 
 void ImplDynamicErrorInfo::UnRegisterError(DynamicErrorInfo const *pDynErrInfo)
 {
-    DynamicErrorInfo **ppDynErrInfo = TheErrorRegistry::get().ppDynErrInfo;
+    DynamicErrorInfo **ppDynErrInfo = GetErrorRegistry().ppDynErrInfo;
     sal_uInt32 nIdx = ErrCode(*pDynErrInfo).GetDynamic() - 1;
     DBG_ASSERT(ppDynErrInfo[nIdx] == pDynErrInfo, "ErrHdl: Error not found");
 
@@ -262,7 +265,7 @@ void ImplDynamicErrorInfo::UnRegisterError(DynamicErrorInfo 
const *pDynErrInfo)
 std::unique_ptr<ErrorInfo> ImplDynamicErrorInfo::GetDynamicErrorInfo(ErrCode 
nId)
 {
     sal_uInt32 nIdx = nId.GetDynamic() - 1;
-    DynamicErrorInfo* pDynErrInfo = TheErrorRegistry::get().ppDynErrInfo[nIdx];
+    DynamicErrorInfo* pDynErrInfo = GetErrorRegistry().ppDynErrInfo[nIdx];
 
     if(pDynErrInfo && ErrCode(*pDynErrInfo)==nId)
         return std::unique_ptr<ErrorInfo>(pDynErrInfo);
diff --git a/vcl/unx/generic/printer/ppdparser.cxx 
b/vcl/unx/generic/printer/ppdparser.cxx
index 8de73fa860b1..d049a67d60c7 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -41,7 +41,6 @@
 #include <osl/thread.h>
 #include <rtl/strbuf.hxx>
 #include <rtl/ustrbuf.hxx>
-#include <rtl/instance.hxx>
 #include <sal/log.hxx>
 #include <salhelper/linkhelper.hxx>
 
@@ -253,7 +252,11 @@ using namespace psp;
 
 namespace
 {
-    struct thePPDCache : public rtl::Static<PPDCache, thePPDCache> {};
+    PPDCache& getPPDCache()
+    {
+        static PPDCache thePPDCache;
+        return thePPDCache;
+    }
 
 class PPDDecompressStream
 {
@@ -385,7 +388,7 @@ void PPDParser::scanPPDDir( const OUString& rDir )
     } const pSuffixes[] =
     { { ".PS", 3 },  { ".PPD", 4 }, { ".PS.GZ", 6 }, { ".PPD.GZ", 7 } };
 
-    PPDCache &rPPDCache = thePPDCache::get();
+    PPDCache &rPPDCache = getPPDCache();
 
     osl::Directory aDir( rDir );
     if ( aDir.open() != osl::FileBase::E_None )
@@ -474,7 +477,7 @@ OUString PPDParser::getPPDFile( const OUString& rFile )
     if( ! aStream.IsOpen() )
     {
         std::unordered_map< OUString, OUString >::const_iterator it;
-        PPDCache &rPPDCache = thePPDCache::get();
+        PPDCache &rPPDCache = getPPDCache();
 
         bool bRetry = true;
         do
@@ -548,7 +551,7 @@ const PPDParser* PPDParser::getParser( const OUString& 
rFile )
                  << rFile << "\" !");
 
 
-    PPDCache &rPPDCache = thePPDCache::get();
+    PPDCache &rPPDCache = getPPDCache();
     for( auto const & i : rPPDCache.aAllParsers )
         if( i->m_aFile == aFile )
             return i.get();
diff --git a/writerfilter/source/dmapper/TagLogger.cxx 
b/writerfilter/source/dmapper/TagLogger.cxx
index 1e9c14aa8066..607f01aaf42f 100644
--- a/writerfilter/source/dmapper/TagLogger.cxx
+++ b/writerfilter/source/dmapper/TagLogger.cxx
@@ -92,17 +92,10 @@ namespace writerfilter
 
 #endif
 
-namespace {
-
-struct TheTagLogger:
-    public rtl::Static<TagLogger, TheTagLogger>
-{};
-
-}
-
     TagLogger& TagLogger::getInstance()
     {
-        return TheTagLogger::get();
+        static TagLogger theTagLogger;
+        return theTagLogger;
     }
 
 #ifdef DBG_UTIL
diff --git a/xmlsecurity/source/component/certificatecontainer.cxx 
b/xmlsecurity/source/component/certificatecontainer.cxx
index e311b1b600f8..e230c7b2ce83 100644
--- a/xmlsecurity/source/component/certificatecontainer.cxx
+++ b/xmlsecurity/source/component/certificatecontainer.cxx
@@ -141,30 +141,12 @@ CertificateContainer::getSupportedServiceNames(  )
     return { "com.sun.star.security.CertificateContainer" };
 }
 
-namespace
-{
-struct Instance
-{
-    explicit Instance(css::uno::Reference<css::uno::XComponentContext> const& 
context)
-        : instance(new CertificateContainer(context))
-    {
-    }
-
-    rtl::Reference<CertificateContainer> instance;
-};
-
-struct Singleton
-    : public rtl::StaticWithArg<Instance, 
css::uno::Reference<css::uno::XComponentContext>,
-                                Singleton>
-{
-};
-}
-
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
 com_sun_star_security_CertificateContainer_get_implementation(
     css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> 
const&)
 {
-    return cppu::acquire(Singleton::get(context).instance.get());
+    static rtl::Reference<CertificateContainer> gContainer = new 
CertificateContainer(context);
+    return cppu::acquire(gContainer.get());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to