diff options
Diffstat (limited to 'tools/source/rc/resmgr.cxx')
-rw-r--r-- | tools/source/rc/resmgr.cxx | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx index 34efb70bf3..14caa3b351 100644 --- a/tools/source/rc/resmgr.cxx +++ b/tools/source/rc/resmgr.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -32,7 +32,6 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> -#include <vos/signal.hxx> #include <tools/debug.hxx> #include <tools/table.hxx> #include <tools/stream.hxx> @@ -44,6 +43,7 @@ #include <osl/thread.h> #include <osl/file.hxx> #include <osl/mutex.hxx> +#include <osl/signal.h> #include <rtl/ustrbuf.hxx> #include <tools/urlobj.hxx> #include <rtl/instance.hxx> @@ -126,39 +126,39 @@ public: class ResMgrContainer { static ResMgrContainer* pOneInstance; - + struct ContainerElement { InternalResMgr* pResMgr; OUString aFileURL; int nRefCount; int nLoadCount; - + ContainerElement() : pResMgr( NULL ), nRefCount( 0 ), nLoadCount( 0 ) {} }; - + std::hash_map< OUString, ContainerElement, OUStringHash> m_aResFiles; com::sun::star::lang::Locale m_aDefLocale; - + ResMgrContainer() { init(); } ~ResMgrContainer(); - + void init(); public: - static ResMgrContainer& get(); + static ResMgrContainer& get(); static void release(); - + InternalResMgr* getResMgr( const OUString& rPrefix, com::sun::star::lang::Locale& rLocale, bool bForceNewInstance = false ); InternalResMgr* getNextFallback( InternalResMgr* pResMgr ); - + void freeResMgr( InternalResMgr* pResMgr ); void setDefLocale( const com::sun::star::lang::Locale& rLocale ) @@ -199,7 +199,7 @@ void ResMgrContainer::init() // get resource path std::list< OUString > aDirs; sal_Int32 nIndex = 0; - + // 1. fixed locations rtl::OUString uri( RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program/resource")); @@ -209,7 +209,7 @@ void ResMgrContainer::init() RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program/resource")); rtl::Bootstrap::expandMacros(uri); aDirs.push_back(uri); - + // 2. in STAR_RESOURCEPATH const sal_Char* pEnv = getenv( "STAR_RESOURCEPATH" ); if( pEnv ) @@ -285,7 +285,7 @@ InternalResMgr* ResMgrContainer::getResMgr( const OUString& rPrefix, com::sun::star::lang::Locale aLocale( rLocale ); OUStringBuffer aSearch( rPrefix.getLength() + 16 ); std::hash_map< OUString, ContainerElement, OUStringHash >::iterator it = m_aResFiles.end(); - + int nTries = 0; if( aLocale.Language.getLength() > 0 ) nTries = 1; @@ -404,10 +404,10 @@ InternalResMgr* ResMgrContainer::getResMgr( const OUString& rPrefix, // at this point it->second.pResMgr must be filled either by creating a new one // (then the refcount is still 0) or because we already had one InternalResMgr* pImp = it->second.pResMgr; - + if( it->second.nRefCount == 0 ) it->second.nLoadCount++; - + // for SimpleResMgr if( bForceNewInstance ) { @@ -433,7 +433,7 @@ InternalResMgr* ResMgrContainer::getResMgr( const OUString& rPrefix, } else it->second.nRefCount++; - + return pImp; } @@ -498,7 +498,7 @@ struct ImpContent struct ImpContentLessCompare : public ::std::binary_function< ImpContent, ImpContent, bool> { - inline bool operator() (const ImpContent& lhs, const ImpContent& rhs) const + inline bool operator() (const ImpContent& lhs, const ImpContent& rhs) const { return lhs.nTypeAndId < rhs.nTypeAndId; } @@ -506,11 +506,11 @@ struct ImpContentLessCompare : public ::std::binary_function< ImpContent, ImpCon struct ImpContentMixLessCompare : public ::std::binary_function< ImpContent, sal_uInt64, bool> { - inline bool operator() (const ImpContent& lhs, const sal_uInt64& rhs) const + inline bool operator() (const ImpContent& lhs, const sal_uInt64& rhs) const { return lhs.nTypeAndId < rhs; } - inline bool operator() (const sal_uInt64& lhs, const ImpContent& rhs) const + inline bool operator() (const sal_uInt64& lhs, const ImpContent& rhs) const { return lhs < rhs.nTypeAndId; } @@ -800,7 +800,7 @@ void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr, ResMgrContainer::get().getResMgr( pResMgr->pImpRes->aPrefix, pResMgr->pImpRes->aLocale, true ); - + ResMgr* pNewResMgr = new ResMgr( pImp ); ByteString aStr = OUStringToOString( pResMgr->GetFileName(), RTL_TEXTENCODING_UTF8 ); @@ -836,19 +836,20 @@ void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr, static void RscException_Impl() { - switch ( NAMESPACE_VOS(OSignalHandler)::raise( OSL_SIGNAL_USER_RESOURCEFAILURE, (void*)"" ) ) + switch ( osl_raiseSignal( OSL_SIGNAL_USER_RESOURCEFAILURE, (void*)"" ) ) { - case NAMESPACE_VOS(OSignalHandler)::TAction_CallNextHandler: - abort(); + case osl_Signal_ActCallNextHdl: + abort(); - case NAMESPACE_VOS(OSignalHandler)::TAction_Ignore: - return; + case osl_Signal_ActIgnore: + return; - case NAMESPACE_VOS(OSignalHandler)::TAction_AbortApplication: - abort(); + case osl_Signal_ActAbortApp: + abort(); - case NAMESPACE_VOS(OSignalHandler)::TAction_KillApplication: - exit(-1); + default: + case osl_Signal_ActKillApp: + exit(-1); } } @@ -989,7 +990,7 @@ ResMgr::~ResMgr() osl::Guard<osl::Mutex> aGuard( getResMgrMutex() ); ResMgrContainer::get().freeResMgr( pImpRes ); - + // clean up possible left rc stack frames while( nCurStack > 0 ) { @@ -1007,7 +1008,7 @@ void ResMgr::incStack() if( nCurStack >= int(aStack.size()) ) aStack.push_back( ImpRCStack() ); aStack[nCurStack].Clear(); - + DBG_ASSERT( nCurStack < 32, "Resource stack unreasonably large" ); } @@ -1027,7 +1028,7 @@ void ResMgr::decStack() { #if OSL_DEBUG_LEVEL > 1 OSL_TRACE( "returning from fallback %s\n", - OUStringToOString(pFallbackResMgr->GetFileName(), osl_getThreadTextEncoding() ).getStr() ); + OUStringToOString(pFallbackResMgr->GetFileName(), osl_getThreadTextEncoding() ).getStr() ); #endif delete pFallbackResMgr; pFallbackResMgr = NULL; @@ -1080,14 +1081,14 @@ BOOL ResMgr::IsAvailable( const ResId& rId, const Resource* pResObj ) const if ( !pMgr ) pMgr = this; - + if( pMgr->pFallbackResMgr ) { ResId aId( rId ); aId.SetResMgr( NULL ); return pMgr->pFallbackResMgr->IsAvailable( aId, pResObj ); } - + if ( !pResObj || pResObj == pMgr->aStack[pMgr->nCurStack].pResObj ) { if ( !pClassRes ) @@ -1114,7 +1115,7 @@ void* ResMgr::GetClass() if( pFallbackResMgr ) return pFallbackResMgr->GetClass(); - + return aStack[nCurStack].pClassRes; } @@ -1134,7 +1135,7 @@ BOOL ResMgr::GetResource( const ResId& rId, const Resource* pResObj ) ResMgr* pMgr = rId.GetResMgr(); if ( pMgr && (this != pMgr) ) return pMgr->GetResource( rId, pResObj ); - + // normally Increment will pop the context; this is // not possible in RC_NOTFOUND case, so pop a frame here ImpRCStack* pTop = &aStack[nCurStack]; @@ -1247,7 +1248,7 @@ void ResMgr::PopContext( const Resource* pResObj ) pFallbackResMgr->PopContext( pResObj ); return; } - + #ifdef DBG_UTIL if ( DbgIsResource() ) { @@ -1298,7 +1299,7 @@ RSHEADER_TYPE* ResMgr::CreateBlock( const ResId& rId ) aId.SetResMgr( NULL ); return pFallbackResMgr->CreateBlock( aId ); } - + RSHEADER_TYPE* pHeader = NULL; if ( GetResource( rId ) ) { @@ -1384,7 +1385,7 @@ sal_uInt32 ResMgr::GetRemainSize() if( pFallbackResMgr ) return pFallbackResMgr->GetRemainSize(); - + const ImpRCStack& rTop = aStack[nCurStack]; return (sal_uInt32)((long)(BYTE *)rTop.pResource + rTop.pResource->GetLocalOff() - @@ -1399,11 +1400,11 @@ void* ResMgr::Increment( sal_uInt32 nSize ) if( pFallbackResMgr ) return pFallbackResMgr->Increment( nSize ); - + ImpRCStack& rStack = aStack[nCurStack]; if( (rStack.Flags & RC_NOTFOUND) ) return rStack.pClassRes; - + BYTE* pClassRes = (BYTE*)rStack.pClassRes + nSize; rStack.pClassRes = pClassRes; @@ -1679,9 +1680,9 @@ ResMgr* ResMgr::CreateResMgr( const sal_Char* pPrefixName, osl::Guard<osl::Mutex> aGuard( getResMgrMutex() ); OUString aPrefix( pPrefixName, strlen( pPrefixName ), osl_getThreadTextEncoding() ); - + if( ! aLocale.Language.getLength() ) - aLocale = ResMgrContainer::get().getDefLocale(); + aLocale = ResMgrContainer::get().getDefLocale(); InternalResMgr* pImp = ResMgrContainer::get().getResMgr( aPrefix, aLocale ); return pImp ? new ResMgr( pImp ) : NULL; @@ -1699,7 +1700,7 @@ ResMgr* ResMgr::SearchCreateResMgr( if( ! rLocale.Language.getLength() ) rLocale = ResMgrContainer::get().getDefLocale(); - + InternalResMgr* pImp = ResMgrContainer::get().getResMgr( aPrefix, rLocale ); return pImp ? new ResMgr( pImp ) : NULL; } @@ -1712,7 +1713,7 @@ INT16 ResMgr::ReadShort() if( pFallbackResMgr ) return pFallbackResMgr->ReadShort(); - + INT16 n = GetShort( GetClass() ); Increment( sizeof( INT16 ) ); return n; @@ -1726,7 +1727,7 @@ INT32 ResMgr::ReadLong() if( pFallbackResMgr ) return pFallbackResMgr->ReadLong(); - + INT32 n = GetLong( GetClass() ); Increment( sizeof( INT32 ) ); return n; @@ -1740,7 +1741,7 @@ UniString ResMgr::ReadStringWithoutHook() if( pFallbackResMgr ) return pFallbackResMgr->ReadStringWithoutHook(); - + UniString aRet; const ImpRCStack& rTop = aStack[nCurStack]; @@ -1752,7 +1753,7 @@ UniString ResMgr::ReadStringWithoutHook() } else Increment( GetStringWithoutHook( aRet, (const BYTE*)GetClass() ) ); - + return aRet; } @@ -1772,7 +1773,7 @@ ULONG ResMgr::GetAutoHelpId() if( pFallbackResMgr ) return pFallbackResMgr->GetAutoHelpId(); - + DBG_ASSERT( nCurStack, "resource stack empty in Auto help id generation" ); if( nCurStack < 1 || nCurStack > 2 ) return 0; @@ -1784,7 +1785,7 @@ ULONG ResMgr::GetAutoHelpId() if( !nGID || nGID > 32767 ) return 0; - + ULONG nHID = 0; // GGGg gggg::gggg gggg::ggLL LLLl::llll llll @@ -1846,7 +1847,7 @@ ULONG ResMgr::GetAutoHelpId() return 0; } // of switch nHID |= nGID << 14; - + return nHID; } @@ -1890,9 +1891,9 @@ SimpleResMgr::SimpleResMgr( const sal_Char* pPrefixName, osl::Guard<osl::Mutex> aGuard( getResMgrMutex() ); if( ! aLocale.Language.getLength() ) - aLocale = ResMgrContainer::get().getDefLocale(); - - m_pResImpl = ResMgrContainer::get().getResMgr( aPrefix, aLocale, true ); + aLocale = ResMgrContainer::get().getDefLocale(); + + m_pResImpl = ResMgrContainer::get().getResMgr( aPrefix, aLocale, true ); DBG_ASSERT( m_pResImpl, "SimpleResMgr::SimpleResMgr : have no impl class !" ); } @@ -1900,7 +1901,7 @@ SimpleResMgr::SimpleResMgr( const sal_Char* pPrefixName, SimpleResMgr::SimpleResMgr( const ::rtl::OUString& _rPrefixName, ::com::sun::star::lang::Locale& _inout_Locale ) { osl::Guard<osl::Mutex> aGuard( getResMgrMutex() ); - m_pResImpl = ResMgrContainer::get().getResMgr( _rPrefixName, _inout_Locale, true ); + m_pResImpl = ResMgrContainer::get().getResMgr( _rPrefixName, _inout_Locale, true ); } // ----------------------------------------------------------------------- |