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 : // a simple resource manager : no stacks, no sharing of the impl class, only loading of strings and blobs
21 : // but thread-safety !! :)
22 :
23 : #ifndef INCLUDED_TOOLS_SIMPLERM_HXX
24 : #define INCLUDED_TOOLS_SIMPLERM_HXX
25 :
26 : #include <osl/mutex.hxx>
27 : #include <tools/resid.hxx>
28 : #include <i18nlangtag/languagetag.hxx>
29 : #include <tools/toolsdllapi.h>
30 :
31 : class InternalResMgr;
32 :
33 : class TOOLS_DLLPUBLIC SimpleResMgr
34 : {
35 : protected:
36 : osl::Mutex m_aAccessSafety;
37 : InternalResMgr* m_pResImpl;
38 :
39 : public:
40 : /** creates a new SimpleResManager
41 : @param pPrefixName
42 : denotes the prefix of the resource file name,
43 : in ThreadTextEncoding
44 : @param rLocale
45 : denotes the locale of the resource file to
46 : load. If empty (SYSTEM), a default locale will be used.
47 : */
48 : SimpleResMgr( const sal_Char* pPrefixName,
49 : const LanguageTag& rLocale);
50 :
51 : virtual ~SimpleResMgr();
52 :
53 : static SimpleResMgr* Create( const sal_Char* pPrefixName,
54 : LanguageTag aLocale = LanguageTag( LANGUAGE_SYSTEM) );// only in VCL
55 :
56 5 : bool IsValid() const { return m_pResImpl != NULL; }
57 :
58 : /** reads the string with the given resource id
59 : @param nId
60 : the resource id of the string to read
61 : @return
62 : the string with the given resource id, or an empty string if the id does not denote
63 : an existent string
64 : @seealso IsAvailable
65 : */
66 : OUString ReadString( sal_uInt32 nId );
67 :
68 : /** checks whether a certain resource is availble
69 : @param _resourceType
70 : the type of the resource to check. Currently, only RSC_STRING (strings) and RSC_RESOURCE (blobs)
71 : are supported, for every other type, <FALSE/> will be returned.
72 : @param _resourceId
73 : the id of the resource to lookup.
74 : @return
75 : <TRUE/> if and only if a resource of the given type, with the given id, is available.
76 : */
77 : bool IsAvailable( RESOURCE_TYPE _resourceType, sal_uInt32 _resourceId );
78 : };
79 :
80 : #endif
81 :
82 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|