xref: /aoo41x/main/automation/source/app/testbasi.cxx (revision 9d1279ec)
1*9d1279ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9d1279ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9d1279ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9d1279ecSAndrew Rist  * distributed with this work for additional information
6*9d1279ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9d1279ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9d1279ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*9d1279ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9d1279ecSAndrew Rist  *
11*9d1279ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9d1279ecSAndrew Rist  *
13*9d1279ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9d1279ecSAndrew Rist  * software distributed under the License is distributed on an
15*9d1279ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9d1279ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*9d1279ecSAndrew Rist  * specific language governing permissions and limitations
18*9d1279ecSAndrew Rist  * under the License.
19*9d1279ecSAndrew Rist  *
20*9d1279ecSAndrew Rist  *************************************************************/
21*9d1279ecSAndrew Rist 
22*9d1279ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_automation.hxx"
26cdf0e10cSrcweir #include <basic/sbx.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef _BASIC_TTRESHLP_HXX
29cdf0e10cSrcweir #include <basic/ttstrhlp.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <basic/testtool.hxx>
32cdf0e10cSrcweir #include "testbasi.hxx"
33cdf0e10cSrcweir //#include "app.hxx"
34cdf0e10cSrcweir //#include "basic.hrc"
35cdf0e10cSrcweir //#include "appbased.hxx"
36cdf0e10cSrcweir #define P_FEHLERLISTE TestToolObj::pFehlerListe
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //#include "status.hxx"
39cdf0e10cSrcweir //#include "basic.hrc"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //#include "object.hxx"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <testapp.hxx>
44cdf0e10cSrcweir #include <testtool.hxx>
45cdf0e10cSrcweir #ifndef _SB_INTERN_HXX
46cdf0e10cSrcweir //#include "sbintern.hxx"
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir 
49cdf0e10cSrcweir //#include "comm_bas.hxx"
50cdf0e10cSrcweir //#include "processw.hxx"
51cdf0e10cSrcweir 
TYPEINIT1(TTBasic,MyBasic)52cdf0e10cSrcweir TYPEINIT1(TTBasic,MyBasic)
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /*class MyFactory : public SbxFactory
55cdf0e10cSrcweir {
56cdf0e10cSrcweir public:
57cdf0e10cSrcweir 	virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX );
58cdf0e10cSrcweir };
59cdf0e10cSrcweir 
60cdf0e10cSrcweir static SampleObjectFac aFac1;
61cdf0e10cSrcweir static MyFactory aFac2;
62cdf0e10cSrcweir static CommunicationFactory aComManFac;
63cdf0e10cSrcweir static ProcessFactory aProcessFac;
64cdf0e10cSrcweir static short nInst = 0;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir SbxBase* MyFactory::Create( sal_uInt16 nSbxId, sal_uInt32 nCr )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	if( nCr == SBXCR_TEST && nSbxId == SBXID_MYBASIC )
69cdf0e10cSrcweir 		return new MyBasic;
70cdf0e10cSrcweir 	else
71cdf0e10cSrcweir 		return NULL;
72cdf0e10cSrcweir } */
73cdf0e10cSrcweir 
74cdf0e10cSrcweir TTBasic::TTBasic() : MyBasic()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir // Eigenes Objekt reinbraten
77cdf0e10cSrcweir 	TestToolObj* pTTO = new TestToolObj( CUniString("App"), this );
78cdf0e10cSrcweir 	pTTO->SetLogHdl( GenLogHdl() );
79cdf0e10cSrcweir 	pTTO->SetWinInfoHdl( GenWinInfoHdl() );
80cdf0e10cSrcweir 	pTTO->SetModuleWinExistsHdl( GenModuleWinExistsHdl() );
81cdf0e10cSrcweir 	pTTO->SetWriteStringHdl( GenWriteStringHdl() );
82cdf0e10cSrcweir 	pTTO->SetCErrorHdl( LINK( this, TTBasic, CErrorImpl ) );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     StartListeningTT( pTTO->GetTTBroadcaster() );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	pTestObject = pTTO;
87cdf0e10cSrcweir 	pTestObject->SetFlag( SBX_EXTSEARCH );
88cdf0e10cSrcweir 	Insert( pTestObject );
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
CreateMyBasic()91cdf0e10cSrcweir MyBasic* TTBasic::CreateMyBasic()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	return new TTBasic();
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
LoadIniFile()96cdf0e10cSrcweir void TTBasic::LoadIniFile()
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	((TestToolObj*)pTestObject)->LoadIniFile();
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
GetSymbolType(const String & rSymbol,sal_Bool bWasTTControl)101cdf0e10cSrcweir SbTextType TTBasic::GetSymbolType( const String &rSymbol, sal_Bool bWasTTControl )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir 	return ((TestToolObj*)pTestObject)->GetSymbolType( rSymbol, bWasTTControl );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
~TTBasic()107cdf0e10cSrcweir TTBasic::~TTBasic()
108cdf0e10cSrcweir {
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
IMPL_LINK(TTBasic,CErrorImpl,ErrorEntry *,pData)111cdf0e10cSrcweir IMPL_LINK( TTBasic, CErrorImpl, ErrorEntry*, pData )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	return CError( pData->nError, pData->aText, pData->nLine, pData->nCol1, pData->nCol2 );
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
Compile(SbModule * p)116cdf0e10cSrcweir sal_Bool TTBasic::Compile( SbModule* p )
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	p->SetComment( ((TestToolObj*)pTestObject)->GetRevision(p->GetSource()) );
119cdf0e10cSrcweir 	SbModule* pOldModule = GetCompileModule();
120cdf0e10cSrcweir 	SetCompileModule( p );
121cdf0e10cSrcweir 	p->SetSource( ((TestToolObj*)pTestObject)->PreCompile(p->GetSource()) );
122cdf0e10cSrcweir 	SetCompileModule( pOldModule );
123cdf0e10cSrcweir 	if ( ((TestToolObj*)pTestObject)->WasPrecompilerError() )
124cdf0e10cSrcweir 		return sal_False;
125cdf0e10cSrcweir 	return MyBasic::Compile( p );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
GetSpechialErrorText()128cdf0e10cSrcweir const String TTBasic::GetSpechialErrorText()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir 	String nErrorText;
131cdf0e10cSrcweir 	if ( pTestObject && IS_ERROR() && GetErrorCode() == GET_ERROR()->nError )
132cdf0e10cSrcweir 	{
133cdf0e10cSrcweir 		nErrorText = GenRealString( GET_ERROR()->aText );
134cdf0e10cSrcweir 		nErrorText.AppendAscii( ": " );
135cdf0e10cSrcweir 		nErrorText += String::CreateFromInt64( GET_ERROR()->nError );
136cdf0e10cSrcweir 	}
137cdf0e10cSrcweir 	else
138cdf0e10cSrcweir 	{
139cdf0e10cSrcweir 		nErrorText = GetErrorText();
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 	return nErrorText;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
ReportRuntimeError(AppBasEd * pEditWin)144cdf0e10cSrcweir void TTBasic::ReportRuntimeError( AppBasEd *pEditWin )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	SbxVariableRef aDummy = new SbxVariable;
147cdf0e10cSrcweir 	aDummy->SetUserData( 24 );  // ID_MaybeAddErr
148cdf0e10cSrcweir 	((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
149cdf0e10cSrcweir 	aDummy->SetUserData( 18 );  // ID_ExceptLog
150cdf0e10cSrcweir 	((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
151cdf0e10cSrcweir 	MyBasic::ReportRuntimeError( pEditWin );
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
DebugFindNoErrors(sal_Bool bDebugFindNoErrors)154cdf0e10cSrcweir void TTBasic::DebugFindNoErrors( sal_Bool bDebugFindNoErrors )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	((TestToolObj*)pTestObject)->DebugFindNoErrors( bDebugFindNoErrors );
157cdf0e10cSrcweir }
158