Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SVX_STRINGLISTRESOURCE_HXX
21 : #define SVX_STRINGLISTRESOURCE_HXX
22 :
23 : #include <tools/rc.hxx>
24 :
25 : #include <svx/svxdllapi.h>
26 :
27 : #include <memory>
28 :
29 : //........................................................................
30 : namespace svx
31 : {
32 : //........................................................................
33 :
34 : //====================================================================
35 : //= StringListResource
36 : //====================================================================
37 : /** loads a list of strings from a resource, where the resource is of type RSC_RESOURCE,
38 : and has sub resources of type string, numbered from 1 to n
39 : */
40 : class StringListResource : public Resource
41 : {
42 : public:
43 : SVX_DLLPUBLIC StringListResource( const ResId& _rResId );
44 : SVX_DLLPUBLIC ~StringListResource();
45 :
46 0 : inline void get( ::std::vector< String >& _rStrings )
47 : {
48 0 : _rStrings = m_aStrings;
49 0 : }
50 :
51 :
52 : /** returns the String with a given local resource id
53 :
54 : @param _nResId
55 : The resource id. It will not be checked if this id exists.
56 :
57 : @return String
58 : The string.
59 : */
60 : String getString( sal_uInt16 _nResId )
61 : {
62 : return String( ResId( _nResId, *m_pResMgr ) );
63 : }
64 :
65 : size_t size() const { return m_aStrings.size(); }
66 : bool empty() const { return m_aStrings.empty(); }
67 :
68 0 : const String& operator[]( size_t _index ) const { return m_aStrings[ _index ]; }
69 :
70 : private:
71 : ::std::vector< String > m_aStrings;
72 : };
73 :
74 : //........................................................................
75 : } // namespace svx
76 : //........................................................................
77 :
78 : #endif // SVX_STRINGLISTRESOURCE_HXX
79 :
80 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|