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 "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
;
60 public DocumentEventListener
63 typedef std::map
<sal_uInt16
, VclPtr
<BaseWindow
> > WindowTable
;
66 friend class JavaDebuggingListenerImpl
;
67 friend class LocalizationMgr
;
68 friend bool implImportDialog(weld::Window
* pWin
, const ScriptDocument
& rDocument
, const OUString
& rLibName
); // defined in baside3.cxx
70 WindowTable aWindowTable
;
72 VclPtr
<BaseWindow
> pCurWin
;
73 ScriptDocument m_aCurDocument
;
74 OUString m_aCurLibName
;
75 std::shared_ptr
<LocalizationMgr
> m_pCurLocalizationMgr
;
77 // Current value of the zoom slider
78 sal_uInt16 m_nCurrentZoomSliderValue
;
79 VclPtr
<ScrollAdaptor
> aHScrollBar
;
80 VclPtr
<ScrollAdaptor
> aVScrollBar
;
81 VclPtr
<TabBar
> pTabBar
; // basctl::TabBar
85 VclPtr
<ModulWindowLayout
> pModulLayout
;
86 VclPtr
<DialogWindowLayout
> pDialogLayout
;
87 VclPtr
<Layout
> pLayout
; // the active layout window
88 // common object catalog window
89 VclPtr
<ObjectCatalog
> aObjectCatalog
;
91 bool m_bAppBasicModified
;
92 bool mbJustOpened
= false;
94 DocumentEventNotifier m_aNotifier
;
96 friend class ContainerListenerImpl
;
97 css::uno::Reference
< css::container::XContainerListener
> m_xLibListener
;
98 std::unique_ptr
<SvxSearchItem
> mpSearchItem
;
102 void InitScrollBars();
103 void InitZoomLevel();
105 void RemoveWindows( const ScriptDocument
& rDocument
, std::u16string_view rLibName
);
106 void UpdateWindows();
107 static void InvalidateBasicIDESlots();
108 void StoreAllWindowData( bool bPersistent
= true );
110 void SetCurLib( const ScriptDocument
& rDocument
, const OUString
& aLibName
, bool bUpdateWindows
= true , bool bCheck
= true );
111 void SetCurLibForLocalization( const ScriptDocument
& rDocument
, const OUString
& aLibName
);
113 DECL_LINK( TabBarHdl
, ::TabBar
*, void );
115 static unsigned nShellCount
;
118 void AdjustPosSizePixel( const Point
&rPos
, const Size
&rSize
);
119 virtual void OuterResizePixel( const Point
&rPos
, const Size
&rSize
) override
;
120 sal_uInt16
InsertWindowInTable (BaseWindow
* pNewWin
);
121 virtual bool PrepareClose( bool bUI
= true ) override
;
123 void SetCurWindow (BaseWindow
* pNewWin
, bool bUpdateTabBar
= false, bool bRememberAsCurrent
= true);
124 void ManageToolbars();
126 VclPtr
<ModulWindow
> CreateBasWin( const ScriptDocument
& rDocument
, const OUString
& rLibName
, const OUString
& rModName
);
127 VclPtr
<DialogWindow
> CreateDlgWin( const ScriptDocument
& rDocument
, const OUString
& rLibName
, const OUString
& rDlgName
);
129 VclPtr
<ModulWindow
> ShowActiveModuleWindow( StarBASIC
const * pBasic
);
131 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
133 virtual void Activate(bool bMDI
) override
;
134 virtual void Deactivate(bool bMDI
) override
;
136 virtual void Move() override
;
137 virtual void ShowCursor( bool bOn
= true ) override
;
139 // DocumentEventListener
140 virtual void onDocumentCreated( const ScriptDocument
& _rDocument
) override
;
141 virtual void onDocumentOpened( const ScriptDocument
& _rDocument
) override
;
142 virtual void onDocumentSave( const ScriptDocument
& _rDocument
) override
;
143 virtual void onDocumentSaveDone( const ScriptDocument
& _rDocument
) override
;
144 virtual void onDocumentSaveAs( const ScriptDocument
& _rDocument
) override
;
145 virtual void onDocumentSaveAsDone( const ScriptDocument
& _rDocument
) override
;
146 virtual void onDocumentClosed( const ScriptDocument
& _rDocument
) override
;
147 virtual void onDocumentTitleChanged( const ScriptDocument
& _rDocument
) override
;
148 virtual void onDocumentModeChanged( const ScriptDocument
& _rDocument
) override
;
151 SFX_DECL_INTERFACE( SVX_INTERFACE_BASIDE_VIEWSH
)
152 SFX_DECL_VIEWFACTORY(Shell
);
155 /// SfxInterface initializer.
156 static void InitInterface_Impl();
159 Shell(SfxViewFrame
& rFrame
, SfxViewShell
*pOldSh
);
160 virtual ~Shell() override
;
162 BaseWindow
* GetCurWindow() const { return pCurWin
; }
163 OUString
const& GetCurLibName() const { return m_aCurLibName
; }
164 const std::shared_ptr
<LocalizationMgr
>& GetCurLocalizationMgr() const { return m_pCurLocalizationMgr
; }
166 TabBar
& GetTabBar() { return *pTabBar
; }
167 WindowTable
& GetWindowTable() { return aWindowTable
; }
168 sal_uInt16
GetWindowId (BaseWindow
const* pWin
) const;
170 SdrView
* GetCurDlgView() const;
172 SfxUndoManager
* GetUndoManager() override
;
174 void SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel
);
175 sal_uInt16
GetCurrentZoomSliderValue() { return m_nCurrentZoomSliderValue
; }
176 static sal_uInt16
GetMinZoom() { return MIN_ZOOM_LEVEL
; }
177 static sal_uInt16
GetMaxZoom() { return MAX_ZOOM_LEVEL
; }
179 virtual css::uno::Reference
< css::view::XRenderable
> GetRenderable() override
;
181 // virtual sal_uInt16 Print( SfxProgress &rProgress, sal_Bool bIsAPI, PrintDialog *pPrintDialog = 0 );
182 virtual SfxPrinter
* GetPrinter( bool bCreate
= false ) override
;
183 virtual sal_uInt16
SetPrinter( SfxPrinter
*pNewPrinter
, SfxPrinterChangeFlags nDiffFlags
= SFX_PRINTER_ALL
) override
;
184 virtual OUString
GetSelectionText( bool bCompleteWords
= false, bool bOnlyASample
= false ) override
;
185 virtual bool HasSelection( bool bText
= true ) const override
;
187 void GetState( SfxItemSet
& );
188 void ExecuteGlobal( SfxRequest
& rReq
);
189 void ExecuteSearch( SfxRequest
& rReq
);
190 void ExecuteCurrent( SfxRequest
& rReq
);
191 void ExecuteBasic( SfxRequest
& rReq
);
192 void ExecuteDialog( SfxRequest
& rReq
);
194 virtual bool HasUIFeature(SfxShellFeature nFeature
) const override
;
196 bool CallBasicErrorHdl( StarBASIC
const * pBasic
);
197 BasicDebugFlags
CallBasicBreakHdl( StarBASIC
const * pBasic
);
199 VclPtr
<BaseWindow
> FindWindow( const ScriptDocument
& rDocument
, std::u16string_view rLibName
, std::u16string_view rName
, ItemType nType
, bool bFindSuspended
= false );
200 VclPtr
<DialogWindow
> FindDlgWin( const ScriptDocument
& rDocument
, const OUString
& rLibName
, const OUString
& rName
, bool bCreateIfNotExist
= false, bool bFindSuspended
= false );
201 VclPtr
<ModulWindow
> FindBasWin( const ScriptDocument
& rDocument
, const OUString
& rLibName
, const OUString
& rModName
, bool bCreateIfNotExist
= false, bool bFindSuspended
= false );
202 VclPtr
<BaseWindow
> FindApplicationWindow();
203 bool NextPage( bool bPrev
);
205 bool IsAppBasicModified () const { return m_bAppBasicModified
; }
206 void SetAppBasicModified (bool bModified
) { m_bAppBasicModified
= bModified
; }
208 // For Dialog Drag&Drop in Dialog Organizer:
209 // (defined in moduldlg.cxx)
210 static void CopyDialogResources(
211 css::uno::Reference
< css::io::XInputStreamProvider
>& io_xISP
,
212 const ScriptDocument
& rSourceDoc
, const OUString
& rSourceLibName
, const ScriptDocument
& rDestDoc
,
213 const OUString
& rDestLibName
, std::u16string_view rDlgName
);
215 static void InvalidateControlSlots();
217 virtual css::uno::Reference
< css::frame::XModel
>
218 GetCurrentDocument() const override
;
220 void UpdateObjectCatalog () { aObjectCatalog
->UpdateEntries(); }
222 void RemoveWindow (BaseWindow
* pWindow
, bool bDestroy
, bool bAllowChangeCurWindow
= true);
225 } // namespace basctl
227 // This typedef helps baside.sdi,
228 // because I don't know how to use nested names in it.
229 typedef basctl::Shell basctl_Shell
;
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */