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 INCLUDED_SVTOOLS_LOCALRESACCESS_HXX
21 : #define INCLUDED_SVTOOLS_LOCALRESACCESS_HXX
22 :
23 : #include <tools/rc.hxx>
24 : #include <tools/rcid.h>
25 : #include <osl/diagnose.h>
26 :
27 :
28 : namespace svt
29 : {
30 :
31 :
32 :
33 : //= OLocalResourceAccess
34 :
35 : /** helper class for acessing local resources
36 : */
37 : class OLocalResourceAccess : public Resource
38 : {
39 : protected:
40 : ResMgr* m_pManager;
41 :
42 : public:
43 0 : OLocalResourceAccess( const ResId& _rId )
44 0 : :Resource( _rId.SetAutoRelease( false ) )
45 0 : ,m_pManager( _rId.GetResMgr() )
46 : {
47 0 : }
48 :
49 0 : OLocalResourceAccess(const ResId& _rId, RESOURCE_TYPE _rType)
50 0 : :Resource(_rId.SetRT(_rType).SetAutoRelease(false))
51 0 : ,m_pManager(_rId.GetResMgr())
52 : {
53 : OSL_ENSURE( m_pManager != NULL, "OLocalResourceAccess::OLocalResourceAccess: invalid resource manager!" );
54 0 : }
55 :
56 0 : ~OLocalResourceAccess()
57 0 : {
58 0 : if ( m_pManager )
59 0 : m_pManager->Increment( m_pManager->GetRemainSize() );
60 0 : FreeResource();
61 0 : }
62 :
63 0 : inline bool IsAvailableRes( const ResId& _rId ) const
64 : {
65 0 : return Resource::IsAvailableRes( _rId );
66 : }
67 : };
68 :
69 :
70 : } // namespace svt
71 :
72 :
73 : #endif // INCLUDED_SVTOOLS_LOCALRESACCESS_HXX
74 :
75 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|