Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / inc / core_resource.hxx
blob727d131cd0000379591b20548629cfb6dabd27f8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef _DBA_CORE_RESOURCE_HXX_
21 #define _DBA_CORE_RESOURCE_HXX_
23 #include <rtl/ustring.hxx>
24 #include <osl/mutex.hxx>
26 class ResMgr;
28 namespace dbaccess
31 #define DBA_RES( id ) ResourceManager::loadString( id )
32 #define DBA_RES_PARAM( id, ascii, replace ) ResourceManager::loadString( id, ascii, replace )
34 #define DBACORE_RESSTRING( id ) DBA_RES( id )
35 // (compatibility)
37 //==================================================================
38 //= ResourceManager
39 //= handling resources within the DBA-Core library
40 //==================================================================
41 class ResourceManager
43 friend class OModuleClient;
44 static sal_Int32 s_nClients; /// number of registered clients
45 static ResMgr* m_pImpl;
47 private:
48 // no instantiation allowed
49 ResourceManager() { }
50 ~ResourceManager() { }
52 protected:
53 static void ensureImplExists();
54 /// register a client for the module
55 static void registerClient();
56 /// revoke a client for the module
57 static void revokeClient();
59 public:
60 /** loads the string with the specified resource id
62 static ::rtl::OUString loadString(sal_uInt16 _nResId);
64 /** loads a string from the resource file, substituting a placeholder with a given string
66 @param _nResId
67 the resource ID of the string to load
68 @param _pPlaceholderAscii
69 the ASCII representation of the placeholder string
70 @param _rReplace
71 the string which should substitute the placeholder
73 static ::rtl::OUString loadString(
74 sal_uInt16 _nResId,
75 const sal_Char* _pPlaceholderAscii,
76 const ::rtl::OUString& _rReplace
79 /** loads a string from the resource file, substituting two placeholders with given strings
81 @param _nResId
82 the resource ID of the string to load
83 @param _pPlaceholderAscii1
84 the ASCII representation of the first placeholder string
85 @param _rReplace1
86 the string which should substitute the first placeholder
87 @param _pPlaceholderAscii2
88 the ASCII representation of the second placeholder string
89 @param _rReplace2
90 the string which should substitute the second placeholder
92 static ::rtl::OUString loadString(
93 sal_uInt16 _nResId,
94 const sal_Char* _pPlaceholderAscii1,
95 const ::rtl::OUString& _rReplace1,
96 const sal_Char* _pPlaceholderAscii2,
97 const ::rtl::OUString& _rReplace2
101 //=========================================================================
102 //= OModuleClient
103 //=========================================================================
104 /** base class for objects which uses any global module-specific resources
106 class OModuleClient
108 public:
109 OModuleClient() { ResourceManager::registerClient(); }
110 ~OModuleClient() { ResourceManager::revokeClient(); }
114 #endif // _DBA_CORE_RESOURCE_HXX_
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */