20#include <config_options.h>
26#include <svx/svxids.hrc>
50#if defined(DISABLE_DYNLOADING) || ENABLE_MERGELIBS
52#define aSfxDocumentInfoItem_Impl basctl_source_basicide_basidesh_aSfxDocumentInfoItem_Impl
53#define aSfxUnoAnyItem_Impl basctl_source_basicide_basidesh_aSfxUnoAnyItem_Impl
56#define ShellClass_basctl_Shell
58#include <basslots.hxx>
60#if defined(DISABLE_DYNLOADING) || ENABLE_MERGELIBS
61#undef aSfxDocumentInfoItem_Impl
62#undef aSfxUnoAnyItem_Impl
69#include <com/sun/star/script/XLibraryContainerPassword.hpp>
70#include <com/sun/star/container/XContainer.hpp>
99 uno::Reference< container::XContainer > xContainer( rScriptDocument.
getLibrary(
E_SCRIPTS, aLibName,
false ), uno::UNO_QUERY );
100 if ( xContainer.is() )
102 uno::Reference< container::XContainerListener > xContainerListener(
this );
103 xContainer->addContainerListener( xContainerListener );
106 catch(
const uno::Exception& ) {}
112 uno::Reference< container::XContainer > xContainer( rScriptDocument.
getLibrary(
E_SCRIPTS, aLibName,
false ), uno::UNO_QUERY );
113 if ( xContainer.is() )
115 uno::Reference< container::XContainerListener > xContainerListener(
this );
116 xContainer->removeContainerListener( xContainerListener );
119 catch(
const uno::Exception& ) {}
123 virtual void SAL_CALL
disposing(
const lang::EventObject& )
override {}
126 virtual void SAL_CALL
elementInserted(
const container::ContainerEvent& Event )
override
128 OUString sModuleName;
129 if(
mpShell && ( Event.Accessor >>= sModuleName ) )
132 virtual void SAL_CALL
elementReplaced(
const container::ContainerEvent& )
override { }
133 virtual void SAL_CALL
elementRemoved(
const container::ContainerEvent& Event )
override
135 OUString sModuleName;
136 if(
mpShell && ( Event.Accessor >>= sModuleName ) )
155 GetStaticInterface()->RegisterChildWindow(SID_SEARCH_DLG);
156 GetStaticInterface()->RegisterChildWindow(SID_SHOW_PROPERTYBROWSER,
false, SfxShellFeature::BasicShowBrowser);
157 GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
159 GetStaticInterface()->RegisterPopupMenu(
"dialog");
171 m_bAppBasicModified( false ),
181 SvxPosSizeStatusBarControl::RegisterControl();
182 SvxInsertStatusBarControl::RegisterControl();
183 XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE );
185 SvxSearchDialogWrapper::RegisterChildWindow();
191 LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
192 LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );
193 SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER );
246 window.second.disposeAndClear();
293 pBindings->Invalidate( SID_SAVEDOC );
311 bool bSetCurWindow =
false;
313 std::vector<VclPtr<BaseWindow> > aDeleteVec;
330 aDeleteVec.emplace_back(pWin );
338 bSetCurWindow =
true;
344 pData->GetLibInfo().RemoveInfoFor( _rDocument );
348 else if ( bSetCurWindow )
355 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR,
true );
379 catch(
const css::container::NoSuchElementException&)
402 pBindings->Invalidate( SID_BASICIDE_CURRENT_ZOOM );
403 pBindings->Invalidate( SID_ATTR_ZOOMSLIDER );
412 DBG_ASSERT( pWin,
"PrepareClose: NULL-Pointer in Table?" );
424 pBindings->Invalidate( SID_SAVEDOC );
425 pBindings->Update( SID_SAVEDOC );
440 VclMessageType::Info, VclButtonsType::Ok,
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 );
492 if ( nPos < pTabBar->GetPageCount() )
506 pMgr =
pCurWin->GetUndoManager();
517 if (rHint.
GetId() == SfxHintId::Dying)
519 EndListening( rBC,
true );
527 const SfxHintId nHintId = pSbxHint->GetId();
528 if ( ( nHintId != SfxHintId::BasicStart ) &&
529 ( nHintId != SfxHintId::BasicStop ) )
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 );
556 if ( nHintId == SfxHintId::BasicStop )
574 if ( nHintId == SfxHintId::BasicStart )
584 bool bSetCurWindow =
false;
585 std::vector<VclPtr<BaseWindow> > aDeleteVec;
590 aDeleteVec.emplace_back(pWin );
596 bSetCurWindow =
true;
606 bool bChangeCurWindow =
pCurWin;
607 std::vector<VclPtr<BaseWindow> > aDeleteVec;
612 aDeleteVec.emplace_back(pWin );
617 bChangeCurWindow =
true;
621 if ( bChangeCurWindow )
629 bool bChangeCurWindow =
pCurWin ==
nullptr;
631 sal_uInt16 nTotalTabs = 0;
635 std::vector<VclPtr<BaseWindow> > aDeleteVec;
642 bChangeCurWindow =
true;
648 aDeleteVec.emplace_back(pWin );
651 for (
auto const& elem : aDeleteVec)
664 for (
auto const& doc : aDocuments)
666 StartListening(*doc.getBasicManager(), DuplicateHandling::Prevent );
670 sal_Int32 nLibCount = aLibNames.getLength();
671 const OUString* pLibNames = aLibNames.getConstArray();
673 for ( sal_Int32
i = 0 ;
i < nLibCount ;
i++ )
675 OUString aLibName = pLibNames[
i ];
680 bool bProtected =
false;
682 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
685 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
695 pLibInfoItem =
pData->GetLibInfo().GetInfo(doc, aLibName);
698 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
707 sal_Int32 nModCount = aModNames.getLength();
708 const OUString* pModNames = aModNames.getConstArray();
709 nTotalTabs += nModCount;
711 for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
713 OUString aModName = pModNames[ j ];
717 if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->
GetCurrentName() == aModName &&
720 pNextActiveWindow = pWin;
724 catch (
const container::NoSuchElementException& )
732 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
737 sal_Int32 nDlgCount = aDlgNames.getLength();
738 const OUString* pDlgNames = aDlgNames.getConstArray();
739 nTotalTabs += nDlgCount;
741 for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ )
743 OUString aDlgName = pDlgNames[ j ];
749 if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->
GetCurrentName() == aDlgName &&
752 pNextActiveWindow = pWin;
756 catch (
const container::NoSuchElementException& )
766 if ( bChangeCurWindow )
768 if ( nTotalTabs == 0 )
773 else if ( !pNextActiveWindow )
785 DBG_ASSERT( pWindow_,
"Cannot delete NULL-Pointer!" );
791 if ( bAllowChangeCurWindow )
867 pBindings->
Invalidate( SID_BASICIDE_CHOOSEMACRO );
868 pBindings->
Invalidate( SID_BASICIDE_MODULEDLG );
875 pBindings->
Invalidate( SID_BASICIDE_MATCHGROUP );
879 pBindings->
Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
880 pBindings->
Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
881 pBindings->
Invalidate( SID_BASICIDE_ADDWATCH );
882 pBindings->
Invalidate( SID_BASICIDE_REMOVEWATCH );
890 pBindings->
Invalidate( SID_BASICIDE_STAT_TITLE );
891 pBindings->
Invalidate( SID_BASICIDE_STAT_POS );
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 );
914 pBindings->
Invalidate( SID_INSERT_PUSHBUTTON );
915 pBindings->
Invalidate( SID_INSERT_RADIOBUTTON );
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 );
958 if ( bUpdateWindows )
967 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
968 pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
969 pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG );
979 if( !aLibName.isEmpty() )
985 catch (
const container::NoSuchElementException& )
988 m_pCurLocalizationMgr = std::make_shared<LocalizationMgr>(
this, rDocument, aLibName, xStringResourceManager);
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)
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 SbModule * GetActiveModule()
css::uno::Any GetUserItem(const OUString &sName) const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
void reset(reference_type *pBody)
virtual void BasicStopped()
const OUString & GetLibName() const
bool IsDocument(const ScriptDocument &rDocument) const
virtual void SetReadOnly(bool bReadOnly)
virtual void Deactivating()=0
const OUString & GetName() const
virtual void BasicStarted()
const ScriptDocument & GetDocument() const
void addContainerListener(const ScriptDocument &rScriptDocument, const OUString &aLibName)
ContainerListenerImpl(Shell *pShell)
virtual void SAL_CALL disposing(const lang::EventObject &) override
virtual void SAL_CALL elementRemoved(const container::ContainerEvent &Event) override
virtual void SAL_CALL elementInserted(const container::ContainerEvent &Event) override
void removeContainerListener(const ScriptDocument &rScriptDocument, const OUString &aLibName)
virtual void SAL_CALL elementReplaced(const container::ContainerEvent &) override
void SetEditorZoomLevel(sal_uInt16 nNewZoomLevel)
ItemType GetCurrentType() const
const OUString & GetCurrentName() const
static css::uno::Reference< css::resource::XStringResourceManager > getStringResourceFromDialogLibrary(const css::uno::Reference< css::container::XNameContainer > &xDialogLib)
EditorWindow & GetEditorWindow()
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
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
void RemoveWindow(BaseWindow *pWindow, bool bDestroy, bool bAllowChangeCurWindow=true)
Shell(SfxViewFrame &rFrame, SfxViewShell *pOldSh)
DocumentEventNotifier m_aNotifier
static void InvalidateControlSlots()
virtual bool PrepareClose(bool bUI=true) override
std::shared_ptr< LocalizationMgr > m_pCurLocalizationMgr
void SetCurLib(const ScriptDocument &rDocument, const OUString &aLibName, bool bUpdateWindows=true, bool bCheck=true)
void SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel)
virtual void onDocumentOpened(const ScriptDocument &_rDocument) override
VclPtr< ModulWindow > FindBasWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rModName, bool bCreateIfNotExist=false, bool bFindSuspended=false)
sal_uInt16 GetWindowId(BaseWindow const *pWin) const
void SetCurLibForLocalization(const ScriptDocument &rDocument, const OUString &aLibName)
virtual ~Shell() override
static unsigned nShellCount
virtual void onDocumentCreated(const ScriptDocument &_rDocument) override
virtual void onDocumentClosed(const ScriptDocument &_rDocument) override
VclPtr< ScrollAdaptor > aVScrollBar
void SetAppBasicModified(bool bModified)
VclPtr< ModulWindowLayout > pModulLayout
static void InitInterface_Impl()
SfxInterface initializer.
bool NextPage(bool bPrev)
ScriptDocument m_aCurDocument
virtual void onDocumentSaveAsDone(const ScriptDocument &_rDocument) override
virtual void onDocumentSave(const ScriptDocument &_rDocument) override
VclPtr< DialogWindow > FindDlgWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rName, bool bCreateIfNotExist=false, bool bFindSuspended=false)
VclPtr< BaseWindow > FindApplicationWindow()
VclPtr< ModulWindow > CreateBasWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rModName)
VclPtr< DialogWindow > CreateDlgWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rDlgName)
void RemoveWindows(const ScriptDocument &rDocument, std::u16string_view rLibName)
SfxUndoManager * GetUndoManager() override
virtual void onDocumentTitleChanged(const ScriptDocument &_rDocument) override
VclPtr< ObjectCatalog > aObjectCatalog
virtual void OuterResizePixel(const Point &rPos, const Size &rSize) override
VclPtr< ScrollAdaptor > aHScrollBar
sal_uInt16 m_nCurrentZoomSliderValue
virtual void onDocumentSaveDone(const ScriptDocument &_rDocument) override
virtual void onDocumentSaveAs(const ScriptDocument &_rDocument) override
css::uno::Reference< css::container::XContainerListener > m_xLibListener
sal_uInt16 InsertWindowInTable(BaseWindow *pNewWin)
VclPtr< BaseWindow > pCurWin
void SetCurWindow(BaseWindow *pNewWin, bool bUpdateTabBar=false, bool bRememberAsCurrent=true)
virtual void onDocumentModeChanged(const ScriptDocument &_rDocument) override
void AdjustPosSizePixel(const Point &rPos, const Size &rSize)
void StoreAllWindowData(bool bPersistent=true)
static void InvalidateBasicIDESlots()
VclPtr< DialogWindowLayout > pDialogLayout
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
constexpr sal_uInt16 DEFAULT_ZOOM_LEVEL
SfxBindings * GetBindingsPtr()
constexpr OUStringLiteral BASIC_IDE_CURRENT_ZOOM
void BasicStopped(bool *pbAppWindowDisabled, bool *pbDispatcherLocked, sal_uInt16 *pnWaitCount, SfxUInt16Item **ppSWActionCount, SfxUInt16Item **ppSWLockViewCount)
SFX_IMPL_NAMED_VIEWFACTORY(Shell, "Default")
ExtraData * GetExtraData()
constexpr OUStringLiteral BASIC_IDE_EDITOR_WINDOW
void ShellCreated(Shell *pShell)
IMPL_LINK(AccessibleDialogWindow, WindowEventListener, VclWindowEvent &, rEvent, void)
std::vector< ScriptDocument > ScriptDocuments
OUString IDEResId(TranslateId aId)
void ShellDestroyed(Shell const *pShell)
#define SFX_IMPL_INTERFACE(Class, SuperClass)
#define SFX_VIEW_REGISTRATION(DocClass)