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