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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_forms.hxx"
26 
27 #include "resourcehelper.hxx"
28 #include "frm_resource.hxx"
29 
30 #include <rtl/ustring.hxx>
31 #include <tools/string.hxx>
32 
33 using rtl::OUString;
34 
35 #define OUSTRING(x) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x))
36 
37 namespace xforms
38 {
39 
getResource(sal_uInt16 nResourceId)40 OUString getResource( sal_uInt16 nResourceId )
41 {
42     return getResource( nResourceId, OUString(), OUString(), OUString() );
43 }
44 
getResource(sal_uInt16 nResourceId,const OUString & rInfo1)45 OUString getResource( sal_uInt16 nResourceId,
46                       const OUString& rInfo1 )
47 {
48     return getResource( nResourceId, rInfo1, OUString(), OUString() );
49 }
50 
getResource(sal_uInt16 nResourceId,const OUString & rInfo1,const OUString & rInfo2)51 OUString getResource( sal_uInt16 nResourceId,
52                       const OUString& rInfo1,
53                       const OUString& rInfo2 )
54 {
55     return getResource( nResourceId, rInfo1, rInfo2, OUString() );
56 }
57 
getResource(sal_uInt16 nResourceId,const OUString & rInfo1,const OUString & rInfo2,const OUString & rInfo3)58 OUString getResource( sal_uInt16 nResourceId,
59                       const OUString& rInfo1,
60                       const OUString& rInfo2,
61                       const OUString& rInfo3 )
62 {
63     OUString sResource = frm::ResourceManager::loadString( nResourceId );
64     OSL_ENSURE( sResource.getLength() > 0, "resource not found?" );
65 
66     // use old style String class for search and replace, so we don't have to
67     // code this again.
68     String sString( sResource );
69     sString.SearchAndReplaceAll( String(OUSTRING("$1")), String(rInfo1) );
70     sString.SearchAndReplaceAll( String(OUSTRING("$2")), String(rInfo2) );
71     sString.SearchAndReplaceAll( String(OUSTRING("$3")), String(rInfo3) );
72     return OUString( sString );
73 }
74 
75 }   // namespace xforms
76