LibreOffice Module basctl (master) 1
basidesh.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <config_options.h>
21
23#include <basic/basmgr.hxx>
26#include <svx/svxids.hrc>
27#include <iderid.hxx>
28#include <strings.hrc>
29#include "baside2.hxx"
30#include <baside3.hxx>
31#include "basdoc.hxx"
32#include <IDEComboBox.hxx>
33#include <editeng/sizeitem.hxx>
34#include "iderdll2.hxx"
35#include <basidectrlr.hxx>
36#include <basidesh.hxx>
37#include <basobj.hxx>
38#include <localizationmgr.hxx>
39#include <sfx2/app.hxx>
40#include <sfx2/bindings.hxx>
41#include <sfx2/dinfdlg.hxx>
42#include <sfx2/infobar.hxx>
43#include <sfx2/minfitem.hxx>
44#include <sfx2/objface.hxx>
45#include <sfx2/viewfrm.hxx>
46#include <svl/srchitem.hxx>
47#include <tools/debug.hxx>
49
50#if defined(DISABLE_DYNLOADING) || ENABLE_MERGELIBS
51/* Avoid clash with the ones from svx/source/form/typemap.cxx */
52#define aSfxDocumentInfoItem_Impl basctl_source_basicide_basidesh_aSfxDocumentInfoItem_Impl
53#define aSfxUnoAnyItem_Impl basctl_source_basicide_basidesh_aSfxUnoAnyItem_Impl
54#endif
55
56#define ShellClass_basctl_Shell
57#define SFX_TYPEMAP
58#include <basslots.hxx>
59
60#if defined(DISABLE_DYNLOADING) || ENABLE_MERGELIBS
61#undef aSfxDocumentInfoItem_Impl
62#undef aSfxUnoAnyItem_Impl
63#endif
64
65#include <iderdll.hxx>
66#include <svx/pszctrl.hxx>
67#include <svx/insctrl.hxx>
68#include <svx/srchdlg.hxx>
69#include <com/sun/star/script/XLibraryContainerPassword.hpp>
70#include <com/sun/star/container/XContainer.hpp>
71#include <svx/xmlsecctrl.hxx>
72#include <sfx2/viewfac.hxx>
73#include <vcl/weld.hxx>
74#include <vcl/settings.hxx>
75#include <vcl/svapp.hxx>
77
78namespace basctl
79{
80constexpr OUStringLiteral BASIC_IDE_EDITOR_WINDOW = u"BasicIDEEditorWindow";
81constexpr OUStringLiteral BASIC_IDE_CURRENT_ZOOM = u"CurrentZoom";
82
83using namespace ::com::sun::star::uno;
84using namespace ::com::sun::star;
85
86class ContainerListenerImpl : public ::cppu::WeakImplHelper< container::XContainerListener >
87{
89public:
90 explicit ContainerListenerImpl(Shell* pShell)
91 : mpShell(pShell)
92 {
93 }
94
95 void addContainerListener( const ScriptDocument& rScriptDocument, const OUString& aLibName )
96 {
97 try
98 {
99 uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, false ), uno::UNO_QUERY );
100 if ( xContainer.is() )
101 {
102 uno::Reference< container::XContainerListener > xContainerListener( this );
103 xContainer->addContainerListener( xContainerListener );
104 }
105 }
106 catch(const uno::Exception& ) {}
107 }
108 void removeContainerListener( const ScriptDocument& rScriptDocument, const OUString& aLibName )
109 {
110 try
111 {
112 uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, false ), uno::UNO_QUERY );
113 if ( xContainer.is() )
114 {
115 uno::Reference< container::XContainerListener > xContainerListener( this );
116 xContainer->removeContainerListener( xContainerListener );
117 }
118 }
119 catch(const uno::Exception& ) {}
120 }
121
122 // XEventListener
123 virtual void SAL_CALL disposing( const lang::EventObject& ) override {}
124
125 // XContainerListener
126 virtual void SAL_CALL elementInserted( const container::ContainerEvent& Event ) override
127 {
128 OUString sModuleName;
129 if( mpShell && ( Event.Accessor >>= sModuleName ) )
131 }
132 virtual void SAL_CALL elementReplaced( const container::ContainerEvent& ) override { }
133 virtual void SAL_CALL elementRemoved( const container::ContainerEvent& Event ) override
134 {
135 OUString sModuleName;
136 if( mpShell && ( Event.Accessor >>= sModuleName ) )
137 {
139 if( pWin )
140 mpShell->RemoveWindow( pWin, true );
141 }
142 }
143
144};
145
147{
149}
150
152
154{
155 GetStaticInterface()->RegisterChildWindow(SID_SEARCH_DLG);
156 GetStaticInterface()->RegisterChildWindow(SID_SHOW_PROPERTYBROWSER, false, SfxShellFeature::BasicShowBrowser);
157 GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
158
159 GetStaticInterface()->RegisterPopupMenu("dialog");
160}
161
162unsigned Shell::nShellCount = 0;
163
164Shell::Shell( SfxViewFrame& rFrame_, SfxViewShell* /* pOldShell */ ) :
166 m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ),
167 aHScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame().GetWindow(), true) ),
168 aVScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame().GetWindow(), false) ),
169 pLayout(nullptr),
170 aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame().GetWindow())),
171 m_bAppBasicModified( false ),
172 m_aNotifier( *this )
173{
175 Init();
176 nShellCount++;
177}
178
180{
181 SvxPosSizeStatusBarControl::RegisterControl();
182 SvxInsertStatusBarControl::RegisterControl();
183 XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE );
184
185 SvxSearchDialogWrapper::RegisterChildWindow();
186
188
189 SetName( "BasicIDE" );
190
191 LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
192 LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );
193 SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER );
194
196 GetViewFrame().GetWindow().GetSettings().GetStyleSettings().GetWindowColor()
197 );
198
199 pCurWin = nullptr;
201 bCreatingWindow = false;
202
204
205 nCurKey = 100;
207 InitTabBar();
209
210 SetCurLib( ScriptDocument::getApplicationScriptDocument(), "Standard", false, false );
211
212 ShellCreated(this);
213
215
216 // It's enough to create the controller ...
217 // It will be public by using magic :-)
218 new Controller(this);
219
220 // Force updating the title ! Because it must be set to the controller
221 // it has to be called directly after creating those controller.
222 SetMDITitle ();
223
225}
226
228{
230
231 ShellDestroyed(this);
232
233 // so that on a basic saving error, the shell doesn't pop right up again
235
236 SetWindow( nullptr );
237 SetCurWindow( nullptr );
238
239 aObjectCatalog.disposeAndClear();
242
243 for (auto & window : aWindowTable)
244 {
245 // no store; does already happen when the BasicManagers are destroyed
246 window.second.disposeAndClear();
247 }
248
249 // no store; does already happen when the BasicManagers are destroyed
250 aWindowTable.clear();
251
252 // Destroy all ContainerListeners for Basic Container.
253 if (ContainerListenerImpl* pListener = static_cast<ContainerListenerImpl*>(m_xLibListener.get()))
254 pListener->removeContainerListener(m_aCurDocument, m_aCurLibName);
255
257
258 nShellCount--;
259
260 pDialogLayout.disposeAndClear();
261 pModulLayout.disposeAndClear();
263
264 // Remember current zoom level
267}
268
269void Shell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
270{
271 if (pCurWin)
272 pCurWin->OnNewDocument();
273
275}
276
277void Shell::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
278{
279 if (pCurWin)
280 pCurWin->OnNewDocument();
282}
283
284void Shell::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
285{
287}
288
289void Shell::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
290{
291 // #i115671: Update SID_SAVEDOC after saving is completed
292 if (SfxBindings* pBindings = GetBindingsPtr())
293 pBindings->Invalidate( SID_SAVEDOC );
294}
295
296void Shell::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
297{
299}
300
301void Shell::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
302{
303 // not interested in
304}
305
307{
308 if ( !_rDocument.isValid() )
309 return;
310
311 bool bSetCurWindow = false;
312 bool bSetCurLib = ( _rDocument == m_aCurDocument );
313 std::vector<VclPtr<BaseWindow> > aDeleteVec;
314
315 // remove all windows which belong to this document
316 for (auto const& window : aWindowTable)
317 {
318 BaseWindow* pWin = window.second;
319 if ( pWin->IsDocument( _rDocument ) )
320 {
322 {
324 pWin->Hide();
326 // there's no notify
327 pWin->BasicStopped();
328 }
329 else
330 aDeleteVec.emplace_back(pWin );
331 }
332 }
333 // delete windows outside main loop so we don't invalidate the original iterator
334 for (VclPtr<BaseWindow> const & pWin : aDeleteVec)
335 {
336 pWin->StoreData();
337 if ( pWin == pCurWin )
338 bSetCurWindow = true;
339 RemoveWindow( pWin, true, false );
340 }
341
342 // remove lib info
344 pData->GetLibInfo().RemoveInfoFor( _rDocument );
345
346 if ( bSetCurLib )
347 SetCurLib( ScriptDocument::getApplicationScriptDocument(), "Standard", true, false );
348 else if ( bSetCurWindow )
350}
351
353{
354 if (SfxBindings* pBindings = GetBindingsPtr())
355 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR, true );
356 SetMDITitle();
357}
358
360{
361 for (auto const& window : aWindowTable)
362 {
363 BaseWindow* pWin = window.second;
364 if ( pWin->IsDocument( _rDocument ) && _rDocument.isDocument() )
365 pWin->SetReadOnly( _rDocument.isReadOnly() );
366 }
367}
368
370{
372 SvtViewOptions aWinOpt(EViewType::Window, BASIC_IDE_EDITOR_WINDOW);
373 if (aWinOpt.Exists())
374 {
375 try
376 {
378 }
379 catch(const css::container::NoSuchElementException&)
380 { TOOLS_WARN_EXCEPTION("basctl.basicide", "Zoom level not defined"); }
381 }
382}
383
384// Applies the new zoom level to all open editor windows
385void Shell::SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel)
386{
387 for (auto const& window : aWindowTable)
388 {
389 ModulWindow* pModuleWindow = dynamic_cast<ModulWindow*>(window.second.get());
390 if (pModuleWindow)
391 {
392 EditorWindow& pEditorWindow = pModuleWindow->GetEditorWindow();
393 pEditorWindow.SetEditorZoomLevel(nNewZoomLevel);
394 }
395 }
396
397 // Update the zoom slider value based on the new global zoom level
398 m_nCurrentZoomSliderValue = nNewZoomLevel;
399
400 if (SfxBindings* pBindings = GetBindingsPtr())
401 {
402 pBindings->Invalidate( SID_BASICIDE_CURRENT_ZOOM );
403 pBindings->Invalidate( SID_ATTR_ZOOMSLIDER );
404 }
405}
406
407void Shell::StoreAllWindowData( bool bPersistent )
408{
409 for (auto const& window : aWindowTable)
410 {
411 BaseWindow* pWin = window.second;
412 DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" );
413 if ( !pWin->IsSuspended() )
414 pWin->StoreData();
415 }
416
417 if ( bPersistent )
418 {
420 SetAppBasicModified(false);
421
422 if (SfxBindings* pBindings = GetBindingsPtr())
423 {
424 pBindings->Invalidate( SID_SAVEDOC );
425 pBindings->Update( SID_SAVEDOC );
426 }
427 }
428}
429
430bool Shell::PrepareClose( bool bUI )
431{
432 // reset here because it's modified after printing etc. (DocInfo)
434
435 if ( StarBASIC::IsRunning() )
436 {
437 if( bUI )
438 {
439 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame().GetFrameWeld(),
440 VclMessageType::Info, VclButtonsType::Ok,
441 IDEResId(RID_STR_CANNOTCLOSE)));
442 xInfoBox->run();
443 }
444 return false;
445 }
446 else
447 {
448 StoreAllWindowData( false ); // don't write on the disk, that will be done later automatically
449 return true;
450 }
451}
452
454{
455 aVScrollBar->SetLineSize( 300 );
456 aVScrollBar->SetPageSize( 2000 );
457 aHScrollBar->SetLineSize( 300 );
458 aHScrollBar->SetPageSize( 2000 );
459}
460
462{
463 pTabBar->Enable();
464 pTabBar->Show();
465 pTabBar->SetSelectHdl( LINK( this, Shell, TabBarHdl ) );
466}
467
468void Shell::OuterResizePixel( const Point &rPos, const Size &rSize )
469{
470 AdjustPosSizePixel( rPos, rSize );
471}
472
473IMPL_LINK( Shell, TabBarHdl, ::TabBar *, pCurTabBar, void )
474{
475 sal_uInt16 nCurId = pCurTabBar->GetCurPageId();
476 BaseWindow* pWin = aWindowTable[ nCurId ].get();
477 DBG_ASSERT( pWin, "Entry in TabBar is not matching a window!" );
478 SetCurWindow( pWin );
479}
480
481
482bool Shell::NextPage( bool bPrev )
483{
484 bool bRet = false;
485 sal_uInt16 nPos = pTabBar->GetPagePos( pTabBar->GetCurPageId() );
486
487 if ( bPrev )
488 --nPos;
489 else
490 ++nPos;
491
492 if ( nPos < pTabBar->GetPageCount() )
493 {
494 VclPtr<BaseWindow> pWin = aWindowTable[ pTabBar->GetPageId( nPos ) ];
495 SetCurWindow( pWin, true );
496 bRet = true;
497 }
498
499 return bRet;
500}
501
503{
504 SfxUndoManager* pMgr = nullptr;
505 if( pCurWin )
506 pMgr = pCurWin->GetUndoManager();
507
508 return pMgr;
509}
510
511
512void Shell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
513{
514 if (!GetShell())
515 return;
516
517 if (rHint.GetId() == SfxHintId::Dying)
518 {
519 EndListening( rBC, true /* log off all */ );
520 aObjectCatalog->UpdateEntries();
521 }
522
523 SbxHint const* pSbxHint = dynamic_cast<SbxHint const*>(&rHint);
524 if (!pSbxHint)
525 return;
526
527 const SfxHintId nHintId = pSbxHint->GetId();
528 if ( ( nHintId != SfxHintId::BasicStart ) &&
529 ( nHintId != SfxHintId::BasicStop ) )
530 return;
531
532 if (SfxBindings* pBindings = GetBindingsPtr())
533 {
534 pBindings->Invalidate( SID_BASICRUN );
535 pBindings->Update( SID_BASICRUN );
536 pBindings->Invalidate( SID_BASICCOMPILE );
537 pBindings->Update( SID_BASICCOMPILE );
538 pBindings->Invalidate( SID_BASICSTEPOVER );
539 pBindings->Update( SID_BASICSTEPOVER );
540 pBindings->Invalidate( SID_BASICSTEPINTO );
541 pBindings->Update( SID_BASICSTEPINTO );
542 pBindings->Invalidate( SID_BASICSTEPOUT );
543 pBindings->Update( SID_BASICSTEPOUT );
544 pBindings->Invalidate( SID_BASICSTOP );
545 pBindings->Update( SID_BASICSTOP );
546 pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
547 pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
548 pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
549 pBindings->Update( SID_BASICIDE_MANAGEBRKPNTS );
550 pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
551 pBindings->Update( SID_BASICIDE_MODULEDLG );
552 pBindings->Invalidate( SID_BASICLOAD );
553 pBindings->Update( SID_BASICLOAD );
554 }
555
556 if ( nHintId == SfxHintId::BasicStop )
557 {
558 // not only at error/break or explicit stoppage,
559 // if the update is turned off due to a programming bug
560 BasicStopped();
561 if (pLayout)
562 pLayout->UpdateDebug(true); // clear...
564 m_pCurLocalizationMgr->handleBasicStopped();
565 }
566 else if( m_pCurLocalizationMgr )
567 {
568 m_pCurLocalizationMgr->handleBasicStarted();
569 }
570
571 for (auto const& window : aWindowTable)
572 {
573 BaseWindow* pWin = window.second;
574 if ( nHintId == SfxHintId::BasicStart )
575 pWin->BasicStarted();
576 else
577 pWin->BasicStopped();
578 }
579}
580
581
583{
584 bool bSetCurWindow = false;
585 std::vector<VclPtr<BaseWindow> > aDeleteVec;
586 for (auto const& window : aWindowTable)
587 {
588 BaseWindow* pWin = window.second;
589 if ( pWin->GetStatus() & BASWIN_TOBEKILLED )
590 aDeleteVec.emplace_back(pWin );
591 }
592 for ( VclPtr<BaseWindow> const & pWin : aDeleteVec )
593 {
594 pWin->StoreData();
595 if ( pWin == pCurWin )
596 bSetCurWindow = true;
597 RemoveWindow( pWin, true, false );
598 }
599 if ( bSetCurWindow )
601}
602
603
604void Shell::RemoveWindows( const ScriptDocument& rDocument, std::u16string_view rLibName )
605{
606 bool bChangeCurWindow = pCurWin;
607 std::vector<VclPtr<BaseWindow> > aDeleteVec;
608 for (auto const& window : aWindowTable)
609 {
610 BaseWindow* pWin = window.second;
611 if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName )
612 aDeleteVec.emplace_back(pWin );
613 }
614 for ( VclPtr<BaseWindow> const & pWin : aDeleteVec )
615 {
616 if ( pWin == pCurWin )
617 bChangeCurWindow = true;
618 pWin->StoreData();
619 RemoveWindow( pWin, true/*bDestroy*/, false );
620 }
621 if ( bChangeCurWindow )
623}
624
625
627{
628 // remove all windows that may not be displayed
629 bool bChangeCurWindow = pCurWin == nullptr;
630 // stores the total number of modules and dialogs visible
631 sal_uInt16 nTotalTabs = 0;
632
633 if ( !m_aCurLibName.isEmpty() )
634 {
635 std::vector<VclPtr<BaseWindow> > aDeleteVec;
636 for (auto const& window : aWindowTable)
637 {
638 BaseWindow* pWin = window.second;
639 if ( !pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName )
640 {
641 if ( pWin == pCurWin )
642 bChangeCurWindow = true;
643 pWin->StoreData();
644 // The request of RUNNING prevents the crash when in reschedule.
645 // Window is frozen at first, later the windows should be changed
646 // anyway to be marked as hidden instead of being deleted.
648 aDeleteVec.emplace_back(pWin );
649 }
650 }
651 for (auto const& elem : aDeleteVec)
652 {
653 RemoveWindow( elem, false, false );
654 }
655 }
656
657 if ( bCreatingWindow )
658 return;
659
660 BaseWindow* pNextActiveWindow = nullptr;
661
662 // show all windows that are to be shown
664 for (auto const& doc : aDocuments)
665 {
666 StartListening(*doc.getBasicManager(), DuplicateHandling::Prevent /* log on only once */);
667
668 // libraries
669 Sequence< OUString > aLibNames( doc.getLibraryNames() );
670 sal_Int32 nLibCount = aLibNames.getLength();
671 const OUString* pLibNames = aLibNames.getConstArray();
672
673 for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
674 {
675 OUString aLibName = pLibNames[ i ];
676
677 if ( m_aCurLibName.isEmpty() || ( doc == m_aCurDocument && aLibName == m_aCurLibName ) )
678 {
679 // check, if library is password protected and not verified
680 bool bProtected = false;
681 Reference< script::XLibraryContainer > xModLibContainer( doc.getLibraryContainer( E_SCRIPTS ) );
682 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
683 {
684 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
685 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
686 {
687 bProtected = true;
688 }
689 }
690
691 if ( !bProtected )
692 {
693 LibInfo::Item const* pLibInfoItem = nullptr;
695 pLibInfoItem = pData->GetLibInfo().GetInfo(doc, aLibName);
696
697 // modules
698 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
699 {
700 StarBASIC* pLib = doc.getBasicManager()->GetLib( aLibName );
701 if ( pLib )
702 StartListening(pLib->GetBroadcaster(), DuplicateHandling::Prevent /* log on only once */);
703
704 try
705 {
706 Sequence< OUString > aModNames( doc.getObjectNames( E_SCRIPTS, aLibName ) );
707 sal_Int32 nModCount = aModNames.getLength();
708 const OUString* pModNames = aModNames.getConstArray();
709 nTotalTabs += nModCount;
710
711 for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
712 {
713 OUString aModName = pModNames[ j ];
714 VclPtr<ModulWindow> pWin = FindBasWin( doc, aLibName, aModName );
715 if ( !pWin )
716 pWin = CreateBasWin( doc, aLibName, aModName );
717 if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aModName &&
718 pLibInfoItem->GetCurrentType() == TYPE_MODULE )
719 {
720 pNextActiveWindow = pWin;
721 }
722 }
723 }
724 catch (const container::NoSuchElementException& )
725 {
726 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
727 }
728 }
729
730 // dialogs
731 Reference< script::XLibraryContainer > xDlgLibContainer( doc.getLibraryContainer( E_DIALOGS ) );
732 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
733 {
734 try
735 {
736 Sequence< OUString > aDlgNames = doc.getObjectNames( E_DIALOGS, aLibName );
737 sal_Int32 nDlgCount = aDlgNames.getLength();
738 const OUString* pDlgNames = aDlgNames.getConstArray();
739 nTotalTabs += nDlgCount;
740
741 for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ )
742 {
743 OUString aDlgName = pDlgNames[ j ];
744 // this find only looks for non-suspended windows;
745 // suspended windows are handled in CreateDlgWin
746 VclPtr<DialogWindow> pWin = FindDlgWin( doc, aLibName, aDlgName );
747 if ( !pWin )
748 pWin = CreateDlgWin( doc, aLibName, aDlgName );
749 if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aDlgName &&
750 pLibInfoItem->GetCurrentType() == TYPE_DIALOG )
751 {
752 pNextActiveWindow = pWin;
753 }
754 }
755 }
756 catch (const container::NoSuchElementException& )
757 {
758 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
759 }
760 }
761 }
762 }
763 }
764 }
765
766 if ( bChangeCurWindow )
767 {
768 if ( nTotalTabs == 0 )
769 {
770 // If no tabs are opened, create a generic module and make it visible
771 pNextActiveWindow = CreateBasWin( m_aCurDocument, m_aCurLibName, OUString() );
772 }
773 else if ( !pNextActiveWindow )
774 {
775 pNextActiveWindow = FindApplicationWindow().get();
776 }
777 SetCurWindow( pNextActiveWindow, true );
778 }
779}
780
781void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChangeCurWindow )
782{
783 VclPtr<BaseWindow> pWindowTmp( pWindow_ );
784
785 DBG_ASSERT( pWindow_, "Cannot delete NULL-Pointer!" );
786 sal_uInt16 nKey = GetWindowId( pWindow_ );
787 pTabBar->RemovePage( nKey );
788 aWindowTable.erase( nKey );
789 if ( pWindow_ == pCurWin )
790 {
791 if ( bAllowChangeCurWindow )
792 {
794 }
795 else
796 {
797 SetCurWindow( nullptr );
798 }
799 }
800 if ( bDestroy )
801 {
802 if ( !( pWindow_->GetStatus() & BASWIN_INRESCHEDULE ) )
803 {
804 pWindowTmp.disposeAndClear();
805 }
806 else
807 {
808 pWindow_->AddStatus( BASWIN_TOBEKILLED );
809 pWindow_->Hide();
810 // In normal mode stop basic in windows to be deleted
811 // In VBA stop basic only if the running script is trying to delete
812 // its parent module
813 bool bStop = true;
814 if ( pWindow_->GetDocument().isInVBAMode() )
815 {
817 if ( !pMod || pMod->GetName() != pWindow_->GetName() )
818 {
819 bStop = false;
820 }
821 }
822 if ( bStop )
823 {
825 // there will be no notify...
826 pWindow_->BasicStopped();
827 }
828 aWindowTable[ nKey ] = pWindow_; // jump in again
829 }
830 }
831 else
832 {
833 pWindow_->AddStatus( BASWIN_SUSPENDED );
834 pWindow_->Deactivating();
835 aWindowTable[ nKey ] = pWindow_; // jump in again
836 }
837
838}
839
840
842{
843 nCurKey++;
844 aWindowTable[ nCurKey ] = pNewWin;
845 return nCurKey;
846}
847
848
850{
851 // only those that have an optic effect...
852
853 if (!GetShell())
854 return;
855
856 SfxBindings* pBindings = GetBindingsPtr();
857 if (!pBindings)
858 return;
859
860 pBindings->Invalidate( SID_COPY );
861 pBindings->Invalidate( SID_CUT );
862 pBindings->Invalidate( SID_PASTE );
863 pBindings->Invalidate( SID_UNDO );
864 pBindings->Invalidate( SID_REDO );
865 pBindings->Invalidate( SID_SAVEDOC );
866 pBindings->Invalidate( SID_SIGNATURE );
867 pBindings->Invalidate( SID_BASICIDE_CHOOSEMACRO );
868 pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
869 pBindings->Invalidate( SID_BASICIDE_OBJCAT );
870 pBindings->Invalidate( SID_BASICSTOP );
871 pBindings->Invalidate( SID_BASICRUN );
872 pBindings->Invalidate( SID_BASICCOMPILE );
873 pBindings->Invalidate( SID_BASICLOAD );
874 pBindings->Invalidate( SID_BASICSAVEAS );
875 pBindings->Invalidate( SID_BASICIDE_MATCHGROUP );
876 pBindings->Invalidate( SID_BASICSTEPINTO );
877 pBindings->Invalidate( SID_BASICSTEPOVER );
878 pBindings->Invalidate( SID_BASICSTEPOUT );
879 pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
880 pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
881 pBindings->Invalidate( SID_BASICIDE_ADDWATCH );
882 pBindings->Invalidate( SID_BASICIDE_REMOVEWATCH );
883
884 pBindings->Invalidate( SID_PRINTDOC );
885 pBindings->Invalidate( SID_PRINTDOCDIRECT );
886 pBindings->Invalidate( SID_SETUPPRINTER );
887 pBindings->Invalidate( SID_DIALOG_TESTMODE );
888
889 pBindings->Invalidate( SID_DOC_MODIFIED );
890 pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
891 pBindings->Invalidate( SID_BASICIDE_STAT_POS );
892 pBindings->Invalidate( SID_ATTR_INSERT );
893 pBindings->Invalidate( SID_ATTR_SIZE );
894}
895
897{
898 if (!GetShell())
899 return;
900
901 SfxBindings* pBindings = GetBindingsPtr();
902 if (!pBindings)
903 return;
904
905 pBindings->Invalidate( SID_INSERT_FORM_RADIO );
906 pBindings->Invalidate( SID_INSERT_FORM_CHECK );
907 pBindings->Invalidate( SID_INSERT_FORM_LIST );
908 pBindings->Invalidate( SID_INSERT_FORM_COMBO );
909 pBindings->Invalidate( SID_INSERT_FORM_VSCROLL );
910 pBindings->Invalidate( SID_INSERT_FORM_HSCROLL );
911 pBindings->Invalidate( SID_INSERT_FORM_SPIN );
912
913 pBindings->Invalidate( SID_INSERT_SELECT );
914 pBindings->Invalidate( SID_INSERT_PUSHBUTTON );
915 pBindings->Invalidate( SID_INSERT_RADIOBUTTON );
916 pBindings->Invalidate( SID_INSERT_CHECKBOX );
917 pBindings->Invalidate( SID_INSERT_LISTBOX );
918 pBindings->Invalidate( SID_INSERT_COMBOBOX );
919 pBindings->Invalidate( SID_INSERT_GROUPBOX );
920 pBindings->Invalidate( SID_INSERT_EDIT );
921 pBindings->Invalidate( SID_INSERT_FIXEDTEXT );
922 pBindings->Invalidate( SID_INSERT_IMAGECONTROL );
923 pBindings->Invalidate( SID_INSERT_PROGRESSBAR );
924 pBindings->Invalidate( SID_INSERT_HSCROLLBAR );
925 pBindings->Invalidate( SID_INSERT_VSCROLLBAR );
926 pBindings->Invalidate( SID_INSERT_HFIXEDLINE );
927 pBindings->Invalidate( SID_INSERT_VFIXEDLINE );
928 pBindings->Invalidate( SID_INSERT_DATEFIELD );
929 pBindings->Invalidate( SID_INSERT_TIMEFIELD );
930 pBindings->Invalidate( SID_INSERT_NUMERICFIELD );
931 pBindings->Invalidate( SID_INSERT_CURRENCYFIELD );
932 pBindings->Invalidate( SID_INSERT_FORMATTEDFIELD );
933 pBindings->Invalidate( SID_INSERT_PATTERNFIELD );
934 pBindings->Invalidate( SID_INSERT_FILECONTROL );
935 pBindings->Invalidate( SID_INSERT_SPINBUTTON );
936 pBindings->Invalidate( SID_INSERT_GRIDCONTROL );
937 pBindings->Invalidate( SID_INSERT_HYPERLINKCONTROL );
938 pBindings->Invalidate( SID_INSERT_TREECONTROL );
939 pBindings->Invalidate( SID_CHOOSE_CONTROLS );
940}
941
942void Shell::SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows, bool bCheck )
943{
944 if ( bCheck && rDocument == m_aCurDocument && aLibName == m_aCurLibName )
945 return;
946
947 ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
948
949 if (pListener)
951
952 m_aCurDocument = rDocument;
953 m_aCurLibName = aLibName;
954
955 if ( pListener )
956 pListener->addContainerListener( m_aCurDocument, aLibName );
957
958 if ( bUpdateWindows )
960
961 SetMDITitle();
962
963 SetCurLibForLocalization( rDocument, aLibName );
964
965 if (SfxBindings* pBindings = GetBindingsPtr())
966 {
967 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
968 pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
969 pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG );
970 }
971}
972
973void Shell::SetCurLibForLocalization( const ScriptDocument& rDocument, const OUString& aLibName )
974{
975 // Create LocalizationMgr
977 try
978 {
979 if( !aLibName.isEmpty() )
980 {
981 Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, true ) );
982 xStringResourceManager = LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
983 }
984 }
985 catch (const container::NoSuchElementException& )
986 {}
987
988 m_pCurLocalizationMgr = std::make_shared<LocalizationMgr>(this, rDocument, aLibName, xStringResourceManager);
989 m_pCurLocalizationMgr->handleTranslationbar();
990}
991
992} // namespace basctl
993
994/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxApplication * SfxGetpApp()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
void SaveBasicAndDialogContainer() const
void Invalidate(sal_uInt16 nId)
SfxHintId GetId() const
virtual void SetModified(bool bModified=true)
void SetName(const OUString &rName)
vcl::Window & GetWindow() const
virtual SfxObjectShell * GetObjectShell() override
weld::Window * GetFrameWeld() const
SfxViewFrame & GetViewFrame() const
void SetWindow(vcl::Window *pViewPort)
vcl::Window * GetWindow() const
static bool IsRunning()
static void Stop()
static SbModule * GetActiveModule()
css::uno::Any GetUserItem(const OUString &sName) const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
bool Exists() const
void disposeAndClear()
void reset(reference_type *pBody)
virtual void BasicStopped()
Definition: bastypes.cxx:251
const OUString & GetLibName() const
Definition: bastypes.hxx:234
bool IsDocument(const ScriptDocument &rDocument) const
Definition: bastypes.hxx:233
int GetStatus() const
Definition: bastypes.hxx:216
virtual void SetReadOnly(bool bReadOnly)
Definition: bastypes.cxx:225
virtual void Deactivating()=0
const OUString & GetName() const
Definition: bastypes.hxx:236
void AddStatus(int n)
Definition: bastypes.hxx:218
virtual void StoreData()
Definition: bastypes.cxx:195
virtual void BasicStarted()
Definition: bastypes.cxx:247
const ScriptDocument & GetDocument() const
Definition: bastypes.hxx:232
bool IsSuspended() const
Definition: bastypes.hxx:229
void addContainerListener(const ScriptDocument &rScriptDocument, const OUString &aLibName)
Definition: basidesh.cxx:95
ContainerListenerImpl(Shell *pShell)
Definition: basidesh.cxx:90
virtual void SAL_CALL disposing(const lang::EventObject &) override
Definition: basidesh.cxx:123
virtual void SAL_CALL elementRemoved(const container::ContainerEvent &Event) override
Definition: basidesh.cxx:133
virtual void SAL_CALL elementInserted(const container::ContainerEvent &Event) override
Definition: basidesh.cxx:126
void removeContainerListener(const ScriptDocument &rScriptDocument, const OUString &aLibName)
Definition: basidesh.cxx:108
virtual void SAL_CALL elementReplaced(const container::ContainerEvent &) override
Definition: basidesh.cxx:132
void SetEditorZoomLevel(sal_uInt16 nNewZoomLevel)
Definition: baside2b.cxx:1296
bool & ShellInCriticalSection()
Definition: iderdll2.hxx:56
ItemType GetCurrentType() const
Definition: bastypes.hxx:287
const OUString & GetCurrentName() const
Definition: bastypes.hxx:286
static css::uno::Reference< css::resource::XStringResourceManager > getStringResourceFromDialogLibrary(const css::uno::Reference< css::container::XNameContainer > &xDialogLib)
EditorWindow & GetEditorWindow()
Definition: baside2.hxx:367
A docking window that contains a tree of the currently loaded macros.
encapsulates a document which contains Basic scripts and dialogs
bool isDocument() const
determines whether the ScriptDocument instance operates on a real document, as opposed to the whole a...
@ AllWithApplication
all ScriptDocuments, including the dedicated one which represents the application-wide scripts/dialog...
static ScriptDocuments getAllScriptDocuments(ScriptDocumentList _eListType)
returns the set of ScriptDocument instances, one for each open document which contains Basic/Dialog c...
static const ScriptDocument & getApplicationScriptDocument()
returns a reference to a shared ScriptDocument instance which operates on the application-wide script...
css::uno::Reference< css::container::XNameContainer > getLibrary(LibraryContainerType _eType, const OUString &_rLibName, bool _bLoadLibrary) const
returns a script or dialog library given by name
bool isReadOnly() const
determines whether the document is read-only
bool isValid() const
determines whether the document is actually able to contain Basic/Dialog libraries
friend class ContainerListenerImpl
Definition: basidesh.hxx:96
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: basidesh.cxx:512
void RemoveWindow(BaseWindow *pWindow, bool bDestroy, bool bAllowChangeCurWindow=true)
Definition: basidesh.cxx:781
Shell(SfxViewFrame &rFrame, SfxViewShell *pOldSh)
Definition: basidesh.cxx:164
DocumentEventNotifier m_aNotifier
Definition: basidesh.hxx:94
static void InvalidateControlSlots()
Definition: basidesh.cxx:896
virtual bool PrepareClose(bool bUI=true) override
Definition: basidesh.cxx:430
std::shared_ptr< LocalizationMgr > m_pCurLocalizationMgr
Definition: basidesh.hxx:75
void SetCurLib(const ScriptDocument &rDocument, const OUString &aLibName, bool bUpdateWindows=true, bool bCheck=true)
Definition: basidesh.cxx:942
void SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel)
Definition: basidesh.cxx:385
virtual void onDocumentOpened(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:277
VclPtr< ModulWindow > FindBasWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rModName, bool bCreateIfNotExist=false, bool bFindSuspended=false)
Definition: basides2.cxx:205
sal_uInt16 GetWindowId(BaseWindow const *pWin) const
Definition: basides3.cxx:125
void SetCurLibForLocalization(const ScriptDocument &rDocument, const OUString &aLibName)
Definition: basidesh.cxx:973
virtual ~Shell() override
Definition: basidesh.cxx:227
static unsigned nShellCount
Definition: basidesh.hxx:115
VclPtr< TabBar > pTabBar
Definition: basidesh.hxx:81
virtual void onDocumentCreated(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:269
virtual void onDocumentClosed(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:306
VclPtr< ScrollAdaptor > aVScrollBar
Definition: basidesh.hxx:80
void SetAppBasicModified(bool bModified)
Definition: basidesh.hxx:206
VclPtr< ModulWindowLayout > pModulLayout
Definition: basidesh.hxx:85
static void InitInterface_Impl()
SfxInterface initializer.
OUString m_aCurLibName
Definition: basidesh.hxx:74
void CheckWindows()
Definition: basidesh.cxx:582
bool NextPage(bool bPrev)
Definition: basidesh.cxx:482
ScriptDocument m_aCurDocument
Definition: basidesh.hxx:73
virtual void onDocumentSaveAsDone(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:301
virtual void onDocumentSave(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:284
void SetMDITitle()
Definition: basides2.cxx:100
bool bCreatingWindow
Definition: basidesh.hxx:82
sal_uInt16 nCurKey
Definition: basidesh.hxx:71
VclPtr< DialogWindow > FindDlgWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rName, bool bCreateIfNotExist=false, bool bFindSuspended=false)
Definition: basides3.cxx:114
VclPtr< BaseWindow > FindApplicationWindow()
Definition: basides1.cxx:1386
VclPtr< ModulWindow > CreateBasWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rModName)
Definition: basides2.cxx:131
VclPtr< DialogWindow > CreateDlgWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rDlgName)
Definition: basides3.cxx:42
void RemoveWindows(const ScriptDocument &rDocument, std::u16string_view rLibName)
Definition: basidesh.cxx:604
SfxUndoManager * GetUndoManager() override
Definition: basidesh.cxx:502
void UpdateWindows()
Definition: basidesh.cxx:626
void InitZoomLevel()
Definition: basidesh.cxx:369
virtual void onDocumentTitleChanged(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:352
VclPtr< ObjectCatalog > aObjectCatalog
Definition: basidesh.hxx:89
VclPtr< Layout > pLayout
Definition: basidesh.hxx:87
virtual void OuterResizePixel(const Point &rPos, const Size &rSize) override
Definition: basidesh.cxx:468
VclPtr< ScrollAdaptor > aHScrollBar
Definition: basidesh.hxx:79
sal_uInt16 m_nCurrentZoomSliderValue
Definition: basidesh.hxx:78
virtual void onDocumentSaveDone(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:289
virtual void onDocumentSaveAs(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:296
void InitScrollBars()
Definition: basidesh.cxx:453
css::uno::Reference< css::container::XContainerListener > m_xLibListener
Definition: basidesh.hxx:97
sal_uInt16 InsertWindowInTable(BaseWindow *pNewWin)
Definition: basidesh.cxx:841
VclPtr< BaseWindow > pCurWin
Definition: basidesh.hxx:72
WindowTable aWindowTable
Definition: basidesh.hxx:70
void SetCurWindow(BaseWindow *pNewWin, bool bUpdateTabBar=false, bool bRememberAsCurrent=true)
Definition: basides1.cxx:1271
void InitTabBar()
Definition: basidesh.cxx:461
virtual void onDocumentModeChanged(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:359
void AdjustPosSizePixel(const Point &rPos, const Size &rSize)
Definition: basides1.cxx:1478
void StoreAllWindowData(bool bPersistent=true)
Definition: basidesh.cxx:407
static void InvalidateBasicIDESlots()
Definition: basidesh.cxx:849
VclPtr< DialogWindowLayout > pDialogLayout
Definition: basidesh.hxx:86
void SetBackground()
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
float u
SfxHintId
sal_uInt16 nPos
const char * pLib
std::unique_ptr< sal_Int32[]> pData
constexpr sal_uInt16 DEFAULT_ZOOM_LEVEL
Definition: basidesh.hxx:46
SfxBindings * GetBindingsPtr()
Definition: basobj3.cxx:426
constexpr OUStringLiteral BASIC_IDE_CURRENT_ZOOM
Definition: basidesh.cxx:81
void BasicStopped(bool *pbAppWindowDisabled, bool *pbDispatcherLocked, sal_uInt16 *pnWaitCount, SfxUInt16Item **ppSWActionCount, SfxUInt16Item **ppSWLockViewCount)
Definition: basobj3.cxx:300
SFX_IMPL_NAMED_VIEWFACTORY(Shell, "Default")
Definition: basidesh.cxx:146
ExtraData * GetExtraData()
Definition: iderdll.cxx:101
constexpr OUStringLiteral BASIC_IDE_EDITOR_WINDOW
Definition: basidesh.cxx:80
Shell * GetShell()
Definition: iderdll.cxx:80
void ShellCreated(Shell *pShell)
Definition: iderdll.cxx:87
IMPL_LINK(AccessibleDialogWindow, WindowEventListener, VclWindowEvent &, rEvent, void)
@ BASWIN_INRESCHEDULE
Definition: bastypes.hxx:148
@ BASWIN_SUSPENDED
Definition: bastypes.hxx:147
@ BASWIN_TOBEKILLED
Definition: bastypes.hxx:146
@ BASWIN_RUNNINGBASIC
Definition: bastypes.hxx:145
std::vector< ScriptDocument > ScriptDocuments
@ TYPE_MODULE
Definition: sbxitem.hxx:32
@ TYPE_DIALOG
Definition: sbxitem.hxx:33
OUString IDEResId(TranslateId aId)
Definition: iderdll.cxx:108
void ShellDestroyed(Shell const *pShell)
Definition: iderdll.cxx:94
int i
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
#define SFX_IMPL_INTERFACE(Class, SuperClass)
#define SFX_VIEW_REGISTRATION(DocClass)
SfxViewShellFlags