xref: /aoo41x/main/framework/inc/macros/debug/event.hxx (revision f8e07b45)
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 
24 #ifndef __FRAMEWORK_MACROS_DEBUG_EVENT_HXX_
25 #define __FRAMEWORK_MACROS_DEBUG_EVENT_HXX_
26 
27 //*************************************************************************************************************
28 //	special macros for event handling
29 //*************************************************************************************************************
30 
31 #ifdef	ENABLE_EVENTDEBUG
32 
33 	//_________________________________________________________________________________________________________________
34 	//	includes
35 	//_________________________________________________________________________________________________________________
36 
37 	#ifndef _RTL_STRBUF_HXX_
38 	#include <rtl/strbuf.hxx>
39 	#endif
40 
41 	/*_____________________________________________________________________________________________________________
42 		LOGFILE_EVENTDEBUG
43 
44 		For follow macros we need a special log file. If user forget to specify anyone, we must do it for him!
45 	_____________________________________________________________________________________________________________*/
46 
47 	#ifndef	LOGFILE_EVENTDEBUG
48 		#define	LOGFILE_EVENTDEBUG																										\
49 					"events.log"
50 	#endif
51 
52 	/*_____________________________________________________________________________________________________________
53 		LOG_FRAMEACTIONEVENT( SFRAMETYPE, SFRAMENAME, AFRAMEACTION )
54 
55 		Use this macro to print debug informations about sending of events to listener for controling right order.
56 		( Use new scope in macro to declare sBuffer more then on time in same "parentscope"! )
57 	_____________________________________________________________________________________________________________*/
58 
59 	#define LOG_FRAMEACTIONEVENT( SFRAMETYPE, SFRAMENAME, AFRAMEACTION )																\
60 				{																														\
61 					::rtl::OStringBuffer sBuffer(1024);																					\
62 					sBuffer.append( "[ "				);																				\
63 					sBuffer.append( SFRAMETYPE			);																				\
64 					sBuffer.append( " ] \""				);																				\
65 					sBuffer.append( U2B( SFRAMENAME )	);																				\
66 					sBuffer.append( "\" send event \""	);																				\
67 					switch( AFRAMEACTION )																								\
68 					{																													\
69 						case ::com::sun::star::frame::FrameAction_COMPONENT_ATTACHED	:	sBuffer.append("COMPONENT ATTACHED"		);	\
70 																							break;										\
71 						case ::com::sun::star::frame::FrameAction_COMPONENT_DETACHING	:	sBuffer.append("COMPONENT DETACHING"	);	\
72 																							break;										\
73 						case ::com::sun::star::frame::FrameAction_COMPONENT_REATTACHED	:	sBuffer.append("COMPONENT REATTACHED"	);	\
74 																							break;										\
75 						case ::com::sun::star::frame::FrameAction_FRAME_ACTIVATED		:	sBuffer.append("FRAME ACTIVATED"		);	\
76 																							break;										\
77 						case ::com::sun::star::frame::FrameAction_FRAME_DEACTIVATING	:	sBuffer.append("FRAME DEACTIVATING"		);	\
78 																							break;										\
79 						case ::com::sun::star::frame::FrameAction_CONTEXT_CHANGED		:	sBuffer.append("CONTEXT CHANGED"		);	\
80 																							break;										\
81 						case ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED	:	sBuffer.append("FRAME UI ACTIVATED"		);	\
82 																							break;										\
83 						case ::com::sun::star::frame::FrameAction_FRAME_UI_DEACTIVATING	:	sBuffer.append("FRAME UI DEACTIVATING"	);	\
84 																							break;										\
85 						case ::com::sun::star::frame::FrameAction_MAKE_FIXED_SIZE		:	sBuffer.append("MAKE_FIXED_SIZE"		);	\
86 																							break;										\
87 						default:	sBuffer.append("... ERROR: invalid FrameAction detected!"	);										\
88 									break;																								\
89 					}																													\
90 					sBuffer.append( " ... event to listener.\n\n" );																	\
91 					WRITE_LOGFILE( LOGFILE_EVENTDEBUG, sBuffer.makeStringAndClear() )													\
92 				}
93 
94 	/*_____________________________________________________________________________________________________________
95 		LOG_FRAMEACTIONEVENT( SFRAMETYPE, SFRAMENAME )
96 
97 		These macro log information about sending of dispose events to listener.
98 		( Use new scope in macro to declare sBuffer more then on time in same "parentscope"! )
99 	_____________________________________________________________________________________________________________*/
100 
101 	#define	LOG_DISPOSEEVENT( SFRAMETYPE, SFRAMENAME )																					\
102 				{																														\
103 					::rtl::OStringBuffer sBuffer(1024);																					\
104 					sBuffer.append( "[ "									);															\
105 					sBuffer.append( SFRAMETYPE								);															\
106 					sBuffer.append( " ] \""									);															\
107 					sBuffer.append( U2B( SFRAMENAME )						);															\
108 					sBuffer.append( "\" send dispose event to listener.\n\n");															\
109 					WRITE_LOGFILE( LOGFILE_EVENTDEBUG, sBuffer.makeStringAndClear() )													\
110 				}
111 
112 #else	// #ifdef ENABLE_EVENTDEBUG
113 
114 	/*_____________________________________________________________________________________________________________
115 		If right testmode is'nt set - implements these macros empty!
116 	_____________________________________________________________________________________________________________*/
117 
118 	#undef	LOGFILE_EVENTDEBUG
119 	#define LOG_FRAMEACTIONEVENT( SFRAMETYPE, SFRAMENAME, AFRAMEACTION )
120 	#define	LOG_DISPOSEEVENT( SFRAMETYPE, SFRAMENAME )
121 
122 #endif	// #ifdef ENABLE_EVENTDEBUG
123 
124 //*****************************************************************************************************************
125 //	end of file
126 //*****************************************************************************************************************
127 
128 #endif	// #ifndef __FRAMEWORK_MACROS_DEBUG_EVENT_HXX_
129