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 SVX_STRINGLISTRESOURCE_HXX
25 #define SVX_STRINGLISTRESOURCE_HXX
26 
27 #include <tools/rc.hxx>
28 
29 #include <svx/svxdllapi.h>
30 
31 #include <memory>
32 
33 //........................................................................
34 namespace svx
35 {
36 //........................................................................
37 
38     //====================================================================
39     //= StringListResource
40     //====================================================================
41     /** loads a list of strings from a resource, where the resource is of type RSC_RESOURCE,
42         and has sub resources of type string, numbered from 1 to n
43     */
44     class StringListResource : public Resource
45     {
46     public:
47         SVX_DLLPUBLIC StringListResource( const ResId& _rResId );
48         SVX_DLLPUBLIC ~StringListResource();
49 
get(::std::vector<String> & _rStrings)50         inline void get( ::std::vector< String >& _rStrings )
51         {
52             _rStrings = m_aStrings;
53         }
54 
55 
56         /** returns the String with a given local resource id
57 
58             @param  _nResId
59                 The resource id. It will not be checked if this id exists.
60 
61             @return String
62                 The string.
63         */
getString(sal_uInt16 _nResId)64         String getString( sal_uInt16 _nResId )
65         {
66             return String( ResId( _nResId, *m_pResMgr ) );
67         }
68 
size() const69         size_t  size() const    { return m_aStrings.size(); }
empty() const70         bool    empty() const   { return m_aStrings.empty(); }
71 
operator [](size_t _index) const72         const String& operator[]( size_t _index ) const { return m_aStrings[ _index ]; }
73 
74     private:
75         ::std::vector< String > m_aStrings;
76     };
77 
78 //........................................................................
79 } // namespace svx
80 //........................................................................
81 
82 #endif // SVX_STRINGLISTRESOURCE_HXX
83