1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SVTOOLS_LOCALRESACCESS_HXX_ 25 #define _SVTOOLS_LOCALRESACCESS_HXX_ 26 27 #include <tools/rc.hxx> 28 #include <tools/rcid.h> 29 #include <osl/diagnose.h> 30 31 //......................................................................... 32 namespace svt 33 { 34 //......................................................................... 35 36 //========================================================================= 37 //= OLocalResourceAccess 38 //========================================================================= 39 /** helper class for acessing local resources 40 */ 41 class OLocalResourceAccess : public Resource 42 { 43 protected: 44 ResMgr* m_pManager; 45 46 public: OLocalResourceAccess(const ResId & _rId)47 OLocalResourceAccess( const ResId& _rId ) 48 :Resource( _rId.SetAutoRelease( sal_False ) ) 49 ,m_pManager( _rId.GetResMgr() ) 50 { 51 } 52 OLocalResourceAccess(const ResId & _rId,RESOURCE_TYPE _rType)53 OLocalResourceAccess(const ResId& _rId, RESOURCE_TYPE _rType) 54 :Resource(_rId.SetRT(_rType).SetAutoRelease(sal_False)) 55 ,m_pManager(_rId.GetResMgr()) 56 { 57 OSL_ENSURE( m_pManager != NULL, "OLocalResourceAccess::OLocalResourceAccess: invalid resource manager!" ); 58 } 59 ~OLocalResourceAccess()60 ~OLocalResourceAccess() 61 { 62 if ( m_pManager ) 63 m_pManager->Increment( m_pManager->GetRemainSize() ); 64 FreeResource(); 65 } 66 IsAvailableRes(const ResId & _rId) const67 inline sal_Bool IsAvailableRes( const ResId& _rId ) const 68 { 69 return Resource::IsAvailableRes( _rId ); 70 } 71 }; 72 73 //......................................................................... 74 } // namespace svt 75 //......................................................................... 76 77 #endif // _SVTOOLS_LOCALRESACCESS_HXX_ 78 79