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 : #ifndef _TOOLS_RC_HXX
20 : #define _TOOLS_RC_HXX
21 :
22 : #include "tools/toolsdllapi.h"
23 : #include <i18npool/lang.h>
24 : #include <tools/string.hxx>
25 : #include <tools/resmgr.hxx>
26 :
27 : class TOOLS_DLLPUBLIC Resource
28 : {
29 : protected:
30 : ResMgr* m_pResMgr;
31 :
32 : // check availability of Resource
33 34403 : sal_Bool IsAvailableRes( const ResId& rId ) const
34 34403 : { return m_pResMgr->IsAvailable( rId, this ); }
35 :
36 : // Load a Resource
37 : void GetRes( const ResId& rResId );
38 :
39 : // check Resource state
40 : void TestRes();
41 :
42 : // Get a pointer to the Resource's data
43 824 : void* GetClassRes()
44 824 : { return m_pResMgr->GetClass(); }
45 :
46 : // increase the memory pointer gotten by GetClassRes()
47 56 : void* IncrementRes( sal_uInt32 nBytes )
48 56 : { return m_pResMgr->Increment( nBytes ); }
49 :
50 : // return the memory size of a Resource data block
51 56 : static sal_uInt32 GetObjSizeRes( RSHEADER_TYPE * pHT )
52 56 : { return ResMgr::GetObjSize( pHT ); }
53 :
54 : // return the remaining size of this Resource's data
55 : sal_uInt32 GetRemainSizeRes()
56 : { return m_pResMgr->GetRemainSize(); }
57 :
58 : // get a 32bit value from Resource data
59 712 : static sal_Int32 GetLongRes( void * pLong )
60 712 : { return ResMgr::GetLong( pLong ); }
61 : // get a 16bit value from Resource data
62 : static sal_Int16 GetShortRes( void * pShort )
63 : { return ResMgr::GetShort( pShort ); }
64 :
65 : // read a 32bit value from resource data and increment pointer
66 3476 : sal_Int32 ReadLongRes()
67 3476 : { return m_pResMgr->ReadLong(); }
68 : // read a 16bit value from resource data and increment pointer
69 1767 : sal_Int16 ReadShortRes()
70 1767 : { return m_pResMgr->ReadShort(); }
71 : // read a string from resource data and increment pointer
72 54 : rtl::OUString ReadStringRes()
73 54 : { return m_pResMgr->ReadString(); }
74 : // read a byte string from resource data and increment pointer
75 582 : rtl::OString ReadByteStringRes()
76 582 : { return m_pResMgr->ReadByteString(); }
77 :
78 : // free the resource from m_pResMgr's stack (pass this ptr for validation)
79 5697 : void FreeResource()
80 5697 : { m_pResMgr->PopContext( this ); }
81 :
82 : // constructors
83 18766 : Resource() : m_pResMgr( NULL ) {}
84 : Resource( const ResId& rResId );
85 :
86 : public:
87 : #ifdef DBG_UTIL
88 : ~Resource() { TestRes(); }
89 : #else
90 14886 : ~Resource() {}
91 : #endif
92 : };
93 :
94 : #endif
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|