xref: /AOO41X/main/basctl/source/basicide/baside2.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_basctl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <ide_pch.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <svtools/texteng.hxx>
36*cdf0e10cSrcweir #include <svtools/textview.hxx>
37*cdf0e10cSrcweir #include <svtools/xtextedt.hxx>
38*cdf0e10cSrcweir #include <basic/sbx.hxx>
39*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
40*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
45*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_
46*cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer2.hpp>
47*cdf0e10cSrcweir #endif
48*cdf0e10cSrcweir #include <com/sun/star/document/MacroExecMode.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/script/ModuleType.hpp>
50*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
51*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
52*cdf0e10cSrcweir #include <basic/basrdll.hxx>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include <baside2.hrc>
56*cdf0e10cSrcweir #include <baside2.hxx>
57*cdf0e10cSrcweir #include <objdlg.hxx>
58*cdf0e10cSrcweir #include <iderdll.hxx>
59*cdf0e10cSrcweir #include <iderdll2.hxx>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #include <basobj.hxx>
62*cdf0e10cSrcweir #include <brkdlg.hxx>
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir #include <svx/srchdlg.hxx>
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #include <vcl/sound.hxx>
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir //#ifndef _TXTCMP_HXX //autogen
69*cdf0e10cSrcweir //#include <svtools/txtcmp.hxx>
70*cdf0e10cSrcweir //#endif
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir #include <unotools/textsearch.hxx>
73*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir using namespace ::com::sun::star;
76*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir #define SPLIT_MARGIN	5
80*cdf0e10cSrcweir #define SPLIT_HEIGHT	2
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir #define LMARGPRN		1700
83*cdf0e10cSrcweir #define RMARGPRN		 900
84*cdf0e10cSrcweir #define TMARGPRN    	2000
85*cdf0e10cSrcweir #define BMARGPRN    	1000
86*cdf0e10cSrcweir #define BORDERPRN		300
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir #define APPWAIT_START	100
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir #define VALIDWINDOW		0x1234
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir #if defined(OW) || defined(MTF)
93*cdf0e10cSrcweir #define FILTERMASK_ALL "*"
94*cdf0e10cSrcweir #elif defined(PM2)
95*cdf0e10cSrcweir #define FILTERMASK_ALL ""
96*cdf0e10cSrcweir #else
97*cdf0e10cSrcweir #define FILTERMASK_ALL "*.*"
98*cdf0e10cSrcweir #endif
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir using namespace ::com::sun::star;
101*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
102*cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs;
103*cdf0e10cSrcweir using namespace utl;
104*cdf0e10cSrcweir using namespace comphelper;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir DBG_NAME( ModulWindow )
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir TYPEINIT1( ModulWindow , IDEBaseWindow );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir void lcl_PrintHeader( Printer* pPrinter, sal_uInt16 nPages, sal_uInt16 nCurPage, const String& rTitle, bool bOutput )
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	short nLeftMargin 	= LMARGPRN;
114*cdf0e10cSrcweir 	Size aSz = pPrinter->GetOutputSize();
115*cdf0e10cSrcweir 	short nBorder = BORDERPRN;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	const Color aOldLineColor( pPrinter->GetLineColor() );
118*cdf0e10cSrcweir 	const Color aOldFillColor( pPrinter->GetFillColor() );
119*cdf0e10cSrcweir 	const Font	aOldFont( pPrinter->GetFont() );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	pPrinter->SetLineColor( Color( COL_BLACK ) );
122*cdf0e10cSrcweir 	pPrinter->SetFillColor();
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	Font aFont( aOldFont );
125*cdf0e10cSrcweir 	aFont.SetWeight( WEIGHT_BOLD );
126*cdf0e10cSrcweir 	aFont.SetAlign( ALIGN_BOTTOM );
127*cdf0e10cSrcweir 	pPrinter->SetFont( aFont );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	long nFontHeight = pPrinter->GetTextHeight();
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	// 1.Border => Strich, 2+3 Border = Freiraum.
132*cdf0e10cSrcweir 	long nYTop = TMARGPRN-3*nBorder-nFontHeight;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	long nXLeft = nLeftMargin-nBorder;
135*cdf0e10cSrcweir 	long nXRight = aSz.Width()-RMARGPRN+nBorder;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     if( bOutput )
138*cdf0e10cSrcweir         pPrinter->DrawRect( Rectangle(
139*cdf0e10cSrcweir             Point( nXLeft, nYTop ),
140*cdf0e10cSrcweir             Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	long nY = TMARGPRN-2*nBorder;
144*cdf0e10cSrcweir 	Point aPos( nLeftMargin, nY );
145*cdf0e10cSrcweir     if( bOutput )
146*cdf0e10cSrcweir         pPrinter->DrawText( aPos, rTitle );
147*cdf0e10cSrcweir 	if ( nPages != 1 )
148*cdf0e10cSrcweir 	{
149*cdf0e10cSrcweir 		aFont.SetWeight( WEIGHT_NORMAL );
150*cdf0e10cSrcweir 		pPrinter->SetFont( aFont );
151*cdf0e10cSrcweir 		String aPageStr( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
152*cdf0e10cSrcweir 		aPageStr += String( IDEResId( RID_STR_PAGE ) );
153*cdf0e10cSrcweir 		aPageStr += ' ';
154*cdf0e10cSrcweir 		aPageStr += String::CreateFromInt32( nCurPage );
155*cdf0e10cSrcweir 		aPageStr += ']';
156*cdf0e10cSrcweir 		aPos.X() += pPrinter->GetTextWidth( rTitle );
157*cdf0e10cSrcweir         if( bOutput )
158*cdf0e10cSrcweir             pPrinter->DrawText( aPos, aPageStr );
159*cdf0e10cSrcweir 	}
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	nY = TMARGPRN-nBorder;
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     if( bOutput )
165*cdf0e10cSrcweir         pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 	pPrinter->SetFont( aOldFont );
168*cdf0e10cSrcweir 	pPrinter->SetFillColor( aOldFillColor );
169*cdf0e10cSrcweir 	pPrinter->SetLineColor( aOldLineColor );
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir void lcl_ConvertTabsToSpaces( String& rLine )
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir 	if ( rLine.Len() )
175*cdf0e10cSrcweir 	{
176*cdf0e10cSrcweir 		sal_uInt16 nPos = 0;
177*cdf0e10cSrcweir 		sal_uInt16 nMax = rLine.Len();
178*cdf0e10cSrcweir 		while ( nPos < nMax )
179*cdf0e10cSrcweir 		{
180*cdf0e10cSrcweir 			if ( rLine.GetChar( nPos ) == '\t' )
181*cdf0e10cSrcweir 			{
182*cdf0e10cSrcweir 				// Nicht 4 Blanks, sondern an 4er TabPos:
183*cdf0e10cSrcweir 				String aBlanker;
184*cdf0e10cSrcweir 				aBlanker.Fill( ( 4 - ( nPos % 4 ) ), ' ' );
185*cdf0e10cSrcweir 				rLine.Erase( nPos, 1 );
186*cdf0e10cSrcweir 				rLine.Insert( aBlanker, nPos );
187*cdf0e10cSrcweir 				nMax = rLine.Len();
188*cdf0e10cSrcweir 			}
189*cdf0e10cSrcweir 			nPos++;	// Nicht optimal, falls Tab, aber auch nicht verkehrt...
190*cdf0e10cSrcweir 		}
191*cdf0e10cSrcweir 	}
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir ModulWindow::ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, String aLibName,
196*cdf0e10cSrcweir                           String aName, ::rtl::OUString& aModule )
197*cdf0e10cSrcweir 		:IDEBaseWindow( pParent, rDocument, aLibName, aName )
198*cdf0e10cSrcweir 		,aXEditorWindow( this )
199*cdf0e10cSrcweir         ,m_aModule( aModule )
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir 	DBG_CTOR( ModulWindow, 0 );
202*cdf0e10cSrcweir 	nValid = VALIDWINDOW;
203*cdf0e10cSrcweir 	pLayout = pParent;
204*cdf0e10cSrcweir 	aXEditorWindow.Show();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	SetBackground();
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir SbModuleRef ModulWindow::XModule()
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir     // ModuleWindows can now be created as a result of the
212*cdf0e10cSrcweir     // modules getting created via the api. This is a result of an
213*cdf0e10cSrcweir     // elementInserted event from the BasicLibrary container.
214*cdf0e10cSrcweir     // However the SbModule is also created from a different listener to
215*cdf0e10cSrcweir     // the same event ( in basmgr ) Therefore it is possible when we look
216*cdf0e10cSrcweir     // for xModule it may not yet be available, here we keep tring to access
217*cdf0e10cSrcweir     // the module until such time as it exists
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir     if ( !xModule.Is() )
220*cdf0e10cSrcweir     {
221*cdf0e10cSrcweir         BasicManager* pBasMgr = GetDocument().getBasicManager();
222*cdf0e10cSrcweir         if ( pBasMgr )
223*cdf0e10cSrcweir         {
224*cdf0e10cSrcweir             StarBASIC* pBasic = pBasMgr->GetLib( GetLibName() );
225*cdf0e10cSrcweir             if ( pBasic )
226*cdf0e10cSrcweir             {
227*cdf0e10cSrcweir                 xBasic = pBasic;
228*cdf0e10cSrcweir                 xModule = (SbModule*)pBasic->FindModule( GetName() );
229*cdf0e10cSrcweir             }
230*cdf0e10cSrcweir         }
231*cdf0e10cSrcweir     }
232*cdf0e10cSrcweir     return xModule;
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir __EXPORT ModulWindow::~ModulWindow()
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir 	DBG_DTOR( ModulWindow, 0 );
238*cdf0e10cSrcweir 	nValid = 0;
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	StarBASIC::Stop();
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir void __EXPORT ModulWindow::GetFocus()
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir 	if ( nValid != VALIDWINDOW  )
247*cdf0e10cSrcweir 		return;
248*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
249*cdf0e10cSrcweir 	aXEditorWindow.GetEdtWindow().GrabFocus();
250*cdf0e10cSrcweir 	// Basisklasse nicht rufen, weil Focus jetzt woanders...
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir void ModulWindow::DoInit()
254*cdf0e10cSrcweir {
255*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
256*cdf0e10cSrcweir 	// Wird beim Umschalten der Fenster gerufen...
257*cdf0e10cSrcweir 	if ( GetVScrollBar() )
258*cdf0e10cSrcweir 		GetVScrollBar()->Hide();
259*cdf0e10cSrcweir 	GetHScrollBar()->Show();
260*cdf0e10cSrcweir //	GetEditorWindow().SetScrollBarRanges();
261*cdf0e10cSrcweir 	GetEditorWindow().InitScrollBars();
262*cdf0e10cSrcweir //	GetEditorWindow().GrabFocus();
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir void __EXPORT ModulWindow::Paint( const Rectangle& )
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir void __EXPORT ModulWindow::Resize()
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir 	aXEditorWindow.SetPosSizePixel( Point( 0, 0 ),
273*cdf0e10cSrcweir 									Size( GetOutputSizePixel() ) );
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir // "Import" von baside4.cxx
278*cdf0e10cSrcweir void CreateEngineForBasic( StarBASIC* pBasic );
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir void ModulWindow::CheckCompileBasic()
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     if ( XModule().Is() )
285*cdf0e10cSrcweir     {
286*cdf0e10cSrcweir 	    // Zur Laufzeit wird niemals compiliert!
287*cdf0e10cSrcweir 	    sal_Bool bRunning = StarBASIC::IsRunning();
288*cdf0e10cSrcweir 	    sal_Bool bModified = ( !xModule->IsCompiled() ||
289*cdf0e10cSrcweir 		    ( GetEditEngine() && GetEditEngine()->IsModified() ) );
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 	    if ( !bRunning && bModified )
292*cdf0e10cSrcweir 	    {
293*cdf0e10cSrcweir 		    sal_Bool bDone = sal_False;
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 			BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
296*cdf0e10cSrcweir 		    pIDEShell->GetViewFrame()->GetWindow().EnterWait();
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 		    if( bModified )
299*cdf0e10cSrcweir 		    {
300*cdf0e10cSrcweir 			    AssertValidEditEngine();
301*cdf0e10cSrcweir 			    GetEditorWindow().SetSourceInBasic( sal_False );
302*cdf0e10cSrcweir 		    }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir 		    sal_Bool bWasModified = GetBasic()->IsModified();
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir 		    bDone = GetBasic()->Compile( xModule );
307*cdf0e10cSrcweir 		    if ( !bWasModified )
308*cdf0e10cSrcweir 			    GetBasic()->SetModified( sal_False );
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 		    if ( bDone )
311*cdf0e10cSrcweir 		    {
312*cdf0e10cSrcweir 			    GetBreakPoints().SetBreakPointsInBasic( xModule );
313*cdf0e10cSrcweir 		    }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 		    pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 		    aStatus.bError = !bDone;
318*cdf0e10cSrcweir 		    aStatus.bIsRunning = sal_False;
319*cdf0e10cSrcweir 	    }
320*cdf0e10cSrcweir     }
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir sal_Bool ModulWindow::BasicExecute()
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir     // #116444# check security settings before macro execution
328*cdf0e10cSrcweir     ScriptDocument aDocument( GetDocument() );
329*cdf0e10cSrcweir     if ( aDocument.isDocument() )
330*cdf0e10cSrcweir     {
331*cdf0e10cSrcweir         if ( !aDocument.allowMacros() )
332*cdf0e10cSrcweir         {
333*cdf0e10cSrcweir             WarningBox( this, WB_OK, String( IDEResId( RID_STR_CANNOTRUNMACRO ) ) ).Execute();
334*cdf0e10cSrcweir             return sal_False;
335*cdf0e10cSrcweir         }
336*cdf0e10cSrcweir     }
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 	CheckCompileBasic();
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 	if ( XModule().Is() && xModule->IsCompiled() && !aStatus.bError )
341*cdf0e10cSrcweir 	{
342*cdf0e10cSrcweir 		if ( GetBreakPoints().Count() )
343*cdf0e10cSrcweir 			aStatus.nBasicFlags = aStatus.nBasicFlags | SbDEBUG_BREAK;
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 		if ( !aStatus.bIsRunning )
346*cdf0e10cSrcweir 		{
347*cdf0e10cSrcweir 			DBG_ASSERT( xModule.Is(), "Kein Modul!" );
348*cdf0e10cSrcweir 			AddStatus( BASWIN_RUNNINGBASIC );
349*cdf0e10cSrcweir 			sal_uInt16 nStart, nEnd, nCurMethodStart = 0;
350*cdf0e10cSrcweir 			TextSelection aSel = GetEditView()->GetSelection();
351*cdf0e10cSrcweir 			if ( aDocument.isInVBAMode() )
352*cdf0e10cSrcweir 				nCurMethodStart = ( aSel.GetStart().GetPara() + 1 );
353*cdf0e10cSrcweir 			SbMethod* pMethod = 0;
354*cdf0e10cSrcweir 			// erstes Macro, sonst blind "Main" (ExtSearch?)
355*cdf0e10cSrcweir 			for ( sal_uInt16 nMacro = 0; nMacro < xModule->GetMethods()->Count(); nMacro++ )
356*cdf0e10cSrcweir 			{
357*cdf0e10cSrcweir 				SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro );
358*cdf0e10cSrcweir 				DBG_ASSERT( pM, "Method?" );
359*cdf0e10cSrcweir 				pM->GetLineRange( nStart, nEnd );
360*cdf0e10cSrcweir 				if ( aDocument.isInVBAMode() )
361*cdf0e10cSrcweir 				{
362*cdf0e10cSrcweir 					if (  nCurMethodStart >= nStart && nCurMethodStart <= nEnd )
363*cdf0e10cSrcweir 					{
364*cdf0e10cSrcweir 						pMethod = pM;
365*cdf0e10cSrcweir 						break;
366*cdf0e10cSrcweir 					}
367*cdf0e10cSrcweir 				}
368*cdf0e10cSrcweir 				else if  ( !pMethod || ( nStart < nCurMethodStart && !pM->IsHidden() ) )
369*cdf0e10cSrcweir 				{
370*cdf0e10cSrcweir 					pMethod = pM;
371*cdf0e10cSrcweir 					nCurMethodStart = nStart;
372*cdf0e10cSrcweir 				}
373*cdf0e10cSrcweir 			}
374*cdf0e10cSrcweir 			if ( !pMethod )
375*cdf0e10cSrcweir 			{
376*cdf0e10cSrcweir 				if ( aDocument.isInVBAMode() )
377*cdf0e10cSrcweir 					return ( BasicIDE::ChooseMacro( uno::Reference< frame::XModel >(), sal_False, rtl::OUString() ).getLength() > 0 ) ? sal_True : sal_False;
378*cdf0e10cSrcweir 				else
379*cdf0e10cSrcweir 					pMethod = (SbMethod*)xModule->Find( String( RTL_CONSTASCII_USTRINGPARAM( "Main" ) ), SbxCLASS_METHOD );
380*cdf0e10cSrcweir 			}
381*cdf0e10cSrcweir 			if ( pMethod )
382*cdf0e10cSrcweir 			{
383*cdf0e10cSrcweir 				pMethod->SetDebugFlags( aStatus.nBasicFlags );
384*cdf0e10cSrcweir 				BasicDLL::SetDebugMode( sal_True );
385*cdf0e10cSrcweir 				BasicIDE::RunMethod( pMethod );
386*cdf0e10cSrcweir 				BasicDLL::SetDebugMode( sal_False );
387*cdf0e10cSrcweir 				// Falls waehrend Interactive=sal_False abgebrochen
388*cdf0e10cSrcweir 				BasicDLL::EnableBreak( sal_True );
389*cdf0e10cSrcweir 			}
390*cdf0e10cSrcweir 			ClearStatus( BASWIN_RUNNINGBASIC );
391*cdf0e10cSrcweir 		}
392*cdf0e10cSrcweir 		else
393*cdf0e10cSrcweir 			aStatus.bIsRunning = sal_False;	// Abbruch von Reschedule()
394*cdf0e10cSrcweir 	}
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir 	sal_Bool bDone = !aStatus.bError;
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir 	return bDone;
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir sal_Bool ModulWindow::CompileBasic()
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
404*cdf0e10cSrcweir 	CheckCompileBasic();
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     sal_Bool bIsCompiled = sal_False;
407*cdf0e10cSrcweir     if ( XModule().Is() )
408*cdf0e10cSrcweir         bIsCompiled = xModule->IsCompiled();
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     return bIsCompiled;
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir sal_Bool ModulWindow::BasicRun()
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 	aStatus.nBasicFlags = 0;
418*cdf0e10cSrcweir 	sal_Bool bDone = BasicExecute();
419*cdf0e10cSrcweir 	return bDone;
420*cdf0e10cSrcweir }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir sal_Bool ModulWindow::BasicStepOver()
423*cdf0e10cSrcweir {
424*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
425*cdf0e10cSrcweir 	aStatus.nBasicFlags = SbDEBUG_STEPINTO | SbDEBUG_STEPOVER;
426*cdf0e10cSrcweir 	sal_Bool bDone = BasicExecute();
427*cdf0e10cSrcweir 	return bDone;
428*cdf0e10cSrcweir }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir sal_Bool ModulWindow::BasicStepInto()
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 	aStatus.nBasicFlags = SbDEBUG_STEPINTO;
436*cdf0e10cSrcweir 	sal_Bool bDone = BasicExecute();
437*cdf0e10cSrcweir 	return bDone;
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir sal_Bool ModulWindow::BasicStepOut()
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 	aStatus.nBasicFlags = SbDEBUG_STEPOUT;
445*cdf0e10cSrcweir 	sal_Bool bDone = BasicExecute();
446*cdf0e10cSrcweir 	return bDone;
447*cdf0e10cSrcweir }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir void ModulWindow::BasicStop()
452*cdf0e10cSrcweir {
453*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir 	GetBasic()->Stop();
456*cdf0e10cSrcweir 	aStatus.bIsRunning = sal_False;
457*cdf0e10cSrcweir }
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir sal_Bool ModulWindow::LoadBasic()
460*cdf0e10cSrcweir {
461*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
462*cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir     Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
465*cdf0e10cSrcweir     Reference < XFilePicker > xFP;
466*cdf0e10cSrcweir     if( xMSF.is() )
467*cdf0e10cSrcweir     {
468*cdf0e10cSrcweir 		Sequence <Any> aServiceType(1);
469*cdf0e10cSrcweir 		aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
470*cdf0e10cSrcweir         xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
471*cdf0e10cSrcweir 					::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
472*cdf0e10cSrcweir     }
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	if ( aCurPath.Len() )
475*cdf0e10cSrcweir 		xFP->setDisplayDirectory ( aCurPath );
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 	//xFP->setTitle( String( IDEResId( RID_STR_OPEN ) ) );
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir     Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
480*cdf0e10cSrcweir 	xFltMgr->appendFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.bas" ) ) );
481*cdf0e10cSrcweir 	xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
482*cdf0e10cSrcweir 	xFltMgr->setCurrentFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir     if( xFP->execute() == RET_OK )
485*cdf0e10cSrcweir 	{
486*cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
487*cdf0e10cSrcweir 		aCurPath = aPaths[0];
488*cdf0e10cSrcweir 		SfxMedium aMedium( aCurPath, STREAM_READ | STREAM_SHARE_DENYWRITE | STREAM_NOCREATE, sal_True );
489*cdf0e10cSrcweir 		SvStream* pStream = aMedium.GetInStream();
490*cdf0e10cSrcweir 		if ( pStream )
491*cdf0e10cSrcweir 		{
492*cdf0e10cSrcweir 			AssertValidEditEngine();
493*cdf0e10cSrcweir 			sal_uLong nLines = CalcLineCount( *pStream );
494*cdf0e10cSrcweir 			// nLines*4: ReadText/Formatting/Highlighting/Formatting
495*cdf0e10cSrcweir 			GetEditorWindow().CreateProgress( String( IDEResId( RID_STR_GENERATESOURCE ) ), nLines*4 );
496*cdf0e10cSrcweir 			GetEditEngine()->SetUpdateMode( sal_False );
497*cdf0e10cSrcweir 			GetEditView()->Read( *pStream );
498*cdf0e10cSrcweir 			GetEditEngine()->SetUpdateMode( sal_True );
499*cdf0e10cSrcweir 			GetEditorWindow().Update();	// Es wurde bei UpdateMode = sal_True nur Invalidiert
500*cdf0e10cSrcweir 			GetEditorWindow().ForceSyntaxTimeout();
501*cdf0e10cSrcweir 			GetEditorWindow().DestroyProgress();
502*cdf0e10cSrcweir 			sal_uLong nError = aMedium.GetError();
503*cdf0e10cSrcweir 			if ( nError )
504*cdf0e10cSrcweir 				ErrorHandler::HandleError( nError );
505*cdf0e10cSrcweir 			else
506*cdf0e10cSrcweir 				bDone = sal_True;
507*cdf0e10cSrcweir 		}
508*cdf0e10cSrcweir 		else
509*cdf0e10cSrcweir 			ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_COULDNTREAD ) ) ).Execute();
510*cdf0e10cSrcweir 	}
511*cdf0e10cSrcweir 	return bDone;
512*cdf0e10cSrcweir }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir sal_Bool ModulWindow::SaveBasicSource()
516*cdf0e10cSrcweir {
517*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
518*cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir     Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
521*cdf0e10cSrcweir     Reference < XFilePicker > xFP;
522*cdf0e10cSrcweir     if( xMSF.is() )
523*cdf0e10cSrcweir     {
524*cdf0e10cSrcweir 		Sequence <Any> aServiceType(1);
525*cdf0e10cSrcweir 		aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
526*cdf0e10cSrcweir         xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
527*cdf0e10cSrcweir 					::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
528*cdf0e10cSrcweir     }
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 	Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
531*cdf0e10cSrcweir 	xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, sal_False);
532*cdf0e10cSrcweir     Any aValue;
533*cdf0e10cSrcweir     aValue <<= (sal_Bool) sal_True;
534*cdf0e10cSrcweir 	xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 	if ( aCurPath.Len() )
537*cdf0e10cSrcweir 		xFP->setDisplayDirectory ( aCurPath );
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir 	//xFP->setTitle( String( IDEResId( RID_STR_SAVE ) ) );
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir     Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
542*cdf0e10cSrcweir 	xFltMgr->appendFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.bas" ) ) );
543*cdf0e10cSrcweir 	xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
544*cdf0e10cSrcweir 	xFltMgr->setCurrentFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir     if( xFP->execute() == RET_OK )
547*cdf0e10cSrcweir 	{
548*cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
549*cdf0e10cSrcweir 		aCurPath = aPaths[0];
550*cdf0e10cSrcweir 		SfxMedium aMedium( aCurPath, STREAM_WRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC, sal_True, sal_False );
551*cdf0e10cSrcweir 		SvStream* pStream = aMedium.GetOutStream();
552*cdf0e10cSrcweir 		if ( pStream )
553*cdf0e10cSrcweir 		{
554*cdf0e10cSrcweir 			EnterWait();
555*cdf0e10cSrcweir 			AssertValidEditEngine();
556*cdf0e10cSrcweir 			GetEditEngine()->Write( *pStream );
557*cdf0e10cSrcweir 			aMedium.Commit();
558*cdf0e10cSrcweir 			LeaveWait();
559*cdf0e10cSrcweir 			sal_uLong nError = aMedium.GetError();
560*cdf0e10cSrcweir 			if ( nError )
561*cdf0e10cSrcweir 				ErrorHandler::HandleError( nError );
562*cdf0e10cSrcweir 			else
563*cdf0e10cSrcweir 				bDone = sal_True;
564*cdf0e10cSrcweir 		}
565*cdf0e10cSrcweir 		else
566*cdf0e10cSrcweir 			ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_COULDNTWRITE) ) ).Execute();
567*cdf0e10cSrcweir 	}
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir 	return bDone;
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir sal_Bool implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocument& rDocument, const String& aLibName );
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir sal_Bool ModulWindow::ImportDialog()
575*cdf0e10cSrcweir {
576*cdf0e10cSrcweir 	const ScriptDocument& rDocument = GetDocument();
577*cdf0e10cSrcweir 	String aLibName = GetLibName();
578*cdf0e10cSrcweir 	sal_Bool bRet = implImportDialog( this, aCurPath, rDocument, aLibName );
579*cdf0e10cSrcweir 	return bRet;
580*cdf0e10cSrcweir }
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir sal_Bool ModulWindow::ToggleBreakPoint( sal_uLong nLine )
583*cdf0e10cSrcweir {
584*cdf0e10cSrcweir 	DBG_ASSERT( XModule().Is(), "Kein Modul!" );
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 	sal_Bool bNewBreakPoint = sal_False;
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir     if ( XModule().Is() )
589*cdf0e10cSrcweir     {
590*cdf0e10cSrcweir         CheckCompileBasic();
591*cdf0e10cSrcweir 	    if ( aStatus.bError )
592*cdf0e10cSrcweir 	    {
593*cdf0e10cSrcweir 		    Sound::Beep();
594*cdf0e10cSrcweir 		    return sal_False;
595*cdf0e10cSrcweir 	    }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir         BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine );
598*cdf0e10cSrcweir 	    if ( pBrk ) // entfernen
599*cdf0e10cSrcweir 	    {
600*cdf0e10cSrcweir 		    xModule->ClearBP( (sal_uInt16)nLine );
601*cdf0e10cSrcweir 		    delete GetBreakPoints().Remove( pBrk );
602*cdf0e10cSrcweir 	    }
603*cdf0e10cSrcweir 	    else // einen erzeugen
604*cdf0e10cSrcweir 	    {
605*cdf0e10cSrcweir 		    if ( xModule->SetBP( (sal_uInt16)nLine) )
606*cdf0e10cSrcweir 		    {
607*cdf0e10cSrcweir 			    GetBreakPoints().InsertSorted( new BreakPoint( nLine ) );
608*cdf0e10cSrcweir 			    bNewBreakPoint = sal_True;
609*cdf0e10cSrcweir 			    if ( StarBASIC::IsRunning() )
610*cdf0e10cSrcweir 			    {
611*cdf0e10cSrcweir 				    for ( sal_uInt16 nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ )
612*cdf0e10cSrcweir 				    {
613*cdf0e10cSrcweir 					    SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod );
614*cdf0e10cSrcweir 					    DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
615*cdf0e10cSrcweir 					    pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
616*cdf0e10cSrcweir 				    }
617*cdf0e10cSrcweir 			    }
618*cdf0e10cSrcweir 		    }
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir 		    if ( !bNewBreakPoint )
621*cdf0e10cSrcweir 			    Sound::Beep();
622*cdf0e10cSrcweir 	    }
623*cdf0e10cSrcweir     }
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 	return bNewBreakPoint;
626*cdf0e10cSrcweir }
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir void ModulWindow::UpdateBreakPoint( const BreakPoint& rBrk )
629*cdf0e10cSrcweir {
630*cdf0e10cSrcweir 	DBG_ASSERT( XModule().Is(), "Kein Modul!" );
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir     if ( XModule().Is() )
633*cdf0e10cSrcweir     {
634*cdf0e10cSrcweir 	    CheckCompileBasic();
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir         if ( rBrk.bEnabled )
637*cdf0e10cSrcweir 		    xModule->SetBP( (sal_uInt16)rBrk.nLine );
638*cdf0e10cSrcweir 	    else
639*cdf0e10cSrcweir 		    xModule->ClearBP( (sal_uInt16)rBrk.nLine );
640*cdf0e10cSrcweir     }
641*cdf0e10cSrcweir }
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir sal_Bool ModulWindow::BasicToggleBreakPoint()
645*cdf0e10cSrcweir {
646*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
647*cdf0e10cSrcweir 	AssertValidEditEngine();
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir 	TextSelection aSel = GetEditView()->GetSelection();
650*cdf0e10cSrcweir 	aSel.GetStart().GetPara()++;	// Basic-Zeilen beginnen bei 1!
651*cdf0e10cSrcweir 	aSel.GetEnd().GetPara()++;
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 	sal_Bool bNewBreakPoint = sal_False;
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 	for ( sal_uLong nLine = aSel.GetStart().GetPara(); nLine <= aSel.GetEnd().GetPara(); nLine++ )
656*cdf0e10cSrcweir 	{
657*cdf0e10cSrcweir 		if ( ToggleBreakPoint( nLine ) )
658*cdf0e10cSrcweir 			bNewBreakPoint = sal_True;
659*cdf0e10cSrcweir 	}
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 	aXEditorWindow.GetBrkWindow().Invalidate();
662*cdf0e10cSrcweir 	return bNewBreakPoint;
663*cdf0e10cSrcweir }
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir void ModulWindow::BasicToggleBreakPointEnabled()
667*cdf0e10cSrcweir {
668*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
669*cdf0e10cSrcweir 	AssertValidEditEngine();
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir 	ExtTextView* pView = GetEditView();
672*cdf0e10cSrcweir 	if ( pView )
673*cdf0e10cSrcweir 	{
674*cdf0e10cSrcweir 		TextSelection aSel = pView->GetSelection();
675*cdf0e10cSrcweir 		BreakPointList& rList = GetBreakPoints();
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 		for ( sal_uLong nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine )
678*cdf0e10cSrcweir 		{
679*cdf0e10cSrcweir 			BreakPoint* pBrk = rList.FindBreakPoint( nLine );
680*cdf0e10cSrcweir 			if ( pBrk )
681*cdf0e10cSrcweir 			{
682*cdf0e10cSrcweir 				pBrk->bEnabled = pBrk->bEnabled ? sal_False : sal_True;
683*cdf0e10cSrcweir 				UpdateBreakPoint( *pBrk );
684*cdf0e10cSrcweir 			}
685*cdf0e10cSrcweir 		}
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir 		GetBreakPointWindow().Invalidate();
688*cdf0e10cSrcweir 	}
689*cdf0e10cSrcweir }
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir void ModulWindow::ManageBreakPoints()
693*cdf0e10cSrcweir {
694*cdf0e10cSrcweir 	BreakPointWindow& rBrkWin = GetBreakPointWindow();
695*cdf0e10cSrcweir 	BreakPointDialog aBrkDlg( &rBrkWin, GetBreakPoints() );
696*cdf0e10cSrcweir 	aBrkDlg.Execute();
697*cdf0e10cSrcweir 	rBrkWin.Invalidate();
698*cdf0e10cSrcweir }
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir IMPL_LINK( ModulWindow, BasicErrorHdl, StarBASIC *, pBasic )
702*cdf0e10cSrcweir {
703*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
704*cdf0e10cSrcweir 	GoOnTop();
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir 	// ReturnWert: BOOL
707*cdf0e10cSrcweir 	//	FALSE:	Abbrechen
708*cdf0e10cSrcweir 	//	TRUE:	Weiter....
709*cdf0e10cSrcweir 	String aErrorText( pBasic->GetErrorText() );
710*cdf0e10cSrcweir 	sal_uInt16 nErrorLine = pBasic->GetLine() - 1;
711*cdf0e10cSrcweir 	sal_uInt16 nErrCol1 = pBasic->GetCol1();
712*cdf0e10cSrcweir 	sal_uInt16 nErrCol2 = pBasic->GetCol2();
713*cdf0e10cSrcweir 	if ( nErrCol2 != 0xFFFF )
714*cdf0e10cSrcweir 		nErrCol2++;
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir 	AssertValidEditEngine();
717*cdf0e10cSrcweir 	GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, nErrCol1 ), TextPaM( nErrorLine, nErrCol2 ) ) );
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir 	String aErrorTextPrefix;
720*cdf0e10cSrcweir 	if( pBasic->IsCompilerError() )
721*cdf0e10cSrcweir 	{
722*cdf0e10cSrcweir 		aErrorTextPrefix = String( IDEResId( RID_STR_COMPILEERROR ) );
723*cdf0e10cSrcweir 	}
724*cdf0e10cSrcweir 	else
725*cdf0e10cSrcweir 	{
726*cdf0e10cSrcweir 		aErrorTextPrefix = String( IDEResId( RID_STR_RUNTIMEERROR ) );
727*cdf0e10cSrcweir 		aErrorTextPrefix += StarBASIC::GetVBErrorCode( pBasic->GetErrorCode() );
728*cdf0e10cSrcweir 		aErrorTextPrefix += ' ';
729*cdf0e10cSrcweir 		pLayout->GetStackWindow().UpdateCalls();
730*cdf0e10cSrcweir 	}
731*cdf0e10cSrcweir 	// Wenn anderes Basic, dan sollte die IDE versuchen, da richtige
732*cdf0e10cSrcweir 	// Modul anzuzeigen...
733*cdf0e10cSrcweir 	sal_Bool bMarkError = ( pBasic == GetBasic() ) ? sal_True : sal_False;
734*cdf0e10cSrcweir 	if ( bMarkError )
735*cdf0e10cSrcweir 		aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine, sal_True );
736*cdf0e10cSrcweir //	ErrorBox( this, WB_OK | WB_DEF_OK, String( aErrorTextPrefix + aErrorText ) ).Execute();
737*cdf0e10cSrcweir //	ErrorHandler::HandleError( pBasic->GetErrorCode() );
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir     // #i47002#
740*cdf0e10cSrcweir     Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( this );
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir     ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir     // #i47002#
745*cdf0e10cSrcweir     Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
746*cdf0e10cSrcweir     if ( !pWindow )
747*cdf0e10cSrcweir         return sal_False;
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir     if ( bMarkError )
750*cdf0e10cSrcweir 		aXEditorWindow.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER );
751*cdf0e10cSrcweir 	return sal_False;
752*cdf0e10cSrcweir }
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir long __EXPORT ModulWindow::BasicBreakHdl( StarBASIC* pBasic )
755*cdf0e10cSrcweir {
756*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
757*cdf0e10cSrcweir 	// Ein GoOnTop aktiviert da Fenster, das veraendert aber den Context fuer
758*cdf0e10cSrcweir 	// das Programm!
759*cdf0e10cSrcweir //	GoOnTop();
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 	// #i69280 Required in Window despite normal usage in next command!
762*cdf0e10cSrcweir 	(void)pBasic;
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir 	// ReturnWert: sal_uInt16 => siehe SB-Debug-Flags
765*cdf0e10cSrcweir 	sal_uInt16 nErrorLine = pBasic->GetLine();
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir 	// Gibt es hier einen BreakPoint?
768*cdf0e10cSrcweir 	BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nErrorLine );
769*cdf0e10cSrcweir     if ( pBrk )
770*cdf0e10cSrcweir     {
771*cdf0e10cSrcweir         pBrk->nHitCount++;
772*cdf0e10cSrcweir         if ( pBrk->nHitCount < pBrk->nStopAfter && GetBasic()->IsBreak() )
773*cdf0e10cSrcweir             return aStatus.nBasicFlags; // weiterlaufen...
774*cdf0e10cSrcweir     }
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 	nErrorLine--;	// EditEngine begint bei 0, Basic bei 1
777*cdf0e10cSrcweir 	// Alleine schon damit gescrollt wird...
778*cdf0e10cSrcweir 	AssertValidEditEngine();
779*cdf0e10cSrcweir 	GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, 0 ), TextPaM( nErrorLine, 0 ) ) );
780*cdf0e10cSrcweir 	aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine );
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir 	pLayout->GetWatchWindow().UpdateWatches();
783*cdf0e10cSrcweir 	pLayout->GetStackWindow().UpdateCalls();
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 	aStatus.bIsInReschedule = sal_True;
786*cdf0e10cSrcweir 	aStatus.bIsRunning = sal_True;
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir 	AddStatus( BASWIN_INRESCHEDULE );
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir 	BasicIDE::InvalidateDebuggerSlots();
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir 	while( aStatus.bIsRunning )
793*cdf0e10cSrcweir 		Application::Yield();
794*cdf0e10cSrcweir 
795*cdf0e10cSrcweir 	aStatus.bIsInReschedule = sal_False;
796*cdf0e10cSrcweir 	aXEditorWindow.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER );
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir 	ClearStatus( BASWIN_INRESCHEDULE );
799*cdf0e10cSrcweir 
800*cdf0e10cSrcweir 	return aStatus.nBasicFlags;
801*cdf0e10cSrcweir }
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir void ModulWindow::BasicAddWatch()
804*cdf0e10cSrcweir {
805*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
806*cdf0e10cSrcweir 	String aWatchStr;
807*cdf0e10cSrcweir 	sal_Bool bInserted = sal_False;
808*cdf0e10cSrcweir 	AssertValidEditEngine();
809*cdf0e10cSrcweir 	sal_Bool bAdd = sal_True;
810*cdf0e10cSrcweir 	if ( !GetEditView()->HasSelection() )
811*cdf0e10cSrcweir 	{
812*cdf0e10cSrcweir //		bAdd = GetEditView()->SelectCurrentWord();
813*cdf0e10cSrcweir 		TextPaM aWordStart;
814*cdf0e10cSrcweir 		String aWord = GetEditEngine()->GetWord( GetEditView()->GetSelection().GetEnd(), &aWordStart );
815*cdf0e10cSrcweir 		if ( aWord.Len() )
816*cdf0e10cSrcweir 		{
817*cdf0e10cSrcweir 			TextSelection aSel( aWordStart );
818*cdf0e10cSrcweir 			sal_uInt16& rIndex = aSel.GetEnd().GetIndex();
819*cdf0e10cSrcweir 			rIndex = rIndex + aWord.Len();
820*cdf0e10cSrcweir 			// aSel.GetEnd().GetIndex() += sal::static_int_cast<int>( aWord.Len() );
821*cdf0e10cSrcweir 			GetEditView()->SetSelection( aSel );
822*cdf0e10cSrcweir 			bAdd = sal_True;
823*cdf0e10cSrcweir 		}
824*cdf0e10cSrcweir 	}
825*cdf0e10cSrcweir 	if ( bAdd )
826*cdf0e10cSrcweir 	{
827*cdf0e10cSrcweir 		TextSelection aSel = GetEditView()->GetSelection();
828*cdf0e10cSrcweir 		if ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() )
829*cdf0e10cSrcweir 		{
830*cdf0e10cSrcweir 			aWatchStr = GetEditView()->GetSelected();
831*cdf0e10cSrcweir 			pLayout->GetWatchWindow().AddWatch( aWatchStr );
832*cdf0e10cSrcweir 			pLayout->GetWatchWindow().UpdateWatches();
833*cdf0e10cSrcweir 			bInserted = sal_True;
834*cdf0e10cSrcweir 		}
835*cdf0e10cSrcweir 	}
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir 	if ( !bInserted )
838*cdf0e10cSrcweir 		Sound::Beep();
839*cdf0e10cSrcweir }
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir 
843*cdf0e10cSrcweir void ModulWindow::BasicRemoveWatch()
844*cdf0e10cSrcweir {
845*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
846*cdf0e10cSrcweir 	sal_Bool bRemoved = pLayout->GetWatchWindow().RemoveSelectedWatch();
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir 	if ( !bRemoved )
849*cdf0e10cSrcweir 		Sound::Beep();
850*cdf0e10cSrcweir }
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir void ModulWindow::EditMacro( const String& rMacroName )
854*cdf0e10cSrcweir {
855*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
856*cdf0e10cSrcweir 	DBG_ASSERT( XModule().Is(), "Kein Modul!" );
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir     if ( XModule().Is() )
859*cdf0e10cSrcweir     {
860*cdf0e10cSrcweir         CheckCompileBasic();
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir 	    if ( !aStatus.bError )
863*cdf0e10cSrcweir 	    {
864*cdf0e10cSrcweir 		    sal_uInt16 nStart, nEnd;
865*cdf0e10cSrcweir 		    SbMethod* pMethod = (SbMethod*)xModule->Find( rMacroName, SbxCLASS_METHOD );
866*cdf0e10cSrcweir 		    if ( pMethod )
867*cdf0e10cSrcweir 		    {
868*cdf0e10cSrcweir 			    pMethod->GetLineRange( nStart, nEnd );
869*cdf0e10cSrcweir 			    if ( nStart )
870*cdf0e10cSrcweir 			    {
871*cdf0e10cSrcweir 				    // Basic beginnt bei 1
872*cdf0e10cSrcweir 				    nStart--;
873*cdf0e10cSrcweir 				    nEnd--;
874*cdf0e10cSrcweir 			    }
875*cdf0e10cSrcweir 			    TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) );
876*cdf0e10cSrcweir 			    AssertValidEditEngine();
877*cdf0e10cSrcweir 			    TextView * pView = GetEditView();
878*cdf0e10cSrcweir 			    // ggf. hinscrollen, so dass erste Zeile oben...
879*cdf0e10cSrcweir 			    long nVisHeight = GetOutputSizePixel().Height();
880*cdf0e10cSrcweir 			    if ( (long)pView->GetTextEngine()->GetTextHeight() > nVisHeight )
881*cdf0e10cSrcweir 			    {
882*cdf0e10cSrcweir 				    long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight;
883*cdf0e10cSrcweir 				    long nOldStartY = pView->GetStartDocPos().Y();
884*cdf0e10cSrcweir 				    long nNewStartY = nStart * pView->GetTextEngine()->GetCharHeight();
885*cdf0e10cSrcweir 				    nNewStartY = Min( nNewStartY, nMaxY );
886*cdf0e10cSrcweir 				    pView->Scroll( 0, -(nNewStartY-nOldStartY) );
887*cdf0e10cSrcweir 				    pView->ShowCursor( sal_False, sal_True );
888*cdf0e10cSrcweir 				    GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() );
889*cdf0e10cSrcweir 			    }
890*cdf0e10cSrcweir 			    pView->SetSelection( aSel );
891*cdf0e10cSrcweir 			    pView->ShowCursor();
892*cdf0e10cSrcweir 			    pView->GetWindow()->GrabFocus();
893*cdf0e10cSrcweir 		    }
894*cdf0e10cSrcweir 	    }
895*cdf0e10cSrcweir     }
896*cdf0e10cSrcweir }
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir 
899*cdf0e10cSrcweir void __EXPORT ModulWindow::StoreData()
900*cdf0e10cSrcweir {
901*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
902*cdf0e10cSrcweir 	// StoreData wird gerufen, wenn der BasicManager zerstoert oder
903*cdf0e10cSrcweir 	// dieses Fenster beendet wird.
904*cdf0e10cSrcweir 	// => Keine Unterbrechungen erwuenscht!
905*cdf0e10cSrcweir 	// Und bei SAVE, wenn AppBasic...
906*cdf0e10cSrcweir 	GetEditorWindow().SetSourceInBasic( sal_True );
907*cdf0e10cSrcweir 	// Nicht das Modify loeschen, sonst wird das Basic nicht gespeichert
908*cdf0e10cSrcweir 	// Es wird beim Speichern sowieso geloescht.
909*cdf0e10cSrcweir //	xModule->SetModified( sal_False );
910*cdf0e10cSrcweir }
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir sal_Bool __EXPORT ModulWindow::CanClose()
913*cdf0e10cSrcweir {
914*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
915*cdf0e10cSrcweir 	return sal_True;
916*cdf0e10cSrcweir }
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir sal_Bool __EXPORT ModulWindow::AllowUndo()
920*cdf0e10cSrcweir {
921*cdf0e10cSrcweir 	return GetEditorWindow().CanModify();
922*cdf0e10cSrcweir }
923*cdf0e10cSrcweir 
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir void __EXPORT ModulWindow::UpdateData()
926*cdf0e10cSrcweir {
927*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
928*cdf0e10cSrcweir 	DBG_ASSERT( XModule().Is(), "Kein Modul!" );
929*cdf0e10cSrcweir 	// UpdateData wird gerufen, wenn sich der Source von aussen
930*cdf0e10cSrcweir 	// geaendert hat.
931*cdf0e10cSrcweir 	// => Keine Unterbrechungen erwuenscht!
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir     if ( XModule().Is() )
934*cdf0e10cSrcweir     {
935*cdf0e10cSrcweir         SetModule( xModule->GetSource32() );
936*cdf0e10cSrcweir 
937*cdf0e10cSrcweir         if ( GetEditView() )
938*cdf0e10cSrcweir 	    {
939*cdf0e10cSrcweir 		    TextSelection aSel = GetEditView()->GetSelection();
940*cdf0e10cSrcweir             setTextEngineText( GetEditEngine(), xModule->GetSource32() );
941*cdf0e10cSrcweir 		    GetEditView()->SetSelection( aSel );
942*cdf0e10cSrcweir 		    GetEditEngine()->SetModified( sal_False );
943*cdf0e10cSrcweir 		    BasicIDE::MarkDocumentModified( GetDocument() );
944*cdf0e10cSrcweir 	    }
945*cdf0e10cSrcweir     }
946*cdf0e10cSrcweir }
947*cdf0e10cSrcweir 
948*cdf0e10cSrcweir sal_Int32 ModulWindow::countPages( Printer* pPrinter )
949*cdf0e10cSrcweir {
950*cdf0e10cSrcweir     return FormatAndPrint( pPrinter, -1 );
951*cdf0e10cSrcweir }
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir void ModulWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
954*cdf0e10cSrcweir {
955*cdf0e10cSrcweir     FormatAndPrint( pPrinter, nPage );
956*cdf0e10cSrcweir }
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir /* implementation note: this is totally inefficient for the XRenderable interface
959*cdf0e10cSrcweir    usage since the whole "document" will be format for every page. Should this ever
960*cdf0e10cSrcweir    become a problem we should
961*cdf0e10cSrcweir    - format only once for every new printer
962*cdf0e10cSrcweir    - keep an index list for each page which is the starting paragraph
963*cdf0e10cSrcweir */
964*cdf0e10cSrcweir sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
965*cdf0e10cSrcweir {
966*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir 	AssertValidEditEngine();
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir 	MapMode eOldMapMode( pPrinter->GetMapMode() );
971*cdf0e10cSrcweir 	Font aOldFont( pPrinter->GetFont() );
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir //	Font aFont( GetEditEngine()->CreateFontFromItemSet( GetEditEngine()->GetEmptyItemSet() ) );
974*cdf0e10cSrcweir 	Font aFont( GetEditEngine()->GetFont() );
975*cdf0e10cSrcweir 	aFont.SetAlign( ALIGN_BOTTOM );
976*cdf0e10cSrcweir 	aFont.SetTransparent( sal_True );
977*cdf0e10cSrcweir 	aFont.SetSize( Size( 0, 360 ) );
978*cdf0e10cSrcweir 	pPrinter->SetFont( aFont );
979*cdf0e10cSrcweir 	pPrinter->SetMapMode( MAP_100TH_MM );
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir 	String aTitle( CreateQualifiedName() );
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir 	sal_uInt16 nLineHeight = (sal_uInt16) pPrinter->GetTextHeight(); // etwas mehr.
984*cdf0e10cSrcweir 	sal_uInt16 nParaSpace = 10;
985*cdf0e10cSrcweir 
986*cdf0e10cSrcweir 	Size aPaperSz = pPrinter->GetOutputSize();
987*cdf0e10cSrcweir 	aPaperSz.Width() -= (LMARGPRN+RMARGPRN);
988*cdf0e10cSrcweir 	aPaperSz.Height() -= (TMARGPRN+BMARGPRN);
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir 	// nLinepPage stimmt nicht, wenn Zeilen umgebrochen werden muessen...
991*cdf0e10cSrcweir 	sal_uInt16 nLinespPage = (sal_uInt16) (aPaperSz.Height()/nLineHeight);
992*cdf0e10cSrcweir 	sal_uInt16 nCharspLine = (sal_uInt16) (aPaperSz.Width() / pPrinter->GetTextWidth( 'X' ) );
993*cdf0e10cSrcweir 	sal_uLong nParas = GetEditEngine()->GetParagraphCount();
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir 	sal_uInt16 nPages = (sal_uInt16) (nParas/nLinespPage+1 );
996*cdf0e10cSrcweir 	sal_uInt16 nCurPage = 1;
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir 	// Header drucken...
999*cdf0e10cSrcweir 	lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 );
1000*cdf0e10cSrcweir 	Point aPos( LMARGPRN, TMARGPRN );
1001*cdf0e10cSrcweir 	for ( sal_uLong nPara = 0; nPara < nParas; nPara++ )
1002*cdf0e10cSrcweir 	{
1003*cdf0e10cSrcweir 		String aLine( GetEditEngine()->GetText( nPara ) );
1004*cdf0e10cSrcweir 		lcl_ConvertTabsToSpaces( aLine );
1005*cdf0e10cSrcweir 		sal_uInt16 nLines = aLine.Len()/nCharspLine+1;
1006*cdf0e10cSrcweir 		for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ )
1007*cdf0e10cSrcweir 		{
1008*cdf0e10cSrcweir 			String aTmpLine( aLine, nLine*nCharspLine, nCharspLine );
1009*cdf0e10cSrcweir 			aPos.Y() += nLineHeight;
1010*cdf0e10cSrcweir 			if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) )
1011*cdf0e10cSrcweir 			{
1012*cdf0e10cSrcweir 				nCurPage++;
1013*cdf0e10cSrcweir 				lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nCurPage-1 == nPrintPage );
1014*cdf0e10cSrcweir 				aPos = Point( LMARGPRN, TMARGPRN+nLineHeight );
1015*cdf0e10cSrcweir 			}
1016*cdf0e10cSrcweir             if( nCurPage-1 == nPrintPage )
1017*cdf0e10cSrcweir                 pPrinter->DrawText( aPos, aTmpLine );
1018*cdf0e10cSrcweir 		}
1019*cdf0e10cSrcweir 		aPos.Y() += nParaSpace;
1020*cdf0e10cSrcweir 	}
1021*cdf0e10cSrcweir 
1022*cdf0e10cSrcweir 	pPrinter->SetFont( aOldFont );
1023*cdf0e10cSrcweir 	pPrinter->SetMapMode( eOldMapMode );
1024*cdf0e10cSrcweir 
1025*cdf0e10cSrcweir     return sal_Int32(nCurPage);
1026*cdf0e10cSrcweir }
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir 
1029*cdf0e10cSrcweir void __EXPORT ModulWindow::ExecuteCommand( SfxRequest& rReq )
1030*cdf0e10cSrcweir {
1031*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
1032*cdf0e10cSrcweir 	AssertValidEditEngine();
1033*cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
1034*cdf0e10cSrcweir 	switch ( nSlot )
1035*cdf0e10cSrcweir 	{
1036*cdf0e10cSrcweir 		case SID_BASICRUN:
1037*cdf0e10cSrcweir 		{
1038*cdf0e10cSrcweir 			BasicRun();
1039*cdf0e10cSrcweir 		}
1040*cdf0e10cSrcweir 		break;
1041*cdf0e10cSrcweir 		case SID_BASICCOMPILE:
1042*cdf0e10cSrcweir 		{
1043*cdf0e10cSrcweir 			CompileBasic();
1044*cdf0e10cSrcweir 		}
1045*cdf0e10cSrcweir 		break;
1046*cdf0e10cSrcweir 		case SID_BASICSTEPOVER:
1047*cdf0e10cSrcweir 		{
1048*cdf0e10cSrcweir 			BasicStepOver();
1049*cdf0e10cSrcweir 		}
1050*cdf0e10cSrcweir 		break;
1051*cdf0e10cSrcweir 		case SID_BASICSTEPINTO:
1052*cdf0e10cSrcweir 		{
1053*cdf0e10cSrcweir 			BasicStepInto();
1054*cdf0e10cSrcweir 		}
1055*cdf0e10cSrcweir 		break;
1056*cdf0e10cSrcweir 		case SID_BASICSTEPOUT:
1057*cdf0e10cSrcweir 		{
1058*cdf0e10cSrcweir 			BasicStepOut();
1059*cdf0e10cSrcweir 		}
1060*cdf0e10cSrcweir 		break;
1061*cdf0e10cSrcweir 		case SID_BASICLOAD:
1062*cdf0e10cSrcweir 		{
1063*cdf0e10cSrcweir 			LoadBasic();
1064*cdf0e10cSrcweir 		}
1065*cdf0e10cSrcweir 		break;
1066*cdf0e10cSrcweir 		case SID_BASICSAVEAS:
1067*cdf0e10cSrcweir 		{
1068*cdf0e10cSrcweir 			SaveBasicSource();
1069*cdf0e10cSrcweir 		}
1070*cdf0e10cSrcweir 		break;
1071*cdf0e10cSrcweir 		case SID_IMPORT_DIALOG:
1072*cdf0e10cSrcweir 		{
1073*cdf0e10cSrcweir 			ImportDialog();
1074*cdf0e10cSrcweir 		}
1075*cdf0e10cSrcweir 		break;
1076*cdf0e10cSrcweir 		case SID_BASICIDE_MATCHGROUP:
1077*cdf0e10cSrcweir 		{
1078*cdf0e10cSrcweir 			if ( !GetEditView()->MatchGroup() )
1079*cdf0e10cSrcweir 				Sound::Beep();
1080*cdf0e10cSrcweir 		}
1081*cdf0e10cSrcweir 		break;
1082*cdf0e10cSrcweir 		case SID_BASICIDE_TOGGLEBRKPNT:
1083*cdf0e10cSrcweir 		{
1084*cdf0e10cSrcweir 			BasicToggleBreakPoint();
1085*cdf0e10cSrcweir 		}
1086*cdf0e10cSrcweir 		break;
1087*cdf0e10cSrcweir 		case SID_BASICIDE_MANAGEBRKPNTS:
1088*cdf0e10cSrcweir 		{
1089*cdf0e10cSrcweir 			ManageBreakPoints();
1090*cdf0e10cSrcweir 		}
1091*cdf0e10cSrcweir 		break;
1092*cdf0e10cSrcweir 		case SID_BASICIDE_TOGGLEBRKPNTENABLED:
1093*cdf0e10cSrcweir 		{
1094*cdf0e10cSrcweir 			BasicToggleBreakPointEnabled();
1095*cdf0e10cSrcweir 		}
1096*cdf0e10cSrcweir 		break;
1097*cdf0e10cSrcweir 		case SID_BASICIDE_ADDWATCH:
1098*cdf0e10cSrcweir 		{
1099*cdf0e10cSrcweir 			BasicAddWatch();
1100*cdf0e10cSrcweir 		}
1101*cdf0e10cSrcweir 		break;
1102*cdf0e10cSrcweir 		case SID_BASICIDE_REMOVEWATCH:
1103*cdf0e10cSrcweir 		{
1104*cdf0e10cSrcweir 			BasicRemoveWatch();
1105*cdf0e10cSrcweir 		}
1106*cdf0e10cSrcweir 		break;
1107*cdf0e10cSrcweir 		case SID_CUT:
1108*cdf0e10cSrcweir 		{
1109*cdf0e10cSrcweir             if ( !IsReadOnly() )
1110*cdf0e10cSrcweir             {
1111*cdf0e10cSrcweir 			    GetEditView()->Cut();
1112*cdf0e10cSrcweir                 SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
1113*cdf0e10cSrcweir                 if ( pBindings )
1114*cdf0e10cSrcweir                     pBindings->Invalidate( SID_DOC_MODIFIED );
1115*cdf0e10cSrcweir             }
1116*cdf0e10cSrcweir 		}
1117*cdf0e10cSrcweir 		break;
1118*cdf0e10cSrcweir 		case SID_COPY:
1119*cdf0e10cSrcweir 		{
1120*cdf0e10cSrcweir 			GetEditView()->Copy();
1121*cdf0e10cSrcweir 		}
1122*cdf0e10cSrcweir 		break;
1123*cdf0e10cSrcweir 		case SID_PASTE:
1124*cdf0e10cSrcweir 		{
1125*cdf0e10cSrcweir             if ( !IsReadOnly() )
1126*cdf0e10cSrcweir             {
1127*cdf0e10cSrcweir 			    GetEditView()->Paste();
1128*cdf0e10cSrcweir                 SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
1129*cdf0e10cSrcweir                 if ( pBindings )
1130*cdf0e10cSrcweir                     pBindings->Invalidate( SID_DOC_MODIFIED );
1131*cdf0e10cSrcweir             }
1132*cdf0e10cSrcweir 		}
1133*cdf0e10cSrcweir 		break;
1134*cdf0e10cSrcweir 		case SID_BASICIDE_BRKPNTSCHANGED:
1135*cdf0e10cSrcweir 		{
1136*cdf0e10cSrcweir 			GetBreakPointWindow().Invalidate();
1137*cdf0e10cSrcweir 		}
1138*cdf0e10cSrcweir 		break;
1139*cdf0e10cSrcweir 	}
1140*cdf0e10cSrcweir }
1141*cdf0e10cSrcweir 
1142*cdf0e10cSrcweir 
1143*cdf0e10cSrcweir 
1144*cdf0e10cSrcweir void __EXPORT ModulWindow::GetState( SfxItemSet &rSet )
1145*cdf0e10cSrcweir {
1146*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
1147*cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
1148*cdf0e10cSrcweir 	for ( sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
1149*cdf0e10cSrcweir 	{
1150*cdf0e10cSrcweir 		switch ( nWh )
1151*cdf0e10cSrcweir 		{
1152*cdf0e10cSrcweir 			// allgemeine Items:
1153*cdf0e10cSrcweir 			case SID_CUT:
1154*cdf0e10cSrcweir 			{
1155*cdf0e10cSrcweir 				if ( !GetEditView() || !GetEditView()->HasSelection() )
1156*cdf0e10cSrcweir 					rSet.DisableItem( nWh );
1157*cdf0e10cSrcweir 
1158*cdf0e10cSrcweir                 if ( IsReadOnly() )
1159*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
1160*cdf0e10cSrcweir             }
1161*cdf0e10cSrcweir 			break;
1162*cdf0e10cSrcweir             case SID_COPY:
1163*cdf0e10cSrcweir 			{
1164*cdf0e10cSrcweir 				if ( !GetEditView() || !GetEditView()->HasSelection() )
1165*cdf0e10cSrcweir 					rSet.DisableItem( nWh );
1166*cdf0e10cSrcweir 			}
1167*cdf0e10cSrcweir 			break;
1168*cdf0e10cSrcweir             case SID_PASTE:
1169*cdf0e10cSrcweir             {
1170*cdf0e10cSrcweir                 if ( !IsPasteAllowed() )
1171*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
1172*cdf0e10cSrcweir 
1173*cdf0e10cSrcweir                 if ( IsReadOnly() )
1174*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
1175*cdf0e10cSrcweir             }
1176*cdf0e10cSrcweir 			break;
1177*cdf0e10cSrcweir 			case SID_BASICIDE_STAT_POS:
1178*cdf0e10cSrcweir 			{
1179*cdf0e10cSrcweir 				TextView* pView = GetEditView();
1180*cdf0e10cSrcweir 				if ( pView )
1181*cdf0e10cSrcweir 				{
1182*cdf0e10cSrcweir 					TextSelection aSel = pView->GetSelection();
1183*cdf0e10cSrcweir 					String aPos( IDEResId( RID_STR_LINE ) );
1184*cdf0e10cSrcweir 					aPos += ' ';
1185*cdf0e10cSrcweir 					aPos += String::CreateFromInt32( aSel.GetEnd().GetPara()+1 );
1186*cdf0e10cSrcweir 					aPos += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
1187*cdf0e10cSrcweir 					aPos += String( IDEResId( RID_STR_COLUMN ) );
1188*cdf0e10cSrcweir 					aPos += ' ';
1189*cdf0e10cSrcweir 					aPos += String::CreateFromInt32( aSel.GetEnd().GetIndex()+1 );
1190*cdf0e10cSrcweir 					SfxStringItem aItem( SID_BASICIDE_STAT_POS, aPos );
1191*cdf0e10cSrcweir 					rSet.Put( aItem );
1192*cdf0e10cSrcweir 				}
1193*cdf0e10cSrcweir 			}
1194*cdf0e10cSrcweir 			break;
1195*cdf0e10cSrcweir 			case SID_ATTR_INSERT:
1196*cdf0e10cSrcweir 			{
1197*cdf0e10cSrcweir 				TextView* pView = GetEditView();
1198*cdf0e10cSrcweir 				if ( pView )
1199*cdf0e10cSrcweir 				{
1200*cdf0e10cSrcweir 					SfxBoolItem aItem( SID_ATTR_INSERT, pView->IsInsertMode() );
1201*cdf0e10cSrcweir 					rSet.Put( aItem );
1202*cdf0e10cSrcweir 				}
1203*cdf0e10cSrcweir 			}
1204*cdf0e10cSrcweir 			break;
1205*cdf0e10cSrcweir 		}
1206*cdf0e10cSrcweir 	}
1207*cdf0e10cSrcweir }
1208*cdf0e10cSrcweir 
1209*cdf0e10cSrcweir 
1210*cdf0e10cSrcweir void __EXPORT ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
1211*cdf0e10cSrcweir {
1212*cdf0e10cSrcweir 	DBG_CHKTHIS( ModulWindow, 0 );
1213*cdf0e10cSrcweir 	if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
1214*cdf0e10cSrcweir 	{
1215*cdf0e10cSrcweir 		// Nicht mit dem Wert Scrollen, sondern lieber die Thumb-Pos fuer die
1216*cdf0e10cSrcweir 		// VisArea verwenden:
1217*cdf0e10cSrcweir 		long nDiff = GetEditView()->GetStartDocPos().X() - pCurScrollBar->GetThumbPos();
1218*cdf0e10cSrcweir 		GetEditView()->Scroll( nDiff, 0 );
1219*cdf0e10cSrcweir 		GetEditView()->ShowCursor( sal_False, sal_True );
1220*cdf0e10cSrcweir 		pCurScrollBar->SetThumbPos( GetEditView()->GetStartDocPos().X() );
1221*cdf0e10cSrcweir 
1222*cdf0e10cSrcweir 	}
1223*cdf0e10cSrcweir }
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir 
1226*cdf0e10cSrcweir sal_Bool __EXPORT ModulWindow::IsModified()
1227*cdf0e10cSrcweir {
1228*cdf0e10cSrcweir 	return GetEditEngine() ? GetEditEngine()->IsModified() : sal_False;
1229*cdf0e10cSrcweir }
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir 
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir void __EXPORT ModulWindow::GoOnTop()
1234*cdf0e10cSrcweir {
1235*cdf0e10cSrcweir 	IDE_DLL()->GetShell()->GetViewFrame()->ToTop();
1236*cdf0e10cSrcweir }
1237*cdf0e10cSrcweir 
1238*cdf0e10cSrcweir String ModulWindow::GetSbModuleName()
1239*cdf0e10cSrcweir {
1240*cdf0e10cSrcweir 	String aModuleName;
1241*cdf0e10cSrcweir 	if ( XModule().Is() )
1242*cdf0e10cSrcweir 		aModuleName = xModule->GetName();
1243*cdf0e10cSrcweir 	return aModuleName;
1244*cdf0e10cSrcweir }
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir 
1248*cdf0e10cSrcweir String __EXPORT ModulWindow::GetTitle()
1249*cdf0e10cSrcweir {
1250*cdf0e10cSrcweir 	return GetSbModuleName();
1251*cdf0e10cSrcweir }
1252*cdf0e10cSrcweir 
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir 
1255*cdf0e10cSrcweir void ModulWindow::FrameWindowMoved()
1256*cdf0e10cSrcweir {
1257*cdf0e10cSrcweir //	if ( GetEditEngine() && GetEditEngine()->IsInSelectionMode() )
1258*cdf0e10cSrcweir //		GetEditEngine()->StopSelectionMode();
1259*cdf0e10cSrcweir }
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir 
1263*cdf0e10cSrcweir void ModulWindow::ShowCursor( sal_Bool bOn )
1264*cdf0e10cSrcweir {
1265*cdf0e10cSrcweir 	if ( GetEditEngine() )
1266*cdf0e10cSrcweir 	{
1267*cdf0e10cSrcweir 		TextView* pView = GetEditEngine()->GetActiveView();
1268*cdf0e10cSrcweir 		if ( pView )
1269*cdf0e10cSrcweir 		{
1270*cdf0e10cSrcweir 			if ( bOn )
1271*cdf0e10cSrcweir 				pView->ShowCursor();
1272*cdf0e10cSrcweir 			else
1273*cdf0e10cSrcweir 				pView->HideCursor();
1274*cdf0e10cSrcweir 		}
1275*cdf0e10cSrcweir 	}
1276*cdf0e10cSrcweir }
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir Window* __EXPORT ModulWindow::GetLayoutWindow()
1280*cdf0e10cSrcweir {
1281*cdf0e10cSrcweir 	return pLayout;
1282*cdf0e10cSrcweir }
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir void ModulWindow::AssertValidEditEngine()
1285*cdf0e10cSrcweir {
1286*cdf0e10cSrcweir 	if ( !GetEditEngine() )
1287*cdf0e10cSrcweir 		GetEditorWindow().CreateEditEngine();
1288*cdf0e10cSrcweir }
1289*cdf0e10cSrcweir 
1290*cdf0e10cSrcweir void ModulWindow::Deactivating()
1291*cdf0e10cSrcweir {
1292*cdf0e10cSrcweir 	if ( GetEditView() )
1293*cdf0e10cSrcweir 		GetEditView()->EraseVirtualDevice();
1294*cdf0e10cSrcweir }
1295*cdf0e10cSrcweir 
1296*cdf0e10cSrcweir sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem, sal_Bool bFromStart )
1297*cdf0e10cSrcweir {
1298*cdf0e10cSrcweir 	// Mann koennte fuer das blinde Alle-Ersetzen auch auf
1299*cdf0e10cSrcweir 	// Syntaxhighlighting/Formatierung verzichten...
1300*cdf0e10cSrcweir 	AssertValidEditEngine();
1301*cdf0e10cSrcweir 	ExtTextView* pView = GetEditView();
1302*cdf0e10cSrcweir 	TextSelection aSel;
1303*cdf0e10cSrcweir 	if ( bFromStart )
1304*cdf0e10cSrcweir 	{
1305*cdf0e10cSrcweir 		aSel = pView->GetSelection();
1306*cdf0e10cSrcweir 		if ( !rSearchItem.GetBackward() )
1307*cdf0e10cSrcweir 			pView->SetSelection( TextSelection() );
1308*cdf0e10cSrcweir 		else
1309*cdf0e10cSrcweir 			pView->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
1310*cdf0e10cSrcweir 	}
1311*cdf0e10cSrcweir 
1312*cdf0e10cSrcweir 	sal_Bool bForward = !rSearchItem.GetBackward();
1313*cdf0e10cSrcweir 	sal_uInt16 nFound = 0;
1314*cdf0e10cSrcweir 	if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND ) ||
1315*cdf0e10cSrcweir 		 ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND_ALL ) )
1316*cdf0e10cSrcweir 	{
1317*cdf0e10cSrcweir 		nFound = pView->Search( rSearchItem.GetSearchOptions() , bForward );
1318*cdf0e10cSrcweir 	}
1319*cdf0e10cSrcweir 	else if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE ) ||
1320*cdf0e10cSrcweir 			  ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL ) )
1321*cdf0e10cSrcweir 	{
1322*cdf0e10cSrcweir         if ( !IsReadOnly() )
1323*cdf0e10cSrcweir         {
1324*cdf0e10cSrcweir             sal_Bool bAll = rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;
1325*cdf0e10cSrcweir             nFound = pView->Replace( rSearchItem.GetSearchOptions() , bAll , bForward );
1326*cdf0e10cSrcweir         }
1327*cdf0e10cSrcweir 	}
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir 	if ( bFromStart && !nFound )
1330*cdf0e10cSrcweir 		pView->SetSelection( aSel );
1331*cdf0e10cSrcweir 
1332*cdf0e10cSrcweir 	return nFound;
1333*cdf0e10cSrcweir }
1334*cdf0e10cSrcweir 
1335*cdf0e10cSrcweir ::svl::IUndoManager* __EXPORT ModulWindow::GetUndoManager()
1336*cdf0e10cSrcweir {
1337*cdf0e10cSrcweir 	if ( GetEditEngine() )
1338*cdf0e10cSrcweir 		return &GetEditEngine()->GetUndoManager();
1339*cdf0e10cSrcweir 	return NULL;
1340*cdf0e10cSrcweir }
1341*cdf0e10cSrcweir 
1342*cdf0e10cSrcweir sal_uInt16 __EXPORT ModulWindow::GetSearchOptions()
1343*cdf0e10cSrcweir {
1344*cdf0e10cSrcweir     sal_uInt16 nOptions = SEARCH_OPTIONS_SEARCH |
1345*cdf0e10cSrcweir                       SEARCH_OPTIONS_WHOLE_WORDS |
1346*cdf0e10cSrcweir                       SEARCH_OPTIONS_BACKWARDS |
1347*cdf0e10cSrcweir                       SEARCH_OPTIONS_REG_EXP |
1348*cdf0e10cSrcweir                       SEARCH_OPTIONS_EXACT |
1349*cdf0e10cSrcweir                       SEARCH_OPTIONS_SELECTION |
1350*cdf0e10cSrcweir                       SEARCH_OPTIONS_SIMILARITY;
1351*cdf0e10cSrcweir 
1352*cdf0e10cSrcweir     if ( !IsReadOnly() )
1353*cdf0e10cSrcweir     {
1354*cdf0e10cSrcweir         nOptions |= SEARCH_OPTIONS_REPLACE;
1355*cdf0e10cSrcweir         nOptions |= SEARCH_OPTIONS_REPLACE_ALL;
1356*cdf0e10cSrcweir     }
1357*cdf0e10cSrcweir 
1358*cdf0e10cSrcweir     return nOptions;
1359*cdf0e10cSrcweir }
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir void __EXPORT ModulWindow::BasicStarted()
1362*cdf0e10cSrcweir {
1363*cdf0e10cSrcweir     if ( XModule().Is() )
1364*cdf0e10cSrcweir     {
1365*cdf0e10cSrcweir         aStatus.bIsRunning = sal_True;
1366*cdf0e10cSrcweir         BreakPointList& rList = GetBreakPoints();
1367*cdf0e10cSrcweir         if ( rList.Count() )
1368*cdf0e10cSrcweir 	    {
1369*cdf0e10cSrcweir             rList.ResetHitCount();
1370*cdf0e10cSrcweir 		    rList.SetBreakPointsInBasic( xModule );
1371*cdf0e10cSrcweir 		    for ( sal_uInt16 nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ )
1372*cdf0e10cSrcweir 		    {
1373*cdf0e10cSrcweir 			    SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod );
1374*cdf0e10cSrcweir 			    DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
1375*cdf0e10cSrcweir 			    pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
1376*cdf0e10cSrcweir 		    }
1377*cdf0e10cSrcweir 	    }
1378*cdf0e10cSrcweir     }
1379*cdf0e10cSrcweir }
1380*cdf0e10cSrcweir 
1381*cdf0e10cSrcweir void __EXPORT ModulWindow::BasicStopped()
1382*cdf0e10cSrcweir {
1383*cdf0e10cSrcweir 	aStatus.bIsRunning = sal_False;
1384*cdf0e10cSrcweir 	GetBreakPointWindow().SetMarkerPos( MARKER_NOMARKER );
1385*cdf0e10cSrcweir }
1386*cdf0e10cSrcweir 
1387*cdf0e10cSrcweir BasicEntryDescriptor ModulWindow::CreateEntryDescriptor()
1388*cdf0e10cSrcweir {
1389*cdf0e10cSrcweir     ScriptDocument aDocument( GetDocument() );
1390*cdf0e10cSrcweir     String aLibName( GetLibName() );
1391*cdf0e10cSrcweir     LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
1392*cdf0e10cSrcweir     String aModName( GetName() );
1393*cdf0e10cSrcweir     String aLibSubName;
1394*cdf0e10cSrcweir     if( xBasic.Is() && aDocument.isInVBAMode() && XModule().Is() )
1395*cdf0e10cSrcweir     {
1396*cdf0e10cSrcweir         switch( xModule->GetModuleType() )
1397*cdf0e10cSrcweir         {
1398*cdf0e10cSrcweir             case script::ModuleType::DOCUMENT:
1399*cdf0e10cSrcweir             {
1400*cdf0e10cSrcweir                 aLibSubName = String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) );
1401*cdf0e10cSrcweir                 uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
1402*cdf0e10cSrcweir                 if( xLib.is() )
1403*cdf0e10cSrcweir                 {
1404*cdf0e10cSrcweir                     String sObjName;
1405*cdf0e10cSrcweir                     ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
1406*cdf0e10cSrcweir                     if( sObjName.Len() )
1407*cdf0e10cSrcweir                     {
1408*cdf0e10cSrcweir                         aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
1409*cdf0e10cSrcweir                     }
1410*cdf0e10cSrcweir                 }
1411*cdf0e10cSrcweir                 break;
1412*cdf0e10cSrcweir             }
1413*cdf0e10cSrcweir             case script::ModuleType::FORM:
1414*cdf0e10cSrcweir                 aLibSubName = String( IDEResId( RID_STR_USERFORMS ) );
1415*cdf0e10cSrcweir                 break;
1416*cdf0e10cSrcweir             case script::ModuleType::NORMAL:
1417*cdf0e10cSrcweir                 aLibSubName = String( IDEResId( RID_STR_NORMAL_MODULES ) );
1418*cdf0e10cSrcweir                 break;
1419*cdf0e10cSrcweir             case script::ModuleType::CLASS:
1420*cdf0e10cSrcweir                 aLibSubName = String( IDEResId( RID_STR_CLASS_MODULES ) );
1421*cdf0e10cSrcweir                 break;
1422*cdf0e10cSrcweir         }
1423*cdf0e10cSrcweir     }
1424*cdf0e10cSrcweir     return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE );
1425*cdf0e10cSrcweir }
1426*cdf0e10cSrcweir 
1427*cdf0e10cSrcweir void ModulWindow::SetReadOnly( sal_Bool b )
1428*cdf0e10cSrcweir {
1429*cdf0e10cSrcweir 	if ( GetEditView() )
1430*cdf0e10cSrcweir 		GetEditView()->SetReadOnly( b );
1431*cdf0e10cSrcweir }
1432*cdf0e10cSrcweir 
1433*cdf0e10cSrcweir sal_Bool ModulWindow::IsReadOnly()
1434*cdf0e10cSrcweir {
1435*cdf0e10cSrcweir     sal_Bool bReadOnly = sal_False;
1436*cdf0e10cSrcweir 
1437*cdf0e10cSrcweir     if ( GetEditView() )
1438*cdf0e10cSrcweir         bReadOnly = GetEditView()->IsReadOnly();
1439*cdf0e10cSrcweir 
1440*cdf0e10cSrcweir     return bReadOnly;
1441*cdf0e10cSrcweir }
1442*cdf0e10cSrcweir 
1443*cdf0e10cSrcweir sal_Bool ModulWindow::IsPasteAllowed()
1444*cdf0e10cSrcweir {
1445*cdf0e10cSrcweir     sal_Bool bPaste = sal_False;
1446*cdf0e10cSrcweir 
1447*cdf0e10cSrcweir     // get clipboard
1448*cdf0e10cSrcweir 	Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
1449*cdf0e10cSrcweir 	if ( xClipboard.is() )
1450*cdf0e10cSrcweir 	{
1451*cdf0e10cSrcweir 		// get clipboard content
1452*cdf0e10cSrcweir 		const sal_uInt32 nRef = Application::ReleaseSolarMutex();
1453*cdf0e10cSrcweir 		Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
1454*cdf0e10cSrcweir 		Application::AcquireSolarMutex( nRef );
1455*cdf0e10cSrcweir 		if ( xTransf.is() )
1456*cdf0e10cSrcweir 		{
1457*cdf0e10cSrcweir 			datatransfer::DataFlavor aFlavor;
1458*cdf0e10cSrcweir 			SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
1459*cdf0e10cSrcweir             if ( xTransf->isDataFlavorSupported( aFlavor ) )
1460*cdf0e10cSrcweir 			{
1461*cdf0e10cSrcweir                 bPaste = sal_True;
1462*cdf0e10cSrcweir             }
1463*cdf0e10cSrcweir         }
1464*cdf0e10cSrcweir     }
1465*cdf0e10cSrcweir 
1466*cdf0e10cSrcweir     return bPaste;
1467*cdf0e10cSrcweir }
1468*cdf0e10cSrcweir 
1469*cdf0e10cSrcweir ModulWindowLayout::ModulWindowLayout( Window* pParent ) :
1470*cdf0e10cSrcweir 	Window( pParent, WB_CLIPCHILDREN ),
1471*cdf0e10cSrcweir 	aVSplitter( this, WinBits( WB_VSCROLL ) ),
1472*cdf0e10cSrcweir 	aHSplitter( this, WinBits( WB_HSCROLL ) ),
1473*cdf0e10cSrcweir 	aWatchWindow( this ),
1474*cdf0e10cSrcweir 	aStackWindow( this ),
1475*cdf0e10cSrcweir 	bVSplitted(sal_False),
1476*cdf0e10cSrcweir 	bHSplitted(sal_False),
1477*cdf0e10cSrcweir     m_pModulWindow(0),
1478*cdf0e10cSrcweir     m_aImagesNormal(IDEResId(RID_IMGLST_LAYOUT)),
1479*cdf0e10cSrcweir     m_aImagesHighContrast(IDEResId(RID_IMGLST_LAYOUT_HC))
1480*cdf0e10cSrcweir {
1481*cdf0e10cSrcweir     SetBackground(GetSettings().GetStyleSettings().GetWindowColor());
1482*cdf0e10cSrcweir 
1483*cdf0e10cSrcweir 	aVSplitter.SetSplitHdl( LINK( this, ModulWindowLayout, SplitHdl ) );
1484*cdf0e10cSrcweir 	aHSplitter.SetSplitHdl( LINK( this, ModulWindowLayout, SplitHdl ) );
1485*cdf0e10cSrcweir 	aVSplitter.Show();
1486*cdf0e10cSrcweir 	aHSplitter.Show();
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir 	aWatchWindow.Show();
1489*cdf0e10cSrcweir 	aStackWindow.Show();
1490*cdf0e10cSrcweir 
1491*cdf0e10cSrcweir     Color aColor(GetSettings().GetStyleSettings().GetFieldTextColor());
1492*cdf0e10cSrcweir     m_aSyntaxColors[TT_UNKNOWN] = aColor;
1493*cdf0e10cSrcweir     m_aSyntaxColors[TT_WHITESPACE] = aColor;
1494*cdf0e10cSrcweir     m_aSyntaxColors[TT_EOL] = aColor;
1495*cdf0e10cSrcweir     m_aColorConfig.AddListener(this);
1496*cdf0e10cSrcweir     m_aSyntaxColors[TT_IDENTIFIER]
1497*cdf0e10cSrcweir         = Color(m_aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).nColor);
1498*cdf0e10cSrcweir     m_aSyntaxColors[TT_NUMBER]
1499*cdf0e10cSrcweir         = Color(m_aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor);
1500*cdf0e10cSrcweir     m_aSyntaxColors[TT_STRING]
1501*cdf0e10cSrcweir         = Color(m_aColorConfig.GetColorValue(svtools::BASICSTRING).nColor);
1502*cdf0e10cSrcweir     m_aSyntaxColors[TT_COMMENT]
1503*cdf0e10cSrcweir         = Color(m_aColorConfig.GetColorValue(svtools::BASICCOMMENT).nColor);
1504*cdf0e10cSrcweir     m_aSyntaxColors[TT_ERROR]
1505*cdf0e10cSrcweir         = Color(m_aColorConfig.GetColorValue(svtools::BASICERROR).nColor);
1506*cdf0e10cSrcweir     m_aSyntaxColors[TT_OPERATOR]
1507*cdf0e10cSrcweir         = Color(m_aColorConfig.GetColorValue(svtools::BASICOPERATOR).nColor);
1508*cdf0e10cSrcweir     m_aSyntaxColors[TT_KEYWORDS]
1509*cdf0e10cSrcweir         = Color(m_aColorConfig.GetColorValue(svtools::BASICKEYWORD).nColor);
1510*cdf0e10cSrcweir 
1511*cdf0e10cSrcweir 	Font aFont( GetFont() );
1512*cdf0e10cSrcweir 	Size aSz( aFont.GetSize() );
1513*cdf0e10cSrcweir 	aSz.Height() *= 3;
1514*cdf0e10cSrcweir 	aSz.Height() /= 2;
1515*cdf0e10cSrcweir 	aFont.SetSize( aSz );
1516*cdf0e10cSrcweir 	aFont.SetWeight( WEIGHT_BOLD );
1517*cdf0e10cSrcweir     aFont.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor());
1518*cdf0e10cSrcweir 	SetFont( aFont );
1519*cdf0e10cSrcweir }
1520*cdf0e10cSrcweir 
1521*cdf0e10cSrcweir ModulWindowLayout::~ModulWindowLayout()
1522*cdf0e10cSrcweir {
1523*cdf0e10cSrcweir     m_aColorConfig.RemoveListener(this);
1524*cdf0e10cSrcweir }
1525*cdf0e10cSrcweir 
1526*cdf0e10cSrcweir void __EXPORT ModulWindowLayout::Resize()
1527*cdf0e10cSrcweir {
1528*cdf0e10cSrcweir 	// ScrollBars, etc. passiert in BasicIDEShell:Adjust...
1529*cdf0e10cSrcweir 	ArrangeWindows();
1530*cdf0e10cSrcweir //	Invalidate();
1531*cdf0e10cSrcweir }
1532*cdf0e10cSrcweir 
1533*cdf0e10cSrcweir void __EXPORT ModulWindowLayout::Paint( const Rectangle& )
1534*cdf0e10cSrcweir {
1535*cdf0e10cSrcweir 	DrawText( Point(), String( IDEResId( RID_STR_NOMODULE ) ) );
1536*cdf0e10cSrcweir }
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir void ModulWindowLayout::ArrangeWindows()
1540*cdf0e10cSrcweir {
1541*cdf0e10cSrcweir 	Size aSz = GetOutputSizePixel();
1542*cdf0e10cSrcweir 
1543*cdf0e10cSrcweir 	// prueffen, ob der Splitter in einem gueltigen Bereich liegt...
1544*cdf0e10cSrcweir 	long nMinPos = SPLIT_MARGIN;
1545*cdf0e10cSrcweir 	long nMaxPos = aSz.Height() - SPLIT_MARGIN;
1546*cdf0e10cSrcweir 
1547*cdf0e10cSrcweir 	long nVSplitPos = aVSplitter.GetSplitPosPixel();
1548*cdf0e10cSrcweir 	long nHSplitPos = aHSplitter.GetSplitPosPixel();
1549*cdf0e10cSrcweir 	if ( !bVSplitted )
1550*cdf0e10cSrcweir 	{
1551*cdf0e10cSrcweir 		// Wenn noch nie gesplitted wurde, Verhaeltniss = 3 : 4
1552*cdf0e10cSrcweir 		nVSplitPos = aSz.Height() * 3 / 4;
1553*cdf0e10cSrcweir 		aVSplitter.SetSplitPosPixel( nVSplitPos );
1554*cdf0e10cSrcweir 	}
1555*cdf0e10cSrcweir 	if ( !bHSplitted )
1556*cdf0e10cSrcweir 	{
1557*cdf0e10cSrcweir 		// Wenn noch nie gesplitted wurde, Verhaeltniss = 2 : 3
1558*cdf0e10cSrcweir 		nHSplitPos = aSz.Width() * 2 / 3;
1559*cdf0e10cSrcweir 		aHSplitter.SetSplitPosPixel( nHSplitPos );
1560*cdf0e10cSrcweir 	}
1561*cdf0e10cSrcweir 	if ( ( nVSplitPos < nMinPos ) || ( nVSplitPos > nMaxPos ) )
1562*cdf0e10cSrcweir 		nVSplitPos = ( nVSplitPos < nMinPos ) ? 0 : ( aSz.Height() - SPLIT_HEIGHT );
1563*cdf0e10cSrcweir 
1564*cdf0e10cSrcweir 	Size aXEWSz;
1565*cdf0e10cSrcweir 	aXEWSz.Width() = aSz.Width();
1566*cdf0e10cSrcweir 	aXEWSz.Height() = nVSplitPos + 1;
1567*cdf0e10cSrcweir 	if ( m_pModulWindow )
1568*cdf0e10cSrcweir 	{
1569*cdf0e10cSrcweir 		DBG_CHKOBJ( m_pModulWindow, ModulWindow, 0 );
1570*cdf0e10cSrcweir 		m_pModulWindow->SetPosSizePixel( Point( 0, 0 ), aXEWSz );
1571*cdf0e10cSrcweir 	}
1572*cdf0e10cSrcweir 
1573*cdf0e10cSrcweir 	aVSplitter.SetDragRectPixel( Rectangle( Point( 0, 0 ), Size( aSz.Width(), aSz.Height() ) ) );
1574*cdf0e10cSrcweir 	aVSplitter.SetPosPixel( Point( 0, nVSplitPos ) );
1575*cdf0e10cSrcweir 	aVSplitter.SetSizePixel( Size( aSz.Width(), SPLIT_HEIGHT ) );
1576*cdf0e10cSrcweir 
1577*cdf0e10cSrcweir 	aHSplitter.SetDragRectPixel( Rectangle( Point( 0, nVSplitPos+SPLIT_HEIGHT ), Size( aSz.Width(), aSz.Height() - nVSplitPos - SPLIT_HEIGHT ) ) );
1578*cdf0e10cSrcweir 	aHSplitter.SetPosPixel( Point( nHSplitPos, nVSplitPos ) );
1579*cdf0e10cSrcweir 	aHSplitter.SetSizePixel( Size( SPLIT_HEIGHT, aSz.Height() - nVSplitPos ) );
1580*cdf0e10cSrcweir 
1581*cdf0e10cSrcweir 	Size aWWSz;
1582*cdf0e10cSrcweir 	Point aWWPos( 0, nVSplitPos+SPLIT_HEIGHT );
1583*cdf0e10cSrcweir 	aWWSz.Width() = nHSplitPos;
1584*cdf0e10cSrcweir 	aWWSz.Height() = aSz.Height() - aWWPos.Y();
1585*cdf0e10cSrcweir 	if ( !aWatchWindow.IsFloatingMode() )
1586*cdf0e10cSrcweir 		aWatchWindow.SetPosSizePixel( aWWPos, aWWSz );
1587*cdf0e10cSrcweir 
1588*cdf0e10cSrcweir 	Size aSWSz;
1589*cdf0e10cSrcweir 	Point aSWPos( nHSplitPos+SPLIT_HEIGHT, nVSplitPos+SPLIT_HEIGHT );
1590*cdf0e10cSrcweir 	aSWSz.Width() = aSz.Width() - aSWPos.X();
1591*cdf0e10cSrcweir 	aSWSz.Height() = aSz.Height() - aSWPos.Y();
1592*cdf0e10cSrcweir 	if ( !aStackWindow.IsFloatingMode() )
1593*cdf0e10cSrcweir 		aStackWindow.SetPosSizePixel( aSWPos, aSWSz );
1594*cdf0e10cSrcweir 
1595*cdf0e10cSrcweir     if ( aStackWindow.IsFloatingMode() && aWatchWindow.IsFloatingMode() )
1596*cdf0e10cSrcweir 		aHSplitter.Hide();
1597*cdf0e10cSrcweir 	else
1598*cdf0e10cSrcweir 		aHSplitter.Show();
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir 	long nHDoubleClickSplitPosX = aSz.Width()-aHSplitter.GetSizePixel().Width();
1601*cdf0e10cSrcweir 	if ( aHSplitter.GetSplitPosPixel() < nHDoubleClickSplitPosX )
1602*cdf0e10cSrcweir 		aHSplitter.SetLastSplitPosPixel( nHDoubleClickSplitPosX );
1603*cdf0e10cSrcweir 
1604*cdf0e10cSrcweir 
1605*cdf0e10cSrcweir 	long nHDoubleClickSplitPosY = aSz.Height()-aVSplitter.GetSizePixel().Height();
1606*cdf0e10cSrcweir 	if ( aVSplitter.GetSplitPosPixel() < nHDoubleClickSplitPosY )
1607*cdf0e10cSrcweir 		aVSplitter.SetLastSplitPosPixel( nHDoubleClickSplitPosY );
1608*cdf0e10cSrcweir }
1609*cdf0e10cSrcweir 
1610*cdf0e10cSrcweir IMPL_LINK( ModulWindowLayout, SplitHdl, Splitter *, pSplitter )
1611*cdf0e10cSrcweir {
1612*cdf0e10cSrcweir 	if ( pSplitter == &aVSplitter )
1613*cdf0e10cSrcweir 		bVSplitted = sal_True;
1614*cdf0e10cSrcweir 	else
1615*cdf0e10cSrcweir 		bHSplitted = sal_True;
1616*cdf0e10cSrcweir 
1617*cdf0e10cSrcweir 	ArrangeWindows();
1618*cdf0e10cSrcweir 	return 0;
1619*cdf0e10cSrcweir }
1620*cdf0e10cSrcweir 
1621*cdf0e10cSrcweir sal_Bool ModulWindowLayout::IsToBeDocked( DockingWindow* pDockingWindow, const Point& rPos, Rectangle& rRect )
1622*cdf0e10cSrcweir {
1623*cdf0e10cSrcweir 	// prueffen, ob als Dock oder als Child:
1624*cdf0e10cSrcweir 	// TRUE:	Floating
1625*cdf0e10cSrcweir 	// FALSE:	Child
1626*cdf0e10cSrcweir 	Point aPosInMe = ScreenToOutputPixel( rPos );
1627*cdf0e10cSrcweir 	Size aSz = GetOutputSizePixel();
1628*cdf0e10cSrcweir 	if ( ( aPosInMe.X() > 0 ) && ( aPosInMe.X() < aSz.Width() ) &&
1629*cdf0e10cSrcweir 		 ( aPosInMe.Y() > 0 ) && ( aPosInMe.Y() < aSz.Height() ) )
1630*cdf0e10cSrcweir 	{
1631*cdf0e10cSrcweir 		long nVSplitPos = aVSplitter.GetSplitPosPixel();
1632*cdf0e10cSrcweir 		long nHSplitPos = aHSplitter.GetSplitPosPixel();
1633*cdf0e10cSrcweir 		if ( pDockingWindow == &aWatchWindow )
1634*cdf0e10cSrcweir 		{
1635*cdf0e10cSrcweir 			if ( ( aPosInMe.Y() > nVSplitPos ) && ( aPosInMe.X() < nHSplitPos ) )
1636*cdf0e10cSrcweir 			{
1637*cdf0e10cSrcweir 				rRect.SetSize( Size( nHSplitPos, aSz.Height() - nVSplitPos ) );
1638*cdf0e10cSrcweir 				rRect.SetPos( OutputToScreenPixel( Point( 0, nVSplitPos ) ) );
1639*cdf0e10cSrcweir 				return sal_True;
1640*cdf0e10cSrcweir 			}
1641*cdf0e10cSrcweir 		}
1642*cdf0e10cSrcweir 		if ( pDockingWindow == &aStackWindow )
1643*cdf0e10cSrcweir 		{
1644*cdf0e10cSrcweir 			if ( ( aPosInMe.Y() > nVSplitPos ) && ( aPosInMe.X() > nHSplitPos ) )
1645*cdf0e10cSrcweir 			{
1646*cdf0e10cSrcweir 				rRect.SetSize( Size( aSz.Width() - nHSplitPos, aSz.Height() - nVSplitPos ) );
1647*cdf0e10cSrcweir 				rRect.SetPos( OutputToScreenPixel( Point( nHSplitPos, nVSplitPos ) ) );
1648*cdf0e10cSrcweir 				return sal_True;
1649*cdf0e10cSrcweir 			}
1650*cdf0e10cSrcweir 		}
1651*cdf0e10cSrcweir 	}
1652*cdf0e10cSrcweir 	return sal_False;
1653*cdf0e10cSrcweir }
1654*cdf0e10cSrcweir 
1655*cdf0e10cSrcweir void ModulWindowLayout::DockaWindow( DockingWindow* pDockingWindow )
1656*cdf0e10cSrcweir {
1657*cdf0e10cSrcweir 	if ( pDockingWindow == &aWatchWindow )
1658*cdf0e10cSrcweir 	{
1659*cdf0e10cSrcweir 		// evtl. Sonderbehandlung...
1660*cdf0e10cSrcweir 		ArrangeWindows();
1661*cdf0e10cSrcweir 	}
1662*cdf0e10cSrcweir 	else if ( pDockingWindow == &aStackWindow )
1663*cdf0e10cSrcweir 	{
1664*cdf0e10cSrcweir 		// evtl. Sonderbehandlung...
1665*cdf0e10cSrcweir 		ArrangeWindows();
1666*cdf0e10cSrcweir 	}
1667*cdf0e10cSrcweir #ifdef DBG_UTIL
1668*cdf0e10cSrcweir 	else
1669*cdf0e10cSrcweir 		DBG_ERROR( "Wer will sich denn hier andocken ?" );
1670*cdf0e10cSrcweir #endif
1671*cdf0e10cSrcweir }
1672*cdf0e10cSrcweir 
1673*cdf0e10cSrcweir void ModulWindowLayout::SetModulWindow( ModulWindow* pModWin )
1674*cdf0e10cSrcweir {
1675*cdf0e10cSrcweir     m_pModulWindow = pModWin;
1676*cdf0e10cSrcweir 	ArrangeWindows();
1677*cdf0e10cSrcweir }
1678*cdf0e10cSrcweir 
1679*cdf0e10cSrcweir // virtual
1680*cdf0e10cSrcweir void ModulWindowLayout::DataChanged(DataChangedEvent const & rDCEvt)
1681*cdf0e10cSrcweir {
1682*cdf0e10cSrcweir     Window::DataChanged(rDCEvt);
1683*cdf0e10cSrcweir     if (rDCEvt.GetType() == DATACHANGED_SETTINGS
1684*cdf0e10cSrcweir         && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
1685*cdf0e10cSrcweir     {
1686*cdf0e10cSrcweir         bool bInvalidate = false;
1687*cdf0e10cSrcweir         Color aColor(GetSettings().GetStyleSettings().GetWindowColor());
1688*cdf0e10cSrcweir         if (aColor
1689*cdf0e10cSrcweir             != rDCEvt.GetOldSettings()->GetStyleSettings().GetWindowColor())
1690*cdf0e10cSrcweir         {
1691*cdf0e10cSrcweir             SetBackground(Wallpaper(aColor));
1692*cdf0e10cSrcweir             bInvalidate = true;
1693*cdf0e10cSrcweir         }
1694*cdf0e10cSrcweir         aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
1695*cdf0e10cSrcweir         if (aColor != rDCEvt.GetOldSettings()->
1696*cdf0e10cSrcweir             GetStyleSettings().GetWindowTextColor())
1697*cdf0e10cSrcweir         {
1698*cdf0e10cSrcweir             Font aFont(GetFont());
1699*cdf0e10cSrcweir             aFont.SetColor(aColor);
1700*cdf0e10cSrcweir             SetFont(aFont);
1701*cdf0e10cSrcweir             bInvalidate = true;
1702*cdf0e10cSrcweir         }
1703*cdf0e10cSrcweir         if (bInvalidate)
1704*cdf0e10cSrcweir             Invalidate();
1705*cdf0e10cSrcweir         aColor = GetSettings().GetStyleSettings().GetFieldTextColor();
1706*cdf0e10cSrcweir         if (aColor != m_aSyntaxColors[TT_UNKNOWN])
1707*cdf0e10cSrcweir         {
1708*cdf0e10cSrcweir             m_aSyntaxColors[TT_UNKNOWN] = aColor;
1709*cdf0e10cSrcweir             m_aSyntaxColors[TT_WHITESPACE] = aColor;
1710*cdf0e10cSrcweir             m_aSyntaxColors[TT_EOL] = aColor;
1711*cdf0e10cSrcweir             updateSyntaxHighlighting();
1712*cdf0e10cSrcweir         }
1713*cdf0e10cSrcweir     }
1714*cdf0e10cSrcweir }
1715*cdf0e10cSrcweir 
1716*cdf0e10cSrcweir // virtual
1717*cdf0e10cSrcweir void ModulWindowLayout::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
1718*cdf0e10cSrcweir {
1719*cdf0e10cSrcweir     {
1720*cdf0e10cSrcweir         Color aColor(m_aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).
1721*cdf0e10cSrcweir                      nColor);
1722*cdf0e10cSrcweir         bool bChanged = aColor != m_aSyntaxColors[TT_IDENTIFIER];
1723*cdf0e10cSrcweir         m_aSyntaxColors[TT_IDENTIFIER] = aColor;
1724*cdf0e10cSrcweir         aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor);
1725*cdf0e10cSrcweir 	if (bChanged || aColor != m_aSyntaxColors[TT_NUMBER])
1726*cdf0e10cSrcweir             bChanged = true;
1727*cdf0e10cSrcweir         m_aSyntaxColors[TT_NUMBER] = aColor;
1728*cdf0e10cSrcweir         aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICSTRING).nColor);
1729*cdf0e10cSrcweir         if (bChanged || aColor != m_aSyntaxColors[TT_STRING])
1730*cdf0e10cSrcweir             bChanged = true;
1731*cdf0e10cSrcweir         m_aSyntaxColors[TT_STRING] = aColor;
1732*cdf0e10cSrcweir         aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICCOMMENT).
1733*cdf0e10cSrcweir                        nColor);
1734*cdf0e10cSrcweir         if (bChanged || aColor != m_aSyntaxColors[TT_COMMENT])
1735*cdf0e10cSrcweir             bChanged = true;
1736*cdf0e10cSrcweir         m_aSyntaxColors[TT_COMMENT] = aColor;
1737*cdf0e10cSrcweir         aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICERROR).nColor);
1738*cdf0e10cSrcweir         if (bChanged || aColor != m_aSyntaxColors[TT_ERROR])
1739*cdf0e10cSrcweir             bChanged = true;
1740*cdf0e10cSrcweir         m_aSyntaxColors[TT_ERROR] = aColor;
1741*cdf0e10cSrcweir         aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICOPERATOR).
1742*cdf0e10cSrcweir                        nColor);
1743*cdf0e10cSrcweir         if (bChanged || aColor != m_aSyntaxColors[TT_OPERATOR])
1744*cdf0e10cSrcweir             bChanged = true;
1745*cdf0e10cSrcweir         m_aSyntaxColors[TT_OPERATOR] = aColor;
1746*cdf0e10cSrcweir         aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICKEYWORD).
1747*cdf0e10cSrcweir                        nColor);
1748*cdf0e10cSrcweir         if (bChanged || aColor != m_aSyntaxColors[TT_KEYWORDS])
1749*cdf0e10cSrcweir             bChanged = true;
1750*cdf0e10cSrcweir         m_aSyntaxColors[TT_KEYWORDS] = aColor;
1751*cdf0e10cSrcweir         if (bChanged)
1752*cdf0e10cSrcweir             updateSyntaxHighlighting();
1753*cdf0e10cSrcweir     }
1754*cdf0e10cSrcweir }
1755*cdf0e10cSrcweir 
1756*cdf0e10cSrcweir void ModulWindowLayout::updateSyntaxHighlighting()
1757*cdf0e10cSrcweir {
1758*cdf0e10cSrcweir     if (m_pModulWindow != 0)
1759*cdf0e10cSrcweir     {
1760*cdf0e10cSrcweir         EditorWindow & rEditor = m_pModulWindow->GetEditorWindow();
1761*cdf0e10cSrcweir         sal_uLong nCount = rEditor.GetEditEngine()->GetParagraphCount();
1762*cdf0e10cSrcweir         for (sal_uLong i = 0; i < nCount; ++i)
1763*cdf0e10cSrcweir             rEditor.DoDelayedSyntaxHighlight(i);
1764*cdf0e10cSrcweir     }
1765*cdf0e10cSrcweir }
1766*cdf0e10cSrcweir 
1767*cdf0e10cSrcweir Image ModulWindowLayout::getImage(sal_uInt16 nId, bool bHighContrastMode) const
1768*cdf0e10cSrcweir {
1769*cdf0e10cSrcweir     return (bHighContrastMode ? m_aImagesHighContrast : m_aImagesNormal).
1770*cdf0e10cSrcweir         GetImage(nId);
1771*cdf0e10cSrcweir }
1772