2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 09:51:50 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2013-10-23 19:15:52 +02:00
|
|
|
#ifndef INCLUDED_TOOLS_RC_HXX
|
|
|
|
#define INCLUDED_TOOLS_RC_HXX
|
2007-04-11 19:16:34 +00:00
|
|
|
|
2013-11-09 15:37:43 -06:00
|
|
|
#include <tools/toolsdllapi.h>
|
2013-04-05 18:40:39 +02:00
|
|
|
#include <i18nlangtag/lang.h>
|
2007-04-11 19:16:34 +00:00
|
|
|
#include <tools/resmgr.hxx>
|
|
|
|
|
|
|
|
class TOOLS_DLLPUBLIC Resource
|
|
|
|
{
|
2012-08-13 23:42:18 +02:00
|
|
|
protected:
|
2007-04-26 08:47:17 +00:00
|
|
|
ResMgr* m_pResMgr;
|
2007-04-11 19:16:34 +00:00
|
|
|
|
2007-04-26 08:47:17 +00:00
|
|
|
// check availability of Resource
|
2013-06-29 23:57:38 -05:00
|
|
|
bool IsAvailableRes( const ResId& rId ) const
|
|
|
|
{ return m_pResMgr->IsAvailable( rId, this ); }
|
2007-04-26 08:47:17 +00:00
|
|
|
|
|
|
|
// Load a Resource
|
2007-04-11 19:16:34 +00:00
|
|
|
void GetRes( const ResId& rResId );
|
|
|
|
|
2007-04-26 08:47:17 +00:00
|
|
|
// check Resource state
|
2014-02-27 10:39:21 +02:00
|
|
|
#ifdef DBG_UTIL
|
2007-04-11 19:16:34 +00:00
|
|
|
void TestRes();
|
2014-02-27 10:39:21 +02:00
|
|
|
#endif
|
2007-04-11 19:16:34 +00:00
|
|
|
|
2007-04-26 08:47:17 +00:00
|
|
|
// Get a pointer to the Resource's data
|
|
|
|
void* GetClassRes()
|
|
|
|
{ return m_pResMgr->GetClass(); }
|
2007-04-11 19:16:34 +00:00
|
|
|
|
2007-04-26 08:47:17 +00:00
|
|
|
// increase the memory pointer gotten by GetClassRes()
|
|
|
|
void* IncrementRes( sal_uInt32 nBytes )
|
|
|
|
{ return m_pResMgr->Increment( nBytes ); }
|
2007-04-11 19:16:34 +00:00
|
|
|
|
2007-04-26 08:47:17 +00:00
|
|
|
// return the memory size of a Resource data block
|
2007-04-11 19:16:34 +00:00
|
|
|
static sal_uInt32 GetObjSizeRes( RSHEADER_TYPE * pHT )
|
2007-04-26 08:47:17 +00:00
|
|
|
{ return ResMgr::GetObjSize( pHT ); }
|
|
|
|
|
|
|
|
// return the remaining size of this Resource's data
|
|
|
|
sal_uInt32 GetRemainSizeRes()
|
|
|
|
{ return m_pResMgr->GetRemainSize(); }
|
|
|
|
|
|
|
|
// get a 32bit value from Resource data
|
|
|
|
static sal_Int32 GetLongRes( void * pLong )
|
|
|
|
{ return ResMgr::GetLong( pLong ); }
|
|
|
|
// get a 16bit value from Resource data
|
|
|
|
static sal_Int16 GetShortRes( void * pShort )
|
|
|
|
{ return ResMgr::GetShort( pShort ); }
|
|
|
|
|
|
|
|
// read a 32bit value from resource data and increment pointer
|
|
|
|
sal_Int32 ReadLongRes()
|
|
|
|
{ return m_pResMgr->ReadLong(); }
|
|
|
|
// read a 16bit value from resource data and increment pointer
|
|
|
|
sal_Int16 ReadShortRes()
|
|
|
|
{ return m_pResMgr->ReadShort(); }
|
|
|
|
// read a string from resource data and increment pointer
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString ReadStringRes()
|
2007-04-26 08:47:17 +00:00
|
|
|
{ return m_pResMgr->ReadString(); }
|
2010-06-04 13:46:22 +02:00
|
|
|
// read a byte string from resource data and increment pointer
|
2013-04-07 12:06:47 +02:00
|
|
|
OString ReadByteStringRes()
|
2010-06-04 13:46:22 +02:00
|
|
|
{ return m_pResMgr->ReadByteString(); }
|
2007-04-11 19:16:34 +00:00
|
|
|
|
2007-04-26 08:47:17 +00:00
|
|
|
// free the resource from m_pResMgr's stack (pass this ptr for validation)
|
|
|
|
void FreeResource()
|
|
|
|
{ m_pResMgr->PopContext( this ); }
|
|
|
|
|
|
|
|
// constructors
|
|
|
|
Resource() : m_pResMgr( NULL ) {}
|
|
|
|
Resource( const ResId& rResId );
|
|
|
|
|
2012-08-13 23:42:18 +02:00
|
|
|
public:
|
|
|
|
#ifdef DBG_UTIL
|
2007-04-26 08:47:17 +00:00
|
|
|
~Resource() { TestRes(); }
|
2012-08-13 23:42:18 +02:00
|
|
|
#else
|
2007-04-26 08:47:17 +00:00
|
|
|
~Resource() {}
|
2012-08-13 23:42:18 +02:00
|
|
|
#endif
|
2007-04-11 19:16:34 +00:00
|
|
|
};
|
|
|
|
|
2012-08-13 23:14:08 +02:00
|
|
|
#endif
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|