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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_automation.hxx"
26 #include <basic/sbx.hxx>
27
28 #ifndef _BASIC_TTRESHLP_HXX
29 #include <basic/ttstrhlp.hxx>
30 #endif
31 #include <basic/testtool.hxx>
32 #include "testbasi.hxx"
33 //#include "app.hxx"
34 //#include "basic.hrc"
35 //#include "appbased.hxx"
36 #define P_FEHLERLISTE TestToolObj::pFehlerListe
37
38 //#include "status.hxx"
39 //#include "basic.hrc"
40
41 //#include "object.hxx"
42
43 #include <testapp.hxx>
44 #include <testtool.hxx>
45 #ifndef _SB_INTERN_HXX
46 //#include "sbintern.hxx"
47 #endif
48
49 //#include "comm_bas.hxx"
50 //#include "processw.hxx"
51
TYPEINIT1(TTBasic,MyBasic)52 TYPEINIT1(TTBasic,MyBasic)
53
54 /*class MyFactory : public SbxFactory
55 {
56 public:
57 virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX );
58 };
59
60 static SampleObjectFac aFac1;
61 static MyFactory aFac2;
62 static CommunicationFactory aComManFac;
63 static ProcessFactory aProcessFac;
64 static short nInst = 0;
65
66 SbxBase* MyFactory::Create( sal_uInt16 nSbxId, sal_uInt32 nCr )
67 {
68 if( nCr == SBXCR_TEST && nSbxId == SBXID_MYBASIC )
69 return new MyBasic;
70 else
71 return NULL;
72 } */
73
74 TTBasic::TTBasic() : MyBasic()
75 {
76 // Eigenes Objekt reinbraten
77 TestToolObj* pTTO = new TestToolObj( CUniString("App"), this );
78 pTTO->SetLogHdl( GenLogHdl() );
79 pTTO->SetWinInfoHdl( GenWinInfoHdl() );
80 pTTO->SetModuleWinExistsHdl( GenModuleWinExistsHdl() );
81 pTTO->SetWriteStringHdl( GenWriteStringHdl() );
82 pTTO->SetCErrorHdl( LINK( this, TTBasic, CErrorImpl ) );
83
84 StartListeningTT( pTTO->GetTTBroadcaster() );
85
86 pTestObject = pTTO;
87 pTestObject->SetFlag( SBX_EXTSEARCH );
88 Insert( pTestObject );
89 }
90
CreateMyBasic()91 MyBasic* TTBasic::CreateMyBasic()
92 {
93 return new TTBasic();
94 }
95
LoadIniFile()96 void TTBasic::LoadIniFile()
97 {
98 ((TestToolObj*)pTestObject)->LoadIniFile();
99 }
100
GetSymbolType(const String & rSymbol,sal_Bool bWasTTControl)101 SbTextType TTBasic::GetSymbolType( const String &rSymbol, sal_Bool bWasTTControl )
102 {
103 return ((TestToolObj*)pTestObject)->GetSymbolType( rSymbol, bWasTTControl );
104 }
105
106
~TTBasic()107 TTBasic::~TTBasic()
108 {
109 }
110
IMPL_LINK(TTBasic,CErrorImpl,ErrorEntry *,pData)111 IMPL_LINK( TTBasic, CErrorImpl, ErrorEntry*, pData )
112 {
113 return CError( pData->nError, pData->aText, pData->nLine, pData->nCol1, pData->nCol2 );
114 }
115
Compile(SbModule * p)116 sal_Bool TTBasic::Compile( SbModule* p )
117 {
118 p->SetComment( ((TestToolObj*)pTestObject)->GetRevision(p->GetSource()) );
119 SbModule* pOldModule = GetCompileModule();
120 SetCompileModule( p );
121 p->SetSource( ((TestToolObj*)pTestObject)->PreCompile(p->GetSource()) );
122 SetCompileModule( pOldModule );
123 if ( ((TestToolObj*)pTestObject)->WasPrecompilerError() )
124 return sal_False;
125 return MyBasic::Compile( p );
126 }
127
GetSpecialErrorText()128 const String TTBasic::GetSpecialErrorText()
129 {
130 String nErrorText;
131 if ( pTestObject && IS_ERROR() && GetErrorCode() == GET_ERROR()->nError )
132 {
133 nErrorText = GenRealString( GET_ERROR()->aText );
134 nErrorText.AppendAscii( ": " );
135 nErrorText += String::CreateFromInt64( GET_ERROR()->nError );
136 }
137 else
138 {
139 nErrorText = GetErrorText();
140 }
141 return nErrorText;
142 }
143
ReportRuntimeError(AppBasEd * pEditWin)144 void TTBasic::ReportRuntimeError( AppBasEd *pEditWin )
145 {
146 SbxVariableRef aDummy = new SbxVariable;
147 aDummy->SetUserData( 24 ); // ID_MaybeAddErr
148 ((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
149 aDummy->SetUserData( 18 ); // ID_ExceptLog
150 ((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
151 MyBasic::ReportRuntimeError( pEditWin );
152 }
153
DebugFindNoErrors(sal_Bool bDebugFindNoErrors)154 void TTBasic::DebugFindNoErrors( sal_Bool bDebugFindNoErrors )
155 {
156 ((TestToolObj*)pTestObject)->DebugFindNoErrors( bDebugFindNoErrors );
157 }
158
159 /* vim: set noet sw=4 ts=4: */
160