summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-11-22 08:56:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-22 12:46:56 +0100
commit06ad764cfb36ece7f054ecb786cc0395346a6a68 (patch)
treef67c2045e736fbbdb67d18255380b2d9288d75e4 /sd
parenta73494cf130866d4e678a1f421df56cdba7441d8 (diff)
improve function-local statics in scripting..svtools
Change-Id: Idf3785a1fbc6fc5b8efbdc4cd363047709f3af91 Reviewed-on: https://gerrit.libreoffice.org/63782 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/core/stlsheet.cxx4
-rw-r--r--sd/source/ui/framework/factories/BasicViewFactory.cxx11
-rw-r--r--sd/source/ui/unoidl/facreg.cxx20
3 files changed, 16 insertions, 19 deletions
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 24f365b30936..3df37e99da6e 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -958,9 +958,7 @@ void SAL_CALL SdStyleSheet::setParentStyle( const OUString& rParentName )
Reference< XPropertySetInfo > SdStyleSheet::getPropertySetInfo()
{
throwIfDisposed();
- static Reference< XPropertySetInfo > xInfo;
- if( !xInfo.is() )
- xInfo = GetStylePropertySet().getPropertySetInfo();
+ static Reference< XPropertySetInfo > xInfo = GetStylePropertySet().getPropertySetInfo();
return xInfo;
}
diff --git a/sd/source/ui/framework/factories/BasicViewFactory.cxx b/sd/source/ui/framework/factories/BasicViewFactory.cxx
index 864f305e6009..d76eccbde220 100644
--- a/sd/source/ui/framework/factories/BasicViewFactory.cxx
+++ b/sd/source/ui/framework/factories/BasicViewFactory.cxx
@@ -439,17 +439,18 @@ bool BasicViewFactory::IsCacheable (const std::shared_ptr<ViewDescriptor>& rpDes
Reference<XRelocatableResource> xResource (rpDescriptor->mxView, UNO_QUERY);
if (xResource.is())
{
- static ::std::vector<Reference<XResourceId> > s_aCacheableResources;
- if (s_aCacheableResources.empty() )
+ static ::std::vector<Reference<XResourceId> > s_aCacheableResources = [&]()
{
+ ::std::vector<Reference<XResourceId> > tmp;
std::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(*mpBase));
// The slide sorter and the task panel are cacheable and relocatable.
- s_aCacheableResources.push_back(FrameworkHelper::CreateResourceId(
+ tmp.push_back(FrameworkHelper::CreateResourceId(
FrameworkHelper::msSlideSorterURL, FrameworkHelper::msLeftDrawPaneURL));
- s_aCacheableResources.push_back(FrameworkHelper::CreateResourceId(
+ tmp.push_back(FrameworkHelper::CreateResourceId(
FrameworkHelper::msSlideSorterURL, FrameworkHelper::msLeftImpressPaneURL));
- }
+ return tmp;
+ }();
::std::vector<Reference<XResourceId> >::const_iterator iId;
for (iId=s_aCacheableResources.begin(); iId!=s_aCacheableResources.end(); ++iId)
diff --git a/sd/source/ui/unoidl/facreg.cxx b/sd/source/ui/unoidl/facreg.cxx
index 7b69d936ea9e..d4dc0533bfcf 100644
--- a/sd/source/ui/unoidl/facreg.cxx
+++ b/sd/source/ui/unoidl/facreg.cxx
@@ -44,16 +44,14 @@ enum FactoryId
typedef std::unordered_map<OUString, FactoryId> FactoryMap;
namespace {
-static std::shared_ptr<FactoryMap> spFactoryMap;
-std::shared_ptr<FactoryMap> const & GetFactoryMap()
+FactoryMap const & GetFactoryMap()
{
- if (spFactoryMap == nullptr)
+ static FactoryMap aFactoryMap
{
- spFactoryMap.reset(new FactoryMap);
- (*spFactoryMap)[SdDrawingDocument_getImplementationName()] = SdDrawingDocumentFactoryId;
- (*spFactoryMap)[SdPresentationDocument_getImplementationName()] = SdPresentationDocumentFactoryId;
- }
- return spFactoryMap;
+ { SdDrawingDocument_getImplementationName(), SdDrawingDocumentFactoryId },
+ { SdPresentationDocument_getImplementationName(), SdPresentationDocumentFactoryId }
+ };
+ return aFactoryMap;
};
} // end of anonymous namespace
@@ -74,10 +72,10 @@ SAL_DLLPUBLIC_EXPORT void * sd_component_getFactory(
uno::Reference<lang::XSingleServiceFactory> xFactory;
uno::Reference<lang::XSingleComponentFactory> xComponentFactory;
- const std::shared_ptr<FactoryMap>& pFactoryMap (GetFactoryMap());
+ const FactoryMap& rFactoryMap (GetFactoryMap());
OUString sImplementationName (OUString::createFromAscii(pImplName));
- FactoryMap::const_iterator iFactory (pFactoryMap->find(sImplementationName));
- if (iFactory != pFactoryMap->end())
+ FactoryMap::const_iterator iFactory (rFactoryMap.find(sImplementationName));
+ if (iFactory != rFactoryMap.end())
{
switch (iFactory->second)
{