xref: /aoo42x/main/automation/source/app/testbasi.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_automation.hxx"
30 #include <basic/sbx.hxx>
31 
32 #ifndef _BASIC_TTRESHLP_HXX
33 #include <basic/ttstrhlp.hxx>
34 #endif
35 #include <basic/testtool.hxx>
36 #include "testbasi.hxx"
37 //#include "app.hxx"
38 //#include "basic.hrc"
39 //#include "appbased.hxx"
40 #define P_FEHLERLISTE TestToolObj::pFehlerListe
41 
42 //#include "status.hxx"
43 //#include "basic.hrc"
44 
45 //#include "object.hxx"
46 
47 #include <testapp.hxx>
48 #include <testtool.hxx>
49 #ifndef _SB_INTERN_HXX
50 //#include "sbintern.hxx"
51 #endif
52 
53 //#include "comm_bas.hxx"
54 //#include "processw.hxx"
55 
56 TYPEINIT1(TTBasic,MyBasic)
57 
58 /*class MyFactory : public SbxFactory
59 {
60 public:
61 	virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX );
62 };
63 
64 static SampleObjectFac aFac1;
65 static MyFactory aFac2;
66 static CommunicationFactory aComManFac;
67 static ProcessFactory aProcessFac;
68 static short nInst = 0;
69 
70 SbxBase* MyFactory::Create( sal_uInt16 nSbxId, sal_uInt32 nCr )
71 {
72 	if( nCr == SBXCR_TEST && nSbxId == SBXID_MYBASIC )
73 		return new MyBasic;
74 	else
75 		return NULL;
76 } */
77 
78 TTBasic::TTBasic() : MyBasic()
79 {
80 // Eigenes Objekt reinbraten
81 	TestToolObj* pTTO = new TestToolObj( CUniString("App"), this );
82 	pTTO->SetLogHdl( GenLogHdl() );
83 	pTTO->SetWinInfoHdl( GenWinInfoHdl() );
84 	pTTO->SetModuleWinExistsHdl( GenModuleWinExistsHdl() );
85 	pTTO->SetWriteStringHdl( GenWriteStringHdl() );
86 	pTTO->SetCErrorHdl( LINK( this, TTBasic, CErrorImpl ) );
87 
88     StartListeningTT( pTTO->GetTTBroadcaster() );
89 
90 	pTestObject = pTTO;
91 	pTestObject->SetFlag( SBX_EXTSEARCH );
92 	Insert( pTestObject );
93 }
94 
95 MyBasic* TTBasic::CreateMyBasic()
96 {
97 	return new TTBasic();
98 }
99 
100 void TTBasic::LoadIniFile()
101 {
102 	((TestToolObj*)pTestObject)->LoadIniFile();
103 }
104 
105 SbTextType TTBasic::GetSymbolType( const String &rSymbol, sal_Bool bWasTTControl )
106 {
107 	return ((TestToolObj*)pTestObject)->GetSymbolType( rSymbol, bWasTTControl );
108 }
109 
110 
111 TTBasic::~TTBasic()
112 {
113 }
114 
115 IMPL_LINK( TTBasic, CErrorImpl, ErrorEntry*, pData )
116 {
117 	return CError( pData->nError, pData->aText, pData->nLine, pData->nCol1, pData->nCol2 );
118 }
119 
120 sal_Bool TTBasic::Compile( SbModule* p )
121 {
122 	p->SetComment( ((TestToolObj*)pTestObject)->GetRevision(p->GetSource()) );
123 	SbModule* pOldModule = GetCompileModule();
124 	SetCompileModule( p );
125 	p->SetSource( ((TestToolObj*)pTestObject)->PreCompile(p->GetSource()) );
126 	SetCompileModule( pOldModule );
127 	if ( ((TestToolObj*)pTestObject)->WasPrecompilerError() )
128 		return sal_False;
129 	return MyBasic::Compile( p );
130 }
131 
132 const String TTBasic::GetSpechialErrorText()
133 {
134 	String nErrorText;
135 	if ( pTestObject && IS_ERROR() && GetErrorCode() == GET_ERROR()->nError )
136 	{
137 		nErrorText = GenRealString( GET_ERROR()->aText );
138 		nErrorText.AppendAscii( ": " );
139 		nErrorText += String::CreateFromInt64( GET_ERROR()->nError );
140 	}
141 	else
142 	{
143 		nErrorText = GetErrorText();
144 	}
145 	return nErrorText;
146 }
147 
148 void TTBasic::ReportRuntimeError( AppBasEd *pEditWin )
149 {
150 	SbxVariableRef aDummy = new SbxVariable;
151 	aDummy->SetUserData( 24 );  // ID_MaybeAddErr
152 	((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
153 	aDummy->SetUserData( 18 );  // ID_ExceptLog
154 	((TestToolObj*)pTestObject)->Notify( pTestObject->GetBroadcaster(), SbxHint( SBX_HINT_DATAWANTED, aDummy ) );
155 	MyBasic::ReportRuntimeError( pEditWin );
156 }
157 
158 void TTBasic::DebugFindNoErrors( sal_Bool bDebugFindNoErrors )
159 {
160 	((TestToolObj*)pTestObject)->DebugFindNoErrors( bDebugFindNoErrors );
161 }
162