1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: baside2.cxx,v $
10 * $Revision: 1.46.2.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_basctl.hxx"
35 #include <ide_pch.hxx>
38 #include <svtools/texteng.hxx>
39 #include <svtools/textview.hxx>
40 #include <svtools/xtextedt.hxx>
41 #include <basic/sbx.hxx>
42 #include <comphelper/processfactory.hxx>
43 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
44 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
45 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
46 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
47 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
48 #ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_
49 #include <com/sun/star/script/XLibraryContainer2.hpp>
51 #include <com/sun/star/document/MacroExecMode.hpp>
52 #include <com/sun/star/script/ModuleType.hpp>
53 #include <toolkit/helper/vclunohelper.hxx>
54 #include <sfx2/docfile.hxx>
55 #include <basic/basrdll.hxx>
58 #include <baside2.hrc>
59 #include <baside2.hxx>
61 #include <iderdll.hxx>
62 #include <iderdll2.hxx>
67 #include <svx/srchdlg.hxx>
69 #include <vcl/sound.hxx>
71 //#ifndef _TXTCMP_HXX //autogen
72 //#include <svtools/txtcmp.hxx>
75 #include <unotools/textsearch.hxx>
76 #include <tools/diagnose_ex.h>
78 using namespace ::com::sun::star
;
79 using namespace ::com::sun::star::uno
;
82 #define SPLIT_MARGIN 5
83 #define SPLIT_HEIGHT 2
91 #define APPWAIT_START 100
93 #define VALIDWINDOW 0x1234
95 #if defined(OW) || defined(MTF)
96 #define FILTERMASK_ALL "*"
98 #define FILTERMASK_ALL ""
100 #define FILTERMASK_ALL "*.*"
103 using namespace ::com::sun::star
;
104 using namespace ::com::sun::star::uno
;
105 using namespace ::com::sun::star::ui::dialogs
;
107 using namespace comphelper
;
110 DBG_NAME( ModulWindow
)
112 TYPEINIT1( ModulWindow
, IDEBaseWindow
);
114 void lcl_getObjectName( const uno::Reference
< container::XNameContainer
>& rLib
, const String
& rModName
, String
& rObjName
);
116 void lcl_PrintHeader( Printer
* pPrinter
, USHORT nPages
, USHORT nCurPage
, const String
& rTitle
)
118 short nLeftMargin
= LMARGPRN
;
119 Size aSz
= pPrinter
->GetOutputSize();
120 short nBorder
= BORDERPRN
;
122 const Color
aOldLineColor( pPrinter
->GetLineColor() );
123 const Color
aOldFillColor( pPrinter
->GetFillColor() );
124 const Font
aOldFont( pPrinter
->GetFont() );
126 pPrinter
->SetLineColor( Color( COL_BLACK
) );
127 pPrinter
->SetFillColor();
129 Font
aFont( aOldFont
);
130 aFont
.SetWeight( WEIGHT_BOLD
);
131 aFont
.SetAlign( ALIGN_BOTTOM
);
132 pPrinter
->SetFont( aFont
);
134 long nFontHeight
= pPrinter
->GetTextHeight();
136 // 1.Border => Strich, 2+3 Border = Freiraum.
137 long nYTop
= TMARGPRN
-3*nBorder
-nFontHeight
;
139 long nXLeft
= nLeftMargin
-nBorder
;
140 long nXRight
= aSz
.Width()-RMARGPRN
+nBorder
;
142 pPrinter
->DrawRect( Rectangle(
143 Point( nXLeft
, nYTop
),
144 Size( nXRight
-nXLeft
, aSz
.Height() - nYTop
- BMARGPRN
+ nBorder
) ) );
147 long nY
= TMARGPRN
-2*nBorder
;
148 Point
aPos( nLeftMargin
, nY
);
149 pPrinter
->DrawText( aPos
, rTitle
);
152 aFont
.SetWeight( WEIGHT_NORMAL
);
153 pPrinter
->SetFont( aFont
);
154 String
aPageStr( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
155 aPageStr
+= String( IDEResId( RID_STR_PAGE
) );
157 aPageStr
+= String::CreateFromInt32( nCurPage
);
159 aPos
.X() += pPrinter
->GetTextWidth( rTitle
);
160 pPrinter
->DrawText( aPos
, aPageStr
);
164 nY
= TMARGPRN
-nBorder
;
166 pPrinter
->DrawLine( Point( nXLeft
, nY
), Point( nXRight
, nY
) );
168 pPrinter
->SetFont( aOldFont
);
169 pPrinter
->SetFillColor( aOldFillColor
);
170 pPrinter
->SetLineColor( aOldLineColor
);
173 void lcl_ConvertTabsToSpaces( String
& rLine
)
178 USHORT nMax
= rLine
.Len();
179 while ( nPos
< nMax
)
181 if ( rLine
.GetChar( nPos
) == '\t' )
183 // Nicht 4 Blanks, sondern an 4er TabPos:
185 aBlanker
.Fill( ( 4 - ( nPos
% 4 ) ), ' ' );
186 rLine
.Erase( nPos
, 1 );
187 rLine
.Insert( aBlanker
, nPos
);
190 nPos
++; // Nicht optimal, falls Tab, aber auch nicht verkehrt...
196 ModulWindow::ModulWindow( ModulWindowLayout
* pParent
, const ScriptDocument
& rDocument
, String aLibName
,
197 String aName
, ::rtl::OUString
& aModule
)
198 :IDEBaseWindow( pParent
, rDocument
, aLibName
, aName
)
199 ,aXEditorWindow( this )
200 ,m_aModule( aModule
)
202 DBG_CTOR( ModulWindow
, 0 );
203 nValid
= VALIDWINDOW
;
205 aXEditorWindow
.Show();
207 BasicManager
* pBasMgr
= rDocument
.getBasicManager();
210 StarBASIC
* pBasic
= pBasMgr
->GetLib( aLibName
);
214 xModule
= (SbModule
*)pBasic
->FindModule( aName
);
222 __EXPORT
ModulWindow::~ModulWindow()
224 DBG_DTOR( ModulWindow
, 0 );
231 void __EXPORT
ModulWindow::GetFocus()
233 if ( nValid
!= VALIDWINDOW
)
235 DBG_CHKTHIS( ModulWindow
, 0 );
236 aXEditorWindow
.GetEdtWindow().GrabFocus();
237 // Basisklasse nicht rufen, weil Focus jetzt woanders...
240 void ModulWindow::DoInit()
242 DBG_CHKTHIS( ModulWindow
, 0 );
243 // Wird beim Umschalten der Fenster gerufen...
244 if ( GetVScrollBar() )
245 GetVScrollBar()->Hide();
246 GetHScrollBar()->Show();
247 // GetEditorWindow().SetScrollBarRanges();
248 GetEditorWindow().InitScrollBars();
249 // GetEditorWindow().GrabFocus();
253 void __EXPORT
ModulWindow::Paint( const Rectangle
& )
257 void __EXPORT
ModulWindow::Resize()
259 aXEditorWindow
.SetPosSizePixel( Point( 0, 0 ),
260 Size( GetOutputSizePixel() ) );
264 // "Import" von baside4.cxx
265 void CreateEngineForBasic( StarBASIC
* pBasic
);
267 void ModulWindow::CheckCompileBasic()
269 DBG_CHKTHIS( ModulWindow
, 0 );
273 // Zur Laufzeit wird niemals compiliert!
274 BOOL bRunning
= StarBASIC::IsRunning();
275 BOOL bModified
= ( !xModule
->IsCompiled() ||
276 ( GetEditEngine() && GetEditEngine()->IsModified() ) );
278 if ( !bRunning
&& bModified
)
282 BasicIDEShell
* pIDEShell
= IDE_DLL()->GetShell();
283 pIDEShell
->GetViewFrame()->GetWindow().EnterWait();
287 AssertValidEditEngine();
288 GetEditorWindow().SetSourceInBasic( FALSE
);
291 BOOL bWasModified
= GetBasic()->IsModified();
293 bDone
= GetBasic()->Compile( xModule
);
295 GetBasic()->SetModified( FALSE
);
299 GetBreakPoints().SetBreakPointsInBasic( xModule
);
302 pIDEShell
->GetViewFrame()->GetWindow().LeaveWait();
304 aStatus
.bError
= !bDone
;
305 aStatus
.bIsRunning
= FALSE
;
310 BOOL
ModulWindow::BasicExecute()
312 DBG_CHKTHIS( ModulWindow
, 0 );
314 // #116444# check security settings before macro execution
315 ScriptDocument
aDocument( GetDocument() );
316 if ( aDocument
.isDocument() )
318 if ( !aDocument
.allowMacros() )
320 WarningBox( this, WB_OK
, String( IDEResId( RID_STR_CANNOTRUNMACRO
) ) ).Execute();
327 if ( xModule
.Is() && xModule
->IsCompiled() && !aStatus
.bError
)
329 if ( GetBreakPoints().Count() )
330 aStatus
.nBasicFlags
= aStatus
.nBasicFlags
| SbDEBUG_BREAK
;
332 if ( !aStatus
.bIsRunning
)
334 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
335 AddStatus( BASWIN_RUNNINGBASIC
);
336 USHORT nStart
, nEnd
, nCurMethodStart
= 0;
337 TextSelection aSel
= GetEditView()->GetSelection();
338 nCurMethodStart
= ( aSel
.GetStart().GetPara() + 1 );
339 SbMethod
* pMethod
= 0;
340 // erstes Macro, sonst blind "Main" (ExtSearch?)
341 for ( USHORT nMacro
= 0; nMacro
< xModule
->GetMethods()->Count(); nMacro
++ )
343 SbMethod
* pM
= (SbMethod
*)xModule
->GetMethods()->Get( nMacro
);
344 DBG_ASSERT( pM
, "Method?" );
345 pM
->GetLineRange( nStart
, nEnd
);
346 if ( nCurMethodStart
>= nStart
&& nCurMethodStart
<= nEnd
)
353 return ( BasicIDE::ChooseMacro( uno::Reference
< frame::XModel
>(), FALSE
, rtl::OUString() ).getLength() > 0 ) ? TRUE
: FALSE
;
357 pMethod
->SetDebugFlags( aStatus
.nBasicFlags
);
358 BasicDLL::SetDebugMode( TRUE
);
359 BasicIDE::RunMethod( pMethod
);
360 BasicDLL::SetDebugMode( FALSE
);
361 // Falls waehrend Interactive=FALSE abgebrochen
362 BasicDLL::EnableBreak( TRUE
);
364 ClearStatus( BASWIN_RUNNINGBASIC
);
367 aStatus
.bIsRunning
= FALSE
; // Abbruch von Reschedule()
370 BOOL bDone
= !aStatus
.bError
;
375 BOOL
ModulWindow::CompileBasic()
377 DBG_CHKTHIS( ModulWindow
, 0 );
380 BOOL bIsCompiled
= FALSE
;
382 bIsCompiled
= xModule
->IsCompiled();
387 BOOL
ModulWindow::BasicRun()
389 DBG_CHKTHIS( ModulWindow
, 0 );
391 aStatus
.nBasicFlags
= 0;
392 BOOL bDone
= BasicExecute();
396 BOOL
ModulWindow::BasicStepOver()
398 DBG_CHKTHIS( ModulWindow
, 0 );
399 aStatus
.nBasicFlags
= SbDEBUG_STEPINTO
| SbDEBUG_STEPOVER
;
400 BOOL bDone
= BasicExecute();
405 BOOL
ModulWindow::BasicStepInto()
407 DBG_CHKTHIS( ModulWindow
, 0 );
409 aStatus
.nBasicFlags
= SbDEBUG_STEPINTO
;
410 BOOL bDone
= BasicExecute();
414 BOOL
ModulWindow::BasicStepOut()
416 DBG_CHKTHIS( ModulWindow
, 0 );
418 aStatus
.nBasicFlags
= SbDEBUG_STEPOUT
;
419 BOOL bDone
= BasicExecute();
425 void ModulWindow::BasicStop()
427 DBG_CHKTHIS( ModulWindow
, 0 );
430 aStatus
.bIsRunning
= FALSE
;
433 BOOL
ModulWindow::LoadBasic()
435 DBG_CHKTHIS( ModulWindow
, 0 );
438 Reference
< lang::XMultiServiceFactory
> xMSF( ::comphelper::getProcessServiceFactory() );
439 Reference
< XFilePicker
> xFP
;
442 Sequence
<Any
> aServiceType(1);
443 aServiceType
[0] <<= TemplateDescription::FILEOPEN_SIMPLE
;
444 xFP
= Reference
< XFilePicker
>( xMSF
->createInstanceWithArguments(
445 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType
), UNO_QUERY
);
448 if ( aCurPath
.Len() )
449 xFP
->setDisplayDirectory ( aCurPath
);
451 //xFP->setTitle( String( IDEResId( RID_STR_OPEN ) ) );
453 Reference
< XFilterManager
> xFltMgr(xFP
, UNO_QUERY
);
454 xFltMgr
->appendFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.bas" ) ) );
455 xFltMgr
->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES
) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL
) ) );
456 xFltMgr
->setCurrentFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
458 if( xFP
->execute() == RET_OK
)
460 Sequence
< ::rtl::OUString
> aPaths
= xFP
->getFiles();
461 aCurPath
= aPaths
[0];
462 SfxMedium
aMedium( aCurPath
, STREAM_READ
| STREAM_SHARE_DENYWRITE
| STREAM_NOCREATE
, TRUE
);
463 SvStream
* pStream
= aMedium
.GetInStream();
466 AssertValidEditEngine();
467 ULONG nLines
= CalcLineCount( *pStream
);
468 // nLines*4: ReadText/Formatting/Highlighting/Formatting
469 GetEditorWindow().CreateProgress( String( IDEResId( RID_STR_GENERATESOURCE
) ), nLines
*4 );
470 GetEditEngine()->SetUpdateMode( FALSE
);
471 GetEditView()->Read( *pStream
);
472 GetEditEngine()->SetUpdateMode( TRUE
);
473 GetEditorWindow().Update(); // Es wurde bei UpdateMode = TRUE nur Invalidiert
474 GetEditorWindow().ForceSyntaxTimeout();
475 GetEditorWindow().DestroyProgress();
476 ULONG nError
= aMedium
.GetError();
478 ErrorHandler::HandleError( nError
);
483 ErrorBox( this, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_COULDNTREAD
) ) ).Execute();
489 BOOL
ModulWindow::SaveBasicSource()
491 DBG_CHKTHIS( ModulWindow
, 0 );
494 Reference
< lang::XMultiServiceFactory
> xMSF( ::comphelper::getProcessServiceFactory() );
495 Reference
< XFilePicker
> xFP
;
498 Sequence
<Any
> aServiceType(1);
499 aServiceType
[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD
;
500 xFP
= Reference
< XFilePicker
>( xMSF
->createInstanceWithArguments(
501 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType
), UNO_QUERY
);
504 Reference
< XFilePickerControlAccess
> xFPControl(xFP
, UNO_QUERY
);
505 xFPControl
->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
, sal_False
);
507 aValue
<<= (sal_Bool
) sal_True
;
508 xFPControl
->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
, 0, aValue
);
510 if ( aCurPath
.Len() )
511 xFP
->setDisplayDirectory ( aCurPath
);
513 //xFP->setTitle( String( IDEResId( RID_STR_SAVE ) ) );
515 Reference
< XFilterManager
> xFltMgr(xFP
, UNO_QUERY
);
516 xFltMgr
->appendFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.bas" ) ) );
517 xFltMgr
->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES
) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL
) ) );
518 xFltMgr
->setCurrentFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
520 if( xFP
->execute() == RET_OK
)
522 Sequence
< ::rtl::OUString
> aPaths
= xFP
->getFiles();
523 aCurPath
= aPaths
[0];
524 SfxMedium
aMedium( aCurPath
, STREAM_WRITE
| STREAM_SHARE_DENYWRITE
| STREAM_TRUNC
, TRUE
, FALSE
);
525 SvStream
* pStream
= aMedium
.GetOutStream();
529 AssertValidEditEngine();
530 GetEditEngine()->Write( *pStream
);
533 ULONG nError
= aMedium
.GetError();
535 ErrorHandler::HandleError( nError
);
540 ErrorBox( this, WB_OK
| WB_DEF_OK
, String( IDEResId( RID_STR_COULDNTWRITE
) ) ).Execute();
546 BOOL
implImportDialog( Window
* pWin
, const String
& rCurPath
, const ScriptDocument
& rDocument
, const String
& aLibName
);
548 BOOL
ModulWindow::ImportDialog()
550 const ScriptDocument
& rDocument
= GetDocument();
551 String aLibName
= GetLibName();
552 BOOL bRet
= implImportDialog( this, aCurPath
, rDocument
, aLibName
);
556 BOOL
ModulWindow::ToggleBreakPoint( ULONG nLine
)
558 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
560 BOOL bNewBreakPoint
= FALSE
;
565 if ( aStatus
.bError
)
571 BreakPoint
* pBrk
= GetBreakPoints().FindBreakPoint( nLine
);
572 if ( pBrk
) // entfernen
574 xModule
->ClearBP( (USHORT
)nLine
);
575 delete GetBreakPoints().Remove( pBrk
);
577 else // einen erzeugen
579 if ( xModule
->SetBP( (USHORT
)nLine
) )
581 GetBreakPoints().InsertSorted( new BreakPoint( nLine
) );
582 bNewBreakPoint
= TRUE
;
583 if ( StarBASIC::IsRunning() )
585 for ( USHORT nMethod
= 0; nMethod
< xModule
->GetMethods()->Count(); nMethod
++ )
587 SbMethod
* pMethod
= (SbMethod
*)xModule
->GetMethods()->Get( nMethod
);
588 DBG_ASSERT( pMethod
, "Methode nicht gefunden! (NULL)" );
589 pMethod
->SetDebugFlags( pMethod
->GetDebugFlags() | SbDEBUG_BREAK
);
594 if ( !bNewBreakPoint
)
599 return bNewBreakPoint
;
602 void ModulWindow::UpdateBreakPoint( const BreakPoint
& rBrk
)
604 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
611 xModule
->SetBP( (USHORT
)rBrk
.nLine
);
613 xModule
->ClearBP( (USHORT
)rBrk
.nLine
);
618 BOOL
ModulWindow::BasicToggleBreakPoint()
620 DBG_CHKTHIS( ModulWindow
, 0 );
621 AssertValidEditEngine();
623 TextSelection aSel
= GetEditView()->GetSelection();
624 aSel
.GetStart().GetPara()++; // Basic-Zeilen beginnen bei 1!
625 aSel
.GetEnd().GetPara()++;
627 BOOL bNewBreakPoint
= FALSE
;
629 for ( ULONG nLine
= aSel
.GetStart().GetPara(); nLine
<= aSel
.GetEnd().GetPara(); nLine
++ )
631 if ( ToggleBreakPoint( nLine
) )
632 bNewBreakPoint
= TRUE
;
635 aXEditorWindow
.GetBrkWindow().Invalidate();
636 return bNewBreakPoint
;
640 void ModulWindow::BasicToggleBreakPointEnabled()
642 DBG_CHKTHIS( ModulWindow
, 0 );
643 AssertValidEditEngine();
645 ExtTextView
* pView
= GetEditView();
648 TextSelection aSel
= pView
->GetSelection();
649 BreakPointList
& rList
= GetBreakPoints();
651 for ( ULONG nLine
= ++aSel
.GetStart().GetPara(), nEnd
= ++aSel
.GetEnd().GetPara(); nLine
<= nEnd
; ++nLine
)
653 BreakPoint
* pBrk
= rList
.FindBreakPoint( nLine
);
656 pBrk
->bEnabled
= pBrk
->bEnabled
? FALSE
: TRUE
;
657 UpdateBreakPoint( *pBrk
);
661 GetBreakPointWindow().Invalidate();
666 void ModulWindow::ManageBreakPoints()
668 BreakPointWindow
& rBrkWin
= GetBreakPointWindow();
669 BreakPointDialog
aBrkDlg( &rBrkWin
, GetBreakPoints() );
671 rBrkWin
.Invalidate();
675 IMPL_LINK( ModulWindow
, BasicErrorHdl
, StarBASIC
*, pBasic
)
677 DBG_CHKTHIS( ModulWindow
, 0 );
683 String
aErrorText( pBasic
->GetErrorText() );
684 USHORT nErrorLine
= pBasic
->GetLine() - 1;
685 USHORT nErrCol1
= pBasic
->GetCol1();
686 USHORT nErrCol2
= pBasic
->GetCol2();
687 if ( nErrCol2
!= 0xFFFF )
690 AssertValidEditEngine();
691 GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine
, nErrCol1
), TextPaM( nErrorLine
, nErrCol2
) ) );
693 String aErrorTextPrefix
;
694 if( pBasic
->IsCompilerError() )
696 aErrorTextPrefix
= String( IDEResId( RID_STR_COMPILEERROR
) );
700 aErrorTextPrefix
= String( IDEResId( RID_STR_RUNTIMEERROR
) );
701 aErrorTextPrefix
+= StarBASIC::GetVBErrorCode( pBasic
->GetErrorCode() );
702 aErrorTextPrefix
+= ' ';
703 pLayout
->GetStackWindow().UpdateCalls();
705 // Wenn anderes Basic, dan sollte die IDE versuchen, da richtige
706 // Modul anzuzeigen...
707 BOOL bMarkError
= ( pBasic
== GetBasic() ) ? TRUE
: FALSE
;
709 aXEditorWindow
.GetBrkWindow().SetMarkerPos( nErrorLine
, TRUE
);
710 // ErrorBox( this, WB_OK | WB_DEF_OK, String( aErrorTextPrefix + aErrorText ) ).Execute();
711 // ErrorHandler::HandleError( pBasic->GetErrorCode() );
714 Reference
< awt::XWindow
> xWindow
= VCLUnoHelper::GetInterface( this );
716 ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
719 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
724 aXEditorWindow
.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER
);
728 long __EXPORT
ModulWindow::BasicBreakHdl( StarBASIC
* pBasic
)
730 DBG_CHKTHIS( ModulWindow
, 0 );
731 // Ein GoOnTop aktiviert da Fenster, das veraendert aber den Context fuer
735 // #i69280 Required in Window despite normal usage in next command!
738 // ReturnWert: USHORT => siehe SB-Debug-Flags
739 USHORT nErrorLine
= pBasic
->GetLine();
741 // Gibt es hier einen BreakPoint?
742 BreakPoint
* pBrk
= GetBreakPoints().FindBreakPoint( nErrorLine
);
746 if ( pBrk
->nHitCount
< pBrk
->nStopAfter
&& GetBasic()->IsBreak() )
747 return aStatus
.nBasicFlags
; // weiterlaufen...
750 nErrorLine
--; // EditEngine begint bei 0, Basic bei 1
751 // Alleine schon damit gescrollt wird...
752 AssertValidEditEngine();
753 GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine
, 0 ), TextPaM( nErrorLine
, 0 ) ) );
754 aXEditorWindow
.GetBrkWindow().SetMarkerPos( nErrorLine
);
756 pLayout
->GetWatchWindow().UpdateWatches();
757 pLayout
->GetStackWindow().UpdateCalls();
759 aStatus
.bIsInReschedule
= TRUE
;
760 aStatus
.bIsRunning
= TRUE
;
762 AddStatus( BASWIN_INRESCHEDULE
);
764 BasicIDE::InvalidateDebuggerSlots();
766 while( aStatus
.bIsRunning
)
767 Application::Yield();
769 aStatus
.bIsInReschedule
= FALSE
;
770 aXEditorWindow
.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER
);
772 ClearStatus( BASWIN_INRESCHEDULE
);
774 return aStatus
.nBasicFlags
;
777 void ModulWindow::BasicAddWatch()
779 DBG_CHKTHIS( ModulWindow
, 0 );
781 BOOL bInserted
= FALSE
;
782 AssertValidEditEngine();
784 if ( !GetEditView()->HasSelection() )
786 // bAdd = GetEditView()->SelectCurrentWord();
788 String aWord
= GetEditEngine()->GetWord( GetEditView()->GetSelection().GetEnd(), &aWordStart
);
791 TextSelection
aSel( aWordStart
);
792 USHORT
& rIndex
= aSel
.GetEnd().GetIndex();
793 rIndex
= rIndex
+ aWord
.Len();
794 // aSel.GetEnd().GetIndex() += sal::static_int_cast<int>( aWord.Len() );
795 GetEditView()->SetSelection( aSel
);
801 TextSelection aSel
= GetEditView()->GetSelection();
802 if ( aSel
.GetStart().GetPara() == aSel
.GetEnd().GetPara() )
804 aWatchStr
= GetEditView()->GetSelected();
805 pLayout
->GetWatchWindow().AddWatch( aWatchStr
);
806 pLayout
->GetWatchWindow().UpdateWatches();
817 void ModulWindow::BasicRemoveWatch()
819 DBG_CHKTHIS( ModulWindow
, 0 );
820 BOOL bRemoved
= pLayout
->GetWatchWindow().RemoveSelectedWatch();
827 void ModulWindow::EditMacro( const String
& rMacroName
)
829 DBG_CHKTHIS( ModulWindow
, 0 );
830 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
836 if ( !aStatus
.bError
)
839 SbMethod
* pMethod
= (SbMethod
*)xModule
->Find( rMacroName
, SbxCLASS_METHOD
);
842 pMethod
->GetLineRange( nStart
, nEnd
);
845 // Basic beginnt bei 1
849 TextSelection
aSel( TextPaM( nStart
, 0 ), TextPaM( nStart
, 0 ) );
850 AssertValidEditEngine();
851 TextView
* pView
= GetEditView();
852 // ggf. hinscrollen, so dass erste Zeile oben...
853 long nVisHeight
= GetOutputSizePixel().Height();
854 if ( (long)pView
->GetTextEngine()->GetTextHeight() > nVisHeight
)
856 long nMaxY
= pView
->GetTextEngine()->GetTextHeight() - nVisHeight
;
857 long nOldStartY
= pView
->GetStartDocPos().Y();
858 long nNewStartY
= nStart
* pView
->GetTextEngine()->GetCharHeight();
859 nNewStartY
= Min( nNewStartY
, nMaxY
);
860 pView
->Scroll( 0, -(nNewStartY
-nOldStartY
) );
861 pView
->ShowCursor( FALSE
, TRUE
);
862 GetEditVScrollBar().SetThumbPos( pView
->GetStartDocPos().Y() );
864 pView
->SetSelection( aSel
);
866 pView
->GetWindow()->GrabFocus();
873 void __EXPORT
ModulWindow::StoreData()
875 DBG_CHKTHIS( ModulWindow
, 0 );
876 // StoreData wird gerufen, wenn der BasicManager zerstoert oder
877 // dieses Fenster beendet wird.
878 // => Keine Unterbrechungen erwuenscht!
879 // Und bei SAVE, wenn AppBasic...
880 GetEditorWindow().SetSourceInBasic( TRUE
);
881 // Nicht das Modify loeschen, sonst wird das Basic nicht gespeichert
882 // Es wird beim Speichern sowieso geloescht.
883 // xModule->SetModified( FALSE );
886 BOOL __EXPORT
ModulWindow::CanClose()
888 DBG_CHKTHIS( ModulWindow
, 0 );
893 BOOL __EXPORT
ModulWindow::AllowUndo()
895 return GetEditorWindow().CanModify();
899 void __EXPORT
ModulWindow::UpdateData()
901 DBG_CHKTHIS( ModulWindow
, 0 );
902 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
903 // UpdateData wird gerufen, wenn sich der Source von aussen
905 // => Keine Unterbrechungen erwuenscht!
909 SetModule( xModule
->GetSource32() );
913 TextSelection aSel
= GetEditView()->GetSelection();
914 setTextEngineText( GetEditEngine(), xModule
->GetSource32() );
915 GetEditView()->SetSelection( aSel
);
916 GetEditEngine()->SetModified( FALSE
);
917 BasicIDE::MarkDocumentModified( GetDocument() );
923 void __EXPORT
ModulWindow::PrintData( Printer
* pPrinter
)
925 DBG_CHKTHIS( ModulWindow
, 0 );
927 AssertValidEditEngine();
929 MapMode
eOldMapMode( pPrinter
->GetMapMode() );
930 Font
aOldFont( pPrinter
->GetFont() );
932 // Font aFont( GetEditEngine()->CreateFontFromItemSet( GetEditEngine()->GetEmptyItemSet() ) );
933 Font
aFont( GetEditEngine()->GetFont() );
934 aFont
.SetAlign( ALIGN_BOTTOM
);
935 aFont
.SetTransparent( TRUE
);
936 aFont
.SetSize( Size( 0, 360 ) );
937 pPrinter
->SetFont( aFont
);
938 pPrinter
->SetMapMode( MAP_100TH_MM
);
940 String
aTitle( CreateQualifiedName() );
942 USHORT nLineHeight
= (USHORT
) pPrinter
->GetTextHeight(); // etwas mehr.
943 USHORT nParaSpace
= 10;
945 Size aPaperSz
= pPrinter
->GetOutputSize();
946 aPaperSz
.Width() -= (LMARGPRN
+RMARGPRN
);
947 aPaperSz
.Height() -= (TMARGPRN
+BMARGPRN
);
949 // nLinepPage stimmt nicht, wenn Zeilen umgebrochen werden muessen...
950 USHORT nLinespPage
= (USHORT
) (aPaperSz
.Height()/nLineHeight
);
951 USHORT nCharspLine
= (USHORT
) (aPaperSz
.Width() / pPrinter
->GetTextWidth( 'X' ) );
952 ULONG nParas
= GetEditEngine()->GetParagraphCount();
954 USHORT nPages
= (USHORT
) (nParas
/nLinespPage
+1 );
957 pPrinter
->StartJob( aTitle
);
958 pPrinter
->StartPage();
960 lcl_PrintHeader( pPrinter
, nPages
, nCurPage
, aTitle
);
961 Point
aPos( LMARGPRN
, TMARGPRN
);
962 for ( ULONG nPara
= 0; nPara
< nParas
; nPara
++ )
964 String
aLine( GetEditEngine()->GetText( nPara
) );
965 lcl_ConvertTabsToSpaces( aLine
);
966 USHORT nLines
= aLine
.Len()/nCharspLine
+1;
967 for ( USHORT nLine
= 0; nLine
< nLines
; nLine
++ )
969 String
aTmpLine( aLine
, nLine
*nCharspLine
, nCharspLine
);
970 aPos
.Y() += nLineHeight
;
971 if ( aPos
.Y() > ( aPaperSz
.Height()+TMARGPRN
) )
975 pPrinter
->StartPage();
976 lcl_PrintHeader( pPrinter
, nPages
, nCurPage
, aTitle
);
977 aPos
= Point( LMARGPRN
, TMARGPRN
+nLineHeight
);
979 pPrinter
->DrawText( aPos
, aTmpLine
);
981 aPos
.Y() += nParaSpace
;
986 pPrinter
->SetFont( aOldFont
);
987 pPrinter
->SetMapMode( eOldMapMode
);
991 void __EXPORT
ModulWindow::ExecuteCommand( SfxRequest
& rReq
)
993 DBG_CHKTHIS( ModulWindow
, 0 );
994 AssertValidEditEngine();
995 USHORT nSlot
= rReq
.GetSlot();
1003 case SID_BASICCOMPILE
:
1008 case SID_BASICSTEPOVER
:
1013 case SID_BASICSTEPINTO
:
1018 case SID_BASICSTEPOUT
:
1028 case SID_BASICSAVEAS
:
1033 case SID_IMPORT_DIALOG
:
1038 case SID_BASICIDE_MATCHGROUP
:
1040 if ( !GetEditView()->MatchGroup() )
1044 case SID_BASICIDE_TOGGLEBRKPNT
:
1046 BasicToggleBreakPoint();
1049 case SID_BASICIDE_MANAGEBRKPNTS
:
1051 ManageBreakPoints();
1054 case SID_BASICIDE_TOGGLEBRKPNTENABLED
:
1056 BasicToggleBreakPointEnabled();
1059 case SID_BASICIDE_ADDWATCH
:
1064 case SID_BASICIDE_REMOVEWATCH
:
1071 if ( !IsReadOnly() )
1073 GetEditView()->Cut();
1074 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
1076 pBindings
->Invalidate( SID_DOC_MODIFIED
);
1082 GetEditView()->Copy();
1087 if ( !IsReadOnly() )
1089 GetEditView()->Paste();
1090 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
1092 pBindings
->Invalidate( SID_DOC_MODIFIED
);
1096 case SID_BASICIDE_BRKPNTSCHANGED
:
1098 GetBreakPointWindow().Invalidate();
1106 void __EXPORT
ModulWindow::GetState( SfxItemSet
&rSet
)
1108 DBG_CHKTHIS( ModulWindow
, 0 );
1109 SfxWhichIter
aIter(rSet
);
1110 for ( USHORT nWh
= aIter
.FirstWhich(); 0 != nWh
; nWh
= aIter
.NextWhich() )
1114 // allgemeine Items:
1117 if ( !GetEditView() || !GetEditView()->HasSelection() )
1118 rSet
.DisableItem( nWh
);
1121 rSet
.DisableItem( nWh
);
1126 if ( !GetEditView() || !GetEditView()->HasSelection() )
1127 rSet
.DisableItem( nWh
);
1132 if ( !IsPasteAllowed() )
1133 rSet
.DisableItem( nWh
);
1136 rSet
.DisableItem( nWh
);
1139 case SID_BASICIDE_STAT_POS
:
1141 TextView
* pView
= GetEditView();
1144 TextSelection aSel
= pView
->GetSelection();
1145 String
aPos( IDEResId( RID_STR_LINE
) );
1147 aPos
+= String::CreateFromInt32( aSel
.GetEnd().GetPara()+1 );
1148 aPos
+= String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
1149 aPos
+= String( IDEResId( RID_STR_COLUMN
) );
1151 aPos
+= String::CreateFromInt32( aSel
.GetEnd().GetIndex()+1 );
1152 SfxStringItem
aItem( SID_BASICIDE_STAT_POS
, aPos
);
1157 case SID_ATTR_INSERT
:
1159 TextView
* pView
= GetEditView();
1162 SfxBoolItem
aItem( SID_ATTR_INSERT
, pView
->IsInsertMode() );
1172 void __EXPORT
ModulWindow::DoScroll( ScrollBar
* pCurScrollBar
)
1174 DBG_CHKTHIS( ModulWindow
, 0 );
1175 if ( ( pCurScrollBar
== GetHScrollBar() ) && GetEditView() )
1177 // Nicht mit dem Wert Scrollen, sondern lieber die Thumb-Pos fuer die
1178 // VisArea verwenden:
1179 long nDiff
= GetEditView()->GetStartDocPos().X() - pCurScrollBar
->GetThumbPos();
1180 GetEditView()->Scroll( nDiff
, 0 );
1181 GetEditView()->ShowCursor( FALSE
, TRUE
);
1182 pCurScrollBar
->SetThumbPos( GetEditView()->GetStartDocPos().X() );
1188 BOOL
ModulWindow::RenameModule( const String
& rNewName
)
1190 if ( !BasicIDE::RenameModule( this, GetDocument(), GetLibName(), GetName(), rNewName
) )
1193 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
1195 pBindings
->Invalidate( SID_DOC_MODIFIED
);
1201 BOOL __EXPORT
ModulWindow::IsModified()
1203 return GetEditEngine() ? GetEditEngine()->IsModified() : FALSE
;
1208 void __EXPORT
ModulWindow::GoOnTop()
1210 IDE_DLL()->GetShell()->GetViewFrame()->ToTop();
1213 String
ModulWindow::GetSbModuleName()
1217 aModuleName
= xModule
->GetName();
1223 String __EXPORT
ModulWindow::GetTitle()
1225 return GetSbModuleName();
1230 void ModulWindow::FrameWindowMoved()
1232 // if ( GetEditEngine() && GetEditEngine()->IsInSelectionMode() )
1233 // GetEditEngine()->StopSelectionMode();
1238 void ModulWindow::ShowCursor( BOOL bOn
)
1240 if ( GetEditEngine() )
1242 TextView
* pView
= GetEditEngine()->GetActiveView();
1246 pView
->ShowCursor();
1248 pView
->HideCursor();
1254 Window
* __EXPORT
ModulWindow::GetLayoutWindow()
1259 void ModulWindow::AssertValidEditEngine()
1261 if ( !GetEditEngine() )
1262 GetEditorWindow().CreateEditEngine();
1265 void ModulWindow::Deactivating()
1267 if ( GetEditView() )
1268 GetEditView()->EraseVirtualDevice();
1271 USHORT
ModulWindow::StartSearchAndReplace( const SvxSearchItem
& rSearchItem
, BOOL bFromStart
)
1273 // Mann koennte fuer das blinde Alle-Ersetzen auch auf
1274 // Syntaxhighlighting/Formatierung verzichten...
1275 AssertValidEditEngine();
1276 ExtTextView
* pView
= GetEditView();
1280 aSel
= pView
->GetSelection();
1281 if ( !rSearchItem
.GetBackward() )
1282 pView
->SetSelection( TextSelection() );
1284 pView
->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
1287 BOOL bForward
= !rSearchItem
.GetBackward();
1289 if ( ( rSearchItem
.GetCommand() == SVX_SEARCHCMD_FIND
) ||
1290 ( rSearchItem
.GetCommand() == SVX_SEARCHCMD_FIND_ALL
) )
1292 nFound
= pView
->Search( rSearchItem
.GetSearchOptions() , bForward
);
1294 else if ( ( rSearchItem
.GetCommand() == SVX_SEARCHCMD_REPLACE
) ||
1295 ( rSearchItem
.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL
) )
1297 if ( !IsReadOnly() )
1299 BOOL bAll
= rSearchItem
.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL
;
1300 nFound
= pView
->Replace( rSearchItem
.GetSearchOptions() , bAll
, bForward
);
1304 if ( bFromStart
&& !nFound
)
1305 pView
->SetSelection( aSel
);
1310 SfxUndoManager
* __EXPORT
ModulWindow::GetUndoManager()
1312 if ( GetEditEngine() )
1313 return &GetEditEngine()->GetUndoManager();
1317 USHORT __EXPORT
ModulWindow::GetSearchOptions()
1319 USHORT nOptions
= SEARCH_OPTIONS_SEARCH
|
1320 SEARCH_OPTIONS_WHOLE_WORDS
|
1321 SEARCH_OPTIONS_BACKWARDS
|
1322 SEARCH_OPTIONS_REG_EXP
|
1323 SEARCH_OPTIONS_EXACT
|
1324 SEARCH_OPTIONS_SELECTION
|
1325 SEARCH_OPTIONS_SIMILARITY
;
1327 if ( !IsReadOnly() )
1329 nOptions
|= SEARCH_OPTIONS_REPLACE
;
1330 nOptions
|= SEARCH_OPTIONS_REPLACE_ALL
;
1336 void __EXPORT
ModulWindow::BasicStarted()
1340 aStatus
.bIsRunning
= TRUE
;
1341 BreakPointList
& rList
= GetBreakPoints();
1342 if ( rList
.Count() )
1344 rList
.ResetHitCount();
1345 rList
.SetBreakPointsInBasic( xModule
);
1346 for ( USHORT nMethod
= 0; nMethod
< xModule
->GetMethods()->Count(); nMethod
++ )
1348 SbMethod
* pMethod
= (SbMethod
*)xModule
->GetMethods()->Get( nMethod
);
1349 DBG_ASSERT( pMethod
, "Methode nicht gefunden! (NULL)" );
1350 pMethod
->SetDebugFlags( pMethod
->GetDebugFlags() | SbDEBUG_BREAK
);
1356 void __EXPORT
ModulWindow::BasicStopped()
1358 aStatus
.bIsRunning
= FALSE
;
1359 GetBreakPointWindow().SetMarkerPos( MARKER_NOMARKER
);
1362 BasicEntryDescriptor
ModulWindow::CreateEntryDescriptor()
1364 ScriptDocument
aDocument( GetDocument() );
1365 String
aLibName( GetLibName() );
1366 LibraryLocation eLocation
= aDocument
.getLibraryLocation( aLibName
);
1367 String
aModName( GetName() );
1369 if( xBasic
.Is() && xBasic
->isVBAEnabled() && xModule
.Is() )
1371 switch( xModule
->GetModuleType() )
1373 case script::ModuleType::Document
:
1375 aLibSubName
= String( IDEResId( RID_STR_DOCUMENT_OBJECTS
) );
1376 uno::Reference
< container::XNameContainer
> xLib
= aDocument
.getOrCreateLibrary( E_SCRIPTS
, aLibName
);
1380 lcl_getObjectName( xLib
, aModName
, sObjName
);
1381 if( sObjName
.Len() )
1383 aModName
.AppendAscii(" (").Append(sObjName
).AppendAscii(")");
1388 case script::ModuleType::Form
:
1389 aLibSubName
= String( IDEResId( RID_STR_USERFORMS
) );
1391 case script::ModuleType::Normal
:
1392 aLibSubName
= String( IDEResId( RID_STR_NORMAL_MODULES
) );
1394 case script::ModuleType::Class
:
1395 aLibSubName
= String( IDEResId( RID_STR_CLASS_MODULES
) );
1399 return BasicEntryDescriptor( aDocument
, eLocation
, aLibName
, aLibSubName
, aModName
, OBJ_TYPE_MODULE
);
1402 void ModulWindow::SetReadOnly( BOOL b
)
1404 if ( GetEditView() )
1405 GetEditView()->SetReadOnly( b
);
1408 BOOL
ModulWindow::IsReadOnly()
1410 BOOL bReadOnly
= FALSE
;
1412 if ( GetEditView() )
1413 bReadOnly
= GetEditView()->IsReadOnly();
1418 BOOL
ModulWindow::IsPasteAllowed()
1420 BOOL bPaste
= FALSE
;
1423 Reference
< datatransfer::clipboard::XClipboard
> xClipboard
= GetClipboard();
1424 if ( xClipboard
.is() )
1426 // get clipboard content
1427 const sal_uInt32 nRef
= Application::ReleaseSolarMutex();
1428 Reference
< datatransfer::XTransferable
> xTransf
= xClipboard
->getContents();
1429 Application::AcquireSolarMutex( nRef
);
1432 datatransfer::DataFlavor aFlavor
;
1433 SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING
, aFlavor
);
1434 if ( xTransf
->isDataFlavorSupported( aFlavor
) )
1444 ModulWindowLayout::ModulWindowLayout( Window
* pParent
) :
1445 Window( pParent
, WB_CLIPCHILDREN
),
1446 aVSplitter( this, WinBits( WB_VSCROLL
) ),
1447 aHSplitter( this, WinBits( WB_HSCROLL
) ),
1448 aWatchWindow( this ),
1449 aStackWindow( this ),
1453 m_aImagesNormal(IDEResId(RID_IMGLST_LAYOUT
)),
1454 m_aImagesHighContrast(IDEResId(RID_IMGLST_LAYOUT_HC
))
1456 SetBackground(GetSettings().GetStyleSettings().GetWindowColor());
1458 aVSplitter
.SetSplitHdl( LINK( this, ModulWindowLayout
, SplitHdl
) );
1459 aHSplitter
.SetSplitHdl( LINK( this, ModulWindowLayout
, SplitHdl
) );
1463 aWatchWindow
.Show();
1464 aStackWindow
.Show();
1466 Color
aColor(GetSettings().GetStyleSettings().GetFieldTextColor());
1467 m_aSyntaxColors
[TT_UNKNOWN
] = aColor
;
1468 m_aSyntaxColors
[TT_WHITESPACE
] = aColor
;
1469 m_aSyntaxColors
[TT_EOL
] = aColor
;
1470 StartListening(m_aColorConfig
);
1471 m_aSyntaxColors
[TT_IDENTIFIER
]
1472 = Color(m_aColorConfig
.GetColorValue(svtools::BASICIDENTIFIER
).nColor
);
1473 m_aSyntaxColors
[TT_NUMBER
]
1474 = Color(m_aColorConfig
.GetColorValue(svtools::BASICNUMBER
).nColor
);
1475 m_aSyntaxColors
[TT_STRING
]
1476 = Color(m_aColorConfig
.GetColorValue(svtools::BASICSTRING
).nColor
);
1477 m_aSyntaxColors
[TT_COMMENT
]
1478 = Color(m_aColorConfig
.GetColorValue(svtools::BASICCOMMENT
).nColor
);
1479 m_aSyntaxColors
[TT_ERROR
]
1480 = Color(m_aColorConfig
.GetColorValue(svtools::BASICERROR
).nColor
);
1481 m_aSyntaxColors
[TT_OPERATOR
]
1482 = Color(m_aColorConfig
.GetColorValue(svtools::BASICOPERATOR
).nColor
);
1483 m_aSyntaxColors
[TT_KEYWORDS
]
1484 = Color(m_aColorConfig
.GetColorValue(svtools::BASICKEYWORD
).nColor
);
1486 Font
aFont( GetFont() );
1487 Size
aSz( aFont
.GetSize() );
1490 aFont
.SetSize( aSz
);
1491 aFont
.SetWeight( WEIGHT_BOLD
);
1492 aFont
.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor());
1496 ModulWindowLayout::~ModulWindowLayout()
1498 EndListening(m_aColorConfig
);
1501 void __EXPORT
ModulWindowLayout::Resize()
1503 // ScrollBars, etc. passiert in BasicIDEShell:Adjust...
1508 void __EXPORT
ModulWindowLayout::Paint( const Rectangle
& )
1510 DrawText( Point(), String( IDEResId( RID_STR_NOMODULE
) ) );
1514 void ModulWindowLayout::ArrangeWindows()
1516 Size aSz
= GetOutputSizePixel();
1518 // prueffen, ob der Splitter in einem gueltigen Bereich liegt...
1519 long nMinPos
= SPLIT_MARGIN
;
1520 long nMaxPos
= aSz
.Height() - SPLIT_MARGIN
;
1522 long nVSplitPos
= aVSplitter
.GetSplitPosPixel();
1523 long nHSplitPos
= aHSplitter
.GetSplitPosPixel();
1526 // Wenn noch nie gesplitted wurde, Verhaeltniss = 3 : 4
1527 nVSplitPos
= aSz
.Height() * 3 / 4;
1528 aVSplitter
.SetSplitPosPixel( nVSplitPos
);
1532 // Wenn noch nie gesplitted wurde, Verhaeltniss = 2 : 3
1533 nHSplitPos
= aSz
.Width() * 2 / 3;
1534 aHSplitter
.SetSplitPosPixel( nHSplitPos
);
1536 if ( ( nVSplitPos
< nMinPos
) || ( nVSplitPos
> nMaxPos
) )
1537 nVSplitPos
= ( nVSplitPos
< nMinPos
) ? 0 : ( aSz
.Height() - SPLIT_HEIGHT
);
1540 aXEWSz
.Width() = aSz
.Width();
1541 aXEWSz
.Height() = nVSplitPos
+ 1;
1542 if ( m_pModulWindow
)
1544 DBG_CHKOBJ( m_pModulWindow
, ModulWindow
, 0 );
1545 m_pModulWindow
->SetPosSizePixel( Point( 0, 0 ), aXEWSz
);
1548 aVSplitter
.SetDragRectPixel( Rectangle( Point( 0, 0 ), Size( aSz
.Width(), aSz
.Height() ) ) );
1549 aVSplitter
.SetPosPixel( Point( 0, nVSplitPos
) );
1550 aVSplitter
.SetSizePixel( Size( aSz
.Width(), SPLIT_HEIGHT
) );
1552 aHSplitter
.SetDragRectPixel( Rectangle( Point( 0, nVSplitPos
+SPLIT_HEIGHT
), Size( aSz
.Width(), aSz
.Height() - nVSplitPos
- SPLIT_HEIGHT
) ) );
1553 aHSplitter
.SetPosPixel( Point( nHSplitPos
, nVSplitPos
) );
1554 aHSplitter
.SetSizePixel( Size( SPLIT_HEIGHT
, aSz
.Height() - nVSplitPos
) );
1557 Point
aWWPos( 0, nVSplitPos
+SPLIT_HEIGHT
);
1558 aWWSz
.Width() = nHSplitPos
;
1559 aWWSz
.Height() = aSz
.Height() - aWWPos
.Y();
1560 if ( !aWatchWindow
.IsFloatingMode() )
1561 aWatchWindow
.SetPosSizePixel( aWWPos
, aWWSz
);
1564 Point
aSWPos( nHSplitPos
+SPLIT_HEIGHT
, nVSplitPos
+SPLIT_HEIGHT
);
1565 aSWSz
.Width() = aSz
.Width() - aSWPos
.X();
1566 aSWSz
.Height() = aSz
.Height() - aSWPos
.Y();
1567 if ( !aStackWindow
.IsFloatingMode() )
1568 aStackWindow
.SetPosSizePixel( aSWPos
, aSWSz
);
1570 if ( aStackWindow
.IsFloatingMode() && aWatchWindow
.IsFloatingMode() )
1575 long nHDoubleClickSplitPosX
= aSz
.Width()-aHSplitter
.GetSizePixel().Width();
1576 if ( aHSplitter
.GetSplitPosPixel() < nHDoubleClickSplitPosX
)
1577 aHSplitter
.SetLastSplitPosPixel( nHDoubleClickSplitPosX
);
1580 long nHDoubleClickSplitPosY
= aSz
.Height()-aVSplitter
.GetSizePixel().Height();
1581 if ( aVSplitter
.GetSplitPosPixel() < nHDoubleClickSplitPosY
)
1582 aVSplitter
.SetLastSplitPosPixel( nHDoubleClickSplitPosY
);
1585 IMPL_LINK( ModulWindowLayout
, SplitHdl
, Splitter
*, pSplitter
)
1587 if ( pSplitter
== &aVSplitter
)
1596 BOOL
ModulWindowLayout::IsToBeDocked( DockingWindow
* pDockingWindow
, const Point
& rPos
, Rectangle
& rRect
)
1598 // prueffen, ob als Dock oder als Child:
1601 Point aPosInMe
= ScreenToOutputPixel( rPos
);
1602 Size aSz
= GetOutputSizePixel();
1603 if ( ( aPosInMe
.X() > 0 ) && ( aPosInMe
.X() < aSz
.Width() ) &&
1604 ( aPosInMe
.Y() > 0 ) && ( aPosInMe
.Y() < aSz
.Height() ) )
1606 long nVSplitPos
= aVSplitter
.GetSplitPosPixel();
1607 long nHSplitPos
= aHSplitter
.GetSplitPosPixel();
1608 if ( pDockingWindow
== &aWatchWindow
)
1610 if ( ( aPosInMe
.Y() > nVSplitPos
) && ( aPosInMe
.X() < nHSplitPos
) )
1612 rRect
.SetSize( Size( nHSplitPos
, aSz
.Height() - nVSplitPos
) );
1613 rRect
.SetPos( OutputToScreenPixel( Point( 0, nVSplitPos
) ) );
1617 if ( pDockingWindow
== &aStackWindow
)
1619 if ( ( aPosInMe
.Y() > nVSplitPos
) && ( aPosInMe
.X() > nHSplitPos
) )
1621 rRect
.SetSize( Size( aSz
.Width() - nHSplitPos
, aSz
.Height() - nVSplitPos
) );
1622 rRect
.SetPos( OutputToScreenPixel( Point( nHSplitPos
, nVSplitPos
) ) );
1630 void ModulWindowLayout::DockaWindow( DockingWindow
* pDockingWindow
)
1632 if ( pDockingWindow
== &aWatchWindow
)
1634 // evtl. Sonderbehandlung...
1637 else if ( pDockingWindow
== &aStackWindow
)
1639 // evtl. Sonderbehandlung...
1644 DBG_ERROR( "Wer will sich denn hier andocken ?" );
1648 void ModulWindowLayout::SetModulWindow( ModulWindow
* pModWin
)
1650 m_pModulWindow
= pModWin
;
1655 void ModulWindowLayout::DataChanged(DataChangedEvent
const & rDCEvt
)
1657 Window::DataChanged(rDCEvt
);
1658 if (rDCEvt
.GetType() == DATACHANGED_SETTINGS
1659 && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) != 0)
1661 bool bInvalidate
= false;
1662 Color
aColor(GetSettings().GetStyleSettings().GetWindowColor());
1664 != rDCEvt
.GetOldSettings()->GetStyleSettings().GetWindowColor())
1666 SetBackground(Wallpaper(aColor
));
1669 aColor
= GetSettings().GetStyleSettings().GetWindowTextColor();
1670 if (aColor
!= rDCEvt
.GetOldSettings()->
1671 GetStyleSettings().GetWindowTextColor())
1673 Font
aFont(GetFont());
1674 aFont
.SetColor(aColor
);
1680 aColor
= GetSettings().GetStyleSettings().GetFieldTextColor();
1681 if (aColor
!= m_aSyntaxColors
[TT_UNKNOWN
])
1683 m_aSyntaxColors
[TT_UNKNOWN
] = aColor
;
1684 m_aSyntaxColors
[TT_WHITESPACE
] = aColor
;
1685 m_aSyntaxColors
[TT_EOL
] = aColor
;
1686 updateSyntaxHighlighting();
1692 void ModulWindowLayout::Notify(SfxBroadcaster
& rBc
, SfxHint
const & rHint
)
1696 if (rHint
.ISA(SfxSimpleHint
)
1697 && (static_cast< SfxSimpleHint
const & >(rHint
).GetId()
1698 == SFX_HINT_COLORS_CHANGED
))
1700 Color
aColor(m_aColorConfig
.GetColorValue(svtools::BASICIDENTIFIER
).
1702 bool bChanged
= aColor
!= m_aSyntaxColors
[TT_IDENTIFIER
];
1703 m_aSyntaxColors
[TT_IDENTIFIER
] = aColor
;
1704 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICNUMBER
).nColor
);
1705 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_NUMBER
])
1707 m_aSyntaxColors
[TT_NUMBER
] = aColor
;
1708 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICSTRING
).nColor
);
1709 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_STRING
])
1711 m_aSyntaxColors
[TT_STRING
] = aColor
;
1712 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICCOMMENT
).
1714 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_COMMENT
])
1716 m_aSyntaxColors
[TT_COMMENT
] = aColor
;
1717 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICERROR
).nColor
);
1718 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_ERROR
])
1720 m_aSyntaxColors
[TT_ERROR
] = aColor
;
1721 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICOPERATOR
).
1723 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_OPERATOR
])
1725 m_aSyntaxColors
[TT_OPERATOR
] = aColor
;
1726 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICKEYWORD
).
1728 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_KEYWORDS
])
1730 m_aSyntaxColors
[TT_KEYWORDS
] = aColor
;
1732 updateSyntaxHighlighting();
1736 void ModulWindowLayout::updateSyntaxHighlighting()
1738 if (m_pModulWindow
!= 0)
1740 EditorWindow
& rEditor
= m_pModulWindow
->GetEditorWindow();
1741 ULONG nCount
= rEditor
.GetEditEngine()->GetParagraphCount();
1742 for (ULONG i
= 0; i
< nCount
; ++i
)
1743 rEditor
.DoDelayedSyntaxHighlight(i
);
1747 Image
ModulWindowLayout::getImage(USHORT nId
, bool bHighContrastMode
) const
1749 return (bHighContrastMode
? m_aImagesHighContrast
: m_aImagesNormal
).