Branch libreoffice-5-0-4
[LibreOffice.git] / include / svtools / localresaccess.hxx
blobf9707727dfe503fb1eed82345853af79a5037c05
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVTOOLS_LOCALRESACCESS_HXX
21 #define INCLUDED_SVTOOLS_LOCALRESACCESS_HXX
23 #include <tools/rc.hxx>
24 #include <tools/rcid.h>
25 #include <osl/diagnose.h>
28 namespace svt
33 //= OLocalResourceAccess
35 /** helper class for acessing local resources
37 class OLocalResourceAccess : public Resource
39 protected:
40 ResMgr* m_pManager;
42 public:
43 OLocalResourceAccess( const ResId& _rId )
44 :Resource( _rId.SetAutoRelease( false ) )
45 ,m_pManager( _rId.GetResMgr() )
49 OLocalResourceAccess(const ResId& _rId, RESOURCE_TYPE _rType)
50 :Resource(_rId.SetRT(_rType).SetAutoRelease(false))
51 ,m_pManager(_rId.GetResMgr())
53 OSL_ENSURE( m_pManager != NULL, "OLocalResourceAccess::OLocalResourceAccess: invalid resource manager!" );
56 ~OLocalResourceAccess()
58 if ( m_pManager )
59 m_pManager->Increment( m_pManager->GetRemainSize() );
60 FreeResource();
63 inline bool IsAvailableRes( const ResId& _rId ) const
65 return Resource::IsAvailableRes( _rId );
70 } // namespace svt
73 #endif // INCLUDED_SVTOOLS_LOCALRESACCESS_HXX
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */