xref: /aoo42x/main/automation/source/inc/testapp.hxx (revision cdf0e10c)
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 
28 #ifndef TESTAPP_HXX
29 #define TESTAPP_HXX
30 
31 #include <basic/sbmod.hxx>
32 #include <basic/testtool.hxx>
33 
34 class CommunicationLink;
35 class CommunicationManagerClientViaSocketTT;
36 class CNames;
37 class ControlItemUId;
38 class CRevNames;
39 //class SbxTransportVariableRef;
40 class ControlsRef;
41 class CmdStream;
42 class FloatingLoadConf;
43 class TestToolObj;
44 class ControlDef;
45 
46 class SbxTransportMethod;
47 class Application;
48 
49 class SotStorage;
50 
51 class ImplTestToolObj;
52 class MyBasic;
53 
54 class ErrorEntry
55 {
56 public:
57 	ErrorEntry(sal_uLong nNr, String aStr = String()) : nError(nNr),aText(aStr),nLine(0),nCol1(0),nCol2(0) {}
58 	ErrorEntry(sal_uLong nNr, String aStr, xub_StrLen l, xub_StrLen c1, xub_StrLen c2 )
59 		: nError(nNr),aText(aStr),nLine(l),nCol1(c1),nCol2(c2) {}
60 	sal_uLong nError;
61 	String aText;
62 	xub_StrLen nLine;
63 	xub_StrLen nCol1;
64 	xub_StrLen nCol2;
65 };
66 
67 SV_DECL_PTRARR_DEL(CErrors, ErrorEntry*, 1, 1)
68 
69 struct ControlDefLoad {
70 	const char* Kurzname;
71 	sal_uLong nUId;
72 };
73 
74 class TestToolObj: public SbxObject
75 {
76 	friend class TTBasic;
77 	friend class Controls;
78 public:
79 	TestToolObj( String aName, String aFilePath );		// Alle Dateien in FilePath, Kein IPC
80 	TestToolObj( String aName, MyBasic* pBas );	// Pfade aus INI, IPC benutzen
81 	~TestToolObj();
82 	void LoadIniFile();				// Laden der IniEinstellungen, die durch den ConfigDialog ge�ndert werden k�nnen
83 	void DebugFindNoErrors( sal_Bool bDebugFindNoErrors );
84 
85 private:
86 	sal_Bool bWasPrecompilerError;	// True wenn beim letzten Precompile ein Fehler auftrat
87 	sal_Bool CError( sal_uLong, const String&, xub_StrLen, xub_StrLen, xub_StrLen );
88 	void CalcPosition( String const &aSource, xub_StrLen nPos, xub_StrLen &l, xub_StrLen &c );
89 	xub_StrLen ImplSearch( const String &aSource, const xub_StrLen nStart, const xub_StrLen nEnd, const String &aSearch, const xub_StrLen nSearchStart = 0 );
90 	xub_StrLen PreCompilePart( String &aSource, xub_StrLen nStart, xub_StrLen nEnd, String aFinalErrorLabel, sal_uInt16 &nLabelCount );
91 	void PreCompileDispatchParts( String &aSource, String aStart, String aEnd, String aFinalLable );
92 public:
93 	String GetRevision(String const &aSourceIn);	// find Revision in the sourcecode
94 	String PreCompile(String const &aSourceIn);	// try catch; testcase endcase ..
95 	sal_Bool WasPrecompilerError();	// True wenn beim letzten Precompile ein Fehler auftrat
96 	void			SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
97 	virtual SbxVariable* Find( const String&, SbxClassType );
98 //	String aKeyPlusClasses;		// Pfad f�r keycodes & classes & res_type (Aus Configdatei)
99 	DECL_LINK( ReturnResultsLink, CommunicationLink* );
100 	sal_Bool			ReturnResults( SvStream *pIn );	// R�cklieferung des Antwortstreams �ber IPC oder TCP/IP oder direkt
101 
102 	void			SetLogHdl( const Link& rLink ) { aLogHdl = rLink; }
103 	const Link&		GetLogHdl() const { return aLogHdl; }
104 
105 	void			SetWinInfoHdl( const Link& rLink ) { aWinInfoHdl = rLink; }
106 	const Link&		GetWinInfoHdl() const { return aWinInfoHdl; }
107 
108 	void			SetModuleWinExistsHdl( const Link& rLink ) { aModuleWinExistsHdl = rLink; }
109 	const Link&		GetModuleWinExistsHdl() const { return aModuleWinExistsHdl; }
110 
111 	void			SetCErrorHdl( const Link& rLink ) { aCErrorHdl = rLink; }
112 	const Link&		GetCErrorHdl() const { return aCErrorHdl; }
113 
114 	void			SetWriteStringHdl( const Link& rLink ) { aWriteStringHdl = rLink; }
115 	const Link&		GetWriteStringHdl() const { return aWriteStringHdl; }
116 
117 	SfxBroadcaster& GetTTBroadcaster();
118 
119 private:
120 	ImplTestToolObj *pImpl;		// Alles was von der Implementation abh�ngt
121 	static const CErrors* GetFehlerListe() { return pFehlerListe; }
122 	sal_Bool bUseIPC;
123 	Link aLogHdl;				// Zum Logen der Fehlermeldungen im Testtool
124 	Link aWinInfoHdl;			// Anzeigen der Windows/Controls der zu testenden App
125 	Link aModuleWinExistsHdl;	// Pr�ft ob das Modul schon im Editor geladen ist
126 	Link aCErrorHdl;			// Melden von Compilererror
127     Link aWriteStringHdl;       // Schreiben von text (e.g. MakroRecorder)
128 	sal_Bool bReturnOK;				// Bricht WaitForAnswer ab
129 	CRevNames *pShortNames;		// Aktuell verwendete Controls, zur gewinnung des Namens aus Fehlermeldung
130 	sal_uLong nSequence;			// Sequence um Antwort und Anfrage zu syncronisieren
131 	rtl::OString aNextReturnId;	// Id des Returnwertes i.e. UId
132     void ReplaceNumbers(String &aText);	// Zahlen im String mit speziellem Format in Namen umwandeln
133 
134     String aLastRecordedKontext;//  Keeps the last kontext recorded by the Macro Recorder
135 
136 #define FLAT sal_True
137 	String ProgPath;			// Dateiname der zu Testenden APP; Gesetzt �ber Start
138 	String aLogFileName;		// Momentaner Logfilename (Wie Programmdatei aber mit .res)
139 	sal_Bool IsBlock;				// Innerhalb Begin/EndBlock
140 	sal_Bool SingleCommandBlock;	// Implizit um jedes kommando ein Begin/EndBlock
141 	CmdStream *In;
142 
143 	void AddName(String &aBisher, String &aNeu );	// Name eventuell mit / anh�ngen
144 	void AddToListByNr( CNames *&pControls, ControlItemUId *&pNewItem );	//
145 	CNames *m_pControls;
146 	CNames *m_pNameKontext;		// Zeigt auf den aktuellen Namenskontext, der �ber 'Kontext' gesetzt wurde
147 	CNames *m_pSIds;
148 	CNames *m_pReverseSlots;		// Slots mit Kurznamen nach Nummer
149 	CNames *m_pReverseControls;	// Controls mit Kurznamen nach Nummer
150 	CNames *m_pReverseControlsSon;// Controls mit Kurznamen nach Nummer nach Fenstern (Son)
151 	CNames *m_pReverseUIds;		// Langnamen nach Nummer
152 
153 
154 	sal_uInt16 nMyVar;				// Wievielte Var aus Pool ist dran
155 
156 	void InitTestToolObj();
157 	CommunicationManagerClientViaSocketTT *pCommunicationManager;
158 	void SendViaSocket();
159 
160 	sal_Bool Load( String aFileName, SbModule *pMod );
161 
162 	void ReadNames( String Filename, CNames *&pNames, CNames *&pUIds, sal_Bool bIsFlat = sal_False );
163 	void ReadFlat( String Filename, CNames *&pNames, sal_Bool bSortByName );
164 	sal_Bool ReadNamesBin( String Filename, CNames *&pSIds, CNames *&pControls );
165 	sal_Bool WriteNamesBin( String Filename, CNames *pSIds, CNames *pControls );
166     void ReadHidLstByNumber();
167     void SortControlsByNumber( sal_Bool bIncludeActive = sal_False );
168 
169     String GetMethodName( sal_uLong nMethodId );
170     String GetKeyName( sal_uInt16 nKeyCode );
171 
172 	void WaitForAnswer ();
173 	DECL_LINK( IdleHdl,   Application* );
174 	DECL_LINK( CallDialogHandler,   Application* );
175 	String aDialogHandlerName;
176 	sal_uInt16 nWindowHandlerCallLevel;
177 
178 	sal_uInt16 nIdleCount;
179 	// wenn DialogHandler gesetzt wird er im IdleHandler inkrementiert und
180 	// in WaitForAnswer r�ckgesetzt. �bersteigt er einen gewissen wert, gehe ich davon aus,
181 	// da� WaitForAnswer still ligt und rufe die DialogHander Sub im BASIC auf.
182 
183 	void BeginBlock();
184 	void EndBlock();
185 
186 	SbTextType GetSymbolType( const String &rSymbol, sal_Bool bWasControl );
187 	static ControlDefLoad const arR_Cmds[];
188 	static CNames *pRCommands;
189 
190 	static CErrors *pFehlerListe;		// Hier werden die Fehler des Testtools gespeichert
191 
192 };
193 
194 #endif
195