Bump version to 6.0-36
[LibreOffice.git] / basctl / source / basicide / basides1.cxx
blob373dcd53eb6779912dcf6aefc7ae4a34d6f63319
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <memory>
21 #include <strings.hrc>
22 #include <helpids.h>
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/srchitem.hxx>
48 #include <svl/visitem.hxx>
49 #include <svl/whiter.hxx>
50 #include <vcl/xtextedt.hxx>
51 #include <vcl/msgbox.hxx>
53 namespace basctl
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::frame;
60 void Shell::ExecuteCurrent( SfxRequest& rReq )
62 if ( !pCurWin )
63 return;
65 switch ( rReq.GetSlot() )
67 case SID_BASICIDE_HIDECURPAGE:
69 pCurWin->StoreData();
70 RemoveWindow( pCurWin, false );
72 break;
73 case SID_BASICIDE_RENAMECURRENT:
75 pTabBar->StartEditMode( pTabBar->GetCurPageId() );
77 break;
78 case FID_SEARCH_NOW:
80 if (!pCurWin->HasActiveEditor())
81 break;
82 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
83 SfxItemSet const& rArgs = *rReq.GetArgs();
84 // unfortunately I don't know the ID:
85 sal_uInt16 nWhich = rArgs.GetWhichByPos( 0 );
86 DBG_ASSERT( nWhich, "Which for SearchItem?" );
87 SfxPoolItem const& rItem = rArgs.Get(nWhich);
88 DBG_ASSERT(dynamic_cast<SvxSearchItem const*>(&rItem), "no searchitem!");
89 SvxSearchItem const& rSearchItem = static_cast<SvxSearchItem const&>(rItem);
90 // memorize item because of the adjustments...
91 GetExtraData()->SetSearchItem(rSearchItem);
92 sal_Int32 nFound = 0;
93 if (rSearchItem.GetCommand() == SvxSearchCmd::REPLACE_ALL)
95 sal_uInt16 nActModWindows = 0;
96 for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it)
98 BaseWindow* pWin = it->second;
99 if (pWin->HasActiveEditor())
100 nActModWindows++;
103 if ( nActModWindows <= 1 || ( !rSearchItem.GetSelection() && ScopedVclPtrInstance<QueryBox>(pCurWin, MessBoxStyle::YesNo|MessBoxStyle::DefaultYes, IDEResId(RID_STR_SEARCHALLMODULES))->Execute() == RET_YES ) )
105 for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it)
107 BaseWindow* pWin = it->second;
108 nFound += pWin->StartSearchAndReplace(rSearchItem);
111 else
112 nFound = pCurWin->StartSearchAndReplace(rSearchItem);
114 OUString aReplStr(IDEResId(RID_STR_SEARCHREPLACES));
115 aReplStr = aReplStr.replaceAll("XX", OUString::number(nFound));
116 ScopedVclPtrInstance<InfoBox>(pCurWin, aReplStr)->Execute();
118 else
120 bool bCanceled = false;
121 nFound = pCurWin->StartSearchAndReplace(rSearchItem);
122 if ( !nFound && !rSearchItem.GetSelection() )
124 // search other modules...
125 bool bChangeCurWindow = false;
126 WindowTableIt it;
127 for (it = aWindowTable.begin(); it != aWindowTable.end(); ++it)
128 if (it->second == pCurWin)
129 break;
130 if (it != aWindowTable.end())
131 ++it;
132 BaseWindow* pWin = it != aWindowTable.end() ? it->second.get() : nullptr;
134 bool bSearchedFromStart = false;
135 while ( !nFound && !bCanceled && ( pWin || !bSearchedFromStart ) )
137 if ( !pWin )
139 SfxViewFrame* pViewFrame = GetViewFrame();
140 SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : nullptr;
141 vcl::Window* pParent = pChildWin ? pChildWin->GetWindow() : nullptr;
142 ScopedVclPtrInstance< QueryBox > aQuery(pParent, MessBoxStyle::YesNo|MessBoxStyle::DefaultYes, IDEResId(RID_STR_SEARCHFROMSTART));
143 if ( aQuery->Execute() == RET_YES )
145 it = aWindowTable.begin();
146 if ( it != aWindowTable.end() )
147 pWin = it->second;
148 bSearchedFromStart = true;
150 else
151 bCanceled = true;
154 if (pWin && pWin->HasActiveEditor())
156 if ( pWin != pCurWin )
158 if ( pCurWin )
159 pWin->SetSizePixel( pCurWin->GetSizePixel() );
160 nFound = pWin->StartSearchAndReplace(rSearchItem, true);
162 if ( nFound )
164 bChangeCurWindow = true;
165 break;
168 if ( pWin && ( pWin != pCurWin ) )
170 if ( it != aWindowTable.end() )
171 ++it;
172 pWin = it != aWindowTable.end() ? it->second.get() : nullptr;
174 else
175 pWin = nullptr;
177 if ( !nFound && bSearchedFromStart )
178 nFound = pCurWin->StartSearchAndReplace(rSearchItem, true);
179 if ( bChangeCurWindow )
180 SetCurWindow( pWin, true );
182 if ( !nFound && !bCanceled )
183 ScopedVclPtrInstance<InfoBox>(pCurWin, IDEResId(RID_STR_SEARCHNOTFOUND))->Execute();
186 rReq.Done();
188 break;
189 case SID_UNDO:
190 case SID_REDO:
191 if ( GetUndoManager() && pCurWin->AllowUndo() )
192 GetViewFrame()->ExecuteSlot( rReq );
193 break;
194 default:
195 pCurWin->ExecuteCommand( rReq );
199 // no matter who's at the top, influence on the shell:
200 void Shell::ExecuteGlobal( SfxRequest& rReq )
202 sal_uInt16 nSlot = rReq.GetSlot();
203 switch ( nSlot )
205 case SID_BASICSTOP:
207 // maybe do not simply stop if on breakpoint!
208 if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get()))
209 pMCurWin->BasicStop();
210 StopBasic();
212 break;
214 case SID_SAVEDOC:
216 if ( pCurWin )
218 // rewrite date into the BASIC
219 StoreAllWindowData();
221 // document basic
222 ScriptDocument aDocument( pCurWin->GetDocument() );
223 if ( aDocument.isDocument() )
225 uno::Reference< task::XStatusIndicator > xStatusIndicator;
227 const SfxUnoAnyItem* pStatusIndicatorItem = rReq.GetArg<SfxUnoAnyItem>(SID_PROGRESS_STATUSBAR_CONTROL);
228 if ( pStatusIndicatorItem )
229 OSL_VERIFY( pStatusIndicatorItem->GetValue() >>= xStatusIndicator );
230 else
232 // get statusindicator
233 SfxViewFrame *pFrame_ = GetFrame();
234 if ( pFrame_ )
236 uno::Reference< task::XStatusIndicatorFactory > xStatFactory(
237 pFrame_->GetFrame().GetFrameInterface(),
238 uno::UNO_QUERY );
239 if( xStatFactory.is() )
240 xStatusIndicator = xStatFactory->createStatusIndicator();
243 if ( xStatusIndicator.is() )
244 rReq.AppendItem( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL, uno::Any( xStatusIndicator ) ) );
247 aDocument.saveDocument( xStatusIndicator );
250 if (SfxBindings* pBindings = GetBindingsPtr())
252 pBindings->Invalidate( SID_DOC_MODIFIED );
253 pBindings->Invalidate( SID_SAVEDOC );
254 pBindings->Invalidate( SID_SIGNATURE );
258 break;
259 case SID_BASICIDE_MODULEDLG:
261 if ( rReq.GetArgs() )
263 const SfxUInt16Item &rTabId = static_cast<const SfxUInt16Item&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID ));
264 Organize( rTabId.GetValue() );
266 else
267 Organize( 0 );
269 break;
270 case SID_BASICIDE_CHOOSEMACRO:
272 ChooseMacro( nullptr );
274 break;
275 case SID_BASICIDE_CREATEMACRO:
276 case SID_BASICIDE_EDITMACRO:
278 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
279 const SfxMacroInfoItem& rInfo = static_cast<const SfxMacroInfoItem&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO ));
280 BasicManager* pBasMgr = const_cast<BasicManager*>(rInfo.GetBasicManager());
281 DBG_ASSERT( pBasMgr, "Nothing selected in basic tree?" );
283 ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
285 StartListening(*pBasMgr, DuplicateHandling::Prevent /* log on only once */);
286 OUString aLibName( rInfo.GetLib() );
287 if ( aLibName.isEmpty() )
288 aLibName = "Standard" ;
289 StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
290 if ( !pBasic )
292 // load module and dialog library (if not loaded)
293 aDocument.loadLibraryIfExists( E_SCRIPTS, aLibName );
294 aDocument.loadLibraryIfExists( E_DIALOGS, aLibName );
296 // get Basic
297 pBasic = pBasMgr->GetLib( aLibName );
299 DBG_ASSERT( pBasic, "No Basic!" );
301 SetCurLib( aDocument, aLibName );
303 if ( pBasic && rReq.GetSlot() == SID_BASICIDE_CREATEMACRO )
305 SbModule* pModule = pBasic->FindModule( rInfo.GetModule() );
306 if ( !pModule )
308 if ( !rInfo.GetModule().isEmpty() || pBasic->GetModules().empty() )
310 const OUString& aModName = rInfo.GetModule();
312 OUString sModuleCode;
313 if ( aDocument.createModule( aLibName, aModName, false, sModuleCode ) )
314 pModule = pBasic->FindModule( aModName );
316 else
317 pModule = pBasic->GetModules().front().get();
319 DBG_ASSERT( pModule, "No Module!" );
320 if ( pModule && !pModule->GetMethods()->Find( rInfo.GetMethod(), SbxClassType::Method ) )
321 CreateMacro( pModule, rInfo.GetMethod() );
323 SfxViewFrame* pViewFrame = GetViewFrame();
324 if ( pViewFrame )
325 pViewFrame->ToTop();
326 VclPtr<ModulWindow> pWin = FindBasWin( aDocument, aLibName, rInfo.GetModule(), true );
327 DBG_ASSERT( pWin, "Edit/Create Macro: Window was not created/found!" );
328 SetCurWindow( pWin, true );
329 pWin->EditMacro( rInfo.GetMethod() );
331 break;
333 case SID_BASICIDE_OBJCAT:
334 // toggling object catalog
335 aObjectCatalog->Show(!aObjectCatalog->IsVisible());
336 if (pLayout)
337 pLayout->ArrangeWindows();
338 // refresh the button state
339 if (SfxBindings* pBindings = GetBindingsPtr())
340 pBindings->Invalidate(SID_BASICIDE_OBJCAT);
341 break;
343 case SID_BASICIDE_NAMECHANGEDONTAB:
345 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
346 const SfxUInt16Item &rTabId = static_cast<const SfxUInt16Item&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID ));
347 const SfxStringItem &rModName = static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_MODULENAME ));
348 if ( aWindowTable.find( rTabId.GetValue() ) != aWindowTable.end() )
350 VclPtr<BaseWindow> pWin = aWindowTable[ rTabId.GetValue() ];
351 const OUString& aNewName( rModName.GetValue() );
352 OUString aOldName( pWin->GetName() );
353 if ( aNewName != aOldName )
355 bool bRenameOk = false;
356 if (ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin.get()))
358 OUString aLibName = pModWin->GetLibName();
359 ScriptDocument aDocument( pWin->GetDocument() );
361 if (RenameModule(pModWin, aDocument, aLibName, aOldName, aNewName))
363 bRenameOk = true;
364 // Because we listen for container events for script
365 // modules, rename will delete the 'old' window
366 // pWin has been invalidated, restore now
367 pWin = FindBasWin( aDocument, aLibName, aNewName, true );
371 else if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(pWin.get()))
373 bRenameOk = pDlgWin->RenameDialog( aNewName );
375 if ( bRenameOk )
377 MarkDocumentModified( pWin->GetDocument() );
379 else
381 // set old name in TabWriter
382 sal_uInt16 nId = GetWindowId( pWin );
383 DBG_ASSERT( nId, "No entry in Tabbar!" );
384 if ( nId )
385 pTabBar->SetPageText( nId, aOldName );
389 // set focus to current window
390 pWin->GrabFocus();
393 break;
394 case SID_BASICIDE_STOREMODULESOURCE:
395 case SID_BASICIDE_UPDATEMODULESOURCE:
397 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
398 const SfxMacroInfoItem& rInfo = static_cast<const SfxMacroInfoItem&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO ));
399 BasicManager* pBasMgr = const_cast<BasicManager*>(rInfo.GetBasicManager());
400 DBG_ASSERT( pBasMgr, "Store source: No BasMgr?" );
401 ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
402 VclPtr<ModulWindow> pWin = FindBasWin( aDocument, rInfo.GetLib(), rInfo.GetModule(), false, true );
403 if ( pWin )
405 if ( rReq.GetSlot() == SID_BASICIDE_STOREMODULESOURCE )
406 pWin->StoreData();
407 else
408 pWin->UpdateData();
411 break;
412 case SID_BASICIDE_STOREALLMODULESOURCES:
413 case SID_BASICIDE_UPDATEALLMODULESOURCES:
415 for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it)
417 BaseWindow* pWin = it->second;
418 if (!pWin->IsSuspended() && dynamic_cast<ModulWindow*>(pWin))
420 if ( rReq.GetSlot() == SID_BASICIDE_STOREALLMODULESOURCES )
421 pWin->StoreData();
422 else
423 pWin->UpdateData();
427 break;
428 case SID_BASICIDE_LIBSELECTED:
429 case SID_BASICIDE_LIBREMOVED:
430 case SID_BASICIDE_LIBLOADED:
432 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
433 const SfxUsrAnyItem& rShellItem = static_cast<const SfxUsrAnyItem&>(rReq.GetArgs()->Get( SID_BASICIDE_ARG_DOCUMENT_MODEL ));
434 uno::Reference< frame::XModel > xModel( rShellItem.GetValue(), UNO_QUERY );
435 ScriptDocument aDocument( xModel.is() ? ScriptDocument( xModel ) : ScriptDocument::getApplicationScriptDocument() );
436 const SfxStringItem& rLibNameItem = static_cast<const SfxStringItem&>(rReq.GetArgs()->Get( SID_BASICIDE_ARG_LIBNAME ));
437 const OUString& aLibName( rLibNameItem.GetValue() );
439 if ( nSlot == SID_BASICIDE_LIBSELECTED )
441 // load module and dialog library (if not loaded)
442 aDocument.loadLibraryIfExists( E_SCRIPTS, aLibName );
443 aDocument.loadLibraryIfExists( E_DIALOGS, aLibName );
445 // check password, if library is password protected and not verified
446 bool bOK = true;
447 Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
448 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
450 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
451 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
453 OUString aPassword;
454 bOK = QueryPassword( xModLibContainer, aLibName, aPassword );
458 if ( bOK )
460 SetCurLib( aDocument, aLibName, true, false );
462 else
464 // adjust old value...
465 if (SfxBindings* pBindings = GetBindingsPtr())
466 pBindings->Invalidate(SID_BASICIDE_LIBSELECTOR, true);
469 else if ( nSlot == SID_BASICIDE_LIBREMOVED )
471 if ( m_aCurLibName.isEmpty() || ( aDocument == m_aCurDocument && aLibName == m_aCurLibName ) )
473 RemoveWindows( aDocument, aLibName );
474 if ( aDocument == m_aCurDocument && aLibName == m_aCurLibName )
476 m_aCurDocument = ScriptDocument::getApplicationScriptDocument();
477 m_aCurLibName.clear();
478 // no UpdateWindows!
479 if (SfxBindings* pBindings = GetBindingsPtr())
480 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
484 else // Loaded...
485 UpdateWindows();
487 break;
488 case SID_BASICIDE_NEWMODULE:
490 VclPtr<ModulWindow> pWin = CreateBasWin( m_aCurDocument, m_aCurLibName, OUString() );
491 DBG_ASSERT( pWin, "New Module: Could not create window!" );
492 SetCurWindow( pWin, true );
494 break;
495 case SID_BASICIDE_NEWDIALOG:
497 VclPtr<DialogWindow> pWin = CreateDlgWin( m_aCurDocument, m_aCurLibName, OUString() );
498 DBG_ASSERT( pWin, "New Module: Could not create window!" );
499 SetCurWindow( pWin, true );
501 break;
502 case SID_BASICIDE_SBXRENAMED:
504 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
506 break;
507 case SID_BASICIDE_SBXINSERTED:
509 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
510 const SbxItem& rSbxItem = static_cast<const SbxItem&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_SBX ));
511 const ScriptDocument& aDocument( rSbxItem.GetDocument() );
512 const OUString& aLibName( rSbxItem.GetLibName() );
513 const OUString& aName( rSbxItem.GetName() );
514 if ( m_aCurLibName.isEmpty() || ( aDocument == m_aCurDocument && aLibName == m_aCurLibName ) )
516 if ( rSbxItem.GetType() == TYPE_MODULE )
517 FindBasWin( aDocument, aLibName, aName, true );
518 else if ( rSbxItem.GetType() == TYPE_DIALOG )
519 FindDlgWin( aDocument, aLibName, aName, true );
522 break;
523 case SID_BASICIDE_SBXDELETED:
525 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
526 const SbxItem& rSbxItem = static_cast<const SbxItem&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_SBX ));
527 const ScriptDocument& aDocument( rSbxItem.GetDocument() );
528 VclPtr<BaseWindow> pWin = FindWindow( aDocument, rSbxItem.GetLibName(), rSbxItem.GetName(), rSbxItem.GetType(), true );
529 if ( pWin )
530 RemoveWindow( pWin, true );
532 break;
533 case SID_BASICIDE_SHOWSBX:
535 DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
536 const SbxItem& rSbxItem = static_cast<const SbxItem&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_SBX ));
537 const ScriptDocument& aDocument( rSbxItem.GetDocument() );
538 const OUString& aLibName( rSbxItem.GetLibName() );
539 const OUString& aName( rSbxItem.GetName() );
540 SetCurLib( aDocument, aLibName );
541 BaseWindow* pWin = nullptr;
542 if ( rSbxItem.GetType() == TYPE_DIALOG )
544 pWin = FindDlgWin( aDocument, aLibName, aName, true );
546 else if ( rSbxItem.GetType() == TYPE_MODULE )
548 pWin = FindBasWin( aDocument, aLibName, aName, true );
550 else if ( rSbxItem.GetType() == TYPE_METHOD )
552 pWin = FindBasWin( aDocument, aLibName, aName, true );
553 static_cast<ModulWindow*>(pWin)->EditMacro( rSbxItem.GetMethodName() );
555 DBG_ASSERT( pWin, "Window was not created!" );
556 SetCurWindow( pWin, true );
557 pTabBar->MakeVisible( pTabBar->GetCurPageId() );
559 break;
560 case SID_BASICIDE_SHOWWINDOW:
562 std::unique_ptr< ScriptDocument > pDocument;
564 const SfxStringItem* pDocumentItem = rReq.GetArg<SfxStringItem>(SID_BASICIDE_ARG_DOCUMENT);
565 if ( pDocumentItem )
567 OUString sDocumentCaption = pDocumentItem->GetValue();
568 if ( !sDocumentCaption.isEmpty() )
569 pDocument.reset( new ScriptDocument( ScriptDocument::getDocumentWithURLOrCaption( sDocumentCaption ) ) );
572 const SfxUsrAnyItem* pDocModelItem = rReq.GetArg<SfxUsrAnyItem>(SID_BASICIDE_ARG_DOCUMENT_MODEL);
573 if ( !pDocument.get() && pDocModelItem )
575 uno::Reference< frame::XModel > xModel( pDocModelItem->GetValue(), UNO_QUERY );
576 if ( xModel.is() )
577 pDocument.reset( new ScriptDocument( xModel ) );
580 if ( !pDocument.get() )
581 break;
583 const SfxStringItem* pLibNameItem = rReq.GetArg<SfxStringItem>(SID_BASICIDE_ARG_LIBNAME);
584 if ( !pLibNameItem )
585 break;
587 OUString aLibName( pLibNameItem->GetValue() );
588 pDocument->loadLibraryIfExists( E_SCRIPTS, aLibName );
589 SetCurLib( *pDocument, aLibName );
590 const SfxStringItem* pNameItem = rReq.GetArg<SfxStringItem>(SID_BASICIDE_ARG_NAME);
591 if ( pNameItem )
593 OUString aName( pNameItem->GetValue() );
594 OUString aModType( "Module" );
595 OUString aType( aModType );
596 const SfxStringItem* pTypeItem = rReq.GetArg<SfxStringItem>(SID_BASICIDE_ARG_TYPE);
597 if ( pTypeItem )
598 aType = pTypeItem->GetValue();
600 BaseWindow* pWin = nullptr;
601 if ( aType == aModType )
602 pWin = FindBasWin( *pDocument, aLibName, aName );
603 else if ( aType == "Dialog" )
604 pWin = FindDlgWin( *pDocument, aLibName, aName );
606 if ( pWin )
608 SetCurWindow( pWin, true );
609 if ( pTabBar )
610 pTabBar->MakeVisible( pTabBar->GetCurPageId() );
612 if (ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin))
614 const SfxUInt32Item* pLineItem = rReq.GetArg<SfxUInt32Item>(SID_BASICIDE_ARG_LINE);
615 if ( pLineItem )
617 pModWin->AssertValidEditEngine();
618 TextView* pTextView = pModWin->GetEditView();
619 if ( pTextView )
621 TextEngine* pTextEngine = pTextView->GetTextEngine();
622 if ( pTextEngine )
624 sal_uInt32 nLine = pLineItem->GetValue();
625 sal_uInt32 nLineCount = 0;
626 for ( sal_uInt32 i = 0, nCount = pTextEngine->GetParagraphCount(); i < nCount; ++i )
627 nLineCount += pTextEngine->GetLineCount( i );
628 if ( nLine > nLineCount )
629 nLine = nLineCount;
630 if ( nLine > 0 )
631 --nLine;
633 // scroll window and set selection
634 long nVisHeight = pModWin->GetOutputSizePixel().Height();
635 long nTextHeight = pTextEngine->GetTextHeight();
636 if ( nTextHeight > nVisHeight )
638 long nMaxY = nTextHeight - nVisHeight;
639 long nOldY = pTextView->GetStartDocPos().Y();
640 long nNewY = nLine * pTextEngine->GetCharHeight() - nVisHeight / 2;
641 nNewY = std::min( nNewY, nMaxY );
642 pTextView->Scroll( 0, -( nNewY - nOldY ) );
643 pTextView->ShowCursor( false );
644 pModWin->GetEditVScrollBar().SetThumbPos( pTextView->GetStartDocPos().Y() );
646 sal_uInt16 nCol1 = 0, nCol2 = 0;
647 const SfxUInt16Item* pCol1Item = rReq.GetArg<SfxUInt16Item>(SID_BASICIDE_ARG_COLUMN1);
648 if ( pCol1Item )
650 nCol1 = pCol1Item->GetValue();
651 if ( nCol1 > 0 )
652 --nCol1;
653 nCol2 = nCol1;
655 const SfxUInt16Item* pCol2Item = rReq.GetArg<SfxUInt16Item>(SID_BASICIDE_ARG_COLUMN2);
656 if ( pCol2Item )
658 nCol2 = pCol2Item->GetValue();
659 if ( nCol2 > 0 )
660 --nCol2;
662 TextSelection aSel( TextPaM( nLine, nCol1 ), TextPaM( nLine, nCol2 ) );
663 pTextView->SetSelection( aSel );
664 pTextView->ShowCursor();
665 vcl::Window* pWindow_ = pTextView->GetWindow();
666 if ( pWindow_ )
667 pWindow_->GrabFocus();
674 rReq.Done();
676 break;
678 case SID_BASICIDE_MANAGE_LANG:
680 ScopedVclPtrInstance< ManageLanguageDialog > aDlg(pCurWin, m_pCurLocalizationMgr);
681 aDlg->Execute();
682 rReq.Done();
684 break;
686 default:
687 if (pLayout)
688 pLayout->ExecuteGlobal(rReq);
689 if (pCurWin)
690 pCurWin->ExecuteGlobal(rReq);
691 break;
695 void Shell::GetState(SfxItemSet &rSet)
697 SfxWhichIter aIter(rSet);
698 for ( sal_uInt16 nWh = aIter.FirstWhich(); nWh != 0; nWh = aIter.NextWhich() )
700 switch ( nWh )
702 case SID_DOCINFO:
704 rSet.DisableItem( nWh );
706 break;
707 case SID_SAVEDOC:
709 bool bDisable = false;
711 if ( pCurWin )
713 if ( !pCurWin->IsModified() )
715 ScriptDocument aDocument( pCurWin->GetDocument() );
716 bDisable = ( !aDocument.isAlive() )
717 || ( aDocument.isDocument() ? !aDocument.isDocumentModified() : !IsAppBasicModified() );
720 else
722 bDisable = true;
725 if ( bDisable )
726 rSet.DisableItem( nWh );
728 break;
729 case SID_NEWWINDOW:
730 case SID_SAVEASDOC:
732 rSet.DisableItem( nWh );
734 break;
735 case SID_SIGNATURE:
737 SignatureState nState = SignatureState::NOSIGNATURES;
738 if ( pCurWin )
740 DocumentSignature aSignature( pCurWin->GetDocument() );
741 nState = aSignature.getScriptingSignatureState();
743 rSet.Put( SfxUInt16Item( SID_SIGNATURE, static_cast<sal_uInt16>(nState) ) );
745 break;
746 case SID_BASICIDE_MODULEDLG:
748 if ( StarBASIC::IsRunning() )
749 rSet.DisableItem( nWh );
751 break;
752 case SID_BASICIDE_OBJCAT:
753 if (pLayout)
754 rSet.Put(SfxBoolItem(nWh, aObjectCatalog->IsVisible()));
755 else
756 rSet.Put(SfxVisibilityItem(nWh, false));
757 break;
758 case SID_BASICIDE_SHOWSBX:
759 case SID_BASICIDE_CREATEMACRO:
760 case SID_BASICIDE_EDITMACRO:
761 case SID_BASICIDE_NAMECHANGEDONTAB:
765 break;
767 case SID_BASICIDE_ADDWATCH:
768 case SID_BASICIDE_REMOVEWATCH:
769 case SID_BASICLOAD:
770 case SID_BASICSAVEAS:
771 case SID_BASICIDE_MATCHGROUP:
773 if (!dynamic_cast<ModulWindow*>(pCurWin.get()))
774 rSet.DisableItem( nWh );
775 else if ( ( nWh == SID_BASICLOAD ) && ( StarBASIC::IsRunning() || ( pCurWin && pCurWin->IsReadOnly() ) ) )
776 rSet.DisableItem( nWh );
778 break;
779 case SID_BASICRUN:
780 case SID_BASICSTEPINTO:
781 case SID_BASICSTEPOVER:
782 case SID_BASICSTEPOUT:
783 case SID_BASICIDE_TOGGLEBRKPNT:
784 case SID_BASICIDE_MANAGEBRKPNTS:
786 if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get()))
788 if (StarBASIC::IsRunning() && !pMCurWin->GetBasicStatus().bIsInReschedule)
789 rSet.DisableItem(nWh);
791 else
792 rSet.DisableItem( nWh );
794 break;
795 case SID_BASICCOMPILE:
797 if (StarBASIC::IsRunning() || !dynamic_cast<ModulWindow*>(pCurWin.get()))
798 rSet.DisableItem( nWh );
800 break;
801 case SID_BASICSTOP:
803 // stop is always possible when some Basic is running...
804 if (!StarBASIC::IsRunning())
805 rSet.DisableItem( nWh );
807 break;
808 case SID_CHOOSE_CONTROLS:
809 case SID_DIALOG_TESTMODE:
810 case SID_INSERT_SELECT:
811 case SID_INSERT_PUSHBUTTON:
812 case SID_INSERT_RADIOBUTTON:
813 case SID_INSERT_CHECKBOX:
814 case SID_INSERT_LISTBOX:
815 case SID_INSERT_COMBOBOX:
816 case SID_INSERT_GROUPBOX:
817 case SID_INSERT_EDIT:
818 case SID_INSERT_FIXEDTEXT:
819 case SID_INSERT_IMAGECONTROL:
820 case SID_INSERT_PROGRESSBAR:
821 case SID_INSERT_HSCROLLBAR:
822 case SID_INSERT_VSCROLLBAR:
823 case SID_INSERT_HFIXEDLINE:
824 case SID_INSERT_VFIXEDLINE:
825 case SID_INSERT_DATEFIELD:
826 case SID_INSERT_TIMEFIELD:
827 case SID_INSERT_NUMERICFIELD:
828 case SID_INSERT_CURRENCYFIELD:
829 case SID_INSERT_FORMATTEDFIELD:
830 case SID_INSERT_PATTERNFIELD:
831 case SID_INSERT_FILECONTROL:
832 case SID_INSERT_SPINBUTTON:
833 case SID_INSERT_TREECONTROL:
834 case SID_INSERT_FORM_RADIO:
835 case SID_INSERT_FORM_CHECK:
836 case SID_INSERT_FORM_LIST:
837 case SID_INSERT_FORM_COMBO:
838 case SID_INSERT_FORM_VSCROLL:
839 case SID_INSERT_FORM_HSCROLL:
840 case SID_INSERT_FORM_SPIN:
842 if (!dynamic_cast<DialogWindow*>(pCurWin.get()))
843 rSet.DisableItem( nWh );
845 break;
846 case SID_SEARCH_OPTIONS:
848 SearchOptionFlags nOptions = SearchOptionFlags::NONE;
849 if( pCurWin )
850 nOptions = pCurWin->GetSearchOptions();
851 rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, static_cast<sal_uInt16>(nOptions) ) );
853 break;
854 case SID_BASICIDE_LIBSELECTOR:
856 OUString aName;
857 if ( !m_aCurLibName.isEmpty() )
859 LibraryLocation eLocation = m_aCurDocument.getLibraryLocation( m_aCurLibName );
860 aName = CreateMgrAndLibStr( m_aCurDocument.getTitle( eLocation ), m_aCurLibName );
862 SfxStringItem aItem( SID_BASICIDE_LIBSELECTOR, aName );
863 rSet.Put( aItem );
865 break;
866 case SID_SEARCH_ITEM:
868 OUString aSelected = GetSelectionText(true);
869 SvxSearchItem& rItem = GetExtraData()->GetSearchItem();
870 rItem.SetSearchString( aSelected );
871 rSet.Put( rItem );
873 break;
874 case SID_BASICIDE_STAT_DATE:
876 SfxStringItem aItem( SID_BASICIDE_STAT_DATE, "Datum?!" );
877 rSet.Put( aItem );
879 break;
880 case SID_DOC_MODIFIED:
882 bool bModified = false;
884 if ( pCurWin )
886 if ( pCurWin->IsModified() )
887 bModified = true;
888 else
890 ScriptDocument aDocument( pCurWin->GetDocument() );
891 bModified = aDocument.isDocument() ? aDocument.isDocumentModified() : IsAppBasicModified();
895 SfxBoolItem aItem(SID_DOC_MODIFIED, bModified);
896 rSet.Put( aItem );
898 break;
899 case SID_BASICIDE_STAT_TITLE:
901 if ( pCurWin )
903 OUString aTitle = pCurWin->CreateQualifiedName();
904 SfxStringItem aItem( SID_BASICIDE_STAT_TITLE, aTitle );
905 rSet.Put( aItem );
908 break;
909 // are interpreted by the controller:
910 case SID_ATTR_SIZE:
911 case SID_ATTR_INSERT:
912 break;
913 case SID_UNDO:
914 case SID_REDO:
916 if( GetUndoManager() ) // recursive GetState else
917 GetViewFrame()->GetSlotState( nWh, nullptr, &rSet );
919 break;
920 case SID_BASICIDE_CURRENT_LANG:
922 if( (pCurWin && pCurWin->IsReadOnly()) || GetCurLibName().isEmpty() )
923 rSet.DisableItem( nWh );
924 else
926 OUString aItemStr;
927 std::shared_ptr<LocalizationMgr> pCurMgr(GetCurLocalizationMgr());
928 if ( pCurMgr->isLibraryLocalized() )
930 Sequence< lang::Locale > aLocaleSeq = pCurMgr->getStringResourceManager()->getLocales();
931 const lang::Locale* pLocale = aLocaleSeq.getConstArray();
932 sal_Int32 i, nCount = aLocaleSeq.getLength();
934 // Force different results for any combination of locales and default locale
935 OUString aLangStr;
936 for ( i = 0; i <= nCount; ++i )
938 lang::Locale aLocale;
939 if( i < nCount )
940 aLocale = pLocale[i];
941 else
942 aLocale = pCurMgr->getStringResourceManager()->getDefaultLocale();
944 aLangStr += aLocale.Language + aLocale.Country + aLocale.Variant;
946 aItemStr = aLangStr;
948 rSet.Put( SfxStringItem( nWh, aItemStr ) );
951 break;
953 case SID_BASICIDE_MANAGE_LANG:
955 if( (pCurWin && pCurWin->IsReadOnly()) || GetCurLibName().isEmpty() )
956 rSet.DisableItem( nWh );
958 break;
959 case SID_GOTOLINE:
961 // if this is not a module window hide the
962 // setting, doesn't make sense for example if the
963 // dialog editor is open
964 if (pCurWin && !dynamic_cast<ModulWindow*>(pCurWin.get()))
966 rSet.DisableItem( nWh );
967 rSet.Put(SfxVisibilityItem(nWh, false));
969 break;
971 case SID_BASICIDE_HIDECURPAGE:
973 if (pTabBar->GetPageCount() == 0)
974 rSet.DisableItem(nWh);
976 break;
977 case SID_BASICIDE_DELETECURRENT:
978 case SID_BASICIDE_RENAMECURRENT:
980 if (pTabBar->GetPageCount() == 0 || StarBASIC::IsRunning())
981 rSet.DisableItem(nWh);
982 else if (m_aCurDocument.isInVBAMode())
984 // disable to delete or rename object modules in IDE
985 BasicManager* pBasMgr = m_aCurDocument.getBasicManager();
986 StarBASIC* pBasic = pBasMgr ? pBasMgr->GetLib(m_aCurLibName) : nullptr;
987 if (pBasic && dynamic_cast<ModulWindow*>(pCurWin.get()))
989 SbModule* pActiveModule = pBasic->FindModule( pCurWin->GetName() );
990 if ( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) )
991 rSet.DisableItem(nWh);
995 SAL_FALLTHROUGH;
997 case SID_BASICIDE_NEWMODULE:
998 case SID_BASICIDE_NEWDIALOG:
1000 Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
1001 Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
1002 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( m_aCurLibName ) && xModLibContainer->isLibraryReadOnly( m_aCurLibName ) ) ||
1003 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( m_aCurLibName ) && xDlgLibContainer->isLibraryReadOnly( m_aCurLibName ) ) )
1004 rSet.DisableItem(nWh);
1006 break;
1007 default:
1008 if (pLayout)
1009 pLayout->GetState(rSet, nWh);
1012 if ( pCurWin )
1013 pCurWin->GetState( rSet );
1016 bool Shell::HasUIFeature(SfxShellFeature nFeature) const
1018 assert((nFeature & ~SfxShellFeature::BasicMask) == SfxShellFeature::NONE);
1019 bool bResult = false;
1021 if (nFeature & SfxShellFeature::BasicShowBrowser)
1023 // fade out (in) property browser in module (dialog) windows
1024 if (dynamic_cast<DialogWindow*>(pCurWin.get()) && !pCurWin->IsReadOnly())
1025 bResult = true;
1028 return bResult;
1031 void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRememberAsCurrent )
1033 if ( pNewWin != pCurWin )
1035 pCurWin = pNewWin;
1036 if (pLayout)
1037 pLayout->Deactivating();
1038 if (pCurWin)
1040 if (pCurWin->GetType() == TYPE_MODULE)
1041 pLayout = pModulLayout.get();
1042 else
1043 pLayout = pDialogLayout.get();
1044 AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel());
1045 pLayout->Activating(*pCurWin);
1046 GetViewFrame()->GetWindow().SetHelpId(pCurWin->GetHid());
1047 if (bRememberAsCurrent)
1048 pCurWin->InsertLibInfo();
1049 if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise
1050 pCurWin->Show();
1051 pCurWin->Init();
1052 if (!GetExtraData()->ShellInCriticalSection())
1054 vcl::Window* pFrameWindow = &GetViewFrame()->GetWindow();
1055 vcl::Window* pFocusWindow = Application::GetFocusWindow();
1056 while ( pFocusWindow && ( pFocusWindow != pFrameWindow ) )
1057 pFocusWindow = pFocusWindow->GetParent();
1058 if ( pFocusWindow ) // Focus in BasicIDE
1059 pCurWin->GrabFocus();
1062 else
1064 SetWindow(pLayout);
1065 pLayout = nullptr;
1067 if ( bUpdateTabBar )
1069 sal_uLong nKey = GetWindowId( pCurWin );
1070 if ( pCurWin && ( pTabBar->GetPagePos( (sal_uInt16)nKey ) == TAB_PAGE_NOTFOUND ) )
1071 pTabBar->InsertPage( (sal_uInt16)nKey, pCurWin->GetTitle() ); // has just been faded in
1072 pTabBar->SetCurPageId( (sal_uInt16)nKey );
1074 if ( pCurWin && pCurWin->IsSuspended() ) // if the window is shown in the case of an error...
1075 pCurWin->SetStatus( pCurWin->GetStatus() & ~BASWIN_SUSPENDED );
1076 if ( pCurWin )
1078 SetWindow( pCurWin );
1079 if ( pCurWin->GetDocument().isDocument() )
1080 SfxObjectShell::SetCurrentComponent( pCurWin->GetDocument().getDocument() );
1082 else if (pLayout)
1084 SetWindow(pLayout);
1085 GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
1086 SfxObjectShell::SetCurrentComponent(nullptr);
1088 aObjectCatalog->SetCurrentEntry(pCurWin);
1089 SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : nullptr );
1090 InvalidateBasicIDESlots();
1091 InvalidateControlSlots();
1092 EnableScrollbars(pCurWin != nullptr);
1094 if ( m_pCurLocalizationMgr )
1095 m_pCurLocalizationMgr->handleTranslationbar();
1097 ManageToolbars();
1099 // fade out (in) property browser in module (dialog) windows
1100 UIFeatureChanged();
1104 void Shell::ManageToolbars()
1106 static const char aMacroBarResName[] = "private:resource/toolbar/macrobar";
1107 static const char aDialogBarResName[] = "private:resource/toolbar/dialogbar";
1108 static const char aInsertControlsBarResName[] = "private:resource/toolbar/insertcontrolsbar";
1109 static const char aFormControlsBarResName[] = "private:resource/toolbar/formcontrolsbar";
1111 if( !pCurWin )
1112 return;
1114 Reference< beans::XPropertySet > xFrameProps
1115 ( GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
1116 if ( xFrameProps.is() )
1118 Reference< css::frame::XLayoutManager > xLayoutManager;
1119 uno::Any a = xFrameProps->getPropertyValue( "LayoutManager" );
1120 a >>= xLayoutManager;
1121 if ( xLayoutManager.is() )
1123 xLayoutManager->lock();
1124 if (dynamic_cast<DialogWindow*>(pCurWin.get()))
1126 xLayoutManager->destroyElement( aMacroBarResName );
1128 xLayoutManager->requestElement( aDialogBarResName );
1129 xLayoutManager->requestElement( aInsertControlsBarResName );
1130 xLayoutManager->requestElement( aFormControlsBarResName );
1132 else
1134 xLayoutManager->destroyElement( aDialogBarResName );
1135 xLayoutManager->destroyElement( aInsertControlsBarResName );
1136 xLayoutManager->destroyElement( aFormControlsBarResName );
1138 xLayoutManager->requestElement( aMacroBarResName );
1140 xLayoutManager->unlock();
1145 VclPtr<BaseWindow> Shell::FindApplicationWindow()
1147 return FindWindow( ScriptDocument::getApplicationScriptDocument(), "", "", TYPE_UNKNOWN );
1150 VclPtr<BaseWindow> Shell::FindWindow(
1151 ScriptDocument const& rDocument,
1152 OUString const& rLibName, OUString const& rName,
1153 ItemType eType, bool bFindSuspended
1156 for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it)
1158 BaseWindow* const pWin = it->second;
1159 if (pWin->Is(rDocument, rLibName, rName, eType, bFindSuspended))
1160 return pWin;
1162 return nullptr;
1165 bool Shell::CallBasicErrorHdl( StarBASIC const * pBasic )
1167 bool bRet = false;
1168 VclPtr<ModulWindow> pModWin = ShowActiveModuleWindow( pBasic );
1169 if ( pModWin )
1170 bRet = pModWin->BasicErrorHdl( pBasic );
1171 return bRet;
1174 BasicDebugFlags Shell::CallBasicBreakHdl( StarBASIC const * pBasic )
1176 BasicDebugFlags nRet = BasicDebugFlags::NONE;
1177 VclPtr<ModulWindow> pModWin = ShowActiveModuleWindow( pBasic );
1178 if ( pModWin )
1180 bool bAppWindowDisabled, bDispatcherLocked;
1181 sal_uInt16 nWaitCount;
1182 SfxUInt16Item *pSWActionCount, *pSWLockViewCount;
1183 BasicStopped( &bAppWindowDisabled, &bDispatcherLocked,
1184 &nWaitCount, &pSWActionCount, &pSWLockViewCount );
1186 nRet = pModWin->BasicBreakHdl();
1188 if ( StarBASIC::IsRunning() ) // if cancelled...
1190 if ( bAppWindowDisabled )
1191 Application::GetDefDialogParent()->Enable(false);
1193 if ( nWaitCount )
1195 Shell* pShell = GetShell();
1196 for ( sal_uInt16 n = 0; n < nWaitCount; n++ )
1197 pShell->GetViewFrame()->GetWindow().EnterWait();
1201 return nRet;
1204 VclPtr<ModulWindow> Shell::ShowActiveModuleWindow( StarBASIC const * pBasic )
1206 SetCurLib( ScriptDocument::getApplicationScriptDocument(), OUString(), false );
1208 SbModule* pActiveModule = StarBASIC::GetActiveModule();
1209 if (SbClassModuleObject* pCMO = dynamic_cast<SbClassModuleObject*>(pActiveModule))
1210 pActiveModule = pCMO->getClassModule();
1212 DBG_ASSERT( pActiveModule, "No active module in ErrorHdl!?" );
1213 if ( pActiveModule )
1215 VclPtr<ModulWindow> pWin;
1216 SbxObject* pParent = pActiveModule->GetParent();
1217 if (StarBASIC* pLib = dynamic_cast<StarBASIC*>(pParent))
1219 if (BasicManager* pBasMgr = FindBasicManager(pLib))
1221 ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
1222 OUString aLibName = pLib->GetName();
1223 pWin = FindBasWin( aDocument, aLibName, pActiveModule->GetName(), true );
1224 DBG_ASSERT( pWin, "Error/Step-Hdl: Window was not created/found!" );
1225 SetCurLib( aDocument, aLibName );
1226 SetCurWindow( pWin, true );
1229 else
1230 SAL_WARN( "basctl.basicide", "No BASIC!");
1231 if (BasicManager* pBasicMgr = FindBasicManager(pBasic))
1232 StartListening(*pBasicMgr, DuplicateHandling::Prevent /* log on only once */);
1233 return pWin;
1235 return nullptr;
1238 void Shell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
1240 // not if iconified because the whole text would be displaced then at restore
1241 if ( GetViewFrame()->GetWindow().GetOutputSizePixel().Height() == 0 )
1242 return;
1244 Size aTabBarSize;
1245 aTabBarSize.Height() = GetViewFrame()->GetWindow().GetFont().GetFontHeight() + 4;
1246 aTabBarSize.Width() = rSize.Width();
1248 Size aSz( rSize );
1249 Size aScrollBarBoxSz( aScrollBarBox->GetSizePixel() );
1250 aSz.Height() -= aScrollBarBoxSz.Height();
1251 aSz.Height() -= aTabBarSize.Height();
1253 Size aOutSz( aSz );
1254 aSz.Width() -= aScrollBarBoxSz.Width();
1255 aScrollBarBox->SetPosPixel( Point( rSize.Width() - aScrollBarBoxSz.Width(), rSize.Height() - aScrollBarBoxSz.Height() ) );
1256 aVScrollBar->SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( aScrollBarBoxSz.Width(), aSz.Height() ) );
1257 aHScrollBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width(), aScrollBarBoxSz.Height() ) );
1258 pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aScrollBarBoxSz.Height()+aSz.Height()), aTabBarSize );
1260 if (pLayout)
1261 pLayout->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin.get()) ? aSz : aOutSz);
1264 Reference< XModel > Shell::GetCurrentDocument() const
1266 Reference< XModel > xDocument;
1267 if ( pCurWin && pCurWin->GetDocument().isDocument() )
1268 xDocument = pCurWin->GetDocument().getDocument();
1269 return xDocument;
1272 void Shell::Activate( bool bMDI )
1274 SfxViewShell::Activate( bMDI );
1276 if ( bMDI )
1278 if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin.get()))
1279 pDCurWin->UpdateBrowser();
1283 void Shell::Deactivate( bool bMDI )
1285 // bMDI == true means that another MDI has been activated; in case of a
1286 // deactivate due to a MessageBox bMDI is false
1287 if ( bMDI )
1289 if (DialogWindow* pXDlgWin = dynamic_cast<DialogWindow*>(pCurWin.get()))
1291 pXDlgWin->DisableBrowser();
1292 if( pXDlgWin->IsModified() )
1293 MarkDocumentModified( pXDlgWin->GetDocument() );
1296 // test CanClose to also test during deactivating the BasicIDE whether
1297 // the sourcecode is too large in one of the modules...
1298 for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it)
1300 BaseWindow* pWin = it->second;
1301 if ( /* !pWin->IsSuspended() && */ !pWin->CanClose() )
1303 if ( !m_aCurLibName.isEmpty() && ( pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) )
1304 SetCurLib( ScriptDocument::getApplicationScriptDocument(), OUString(), false );
1305 SetCurWindow( pWin, true );
1306 break;
1312 } // namespace basctl
1314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */