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();
547 BOOL
ModulWindow::ToggleBreakPoint( ULONG nLine
)
549 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
551 BOOL bNewBreakPoint
= FALSE
;
556 if ( aStatus
.bError
)
562 BreakPoint
* pBrk
= GetBreakPoints().FindBreakPoint( nLine
);
563 if ( pBrk
) // entfernen
565 xModule
->ClearBP( (USHORT
)nLine
);
566 delete GetBreakPoints().Remove( pBrk
);
568 else // einen erzeugen
570 if ( xModule
->SetBP( (USHORT
)nLine
) )
572 GetBreakPoints().InsertSorted( new BreakPoint( nLine
) );
573 bNewBreakPoint
= TRUE
;
574 if ( StarBASIC::IsRunning() )
576 for ( USHORT nMethod
= 0; nMethod
< xModule
->GetMethods()->Count(); nMethod
++ )
578 SbMethod
* pMethod
= (SbMethod
*)xModule
->GetMethods()->Get( nMethod
);
579 DBG_ASSERT( pMethod
, "Methode nicht gefunden! (NULL)" );
580 pMethod
->SetDebugFlags( pMethod
->GetDebugFlags() | SbDEBUG_BREAK
);
585 if ( !bNewBreakPoint
)
590 return bNewBreakPoint
;
593 void ModulWindow::UpdateBreakPoint( const BreakPoint
& rBrk
)
595 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
602 xModule
->SetBP( (USHORT
)rBrk
.nLine
);
604 xModule
->ClearBP( (USHORT
)rBrk
.nLine
);
609 BOOL
ModulWindow::BasicToggleBreakPoint()
611 DBG_CHKTHIS( ModulWindow
, 0 );
612 AssertValidEditEngine();
614 TextSelection aSel
= GetEditView()->GetSelection();
615 aSel
.GetStart().GetPara()++; // Basic-Zeilen beginnen bei 1!
616 aSel
.GetEnd().GetPara()++;
618 BOOL bNewBreakPoint
= FALSE
;
620 for ( ULONG nLine
= aSel
.GetStart().GetPara(); nLine
<= aSel
.GetEnd().GetPara(); nLine
++ )
622 if ( ToggleBreakPoint( nLine
) )
623 bNewBreakPoint
= TRUE
;
626 aXEditorWindow
.GetBrkWindow().Invalidate();
627 return bNewBreakPoint
;
631 void ModulWindow::BasicToggleBreakPointEnabled()
633 DBG_CHKTHIS( ModulWindow
, 0 );
634 AssertValidEditEngine();
636 ExtTextView
* pView
= GetEditView();
639 TextSelection aSel
= pView
->GetSelection();
640 BreakPointList
& rList
= GetBreakPoints();
642 for ( ULONG nLine
= ++aSel
.GetStart().GetPara(), nEnd
= ++aSel
.GetEnd().GetPara(); nLine
<= nEnd
; ++nLine
)
644 BreakPoint
* pBrk
= rList
.FindBreakPoint( nLine
);
647 pBrk
->bEnabled
= pBrk
->bEnabled
? FALSE
: TRUE
;
648 UpdateBreakPoint( *pBrk
);
652 GetBreakPointWindow().Invalidate();
657 void ModulWindow::ManageBreakPoints()
659 BreakPointWindow
& rBrkWin
= GetBreakPointWindow();
660 BreakPointDialog
aBrkDlg( &rBrkWin
, GetBreakPoints() );
662 rBrkWin
.Invalidate();
666 IMPL_LINK( ModulWindow
, BasicErrorHdl
, StarBASIC
*, pBasic
)
668 DBG_CHKTHIS( ModulWindow
, 0 );
674 String
aErrorText( pBasic
->GetErrorText() );
675 USHORT nErrorLine
= pBasic
->GetLine() - 1;
676 USHORT nErrCol1
= pBasic
->GetCol1();
677 USHORT nErrCol2
= pBasic
->GetCol2();
678 if ( nErrCol2
!= 0xFFFF )
681 AssertValidEditEngine();
682 GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine
, nErrCol1
), TextPaM( nErrorLine
, nErrCol2
) ) );
684 String aErrorTextPrefix
;
685 if( pBasic
->IsCompilerError() )
687 aErrorTextPrefix
= String( IDEResId( RID_STR_COMPILEERROR
) );
691 aErrorTextPrefix
= String( IDEResId( RID_STR_RUNTIMEERROR
) );
692 aErrorTextPrefix
+= StarBASIC::GetVBErrorCode( pBasic
->GetErrorCode() );
693 aErrorTextPrefix
+= ' ';
694 pLayout
->GetStackWindow().UpdateCalls();
696 // Wenn anderes Basic, dan sollte die IDE versuchen, da richtige
697 // Modul anzuzeigen...
698 BOOL bMarkError
= ( pBasic
== GetBasic() ) ? TRUE
: FALSE
;
700 aXEditorWindow
.GetBrkWindow().SetMarkerPos( nErrorLine
, TRUE
);
701 // ErrorBox( this, WB_OK | WB_DEF_OK, String( aErrorTextPrefix + aErrorText ) ).Execute();
702 // ErrorHandler::HandleError( pBasic->GetErrorCode() );
705 Reference
< awt::XWindow
> xWindow
= VCLUnoHelper::GetInterface( this );
707 ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
710 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
715 aXEditorWindow
.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER
);
719 long __EXPORT
ModulWindow::BasicBreakHdl( StarBASIC
* pBasic
)
721 DBG_CHKTHIS( ModulWindow
, 0 );
722 // Ein GoOnTop aktiviert da Fenster, das veraendert aber den Context fuer
726 // #i69280 Required in Window despite normal usage in next command!
729 // ReturnWert: USHORT => siehe SB-Debug-Flags
730 USHORT nErrorLine
= pBasic
->GetLine();
732 // Gibt es hier einen BreakPoint?
733 BreakPoint
* pBrk
= GetBreakPoints().FindBreakPoint( nErrorLine
);
737 if ( pBrk
->nHitCount
< pBrk
->nStopAfter
&& GetBasic()->IsBreak() )
738 return aStatus
.nBasicFlags
; // weiterlaufen...
741 nErrorLine
--; // EditEngine begint bei 0, Basic bei 1
742 // Alleine schon damit gescrollt wird...
743 AssertValidEditEngine();
744 GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine
, 0 ), TextPaM( nErrorLine
, 0 ) ) );
745 aXEditorWindow
.GetBrkWindow().SetMarkerPos( nErrorLine
);
747 pLayout
->GetWatchWindow().UpdateWatches();
748 pLayout
->GetStackWindow().UpdateCalls();
750 aStatus
.bIsInReschedule
= TRUE
;
751 aStatus
.bIsRunning
= TRUE
;
753 AddStatus( BASWIN_INRESCHEDULE
);
755 BasicIDE::InvalidateDebuggerSlots();
757 while( aStatus
.bIsRunning
)
758 Application::Yield();
760 aStatus
.bIsInReschedule
= FALSE
;
761 aXEditorWindow
.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER
);
763 ClearStatus( BASWIN_INRESCHEDULE
);
765 return aStatus
.nBasicFlags
;
768 void ModulWindow::BasicAddWatch()
770 DBG_CHKTHIS( ModulWindow
, 0 );
772 BOOL bInserted
= FALSE
;
773 AssertValidEditEngine();
775 if ( !GetEditView()->HasSelection() )
777 // bAdd = GetEditView()->SelectCurrentWord();
779 String aWord
= GetEditEngine()->GetWord( GetEditView()->GetSelection().GetEnd(), &aWordStart
);
782 TextSelection
aSel( aWordStart
);
783 USHORT
& rIndex
= aSel
.GetEnd().GetIndex();
784 rIndex
= rIndex
+ aWord
.Len();
785 // aSel.GetEnd().GetIndex() += sal::static_int_cast<int>( aWord.Len() );
786 GetEditView()->SetSelection( aSel
);
792 TextSelection aSel
= GetEditView()->GetSelection();
793 if ( aSel
.GetStart().GetPara() == aSel
.GetEnd().GetPara() )
795 aWatchStr
= GetEditView()->GetSelected();
796 pLayout
->GetWatchWindow().AddWatch( aWatchStr
);
797 pLayout
->GetWatchWindow().UpdateWatches();
808 void ModulWindow::BasicRemoveWatch()
810 DBG_CHKTHIS( ModulWindow
, 0 );
811 BOOL bRemoved
= pLayout
->GetWatchWindow().RemoveSelectedWatch();
818 void ModulWindow::EditMacro( const String
& rMacroName
)
820 DBG_CHKTHIS( ModulWindow
, 0 );
821 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
827 if ( !aStatus
.bError
)
830 SbMethod
* pMethod
= (SbMethod
*)xModule
->Find( rMacroName
, SbxCLASS_METHOD
);
833 pMethod
->GetLineRange( nStart
, nEnd
);
836 // Basic beginnt bei 1
840 TextSelection
aSel( TextPaM( nStart
, 0 ), TextPaM( nStart
, 0 ) );
841 AssertValidEditEngine();
842 TextView
* pView
= GetEditView();
843 // ggf. hinscrollen, so dass erste Zeile oben...
844 long nVisHeight
= GetOutputSizePixel().Height();
845 if ( (long)pView
->GetTextEngine()->GetTextHeight() > nVisHeight
)
847 long nMaxY
= pView
->GetTextEngine()->GetTextHeight() - nVisHeight
;
848 long nOldStartY
= pView
->GetStartDocPos().Y();
849 long nNewStartY
= nStart
* pView
->GetTextEngine()->GetCharHeight();
850 nNewStartY
= Min( nNewStartY
, nMaxY
);
851 pView
->Scroll( 0, -(nNewStartY
-nOldStartY
) );
852 pView
->ShowCursor( FALSE
, TRUE
);
853 GetEditVScrollBar().SetThumbPos( pView
->GetStartDocPos().Y() );
855 pView
->SetSelection( aSel
);
857 pView
->GetWindow()->GrabFocus();
864 void __EXPORT
ModulWindow::StoreData()
866 DBG_CHKTHIS( ModulWindow
, 0 );
867 // StoreData wird gerufen, wenn der BasicManager zerstoert oder
868 // dieses Fenster beendet wird.
869 // => Keine Unterbrechungen erwuenscht!
870 // Und bei SAVE, wenn AppBasic...
871 GetEditorWindow().SetSourceInBasic( TRUE
);
872 // Nicht das Modify loeschen, sonst wird das Basic nicht gespeichert
873 // Es wird beim Speichern sowieso geloescht.
874 // xModule->SetModified( FALSE );
877 BOOL __EXPORT
ModulWindow::CanClose()
879 DBG_CHKTHIS( ModulWindow
, 0 );
884 BOOL __EXPORT
ModulWindow::AllowUndo()
886 return GetEditorWindow().CanModify();
890 void __EXPORT
ModulWindow::UpdateData()
892 DBG_CHKTHIS( ModulWindow
, 0 );
893 DBG_ASSERT( xModule
.Is(), "Kein Modul!" );
894 // UpdateData wird gerufen, wenn sich der Source von aussen
896 // => Keine Unterbrechungen erwuenscht!
900 SetModule( xModule
->GetSource32() );
904 TextSelection aSel
= GetEditView()->GetSelection();
905 setTextEngineText( GetEditEngine(), xModule
->GetSource32() );
906 GetEditView()->SetSelection( aSel
);
907 GetEditEngine()->SetModified( FALSE
);
908 BasicIDE::MarkDocumentModified( GetDocument() );
914 void __EXPORT
ModulWindow::PrintData( Printer
* pPrinter
)
916 DBG_CHKTHIS( ModulWindow
, 0 );
918 AssertValidEditEngine();
920 MapMode
eOldMapMode( pPrinter
->GetMapMode() );
921 Font
aOldFont( pPrinter
->GetFont() );
923 // Font aFont( GetEditEngine()->CreateFontFromItemSet( GetEditEngine()->GetEmptyItemSet() ) );
924 Font
aFont( GetEditEngine()->GetFont() );
925 aFont
.SetAlign( ALIGN_BOTTOM
);
926 aFont
.SetTransparent( TRUE
);
927 aFont
.SetSize( Size( 0, 360 ) );
928 pPrinter
->SetFont( aFont
);
929 pPrinter
->SetMapMode( MAP_100TH_MM
);
931 String
aTitle( CreateQualifiedName() );
933 USHORT nLineHeight
= (USHORT
) pPrinter
->GetTextHeight(); // etwas mehr.
934 USHORT nParaSpace
= 10;
936 Size aPaperSz
= pPrinter
->GetOutputSize();
937 aPaperSz
.Width() -= (LMARGPRN
+RMARGPRN
);
938 aPaperSz
.Height() -= (TMARGPRN
+BMARGPRN
);
940 // nLinepPage stimmt nicht, wenn Zeilen umgebrochen werden muessen...
941 USHORT nLinespPage
= (USHORT
) (aPaperSz
.Height()/nLineHeight
);
942 USHORT nCharspLine
= (USHORT
) (aPaperSz
.Width() / pPrinter
->GetTextWidth( 'X' ) );
943 ULONG nParas
= GetEditEngine()->GetParagraphCount();
945 USHORT nPages
= (USHORT
) (nParas
/nLinespPage
+1 );
948 pPrinter
->StartJob( aTitle
);
949 pPrinter
->StartPage();
951 lcl_PrintHeader( pPrinter
, nPages
, nCurPage
, aTitle
);
952 Point
aPos( LMARGPRN
, TMARGPRN
);
953 for ( ULONG nPara
= 0; nPara
< nParas
; nPara
++ )
955 String
aLine( GetEditEngine()->GetText( nPara
) );
956 lcl_ConvertTabsToSpaces( aLine
);
957 USHORT nLines
= aLine
.Len()/nCharspLine
+1;
958 for ( USHORT nLine
= 0; nLine
< nLines
; nLine
++ )
960 String
aTmpLine( aLine
, nLine
*nCharspLine
, nCharspLine
);
961 aPos
.Y() += nLineHeight
;
962 if ( aPos
.Y() > ( aPaperSz
.Height()+TMARGPRN
) )
966 pPrinter
->StartPage();
967 lcl_PrintHeader( pPrinter
, nPages
, nCurPage
, aTitle
);
968 aPos
= Point( LMARGPRN
, TMARGPRN
+nLineHeight
);
970 pPrinter
->DrawText( aPos
, aTmpLine
);
972 aPos
.Y() += nParaSpace
;
977 pPrinter
->SetFont( aOldFont
);
978 pPrinter
->SetMapMode( eOldMapMode
);
982 void __EXPORT
ModulWindow::ExecuteCommand( SfxRequest
& rReq
)
984 DBG_CHKTHIS( ModulWindow
, 0 );
985 AssertValidEditEngine();
986 USHORT nSlot
= rReq
.GetSlot();
994 case SID_BASICCOMPILE
:
999 case SID_BASICSTEPOVER
:
1004 case SID_BASICSTEPINTO
:
1009 case SID_BASICSTEPOUT
:
1019 case SID_BASICSAVEAS
:
1024 case SID_BASICIDE_MATCHGROUP
:
1026 if ( !GetEditView()->MatchGroup() )
1030 case SID_BASICIDE_TOGGLEBRKPNT
:
1032 BasicToggleBreakPoint();
1035 case SID_BASICIDE_MANAGEBRKPNTS
:
1037 ManageBreakPoints();
1040 case SID_BASICIDE_TOGGLEBRKPNTENABLED
:
1042 BasicToggleBreakPointEnabled();
1045 case SID_BASICIDE_ADDWATCH
:
1050 case SID_BASICIDE_REMOVEWATCH
:
1057 if ( !IsReadOnly() )
1059 GetEditView()->Cut();
1060 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
1062 pBindings
->Invalidate( SID_DOC_MODIFIED
);
1068 GetEditView()->Copy();
1073 if ( !IsReadOnly() )
1075 GetEditView()->Paste();
1076 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
1078 pBindings
->Invalidate( SID_DOC_MODIFIED
);
1082 case SID_BASICIDE_BRKPNTSCHANGED
:
1084 GetBreakPointWindow().Invalidate();
1092 void __EXPORT
ModulWindow::GetState( SfxItemSet
&rSet
)
1094 DBG_CHKTHIS( ModulWindow
, 0 );
1095 SfxWhichIter
aIter(rSet
);
1096 for ( USHORT nWh
= aIter
.FirstWhich(); 0 != nWh
; nWh
= aIter
.NextWhich() )
1100 // allgemeine Items:
1103 if ( !GetEditView() || !GetEditView()->HasSelection() )
1104 rSet
.DisableItem( nWh
);
1107 rSet
.DisableItem( nWh
);
1112 if ( !GetEditView() || !GetEditView()->HasSelection() )
1113 rSet
.DisableItem( nWh
);
1118 if ( !IsPasteAllowed() )
1119 rSet
.DisableItem( nWh
);
1122 rSet
.DisableItem( nWh
);
1125 case SID_BASICIDE_STAT_POS
:
1127 TextView
* pView
= GetEditView();
1130 TextSelection aSel
= pView
->GetSelection();
1131 String
aPos( IDEResId( RID_STR_LINE
) );
1133 aPos
+= String::CreateFromInt32( aSel
.GetEnd().GetPara()+1 );
1134 aPos
+= String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
1135 aPos
+= String( IDEResId( RID_STR_COLUMN
) );
1137 aPos
+= String::CreateFromInt32( aSel
.GetEnd().GetIndex()+1 );
1138 SfxStringItem
aItem( SID_BASICIDE_STAT_POS
, aPos
);
1143 case SID_ATTR_INSERT
:
1145 TextView
* pView
= GetEditView();
1148 SfxBoolItem
aItem( SID_ATTR_INSERT
, pView
->IsInsertMode() );
1158 void __EXPORT
ModulWindow::DoScroll( ScrollBar
* pCurScrollBar
)
1160 DBG_CHKTHIS( ModulWindow
, 0 );
1161 if ( ( pCurScrollBar
== GetHScrollBar() ) && GetEditView() )
1163 // Nicht mit dem Wert Scrollen, sondern lieber die Thumb-Pos fuer die
1164 // VisArea verwenden:
1165 long nDiff
= GetEditView()->GetStartDocPos().X() - pCurScrollBar
->GetThumbPos();
1166 GetEditView()->Scroll( nDiff
, 0 );
1167 GetEditView()->ShowCursor( FALSE
, TRUE
);
1168 pCurScrollBar
->SetThumbPos( GetEditView()->GetStartDocPos().X() );
1174 BOOL
ModulWindow::RenameModule( const String
& rNewName
)
1176 if ( !BasicIDE::RenameModule( this, GetDocument(), GetLibName(), GetName(), rNewName
) )
1179 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
1181 pBindings
->Invalidate( SID_DOC_MODIFIED
);
1187 BOOL __EXPORT
ModulWindow::IsModified()
1189 return GetEditEngine() ? GetEditEngine()->IsModified() : FALSE
;
1194 void __EXPORT
ModulWindow::GoOnTop()
1196 IDE_DLL()->GetShell()->GetViewFrame()->ToTop();
1199 String
ModulWindow::GetSbModuleName()
1203 aModuleName
= xModule
->GetName();
1209 String __EXPORT
ModulWindow::GetTitle()
1211 return GetSbModuleName();
1216 void ModulWindow::FrameWindowMoved()
1218 // if ( GetEditEngine() && GetEditEngine()->IsInSelectionMode() )
1219 // GetEditEngine()->StopSelectionMode();
1224 void ModulWindow::ShowCursor( BOOL bOn
)
1226 if ( GetEditEngine() )
1228 TextView
* pView
= GetEditEngine()->GetActiveView();
1232 pView
->ShowCursor();
1234 pView
->HideCursor();
1240 Window
* __EXPORT
ModulWindow::GetLayoutWindow()
1245 void ModulWindow::AssertValidEditEngine()
1247 if ( !GetEditEngine() )
1248 GetEditorWindow().CreateEditEngine();
1251 void ModulWindow::Deactivating()
1253 if ( GetEditView() )
1254 GetEditView()->EraseVirtualDevice();
1257 USHORT
ModulWindow::StartSearchAndReplace( const SvxSearchItem
& rSearchItem
, BOOL bFromStart
)
1259 // Mann koennte fuer das blinde Alle-Ersetzen auch auf
1260 // Syntaxhighlighting/Formatierung verzichten...
1261 AssertValidEditEngine();
1262 ExtTextView
* pView
= GetEditView();
1266 aSel
= pView
->GetSelection();
1267 if ( !rSearchItem
.GetBackward() )
1268 pView
->SetSelection( TextSelection() );
1270 pView
->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
1273 BOOL bForward
= !rSearchItem
.GetBackward();
1275 if ( ( rSearchItem
.GetCommand() == SVX_SEARCHCMD_FIND
) ||
1276 ( rSearchItem
.GetCommand() == SVX_SEARCHCMD_FIND_ALL
) )
1278 nFound
= pView
->Search( rSearchItem
.GetSearchOptions() , bForward
);
1280 else if ( ( rSearchItem
.GetCommand() == SVX_SEARCHCMD_REPLACE
) ||
1281 ( rSearchItem
.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL
) )
1283 if ( !IsReadOnly() )
1285 BOOL bAll
= rSearchItem
.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL
;
1286 nFound
= pView
->Replace( rSearchItem
.GetSearchOptions() , bAll
, bForward
);
1290 if ( bFromStart
&& !nFound
)
1291 pView
->SetSelection( aSel
);
1296 SfxUndoManager
* __EXPORT
ModulWindow::GetUndoManager()
1298 if ( GetEditEngine() )
1299 return &GetEditEngine()->GetUndoManager();
1303 USHORT __EXPORT
ModulWindow::GetSearchOptions()
1305 USHORT nOptions
= SEARCH_OPTIONS_SEARCH
|
1306 SEARCH_OPTIONS_WHOLE_WORDS
|
1307 SEARCH_OPTIONS_BACKWARDS
|
1308 SEARCH_OPTIONS_REG_EXP
|
1309 SEARCH_OPTIONS_EXACT
|
1310 SEARCH_OPTIONS_SELECTION
|
1311 SEARCH_OPTIONS_SIMILARITY
;
1313 if ( !IsReadOnly() )
1315 nOptions
|= SEARCH_OPTIONS_REPLACE
;
1316 nOptions
|= SEARCH_OPTIONS_REPLACE_ALL
;
1322 void __EXPORT
ModulWindow::BasicStarted()
1326 aStatus
.bIsRunning
= TRUE
;
1327 BreakPointList
& rList
= GetBreakPoints();
1328 if ( rList
.Count() )
1330 rList
.ResetHitCount();
1331 rList
.SetBreakPointsInBasic( xModule
);
1332 for ( USHORT nMethod
= 0; nMethod
< xModule
->GetMethods()->Count(); nMethod
++ )
1334 SbMethod
* pMethod
= (SbMethod
*)xModule
->GetMethods()->Get( nMethod
);
1335 DBG_ASSERT( pMethod
, "Methode nicht gefunden! (NULL)" );
1336 pMethod
->SetDebugFlags( pMethod
->GetDebugFlags() | SbDEBUG_BREAK
);
1342 void __EXPORT
ModulWindow::BasicStopped()
1344 aStatus
.bIsRunning
= FALSE
;
1345 GetBreakPointWindow().SetMarkerPos( MARKER_NOMARKER
);
1348 BasicEntryDescriptor
ModulWindow::CreateEntryDescriptor()
1350 ScriptDocument
aDocument( GetDocument() );
1351 String
aLibName( GetLibName() );
1352 LibraryLocation eLocation
= aDocument
.getLibraryLocation( aLibName
);
1353 String
aModName( GetName() );
1355 if( xBasic
.Is() && xBasic
->isVBAEnabled() && xModule
.Is() )
1357 switch( xModule
->GetModuleType() )
1359 case script::ModuleType::Document
:
1361 aLibSubName
= String( IDEResId( RID_STR_DOCUMENT_OBJECTS
) );
1362 uno::Reference
< container::XNameContainer
> xLib
= aDocument
.getOrCreateLibrary( E_SCRIPTS
, aLibName
);
1366 lcl_getObjectName( xLib
, aModName
, sObjName
);
1367 if( sObjName
.Len() )
1369 aModName
.AppendAscii(" (").Append(sObjName
).AppendAscii(")");
1374 case script::ModuleType::Form
:
1375 aLibSubName
= String( IDEResId( RID_STR_USERFORMS
) );
1377 case script::ModuleType::Normal
:
1378 aLibSubName
= String( IDEResId( RID_STR_NORMAL_MODULES
) );
1380 case script::ModuleType::Class
:
1381 aLibSubName
= String( IDEResId( RID_STR_CLASS_MODULES
) );
1385 return BasicEntryDescriptor( aDocument
, eLocation
, aLibName
, aLibSubName
, aModName
, OBJ_TYPE_MODULE
);
1388 void ModulWindow::SetReadOnly( BOOL b
)
1390 if ( GetEditView() )
1391 GetEditView()->SetReadOnly( b
);
1394 BOOL
ModulWindow::IsReadOnly()
1396 BOOL bReadOnly
= FALSE
;
1398 if ( GetEditView() )
1399 bReadOnly
= GetEditView()->IsReadOnly();
1404 BOOL
ModulWindow::IsPasteAllowed()
1406 BOOL bPaste
= FALSE
;
1409 Reference
< datatransfer::clipboard::XClipboard
> xClipboard
= GetClipboard();
1410 if ( xClipboard
.is() )
1412 // get clipboard content
1413 const sal_uInt32 nRef
= Application::ReleaseSolarMutex();
1414 Reference
< datatransfer::XTransferable
> xTransf
= xClipboard
->getContents();
1415 Application::AcquireSolarMutex( nRef
);
1418 datatransfer::DataFlavor aFlavor
;
1419 SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING
, aFlavor
);
1420 if ( xTransf
->isDataFlavorSupported( aFlavor
) )
1430 ModulWindowLayout::ModulWindowLayout( Window
* pParent
) :
1431 Window( pParent
, WB_CLIPCHILDREN
),
1432 aVSplitter( this, WinBits( WB_VSCROLL
) ),
1433 aHSplitter( this, WinBits( WB_HSCROLL
) ),
1434 aWatchWindow( this ),
1435 aStackWindow( this ),
1439 m_aImagesNormal(IDEResId(RID_IMGLST_LAYOUT
)),
1440 m_aImagesHighContrast(IDEResId(RID_IMGLST_LAYOUT_HC
))
1442 SetBackground(GetSettings().GetStyleSettings().GetWindowColor());
1444 aVSplitter
.SetSplitHdl( LINK( this, ModulWindowLayout
, SplitHdl
) );
1445 aHSplitter
.SetSplitHdl( LINK( this, ModulWindowLayout
, SplitHdl
) );
1449 aWatchWindow
.Show();
1450 aStackWindow
.Show();
1452 Color
aColor(GetSettings().GetStyleSettings().GetFieldTextColor());
1453 m_aSyntaxColors
[TT_UNKNOWN
] = aColor
;
1454 m_aSyntaxColors
[TT_WHITESPACE
] = aColor
;
1455 m_aSyntaxColors
[TT_EOL
] = aColor
;
1456 StartListening(m_aColorConfig
);
1457 m_aSyntaxColors
[TT_IDENTIFIER
]
1458 = Color(m_aColorConfig
.GetColorValue(svtools::BASICIDENTIFIER
).nColor
);
1459 m_aSyntaxColors
[TT_NUMBER
]
1460 = Color(m_aColorConfig
.GetColorValue(svtools::BASICNUMBER
).nColor
);
1461 m_aSyntaxColors
[TT_STRING
]
1462 = Color(m_aColorConfig
.GetColorValue(svtools::BASICSTRING
).nColor
);
1463 m_aSyntaxColors
[TT_COMMENT
]
1464 = Color(m_aColorConfig
.GetColorValue(svtools::BASICCOMMENT
).nColor
);
1465 m_aSyntaxColors
[TT_ERROR
]
1466 = Color(m_aColorConfig
.GetColorValue(svtools::BASICERROR
).nColor
);
1467 m_aSyntaxColors
[TT_OPERATOR
]
1468 = Color(m_aColorConfig
.GetColorValue(svtools::BASICOPERATOR
).nColor
);
1469 m_aSyntaxColors
[TT_KEYWORDS
]
1470 = Color(m_aColorConfig
.GetColorValue(svtools::BASICKEYWORD
).nColor
);
1472 Font
aFont( GetFont() );
1473 Size
aSz( aFont
.GetSize() );
1476 aFont
.SetSize( aSz
);
1477 aFont
.SetWeight( WEIGHT_BOLD
);
1478 aFont
.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor());
1482 ModulWindowLayout::~ModulWindowLayout()
1484 EndListening(m_aColorConfig
);
1487 void __EXPORT
ModulWindowLayout::Resize()
1489 // ScrollBars, etc. passiert in BasicIDEShell:Adjust...
1494 void __EXPORT
ModulWindowLayout::Paint( const Rectangle
& )
1496 DrawText( Point(), String( IDEResId( RID_STR_NOMODULE
) ) );
1500 void ModulWindowLayout::ArrangeWindows()
1502 Size aSz
= GetOutputSizePixel();
1504 // prueffen, ob der Splitter in einem gueltigen Bereich liegt...
1505 long nMinPos
= SPLIT_MARGIN
;
1506 long nMaxPos
= aSz
.Height() - SPLIT_MARGIN
;
1508 long nVSplitPos
= aVSplitter
.GetSplitPosPixel();
1509 long nHSplitPos
= aHSplitter
.GetSplitPosPixel();
1512 // Wenn noch nie gesplitted wurde, Verhaeltniss = 3 : 4
1513 nVSplitPos
= aSz
.Height() * 3 / 4;
1514 aVSplitter
.SetSplitPosPixel( nVSplitPos
);
1518 // Wenn noch nie gesplitted wurde, Verhaeltniss = 2 : 3
1519 nHSplitPos
= aSz
.Width() * 2 / 3;
1520 aHSplitter
.SetSplitPosPixel( nHSplitPos
);
1522 if ( ( nVSplitPos
< nMinPos
) || ( nVSplitPos
> nMaxPos
) )
1523 nVSplitPos
= ( nVSplitPos
< nMinPos
) ? 0 : ( aSz
.Height() - SPLIT_HEIGHT
);
1526 aXEWSz
.Width() = aSz
.Width();
1527 aXEWSz
.Height() = nVSplitPos
+ 1;
1528 if ( m_pModulWindow
)
1530 DBG_CHKOBJ( m_pModulWindow
, ModulWindow
, 0 );
1531 m_pModulWindow
->SetPosSizePixel( Point( 0, 0 ), aXEWSz
);
1534 aVSplitter
.SetDragRectPixel( Rectangle( Point( 0, 0 ), Size( aSz
.Width(), aSz
.Height() ) ) );
1535 aVSplitter
.SetPosPixel( Point( 0, nVSplitPos
) );
1536 aVSplitter
.SetSizePixel( Size( aSz
.Width(), SPLIT_HEIGHT
) );
1538 aHSplitter
.SetDragRectPixel( Rectangle( Point( 0, nVSplitPos
+SPLIT_HEIGHT
), Size( aSz
.Width(), aSz
.Height() - nVSplitPos
- SPLIT_HEIGHT
) ) );
1539 aHSplitter
.SetPosPixel( Point( nHSplitPos
, nVSplitPos
) );
1540 aHSplitter
.SetSizePixel( Size( SPLIT_HEIGHT
, aSz
.Height() - nVSplitPos
) );
1543 Point
aWWPos( 0, nVSplitPos
+SPLIT_HEIGHT
);
1544 aWWSz
.Width() = nHSplitPos
;
1545 aWWSz
.Height() = aSz
.Height() - aWWPos
.Y();
1546 if ( !aWatchWindow
.IsFloatingMode() )
1547 aWatchWindow
.SetPosSizePixel( aWWPos
, aWWSz
);
1550 Point
aSWPos( nHSplitPos
+SPLIT_HEIGHT
, nVSplitPos
+SPLIT_HEIGHT
);
1551 aSWSz
.Width() = aSz
.Width() - aSWPos
.X();
1552 aSWSz
.Height() = aSz
.Height() - aSWPos
.Y();
1553 if ( !aStackWindow
.IsFloatingMode() )
1554 aStackWindow
.SetPosSizePixel( aSWPos
, aSWSz
);
1556 if ( aStackWindow
.IsFloatingMode() && aWatchWindow
.IsFloatingMode() )
1561 long nHDoubleClickSplitPosX
= aSz
.Width()-aHSplitter
.GetSizePixel().Width();
1562 if ( aHSplitter
.GetSplitPosPixel() < nHDoubleClickSplitPosX
)
1563 aHSplitter
.SetLastSplitPosPixel( nHDoubleClickSplitPosX
);
1566 long nHDoubleClickSplitPosY
= aSz
.Height()-aVSplitter
.GetSizePixel().Height();
1567 if ( aVSplitter
.GetSplitPosPixel() < nHDoubleClickSplitPosY
)
1568 aVSplitter
.SetLastSplitPosPixel( nHDoubleClickSplitPosY
);
1571 IMPL_LINK( ModulWindowLayout
, SplitHdl
, Splitter
*, pSplitter
)
1573 if ( pSplitter
== &aVSplitter
)
1582 BOOL
ModulWindowLayout::IsToBeDocked( DockingWindow
* pDockingWindow
, const Point
& rPos
, Rectangle
& rRect
)
1584 // prueffen, ob als Dock oder als Child:
1587 Point aPosInMe
= ScreenToOutputPixel( rPos
);
1588 Size aSz
= GetOutputSizePixel();
1589 if ( ( aPosInMe
.X() > 0 ) && ( aPosInMe
.X() < aSz
.Width() ) &&
1590 ( aPosInMe
.Y() > 0 ) && ( aPosInMe
.Y() < aSz
.Height() ) )
1592 long nVSplitPos
= aVSplitter
.GetSplitPosPixel();
1593 long nHSplitPos
= aHSplitter
.GetSplitPosPixel();
1594 if ( pDockingWindow
== &aWatchWindow
)
1596 if ( ( aPosInMe
.Y() > nVSplitPos
) && ( aPosInMe
.X() < nHSplitPos
) )
1598 rRect
.SetSize( Size( nHSplitPos
, aSz
.Height() - nVSplitPos
) );
1599 rRect
.SetPos( OutputToScreenPixel( Point( 0, nVSplitPos
) ) );
1603 if ( pDockingWindow
== &aStackWindow
)
1605 if ( ( aPosInMe
.Y() > nVSplitPos
) && ( aPosInMe
.X() > nHSplitPos
) )
1607 rRect
.SetSize( Size( aSz
.Width() - nHSplitPos
, aSz
.Height() - nVSplitPos
) );
1608 rRect
.SetPos( OutputToScreenPixel( Point( nHSplitPos
, nVSplitPos
) ) );
1616 void ModulWindowLayout::DockaWindow( DockingWindow
* pDockingWindow
)
1618 if ( pDockingWindow
== &aWatchWindow
)
1620 // evtl. Sonderbehandlung...
1623 else if ( pDockingWindow
== &aStackWindow
)
1625 // evtl. Sonderbehandlung...
1630 DBG_ERROR( "Wer will sich denn hier andocken ?" );
1634 void ModulWindowLayout::SetModulWindow( ModulWindow
* pModWin
)
1636 m_pModulWindow
= pModWin
;
1641 void ModulWindowLayout::DataChanged(DataChangedEvent
const & rDCEvt
)
1643 Window::DataChanged(rDCEvt
);
1644 if (rDCEvt
.GetType() == DATACHANGED_SETTINGS
1645 && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) != 0)
1647 bool bInvalidate
= false;
1648 Color
aColor(GetSettings().GetStyleSettings().GetWindowColor());
1650 != rDCEvt
.GetOldSettings()->GetStyleSettings().GetWindowColor())
1652 SetBackground(Wallpaper(aColor
));
1655 aColor
= GetSettings().GetStyleSettings().GetWindowTextColor();
1656 if (aColor
!= rDCEvt
.GetOldSettings()->
1657 GetStyleSettings().GetWindowTextColor())
1659 Font
aFont(GetFont());
1660 aFont
.SetColor(aColor
);
1666 aColor
= GetSettings().GetStyleSettings().GetFieldTextColor();
1667 if (aColor
!= m_aSyntaxColors
[TT_UNKNOWN
])
1669 m_aSyntaxColors
[TT_UNKNOWN
] = aColor
;
1670 m_aSyntaxColors
[TT_WHITESPACE
] = aColor
;
1671 m_aSyntaxColors
[TT_EOL
] = aColor
;
1672 updateSyntaxHighlighting();
1678 void ModulWindowLayout::Notify(SfxBroadcaster
& rBc
, SfxHint
const & rHint
)
1682 if (rHint
.ISA(SfxSimpleHint
)
1683 && (static_cast< SfxSimpleHint
const & >(rHint
).GetId()
1684 == SFX_HINT_COLORS_CHANGED
))
1686 Color
aColor(m_aColorConfig
.GetColorValue(svtools::BASICIDENTIFIER
).
1688 bool bChanged
= aColor
!= m_aSyntaxColors
[TT_IDENTIFIER
];
1689 m_aSyntaxColors
[TT_IDENTIFIER
] = aColor
;
1690 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICNUMBER
).nColor
);
1691 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_NUMBER
])
1693 m_aSyntaxColors
[TT_NUMBER
] = aColor
;
1694 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICSTRING
).nColor
);
1695 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_STRING
])
1697 m_aSyntaxColors
[TT_STRING
] = aColor
;
1698 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICCOMMENT
).
1700 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_COMMENT
])
1702 m_aSyntaxColors
[TT_COMMENT
] = aColor
;
1703 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICERROR
).nColor
);
1704 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_ERROR
])
1706 m_aSyntaxColors
[TT_ERROR
] = aColor
;
1707 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICOPERATOR
).
1709 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_OPERATOR
])
1711 m_aSyntaxColors
[TT_OPERATOR
] = aColor
;
1712 aColor
= Color(m_aColorConfig
.GetColorValue(svtools::BASICKEYWORD
).
1714 if (bChanged
|| aColor
!= m_aSyntaxColors
[TT_KEYWORDS
])
1716 m_aSyntaxColors
[TT_KEYWORDS
] = aColor
;
1718 updateSyntaxHighlighting();
1722 void ModulWindowLayout::updateSyntaxHighlighting()
1724 if (m_pModulWindow
!= 0)
1726 EditorWindow
& rEditor
= m_pModulWindow
->GetEditorWindow();
1727 ULONG nCount
= rEditor
.GetEditEngine()->GetParagraphCount();
1728 for (ULONG i
= 0; i
< nCount
; ++i
)
1729 rEditor
.DoDelayedSyntaxHighlight(i
);
1733 Image
ModulWindowLayout::getImage(USHORT nId
, bool bHighContrastMode
) const
1735 return (bHighContrastMode
? m_aImagesHighContrast
: m_aImagesNormal
).