1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <strings.hrc>
24 #include "baside2.hxx"
25 #include <baside3.hxx>
26 #include <docsignature.hxx>
27 #include <iderdll.hxx>
28 #include "iderdll2.hxx"
29 #include <localizationmgr.hxx>
30 #include <managelang.hxx>
32 #include <basic/basmgr.hxx>
33 #include <basic/sbmeth.hxx>
34 #include <com/sun/star/script/ModuleType.hpp>
35 #include <com/sun/star/script/XLibraryContainerPassword.hpp>
36 #include <com/sun/star/frame/XLayoutManager.hpp>
37 #include <sfx2/childwin.hxx>
38 #include <sfx2/docfac.hxx>
39 #include <sfx2/dinfdlg.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <sfx2/minfitem.hxx>
42 #include <sfx2/printer.hxx>
43 #include <sfx2/request.hxx>
44 #include <svx/svxids.hrc>
45 #include <svl/aeitem.hxx>
46 #include <svl/intitem.hxx>
47 #include <svl/visitem.hxx>
48 #include <svl/whiter.hxx>
49 #include <vcl/xtextedt.hxx>
50 #include <vcl/svapp.hxx>
51 #include <vcl/weld.hxx>
56 using namespace ::com::sun::star
;
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::frame
;
60 void Shell::ExecuteSearch( SfxRequest
& rReq
)
65 const SfxItemSet
* pArgs
= rReq
.GetArgs();
66 sal_uInt16 nSlot
= rReq
.GetSlot();
68 // if searching has not been done before this time
69 if (nSlot
== SID_BASICIDE_REPEAT_SEARCH
&& !mpSearchItem
)
71 rReq
.SetReturnValue(SfxBoolItem(nSlot
, false));
77 case SID_SEARCH_OPTIONS
:
80 mpSearchItem
.reset( static_cast<SvxSearchItem
*>( pArgs
->Get(SID_SEARCH_ITEM
).Clone() ));
84 GetViewFrame()->GetBindings().Invalidate(SID_SEARCH_ITEM
);
86 case SID_BASICIDE_REPEAT_SEARCH
:
89 if (!pCurWin
->HasActiveEditor())
92 // If it is a repeat searching
93 if ( nSlot
== SID_BASICIDE_REPEAT_SEARCH
)
96 mpSearchItem
.reset( new SvxSearchItem( SID_SEARCH_ITEM
));
100 // Get SearchItem from request if it is the first searching
103 mpSearchItem
.reset( static_cast<SvxSearchItem
*>( pArgs
->Get( SID_SEARCH_ITEM
).Clone() ));
107 sal_Int32 nFound
= 0;
109 if ( mpSearchItem
->GetCommand() == SvxSearchCmd::REPLACE_ALL
)
111 sal_uInt16 nActModWindows
= 0;
112 for (auto const& window
: aWindowTable
)
114 BaseWindow
* pWin
= window
.second
;
115 if (pWin
->HasActiveEditor())
119 bool bAllModules
= nActModWindows
<= 1;
122 std::unique_ptr
<weld::MessageDialog
> xQueryBox(Application::CreateMessageDialog(pCurWin
? pCurWin
->GetFrameWeld() : nullptr,
123 VclMessageType::Question
, VclButtonsType::YesNo
,
124 IDEResId(RID_STR_SEARCHALLMODULES
)));
125 xQueryBox
->set_default_response(RET_YES
);
126 bAllModules
= xQueryBox
->run() == RET_YES
;
131 for (auto const& window
: aWindowTable
)
133 BaseWindow
* pWin
= window
.second
;
134 nFound
+= pWin
->StartSearchAndReplace( *mpSearchItem
);
138 nFound
= pCurWin
->StartSearchAndReplace( *mpSearchItem
);
140 OUString
aReplStr(IDEResId(RID_STR_SEARCHREPLACES
));
141 aReplStr
= aReplStr
.replaceAll("XX", OUString::number(nFound
));
143 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(pCurWin
->GetFrameWeld(),
144 VclMessageType::Info
, VclButtonsType::Ok
,
150 bool bCanceled
= false;
151 nFound
= pCurWin
->StartSearchAndReplace( *mpSearchItem
);
152 if ( !nFound
&& !mpSearchItem
->GetSelection() )
154 // search other modules...
155 bool bChangeCurWindow
= false;
157 for (it
= aWindowTable
.begin(); it
!= aWindowTable
.end(); ++it
)
158 if (it
->second
== pCurWin
)
160 if (it
!= aWindowTable
.end())
162 BaseWindow
* pWin
= it
!= aWindowTable
.end() ? it
->second
.get() : nullptr;
164 bool bSearchedFromStart
= false;
165 while ( !nFound
&& !bCanceled
&& ( pWin
|| !bSearchedFromStart
) )
169 SfxViewFrame
* pViewFrame
= GetViewFrame();
170 SfxChildWindow
* pChildWin
= pViewFrame
? pViewFrame
->GetChildWindow( SID_SEARCH_DLG
) : nullptr;
171 vcl::Window
* pParent
= pChildWin
? pChildWin
->GetWindow() : nullptr;
173 std::unique_ptr
<weld::MessageDialog
> xQueryBox(Application::CreateMessageDialog(pParent
? pParent
->GetFrameWeld() : nullptr,
174 VclMessageType::Question
, VclButtonsType::YesNo
,
175 IDEResId(RID_STR_SEARCHFROMSTART
)));
176 xQueryBox
->set_default_response(RET_YES
);
177 if (xQueryBox
->run() == RET_YES
)
179 it
= aWindowTable
.begin();
180 if ( it
!= aWindowTable
.end() )
182 bSearchedFromStart
= true;
188 if (pWin
&& pWin
->HasActiveEditor())
190 if ( pWin
!= pCurWin
)
193 pWin
->SetSizePixel( pCurWin
->GetSizePixel() );
194 nFound
= pWin
->StartSearchAndReplace( *mpSearchItem
, true );
198 bChangeCurWindow
= true;
202 if ( pWin
&& ( pWin
!= pCurWin
) )
204 if ( it
!= aWindowTable
.end() )
206 pWin
= it
!= aWindowTable
.end() ? it
->second
.get() : nullptr;
211 if ( !nFound
&& bSearchedFromStart
)
212 nFound
= pCurWin
->StartSearchAndReplace( *mpSearchItem
, true );
213 if ( bChangeCurWindow
)
214 SetCurWindow( pWin
, true );
216 if ( !nFound
&& !bCanceled
)
218 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(pCurWin
->GetFrameWeld(),
219 VclMessageType::Info
, VclButtonsType::Ok
,
220 IDEResId(RID_STR_SEARCHNOTFOUND
)));
229 pCurWin
->ExecuteCommand( rReq
);
233 void Shell::ExecuteCurrent( SfxRequest
& rReq
)
238 switch ( rReq
.GetSlot() )
240 case SID_BASICIDE_HIDECURPAGE
:
242 pCurWin
->StoreData();
243 RemoveWindow( pCurWin
, false );
246 case SID_BASICIDE_RENAMECURRENT
:
248 pTabBar
->StartEditMode( pTabBar
->GetCurPageId() );
253 if ( GetUndoManager() && pCurWin
->AllowUndo() )
254 GetViewFrame()->ExecuteSlot( rReq
);
257 pCurWin
->ExecuteCommand( rReq
);
261 // no matter who's at the top, influence on the shell:
262 void Shell::ExecuteGlobal( SfxRequest
& rReq
)
264 sal_uInt16 nSlot
= rReq
.GetSlot();
269 // maybe do not simply stop if on breakpoint!
270 if (ModulWindow
* pMCurWin
= dynamic_cast<ModulWindow
*>(pCurWin
.get()))
271 pMCurWin
->BasicStop();
280 // rewrite date into the BASIC
281 StoreAllWindowData();
284 ScriptDocument
aDocument( pCurWin
->GetDocument() );
285 if ( aDocument
.isDocument() )
287 uno::Reference
< task::XStatusIndicator
> xStatusIndicator
;
289 const SfxUnoAnyItem
* pStatusIndicatorItem
= rReq
.GetArg
<SfxUnoAnyItem
>(SID_PROGRESS_STATUSBAR_CONTROL
);
290 if ( pStatusIndicatorItem
)
291 OSL_VERIFY( pStatusIndicatorItem
->GetValue() >>= xStatusIndicator
);
294 // get statusindicator
295 SfxViewFrame
*pFrame_
= GetFrame();
298 uno::Reference
< task::XStatusIndicatorFactory
> xStatFactory(
299 pFrame_
->GetFrame().GetFrameInterface(),
301 if( xStatFactory
.is() )
302 xStatusIndicator
= xStatFactory
->createStatusIndicator();
305 if ( xStatusIndicator
.is() )
306 rReq
.AppendItem( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL
, uno::Any( xStatusIndicator
) ) );
309 aDocument
.saveDocument( xStatusIndicator
);
312 if (SfxBindings
* pBindings
= GetBindingsPtr())
314 pBindings
->Invalidate( SID_DOC_MODIFIED
);
315 pBindings
->Invalidate( SID_SAVEDOC
);
316 pBindings
->Invalidate( SID_SIGNATURE
);
321 case SID_BASICIDE_MODULEDLG
:
323 if ( rReq
.GetArgs() )
325 const SfxUInt16Item
&rTabId
= rReq
.GetArgs()->Get(SID_BASICIDE_ARG_TABID
);
326 Organize( rTabId
.GetValue() );
332 case SID_BASICIDE_CHOOSEMACRO
:
334 ChooseMacro( nullptr );
337 case SID_BASICIDE_CREATEMACRO
:
338 case SID_BASICIDE_EDITMACRO
:
340 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
341 const SfxMacroInfoItem
& rInfo
= rReq
.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO
);
342 BasicManager
* pBasMgr
= const_cast<BasicManager
*>(rInfo
.GetBasicManager());
343 DBG_ASSERT( pBasMgr
, "Nothing selected in basic tree?" );
345 ScriptDocument
aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr
) );
347 StartListening(*pBasMgr
, DuplicateHandling::Prevent
/* log on only once */);
348 OUString
aLibName( rInfo
.GetLib() );
349 if ( aLibName
.isEmpty() )
350 aLibName
= "Standard" ;
351 StarBASIC
* pBasic
= pBasMgr
->GetLib( aLibName
);
354 // load module and dialog library (if not loaded)
355 aDocument
.loadLibraryIfExists( E_SCRIPTS
, aLibName
);
356 aDocument
.loadLibraryIfExists( E_DIALOGS
, aLibName
);
359 pBasic
= pBasMgr
->GetLib( aLibName
);
361 DBG_ASSERT( pBasic
, "No Basic!" );
363 SetCurLib( aDocument
, aLibName
);
365 if ( pBasic
&& rReq
.GetSlot() == SID_BASICIDE_CREATEMACRO
)
367 SbModule
* pModule
= pBasic
->FindModule( rInfo
.GetModule() );
370 if ( !rInfo
.GetModule().isEmpty() || pBasic
->GetModules().empty() )
372 const OUString
& aModName
= rInfo
.GetModule();
374 OUString sModuleCode
;
375 if ( aDocument
.createModule( aLibName
, aModName
, false, sModuleCode
) )
376 pModule
= pBasic
->FindModule( aModName
);
379 pModule
= pBasic
->GetModules().front().get();
381 DBG_ASSERT( pModule
, "No Module!" );
382 if ( pModule
&& !pModule
->GetMethods()->Find( rInfo
.GetMethod(), SbxClassType::Method
) )
383 CreateMacro( pModule
, rInfo
.GetMethod() );
385 SfxViewFrame
* pViewFrame
= GetViewFrame();
388 VclPtr
<ModulWindow
> pWin
= FindBasWin( aDocument
, aLibName
, rInfo
.GetModule(), true );
389 DBG_ASSERT( pWin
, "Edit/Create Macro: Window was not created/found!" );
390 SetCurWindow( pWin
, true );
391 pWin
->EditMacro( rInfo
.GetMethod() );
395 case SID_BASICIDE_OBJCAT
:
396 // toggling object catalog
397 aObjectCatalog
->Show(!aObjectCatalog
->IsVisible());
399 pLayout
->ArrangeWindows();
400 // refresh the button state
401 if (SfxBindings
* pBindings
= GetBindingsPtr())
402 pBindings
->Invalidate(SID_BASICIDE_OBJCAT
);
405 case SID_BASICIDE_NAMECHANGEDONTAB
:
407 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
408 const SfxUInt16Item
&rTabId
= rReq
.GetArgs()->Get(SID_BASICIDE_ARG_TABID
);
409 const SfxStringItem
&rModName
= rReq
.GetArgs()->Get(SID_BASICIDE_ARG_MODULENAME
);
410 if ( aWindowTable
.find( rTabId
.GetValue() ) != aWindowTable
.end() )
412 VclPtr
<BaseWindow
> pWin
= aWindowTable
[ rTabId
.GetValue() ];
413 const OUString
& aNewName( rModName
.GetValue() );
414 OUString
aOldName( pWin
->GetName() );
415 if ( aNewName
!= aOldName
)
417 bool bRenameOk
= false;
418 if (ModulWindow
* pModWin
= dynamic_cast<ModulWindow
*>(pWin
.get()))
420 OUString aLibName
= pModWin
->GetLibName();
421 ScriptDocument
aDocument( pWin
->GetDocument() );
423 if (RenameModule(pModWin
->GetFrameWeld(), aDocument
, aLibName
, aOldName
, aNewName
))
426 // Because we listen for container events for script
427 // modules, rename will delete the 'old' window
428 // pWin has been invalidated, restore now
429 pWin
= FindBasWin( aDocument
, aLibName
, aNewName
, true );
433 else if (DialogWindow
* pDlgWin
= dynamic_cast<DialogWindow
*>(pWin
.get()))
435 bRenameOk
= pDlgWin
->RenameDialog( aNewName
);
439 MarkDocumentModified( pWin
->GetDocument() );
443 // set old name in TabWriter
444 sal_uInt16 nId
= GetWindowId( pWin
);
445 DBG_ASSERT( nId
, "No entry in Tabbar!" );
447 pTabBar
->SetPageText( nId
, aOldName
);
451 // set focus to current window
456 case SID_BASICIDE_STOREMODULESOURCE
:
457 case SID_BASICIDE_UPDATEMODULESOURCE
:
459 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
460 const SfxMacroInfoItem
& rInfo
= rReq
.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO
);
461 BasicManager
* pBasMgr
= const_cast<BasicManager
*>(rInfo
.GetBasicManager());
462 DBG_ASSERT( pBasMgr
, "Store source: No BasMgr?" );
463 ScriptDocument
aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr
) );
464 VclPtr
<ModulWindow
> pWin
= FindBasWin( aDocument
, rInfo
.GetLib(), rInfo
.GetModule(), false, true );
467 if ( rReq
.GetSlot() == SID_BASICIDE_STOREMODULESOURCE
)
474 case SID_BASICIDE_STOREALLMODULESOURCES
:
475 case SID_BASICIDE_UPDATEALLMODULESOURCES
:
477 for (auto const& window
: aWindowTable
)
479 BaseWindow
* pWin
= window
.second
;
480 if (!pWin
->IsSuspended() && dynamic_cast<ModulWindow
*>(pWin
))
482 if ( rReq
.GetSlot() == SID_BASICIDE_STOREALLMODULESOURCES
)
490 case SID_BASICIDE_LIBSELECTED
:
491 case SID_BASICIDE_LIBREMOVED
:
492 case SID_BASICIDE_LIBLOADED
:
494 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
495 const SfxUnoAnyItem
& rShellItem
= rReq
.GetArgs()->Get( SID_BASICIDE_ARG_DOCUMENT_MODEL
);
496 uno::Reference
< frame::XModel
> xModel( rShellItem
.GetValue(), UNO_QUERY
);
497 ScriptDocument
aDocument( xModel
.is() ? ScriptDocument( xModel
) : ScriptDocument::getApplicationScriptDocument() );
498 const SfxStringItem
& rLibNameItem
= rReq
.GetArgs()->Get( SID_BASICIDE_ARG_LIBNAME
);
499 const OUString
& aLibName( rLibNameItem
.GetValue() );
501 if ( nSlot
== SID_BASICIDE_LIBSELECTED
)
503 // load module and dialog library (if not loaded)
504 aDocument
.loadLibraryIfExists( E_SCRIPTS
, aLibName
);
505 aDocument
.loadLibraryIfExists( E_DIALOGS
, aLibName
);
507 // check password, if library is password protected and not verified
509 Reference
< script::XLibraryContainer
> xModLibContainer( aDocument
.getLibraryContainer( E_SCRIPTS
) );
510 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aLibName
) )
512 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContainer
, UNO_QUERY
);
513 if ( xPasswd
.is() && xPasswd
->isLibraryPasswordProtected( aLibName
) && !xPasswd
->isLibraryPasswordVerified( aLibName
) )
516 bOK
= QueryPassword( xModLibContainer
, aLibName
, aPassword
);
522 SetCurLib( aDocument
, aLibName
, true, false );
526 // adjust old value...
527 if (SfxBindings
* pBindings
= GetBindingsPtr())
528 pBindings
->Invalidate(SID_BASICIDE_LIBSELECTOR
, true);
531 else if ( nSlot
== SID_BASICIDE_LIBREMOVED
)
533 if ( m_aCurLibName
.isEmpty() || ( aDocument
== m_aCurDocument
&& aLibName
== m_aCurLibName
) )
535 RemoveWindows( aDocument
, aLibName
);
536 if ( aDocument
== m_aCurDocument
&& aLibName
== m_aCurLibName
)
538 m_aCurDocument
= ScriptDocument::getApplicationScriptDocument();
539 m_aCurLibName
.clear();
541 if (SfxBindings
* pBindings
= GetBindingsPtr())
542 pBindings
->Invalidate( SID_BASICIDE_LIBSELECTOR
);
550 case SID_BASICIDE_NEWMODULE
:
552 VclPtr
<ModulWindow
> pWin
= CreateBasWin( m_aCurDocument
, m_aCurLibName
, OUString() );
553 DBG_ASSERT( pWin
, "New Module: Could not create window!" );
554 SetCurWindow( pWin
, true );
557 case SID_BASICIDE_NEWDIALOG
:
559 VclPtr
<DialogWindow
> pWin
= CreateDlgWin( m_aCurDocument
, m_aCurLibName
, OUString() );
560 DBG_ASSERT( pWin
, "New Module: Could not create window!" );
561 SetCurWindow( pWin
, true );
564 case SID_BASICIDE_SBXRENAMED
:
566 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
569 case SID_BASICIDE_SBXINSERTED
:
571 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
572 const SbxItem
& rSbxItem
= rReq
.GetArgs()->Get(SID_BASICIDE_ARG_SBX
);
573 const ScriptDocument
& aDocument( rSbxItem
.GetDocument() );
574 const OUString
& aLibName( rSbxItem
.GetLibName() );
575 const OUString
& aName( rSbxItem
.GetName() );
576 if ( m_aCurLibName
.isEmpty() || ( aDocument
== m_aCurDocument
&& aLibName
== m_aCurLibName
) )
578 if ( rSbxItem
.GetType() == TYPE_MODULE
)
579 FindBasWin( aDocument
, aLibName
, aName
, true );
580 else if ( rSbxItem
.GetType() == TYPE_DIALOG
)
581 FindDlgWin( aDocument
, aLibName
, aName
, true );
585 case SID_BASICIDE_SBXDELETED
:
587 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
588 const SbxItem
& rSbxItem
= rReq
.GetArgs()->Get(SID_BASICIDE_ARG_SBX
);
589 const ScriptDocument
& aDocument( rSbxItem
.GetDocument() );
590 VclPtr
<BaseWindow
> pWin
= FindWindow( aDocument
, rSbxItem
.GetLibName(), rSbxItem
.GetName(), rSbxItem
.GetType(), true );
592 RemoveWindow( pWin
, true );
595 case SID_BASICIDE_SHOWSBX
:
597 DBG_ASSERT( rReq
.GetArgs(), "arguments expected" );
598 const SbxItem
& rSbxItem
= rReq
.GetArgs()->Get(SID_BASICIDE_ARG_SBX
);
599 const ScriptDocument
& aDocument( rSbxItem
.GetDocument() );
600 const OUString
& aLibName( rSbxItem
.GetLibName() );
601 const OUString
& aName( rSbxItem
.GetName() );
602 SetCurLib( aDocument
, aLibName
);
603 BaseWindow
* pWin
= nullptr;
604 if ( rSbxItem
.GetType() == TYPE_DIALOG
)
606 pWin
= FindDlgWin( aDocument
, aLibName
, aName
, true );
608 else if ( rSbxItem
.GetType() == TYPE_MODULE
)
610 pWin
= FindBasWin( aDocument
, aLibName
, aName
, true );
612 else if ( rSbxItem
.GetType() == TYPE_METHOD
)
614 pWin
= FindBasWin( aDocument
, aLibName
, aName
, true );
615 static_cast<ModulWindow
*>(pWin
)->EditMacro( rSbxItem
.GetMethodName() );
617 DBG_ASSERT( pWin
, "Window was not created!" );
618 SetCurWindow( pWin
, true );
619 pTabBar
->MakeVisible( pTabBar
->GetCurPageId() );
622 case SID_BASICIDE_SHOWWINDOW
:
624 std::unique_ptr
< ScriptDocument
> pDocument
;
626 const SfxStringItem
* pDocumentItem
= rReq
.GetArg
<SfxStringItem
>(SID_BASICIDE_ARG_DOCUMENT
);
629 OUString sDocumentCaption
= pDocumentItem
->GetValue();
630 if ( !sDocumentCaption
.isEmpty() )
631 pDocument
.reset( new ScriptDocument( ScriptDocument::getDocumentWithURLOrCaption( sDocumentCaption
) ) );
634 const SfxUnoAnyItem
* pDocModelItem
= rReq
.GetArg
<SfxUnoAnyItem
>(SID_BASICIDE_ARG_DOCUMENT_MODEL
);
635 if ( !pDocument
.get() && pDocModelItem
)
637 uno::Reference
< frame::XModel
> xModel( pDocModelItem
->GetValue(), UNO_QUERY
);
639 pDocument
.reset( new ScriptDocument( xModel
) );
642 if ( !pDocument
.get() )
645 const SfxStringItem
* pLibNameItem
= rReq
.GetArg
<SfxStringItem
>(SID_BASICIDE_ARG_LIBNAME
);
649 OUString
aLibName( pLibNameItem
->GetValue() );
650 pDocument
->loadLibraryIfExists( E_SCRIPTS
, aLibName
);
651 SetCurLib( *pDocument
, aLibName
);
652 const SfxStringItem
* pNameItem
= rReq
.GetArg
<SfxStringItem
>(SID_BASICIDE_ARG_NAME
);
655 OUString
aName( pNameItem
->GetValue() );
656 OUString
aModType( "Module" );
657 OUString
aType( aModType
);
658 const SfxStringItem
* pTypeItem
= rReq
.GetArg
<SfxStringItem
>(SID_BASICIDE_ARG_TYPE
);
660 aType
= pTypeItem
->GetValue();
662 BaseWindow
* pWin
= nullptr;
663 if ( aType
== aModType
)
664 pWin
= FindBasWin( *pDocument
, aLibName
, aName
);
665 else if ( aType
== "Dialog" )
666 pWin
= FindDlgWin( *pDocument
, aLibName
, aName
);
670 SetCurWindow( pWin
, true );
672 pTabBar
->MakeVisible( pTabBar
->GetCurPageId() );
674 if (ModulWindow
* pModWin
= dynamic_cast<ModulWindow
*>(pWin
))
676 const SfxUInt32Item
* pLineItem
= rReq
.GetArg
<SfxUInt32Item
>(SID_BASICIDE_ARG_LINE
);
679 pModWin
->AssertValidEditEngine();
680 TextView
* pTextView
= pModWin
->GetEditView();
683 TextEngine
* pTextEngine
= pTextView
->GetTextEngine();
686 sal_uInt32 nLine
= pLineItem
->GetValue();
687 sal_uInt32 nLineCount
= 0;
688 for ( sal_uInt32 i
= 0, nCount
= pTextEngine
->GetParagraphCount(); i
< nCount
; ++i
)
689 nLineCount
+= pTextEngine
->GetLineCount( i
);
690 if ( nLine
> nLineCount
)
695 // scroll window and set selection
696 long nVisHeight
= pModWin
->GetOutputSizePixel().Height();
697 long nTextHeight
= pTextEngine
->GetTextHeight();
698 if ( nTextHeight
> nVisHeight
)
700 long nMaxY
= nTextHeight
- nVisHeight
;
701 long nOldY
= pTextView
->GetStartDocPos().Y();
702 long nNewY
= nLine
* pTextEngine
->GetCharHeight() - nVisHeight
/ 2;
703 nNewY
= std::min( nNewY
, nMaxY
);
704 pTextView
->Scroll( 0, -( nNewY
- nOldY
) );
705 pTextView
->ShowCursor( false );
706 pModWin
->GetEditVScrollBar().SetThumbPos( pTextView
->GetStartDocPos().Y() );
708 sal_uInt16 nCol1
= 0, nCol2
= 0;
709 const SfxUInt16Item
* pCol1Item
= rReq
.GetArg
<SfxUInt16Item
>(SID_BASICIDE_ARG_COLUMN1
);
712 nCol1
= pCol1Item
->GetValue();
717 const SfxUInt16Item
* pCol2Item
= rReq
.GetArg
<SfxUInt16Item
>(SID_BASICIDE_ARG_COLUMN2
);
720 nCol2
= pCol2Item
->GetValue();
724 TextSelection
aSel( TextPaM( nLine
, nCol1
), TextPaM( nLine
, nCol2
) );
725 pTextView
->SetSelection( aSel
);
726 pTextView
->ShowCursor();
727 vcl::Window
* pWindow_
= pTextView
->GetWindow();
729 pWindow_
->GrabFocus();
740 case SID_BASICIDE_MANAGE_LANG
:
742 ScopedVclPtrInstance
< ManageLanguageDialog
> aDlg(pCurWin
, m_pCurLocalizationMgr
);
750 pLayout
->ExecuteGlobal(rReq
);
752 pCurWin
->ExecuteGlobal(rReq
);
757 void Shell::GetState(SfxItemSet
&rSet
)
759 SfxWhichIter
aIter(rSet
);
760 for ( sal_uInt16 nWh
= aIter
.FirstWhich(); nWh
!= 0; nWh
= aIter
.NextWhich() )
766 rSet
.DisableItem( nWh
);
771 bool bDisable
= false;
775 if ( !pCurWin
->IsModified() )
777 ScriptDocument
aDocument( pCurWin
->GetDocument() );
778 bDisable
= ( !aDocument
.isAlive() )
779 || ( aDocument
.isDocument() ? !aDocument
.isDocumentModified() : !IsAppBasicModified() );
788 rSet
.DisableItem( nWh
);
794 rSet
.DisableItem( nWh
);
799 SignatureState nState
= SignatureState::NOSIGNATURES
;
802 DocumentSignature
aSignature( pCurWin
->GetDocument() );
803 nState
= aSignature
.getScriptingSignatureState();
805 rSet
.Put( SfxUInt16Item( SID_SIGNATURE
, static_cast<sal_uInt16
>(nState
) ) );
808 case SID_BASICIDE_MODULEDLG
:
810 if ( StarBASIC::IsRunning() )
811 rSet
.DisableItem( nWh
);
814 case SID_BASICIDE_OBJCAT
:
816 rSet
.Put(SfxBoolItem(nWh
, aObjectCatalog
->IsVisible()));
818 rSet
.Put(SfxVisibilityItem(nWh
, false));
820 case SID_BASICIDE_SHOWSBX
:
821 case SID_BASICIDE_CREATEMACRO
:
822 case SID_BASICIDE_EDITMACRO
:
823 case SID_BASICIDE_NAMECHANGEDONTAB
:
829 case SID_BASICIDE_ADDWATCH
:
830 case SID_BASICIDE_REMOVEWATCH
:
832 case SID_BASICSAVEAS
:
833 case SID_BASICIDE_MATCHGROUP
:
835 if (!dynamic_cast<ModulWindow
*>(pCurWin
.get()))
836 rSet
.DisableItem( nWh
);
837 else if ( ( nWh
== SID_BASICLOAD
) && ( StarBASIC::IsRunning() || ( pCurWin
&& pCurWin
->IsReadOnly() ) ) )
838 rSet
.DisableItem( nWh
);
842 case SID_BASICSTEPINTO
:
843 case SID_BASICSTEPOVER
:
844 case SID_BASICSTEPOUT
:
845 case SID_BASICIDE_TOGGLEBRKPNT
:
846 case SID_BASICIDE_MANAGEBRKPNTS
:
848 if (ModulWindow
* pMCurWin
= dynamic_cast<ModulWindow
*>(pCurWin
.get()))
850 if (StarBASIC::IsRunning() && !pMCurWin
->GetBasicStatus().bIsInReschedule
)
851 rSet
.DisableItem(nWh
);
854 rSet
.DisableItem( nWh
);
857 case SID_BASICCOMPILE
:
859 if (StarBASIC::IsRunning() || !dynamic_cast<ModulWindow
*>(pCurWin
.get()))
860 rSet
.DisableItem( nWh
);
865 // stop is always possible when some Basic is running...
866 if (!StarBASIC::IsRunning())
867 rSet
.DisableItem( nWh
);
870 case SID_CHOOSE_CONTROLS
:
871 case SID_DIALOG_TESTMODE
:
872 case SID_INSERT_SELECT
:
873 case SID_INSERT_PUSHBUTTON
:
874 case SID_INSERT_RADIOBUTTON
:
875 case SID_INSERT_CHECKBOX
:
876 case SID_INSERT_LISTBOX
:
877 case SID_INSERT_COMBOBOX
:
878 case SID_INSERT_GROUPBOX
:
879 case SID_INSERT_EDIT
:
880 case SID_INSERT_FIXEDTEXT
:
881 case SID_INSERT_IMAGECONTROL
:
882 case SID_INSERT_PROGRESSBAR
:
883 case SID_INSERT_HSCROLLBAR
:
884 case SID_INSERT_VSCROLLBAR
:
885 case SID_INSERT_HFIXEDLINE
:
886 case SID_INSERT_VFIXEDLINE
:
887 case SID_INSERT_DATEFIELD
:
888 case SID_INSERT_TIMEFIELD
:
889 case SID_INSERT_NUMERICFIELD
:
890 case SID_INSERT_CURRENCYFIELD
:
891 case SID_INSERT_FORMATTEDFIELD
:
892 case SID_INSERT_PATTERNFIELD
:
893 case SID_INSERT_FILECONTROL
:
894 case SID_INSERT_SPINBUTTON
:
895 case SID_INSERT_TREECONTROL
:
896 case SID_INSERT_FORM_RADIO
:
897 case SID_INSERT_FORM_CHECK
:
898 case SID_INSERT_FORM_LIST
:
899 case SID_INSERT_FORM_COMBO
:
900 case SID_INSERT_FORM_VSCROLL
:
901 case SID_INSERT_FORM_HSCROLL
:
902 case SID_INSERT_FORM_SPIN
:
904 if (!dynamic_cast<DialogWindow
*>(pCurWin
.get()))
905 rSet
.DisableItem( nWh
);
908 case SID_SEARCH_OPTIONS
:
910 SearchOptionFlags nOptions
= SearchOptionFlags::NONE
;
912 nOptions
= pCurWin
->GetSearchOptions();
913 rSet
.Put( SfxUInt16Item( SID_SEARCH_OPTIONS
, static_cast<sal_uInt16
>(nOptions
) ) );
916 case SID_BASICIDE_LIBSELECTOR
:
919 if ( !m_aCurLibName
.isEmpty() )
921 LibraryLocation eLocation
= m_aCurDocument
.getLibraryLocation( m_aCurLibName
);
922 aName
= CreateMgrAndLibStr( m_aCurDocument
.getTitle( eLocation
), m_aCurLibName
);
924 SfxStringItem
aItem( SID_BASICIDE_LIBSELECTOR
, aName
);
928 case SID_SEARCH_ITEM
:
932 mpSearchItem
.reset( new SvxSearchItem( SID_SEARCH_ITEM
));
933 mpSearchItem
->SetSearchString( GetSelectionText( true ));
936 if ( mbJustOpened
&& HasSelection() )
938 OUString aText
= GetSelectionText( true );
940 if ( !aText
.isEmpty() )
942 mpSearchItem
->SetSearchString( aText
);
943 mpSearchItem
->SetSelection( false );
946 mpSearchItem
->SetSelection( true );
949 mbJustOpened
= false;
950 rSet
.Put( *mpSearchItem
);
953 case SID_BASICIDE_STAT_DATE
:
955 SfxStringItem
aItem( SID_BASICIDE_STAT_DATE
, "Datum?!" );
959 case SID_DOC_MODIFIED
:
961 bool bModified
= false;
965 if ( pCurWin
->IsModified() )
969 ScriptDocument
aDocument( pCurWin
->GetDocument() );
970 bModified
= aDocument
.isDocument() ? aDocument
.isDocumentModified() : IsAppBasicModified();
974 SfxBoolItem
aItem(SID_DOC_MODIFIED
, bModified
);
978 case SID_BASICIDE_STAT_TITLE
:
982 OUString aTitle
= pCurWin
->CreateQualifiedName();
983 SfxStringItem
aItem( SID_BASICIDE_STAT_TITLE
, aTitle
);
988 // are interpreted by the controller:
990 case SID_ATTR_INSERT
:
995 if( GetUndoManager() ) // recursive GetState else
996 GetViewFrame()->GetSlotState( nWh
, nullptr, &rSet
);
999 case SID_BASICIDE_CURRENT_LANG
:
1001 if( (pCurWin
&& pCurWin
->IsReadOnly()) || GetCurLibName().isEmpty() )
1002 rSet
.DisableItem( nWh
);
1006 std::shared_ptr
<LocalizationMgr
> pCurMgr(GetCurLocalizationMgr());
1007 if ( pCurMgr
->isLibraryLocalized() )
1009 Sequence
< lang::Locale
> aLocaleSeq
= pCurMgr
->getStringResourceManager()->getLocales();
1010 const lang::Locale
* pLocale
= aLocaleSeq
.getConstArray();
1011 sal_Int32 i
, nCount
= aLocaleSeq
.getLength();
1013 // Force different results for any combination of locales and default locale
1015 for ( i
= 0; i
<= nCount
; ++i
)
1017 lang::Locale aLocale
;
1019 aLocale
= pLocale
[i
];
1021 aLocale
= pCurMgr
->getStringResourceManager()->getDefaultLocale();
1023 aLangStr
+= aLocale
.Language
+ aLocale
.Country
+ aLocale
.Variant
;
1025 aItemStr
= aLangStr
;
1027 rSet
.Put( SfxStringItem( nWh
, aItemStr
) );
1032 case SID_BASICIDE_MANAGE_LANG
:
1034 if( (pCurWin
&& pCurWin
->IsReadOnly()) || GetCurLibName().isEmpty() )
1035 rSet
.DisableItem( nWh
);
1040 // if this is not a module window hide the
1041 // setting, doesn't make sense for example if the
1042 // dialog editor is open
1043 if (pCurWin
&& !dynamic_cast<ModulWindow
*>(pCurWin
.get()))
1045 rSet
.DisableItem( nWh
);
1046 rSet
.Put(SfxVisibilityItem(nWh
, false));
1050 case SID_BASICIDE_HIDECURPAGE
:
1052 if (pTabBar
->GetPageCount() == 0)
1053 rSet
.DisableItem(nWh
);
1056 case SID_BASICIDE_DELETECURRENT
:
1057 case SID_BASICIDE_RENAMECURRENT
:
1059 if (pTabBar
->GetPageCount() == 0 || StarBASIC::IsRunning())
1060 rSet
.DisableItem(nWh
);
1061 else if (m_aCurDocument
.isInVBAMode())
1063 // disable to delete or rename object modules in IDE
1064 BasicManager
* pBasMgr
= m_aCurDocument
.getBasicManager();
1065 StarBASIC
* pBasic
= pBasMgr
? pBasMgr
->GetLib(m_aCurLibName
) : nullptr;
1066 if (pBasic
&& dynamic_cast<ModulWindow
*>(pCurWin
.get()))
1068 SbModule
* pActiveModule
= pBasic
->FindModule( pCurWin
->GetName() );
1069 if ( pActiveModule
&& ( pActiveModule
->GetModuleType() == script::ModuleType::DOCUMENT
) )
1070 rSet
.DisableItem(nWh
);
1076 case SID_BASICIDE_NEWMODULE
:
1077 case SID_BASICIDE_NEWDIALOG
:
1079 Reference
< script::XLibraryContainer2
> xModLibContainer( m_aCurDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
1080 Reference
< script::XLibraryContainer2
> xDlgLibContainer( m_aCurDocument
.getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
1081 if ( ( xModLibContainer
.is() && xModLibContainer
->hasByName( m_aCurLibName
) && xModLibContainer
->isLibraryReadOnly( m_aCurLibName
) ) ||
1082 ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( m_aCurLibName
) && xDlgLibContainer
->isLibraryReadOnly( m_aCurLibName
) ) )
1083 rSet
.DisableItem(nWh
);
1088 pLayout
->GetState(rSet
, nWh
);
1092 pCurWin
->GetState( rSet
);
1095 bool Shell::HasUIFeature(SfxShellFeature nFeature
) const
1097 assert((nFeature
& ~SfxShellFeature::BasicMask
) == SfxShellFeature::NONE
);
1098 bool bResult
= false;
1100 if (nFeature
& SfxShellFeature::BasicShowBrowser
)
1102 // fade out (in) property browser in module (dialog) windows
1103 if (dynamic_cast<DialogWindow
*>(pCurWin
.get()) && !pCurWin
->IsReadOnly())
1110 void Shell::SetCurWindow( BaseWindow
* pNewWin
, bool bUpdateTabBar
, bool bRememberAsCurrent
)
1112 if ( pNewWin
!= pCurWin
)
1116 pLayout
->Deactivating();
1119 if (pCurWin
->GetType() == TYPE_MODULE
)
1120 pLayout
= pModulLayout
.get();
1122 pLayout
= pDialogLayout
.get();
1123 AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel());
1124 pLayout
->Activating(*pCurWin
);
1125 GetViewFrame()->GetWindow().SetHelpId(pCurWin
->GetHid());
1126 if (bRememberAsCurrent
)
1127 pCurWin
->InsertLibInfo();
1128 if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise
1131 if (!GetExtraData()->ShellInCriticalSection())
1133 vcl::Window
* pFrameWindow
= &GetViewFrame()->GetWindow();
1134 vcl::Window
* pFocusWindow
= Application::GetFocusWindow();
1135 while ( pFocusWindow
&& ( pFocusWindow
!= pFrameWindow
) )
1136 pFocusWindow
= pFocusWindow
->GetParent();
1137 if ( pFocusWindow
) // Focus in BasicIDE
1138 pCurWin
->GrabFocus();
1146 if ( bUpdateTabBar
)
1148 sal_uLong nKey
= GetWindowId( pCurWin
);
1149 if ( pCurWin
&& ( pTabBar
->GetPagePos( static_cast<sal_uInt16
>(nKey
) ) == TAB_PAGE_NOTFOUND
) )
1150 pTabBar
->InsertPage( static_cast<sal_uInt16
>(nKey
), pCurWin
->GetTitle() ); // has just been faded in
1151 pTabBar
->SetCurPageId( static_cast<sal_uInt16
>(nKey
) );
1153 if ( pCurWin
&& pCurWin
->IsSuspended() ) // if the window is shown in the case of an error...
1154 pCurWin
->SetStatus( pCurWin
->GetStatus() & ~BASWIN_SUSPENDED
);
1157 SetWindow( pCurWin
);
1158 if ( pCurWin
->GetDocument().isDocument() )
1159 SfxObjectShell::SetCurrentComponent( pCurWin
->GetDocument().getDocument() );
1164 GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW
);
1165 SfxObjectShell::SetCurrentComponent(nullptr);
1167 aObjectCatalog
->SetCurrentEntry(pCurWin
);
1168 SetUndoManager( pCurWin
? pCurWin
->GetUndoManager() : nullptr );
1169 InvalidateBasicIDESlots();
1170 InvalidateControlSlots();
1171 EnableScrollbars(pCurWin
!= nullptr);
1173 if ( m_pCurLocalizationMgr
)
1174 m_pCurLocalizationMgr
->handleTranslationbar();
1178 // fade out (in) property browser in module (dialog) windows
1183 void Shell::ManageToolbars()
1185 static const char aMacroBarResName
[] = "private:resource/toolbar/macrobar";
1186 static const char aDialogBarResName
[] = "private:resource/toolbar/dialogbar";
1187 static const char aInsertControlsBarResName
[] = "private:resource/toolbar/insertcontrolsbar";
1188 static const char aFormControlsBarResName
[] = "private:resource/toolbar/formcontrolsbar";
1193 Reference
< beans::XPropertySet
> xFrameProps
1194 ( GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY
);
1195 if ( xFrameProps
.is() )
1197 Reference
< css::frame::XLayoutManager
> xLayoutManager
;
1198 uno::Any a
= xFrameProps
->getPropertyValue( "LayoutManager" );
1199 a
>>= xLayoutManager
;
1200 if ( xLayoutManager
.is() )
1202 xLayoutManager
->lock();
1203 if (dynamic_cast<DialogWindow
*>(pCurWin
.get()))
1205 xLayoutManager
->destroyElement( aMacroBarResName
);
1207 xLayoutManager
->requestElement( aDialogBarResName
);
1208 xLayoutManager
->requestElement( aInsertControlsBarResName
);
1209 xLayoutManager
->requestElement( aFormControlsBarResName
);
1213 xLayoutManager
->destroyElement( aDialogBarResName
);
1214 xLayoutManager
->destroyElement( aInsertControlsBarResName
);
1215 xLayoutManager
->destroyElement( aFormControlsBarResName
);
1217 xLayoutManager
->requestElement( aMacroBarResName
);
1219 xLayoutManager
->unlock();
1224 VclPtr
<BaseWindow
> Shell::FindApplicationWindow()
1226 return FindWindow( ScriptDocument::getApplicationScriptDocument(), "", "", TYPE_UNKNOWN
);
1229 VclPtr
<BaseWindow
> Shell::FindWindow(
1230 ScriptDocument
const& rDocument
,
1231 OUString
const& rLibName
, OUString
const& rName
,
1232 ItemType eType
, bool bFindSuspended
1235 for (auto const& window
: aWindowTable
)
1237 BaseWindow
* const pWin
= window
.second
;
1238 if (pWin
->Is(rDocument
, rLibName
, rName
, eType
, bFindSuspended
))
1244 bool Shell::CallBasicErrorHdl( StarBASIC
const * pBasic
)
1247 VclPtr
<ModulWindow
> pModWin
= ShowActiveModuleWindow( pBasic
);
1249 bRet
= pModWin
->BasicErrorHdl( pBasic
);
1253 BasicDebugFlags
Shell::CallBasicBreakHdl( StarBASIC
const * pBasic
)
1255 BasicDebugFlags nRet
= BasicDebugFlags::NONE
;
1256 VclPtr
<ModulWindow
> pModWin
= ShowActiveModuleWindow( pBasic
);
1259 bool bAppWindowDisabled
, bDispatcherLocked
;
1260 sal_uInt16 nWaitCount
;
1261 SfxUInt16Item
*pSWActionCount
, *pSWLockViewCount
;
1262 BasicStopped( &bAppWindowDisabled
, &bDispatcherLocked
,
1263 &nWaitCount
, &pSWActionCount
, &pSWLockViewCount
);
1265 nRet
= pModWin
->BasicBreakHdl();
1267 if ( StarBASIC::IsRunning() ) // if cancelled...
1269 if ( bAppWindowDisabled
)
1270 Application::GetDefDialogParent()->Enable(false);
1274 Shell
* pShell
= GetShell();
1275 for ( sal_uInt16 n
= 0; n
< nWaitCount
; n
++ )
1276 pShell
->GetViewFrame()->GetWindow().EnterWait();
1283 VclPtr
<ModulWindow
> Shell::ShowActiveModuleWindow( StarBASIC
const * pBasic
)
1285 SetCurLib( ScriptDocument::getApplicationScriptDocument(), OUString(), false );
1287 SbModule
* pActiveModule
= StarBASIC::GetActiveModule();
1288 if (SbClassModuleObject
* pCMO
= dynamic_cast<SbClassModuleObject
*>(pActiveModule
))
1289 pActiveModule
= pCMO
->getClassModule();
1291 DBG_ASSERT( pActiveModule
, "No active module in ErrorHdl!?" );
1292 if ( pActiveModule
)
1294 VclPtr
<ModulWindow
> pWin
;
1295 SbxObject
* pParent
= pActiveModule
->GetParent();
1296 if (StarBASIC
* pLib
= dynamic_cast<StarBASIC
*>(pParent
))
1298 if (BasicManager
* pBasMgr
= FindBasicManager(pLib
))
1300 ScriptDocument
aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr
) );
1301 OUString aLibName
= pLib
->GetName();
1302 pWin
= FindBasWin( aDocument
, aLibName
, pActiveModule
->GetName(), true );
1303 DBG_ASSERT( pWin
, "Error/Step-Hdl: Window was not created/found!" );
1304 SetCurLib( aDocument
, aLibName
);
1305 SetCurWindow( pWin
, true );
1309 SAL_WARN( "basctl.basicide", "No BASIC!");
1310 if (BasicManager
* pBasicMgr
= FindBasicManager(pBasic
))
1311 StartListening(*pBasicMgr
, DuplicateHandling::Prevent
/* log on only once */);
1317 void Shell::AdjustPosSizePixel( const Point
&rPos
, const Size
&rSize
)
1319 // not if iconified because the whole text would be displaced then at restore
1320 if ( GetViewFrame()->GetWindow().GetOutputSizePixel().Height() == 0 )
1324 aTabBarSize
.setHeight( GetViewFrame()->GetWindow().GetFont().GetFontHeight() + 4 );
1325 aTabBarSize
.setWidth( rSize
.Width() );
1328 Size
aScrollBarBoxSz( aScrollBarBox
->GetSizePixel() );
1329 aSz
.AdjustHeight( -(aScrollBarBoxSz
.Height()) );
1330 aSz
.AdjustHeight( -(aTabBarSize
.Height()) );
1333 aSz
.AdjustWidth( -(aScrollBarBoxSz
.Width()) );
1334 aScrollBarBox
->SetPosPixel( Point( rSize
.Width() - aScrollBarBoxSz
.Width(), rSize
.Height() - aScrollBarBoxSz
.Height() ) );
1335 aVScrollBar
->SetPosSizePixel( Point( rPos
.X()+aSz
.Width(), rPos
.Y() ), Size( aScrollBarBoxSz
.Width(), aSz
.Height() ) );
1336 aHScrollBar
->SetPosSizePixel( Point( rPos
.X(), rPos
.Y()+aSz
.Height() ), Size( aSz
.Width(), aScrollBarBoxSz
.Height() ) );
1337 pTabBar
->SetPosSizePixel( Point( rPos
.X(), rPos
.Y()+aScrollBarBoxSz
.Height()+aSz
.Height()), aTabBarSize
);
1340 pLayout
->SetPosSizePixel(rPos
, dynamic_cast<DialogWindow
*>(pCurWin
.get()) ? aSz
: aOutSz
);
1343 Reference
< XModel
> Shell::GetCurrentDocument() const
1345 Reference
< XModel
> xDocument
;
1346 if ( pCurWin
&& pCurWin
->GetDocument().isDocument() )
1347 xDocument
= pCurWin
->GetDocument().getDocument();
1351 void Shell::Activate( bool bMDI
)
1353 SfxViewShell::Activate( bMDI
);
1357 if (DialogWindow
* pDCurWin
= dynamic_cast<DialogWindow
*>(pCurWin
.get()))
1358 pDCurWin
->UpdateBrowser();
1362 void Shell::Deactivate( bool bMDI
)
1364 // bMDI == true means that another MDI has been activated; in case of a
1365 // deactivate due to a MessageBox bMDI is false
1368 if (DialogWindow
* pXDlgWin
= dynamic_cast<DialogWindow
*>(pCurWin
.get()))
1370 pXDlgWin
->DisableBrowser();
1371 if( pXDlgWin
->IsModified() )
1372 MarkDocumentModified( pXDlgWin
->GetDocument() );
1375 // test CanClose to also test during deactivating the BasicIDE whether
1376 // the sourcecode is too large in one of the modules...
1377 for (auto const& window
: aWindowTable
)
1379 BaseWindow
* pWin
= window
.second
;
1380 if ( /* !pWin->IsSuspended() && */ !pWin
->CanClose() )
1382 if ( !m_aCurLibName
.isEmpty() && ( pWin
->IsDocument( m_aCurDocument
) || pWin
->GetLibName() != m_aCurLibName
) )
1383 SetCurLib( ScriptDocument::getApplicationScriptDocument(), OUString(), false );
1384 SetCurWindow( pWin
, true );
1391 } // namespace basctl
1393 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */