diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-08-01 13:50:45 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-08-02 10:36:07 +0200 |
commit | 13fac4894f752e922727c6f22c6303712e06ba12 (patch) | |
tree | 5689829e917927bb13461d91988ec99e461f1831 /formula/source/core | |
parent | 13cadf3fe38daa0b4cfddcfa68ec8631bc85f44a (diff) |
normalize resource locale ctor construction mechanisms
make them all the same and share std::locales more
various OModuleClient, etc, classes go away
Change-Id: I7e3ff01a69332eeacd22e3078f66a60318de62d5
Reviewed-on: https://gerrit.libreoffice.org/40634
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'formula/source/core')
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 4 | ||||
-rw-r--r-- | formula/source/core/inc/core_resource.hxx | 72 | ||||
-rw-r--r-- | formula/source/core/resource/core_resource.cxx | 60 |
3 files changed, 6 insertions, 130 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 5ff5067505c6..0377fd761df3 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -235,7 +235,7 @@ void OpCodeList::putDefaultOpCode( const FormulaCompiler::NonConstOpCodeMapPtr& } if (!pKey) return; - OUString sKey = !mbLocalized ? OUString::createFromAscii(pKey) : Translate::get(pKey, ResourceManager::getResLocale()); + OUString sKey = !mbLocalized ? OUString::createFromAscii(pKey) : ForResId(pKey); xMap->putOpCode(sKey, OpCode(nOp), pCharClass); } @@ -853,7 +853,6 @@ void lcl_fillNativeSymbols( FormulaCompiler::NonConstOpCodeMapPtr& xMap, bool bD aSymbolMap.mxSymbolMap.reset( new FormulaCompiler::OpCodeMap( SC_OPCODE_LAST_OPCODE_ID + 1, true, FormulaGrammar::GRAM_NATIVE_UI)); - OModuleClient aModuleClient; OpCodeList aOpCodeListSymbols(false, RID_STRLIST_FUNCTION_NAMES_SYMBOLS, aSymbolMap.mxSymbolMap); OpCodeList aOpCodeListNative(true, RID_STRLIST_FUNCTION_NAMES, aSymbolMap.mxSymbolMap); // No AddInMap for native core mapping. @@ -949,7 +948,6 @@ void FormulaCompiler::loadSymbols(const std::pair<const char*, int>* pSymbols, F { // not Core rxMap.reset( new OpCodeMap( SC_OPCODE_LAST_OPCODE_ID + 1, eGrammar != FormulaGrammar::GRAM_ODFF, eGrammar )); - OModuleClient aModuleClient; OpCodeList aOpCodeList(false, pSymbols, rxMap, eSepType); fillFromAddInMap( rxMap, eGrammar); diff --git a/formula/source/core/inc/core_resource.hxx b/formula/source/core/inc/core_resource.hxx deleted file mode 100644 index 3dc321b57834..000000000000 --- a/formula/source/core/inc/core_resource.hxx +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_FORMULA_SOURCE_CORE_INC_CORE_RESOURCE_HXX -#define INCLUDED_FORMULA_SOURCE_CORE_INC_CORE_RESOURCE_HXX - -#include <rtl/ustring.hxx> - -namespace formula -{ - - //= ResourceManager - //= handling resources within the FORMULA-Core library - - class ResourceManager - { - friend class OModuleClient; - static sal_Int32 s_nClients; /// number of registered clients - static std::locale* m_pImpl; - - private: - // no instantiation allowed - ResourceManager() = delete; - ~ResourceManager() { } - - protected: - static void ensureImplExists(); - /// register a client for the module - static void registerClient(); - /// revoke a client for the module - static void revokeClient(); - - public: - - static const std::locale& getResLocale(); - }; - - - //= OModuleClient - - /** base class for objects which uses any global module-specific resources - */ - class OModuleClient - { - public: - OModuleClient() { ResourceManager::registerClient(); } - ~OModuleClient() { ResourceManager::revokeClient(); } - }; - - -} // formula - - -#endif // INCLUDED_FORMULA_SOURCE_CORE_INC_CORE_RESOURCE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/formula/source/core/resource/core_resource.cxx b/formula/source/core/resource/core_resource.cxx index 5163d41b5ae7..d68ab6b193a8 100644 --- a/formula/source/core/resource/core_resource.cxx +++ b/formula/source/core/resource/core_resource.cxx @@ -16,63 +16,13 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#include "core_resource.hxx" - #include <unotools/resmgr.hxx> +#include "core_resource.hxx" -// ---- needed as long as we have no contexts for components --- -#include <rtl/instance.hxx> -#include <svl/solar.hrc> - - -namespace formula +OUString ForResId(const char *pId) { - - - //= ResourceManager - - namespace - { - // access safety - struct theResourceManagerMutex : public rtl::Static< osl::Mutex, theResourceManagerMutex > {}; - } - - sal_Int32 ResourceManager::s_nClients = 0; - std::locale* ResourceManager::m_pImpl = nullptr; - - void ResourceManager::ensureImplExists() - { - if (m_pImpl) - return; - - m_pImpl = new std::locale(Translate::Create("for")); - } - - void ResourceManager::registerClient() - { - ::osl::MutexGuard aGuard(theResourceManagerMutex::get()); - ++s_nClients; - } - - void ResourceManager::revokeClient() - { - ::osl::MutexGuard aGuard(theResourceManagerMutex::get()); - if (!--s_nClients && m_pImpl) - { - delete m_pImpl; - m_pImpl = nullptr; - } - } - - const std::locale& ResourceManager::getResLocale() - { - ensureImplExists(); - return *m_pImpl; - } - - -} // formula - + static std::locale loc = Translate::Create("for"); + return Translate::get(pId, loc); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |