xref: /trunk/main/basic/inc/basic/testtool.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _BASIC_TESTTOOL_HXX_
28 #define _BASIC_TESTTOOL_HXX_
29 
30 #include <svl/smplhint.hxx>
31 #include <tools/string.hxx>
32 
33 #define TESTTOOL_DEFAULT_PORT 12479
34 #define UNO_DEFAULT_PORT 12480
35 #define DEFAULT_HOST "localhost"
36 
37 #define TT_SIGNATURE_FOR_UNICODE_TEXTFILES "'encoding UTF-8  Do not remove or change this line!"
38 
39 #define ASSERTION_STACK_PREFIX "Backtrace:"
40 
41 // #94145# Due to a tab in TT_SIGNATURE_FOR_UNICODE_TEXTFILES which is changed to blanks by some editors
42 // this routine became necessary
43 sal_Bool IsTTSignatureForUnicodeTextfile( String aLine );
44 
45 //#include "testapp.hxx"
46 #define ADD_ERROR_QUIET(nNr, aStr)                                      \
47 {                                                                       \
48     ErrorEntry *pErr;                                                   \
49     if ( BasicRuntimeAccess::HasRuntime() )                             \
50     {                                                                   \
51         BasicRuntime aRun = BasicRuntimeAccess::GetRuntime();           \
52         xub_StrLen aErrLn = StarBASIC::GetErl();                        \
53         if ( 0 == aErrLn )                                              \
54             aErrLn = aRun.GetLine();                                    \
55         pErr = new ErrorEntry(nNr, aStr,                                \
56             aErrLn, aRun.GetCol1(), aRun.GetCol2());                    \
57     }                                                                   \
58     else                                                                \
59     {                                                                   \
60         pErr = new ErrorEntry(nNr, aStr);                               \
61     }                                                                   \
62     P_FEHLERLISTE->C40_INSERT(ErrorEntry, pErr, P_FEHLERLISTE->Count());\
63 }
64 // ??? Irgendwann noch was mit der UID anfangen !!
65 #define ADD_ERROR(nNr, aStr) { \
66         if ( !SbxBase::IsError() )              \
67             SbxBase::SetError( nNr );           \
68         ADD_ERROR_QUIET(nNr, aStr); \
69 }
70 
71 #define POP_ERROR() P_FEHLERLISTE->DeleteAndDestroy(0)
72 #define GET_ERROR() P_FEHLERLISTE->GetObject(0)
73 #define IS_ERROR() ( P_FEHLERLISTE->Count() > 0 )
74 
75 // Transmission of error logs
76 enum TTLogType { LOG_RUN, LOG_TEST_CASE, LOG_ERROR, LOG_CALL_STACK, LOG_MESSAGE, LOG_WARNING, LOG_ASSERTION, LOG_QA_ERROR, LOG_ASSERTION_STACK };
77 
78 struct TTDebugData
79 {
80 public:
81     TTLogType aLogType;
82     String aMsg;
83     String aFilename;
84     xub_StrLen nLine;
85     xub_StrLen nCol1;
86     xub_StrLen nCol2;
87 };
88 
89 struct TTLogMsg
90 {
91 public:
92     String aLogFileName;
93     TTDebugData aDebugData;
94 };
95 
96 // For transmission of window information from the Testapp
97 struct WinInfoRec
98 {
99 public:
100     String aUId;
101     String aKurzname;
102     String aSlotname;
103     String aLangname;
104     sal_uInt16 nRType;
105     String aRName;
106     sal_Bool bIsReset;
107 };
108 
109 // Defines for syntax Highlighting
110 #define TT_KEYWORD      ((SbTextType)100)   // Including locally executed commands like 'use' ...
111 #define TT_REMOTECMD    ((SbTextType)101)   // Remotely executed commands like 'nodebug'
112 #define TT_LOCALCMD     ((SbTextType)102)   // Locally executed commands like 'use'
113 #define TT_CONTROL      ((SbTextType)103)   // Possibly available control loaded by 'use'
114 #define TT_SLOT         ((SbTextType)104)   // Available Slots loaded by 'use'
115 #define TT_METHOD       ((SbTextType)105)   // Possibly allowed Method for controls
116 #define TT_NOMETHOD     ((SbTextType)106)   // No Possibly allowed Method for controls
117 
118 #define FILELIST1       ((SbTextType)111)   // Symbols in file 1
119 #define FILELIST2       ((SbTextType)112)   // Symbols in file 2
120 #define FILELIST3       ((SbTextType)113)   // Symbols in file 3
121 #define FILELIST4       ((SbTextType)114)   // Symbols in file 4
122 
123 /// defines for hints from TestToolObj to the Application
124 #define SBX_HINT_LANGUAGE_EXTENSION_LOADED      SFX_HINT_USER06
125 #define SBX_HINT_EXECUTION_STATUS_INFORMATION   SFX_HINT_USER07
126 
127 #define TT_EXECUTION_ENTERWAIT  0x01
128 #define TT_EXECUTION_LEAVEWAIT  0x02
129 #define TT_EXECUTION_SHOW_ACTION    0x03
130 #define TT_EXECUTION_HIDE_ACTION    0x04
131 
132 class TTExecutionStatusHint : public SfxSimpleHint
133 {
134 private:
135     sal_uInt16 mnType;
136     String maExecutionStatus;
137     String maAdditionalExecutionStatus;
138 
139 public:
140             TYPEINFO();
141             TTExecutionStatusHint( sal_uInt16 nType, sal_Char *pExecutionStatus, const sal_Char *pAdditionalExecutionStatus = "" )
142                 : SfxSimpleHint(SBX_HINT_EXECUTION_STATUS_INFORMATION)
143                 , mnType( nType )
144                 , maExecutionStatus( pExecutionStatus, RTL_TEXTENCODING_ASCII_US )
145                 , maAdditionalExecutionStatus( pAdditionalExecutionStatus, RTL_TEXTENCODING_ASCII_US )
146                 {;}
147 
148             TTExecutionStatusHint( sal_uInt16 nType, const String &aExecutionStatus = String(), const String &aAdditionalExecutionStatus = String() )
149                 : SfxSimpleHint(SBX_HINT_EXECUTION_STATUS_INFORMATION)
150                 , mnType( nType )
151                 , maExecutionStatus( aExecutionStatus )
152                 , maAdditionalExecutionStatus( aAdditionalExecutionStatus )
153                 {;}
154 
155     const String& GetExecutionStatus() const { return maExecutionStatus; }
156     const String& GetAdditionalExecutionStatus() const { return maAdditionalExecutionStatus; }
157     sal_uInt16 GetType(){ return mnType; }
158 };
159 
160 #endif // _BASIC_TESTTOOL_HXX_
161