update dev300-m58
[ooovba.git] / dbaccess / source / core / resource / core_resource.cxx
blob474a5d3b31cdb12439a93f9649804c4f6467c2ba
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: core_resource.cxx,v $
10 * $Revision: 1.11.68.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #include "core_resource.hxx"
36 #include <tools/resmgr.hxx>
38 // ---- needed as long as we have no contexts for components ---
39 #ifndef _SV_SVAPP_HXX
40 #include <vcl/svapp.hxx>
41 #endif
42 //---------------------------------------------------
44 #ifndef _SOLAR_HRC
45 #include <svtools/solar.hrc>
46 #endif
48 //.........................................................................
49 namespace dbaccess
52 //==================================================================
53 //= ResourceManager
54 //==================================================================
55 ::osl::Mutex ResourceManager::s_aMutex;
56 sal_Int32 ResourceManager::s_nClients = 0;
57 ResMgr* ResourceManager::m_pImpl = NULL;
59 //------------------------------------------------------------------
60 void ResourceManager::ensureImplExists()
62 if (m_pImpl)
63 return;
65 ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
67 ByteString sFileName("dba");
69 m_pImpl = ResMgr::CreateResMgr(sFileName.GetBuffer(), aLocale);
72 //------------------------------------------------------------------
73 ::rtl::OUString ResourceManager::loadString(sal_uInt16 _nResId)
75 ::rtl::OUString sReturn;
77 ensureImplExists();
78 if (m_pImpl)
79 sReturn = String(ResId(_nResId,*m_pImpl));
81 return sReturn;
84 //------------------------------------------------------------------
85 ::rtl::OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii, const ::rtl::OUString& _rReplace )
87 String sString( loadString( _nResId ) );
88 sString.SearchAndReplaceAscii( _pPlaceholderAscii, _rReplace );
89 return sString;
91 //-------------------------------------------------------------------------
92 void ResourceManager::registerClient()
94 ::osl::MutexGuard aGuard(s_aMutex);
95 ++s_nClients;
98 //-------------------------------------------------------------------------
99 void ResourceManager::revokeClient()
101 ::osl::MutexGuard aGuard(s_aMutex);
102 if (!--s_nClients && m_pImpl)
104 delete m_pImpl;
105 m_pImpl = NULL;
108 ResMgr* ResourceManager::getResManager()
110 ensureImplExists();
111 return m_pImpl;
114 //.........................................................................
116 //.........................................................................