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