1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _SFX_SFXTYPES_HXX 28 #define _SFX_SFXTYPES_HXX 29 30 #include <tools/debug.hxx> 31 #ifndef _RC_HXX //autogen 32 #include <tools/rc.hxx> 33 #endif 34 #ifndef _RCID_H //autogen 35 #include <tools/rcid.h> 36 #endif 37 #ifndef _RESID_HXX //autogen 38 #include <tools/resid.hxx> 39 #endif 40 #include <tools/link.hxx> 41 #ifndef _APP_HXX //autogen 42 #include <vcl/svapp.hxx> 43 #endif 44 #include <vcl/wrkwin.hxx> 45 46 #ifndef _VOS_MUTEX_HXX //autogen 47 #include <vos/mutex.hxx> 48 #endif 49 50 #ifndef DELETEZ 51 #define DELETEZ(pPtr) ( delete pPtr, pPtr = 0 ) 52 #endif 53 54 #ifndef DELETEX 55 #ifdef DBG_UTIL 56 #define DELETEX(pPtr) ( delete pPtr, (void*&) pPtr = (void*) 0xFFFFFFFF ) 57 #else 58 #define DELETEX(pPtr) delete pPtr 59 #endif 60 #endif 61 62 class SfxShell; 63 class Timer; 64 65 //------------------------------------------------------------------------ 66 67 // Macro fuer den Call-Profiler unter WinNT 68 // mit S_CAP kann eine Messung gestarted, mit E_CAP wieder gestoppt werden 69 #if defined( WNT ) && defined( PROFILE ) 70 71 extern "C" { 72 void StartCAP(); 73 void StopCAP(); 74 void DumpCAP(); 75 }; 76 77 #define S_CAP() StartCAP(); 78 #define E_CAP() StopCAP(); DumpCAP(); 79 80 struct _Capper 81 { 82 _Capper() { S_CAP(); } 83 ~_Capper() { E_CAP(); } 84 }; 85 86 #define CAP _Capper _aCap_ 87 88 #else 89 90 #define S_CAP() 91 #define E_CAP() 92 #define CAP 93 94 #endif 95 96 #ifdef DBG_UTIL 97 #ifndef DBG 98 #define DBG(statement) statement 99 #endif 100 #define DBG_OUTF(x) DbgOutf x 101 #else 102 #ifndef DBG 103 #define DBG(statement) 104 #endif 105 #define DBG_OUTF(x) 106 #endif 107 108 #define TRIM(s) s.EraseLeadingChars().EraseTrailingChars() 109 110 //------------------------------------------------------------------------ 111 112 String SfxShellIdent_Impl( const SfxShell *pSh ); 113 114 //------------------------------------------------------------------------ 115 116 #if defined(DBG_UTIL) && ( defined(WNT) || defined(OS2) ) 117 118 class SfxStack 119 { 120 static unsigned nLevel; 121 122 public: 123 SfxStack( const char *pName ) 124 { 125 ++nLevel; 126 DbgOutf( "STACK: enter %3d %s", nLevel, pName ); 127 } 128 ~SfxStack() 129 { 130 DbgOutf( "STACK: leave %3d", nLevel ); 131 --nLevel; 132 } 133 }; 134 135 #define SFX_STACK(s) SfxStack aSfxStack_( #s ) 136 #else 137 #define SFX_STACK(s) 138 #endif 139 140 //------------------------------------------------------------------------ 141 142 String SearchAndReplace( const String &rSource, 143 const String &rToReplace, 144 const String &rReplacement ); 145 146 #define SFX_PASSWORD_CODE "_:;*\x9A?()/&[&" 147 String SfxStringEncode( const String &rSource, 148 const char *pKey = SFX_PASSWORD_CODE ); 149 String SfxStringDecode( const String &rSource, 150 const char *pKey = SFX_PASSWORD_CODE ); 151 152 153 struct StringList_Impl : private Resource 154 { 155 156 ResId aResId; 157 158 StringList_Impl( const ResId& rErrIdP, sal_uInt16 nId) 159 : Resource( rErrIdP ),aResId(nId, *rErrIdP.GetResMgr()){} 160 ~StringList_Impl() { FreeResource(); } 161 162 String GetString(){ return String( aResId ); } 163 operator sal_Bool(){return IsAvailableRes(aResId.SetRT(RSC_STRING));} 164 165 }; 166 167 #define SFX_DEL_PTRARR(pArr) \ 168 { \ 169 for ( sal_uInt16 n = (pArr)->Count(); n--; ) \ 170 delete (pArr)->GetObject(n); \ 171 DELETEX(pArr); \ 172 } 173 174 class SfxBoolResetter 175 { 176 sal_Bool& _rVar; 177 sal_Bool _bOld; 178 179 public: 180 SfxBoolResetter( sal_Bool &rVar ) 181 : _rVar( rVar ), 182 _bOld( rVar ) 183 {} 184 185 ~SfxBoolResetter() 186 { _rVar = _bOld; } 187 }; 188 189 #define GPF() *(int*)0 = 0 190 191 #endif // #ifndef _SFX_SFXTYPES_HXX 192 193 194