update dev300-m58
[ooovba.git] / formula / source / core / resource / core_resource.cxx
blob088c5958f28b0ecdce26321e012262a998664409
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_formula.hxx"
34 #include "core_resource.hxx"
36 #include <tools/resmgr.hxx>
38 // ---- needed as long as we have no contexts for components ---
39 #include <vcl/svapp.hxx>
40 #include <svtools/solar.hrc>
42 //.........................................................................
43 namespace formula
46 //==================================================================
47 //= ResourceManager
48 //==================================================================
49 ::osl::Mutex ResourceManager::s_aMutex;
50 sal_Int32 ResourceManager::s_nClients = 0;
51 ResMgr* ResourceManager::m_pImpl = NULL;
53 //------------------------------------------------------------------
54 void ResourceManager::ensureImplExists()
56 if (m_pImpl)
57 return;
59 ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
61 ByteString sFileName("for");
63 m_pImpl = ResMgr::CreateResMgr(sFileName.GetBuffer(), aLocale);
66 //------------------------------------------------------------------
67 ::rtl::OUString ResourceManager::loadString(sal_uInt16 _nResId)
69 ::rtl::OUString sReturn;
71 ensureImplExists();
72 if (m_pImpl)
73 sReturn = String(ResId(_nResId,*m_pImpl));
75 return sReturn;
78 //------------------------------------------------------------------
79 ::rtl::OUString ResourceManager::loadString( sal_uInt16 _nResId, const sal_Char* _pPlaceholderAscii, const ::rtl::OUString& _rReplace )
81 String sString( loadString( _nResId ) );
82 sString.SearchAndReplaceAscii( _pPlaceholderAscii, _rReplace );
83 return sString;
85 //-------------------------------------------------------------------------
86 void ResourceManager::registerClient()
88 ::osl::MutexGuard aGuard(s_aMutex);
89 ++s_nClients;
92 //-------------------------------------------------------------------------
93 void ResourceManager::revokeClient()
95 ::osl::MutexGuard aGuard(s_aMutex);
96 if (!--s_nClients && m_pImpl)
98 delete m_pImpl;
99 m_pImpl = NULL;
102 ResMgr* ResourceManager::getResManager()
104 ensureImplExists();
105 return m_pImpl;
108 //.........................................................................
109 } // formula
110 //.........................................................................