1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10*96de5490SAndrew Rist * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*96de5490SAndrew Rist * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19*96de5490SAndrew Rist * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "core_resource.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <tools/resmgr.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir // ---- needed as long as we have no contexts for components --- 32cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX 33cdf0e10cSrcweir #include <vcl/svapp.hxx> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir //--------------------------------------------------- 36cdf0e10cSrcweir 37cdf0e10cSrcweir #ifndef _SOLAR_HRC 38cdf0e10cSrcweir #include <svl/solar.hrc> 39cdf0e10cSrcweir #endif 40cdf0e10cSrcweir 41cdf0e10cSrcweir //......................................................................... 42cdf0e10cSrcweir namespace dbaccess 43cdf0e10cSrcweir { 44cdf0e10cSrcweir 45cdf0e10cSrcweir //================================================================== 46cdf0e10cSrcweir //= ResourceManager 47cdf0e10cSrcweir //================================================================== 48cdf0e10cSrcweir ::osl::Mutex ResourceManager::s_aMutex; 49cdf0e10cSrcweir sal_Int32 ResourceManager::s_nClients = 0; 50cdf0e10cSrcweir ResMgr* ResourceManager::m_pImpl = NULL; 51cdf0e10cSrcweir 52cdf0e10cSrcweir //------------------------------------------------------------------ ensureImplExists()53cdf0e10cSrcweir void ResourceManager::ensureImplExists() 54cdf0e10cSrcweir { 55cdf0e10cSrcweir if (m_pImpl) 56cdf0e10cSrcweir return; 57cdf0e10cSrcweir 58cdf0e10cSrcweir ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); 59cdf0e10cSrcweir 60cdf0e10cSrcweir ByteString sFileName("dba"); 61cdf0e10cSrcweir 62cdf0e10cSrcweir m_pImpl = ResMgr::CreateResMgr(sFileName.GetBuffer(), aLocale); 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir //------------------------------------------------------------------ loadString(sal_uInt16 _nResId)66cdf0e10cSrcweir ::rtl::OUString ResourceManager::loadString(sal_uInt16 _nResId) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir ::rtl::OUString sReturn; 69cdf0e10cSrcweir 70cdf0e10cSrcweir ensureImplExists(); 71cdf0e10cSrcweir if (m_pImpl) 72cdf0e10cSrcweir sReturn = String(ResId(_nResId,*m_pImpl)); 73cdf0e10cSrcweir 74cdf0e10cSrcweir return sReturn; 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir //------------------------------------------------------------------ loadString(sal_uInt16 _nResId,const sal_Char * _pPlaceholderAscii,const::rtl::OUString & _rReplace)78cdf0e10cSrcweir ::rtl::OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii, const ::rtl::OUString& _rReplace ) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir String sString( loadString( _nResId ) ); 81cdf0e10cSrcweir sString.SearchAndReplaceAscii( _pPlaceholderAscii, _rReplace ); 82cdf0e10cSrcweir return sString; 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir //------------------------------------------------------------------ loadString(sal_uInt16 _nResId,const sal_Char * _pPlaceholderAscii1,const::rtl::OUString & _rReplace1,const sal_Char * _pPlaceholderAscii2,const::rtl::OUString & _rReplace2)86cdf0e10cSrcweir ::rtl::OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii1, const ::rtl::OUString& _rReplace1, 87cdf0e10cSrcweir const sal_Char* _pPlaceholderAscii2, const ::rtl::OUString& _rReplace2 ) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir String sString( loadString( _nResId ) ); 90cdf0e10cSrcweir sString.SearchAndReplaceAscii( _pPlaceholderAscii1, _rReplace1 ); 91cdf0e10cSrcweir sString.SearchAndReplaceAscii( _pPlaceholderAscii2, _rReplace2 ); 92cdf0e10cSrcweir return sString; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir //------------------------------------------------------------------------- registerClient()96cdf0e10cSrcweir void ResourceManager::registerClient() 97cdf0e10cSrcweir { 98cdf0e10cSrcweir ::osl::MutexGuard aGuard(s_aMutex); 99cdf0e10cSrcweir ++s_nClients; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir //------------------------------------------------------------------------- revokeClient()103cdf0e10cSrcweir void ResourceManager::revokeClient() 104cdf0e10cSrcweir { 105cdf0e10cSrcweir ::osl::MutexGuard aGuard(s_aMutex); 106cdf0e10cSrcweir if (!--s_nClients && m_pImpl) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir delete m_pImpl; 109cdf0e10cSrcweir m_pImpl = NULL; 110cdf0e10cSrcweir } 111cdf0e10cSrcweir } 112cdf0e10cSrcweir //......................................................................... 113cdf0e10cSrcweir } 114cdf0e10cSrcweir //......................................................................... 115cdf0e10cSrcweir 116