xref: /aoo42x/main/sfx2/source/inc/sfxtypes.hxx (revision 353d8f4d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFX_SFXTYPES_HXX
24 #define _SFX_SFXTYPES_HXX
25 
26 #include <tools/debug.hxx>
27 #ifndef _RC_HXX //autogen
28 #include <tools/rc.hxx>
29 #endif
30 #ifndef _RCID_H //autogen
31 #include <tools/rcid.h>
32 #endif
33 #ifndef _RESID_HXX //autogen
34 #include <tools/resid.hxx>
35 #endif
36 #include <tools/link.hxx>
37 #ifndef _APP_HXX //autogen
38 #include <vcl/svapp.hxx>
39 #endif
40 #include <vcl/wrkwin.hxx>
41 
42 #ifndef _VOS_MUTEX_HXX //autogen
43 #include <vos/mutex.hxx>
44 #endif
45 
46 #ifndef DELETEZ
47 #define DELETEZ(pPtr) ( delete pPtr, pPtr = 0 )
48 #endif
49 
50 #ifndef DELETEX
51 #ifdef DBG_UTIL
52 #define DELETEX(pPtr) ( delete pPtr, (void*&) pPtr = (void*) 0xFFFFFFFF )
53 #else
54 #define DELETEX(pPtr) delete pPtr
55 #endif
56 #endif
57 
58 class SfxShell;
59 class Timer;
60 
61 //------------------------------------------------------------------------
62 
63 // Macro fuer den Call-Profiler unter WinNT
64 // mit S_CAP kann eine Messung gestarted, mit E_CAP wieder gestoppt werden
65 #if defined( WNT ) && defined( PROFILE )
66 
67 extern "C" {
68 	void StartCAP();
69 	void StopCAP();
70 	void DumpCAP();
71 };
72 
73 #define S_CAP()   StartCAP();
74 #define E_CAP()   StopCAP(); DumpCAP();
75 
76 struct _Capper
77 {
_Capper_Capper78 	_Capper() { S_CAP(); }
~_Capper_Capper79 	~_Capper() { E_CAP(); }
80 };
81 
82 #define CAP _Capper _aCap_
83 
84 #else
85 
86 #define S_CAP()
87 #define E_CAP()
88 #define CAP
89 
90 #endif
91 
92 #ifdef DBG_UTIL
93 #ifndef DBG
94 #define DBG(statement) statement
95 #endif
96 #define DBG_OUTF(x) DbgOutf x
97 #else
98 #ifndef DBG
99 #define DBG(statement)
100 #endif
101 #define DBG_OUTF(x)
102 #endif
103 
104 #define TRIM(s) s.EraseLeadingChars().EraseTrailingChars()
105 
106 //------------------------------------------------------------------------
107 
108 String SfxShellIdent_Impl( const SfxShell *pSh );
109 
110 //------------------------------------------------------------------------
111 
112 #if defined(DBG_UTIL) && ( defined(WNT) || defined(OS2) )
113 
114 class SfxStack
115 {
116 	static unsigned nLevel;
117 
118 public:
SfxStack(const char * pName)119 	SfxStack( const char *pName )
120 	{
121 		++nLevel;
122 		DbgOutf( "STACK: enter %3d %s", nLevel, pName );
123 	}
~SfxStack()124 	~SfxStack()
125 	{
126 		DbgOutf( "STACK: leave %3d", nLevel );
127 		--nLevel;
128 	}
129 };
130 
131 #define SFX_STACK(s) SfxStack aSfxStack_( #s )
132 #else
133 #define SFX_STACK(s)
134 #endif
135 
136 //------------------------------------------------------------------------
137 
138 String SearchAndReplace( const String &rSource,
139 						 const String &rToReplace,
140 						 const String &rReplacement );
141 
142 #define SFX_PASSWORD_CODE "_:;*\x9A?()/&[&"
143 String SfxStringEncode( const String &rSource,
144 						const char *pKey = SFX_PASSWORD_CODE );
145 String SfxStringDecode( const String &rSource,
146 						const char *pKey = SFX_PASSWORD_CODE );
147 
148 
149 struct StringList_Impl : private Resource
150 {
151 
152 	ResId aResId;
153 
StringList_ImplStringList_Impl154 	StringList_Impl( const ResId& rErrIdP,  sal_uInt16 nId)
155 		: Resource( rErrIdP ),aResId(nId, *rErrIdP.GetResMgr()){}
~StringList_ImplStringList_Impl156 	~StringList_Impl() { FreeResource(); }
157 
GetStringStringList_Impl158 	String GetString(){ return String( aResId ); }
operator sal_BoolStringList_Impl159 	operator sal_Bool(){return IsAvailableRes(aResId.SetRT(RSC_STRING));}
160 
161 };
162 
163 #define SFX_DEL_PTRARR(pArr) 									\
164 			{                                                   \
165 				for ( sal_uInt16 n = (pArr)->Count(); n--; )        \
166 					delete (pArr)->GetObject(n);                \
167 				DELETEX(pArr);                                  \
168 			}
169 
170 class SfxBoolResetter
171 {
172 	sal_Bool&				_rVar;
173 	sal_Bool				_bOld;
174 
175 public:
SfxBoolResetter(sal_Bool & rVar)176 						SfxBoolResetter( sal_Bool &rVar )
177 						:	_rVar( rVar ),
178 							_bOld( rVar )
179 						{}
180 
~SfxBoolResetter()181 						~SfxBoolResetter()
182 						{ _rVar = _bOld; }
183 };
184 
185 #define GPF() *(int*)0 = 0
186 
187 #endif // #ifndef _SFX_SFXTYPES_HXX
188 
189 
190