1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "doceventnotifier.hxx"
22 #include <basctl/sbxitem.hxx>
23 #include "ObjectCatalog.hxx"
25 #include <com/sun/star/container/XContainerListener.hpp>
26 #include <sfx2/viewsh.hxx>
27 #include <svx/ifaceids.hxx>
28 #include <svl/srchitem.hxx>
29 #include <svtools/scrolladaptor.hxx>
32 #include <string_view>
44 // Used to control zoom level
45 constexpr sal_uInt16 MIN_ZOOM_LEVEL
= 50;
46 constexpr sal_uInt16 DEFAULT_ZOOM_LEVEL
= 100;
47 constexpr sal_uInt16 MAX_ZOOM_LEVEL
= 400;
51 class ModulWindowLayout
;
53 class DialogWindowLayout
;
56 class LocalizationMgr
;
57 class BasicColorConfig
;
58 class ContainerListenerImpl
;
62 public DocumentEventListener
65 typedef std::map
<sal_uInt16
, VclPtr
<BaseWindow
> > WindowTable
;
68 friend class JavaDebuggingListenerImpl
;
69 friend class LocalizationMgr
;
70 friend bool implImportDialog(weld::Window
* pWin
, const ScriptDocument
& rDocument
, const OUString
& rLibName
); // defined in baside3.cxx
72 WindowTable aWindowTable
;
74 VclPtr
<BaseWindow
> pCurWin
;
75 ScriptDocument m_aCurDocument
;
76 OUString m_aCurLibName
;
77 std::shared_ptr
<LocalizationMgr
> m_pCurLocalizationMgr
;
79 // Current value of the zoom slider
80 sal_uInt16 m_nCurrentZoomSliderValue
;
81 VclPtr
<ScrollAdaptor
> aHScrollBar
;
82 VclPtr
<ScrollAdaptor
> aVScrollBar
;
83 VclPtr
<TabBar
> pTabBar
; // basctl::TabBar
86 // Basic editor color configuration
87 std::shared_ptr
<BasicColorConfig
> m_aColorConfig
;
90 VclPtr
<ModulWindowLayout
> pModulLayout
;
91 VclPtr
<DialogWindowLayout
> pDialogLayout
;
92 VclPtr
<Layout
> pLayout
; // the active layout window
93 // common object catalog window
94 VclPtr
<ObjectCatalog
> aObjectCatalog
;
96 bool m_bAppBasicModified
;
97 bool mbJustOpened
= false;
99 DocumentEventNotifier m_aNotifier
;
101 friend class ContainerListenerImpl
;
102 rtl::Reference
<ContainerListenerImpl
> m_xLibListener
;
103 std::unique_ptr
<SvxSearchItem
> mpSearchItem
;
107 void InitScrollBars();
108 void InitZoomLevel();
110 void RemoveWindows( const ScriptDocument
& rDocument
, std::u16string_view rLibName
);
111 void UpdateWindows();
112 static void InvalidateBasicIDESlots();
113 void StoreAllWindowData( bool bPersistent
= true );
115 void SetCurLib( const ScriptDocument
& rDocument
, const OUString
& aLibName
, bool bUpdateWindows
= true , bool bCheck
= true );
116 void SetCurLibForLocalization( const ScriptDocument
& rDocument
, const OUString
& aLibName
);
118 DECL_LINK( TabBarHdl
, ::TabBar
*, void );
120 static unsigned nShellCount
;
123 void AdjustPosSizePixel( const Point
&rPos
, const Size
&rSize
);
124 virtual void OuterResizePixel( const Point
&rPos
, const Size
&rSize
) override
;
125 sal_uInt16
InsertWindowInTable (BaseWindow
* pNewWin
);
126 virtual bool PrepareClose( bool bUI
= true ) override
;
128 void SetCurWindow (BaseWindow
* pNewWin
, bool bUpdateTabBar
= false, bool bRememberAsCurrent
= true);
129 void ManageToolbars();
131 VclPtr
<ModulWindow
> CreateBasWin( const ScriptDocument
& rDocument
, const OUString
& rLibName
, const OUString
& rModName
);
132 VclPtr
<DialogWindow
> CreateDlgWin( const ScriptDocument
& rDocument
, const OUString
& rLibName
, const OUString
& rDlgName
);
134 VclPtr
<ModulWindow
> ShowActiveModuleWindow( StarBASIC
const * pBasic
);
136 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
138 virtual void Activate(bool bMDI
) override
;
139 virtual void Deactivate(bool bMDI
) override
;
141 virtual void Move() override
;
142 virtual void ShowCursor( bool bOn
= true ) override
;
144 // DocumentEventListener
145 virtual void onDocumentCreated( const ScriptDocument
& _rDocument
) override
;
146 virtual void onDocumentOpened( const ScriptDocument
& _rDocument
) override
;
147 virtual void onDocumentSave( const ScriptDocument
& _rDocument
) override
;
148 virtual void onDocumentSaveDone( const ScriptDocument
& _rDocument
) override
;
149 virtual void onDocumentSaveAs( const ScriptDocument
& _rDocument
) override
;
150 virtual void onDocumentSaveAsDone( const ScriptDocument
& _rDocument
) override
;
151 virtual void onDocumentClosed( const ScriptDocument
& _rDocument
) override
;
152 virtual void onDocumentTitleChanged( const ScriptDocument
& _rDocument
) override
;
153 virtual void onDocumentModeChanged( const ScriptDocument
& _rDocument
) override
;
156 SFX_DECL_INTERFACE( SVX_INTERFACE_BASIDE_VIEWSH
)
157 SFX_DECL_VIEWFACTORY(Shell
);
160 /// SfxInterface initializer.
161 static void InitInterface_Impl();
164 Shell(SfxViewFrame
& rFrame
, SfxViewShell
*pOldSh
);
165 virtual ~Shell() override
;
167 BaseWindow
* GetCurWindow() const { return pCurWin
; }
168 OUString
const& GetCurLibName() const { return m_aCurLibName
; }
169 const std::shared_ptr
<LocalizationMgr
>& GetCurLocalizationMgr() const { return m_pCurLocalizationMgr
; }
171 TabBar
& GetTabBar() { return *pTabBar
; }
172 WindowTable
& GetWindowTable() { return aWindowTable
; }
173 sal_uInt16
GetWindowId (BaseWindow
const* pWin
) const;
175 SdrView
* GetCurDlgView() const;
177 SfxUndoManager
* GetUndoManager() override
;
179 void SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel
);
180 sal_uInt16
GetCurrentZoomSliderValue() { return m_nCurrentZoomSliderValue
; }
181 static sal_uInt16
GetMinZoom() { return MIN_ZOOM_LEVEL
; }
182 static sal_uInt16
GetMaxZoom() { return MAX_ZOOM_LEVEL
; }
184 virtual css::uno::Reference
< css::view::XRenderable
> GetRenderable() override
;
186 // virtual sal_uInt16 Print( SfxProgress &rProgress, sal_Bool bIsAPI, PrintDialog *pPrintDialog = 0 );
187 virtual SfxPrinter
* GetPrinter( bool bCreate
= false ) override
;
188 virtual sal_uInt16
SetPrinter( SfxPrinter
*pNewPrinter
, SfxPrinterChangeFlags nDiffFlags
= SFX_PRINTER_ALL
) override
;
189 virtual OUString
GetSelectionText( bool bCompleteWords
= false, bool bOnlyASample
= false ) override
;
190 virtual bool HasSelection( bool bText
= true ) const override
;
192 void GetState( SfxItemSet
& );
193 void ExecuteGlobal( SfxRequest
& rReq
);
194 void ExecuteSearch( SfxRequest
& rReq
);
195 void ExecuteCurrent( SfxRequest
& rReq
);
196 void ExecuteBasic( SfxRequest
& rReq
);
197 void ExecuteDialog( SfxRequest
& rReq
);
199 virtual bool HasUIFeature(SfxShellFeature nFeature
) const override
;
201 bool CallBasicErrorHdl( StarBASIC
const * pBasic
);
202 BasicDebugFlags
CallBasicBreakHdl( StarBASIC
const * pBasic
);
204 VclPtr
<BaseWindow
> FindWindow( const ScriptDocument
& rDocument
, std::u16string_view rLibName
, std::u16string_view rName
, SbxItemType nSbxType
, bool bFindSuspended
= false );
205 VclPtr
<DialogWindow
> FindDlgWin( const ScriptDocument
& rDocument
, const OUString
& rLibName
, const OUString
& rName
, bool bCreateIfNotExist
= false, bool bFindSuspended
= false );
206 VclPtr
<ModulWindow
> FindBasWin( const ScriptDocument
& rDocument
, const OUString
& rLibName
, const OUString
& rModName
, bool bCreateIfNotExist
= false, bool bFindSuspended
= false );
207 VclPtr
<BaseWindow
> FindApplicationWindow();
208 bool NextPage( bool bPrev
);
210 bool IsAppBasicModified () const { return m_bAppBasicModified
; }
211 void SetAppBasicModified (bool bModified
) { m_bAppBasicModified
= bModified
; }
213 // For Dialog Drag&Drop in Dialog Organizer:
214 // (defined in moduldlg.cxx)
215 static void CopyDialogResources(
216 css::uno::Reference
< css::io::XInputStreamProvider
>& io_xISP
,
217 const ScriptDocument
& rSourceDoc
, const OUString
& rSourceLibName
, const ScriptDocument
& rDestDoc
,
218 const OUString
& rDestLibName
, std::u16string_view rDlgName
);
220 static void InvalidateControlSlots();
222 virtual css::uno::Reference
< css::frame::XModel
>
223 GetCurrentDocument() const override
;
225 void UpdateObjectCatalog () { aObjectCatalog
->UpdateEntries(); }
227 void RemoveWindow (BaseWindow
* pWindow
, bool bDestroy
, bool bAllowChangeCurWindow
= true);
229 const std::shared_ptr
<BasicColorConfig
>& GetColorConfig() const { return m_aColorConfig
; }
232 } // namespace basctl
234 // This typedef helps baside.sdi,
235 // because I don't know how to use nested names in it.
236 typedef basctl::Shell basctl_Shell
;
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */