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