merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / core / resource / core_resource.cxx
blob0cbbd0f0743de08bfdfa92d01b41cb7b2d6d6a2a
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;
92 //------------------------------------------------------------------
93 ::rtl::OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii1, const ::rtl::OUString& _rReplace1,
94 const sal_Char* _pPlaceholderAscii2, const ::rtl::OUString& _rReplace2 )
96 String sString( loadString( _nResId ) );
97 sString.SearchAndReplaceAscii( _pPlaceholderAscii1, _rReplace1 );
98 sString.SearchAndReplaceAscii( _pPlaceholderAscii2, _rReplace2 );
99 return sString;
102 //-------------------------------------------------------------------------
103 void ResourceManager::registerClient()
105 ::osl::MutexGuard aGuard(s_aMutex);
106 ++s_nClients;
109 //-------------------------------------------------------------------------
110 void ResourceManager::revokeClient()
112 ::osl::MutexGuard aGuard(s_aMutex);
113 if (!--s_nClients && m_pImpl)
115 delete m_pImpl;
116 m_pImpl = NULL;
119 ResMgr* ResourceManager::getResManager()
121 ensureImplExists();
122 return m_pImpl;
125 //.........................................................................
127 //.........................................................................