1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef CONNECTIVITY_SHAREDRESOURCES_HXX
25 #define CONNECTIVITY_SHAREDRESOURCES_HXX
26 
27 /** === begin UNO includes === **/
28 /** === end UNO includes === **/
29 
30 #include <rtl/ustring.hxx>
31 #include <list>
32 #include "connectivity/dbtoolsdllapi.hxx"
33 
34 //........................................................................
35 namespace connectivity
36 {
37 //........................................................................
38 
39     typedef sal_uInt16  ResourceId;
40 	//====================================================================
41 	//= SharedResources
42 	//====================================================================
43     /** helper class for accessing resources shared by different libraries
44         in the connectivity module
45     */
46 	class OOO_DLLPUBLIC_DBTOOLS SharedResources
47 	{
48     public:
49         SharedResources();
50         ~SharedResources();
51 
52         /** loads a string from the shared resource file
53             @param  _nResId
54                 the resource ID of the string
55             @return
56                 the string from the resource file
57         */
58         ::rtl::OUString
59             getResourceString(
60                 ResourceId _nResId
61             ) const;
62 
63         /** loads a string from the shared resource file, and replaces
64             a given ASCII pattern with a given string
65 
66             @param  _nResId
67                 the resource ID of the string to load
68             @param  _pAsciiPatternToReplace
69                 the ASCII string which is to search in the string. Must not be <NULL/>.
70             @param  _rStringToSubstitute
71                 the String which should substitute the ASCII pattern.
72 
73             @return
74                 the string from the resource file, with applied string substitution
75         */
76         ::rtl::OUString
77             getResourceStringWithSubstitution(
78                 ResourceId _nResId,
79                 const sal_Char* _pAsciiPatternToReplace,
80                 const ::rtl::OUString& _rStringToSubstitute
81             ) const;
82 
83         /** loads a string from the shared resource file, and replaces
84             a given ASCII pattern with a given string
85 
86             @param  _nResId
87                 the resource ID of the string to load
88             @param  _pAsciiPatternToReplace1
89                 the ASCII string (1) which is to search in the string. Must not be <NULL/>.
90             @param  _rStringToSubstitute1
91                 the String which should substitute the ASCII pattern (1)
92             @param  _pAsciiPatternToReplace2
93                 the ASCII string (2) which is to search in the string. Must not be <NULL/>.
94             @param  _rStringToSubstitute2
95                 the String which should substitute the ASCII pattern (2)
96 
97             @return
98                 the string from the resource file, with applied string substitution
99         */
100         ::rtl::OUString
101             getResourceStringWithSubstitution(
102                 ResourceId _nResId,
103                 const sal_Char* _pAsciiPatternToReplace1,
104                 const ::rtl::OUString& _rStringToSubstitute1,
105                 const sal_Char* _pAsciiPatternToReplace2,
106                 const ::rtl::OUString& _rStringToSubstitute2
107             ) const;
108 
109         /** loads a string from the shared resource file, and replaces
110             a given ASCII pattern with a given string
111 
112             @param  _nResId
113                 the resource ID of the string to load
114             @param  _pAsciiPatternToReplace1
115                 the ASCII string (1) which is to search in the string. Must not be <NULL/>.
116             @param  _rStringToSubstitute1
117                 the String which should substitute the ASCII pattern (1)
118             @param  _pAsciiPatternToReplace2
119                 the ASCII string (2) which is to search in the string. Must not be <NULL/>.
120             @param  _rStringToSubstitute2
121                 the String which should substitute the ASCII pattern (2)
122             @param  _pAsciiPatternToReplace3
123                 the ASCII string (3) which is to search in the string. Must not be <NULL/>.
124             @param  _rStringToSubstitute3
125                 the String which should substitute the ASCII pattern (3)
126 
127             @return
128                 the string from the resource file, with applied string substitution
129         */
130         ::rtl::OUString
131             getResourceStringWithSubstitution(
132                 ResourceId _nResId,
133                 const sal_Char* _pAsciiPatternToReplace1,
134                 const ::rtl::OUString& _rStringToSubstitute1,
135                 const sal_Char* _pAsciiPatternToReplace2,
136                 const ::rtl::OUString& _rStringToSubstitute2,
137                 const sal_Char* _pAsciiPatternToReplace3,
138                 const ::rtl::OUString& _rStringToSubstitute3
139             ) const;
140 
141         /** loads a string from the shared resource file, and replaces a given ASCII pattern with a given string
142 
143             @param  _nResId
144                 the resource ID of the string to load
145             @param  _aStringToSubstitutes
146                 A list of substitutions.
147 
148             @return
149                 the string from the resource file, with applied string substitution
150         */
151         ::rtl::OUString getResourceStringWithSubstitution( ResourceId _nResId,
152                     const ::std::list< ::std::pair<const sal_Char* , ::rtl::OUString > > _aStringToSubstitutes) const;
153 	};
154 
155 //........................................................................
156 } // namespace connectivity
157 //........................................................................
158 
159 #endif // CONNECTIVITY_SHAREDRESOURCES_HXX
160 
161