1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: targeting.hxx,v $
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 ************************************************************************/
31 #ifndef __FRAMEWORK_MACROS_DEBUG_TARGETING_HXX_
32 #define __FRAMEWORK_MACROS_DEBUG_TARGETING_HXX_
34 //*****************************************************************************************************************
35 // special macros for targeting of frames
36 //*****************************************************************************************************************
38 #ifdef ENABLE_TARGETINGDEBUG
40 //_____________________________________________________________________________________________________________
42 //_____________________________________________________________________________________________________________
44 #ifndef _RTL_STRBUF_HXX_
45 #include <rtl/strbuf.hxx>
48 /*_____________________________________________________________________________________________________________
51 For follow macros we need a special log file. If user forget to specify anyone, we must do it for him!
52 _____________________________________________________________________________________________________________*/
54 #ifndef LOGFILE_TARGETING
55 #define LOGFILE_TARGETSTEPS "targetsteps.log"
56 #define LOGFILE_TARGETPARAM "targetparam.log"
59 /*_____________________________________________________________________________________________________________
60 LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS )
62 Log format for parameter e.g.: Desktop::findFrame( "frame1", 23 ) my name is "desktop"
63 Log format for steps e.g.: desktop--
65 With this macro you can log informations about search parameter of method "findFrame()" of an service.
66 Use it at beginning of search only!
67 _____________________________________________________________________________________________________________*/
69 #define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS ) \
70 /* Use new scope to prevent code against multiple variable defines! */ \
72 ::rtl::OStringBuffer sBufferParam(256); \
73 ::rtl::OStringBuffer sBufferSteps(256); \
74 sBufferParam.append( SSERVICE ); \
75 sBufferParam.append( "::findFrame( \"" ); \
76 sBufferParam.append( U2B( STARGETNAME ) ); \
77 sBufferParam.append( "\", " ); \
78 sBufferParam.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \
79 sBufferParam.append( " ) my name is \"" ); \
80 sBufferParam.append( U2B( SFRAMENAME ) ); \
81 sBufferParam.append( "\"\n" ); \
82 sBufferSteps.append( U2B( SFRAMENAME ) ); \
83 sBufferSteps.append( "--" ); \
84 WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBufferParam.makeStringAndClear() ) \
85 WRITE_LOGFILE( LOGFILE_TARGETSTEPS, sBufferSteps.makeStringAndClear() ) \
88 /*_____________________________________________________________________________________________________________
89 LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS )
91 With this macro you can log informations about search parameter of method "queryDispatch()" of an service.
92 Use it at beginning of search only!
93 _____________________________________________________________________________________________________________*/
95 #define LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS ) \
96 /* Use new scope to prevent code against multiple variable defines! */ \
98 ::rtl::OStringBuffer sBuffer(1024); \
99 sBuffer.append( "[ " ); \
100 sBuffer.append( U2B( SFRAMENAME ) ); \
101 sBuffer.append( "] " ); \
102 sBuffer.append( SSERVICE ); \
103 sBuffer.append( "::queryDispatch( \"" ); \
104 sBuffer.append( U2B( AURL.Complete ) ); \
105 sBuffer.append( "\", \"" ); \
106 sBuffer.append( U2B( STARGETNAME ) ); \
107 sBuffer.append( "\", " ); \
108 sBuffer.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \
109 sBuffer.append( " )\n" ); \
110 WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() ) \
113 /*_____________________________________________________________________________________________________________
114 LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER )
116 With this macro you can log informations about search parameter of method "loadComponentFromURL()" of an service.
117 Use it at beginning of search only!
118 _____________________________________________________________________________________________________________*/
120 #define LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER ) \
121 /* Use new scope to prevent code against multiple variable defines! */ \
123 ::rtl::OStringBuffer sBuffer(1024); \
124 sBuffer.append( "[ " ); \
125 sBuffer.append( U2B( SFRAMENAME ) ); \
126 sBuffer.append( "] " ); \
127 sBuffer.append( SSERVICE ); \
128 sBuffer.append( "::loadComponentFromURL( \"" ); \
129 sBuffer.append( U2B( SURL ) ); \
130 sBuffer.append( "\", \"" ); \
131 sBuffer.append( U2B( STARGETNAME ) ); \
132 sBuffer.append( "\", " ); \
133 sBuffer.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \
134 sBuffer.append( ", " ); \
135 sal_Int32 nCount = SEQPARAMETER.getLength(); \
136 for( sal_Int32 nParameter=0; nParameter<nCount; ++nParameter ) \
138 sBuffer.append( U2B( SEQPARAMETER[nParameter].Name )); \
139 if( nParameter<(nCount-1) ) \
141 sBuffer.append( " | " ); \
144 sBuffer.append( " )\n" ); \
145 WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() ) \
148 /*_____________________________________________________________________________________________________________
149 LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME )
151 With this macro you can log informations about search result of "findFrame()".
152 Use it at the end of this method only!
153 _____________________________________________________________________________________________________________*/
155 #define LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME ) \
156 /* Use new scope to prevent code against multiple variable defines! */ \
158 ::rtl::OStringBuffer sBufferParam(256); \
159 ::rtl::OStringBuffer sBufferSteps(256); \
160 sBufferParam.append( SSERVICE ); \
161 sBufferParam.append( "::findFrame() at \"" ); \
162 sBufferParam.append( U2B( SFRAMENAME ) ); \
163 sBufferParam.append( "\" " ); \
164 if( XFRAME.is() == sal_True ) \
166 sBufferParam.append( "return with valid frame.\n" ); \
167 sBufferSteps.append( "OK [" ); \
168 sBufferSteps.append( U2B( XFRAME->getName() ) ); \
169 sBufferSteps.append( "]\n" ); \
173 sBufferParam.append( "return with NULL frame!\n"); \
174 sBufferSteps.append( "??\n" ); \
176 WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBufferParam.makeStringAndClear() ) \
177 WRITE_LOGFILE( LOGFILE_TARGETSTEPS, sBufferSteps.makeStringAndClear() ) \
180 /*_____________________________________________________________________________________________________________
181 LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER )
183 With this macro you can log informations about search result of "queryDispatch()".
184 Use it at the end of this method only!
185 _____________________________________________________________________________________________________________*/
187 #define LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER ) \
188 /* Use new scope to prevent code against multiple variable defines! */ \
190 ::rtl::OStringBuffer sBuffer(1024); \
191 sBuffer.append( "[ " ); \
192 sBuffer.append( U2B( SFRAMENAME ) ); \
193 sBuffer.append( "] " ); \
194 sBuffer.append( SSERVICE ); \
195 if( XDISPATCHER.is() == sal_True ) \
197 sBuffer.append( "::queryDispatch() return with valid dispatcher." ); \
201 sBuffer.append( "::queryDispatch() return with NULL dispatcher!" ); \
203 sBuffer.append( "\n" ); \
204 WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() ) \
207 /*_____________________________________________________________________________________________________________
208 LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT )
210 With this macro you can log informations about search result of "loadComponentFromURL()".
211 Use it at the end of this method only!
212 _____________________________________________________________________________________________________________*/
214 #define LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT ) \
215 /* Use new scope to prevent code against multiple variable defines! */ \
217 ::rtl::OStringBuffer sBuffer(1024); \
218 sBuffer.append( "[ " ); \
219 sBuffer.append( U2B( SFRAMENAME ) ); \
220 sBuffer.append( "] " ); \
221 sBuffer.append( SSERVICE ); \
222 if( XCOMPONENT.is() == sal_True ) \
224 sBuffer.append( "::loadComponentFromURL() return with valid component." ); \
228 sBuffer.append( "::loadComponentFromURL() return with NULL component!" ); \
230 sBuffer.append( "\n" ); \
231 WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() ) \
234 #else // #ifdef ENABLE_TARGETINGDEBUG
236 /*_____________________________________________________________________________________________________________
237 If right testmode is'nt set - implements these macro empty!
238 _____________________________________________________________________________________________________________*/
240 #undef LOGFILE_TARGETPARAM
241 #undef LOGFILE_TARGETSTEPS
242 #define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS )
243 #define LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS )
244 #define LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER )
245 #define LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME )
246 #define LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER )
247 #define LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT )
249 #endif // #ifdef ENABLE_TARGETINGDEBUG
251 //*****************************************************************************************************************
253 //*****************************************************************************************************************
255 #endif // #ifndef __FRAMEWORK_MACROS_DEBUG_TARGETING_HXX_