merge the formfield patch from ooo-build
[ooovba.git] / sfx2 / source / inc / sfxtypes.hxx
blob5524a9093c45457d90b1de529b12bde993da6d35
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sfxtypes.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFX_SFXTYPES_HXX
31 #define _SFX_SFXTYPES_HXX
33 #include <tools/debug.hxx>
34 #ifndef _RC_HXX //autogen
35 #include <tools/rc.hxx>
36 #endif
37 #ifndef _RCID_H //autogen
38 #include <tools/rcid.h>
39 #endif
40 #ifndef _RESID_HXX //autogen
41 #include <tools/resid.hxx>
42 #endif
43 #include <tools/link.hxx>
44 #ifndef _APP_HXX //autogen
45 #include <vcl/svapp.hxx>
46 #endif
47 #include <vcl/wrkwin.hxx>
49 #ifndef _VOS_MUTEX_HXX //autogen
50 #include <vos/mutex.hxx>
51 #endif
53 #ifndef DELETEZ
54 #define DELETEZ(pPtr) ( delete pPtr, pPtr = 0 )
55 #endif
57 #ifndef DELETEX
58 #ifdef DBG_UTIL
59 #define DELETEX(pPtr) ( delete pPtr, (void*&) pPtr = (void*) 0xFFFFFFFF )
60 #else
61 #define DELETEX(pPtr) delete pPtr
62 #endif
63 #endif
65 class SfxShell;
66 class Timer;
68 #if !defined(_SFX_APPCTOR_CXX) && defined(WNT)
69 #ifndef _DLL_
70 #error _DLL_ mal wieder nicht defined => GetpApp() == 0
71 #endif
72 #endif
74 //------------------------------------------------------------------------
76 // Macro fuer den Call-Profiler unter WinNT
77 // mit S_CAP kann eine Messung gestarted, mit E_CAP wieder gestoppt werden
78 #if defined( WNT ) && defined( PROFILE )
80 extern "C" {
81 void StartCAP();
82 void StopCAP();
83 void DumpCAP();
86 #define S_CAP() StartCAP();
87 #define E_CAP() StopCAP(); DumpCAP();
89 struct _Capper
91 _Capper() { S_CAP(); }
92 ~_Capper() { E_CAP(); }
95 #define CAP _Capper _aCap_
97 #else
99 #define S_CAP()
100 #define E_CAP()
101 #define CAP
103 #endif
105 #ifdef DBG_UTIL
106 #ifndef DBG
107 #define DBG(statement) statement
108 #endif
109 #define DBG_OUTF(x) DbgOutf x
110 #else
111 #ifndef DBG
112 #define DBG(statement)
113 #endif
114 #define DBG_OUTF(x)
115 #endif
117 #define TRIM(s) s.EraseLeadingChars().EraseTrailingChars()
119 //------------------------------------------------------------------------
121 String SfxShellIdent_Impl( const SfxShell *pSh );
123 //------------------------------------------------------------------------
125 #if defined(DBG_UTIL) && ( defined(WNT) || defined(OS2) )
127 class SfxStack
129 static unsigned nLevel;
131 public:
132 SfxStack( const char *pName )
134 ++nLevel;
135 DbgOutf( "STACK: enter %3d %s", nLevel, pName );
137 ~SfxStack()
139 DbgOutf( "STACK: leave %3d", nLevel );
140 --nLevel;
144 #define SFX_STACK(s) SfxStack aSfxStack_( #s )
145 #else
146 #define SFX_STACK(s)
147 #endif
149 //------------------------------------------------------------------------
151 String SearchAndReplace( const String &rSource,
152 const String &rToReplace,
153 const String &rReplacement );
155 #define SFX_PASSWORD_CODE "_:;*\x9A?()/&[&"
156 String SfxStringEncode( const String &rSource,
157 const char *pKey = SFX_PASSWORD_CODE );
158 String SfxStringDecode( const String &rSource,
159 const char *pKey = SFX_PASSWORD_CODE );
162 struct StringList_Impl : private Resource
165 ResId aResId;
167 StringList_Impl( const ResId& rErrIdP, USHORT nId)
168 : Resource( rErrIdP ),aResId(nId, *rErrIdP.GetResMgr()){}
169 ~StringList_Impl() { FreeResource(); }
171 String GetString(){ return String( aResId ); }
172 operator BOOL(){return IsAvailableRes(aResId.SetRT(RSC_STRING));}
176 #define SFX_DEL_PTRARR(pArr) \
178 for ( USHORT n = (pArr)->Count(); n--; ) \
179 delete (pArr)->GetObject(n); \
180 DELETEX(pArr); \
183 class SfxBoolResetter
185 BOOL& _rVar;
186 BOOL _bOld;
188 public:
189 SfxBoolResetter( BOOL &rVar )
190 : _rVar( rVar ),
191 _bOld( rVar )
194 ~SfxBoolResetter()
195 { _rVar = _bOld; }
198 #define GPF() *(int*)0 = 0
200 #endif // #ifndef _SFX_SFXTYPES_HXX