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: basides1.cxx,v $
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"
34 #include "docsignature.hxx"
36 #define GLOBALOVERFLOW2
37 #include <basic/sbx.hxx>
38 #define _SVSTDARR_STRINGS
39 #include <svtools/svstdarr.hxx>
40 #include <ide_pch.hxx>
42 #define _SOLAR__PRIVATE 1
44 // #define _SVX_NOIDERESIDS
47 #define SI_NOSBXCONTROLS
52 #include <basidesh.hrc>
53 #include <basidesh.hxx>
54 #include <baside2.hxx>
55 #include <baside3.hxx>
57 #include <iderdll.hxx>
58 #include <iderdll2.hxx>
59 #include <sbxitem.hxx>
60 #include <managelang.hxx>
61 #include <localizationmgr.hxx>
64 #include <svtools/texteng.hxx>
65 #include <svtools/textview.hxx>
66 #include <svtools/xtextedt.hxx>
67 #include <tools/urlobj.hxx>
68 #include <tools/diagnose_ex.h>
69 #include <sfx2/minfitem.hxx>
70 #include <sfx2/docfile.hxx>
71 #include <com/sun/star/task/XStatusIndicator.hpp>
72 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
73 #include <com/sun/star/script/XLibraryContainer.hpp>
74 #include <com/sun/star/script/XLibraryContainerPassword.hpp>
75 #include <com/sun/star/frame/XDispatchProvider.hpp>
76 #include <com/sun/star/frame/XLayoutManager.hpp>
82 using namespace ::com::sun::star
;
83 using namespace ::com::sun::star::uno
;
84 using namespace ::com::sun::star::frame
;
88 // Egal was, einfach ans aktuelle Fenster:
89 void __EXPORT
BasicIDEShell::ExecuteCurrent( SfxRequest
& rReq
)
94 switch ( rReq
.GetSlot() )
96 case SID_BASICIDE_HIDECURPAGE
:
99 RemoveWindow( pCurWin
, FALSE
);
102 case SID_BASICIDE_DELETECURRENT
:
104 ScriptDocument
aDocument( pCurWin
->GetDocument() );
105 String aLibName
= pCurWin
->GetLibName();
106 String aName
= pCurWin
->GetName();
108 if ( pCurWin
->ISA( ModulWindow
) )
111 if ( QueryDelModule( aName
, pCurWin
) )
113 if ( aDocument
.removeModule( aLibName
, aName
) )
115 RemoveWindow( pCurWin
, TRUE
);
116 BasicIDE::MarkDocumentModified( aDocument
);
123 if ( QueryDelDialog( aName
, pCurWin
) )
125 if ( BasicIDE::RemoveDialog( aDocument
, aLibName
, aName
) )
127 RemoveWindow( pCurWin
, TRUE
);
128 BasicIDE::MarkDocumentModified( aDocument
);
134 case SID_BASICIDE_RENAMECURRENT
:
136 pTabBar
->StartEditMode( pTabBar
->GetCurPageId() );
141 if ( pCurWin
->ISA( ModulWindow
) )
143 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
144 const SfxItemSet
* pArgs
= rReq
.GetArgs();
145 // Leider kenne ich die ID nicht:
146 USHORT nWhich
= pArgs
->GetWhichByPos( 0 );
147 DBG_ASSERT( nWhich
, "Wich fuer SearchItem ?" );
148 const SfxPoolItem
& rItem
= pArgs
->Get( nWhich
);
149 DBG_ASSERT( rItem
.ISA( SvxSearchItem
), "Kein Searchitem!" );
150 if ( rItem
.ISA( SvxSearchItem
) )
152 // Item wegen der Einstellungen merken...
153 IDE_DLL()->GetExtraData()->SetSearchItem( (const SvxSearchItem
&)rItem
);
155 BOOL bCanceled
= FALSE
;
156 if ( ((const SvxSearchItem
&)rItem
).GetCommand() == SVX_SEARCHCMD_REPLACE_ALL
)
158 USHORT nActModWindows
= 0;
159 IDEBaseWindow
* pWin
= aIDEWindowTable
.First();
162 if ( !pWin
->IsSuspended() && pWin
->IsA( TYPE( ModulWindow
) ) )
164 pWin
= aIDEWindowTable
.Next();
167 if ( ( nActModWindows
<= 1 ) || ( !((const SvxSearchItem
&)rItem
).GetSelection() && QueryBox( pCurWin
, WB_YES_NO
|WB_DEF_YES
, String( IDEResId( RID_STR_SEARCHALLMODULES
) ) ).Execute() == RET_YES
) )
169 pWin
= aIDEWindowTable
.First();
172 if ( !pWin
->IsSuspended() && pWin
->IsA( TYPE( ModulWindow
) ) )
173 nFound
= nFound
+ ((ModulWindow
*)pWin
)->StartSearchAndReplace( (const SvxSearchItem
&)rItem
);
174 pWin
= aIDEWindowTable
.Next();
178 nFound
= ((ModulWindow
*)pCurWin
)->StartSearchAndReplace( (const SvxSearchItem
&)rItem
);
180 IDEResId
nId( RID_STR_SEARCHREPLACES
);
181 String
aReplStr( nId
);
182 aReplStr
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), String::CreateFromInt32( nFound
) );
183 InfoBox( pCurWin
, aReplStr
).Execute();
187 nFound
= ((ModulWindow
*)pCurWin
)->StartSearchAndReplace( (const SvxSearchItem
&)rItem
);
188 if ( !nFound
&& !((const SvxSearchItem
&)rItem
).GetSelection() )
190 // Andere Module durchsuchen...
191 BOOL bChangeCurWindow
= FALSE
;
192 aIDEWindowTable
.Seek( pCurWin
);
193 // Erstmal beim naechsten Anfangen, ggf. spaeter von vorne
194 IDEBaseWindow
* pWin
= aIDEWindowTable
.Next();
195 BOOL bSearchedFromStart
= FALSE
;
196 while ( !nFound
&& !bCanceled
&& ( pWin
|| !bSearchedFromStart
) )
200 SfxViewFrame
* pViewFrame
= GetViewFrame();
201 SfxChildWindow
* pChildWin
= pViewFrame
? pViewFrame
->GetChildWindow( SID_SEARCH_DLG
) : NULL
;
202 Window
* pParent
= pChildWin
? pChildWin
->GetWindow() : NULL
;
203 QueryBox
aQuery( pParent
, WB_YES_NO
|WB_DEF_YES
, String( IDEResId( RID_STR_SEARCHFROMSTART
) ) );
204 if ( aQuery
.Execute() == RET_YES
)
206 pWin
= aIDEWindowTable
.First();
207 bSearchedFromStart
= TRUE
;
213 if ( pWin
&& !pWin
->IsSuspended() && pWin
->IsA( TYPE( ModulWindow
) ) )
215 if ( pWin
!= pCurWin
)
217 // Groesse einstellen, damit die View
218 // gleich richtig justiert werden kann.
220 pWin
->SetSizePixel( pCurWin
->GetSizePixel() );
221 nFound
= ((ModulWindow
*)pWin
)->StartSearchAndReplace( (const SvxSearchItem
&)rItem
, TRUE
);
225 bChangeCurWindow
= TRUE
;
229 if ( pWin
&& ( pWin
!= pCurWin
) )
230 pWin
= aIDEWindowTable
.Next();
232 pWin
= 0; // Dann sind wir durch...
234 if ( !nFound
&& bSearchedFromStart
) // Aktuelles von vorne...
235 nFound
= ((ModulWindow
*)pCurWin
)->StartSearchAndReplace( (const SvxSearchItem
&)rItem
, TRUE
);
236 if ( bChangeCurWindow
)
237 SetCurWindow( pWin
, TRUE
);
239 if ( !nFound
&& !bCanceled
)
240 InfoBox( pCurWin
, String( IDEResId( RID_STR_SEARCHNOTFOUND
) ) ).Execute();
250 if ( pCurWin
&& pCurWin
->ISA( ModulWindow
) )
251 pCurWin
->GrabFocus();
257 if ( GetUndoManager() && pCurWin
->AllowUndo() )
259 GetViewFrame()->ExecuteSlot( rReq
);
265 pCurWin
->ExecuteCommand( rReq
);
270 // Egal, wer oben, Einfluss auf die Shell:
271 void __EXPORT
BasicIDEShell::ExecuteGlobal( SfxRequest
& rReq
)
273 USHORT nSlot
= rReq
.GetSlot();
278 // Evtl. nicht einfach anhalten, falls auf Brechpunkt!
279 if ( pCurWin
&& pCurWin
->IsA( TYPE( ModulWindow
) ) )
280 ((ModulWindow
*)pCurWin
)->BasicStop();
281 BasicIDE::StopBasic();
289 // Daten ins BASIC zurueckschreiben
290 StoreAllWindowData();
293 ScriptDocument
aDocument( pCurWin
->GetDocument() );
294 if ( aDocument
.isDocument() )
296 uno::Reference
< task::XStatusIndicator
> xStatusIndicator
;
298 SFX_REQUEST_ARG( rReq
, pStatusIndicatorItem
, SfxUnoAnyItem
, SID_PROGRESS_STATUSBAR_CONTROL
, FALSE
);
299 if ( pStatusIndicatorItem
)
300 OSL_VERIFY( pStatusIndicatorItem
->GetValue() >>= xStatusIndicator
);
303 // get statusindicator
304 SfxViewFrame
*pFrame_
= GetFrame();
305 if ( pFrame_
&& pFrame_
->GetFrame() )
307 uno::Reference
< task::XStatusIndicatorFactory
> xStatFactory(
308 pFrame_
->GetFrame()->GetFrameInterface(),
310 if( xStatFactory
.is() )
311 xStatusIndicator
= xStatFactory
->createStatusIndicator();
314 if ( xStatusIndicator
.is() )
315 rReq
.AppendItem( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL
, uno::makeAny( xStatusIndicator
) ) );
318 aDocument
.saveDocument( xStatusIndicator
);
321 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
324 pBindings
->Invalidate( SID_DOC_MODIFIED
);
325 pBindings
->Invalidate( SID_SAVEDOC
);
326 pBindings
->Invalidate( SID_SIGNATURE
);
335 ::basctl::DocumentSignature
aSignature( pCurWin
->GetDocument() );
336 if ( aSignature
.supportsSignatures() )
338 aSignature
.signScriptingContent();
339 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
341 pBindings
->Invalidate( SID_SIGNATURE
);
347 case SID_BASICIDE_MODULEDLG
:
349 if ( rReq
.GetArgs() )
351 const SfxUInt16Item
&rTabId
= (const SfxUInt16Item
&)rReq
.GetArgs()->Get(SID_BASICIDE_ARG_TABID
);
352 BasicIDE::Organize( rTabId
.GetValue() );
355 BasicIDE::Organize( 0 );
358 case SID_BASICIDE_CHOOSEMACRO
:
360 BasicIDE::ChooseMacro( NULL
, FALSE
, ::rtl::OUString() );
363 case SID_BASICIDE_CREATEMACRO
:
364 case SID_BASICIDE_EDITMACRO
:
366 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
367 const SfxMacroInfoItem
& rInfo
= (const SfxMacroInfoItem
&)rReq
.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO
);
368 BasicManager
* pBasMgr
= (BasicManager
*)rInfo
.GetBasicManager();
369 DBG_ASSERT( pBasMgr
, "Nichts selektiert im Basic-Baum ?" );
371 ScriptDocument
aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr
) );
373 StartListening( *pBasMgr
, TRUE
/* Nur einmal anmelden */ );
374 String
aLibName( rInfo
.GetLib() );
375 if ( !aLibName
.Len() )
376 aLibName
= String::CreateFromAscii( "Standard" );
377 StarBASIC
* pBasic
= pBasMgr
->GetLib( aLibName
);
380 // load module and dialog library (if not loaded)
381 aDocument
.loadLibraryIfExists( E_SCRIPTS
, aLibName
);
382 aDocument
.loadLibraryIfExists( E_DIALOGS
, aLibName
);
385 pBasic
= pBasMgr
->GetLib( aLibName
);
387 DBG_ASSERT( pBasic
, "Kein Basic!" );
389 SetCurLib( aDocument
, aLibName
);
391 if ( rReq
.GetSlot() == SID_BASICIDE_CREATEMACRO
)
393 SbModule
* pModule
= pBasic
->FindModule( rInfo
.GetModule() );
396 if ( rInfo
.GetModule().Len() || !pBasic
->GetModules()->Count() )
398 String aModName
= rInfo
.GetModule();
400 ::rtl::OUString sModuleCode
;
401 if ( aDocument
.createModule( aLibName
, aModName
, FALSE
, sModuleCode
) )
402 pModule
= pBasic
->FindModule( aModName
);
405 pModule
= (SbModule
*) pBasic
->GetModules()->Get(0);
407 DBG_ASSERT( pModule
, "Kein Modul!" );
408 if ( !pModule
->GetMethods()->Find( rInfo
.GetMethod(), SbxCLASS_METHOD
) )
409 BasicIDE::CreateMacro( pModule
, rInfo
.GetMethod() );
411 SfxViewFrame
* pViewFrame
= GetViewFrame();
414 ModulWindow
* pWin
= FindBasWin( aDocument
, aLibName
, rInfo
.GetModule(), TRUE
);
415 DBG_ASSERT( pWin
, "Edit/Create Macro: Fenster wurde nicht erzeugt/gefunden!" );
416 SetCurWindow( pWin
, TRUE
);
417 pWin
->EditMacro( rInfo
.GetMethod() );
420 case SID_BASICIDE_OBJCAT
:
422 ShowObjectDialog( TRUE
, TRUE
);
425 case SID_BASICIDE_NAMECHANGEDONTAB
:
427 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
428 const SfxUInt16Item
&rTabId
= (const SfxUInt16Item
&)rReq
.GetArgs()->Get(SID_BASICIDE_ARG_TABID
);
429 const SfxStringItem
&rModName
= (const SfxStringItem
&)rReq
.GetArgs()->Get(SID_BASICIDE_ARG_MODULENAME
);
430 IDEBaseWindow
* pWin
= aIDEWindowTable
.Get( rTabId
.GetValue() );
431 DBG_ASSERT( pWin
, "Window nicht im Liste, aber in TabBar ?" );
434 String
aNewName( rModName
.GetValue() );
435 String
aOldName( pWin
->GetName() );
437 if ( aNewName
!= aOldName
)
439 if ( ( pWin
->IsA( TYPE( ModulWindow
) ) && ((ModulWindow
*)pWin
)->RenameModule( aNewName
) )
440 || ( pWin
->IsA( TYPE( DialogWindow
) ) && ((DialogWindow
*)pWin
)->RenameDialog( aNewName
) ) )
442 BasicIDE::MarkDocumentModified( pWin
->GetDocument() );
446 // set old name in TabWriter
447 USHORT nId
= (USHORT
)aIDEWindowTable
.GetKey( pWin
);
448 DBG_ASSERT( nId
, "No entry in Tabbar!" );
450 pTabBar
->SetPageText( nId
, aOldName
);
454 // set focus to current window
459 case SID_BASICIDE_STOREMODULESOURCE
:
460 case SID_BASICIDE_UPDATEMODULESOURCE
:
462 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
463 const SfxMacroInfoItem
& rInfo
= (const SfxMacroInfoItem
&)rReq
.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO
);
464 BasicManager
* pBasMgr
= (BasicManager
*)rInfo
.GetBasicManager();
465 DBG_ASSERT( pBasMgr
, "Store source: Kein BasMgr?" );
466 ScriptDocument
aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr
) );
467 ModulWindow
* pWin
= FindBasWin( aDocument
, rInfo
.GetLib(), rInfo
.GetModule(), FALSE
, TRUE
);
470 if ( rReq
.GetSlot() == SID_BASICIDE_STOREMODULESOURCE
)
477 case SID_BASICIDE_STOREALLMODULESOURCES
:
478 case SID_BASICIDE_UPDATEALLMODULESOURCES
:
480 IDEBaseWindow
* pWin
= aIDEWindowTable
.First();
483 if ( !pWin
->IsSuspended() && pWin
->IsA( TYPE( ModulWindow
) ) )
485 if ( rReq
.GetSlot() == SID_BASICIDE_STOREALLMODULESOURCES
)
490 pWin
= aIDEWindowTable
.Next();
494 case SID_BASICIDE_LIBSELECTED
:
495 case SID_BASICIDE_LIBREMOVED
:
496 case SID_BASICIDE_LIBLOADED
:
498 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
499 const SfxUsrAnyItem
& rShellItem
= (const SfxUsrAnyItem
&)rReq
.GetArgs()->Get( SID_BASICIDE_ARG_DOCUMENT_MODEL
);
500 uno::Reference
< frame::XModel
> xModel( rShellItem
.GetValue(), UNO_QUERY
);
501 ScriptDocument
aDocument( xModel
.is() ? ScriptDocument( xModel
) : ScriptDocument::getApplicationScriptDocument() );
502 const SfxStringItem
& rLibNameItem
= (const SfxStringItem
&)rReq
.GetArgs()->Get( SID_BASICIDE_ARG_LIBNAME
);
503 String
aLibName( rLibNameItem
.GetValue() );
505 if ( nSlot
== SID_BASICIDE_LIBSELECTED
)
507 // load module and dialog library (if not loaded)
508 aDocument
.loadLibraryIfExists( E_SCRIPTS
, aLibName
);
509 aDocument
.loadLibraryIfExists( E_DIALOGS
, aLibName
);
511 // check password, if library is password protected and not verified
513 Reference
< script::XLibraryContainer
> xModLibContainer( aDocument
.getLibraryContainer( E_SCRIPTS
) );
514 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aLibName
) )
516 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContainer
, UNO_QUERY
);
517 if ( xPasswd
.is() && xPasswd
->isLibraryPasswordProtected( aLibName
) && !xPasswd
->isLibraryPasswordVerified( aLibName
) )
520 bOK
= QueryPassword( xModLibContainer
, aLibName
, aPassword
);
526 SetCurLib( aDocument
, aLibName
, true, false );
530 // alten Wert einstellen...
531 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
533 pBindings
->Invalidate( SID_BASICIDE_LIBSELECTOR
, TRUE
, FALSE
);
536 else if ( nSlot
== SID_BASICIDE_LIBREMOVED
)
538 if ( !m_aCurLibName
.Len() || ( aDocument
== m_aCurDocument
&& aLibName
== m_aCurLibName
) )
540 RemoveWindows( aDocument
, aLibName
, TRUE
);
541 if ( aDocument
== m_aCurDocument
&& aLibName
== m_aCurLibName
)
543 m_aCurDocument
= ScriptDocument::getApplicationScriptDocument();
544 m_aCurLibName
= String();
545 // Kein UpdateWindows!
546 SfxBindings
* pBindings
= BasicIDE::GetBindingsPtr();
548 pBindings
->Invalidate( SID_BASICIDE_LIBSELECTOR
);
556 case SID_BASICIDE_NEWMODULE
:
558 ModulWindow
* pWin
= CreateBasWin( m_aCurDocument
, m_aCurLibName
, String() );
559 DBG_ASSERT( pWin
, "New Module: Konnte Fenster nicht erzeugen!" );
560 SetCurWindow( pWin
, TRUE
);
563 case SID_BASICIDE_NEWDIALOG
:
565 DialogWindow
* pWin
= CreateDlgWin( m_aCurDocument
, m_aCurLibName
, String() );
566 DBG_ASSERT( pWin
, "New Module: Konnte Fenster nicht erzeugen!" );
567 SetCurWindow( pWin
, TRUE
);
570 case SID_BASICIDE_SBXRENAMED
:
572 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
575 case SID_BASICIDE_SBXINSERTED
:
577 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
578 const SbxItem
& rSbxItem
= (const SbxItem
&)rReq
.GetArgs()->Get(SID_BASICIDE_ARG_SBX
);
579 ScriptDocument
aDocument( rSbxItem
.GetDocument() );
580 String
aLibName( rSbxItem
.GetLibName() );
581 String
aName( rSbxItem
.GetName() );
582 if ( !m_aCurLibName
.Len() || ( aDocument
== m_aCurDocument
&& aLibName
== m_aCurLibName
) )
584 IDEBaseWindow
* pWin
= 0;
585 if ( rSbxItem
.GetType() == BASICIDE_TYPE_MODULE
)
586 pWin
= FindBasWin( aDocument
, aLibName
, aName
, TRUE
);
587 else if ( rSbxItem
.GetType() == BASICIDE_TYPE_DIALOG
)
588 pWin
= FindDlgWin( aDocument
, aLibName
, aName
, TRUE
);
592 case SID_BASICIDE_SBXDELETED
:
594 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
595 const SbxItem
& rSbxItem
= (const SbxItem
&)rReq
.GetArgs()->Get(SID_BASICIDE_ARG_SBX
);
596 ScriptDocument
aDocument( rSbxItem
.GetDocument() );
597 IDEBaseWindow
* pWin
= FindWindow( aDocument
, rSbxItem
.GetLibName(), rSbxItem
.GetName(), rSbxItem
.GetType(), TRUE
);
599 RemoveWindow( pWin
, TRUE
);
602 case SID_BASICIDE_SHOWSBX
:
604 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
605 const SbxItem
& rSbxItem
= (const SbxItem
&)rReq
.GetArgs()->Get(SID_BASICIDE_ARG_SBX
);
606 ScriptDocument
aDocument( rSbxItem
.GetDocument() );
607 String
aLibName( rSbxItem
.GetLibName() );
608 String
aName( rSbxItem
.GetName() );
609 SetCurLib( aDocument
, aLibName
);
610 IDEBaseWindow
* pWin
= 0;
611 if ( rSbxItem
.GetType() == BASICIDE_TYPE_DIALOG
)
613 pWin
= FindDlgWin( aDocument
, aLibName
, aName
, TRUE
);
615 else if ( rSbxItem
.GetType() == BASICIDE_TYPE_MODULE
)
617 pWin
= FindBasWin( aDocument
, aLibName
, aName
, TRUE
);
619 else if ( rSbxItem
.GetType() == BASICIDE_TYPE_METHOD
)
621 pWin
= FindBasWin( aDocument
, aLibName
, aName
, TRUE
);
622 ((ModulWindow
*)pWin
)->EditMacro( rSbxItem
.GetMethodName() );
624 DBG_ASSERT( pWin
, "Fenster wurde nicht erzeugt!" );
625 SetCurWindow( pWin
, TRUE
);
626 pTabBar
->MakeVisible( pTabBar
->GetCurPageId() );
629 case SID_SHOW_PROPERTYBROWSER
:
631 GetViewFrame()->ChildWindowExecute( rReq
);
635 case SID_BASICIDE_SHOWWINDOW
:
637 ::std::auto_ptr
< ScriptDocument
> pDocument
;
639 SFX_REQUEST_ARG( rReq
, pDocumentItem
, SfxStringItem
, SID_BASICIDE_ARG_DOCUMENT
, sal_False
);
642 String sDocumentCaption
= pDocumentItem
->GetValue();
643 if ( sDocumentCaption
.Len() )
644 pDocument
.reset( new ScriptDocument( ScriptDocument::getDocumentWithURLOrCaption( sDocumentCaption
) ) );
647 SFX_REQUEST_ARG( rReq
, pDocModelItem
, SfxUsrAnyItem
, SID_BASICIDE_ARG_DOCUMENT_MODEL
, sal_False
);
648 if ( !pDocument
.get() && pDocModelItem
)
650 uno::Reference
< frame::XModel
> xModel( pDocModelItem
->GetValue(), UNO_QUERY
);
652 pDocument
.reset( new ScriptDocument( xModel
) );
655 if ( !pDocument
.get() )
658 SFX_REQUEST_ARG( rReq
, pLibNameItem
, SfxStringItem
, SID_BASICIDE_ARG_LIBNAME
, sal_False
);
662 String
aLibName( pLibNameItem
->GetValue() );
663 pDocument
->loadLibraryIfExists( E_SCRIPTS
, aLibName
);
664 SetCurLib( *pDocument
, aLibName
);
665 SFX_REQUEST_ARG( rReq
, pNameItem
, SfxStringItem
, SID_BASICIDE_ARG_NAME
, sal_False
);
668 String
aName( pNameItem
->GetValue() );
669 String
aModType( String::CreateFromAscii( "Module" ) );
670 String
aDlgType( String::CreateFromAscii( "Dialog" ) );
671 String
aType( aModType
);
672 SFX_REQUEST_ARG( rReq
, pTypeItem
, SfxStringItem
, SID_BASICIDE_ARG_TYPE
, sal_False
);
674 aType
= pTypeItem
->GetValue();
676 IDEBaseWindow
* pWin
= 0;
677 if ( aType
== aModType
)
678 pWin
= FindBasWin( *pDocument
, aLibName
, aName
, FALSE
);
679 else if ( aType
== aDlgType
)
680 pWin
= FindDlgWin( *pDocument
, aLibName
, aName
, FALSE
);
684 SetCurWindow( pWin
, TRUE
);
686 pTabBar
->MakeVisible( pTabBar
->GetCurPageId() );
688 if ( pWin
->ISA( ModulWindow
) )
690 ModulWindow
* pModWin
= (ModulWindow
*)pWin
;
691 SFX_REQUEST_ARG( rReq
, pLineItem
, SfxUInt32Item
, SID_BASICIDE_ARG_LINE
, sal_False
);
694 pModWin
->AssertValidEditEngine();
695 TextView
* pTextView
= pModWin
->GetEditView();
698 TextEngine
* pTextEngine
= pTextView
->GetTextEngine();
701 sal_uInt32 nLine
= pLineItem
->GetValue();
702 sal_uInt32 nLineCount
= 0;
703 for ( sal_uInt32 i
= 0, nCount
= pTextEngine
->GetParagraphCount(); i
< nCount
; ++i
)
704 nLineCount
+= pTextEngine
->GetLineCount( i
);
705 if ( nLine
> nLineCount
)
710 // scroll window and set selection
711 long nVisHeight
= pModWin
->GetOutputSizePixel().Height();
712 long nTextHeight
= pTextEngine
->GetTextHeight();
713 if ( nTextHeight
> nVisHeight
)
715 long nMaxY
= nTextHeight
- nVisHeight
;
716 long nOldY
= pTextView
->GetStartDocPos().Y();
717 long nNewY
= nLine
* pTextEngine
->GetCharHeight() - nVisHeight
/ 2;
718 nNewY
= ::std::min( nNewY
, nMaxY
);
719 pTextView
->Scroll( 0, -( nNewY
- nOldY
) );
720 pTextView
->ShowCursor( FALSE
, TRUE
);
721 pModWin
->GetEditVScrollBar().SetThumbPos( pTextView
->GetStartDocPos().Y() );
723 sal_uInt16 nCol1
= 0, nCol2
= 0;
724 SFX_REQUEST_ARG( rReq
, pCol1Item
, SfxUInt16Item
, SID_BASICIDE_ARG_COLUMN1
, sal_False
);
727 nCol1
= pCol1Item
->GetValue();
732 SFX_REQUEST_ARG( rReq
, pCol2Item
, SfxUInt16Item
, SID_BASICIDE_ARG_COLUMN2
, sal_False
);
735 nCol2
= pCol2Item
->GetValue();
739 TextSelection
aSel( TextPaM( nLine
, nCol1
), TextPaM( nLine
, nCol2
) );
740 pTextView
->SetSelection( aSel
);
741 pTextView
->ShowCursor();
742 Window
* pWindow_
= pTextView
->GetWindow();
744 pWindow_
->GrabFocus();
755 case SID_BASICIDE_MANAGE_LANG
:
757 ManageLanguageDialog
aDlg( GetCurWindow(), GetCurLocalizationMgr() );
765 void __EXPORT
BasicIDEShell::GetState(SfxItemSet
&rSet
)
767 SfxWhichIter
aIter(rSet
);
768 for ( USHORT nWh
= aIter
.FirstWhich(); 0 != nWh
; nWh
= aIter
.NextWhich() )
774 rSet
.DisableItem( nWh
);
779 BOOL bDisable
= FALSE
;
783 if ( !pCurWin
->IsModified() )
785 ScriptDocument
aDocument( pCurWin
->GetDocument() );
786 bDisable
= ( !aDocument
.isAlive() )
787 || ( aDocument
.isDocument() ? !aDocument
.isDocumentModified() : !IsAppBasicModified() );
796 rSet
.DisableItem( nWh
);
802 rSet
.DisableItem( nWh
);
807 sal_uInt16 nState
= 0;
810 ::basctl::DocumentSignature
aSignature( pCurWin
->GetDocument() );
811 nState
= aSignature
.getScriptingSignatureState();
813 rSet
.Put( SfxUInt16Item( SID_SIGNATURE
, nState
) );
816 case SID_BASICIDE_MODULEDLG
:
818 if ( StarBASIC::IsRunning() )
819 rSet
.DisableItem( nWh
);
822 case SID_BASICIDE_CHOOSEMACRO
:
823 case SID_BASICIDE_OBJCAT
:
824 case SID_BASICIDE_SHOWSBX
:
825 case SID_BASICIDE_CREATEMACRO
:
826 case SID_BASICIDE_EDITMACRO
:
827 case SID_BASICIDE_NAMECHANGEDONTAB
:
833 case SID_BASICIDE_ADDWATCH
:
834 case SID_BASICIDE_REMOVEWATCH
:
836 case SID_BASICSAVEAS
:
837 case SID_BASICIDE_MATCHGROUP
:
839 if ( !pCurWin
|| !pCurWin
->IsA( TYPE( ModulWindow
) ) )
840 rSet
.DisableItem( nWh
);
841 else if ( ( nWh
== SID_BASICLOAD
) && ( StarBASIC::IsRunning() || ( pCurWin
&& pCurWin
->IsReadOnly() ) ) )
842 rSet
.DisableItem( nWh
);
846 case SID_BASICSTEPINTO
:
847 case SID_BASICSTEPOVER
:
848 case SID_BASICSTEPOUT
:
849 case SID_BASICIDE_TOGGLEBRKPNT
:
850 case SID_BASICIDE_MANAGEBRKPNTS
:
852 if ( !pCurWin
|| !pCurWin
->IsA( TYPE( ModulWindow
) ) )
853 rSet
.DisableItem( nWh
);
854 else if ( StarBASIC::IsRunning() && !((ModulWindow
*)pCurWin
)->GetBasicStatus().bIsInReschedule
)
855 rSet
.DisableItem( nWh
);
858 case SID_BASICCOMPILE
:
860 if ( !pCurWin
|| !pCurWin
->IsA( TYPE( ModulWindow
) ) || StarBASIC::IsRunning() )
861 rSet
.DisableItem( nWh
);
866 // Stop immermoeglich, wenn irgendein Basic lauft...
867 if ( !StarBASIC::IsRunning() )
868 rSet
.DisableItem( nWh
);
871 case SID_CHOOSE_CONTROLS
:
872 case SID_DIALOG_TESTMODE
:
874 if( !pCurWin
|| !pCurWin
->IsA( TYPE( DialogWindow
) ) )
875 rSet
.DisableItem( nWh
);
879 case SID_SHOW_HIDDEN
:
881 rSet
.DisableItem( nWh
);
884 case SID_SEARCH_OPTIONS
:
888 nOptions
= pCurWin
->GetSearchOptions();
889 rSet
.Put( SfxUInt16Item( SID_SEARCH_OPTIONS
, nOptions
) );
892 case SID_BASICIDE_LIBSELECTOR
:
895 if ( m_aCurLibName
.Len() )
897 LibraryLocation eLocation
= m_aCurDocument
.getLibraryLocation( m_aCurLibName
);
898 aName
= CreateMgrAndLibStr( m_aCurDocument
.getTitle( eLocation
), m_aCurLibName
);
900 SfxStringItem
aItem( SID_BASICIDE_LIBSELECTOR
, aName
);
904 case SID_SEARCH_ITEM
:
906 String aSelected
= GetSelectionText( TRUE
);
907 SvxSearchItem
& rItem
= IDE_DLL()->GetExtraData()->GetSearchItem();
908 rItem
.SetSearchString( aSelected
);
912 case SID_BASICIDE_STAT_DATE
:
915 aDate
= String( RTL_CONSTASCII_USTRINGPARAM( "Datum?!" ) );
916 SfxStringItem
aItem( SID_BASICIDE_STAT_DATE
, aDate
);
920 case SID_DOC_MODIFIED
:
922 String aModifiedMarker
;
923 BOOL bModified
= FALSE
;
927 if ( pCurWin
->IsModified() )
931 ScriptDocument
aDocument( pCurWin
->GetDocument() );
932 bModified
= aDocument
.isDocument() ? aDocument
.isDocumentModified() : IsAppBasicModified();
937 aModifiedMarker
= '*';
939 SfxStringItem
aItem( SID_DOC_MODIFIED
, aModifiedMarker
);
943 case SID_BASICIDE_STAT_TITLE
:
947 String aTitle
= pCurWin
->CreateQualifiedName();
948 SfxStringItem
aItem( SID_BASICIDE_STAT_TITLE
, aTitle
);
953 // Werden vom Controller ausgewertet:
955 case SID_ATTR_INSERT
:
960 if( GetUndoManager() ) // sonst rekursives GetState
961 GetViewFrame()->GetSlotState( nWh
, NULL
, &rSet
);
964 case SID_SHOW_PROPERTYBROWSER
:
966 if ( GetViewFrame()->KnowsChildWindow( nWh
) )
967 rSet
.Put( SfxBoolItem( nWh
, GetViewFrame()->HasChildWindow( nWh
) ) );
969 rSet
.DisableItem( nWh
);
973 case SID_BASICIDE_CURRENT_LANG
:
975 if( (pCurWin
&& pCurWin
->IsReadOnly()) || GetCurLibName().Len() == 0 )
976 rSet
.DisableItem( nWh
);
980 LocalizationMgr
* pCurMgr
= GetCurLocalizationMgr();
981 if ( pCurMgr
->isLibraryLocalized() )
983 Sequence
< lang::Locale
> aLocaleSeq
= pCurMgr
->getStringResourceManager()->getLocales();
984 const lang::Locale
* pLocale
= aLocaleSeq
.getConstArray();
985 INT32 i
, nCount
= aLocaleSeq
.getLength();
987 // Force different results for any combination of locales and default locale
988 ::rtl::OUString aLangStr
;
989 for ( i
= 0; i
<= nCount
; ++i
)
991 lang::Locale aLocale
;
993 aLocale
= pLocale
[i
];
995 aLocale
= pCurMgr
->getStringResourceManager()->getDefaultLocale();
997 aLangStr
+= aLocale
.Language
;
998 aLangStr
+= aLocale
.Country
;
999 aLangStr
+= aLocale
.Variant
;
1001 aItemStr
= aLangStr
;
1003 rSet
.Put( SfxStringItem( nWh
, aItemStr
) );
1008 case SID_BASICIDE_MANAGE_LANG
:
1010 if( (pCurWin
&& pCurWin
->IsReadOnly()) || GetCurLibName().Len() == 0 )
1011 rSet
.DisableItem( nWh
);
1017 pCurWin
->GetState( rSet
);
1020 sal_Bool
BasicIDEShell::HasUIFeature( sal_uInt32 nFeature
)
1022 sal_Bool bResult
= sal_False
;
1024 if ( (nFeature
& BASICIDE_UI_FEATURE_SHOW_BROWSER
) == BASICIDE_UI_FEATURE_SHOW_BROWSER
)
1026 // fade out (in) property browser in module (dialog) windows
1027 if ( pCurWin
&& pCurWin
->IsA( TYPE( DialogWindow
) ) && !pCurWin
->IsReadOnly() )
1034 void BasicIDEShell::SetCurWindow( IDEBaseWindow
* pNewWin
, BOOL bUpdateTabBar
, BOOL bRememberAsCurrent
)
1036 // Es muss ein EditWindow am Sfx gesetzt sein, sonst kommt kein
1037 // Resize, also stehen die Controls auf den Wiese...
1038 // Sieht dann sowieso besser aus, wenn das Modul-Layout angezeigt wird...
1039 if ( !pNewWin
&& ( GetWindow() != pModulLayout
) )
1041 pModulLayout
->Show();
1042 AdjustPosSizePixel( Point( 0, 0 ), GetViewFrame()->GetWindow().GetOutputSizePixel() );
1043 SetWindow( pModulLayout
);
1044 EnableScrollbars( FALSE
);
1048 if ( pNewWin
!= pCurWin
)
1050 IDEBaseWindow
* pPrevCurWin
= pCurWin
;
1054 pPrevCurWin
->Hide();
1055 pPrevCurWin
->Deactivating();
1056 // pPrevCurWin->GetLayoutWindow()->Hide();
1057 if( pPrevCurWin
->IsA( TYPE( DialogWindow
) ) )
1059 ((DialogWindow
*)pPrevCurWin
)->DisableBrowser();
1063 pModulLayout
->SetModulWindow( NULL
);
1068 AdjustPosSizePixel( Point( 0, 0 ), GetViewFrame()->GetWindow().GetOutputSizePixel() );
1069 if( pCurWin
->IsA( TYPE( ModulWindow
) ) )
1071 GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW
);
1072 pModulLayout
->SetModulWindow( (ModulWindow
*)pCurWin
);
1073 pModulLayout
->Show();
1077 pModulLayout
->Hide();
1078 GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_DIALOGWINDOW
);
1081 if ( bRememberAsCurrent
)
1083 BasicIDEData
* pData
= IDE_DLL()->GetExtraData();
1086 USHORT nCurrentType
= pCurWin
->IsA( TYPE( ModulWindow
) ) ? BASICIDE_TYPE_MODULE
: BASICIDE_TYPE_DIALOG
;
1087 LibInfoItem
* pLibInfoItem
= new LibInfoItem( pCurWin
->GetDocument(), pCurWin
->GetLibName(), pCurWin
->GetName(), nCurrentType
);
1088 pData
->GetLibInfos().InsertInfo( pLibInfoItem
);
1092 if ( GetViewFrame()->GetWindow().IsVisible() ) // sonst macht es spaeter der SFX
1097 if ( !IDE_DLL()->GetExtraData()->ShellInCriticalSection() )
1099 Window
* pFrameWindow
= &GetViewFrame()->GetWindow();
1100 Window
* pFocusWindow
= Application::GetFocusWindow();
1101 while ( pFocusWindow
&& ( pFocusWindow
!= pFrameWindow
) )
1102 pFocusWindow
= pFocusWindow
->GetParent();
1103 if ( pFocusWindow
) // Focus in BasicIDE
1104 pNewWin
->GrabFocus();
1106 if( pCurWin
->IsA( TYPE( DialogWindow
) ) )
1107 ((DialogWindow
*)pCurWin
)->UpdateBrowser();
1109 if ( bUpdateTabBar
)
1111 ULONG nKey
= aIDEWindowTable
.GetKey( pCurWin
);
1112 if ( pCurWin
&& ( pTabBar
->GetPagePos( (USHORT
)nKey
) == TAB_PAGE_NOTFOUND
) )
1113 pTabBar
->InsertPage( (USHORT
)nKey
, pCurWin
->GetTitle() ); // wurde neu eingeblendet
1114 pTabBar
->SetCurPageId( (USHORT
)nKey
);
1116 if ( pCurWin
&& pCurWin
->IsSuspended() ) // Wenn das Fenster im Fehlerfall angezeigt wird...
1117 pCurWin
->SetStatus( pCurWin
->GetStatus() & ~BASWIN_SUSPENDED
);
1120 SetWindow( pCurWin
);
1121 if ( pCurWin
->GetDocument().isDocument() )
1122 SfxObjectShell::SetCurrentComponent( pCurWin
->GetDocument().getDocument() );
1126 SetWindow( pModulLayout
);
1127 GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW
);
1128 SfxObjectShell::SetCurrentComponent( NULL
);
1130 SetUndoManager( pCurWin
? pCurWin
->GetUndoManager() : 0 );
1131 InvalidateBasicIDESlots();
1132 EnableScrollbars( pCurWin
? TRUE
: FALSE
);
1134 if ( m_pCurLocalizationMgr
)
1135 m_pCurLocalizationMgr
->handleTranslationbar();
1139 // fade out (in) property browser in module (dialog) windows
1144 void BasicIDEShell::ManageToolbars()
1146 static ::rtl::OUString aLayoutManagerName
= ::rtl::OUString::createFromAscii( "LayoutManager" );
1147 static ::rtl::OUString aMacroBarResName
=
1148 ::rtl::OUString::createFromAscii( "private:resource/toolbar/macrobar" );
1149 static ::rtl::OUString aDialogBarResName
=
1150 ::rtl::OUString::createFromAscii( "private:resource/toolbar/dialogbar" );
1151 static ::rtl::OUString aInsertControlsBarResName
=
1152 ::rtl::OUString::createFromAscii( "private:resource/toolbar/insertcontrolsbar" );
1153 (void)aInsertControlsBarResName
;
1158 Reference
< beans::XPropertySet
> xFrameProps
1159 ( GetViewFrame()->GetFrame()->GetFrameInterface(), uno::UNO_QUERY
);
1160 if ( xFrameProps
.is() )
1162 Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
1163 uno::Any a
= xFrameProps
->getPropertyValue( aLayoutManagerName
);
1164 a
>>= xLayoutManager
;
1165 if ( xLayoutManager
.is() )
1167 xLayoutManager
->lock();
1168 if( pCurWin
->IsA( TYPE( DialogWindow
) ) )
1170 xLayoutManager
->destroyElement( aMacroBarResName
);
1172 xLayoutManager
->requestElement( aDialogBarResName
);
1173 xLayoutManager
->requestElement( aInsertControlsBarResName
);
1177 xLayoutManager
->destroyElement( aDialogBarResName
);
1178 xLayoutManager
->destroyElement( aInsertControlsBarResName
);
1180 xLayoutManager
->requestElement( aMacroBarResName
);
1182 xLayoutManager
->unlock();
1187 IDEBaseWindow
* BasicIDEShell::FindApplicationWindow()
1189 return FindWindow( ScriptDocument::getApplicationScriptDocument() );
1192 IDEBaseWindow
* BasicIDEShell::FindWindow( const ScriptDocument
& rDocument
, const String
& rLibName
, const String
& rName
, USHORT nType
, BOOL bFindSuspended
)
1194 IDEBaseWindow
* pWin
= aIDEWindowTable
.First();
1197 if ( !pWin
->IsSuspended() || bFindSuspended
)
1199 if ( !rLibName
.Len() || !rName
.Len() || nType
== BASICIDE_TYPE_UNKNOWN
)
1201 // return any non-suspended window
1204 else if ( pWin
->IsDocument( rDocument
) )
1206 OSL_TRACE("FindWindow pWin->GetLibName() %s rLibName %s",
1207 rtl::OUStringToOString( pWin
->GetLibName(), RTL_TEXTENCODING_UTF8
).getStr(),
1208 rtl::OUStringToOString( rLibName
, RTL_TEXTENCODING_UTF8
).getStr() );
1209 OSL_TRACE("pWin->pWin->IsA( TYPE( ModulWindow ) %d && nType %d = BASICIDE_TYPE_MODULE %d", pWin
->IsA( TYPE( ModulWindow
) ), nType
, BASICIDE_TYPE_MODULE
);
1210 OSL_TRACE("pWin->pWin->IsA( TYPE( DialogWindow ) %d && nType %d = BASICIDE_TYPE_DIALOG %d", pWin
->IsA( TYPE( DialogWindow
) ), nType
, BASICIDE_TYPE_DIALOG
);
1211 if ( pWin
->GetLibName() == rLibName
&& pWin
->GetName() == rName
&&
1212 ( ( pWin
->IsA( TYPE( ModulWindow
) ) && nType
== BASICIDE_TYPE_MODULE
) ||
1213 ( pWin
->IsA( TYPE( DialogWindow
) ) && nType
== BASICIDE_TYPE_DIALOG
) ) )
1217 pWin
= aIDEWindowTable
.Next();
1222 long BasicIDEShell::CallBasicErrorHdl( StarBASIC
* pBasic
)
1225 ModulWindow
* pModWin
= ShowActiveModuleWindow( pBasic
);
1227 nRet
= pModWin
->BasicErrorHdl( pBasic
);
1231 long BasicIDEShell::CallBasicBreakHdl( StarBASIC
* pBasic
)
1234 ModulWindow
* pModWin
= ShowActiveModuleWindow( pBasic
);
1237 BOOL bAppWindowDisabled
, bDispatcherLocked
;
1239 SfxUInt16Item
*pSWActionCount
, *pSWLockViewCount
;
1240 BasicIDE::BasicStopped( &bAppWindowDisabled
, &bDispatcherLocked
,
1241 &nWaitCount
, &pSWActionCount
, &pSWLockViewCount
);
1243 nRet
= pModWin
->BasicBreakHdl( pBasic
);
1245 if ( StarBASIC::IsRunning() ) // Falls abgebrochen...
1247 if ( bAppWindowDisabled
)
1248 Application::GetDefDialogParent()->Enable( FALSE
);
1250 if ( bDispatcherLocked )
1251 SFX_APP()->LockDispatcher( TRUE );
1255 BasicIDEShell
* pIDEShell
= IDE_DLL()->GetShell();
1256 for ( USHORT n
= 0; n
< nWaitCount
; n
++ )
1257 pIDEShell
->GetViewFrame()->GetWindow().EnterWait();
1264 ModulWindow
* BasicIDEShell::ShowActiveModuleWindow( StarBASIC
* pBasic
)
1266 SetCurLib( ScriptDocument::getApplicationScriptDocument(), String(), false );
1268 SbModule
* pActiveModule
= StarBASIC::GetActiveModule();
1269 SbClassModuleObject
* pClassModuleObject
= PTR_CAST(SbClassModuleObject
,pActiveModule
);
1270 if( pClassModuleObject
!= NULL
)
1271 pActiveModule
= pClassModuleObject
->getClassModule();
1273 DBG_ASSERT( pActiveModule
, "Kein aktives Modul im ErrorHdl?!" );
1274 if ( pActiveModule
)
1276 ModulWindow
* pWin
= 0;
1277 SbxObject
* pParent
= pActiveModule
->GetParent();
1278 DBG_ASSERT( pParent
&& pParent
->ISA( StarBASIC
), "Kein BASIC!" );
1279 StarBASIC
* pLib
= static_cast< StarBASIC
* >( pParent
);
1282 BasicManager
* pBasMgr
= BasicIDE::FindBasicManager( pLib
);
1285 ScriptDocument
aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr
) );
1286 String aLibName
= pLib
->GetName();
1287 pWin
= FindBasWin( aDocument
, aLibName
, pActiveModule
->GetName(), TRUE
);
1288 DBG_ASSERT( pWin
, "Error/Step-Hdl: Fenster wurde nicht erzeugt/gefunden!" );
1289 SetCurLib( aDocument
, aLibName
);
1290 SetCurWindow( pWin
, TRUE
);
1293 BasicManager
* pBasicMgr
= BasicIDE::FindBasicManager( pBasic
);
1295 StartListening( *pBasicMgr
, TRUE
/* Nur einmal anmelden */ );
1301 void __EXPORT
BasicIDEShell::AdjustPosSizePixel( const Point
&rPos
, const Size
&rSize
)
1303 // Nicht wenn minimiert, weil dann bei Restore der Text verschoben ist.
1304 if ( GetViewFrame()->GetWindow().GetOutputSizePixel().Height() == 0 )
1308 // long nScrollbarWidthPixel = aVScrollBar.GetSizePixel().Width();
1309 Size
aScrollBarBoxSz( aScrollBarBox
.GetSizePixel() );
1310 aSz
.Height() -= aScrollBarBoxSz
.Height();
1313 aSz
.Width() -= aScrollBarBoxSz
.Width();
1314 aScrollBarBox
.SetPosPixel( Point( rSize
.Width() - aScrollBarBoxSz
.Width(), rSize
.Height() - aScrollBarBoxSz
.Height() ) );
1315 aVScrollBar
.SetPosSizePixel( Point( rPos
.X()+aSz
.Width(), rPos
.Y() ), Size( aScrollBarBoxSz
.Width(), aSz
.Height() ) );
1316 if ( bTabBarSplitted
)
1318 // SplitSize ist beim Resize 0 !
1319 long nSplitPos
= pTabBar
->GetSizePixel().Width();
1320 if ( nSplitPos
> aSz
.Width() )
1321 nSplitPos
= aSz
.Width();
1322 pTabBar
->SetPosSizePixel( Point( rPos
.X(), rPos
.Y()+aSz
.Height() ), Size( nSplitPos
, aScrollBarBoxSz
.Height() ) );
1323 long nScrlStart
= rPos
.X() + nSplitPos
;
1324 aHScrollBar
.SetPosSizePixel( Point( nScrlStart
, rPos
.Y()+aSz
.Height() ), Size( aSz
.Width() - nScrlStart
+ 1, aScrollBarBoxSz
.Height() ) );
1325 aHScrollBar
.Update();
1329 aHScrollBar
.SetPosSizePixel( Point( rPos
.X()+ aSz
.Width()/2 - 1, rPos
.Y()+aSz
.Height() ), Size( aSz
.Width()/2 + 2, aScrollBarBoxSz
.Height() ) );
1330 pTabBar
->SetPosSizePixel( Point( rPos
.X(), rPos
.Y()+aSz
.Height() ), Size( aSz
.Width()/2, aScrollBarBoxSz
.Height() ) );
1333 Window
* pEdtWin
= pCurWin
? pCurWin
->GetLayoutWindow() : pModulLayout
;
1336 if( pCurWin
&& pCurWin
->IsA( TYPE( DialogWindow
) ) )
1337 pEdtWin
->SetPosSizePixel( rPos
, aSz
); // Ohne ScrollBar
1339 pEdtWin
->SetPosSizePixel( rPos
, aOutSz
);
1343 Reference
< XModel
> BasicIDEShell::GetCurrentDocument() const
1345 Reference
< XModel
> xDocument
;
1346 if ( pCurWin
&& pCurWin
->GetDocument().isDocument() )
1347 xDocument
= pCurWin
->GetDocument().getDocument();
1351 void __EXPORT
BasicIDEShell::Activate( BOOL bMDI
)
1353 SfxViewShell::Activate( bMDI
);
1357 if( pCurWin
&& pCurWin
->IsA( TYPE( DialogWindow
) ) )
1358 ((DialogWindow
*)pCurWin
)->UpdateBrowser();
1360 ShowObjectDialog( TRUE
, FALSE
);
1364 void __EXPORT
BasicIDEShell::Deactivate( BOOL bMDI
)
1366 // bMDI TRUE heisst, dass ein anderes MDI aktiviert wurde, bei einem
1367 // Deactivate durch eine MessageBox ist bMDI FALSE
1370 if( pCurWin
&& pCurWin
->IsA( TYPE( DialogWindow
) ) )
1372 DialogWindow
* pXDlgWin
= (DialogWindow
*)pCurWin
;
1373 pXDlgWin
->DisableBrowser();
1374 if( pXDlgWin
->IsModified() )
1375 BasicIDE::MarkDocumentModified( pXDlgWin
->GetDocument() );
1378 // CanClose pruefen, damit auch beim deaktivieren der BasicIDE geprueft wird,
1379 // ob in einem Modul der Sourcecode zu gross ist...
1380 for ( ULONG nWin
= 0; nWin
< aIDEWindowTable
.Count(); nWin
++ )
1382 IDEBaseWindow
* pWin
= aIDEWindowTable
.GetObject( nWin
);
1383 if ( /* !pWin->IsSuspended() && */ !pWin
->CanClose() )
1385 if ( m_aCurLibName
.Len() && ( pWin
->IsDocument( m_aCurDocument
) || pWin
->GetLibName() != m_aCurLibName
) )
1386 SetCurLib( ScriptDocument::getApplicationScriptDocument(), String(), false );
1387 SetCurWindow( pWin
, TRUE
);
1392 ShowObjectDialog( FALSE
, FALSE
);
1397 IMPL_LINK( BasicIDEShell
, AccelSelectHdl
, Accelerator
*, pAccel
)
1400 SfxViewFrame
* pViewFrame
= GetViewFrame();
1401 SfxDispatcher
* pDispatcher
= pViewFrame
? pViewFrame
->GetDispatcher() : NULL
;
1404 switch ( pAccel
->GetCurKeyCode().GetCode() )
1407 if ( pAccel
->GetCurKeyCode().IsShift() )
1408 pDispatcher
->Execute( SID_BASICSTOP
, SFX_CALLMODE_SYNCHRON
);
1410 pDispatcher
->Execute( SID_BASICRUN
, SFX_CALLMODE_SYNCHRON
);
1413 pDispatcher
->Execute( SID_BASICIDE_ADDWATCH
, SFX_CALLMODE_SYNCHRON
);
1416 if ( pAccel
->GetCurKeyCode().IsShift() )
1417 pDispatcher
->Execute( SID_BASICSTEPOVER
, SFX_CALLMODE_SYNCHRON
);
1419 pDispatcher
->Execute( SID_BASICSTEPINTO
, SFX_CALLMODE_SYNCHRON
);
1422 if ( pAccel
->GetCurKeyCode().IsShift() )
1423 pDispatcher
->Execute( SID_BASICIDE_TOGGLEBRKPNTENABLED
, SFX_CALLMODE_SYNCHRON
);
1425 pDispatcher
->Execute( SID_BASICIDE_TOGGLEBRKPNT
, SFX_CALLMODE_SYNCHRON
);
1427 default: bDone
= FALSE
;