diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-01-27 12:31:29 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-01-27 12:31:29 +0100 |
commit | 3e9a6ba55b112d92b59931df086d899b3354cc27 (patch) | |
tree | 0934844e8e034a8ef7df31c25fcfff459b9315c1 /filter | |
parent | vcl: I don't think calling a data type 'DataType' is very sensible (diff) | |
download | core-3e9a6ba55b112d92b59931df086d899b3354cc27.tar.gz core-3e9a6ba55b112d92b59931df086d899b3354cc27.zip |
Replace salhelper::SingletonRef with rtl::Static
Change-Id: Idc897e2b641a7b2a62e48a43f57dd46cd48df7ad
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/config/cache/basecontainer.cxx | 26 | ||||
-rw-r--r-- | filter/source/config/cache/basecontainer.hxx | 5 | ||||
-rw-r--r-- | filter/source/config/cache/contenthandlerfactory.cxx | 8 | ||||
-rw-r--r-- | filter/source/config/cache/filtercache.hxx | 5 | ||||
-rw-r--r-- | filter/source/config/cache/filterfactory.cxx | 10 | ||||
-rw-r--r-- | filter/source/config/cache/frameloaderfactory.cxx | 8 | ||||
-rw-r--r-- | filter/source/config/cache/typedetection.cxx | 52 |
7 files changed, 54 insertions, 60 deletions
diff --git a/filter/source/config/cache/basecontainer.cxx b/filter/source/config/cache/basecontainer.cxx index 37e50945b2d9..7c449c1b13b0 100644 --- a/filter/source/config/cache/basecontainer.cxx +++ b/filter/source/config/cache/basecontainer.cxx @@ -28,35 +28,19 @@ #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> #include <osl/diagnose.h> -#include <rtl/instance.hxx> #define LOAD_IMPLICIT namespace filter{ namespace config{ - -namespace -{ - typedef ::salhelper::SingletonRef< FilterCache > FilterCacheRefHold; - /** @short hold at least one filter cache instance alive and - prevent the office from unloading this cache if no filter - is currently used.*/ - struct thePerformanceOptimizer : - public rtl::Static<FilterCacheRefHold, thePerformanceOptimizer> - { - }; -} - BaseContainer::BaseContainer() : BaseLock ( ) - , m_rCache ( ) , m_pFlushCache(nullptr ) , m_eType() , m_lListener (m_aLock) { - m_rCache->load(FilterCache::E_CONTAINS_STANDARD); - thePerformanceOptimizer::get(); + TheFilterCache::get().load(FilterCache::E_CONTAINS_STANDARD); } @@ -114,7 +98,7 @@ void BaseContainer::impl_loadOnDemand() break; } - m_rCache->load(eRequiredState); + TheFilterCache::get().load(eRequiredState); // <- SAFE #endif } @@ -127,7 +111,7 @@ void BaseContainer::impl_initFlushMode() // SAFE -> ::osl::ResettableMutexGuard aLock(m_aLock); if (!m_pFlushCache) - m_pFlushCache = m_rCache->clone(); + m_pFlushCache = TheFilterCache::get().clone(); if (!m_pFlushCache) throw css::uno::RuntimeException( "Can not create write copy of internal used cache on demand.", static_cast< OWeakObject* >(this)); @@ -143,7 +127,7 @@ FilterCache* BaseContainer::impl_getWorkingCache() const if (m_pFlushCache) return m_pFlushCache; else - return &(*m_rCache); + return &TheFilterCache::get(); // <- SAFE } @@ -492,7 +476,7 @@ void SAL_CALL BaseContainer::flush() If the global cache gets this information via listener, we should remove this method! */ - m_rCache->takeOver(*m_pFlushCache); + TheFilterCache::get().takeOver(*m_pFlushCache); } catch(const css::uno::Exception& ex) { diff --git a/filter/source/config/cache/basecontainer.hxx b/filter/source/config/cache/basecontainer.hxx index 79c7aff77b60..df104b1459e6 100644 --- a/filter/source/config/cache/basecontainer.hxx +++ b/filter/source/config/cache/basecontainer.hxx @@ -28,7 +28,6 @@ #include <com/sun/star/container/XContainerQuery.hpp> #include <com/sun/star/util/XFlushable.hpp> #include <cppuhelper/interfacecontainer.h> -#include <salhelper/singletonref.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/weakref.hxx> #include <rtl/ustring.hxx> @@ -75,10 +74,6 @@ class BaseContainer : public BaseLock at the interface XServiceInfo of our class ... */ css::uno::Sequence< OUString > m_lServiceNames; - /** @short reference(!) to a singleton filter cache implementation, - which is used to work with the underlying configuration. */ - ::salhelper::SingletonRef< FilterCache > m_rCache; - /** @short local filter cache, which is used to collect changes on the filter configuration first and flush it later. diff --git a/filter/source/config/cache/contenthandlerfactory.cxx b/filter/source/config/cache/contenthandlerfactory.cxx index 38afa0689bcc..4e1b2b4c777f 100644 --- a/filter/source/config/cache/contenthandlerfactory.cxx +++ b/filter/source/config/cache/contenthandlerfactory.cxx @@ -79,7 +79,9 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL ContentHandlerFactory::crea type name instead of a handler name. For a small migration time we must simulate this old feature :-( */ - if (!m_rCache->hasItem(FilterCache::E_CONTENTHANDLER, sHandler) && m_rCache->hasItem(FilterCache::E_TYPE, sHandler)) + auto & cache = TheFilterCache::get(); + + if (!cache.hasItem(FilterCache::E_CONTENTHANDLER, sHandler) && cache.hasItem(FilterCache::E_TYPE, sHandler)) { _FILTER_CONFIG_LOG_("ContentHandlerFactory::createInstanceWithArguments() ... simulate old type search functionality!\n"); @@ -97,7 +99,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL ContentHandlerFactory::crea // prevent outside code against NoSuchElementException! // But don't implement such defensive strategy for our new create handling :-) - if (!m_rCache->hasItem(FilterCache::E_CONTENTHANDLER, sRealHandler)) + if (!cache.hasItem(FilterCache::E_CONTENTHANDLER, sRealHandler)) return css::uno::Reference< css::uno::XInterface>(); } @@ -106,7 +108,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL ContentHandlerFactory::crea #endif // _FILTER_CONFIG_MIGRATION_Q_ // search handler on cache - CacheItem aHandler = m_rCache->getItem(FilterCache::E_CONTENTHANDLER, sRealHandler); + CacheItem aHandler = cache.getItem(FilterCache::E_CONTENTHANDLER, sRealHandler); // create service instance xHandler = m_xContext->getServiceManager()->createInstanceWithContext(sRealHandler, m_xContext); diff --git a/filter/source/config/cache/filtercache.hxx b/filter/source/config/cache/filtercache.hxx index a98684957065..aa8b50b27c6b 100644 --- a/filter/source/config/cache/filtercache.hxx +++ b/filter/source/config/cache/filtercache.hxx @@ -31,6 +31,7 @@ #include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Any.h> #include <comphelper/documentconstants.hxx> +#include <rtl/instance.hxx> #include <rtl/ref.hxx> #include <rtl/ustring.hxx> @@ -276,7 +277,7 @@ class FilterCache : public BaseLock /** @short standard dtor. */ - virtual ~FilterCache(); + ~FilterCache(); @@ -977,6 +978,8 @@ class FilterCache : public BaseLock static css::uno::Sequence< OUString > impl_convertFlagField2FlagNames(SfxFilterFlags nFlags); }; +struct TheFilterCache: public rtl::Static<FilterCache, TheFilterCache> {}; + } // namespace config } // namespace filter diff --git a/filter/source/config/cache/filterfactory.cxx b/filter/source/config/cache/filterfactory.cxx index 4577415798c0..07acb6457313 100644 --- a/filter/source/config/cache/filterfactory.cxx +++ b/filter/source/config/cache/filterfactory.cxx @@ -95,7 +95,9 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::createInstan type name instead of a filter name. For a small migration time we must simulate this old feature :-( */ - if (!m_rCache->hasItem(FilterCache::E_FILTER, sFilter) && m_rCache->hasItem(FilterCache::E_TYPE, sFilter)) + auto & cache = TheFilterCache::get(); + + if (!cache.hasItem(FilterCache::E_FILTER, sFilter) && cache.hasItem(FilterCache::E_TYPE, sFilter)) { OSL_FAIL("Who use this deprecated functionality?"); _FILTER_CONFIG_LOG_("FilterFactory::createInstanceWithArguments() ... simulate old type search functionality!\n"); @@ -112,7 +114,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::createInstan // prevent outside code against NoSuchElementException! // But don't implement such defensive strategy for our new create handling :-) - if (!m_rCache->hasItem(FilterCache::E_FILTER, sRealFilter)) + if (!cache.hasItem(FilterCache::E_FILTER, sRealFilter)) return css::uno::Reference< css::uno::XInterface>(); } @@ -121,7 +123,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::createInstan #endif // _FILTER_CONFIG_MIGRATION_Q_ // search filter on cache - CacheItem aFilter = m_rCache->getItem(FilterCache::E_FILTER, sRealFilter); + CacheItem aFilter = cache.getItem(FilterCache::E_FILTER, sRealFilter); OUString sFilterService; aFilter[PROPNAME_FILTERSERVICE] >>= sFilterService; @@ -169,7 +171,7 @@ css::uno::Sequence< OUString > SAL_CALL FilterFactory::getAvailableServiceNames( OUStringList lUNOFilters; try { - lUNOFilters = m_rCache->getMatchingItemsByProps(FilterCache::E_FILTER, lIProps, lEProps); + lUNOFilters = TheFilterCache::get().getMatchingItemsByProps(FilterCache::E_FILTER, lIProps, lEProps); } catch(const css::uno::RuntimeException&) { throw; } diff --git a/filter/source/config/cache/frameloaderfactory.cxx b/filter/source/config/cache/frameloaderfactory.cxx index d2bcf6fd0d40..f53f0c9ff989 100644 --- a/filter/source/config/cache/frameloaderfactory.cxx +++ b/filter/source/config/cache/frameloaderfactory.cxx @@ -76,7 +76,9 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FrameLoaderFactory::createI type name instead of a loader name. For a small migration time we must simulate this old feature :-( */ - if (!m_rCache->hasItem(FilterCache::E_FRAMELOADER, sLoader) && m_rCache->hasItem(FilterCache::E_TYPE, sLoader)) + auto & cache = TheFilterCache::get(); + + if (!cache.hasItem(FilterCache::E_FRAMELOADER, sLoader) && cache.hasItem(FilterCache::E_TYPE, sLoader)) { _FILTER_CONFIG_LOG_("FrameLoaderFactory::createInstanceWithArguments() ... simulate old type search functionality!\n"); @@ -94,7 +96,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FrameLoaderFactory::createI // prevent outside code against NoSuchElementException! // But don't implement such defensive strategy for our new create handling :-) - if (!m_rCache->hasItem(FilterCache::E_FRAMELOADER, sRealLoader)) + if (!cache.hasItem(FilterCache::E_FRAMELOADER, sRealLoader)) return css::uno::Reference< css::uno::XInterface>(); } @@ -103,7 +105,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FrameLoaderFactory::createI #endif // _FILTER_CONFIG_MIGRATION_Q_ // search loader on cache - CacheItem aLoader = m_rCache->getItem(m_eType, sRealLoader); + CacheItem aLoader = cache.getItem(m_eType, sRealLoader); // create service instance css::uno::Reference< css::uno::XInterface > xLoader = m_xContext->getServiceManager()->createInstanceWithContext(sRealLoader, m_xContext); diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx index 2a11e45b7a2d..4031c93271a0 100644 --- a/filter/source/config/cache/typedetection.cxx +++ b/filter/source/config/cache/typedetection.cxx @@ -81,16 +81,17 @@ OUString SAL_CALL TypeDetection::queryTypeByURL(const OUString& sURL) // set std types as minimum requirement first! // Only in case no type was found for given URL, // use optional types too ... + auto & cache = TheFilterCache::get(); FlatDetection lFlatTypes; - m_rCache->detectFlatForURL(aURL, lFlatTypes); + cache.detectFlatForURL(aURL, lFlatTypes); if ( (lFlatTypes.size() < 1 ) && - (!m_rCache->isFillState(FilterCache::E_CONTAINS_TYPES)) + (!cache.isFillState(FilterCache::E_CONTAINS_TYPES)) ) { - m_rCache->load(FilterCache::E_CONTAINS_TYPES); - m_rCache->detectFlatForURL(aURL, lFlatTypes); + cache.load(FilterCache::E_CONTAINS_TYPES); + cache.detectFlatForURL(aURL, lFlatTypes); } // first item is guaranteed as "preferred" one! @@ -479,6 +480,8 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes if (!sFilter.isEmpty()) return; + auto & cache = TheFilterCache::get(); + // b) // check a preselected document service too. // Then we have to search a suitable filter within this module. @@ -497,12 +500,12 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes // Attention: For executing next lines of code, We must be sure that // all filters already loaded :-( // That can disturb our "load on demand feature". But we have no other chance! - m_rCache->load(FilterCache::E_CONTAINS_FILTERS); + cache.load(FilterCache::E_CONTAINS_FILTERS); CacheItem lIProps; lIProps[PROPNAME_DOCUMENTSERVICE] <<= sDocumentService; lIProps[PROPNAME_TYPE ] <<= sRealType; - OUStringList lFilters = m_rCache->getMatchingItemsByProps(FilterCache::E_FILTER, lIProps); + OUStringList lFilters = cache.getMatchingItemsByProps(FilterCache::E_FILTER, lIProps); aLock.clear(); // <- SAFE @@ -514,7 +517,7 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes aLock.reset(); try { - CacheItem aFilter = m_rCache->getItem(FilterCache::E_FILTER, *pIt); + CacheItem aFilter = cache.getItem(FilterCache::E_FILTER, *pIt); sal_Int32 nFlags = 0; aFilter[PROPNAME_FLAGS] >>= nFlags; @@ -553,9 +556,9 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes // SAFE -> ::osl::ResettableMutexGuard aLock(m_aLock); - CacheItem aType = m_rCache->getItem(FilterCache::E_TYPE, sType); + CacheItem aType = cache.getItem(FilterCache::E_TYPE, sType); aType[PROPNAME_PREFERREDFILTER] >>= sFilter; - CacheItem aFilter = m_rCache->getItem(FilterCache::E_FILTER, sFilter); + CacheItem aFilter = cache.getItem(FilterCache::E_FILTER, sFilter); aLock.clear(); // <- SAFE @@ -579,11 +582,11 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes // Attention: For executing next lines of code, We must be sure that // all filters already loaded :-( // That can disturb our "load on demand feature". But we have no other chance! - m_rCache->load(FilterCache::E_CONTAINS_FILTERS); + cache.load(FilterCache::E_CONTAINS_FILTERS); CacheItem lIProps; lIProps[PROPNAME_TYPE] <<= sType; - OUStringList lFilters = m_rCache->getMatchingItemsByProps(FilterCache::E_FILTER, lIProps); + OUStringList lFilters = cache.getMatchingItemsByProps(FilterCache::E_FILTER, lIProps); aLock.clear(); // <- SAFE @@ -599,7 +602,7 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes aLock.reset(); try { - CacheItem aFilter = m_rCache->getItem(FilterCache::E_FILTER, sFilter); + CacheItem aFilter = cache.getItem(FilterCache::E_FILTER, sFilter); sal_Int32 nFlags = 0; aFilter[PROPNAME_FLAGS] >>= nFlags; @@ -651,7 +654,7 @@ bool TypeDetection::impl_getPreselectionForType( { // SAFE -> -------------------------- ::osl::ResettableMutexGuard aLock(m_aLock); - aType = m_rCache->getItem(FilterCache::E_TYPE, sType); + aType = TheFilterCache::get().getItem(FilterCache::E_TYPE, sType); aLock.clear(); // <- SAFE -------------------------- } @@ -746,11 +749,12 @@ bool TypeDetection::impl_getPreselectionForDocumentService( // Attention: For executing next lines of code, We must be sure that // all filters already loaded :-( // That can disturb our "load on demand feature". But we have no other chance! - m_rCache->load(FilterCache::E_CONTAINS_FILTERS); + auto & cache = TheFilterCache::get(); + cache.load(FilterCache::E_CONTAINS_FILTERS); CacheItem lIProps; lIProps[PROPNAME_DOCUMENTSERVICE] <<= sPreSelDocumentService; - lFilters = m_rCache->getMatchingItemsByProps(FilterCache::E_FILTER, lIProps); + lFilters = cache.getMatchingItemsByProps(FilterCache::E_FILTER, lIProps); aLock.clear(); // <- SAFE -------------------------- @@ -785,7 +789,7 @@ OUString TypeDetection::impl_getTypeFromFilter(const OUString& rFilterName) try { osl::MutexGuard aLock(m_aLock); - aFilter = m_rCache->getItem(FilterCache::E_FILTER, rFilterName); + aFilter = TheFilterCache::get().getItem(FilterCache::E_FILTER, rFilterName); } catch (const container::NoSuchElementException&) { @@ -807,8 +811,9 @@ void TypeDetection::impl_getAllFormatTypes( try { osl::MutexGuard aLock(m_aLock); - m_rCache->load(FilterCache::E_CONTAINS_FILTERS); - aFilterNames = m_rCache->getItemNames(FilterCache::E_FILTER); + auto & cache = TheFilterCache::get(); + cache.load(FilterCache::E_CONTAINS_FILTERS); + aFilterNames = cache.getItemNames(FilterCache::E_FILTER); } catch (const container::NoSuchElementException&) { @@ -831,7 +836,7 @@ void TypeDetection::impl_getAllFormatTypes( { // Get all types that match the URL alone. FlatDetection aFlatByURL; - m_rCache->detectFlatForURL(aParsedURL, aFlatByURL); + TheFilterCache::get().detectFlatForURL(aParsedURL, aFlatByURL); FlatDetection::const_iterator it = aFlatByURL.begin(), itEnd = aFlatByURL.end(); for (; it != itEnd; ++it) { @@ -920,7 +925,7 @@ OUString TypeDetection::impl_detectTypeFlatAndDeep( utl::MediaDescriptor& r { // SAFE -> ---------------------------------- ::osl::ResettableMutexGuard aLock(m_aLock); - CacheItem aType = m_rCache->getItem(FilterCache::E_TYPE, sFlatType); + CacheItem aType = TheFilterCache::get().getItem(FilterCache::E_TYPE, sFlatType); aLock.clear(); OUString sDetectService; @@ -1178,7 +1183,7 @@ bool TypeDetection::impl_validateAndSetTypeOnDescriptor( utl::MediaDescript { // SAFE -> ::osl::ResettableMutexGuard aLock(m_aLock); - if (m_rCache->hasItem(FilterCache::E_TYPE, sType)) + if (TheFilterCache::get().hasItem(FilterCache::E_TYPE, sType)) { rDescriptor[utl::MediaDescriptor::PROP_TYPENAME()] <<= sType; return true; @@ -1201,10 +1206,11 @@ bool TypeDetection::impl_validateAndSetFilterOnDescriptor( utl::MediaDescri // SAFE -> ::osl::ResettableMutexGuard aLock(m_aLock); - CacheItem aFilter = m_rCache->getItem(FilterCache::E_FILTER, sFilter); + auto & cache = TheFilterCache::get(); + CacheItem aFilter = cache.getItem(FilterCache::E_FILTER, sFilter); OUString sType; aFilter[PROPNAME_TYPE] >>= sType; - CacheItem aType = m_rCache->getItem(FilterCache::E_TYPE, sType); + CacheItem aType = cache.getItem(FilterCache::E_TYPE, sType); aLock.clear(); // <- SAFE |