update dev300-m58
[ooovba.git] / automation / source / app / testbasi.cxx
blobc53889f04c1399a945a53abbb5e8f93a154cc6f9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testbasi.cxx,v $
10 * $Revision: 1.9.14.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_automation.hxx"
33 #include <basic/sbx.hxx>
35 #ifndef _BASIC_TTRESHLP_HXX
36 #include <basic/ttstrhlp.hxx>
37 #endif
38 #include <basic/testtool.hxx>
39 #include "testbasi.hxx"
40 //#include "app.hxx"
41 //#include "basic.hrc"
42 //#include "appbased.hxx"
43 #define P_FEHLERLISTE TestToolObj::pFehlerListe
45 //#include "status.hxx"
46 //#include "basic.hrc"
48 //#include "object.hxx"
50 #include <testapp.hxx>
51 #include <testtool.hxx>
52 #ifndef _SB_INTERN_HXX
53 //#include "sbintern.hxx"
54 #endif
56 //#include "comm_bas.hxx"
57 //#include "processw.hxx"
59 TYPEINIT1(TTBasic,MyBasic)
61 /*class MyFactory : public SbxFactory
63 public:
64 virtual SbxBase* Create( UINT16 nSbxId, UINT32 = SBXCR_SBX );
67 static SampleObjectFac aFac1;
68 static MyFactory aFac2;
69 static CommunicationFactory aComManFac;
70 static ProcessFactory aProcessFac;
71 static short nInst = 0;
73 SbxBase* MyFactory::Create( UINT16 nSbxId, UINT32 nCr )
75 if( nCr == SBXCR_TEST && nSbxId == SBXID_MYBASIC )
76 return new MyBasic;
77 else
78 return NULL;
79 } */
81 TTBasic::TTBasic() : MyBasic()
83 // Eigenes Objekt reinbraten
84 TestToolObj* pTTO = new TestToolObj( CUniString("App"), this );
85 pTTO->SetLogHdl( GenLogHdl() );
86 pTTO->SetWinInfoHdl( GenWinInfoHdl() );
87 pTTO->SetModuleWinExistsHdl( GenModuleWinExistsHdl() );
88 pTTO->SetWriteStringHdl( GenWriteStringHdl() );
89 pTTO->SetCErrorHdl( LINK( this, TTBasic, CErrorImpl ) );
91 StartListeningTT( pTTO->GetTTBroadcaster() );
93 pTestObject = pTTO;
94 pTestObject->SetFlag( SBX_EXTSEARCH );
95 Insert( pTestObject );
98 MyBasic* TTBasic::CreateMyBasic()
100 return new TTBasic();
103 void TTBasic::LoadIniFile()
105 ((TestToolObj*)pTestObject)->LoadIniFile();
108 SbTextType TTBasic::GetSymbolType( const String &rSymbol, BOOL bWasTTControl )
110 return ((TestToolObj*)pTestObject)->GetSymbolType( rSymbol, bWasTTControl );
114 TTBasic::~TTBasic()
118 IMPL_LINK( TTBasic, CErrorImpl, ErrorEntry*, pData )
120 return CError( pData->nError, pData->aText, pData->nLine, pData->nCol1, pData->nCol2 );
123 BOOL TTBasic::Compile( SbModule* p )
125 p->SetComment( ((TestToolObj*)pTestObject)->GetRevision(p->GetSource()) );
126 SbModule* pOldModule = GetCompileModule();
127 SetCompileModule( p );
128 p->SetSource( ((TestToolObj*)pTestObject)->PreCompile(p->GetSource()) );
129 SetCompileModule( pOldModule );
130 if ( ((TestToolObj*)pTestObject)->WasPrecompilerError() )
131 return FALSE;
132 return MyBasic::Compile( p );
135 const String TTBasic::GetSpechialErrorText()
137 String nErrorText;
138 if ( pTestObject && IS_ERROR() && GetErrorCode() == GET_ERROR()->nError )
140 nErrorText = GenRealString( GET_ERROR()->aText );
141 nErrorText.AppendAscii( ": " );
142 nErrorText += String::CreateFromInt64( GET_ERROR()->nError );
144 else
146 nErrorText = GetErrorText();
148 return nErrorText;
151 void TTBasic::ReportRuntimeError( AppBasEd *pEditWin )
153 SbxVariableRef aDummy = new SbxVariable;
154 aDummy->SetUserData( 24 ); // ID_MaybeAddErr
155 ((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
156 aDummy->SetUserData( 18 ); // ID_ExceptLog
157 ((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
158 MyBasic::ReportRuntimeError( pEditWin );
161 void TTBasic::DebugFindNoErrors( BOOL bDebugFindNoErrors )
163 ((TestToolObj*)pTestObject)->DebugFindNoErrors( bDebugFindNoErrors );