1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include "core_resource.hxx"
22 #include <tools/resmgr.hxx>
24 // ---- needed as long as we have no contexts for components ---
25 #include <vcl/svapp.hxx>
26 #include <vcl/settings.hxx>
27 #include <rtl/instance.hxx>
28 #include <svl/solar.hrc>
37 struct theResourceManagerMutex
: public rtl::Static
< osl::Mutex
, theResourceManagerMutex
> {};
40 sal_Int32
ResourceManager::s_nClients
= 0;
41 ResMgr
* ResourceManager::m_pImpl
= NULL
;
43 void ResourceManager::ensureImplExists()
48 m_pImpl
= ResMgr::CreateResMgr("dba", Application::GetSettings().GetUILanguageTag());
51 OUString
ResourceManager::loadString(sal_uInt16 _nResId
)
57 sReturn
= OUString(ResId(_nResId
,*m_pImpl
));
62 OUString
ResourceManager::loadString( sal_uInt16 _nResId
, const sal_Char
* _pPlaceholderAscii
, const OUString
& _rReplace
)
64 OUString
sString( loadString( _nResId
) );
65 return sString
.replaceFirst( OUString::createFromAscii(_pPlaceholderAscii
), _rReplace
);
68 OUString
ResourceManager::loadString( sal_uInt16 _nResId
, const sal_Char
* _pPlaceholderAscii1
, const OUString
& _rReplace1
,
69 const sal_Char
* _pPlaceholderAscii2
, const OUString
& _rReplace2
)
71 OUString
sString( loadString( _nResId
) );
72 sString
= sString
.replaceFirst( OUString::createFromAscii(_pPlaceholderAscii1
), _rReplace1
);
73 sString
= sString
.replaceFirst( OUString::createFromAscii(_pPlaceholderAscii2
), _rReplace2
);
77 void ResourceManager::registerClient()
79 ::osl::MutexGuard
aGuard(theResourceManagerMutex::get());
83 void ResourceManager::revokeClient()
85 ::osl::MutexGuard
aGuard(theResourceManagerMutex::get());
86 if (!--s_nClients
&& m_pImpl
)
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */