xref: /AOO41X/main/framework/inc/macros/debug/targeting.hxx (revision f8e07b45f7e1fb69563504f404bb0b75210f0be6)
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_TARGETING_HXX_
25 #define __FRAMEWORK_MACROS_DEBUG_TARGETING_HXX_
26 
27 //*****************************************************************************************************************
28 //  special macros for targeting of frames
29 //*****************************************************************************************************************
30 
31 #ifdef  ENABLE_TARGETINGDEBUG
32 
33     //_____________________________________________________________________________________________________________
34     //  includes
35     //_____________________________________________________________________________________________________________
36 
37     #ifndef _RTL_STRBUF_HXX_
38     #include <rtl/strbuf.hxx>
39     #endif
40 
41     /*_____________________________________________________________________________________________________________
42         LOGFILE_TARGETING
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_TARGETING
48         #define LOGFILE_TARGETSTEPS     "targetsteps.log"
49         #define LOGFILE_TARGETPARAM     "targetparam.log"
50     #endif
51 
52     /*_____________________________________________________________________________________________________________
53         LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS )
54 
55         Log format for parameter e.g.: Desktop::findFrame( "frame1", 23 ) my name is "desktop"
56         Log format for steps     e.g.: desktop--
57 
58         With this macro you can log informations about search parameter of method "findFrame()" of an service.
59         Use it at beginning of search only!
60     _____________________________________________________________________________________________________________*/
61 
62     #define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS )                          \
63                 /* Use new scope to prevent code against multiple variable defines! */                          \
64                 {                                                                                               \
65                     ::rtl::OStringBuffer sBufferParam(256);                                                     \
66                     ::rtl::OStringBuffer sBufferSteps(256);                                                     \
67                     sBufferParam.append( SSERVICE                                               );              \
68                     sBufferParam.append( "::findFrame( \""                                      );              \
69                     sBufferParam.append( U2B( STARGETNAME )                                     );              \
70                     sBufferParam.append( "\", "                                                 );              \
71                     sBufferParam.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) )   );              \
72                     sBufferParam.append( " ) my name is \""                                     );              \
73                     sBufferParam.append( U2B( SFRAMENAME )                                      );              \
74                     sBufferParam.append( "\"\n"                                                 );              \
75                     sBufferSteps.append( U2B( SFRAMENAME )                                      );              \
76                     sBufferSteps.append( "--"                                                   );              \
77                     WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBufferParam.makeStringAndClear() )                     \
78                     WRITE_LOGFILE( LOGFILE_TARGETSTEPS, sBufferSteps.makeStringAndClear() )                     \
79                 }
80 
81     /*_____________________________________________________________________________________________________________
82         LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS )
83 
84         With this macro you can log informations about search parameter of method "queryDispatch()" of an service.
85         Use it at beginning of search only!
86     _____________________________________________________________________________________________________________*/
87 
88     #define LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS )                        \
89                 /* Use new scope to prevent code against multiple variable defines! */                                  \
90                 {                                                                                                       \
91                     ::rtl::OStringBuffer sBuffer(1024);                                                                 \
92                     sBuffer.append( "[ "                                                    );                          \
93                     sBuffer.append( U2B( SFRAMENAME )                                       );                          \
94                     sBuffer.append( "] "                                                    );                          \
95                     sBuffer.append( SSERVICE                                                );                          \
96                     sBuffer.append( "::queryDispatch( \""                                   );                          \
97                     sBuffer.append( U2B( AURL.Complete )                                    );                          \
98                     sBuffer.append( "\", \""                                                );                          \
99                     sBuffer.append( U2B( STARGETNAME )                                      );                          \
100                     sBuffer.append( "\", "                                                  );                          \
101                     sBuffer.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) )    );                          \
102                     sBuffer.append( " )\n"                                                  );                          \
103                     WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() )                                  \
104                 }
105 
106     /*_____________________________________________________________________________________________________________
107         LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER )
108 
109         With this macro you can log informations about search parameter of method "loadComponentFromURL()" of an service.
110         Use it at beginning of search only!
111     _____________________________________________________________________________________________________________*/
112 
113     #define LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER )   \
114                 /* Use new scope to prevent code against multiple variable defines! */                                  \
115                 {                                                                                                       \
116                     ::rtl::OStringBuffer sBuffer(1024);                                                                 \
117                     sBuffer.append( "[ "                                                    );                          \
118                     sBuffer.append( U2B( SFRAMENAME )                                       );                          \
119                     sBuffer.append( "] "                                                    );                          \
120                     sBuffer.append( SSERVICE                                                );                          \
121                     sBuffer.append( "::loadComponentFromURL( \""                            );                          \
122                     sBuffer.append( U2B( SURL )                                             );                          \
123                     sBuffer.append( "\", \""                                                );                          \
124                     sBuffer.append( U2B( STARGETNAME )                                      );                          \
125                     sBuffer.append( "\", "                                                  );                          \
126                     sBuffer.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) )    );                          \
127                     sBuffer.append( ", "                                                    );                          \
128                     sal_Int32 nCount = SEQPARAMETER.getLength();                                                        \
129                     for( sal_Int32 nParameter=0; nParameter<nCount; ++nParameter )                                      \
130                     {                                                                                                   \
131                         sBuffer.append( U2B( SEQPARAMETER[nParameter].Name ));                                          \
132                         if( nParameter<(nCount-1) )                                                                     \
133                         {                                                                                               \
134                             sBuffer.append( " | " );                                                                    \
135                         }                                                                                               \
136                     }                                                                                                   \
137                     sBuffer.append( " )\n"                                                  );                          \
138                     WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() )                                  \
139                 }
140 
141     /*_____________________________________________________________________________________________________________
142         LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME )
143 
144         With this macro you can log informations about search result of "findFrame()".
145         Use it at the end of this method only!
146     _____________________________________________________________________________________________________________*/
147 
148     #define LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME )                                                        \
149                 /* Use new scope to prevent code against multiple variable defines! */                                  \
150                 {                                                                                                       \
151                     ::rtl::OStringBuffer sBufferParam(256);                                                             \
152                     ::rtl::OStringBuffer sBufferSteps(256);                                                             \
153                     sBufferParam.append( SSERVICE               );                                                      \
154                     sBufferParam.append( "::findFrame() at \""  );                                                      \
155                     sBufferParam.append( U2B( SFRAMENAME )      );                                                      \
156                     sBufferParam.append( "\" "                  );                                                      \
157                     if( XFRAME.is() == sal_True )                                                                       \
158                     {                                                                                                   \
159                         sBufferParam.append( "return with valid frame.\n"       );                                      \
160                         sBufferSteps.append( "OK ["                             );                                      \
161                         sBufferSteps.append( U2B( XFRAME->getName() )           );                                      \
162                         sBufferSteps.append( "]\n"                              );                                      \
163                     }                                                                                                   \
164                     else                                                                                                \
165                     {                                                                                                   \
166                         sBufferParam.append( "return with NULL frame!\n");                                              \
167                         sBufferSteps.append( "??\n"                     );                                              \
168                     }                                                                                                   \
169                     WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBufferParam.makeStringAndClear() )                             \
170                     WRITE_LOGFILE( LOGFILE_TARGETSTEPS, sBufferSteps.makeStringAndClear() )                             \
171                 }
172 
173     /*_____________________________________________________________________________________________________________
174         LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER )
175 
176         With this macro you can log informations about search result of "queryDispatch()".
177         Use it at the end of this method only!
178     _____________________________________________________________________________________________________________*/
179 
180     #define LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER )                                               \
181                 /* Use new scope to prevent code against multiple variable defines! */                                  \
182                 {                                                                                                       \
183                     ::rtl::OStringBuffer sBuffer(1024);                                                                 \
184                     sBuffer.append( "[ "                );                                                              \
185                     sBuffer.append( U2B( SFRAMENAME )   );                                                              \
186                     sBuffer.append( "] "                );                                                              \
187                     sBuffer.append( SSERVICE            );                                                              \
188                     if( XDISPATCHER.is() == sal_True )                                                                  \
189                     {                                                                                                   \
190                         sBuffer.append( "::queryDispatch() return with valid dispatcher."   );                          \
191                     }                                                                                                   \
192                     else                                                                                                \
193                     {                                                                                                   \
194                         sBuffer.append( "::queryDispatch() return with NULL dispatcher!"    );                          \
195                     }                                                                                                   \
196                     sBuffer.append( "\n" );                                                                             \
197                     WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() )                                  \
198                 }
199 
200     /*_____________________________________________________________________________________________________________
201         LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT )
202 
203         With this macro you can log informations about search result of "loadComponentFromURL()".
204         Use it at the end of this method only!
205     _____________________________________________________________________________________________________________*/
206 
207     #define LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT )                                         \
208                 /* Use new scope to prevent code against multiple variable defines! */                                  \
209                 {                                                                                                       \
210                     ::rtl::OStringBuffer sBuffer(1024);                                                                 \
211                     sBuffer.append( "[ "                );                                                              \
212                     sBuffer.append( U2B( SFRAMENAME )   );                                                              \
213                     sBuffer.append( "] "                );                                                              \
214                     sBuffer.append( SSERVICE            );                                                              \
215                     if( XCOMPONENT.is() == sal_True )                                                                   \
216                     {                                                                                                   \
217                         sBuffer.append( "::loadComponentFromURL() return with valid component." );                      \
218                     }                                                                                                   \
219                     else                                                                                                \
220                     {                                                                                                   \
221                         sBuffer.append( "::loadComponentFromURL() return with NULL component!"  );                      \
222                     }                                                                                                   \
223                     sBuffer.append( "\n" );                                                                             \
224                     WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear() )                                  \
225                 }
226 
227 #else   // #ifdef ENABLE_TARGETINGDEBUG
228 
229     /*_____________________________________________________________________________________________________________
230         If right testmode is'nt set - implements these macro empty!
231     _____________________________________________________________________________________________________________*/
232 
233     #undef  LOGFILE_TARGETPARAM
234     #undef  LOGFILE_TARGETSTEPS
235     #define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS )
236     #define LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS )
237     #define LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER )
238     #define LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME )
239     #define LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER )
240     #define LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT )
241 
242 #endif  // #ifdef ENABLE_TARGETINGDEBUG
243 
244 //*****************************************************************************************************************
245 //  end of file
246 //*****************************************************************************************************************
247 
248 #endif  // #ifndef __FRAMEWORK_MACROS_DEBUG_TARGETING_HXX_
249