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