bump product version to 4.1.6.2
[LibreOffice.git] / dbaccess / source / core / resource / core_resource.cxx
blob01284eb516ec95b373f47a4079e48db50736e25f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "core_resource.hxx"
23 #include <tools/resmgr.hxx>
25 // ---- needed as long as we have no contexts for components ---
26 #include <vcl/svapp.hxx>
27 //---------------------------------------------------
28 #include <rtl/instance.hxx>
29 #include <svl/solar.hrc>
31 //.........................................................................
32 namespace dbaccess
35 //==================================================================
36 //= ResourceManager
37 //==================================================================
38 namespace
40 // access safety
41 struct theResourceManagerMutex : public rtl::Static< osl::Mutex, theResourceManagerMutex > {};
44 sal_Int32 ResourceManager::s_nClients = 0;
45 ResMgr* ResourceManager::m_pImpl = NULL;
47 //------------------------------------------------------------------
48 void ResourceManager::ensureImplExists()
50 if (m_pImpl)
51 return;
53 m_pImpl = ResMgr::CreateResMgr("dba", Application::GetSettings().GetUILanguageTag());
56 //------------------------------------------------------------------
57 OUString ResourceManager::loadString(sal_uInt16 _nResId)
59 OUString sReturn;
61 ensureImplExists();
62 if (m_pImpl)
63 sReturn = OUString(ResId(_nResId,*m_pImpl));
65 return sReturn;
68 //------------------------------------------------------------------
69 OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii, const OUString& _rReplace )
71 OUString sString( loadString( _nResId ) );
72 return sString.replaceFirst( OUString::createFromAscii(_pPlaceholderAscii), _rReplace );
75 //------------------------------------------------------------------
76 OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii1, const OUString& _rReplace1,
77 const sal_Char* _pPlaceholderAscii2, const OUString& _rReplace2 )
79 OUString sString( loadString( _nResId ) );
80 sString = sString.replaceFirst( OUString::createFromAscii(_pPlaceholderAscii1), _rReplace1 );
81 sString = sString.replaceFirst( OUString::createFromAscii(_pPlaceholderAscii2), _rReplace2 );
82 return sString;
85 //-------------------------------------------------------------------------
86 void ResourceManager::registerClient()
88 ::osl::MutexGuard aGuard(theResourceManagerMutex::get());
89 ++s_nClients;
92 //-------------------------------------------------------------------------
93 void ResourceManager::revokeClient()
95 ::osl::MutexGuard aGuard(theResourceManagerMutex::get());
96 if (!--s_nClients && m_pImpl)
98 delete m_pImpl;
99 m_pImpl = NULL;
102 //.........................................................................
104 //.........................................................................
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */