xref: /AOO41X/main/basic/inc/basic/testtool.hxx (revision 234bd5c559aaf7abbd02d045859137b774cd8b34)
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 _BASIC_TESTTOOL_HXX_
24 #define _BASIC_TESTTOOL_HXX_
25 
26 #include <svl/smplhint.hxx>
27 #include <tools/string.hxx>
28 
29 #define TESTTOOL_DEFAULT_PORT 12479
30 #define UNO_DEFAULT_PORT 12480
31 #define DEFAULT_HOST "localhost"
32 
33 #define TT_SIGNATURE_FOR_UNICODE_TEXTFILES "'encoding UTF-8  Do not remove or change this line!"
34 
35 #define ASSERTION_STACK_PREFIX "Backtrace:"
36 
37 // #94145# Due to a tab in TT_SIGNATURE_FOR_UNICODE_TEXTFILES which is changed to blanks by some editors
38 // this routine became necessary
39 sal_Bool IsTTSignatureForUnicodeTextfile( String aLine );
40 
41 //#include "testapp.hxx"
42 #define ADD_ERROR_QUIET(nNr, aStr)                                      \
43 {                                                                       \
44     ErrorEntry *pErr;                                                   \
45     if ( BasicRuntimeAccess::HasRuntime() )                             \
46     {                                                                   \
47         BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();           \
48         xub_StrLen aErrLn = StarBASIC::GetErl();                        \
49         if ( 0 == aErrLn )                                              \
50             aErrLn = aRun.GetLine();                                    \
51         pErr = new ErrorEntry(nNr, aStr,                                \
52             aErrLn, aRun.GetCol1(), aRun.GetCol2());                    \
53     }                                                                   \
54     else                                                                \
55     {                                                                   \
56         pErr = new ErrorEntry(nNr, aStr);                               \
57     }                                                                   \
58     P_FEHLERLISTE->C40_INSERT(ErrorEntry, pErr, P_FEHLERLISTE->Count());\
59 }
60 // ??? Irgendwann noch was mit der UID anfangen !!
61 #define ADD_ERROR(nNr, aStr) { \
62         if ( !SbxBase::IsError() )              \
63             SbxBase::SetError( nNr );           \
64         ADD_ERROR_QUIET(nNr, aStr); \
65 }
66 
67 #define POP_ERROR() P_FEHLERLISTE->DeleteAndDestroy(0)
68 #define GET_ERROR() P_FEHLERLISTE->GetObject(0)
69 #define IS_ERROR() ( P_FEHLERLISTE->Count() > 0 )
70 
71 // Transmission of error logs
72 enum TTLogType { LOG_RUN, LOG_TEST_CASE, LOG_ERROR, LOG_CALL_STACK, LOG_MESSAGE, LOG_WARNING, LOG_ASSERTION, LOG_QA_ERROR, LOG_ASSERTION_STACK };
73 
74 struct TTDebugData
75 {
76 public:
77     TTLogType aLogType;
78     String aMsg;
79     String aFilename;
80     xub_StrLen nLine;
81     xub_StrLen nCol1;
82     xub_StrLen nCol2;
83 };
84 
85 struct TTLogMsg
86 {
87 public:
88     String aLogFileName;
89     TTDebugData aDebugData;
90 };
91 
92 // For transmission of window information from the Testapp
93 struct WinInfoRec
94 {
95 public:
96     String aUId;
97     String aKurzname;
98     String aSlotname;
99     String aLangname;
100     sal_uInt16 nRType;
101     String aRName;
102     sal_Bool bIsReset;
103 };
104 
105 // Defines for syntax Highlighting
106 #define TT_KEYWORD      ((SbTextType)100)   // Including locally executed commands like 'use' ...
107 #define TT_REMOTECMD    ((SbTextType)101)   // Remotely executed commands like 'nodebug'
108 #define TT_LOCALCMD     ((SbTextType)102)   // Locally executed commands like 'use'
109 #define TT_CONTROL      ((SbTextType)103)   // Possibly available control loaded by 'use'
110 #define TT_SLOT         ((SbTextType)104)   // Available Slots loaded by 'use'
111 #define TT_METHOD       ((SbTextType)105)   // Possibly allowed Method for controls
112 #define TT_NOMETHOD     ((SbTextType)106)   // No Possibly allowed Method for controls
113 
114 #define FILELIST1       ((SbTextType)111)   // Symbols in file 1
115 #define FILELIST2       ((SbTextType)112)   // Symbols in file 2
116 #define FILELIST3       ((SbTextType)113)   // Symbols in file 3
117 #define FILELIST4       ((SbTextType)114)   // Symbols in file 4
118 
119 /// defines for hints from TestToolObj to the Application
120 #define SBX_HINT_LANGUAGE_EXTENSION_LOADED      SFX_HINT_USER06
121 #define SBX_HINT_EXECUTION_STATUS_INFORMATION   SFX_HINT_USER07
122 
123 #define TT_EXECUTION_ENTERWAIT  0x01
124 #define TT_EXECUTION_LEAVEWAIT  0x02
125 #define TT_EXECUTION_SHOW_ACTION    0x03
126 #define TT_EXECUTION_HIDE_ACTION    0x04
127 
128 class TTExecutionStatusHint : public SfxSimpleHint
129 {
130 private:
131     sal_uInt16 mnType;
132     String maExecutionStatus;
133     String maAdditionalExecutionStatus;
134 
135 public:
136             TYPEINFO();
TTExecutionStatusHint(sal_uInt16 nType,sal_Char * pExecutionStatus,const sal_Char * pAdditionalExecutionStatus="")137             TTExecutionStatusHint( sal_uInt16 nType, sal_Char *pExecutionStatus, const sal_Char *pAdditionalExecutionStatus = "" )
138                 : SfxSimpleHint(SBX_HINT_EXECUTION_STATUS_INFORMATION)
139                 , mnType( nType )
140                 , maExecutionStatus( pExecutionStatus, RTL_TEXTENCODING_ASCII_US )
141                 , maAdditionalExecutionStatus( pAdditionalExecutionStatus, RTL_TEXTENCODING_ASCII_US )
142                 {;}
143 
TTExecutionStatusHint(sal_uInt16 nType,const String & aExecutionStatus=String (),const String & aAdditionalExecutionStatus=String ())144             TTExecutionStatusHint( sal_uInt16 nType, const String &aExecutionStatus = String(), const String &aAdditionalExecutionStatus = String() )
145                 : SfxSimpleHint(SBX_HINT_EXECUTION_STATUS_INFORMATION)
146                 , mnType( nType )
147                 , maExecutionStatus( aExecutionStatus )
148                 , maAdditionalExecutionStatus( aAdditionalExecutionStatus )
149                 {;}
150 
GetExecutionStatus() const151     const String& GetExecutionStatus() const { return maExecutionStatus; }
GetAdditionalExecutionStatus() const152     const String& GetAdditionalExecutionStatus() const { return maAdditionalExecutionStatus; }
GetType()153     sal_uInt16 GetType(){ return mnType; }
154 };
155 
156 #endif // _BASIC_TESTTOOL_HXX_
157