diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-07-31 17:16:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-08-01 13:42:21 +0100 |
commit | b1d829e52e826b6ea4ae884a64fdb68b66c74dd7 (patch) | |
tree | d6aa2ee59178ecf5ea78e80917df18149ae9bb66 /extensions/source/inc | |
parent | f4e5940abbbaa3c2747108b0954e8912d164f3e5 (diff) |
move resmgr to unotools
and the vast majority of translations is to the ui language so default
ctor with that arg
and now drop OModuleResourceClient
Change-Id: I3b85a560ffdfe5f019c2271ac56a5fe4a361522b
Diffstat (limited to 'extensions/source/inc')
-rw-r--r-- | extensions/source/inc/componentmodule.cxx | 75 | ||||
-rw-r--r-- | extensions/source/inc/componentmodule.hxx | 37 |
2 files changed, 6 insertions, 106 deletions
diff --git a/extensions/source/inc/componentmodule.cxx b/extensions/source/inc/componentmodule.cxx index 619c5472ab6d..40273cf879de 100644 --- a/extensions/source/inc/componentmodule.cxx +++ b/extensions/source/inc/componentmodule.cxx @@ -19,7 +19,7 @@ #include <memory> #include "componentmodule.hxx" -#include <tools/resmgr.hxx> +#include <unotools/resmgr.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <svl/solar.hrc> @@ -27,89 +27,22 @@ #include <tools/debug.hxx> #include <rtl/strbuf.hxx> -#define ENTER_MOD_METHOD() \ - ::osl::MutexGuard aGuard(s_aMutex); \ - ensureImpl() - - namespace compmodule { - - using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::registry; using namespace ::comphelper; using namespace ::cppu; - // implementation for <type>OModule</type>. not threadsafe, has to be guarded by its owner - class OModuleImpl - { - std::locale m_aResLocale; - bool m_bInitialized; - - public: - /// ctor - OModuleImpl(); - - /// get the manager for the resources of the module - const std::locale& getResLocale(); - }; - - - OModuleImpl::OModuleImpl() - : m_bInitialized(false) - { - } - - const std::locale& OModuleImpl::getResLocale() + OUString ModuleRes(const char* pId) { - // note that this method is not threadsafe, which counts for the whole class ! - if (!m_bInitialized) - { - // create a manager with a fixed prefix - m_aResLocale = Translate::Create("pcr", Application::GetSettings().GetUILanguageTag()); - m_bInitialized = true; - } - return m_aResLocale; - } - - ::osl::Mutex OModule::s_aMutex; - sal_Int32 OModule::s_nClients = 0; - OModuleImpl* OModule::s_pImpl = nullptr; - - const std::locale& OModule::getResLocale() - { - ENTER_MOD_METHOD(); - return s_pImpl->getResLocale(); - } - - void OModule::registerClient() - { - ::osl::MutexGuard aGuard(s_aMutex); - ++s_nClients; - } - - void OModule::revokeClient() - { - ::osl::MutexGuard aGuard(s_aMutex); - if (!--s_nClients && s_pImpl) - { - delete s_pImpl; - s_pImpl = nullptr; - } - } - - void OModule::ensureImpl() - { - if (s_pImpl) - return; - s_pImpl = new OModuleImpl(); + static std::locale loc = Translate::Create("pcr"); + return Translate::get(pId, loc); } //- registration helper - std::vector< OUString >* OModule::s_pImplementationNames = nullptr; std::vector< Sequence< OUString > >* OModule::s_pSupportedServices = nullptr; std::vector< ComponentInstantiation >* OModule::s_pCreationFunctionPointers = nullptr; diff --git a/extensions/source/inc/componentmodule.hxx b/extensions/source/inc/componentmodule.hxx index 163b394f7f15..92bb52d1de5a 100644 --- a/extensions/source/inc/componentmodule.hxx +++ b/extensions/source/inc/componentmodule.hxx @@ -26,7 +26,7 @@ */ #include <osl/mutex.hxx> -#include <tools/resmgr.hxx> +#include <unotools/resmgr.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/uno/Sequence.hxx> @@ -47,20 +47,12 @@ typedef css::uno::Reference< css::lang::XSingleServiceFactory > (SAL_CALL *Facto rtl_ModuleCount* ); - class OModuleImpl; class OModule { - friend class OModuleResourceClient; - private: OModule() = delete; //TODO: get rid of this class protected: - // resource administration - static ::osl::Mutex s_aMutex; /// access safety - static sal_Int32 s_nClients; /// number of registered clients - static OModuleImpl* s_pImpl; /// impl class. lives as long as at least one client for the module is registered - // auto registration administration static std::vector< OUString >* s_pImplementationNames; @@ -112,35 +104,10 @@ typedef css::uno::Reference< css::lang::XSingleServiceFactory > (SAL_CALL *Facto const OUString& _rImplementationName, const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxServiceManager ); - - protected: - /// register a client for the module - static void registerClient(); - /// revoke a client for the module - static void revokeClient(); - - private: - /** ensure that the impl class exists - @precond m_aMutex is guarded when this method gets called - */ - static void ensureImpl(); }; - - // base class for objects which uses any global module-specific resources - class OModuleResourceClient - { - public: - OModuleResourceClient() { OModule::registerClient(); } - ~OModuleResourceClient() { OModule::revokeClient(); } - }; - - // specialized ResId, using the resource locale provided by the global module - static inline OUString ModuleRes(const char* pId) - { - return Translate::get(pId, OModule::getResLocale()); - } + OUString ModuleRes(const char* pId); template <class TYPE> class OMultiInstanceAutoRegistration |