1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef CONNECTIVITY_SHAREDRESOURCES_HXX
29 #define CONNECTIVITY_SHAREDRESOURCES_HXX
30 
31 /** === begin UNO includes === **/
32 /** === end UNO includes === **/
33 
34 #include <rtl/ustring.hxx>
35 #include <list>
36 #include "connectivity/dbtoolsdllapi.hxx"
37 
38 //........................................................................
39 namespace connectivity
40 {
41 //........................................................................
42 
43     typedef sal_uInt16  ResourceId;
44 	//====================================================================
45 	//= SharedResources
46 	//====================================================================
47     /** helper class for accessing resources shared by different libraries
48         in the connectivity module
49     */
50 	class OOO_DLLPUBLIC_DBTOOLS SharedResources
51 	{
52     public:
53         SharedResources();
54         ~SharedResources();
55 
56         /** loads a string from the shared resource file
57             @param  _nResId
58                 the resource ID of the string
59             @return
60                 the string from the resource file
61         */
62         ::rtl::OUString
63             getResourceString(
64                 ResourceId _nResId
65             ) const;
66 
67         /** loads a string from the shared resource file, and replaces
68             a given ASCII pattern with a given string
69 
70             @param  _nResId
71                 the resource ID of the string to load
72             @param  _pAsciiPatternToReplace
73                 the ASCII string which is to search in the string. Must not be <NULL/>.
74             @param  _rStringToSubstitute
75                 the String which should substitute the ASCII pattern.
76 
77             @return
78                 the string from the resource file, with applied string substitution
79         */
80         ::rtl::OUString
81             getResourceStringWithSubstitution(
82                 ResourceId _nResId,
83                 const sal_Char* _pAsciiPatternToReplace,
84                 const ::rtl::OUString& _rStringToSubstitute
85             ) const;
86 
87         /** loads a string from the shared resource file, and replaces
88             a given ASCII pattern with a given string
89 
90             @param  _nResId
91                 the resource ID of the string to load
92             @param  _pAsciiPatternToReplace1
93                 the ASCII string (1) which is to search in the string. Must not be <NULL/>.
94             @param  _rStringToSubstitute1
95                 the String which should substitute the ASCII pattern (1)
96             @param  _pAsciiPatternToReplace2
97                 the ASCII string (2) which is to search in the string. Must not be <NULL/>.
98             @param  _rStringToSubstitute2
99                 the String which should substitute the ASCII pattern (2)
100 
101             @return
102                 the string from the resource file, with applied string substitution
103         */
104         ::rtl::OUString
105             getResourceStringWithSubstitution(
106                 ResourceId _nResId,
107                 const sal_Char* _pAsciiPatternToReplace1,
108                 const ::rtl::OUString& _rStringToSubstitute1,
109                 const sal_Char* _pAsciiPatternToReplace2,
110                 const ::rtl::OUString& _rStringToSubstitute2
111             ) const;
112 
113         /** loads a string from the shared resource file, and replaces
114             a given ASCII pattern with a given string
115 
116             @param  _nResId
117                 the resource ID of the string to load
118             @param  _pAsciiPatternToReplace1
119                 the ASCII string (1) which is to search in the string. Must not be <NULL/>.
120             @param  _rStringToSubstitute1
121                 the String which should substitute the ASCII pattern (1)
122             @param  _pAsciiPatternToReplace2
123                 the ASCII string (2) which is to search in the string. Must not be <NULL/>.
124             @param  _rStringToSubstitute2
125                 the String which should substitute the ASCII pattern (2)
126             @param  _pAsciiPatternToReplace3
127                 the ASCII string (3) which is to search in the string. Must not be <NULL/>.
128             @param  _rStringToSubstitute3
129                 the String which should substitute the ASCII pattern (3)
130 
131             @return
132                 the string from the resource file, with applied string substitution
133         */
134         ::rtl::OUString
135             getResourceStringWithSubstitution(
136                 ResourceId _nResId,
137                 const sal_Char* _pAsciiPatternToReplace1,
138                 const ::rtl::OUString& _rStringToSubstitute1,
139                 const sal_Char* _pAsciiPatternToReplace2,
140                 const ::rtl::OUString& _rStringToSubstitute2,
141                 const sal_Char* _pAsciiPatternToReplace3,
142                 const ::rtl::OUString& _rStringToSubstitute3
143             ) const;
144 
145         /** loads a string from the shared resource file, and replaces a given ASCII pattern with a given string
146 
147             @param  _nResId
148                 the resource ID of the string to load
149             @param  _aStringToSubstitutes
150                 A list of substitutions.
151 
152             @return
153                 the string from the resource file, with applied string substitution
154         */
155         ::rtl::OUString getResourceStringWithSubstitution( ResourceId _nResId,
156                     const ::std::list< ::std::pair<const sal_Char* , ::rtl::OUString > > _aStringToSubstitutes) const;
157 	};
158 
159 //........................................................................
160 } // namespace connectivity
161 //........................................................................
162 
163 #endif // CONNECTIVITY_SHAREDRESOURCES_HXX
164 
165