LibreOffice Module basctl (master) 1
basidesh.hxx
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#pragma once
20
21#include "doceventnotifier.hxx"
22#include "sbxitem.hxx"
23#include "ObjectCatalog.hxx"
24
25#include <com/sun/star/container/XContainerListener.hpp>
26#include <sfx2/viewsh.hxx>
27#include <svx/ifaceids.hxx>
28#include <svl/srchitem.hxx>
30#include <map>
31#include <memory>
32#include <string_view>
33
34class SfxViewFactory;
35class SdrView;
36class TabBar;
37class SbxObject;
38class SbModule;
39class StarBASIC;
40
41namespace basctl
42{
43
44// Used to control zoom level
45constexpr sal_uInt16 MIN_ZOOM_LEVEL = 50;
46constexpr sal_uInt16 DEFAULT_ZOOM_LEVEL = 100;
47constexpr sal_uInt16 MAX_ZOOM_LEVEL = 400;
48
49class Layout;
50class ModulWindow;
52class DialogWindow;
54class TabBar;
55class BaseWindow;
56class LocalizationMgr;
57
58class Shell :
59 public SfxViewShell,
61{
62public:
63 typedef std::map<sal_uInt16, VclPtr<BaseWindow> > WindowTable;
64
65private:
67 friend class LocalizationMgr;
68 friend bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const OUString& rLibName); // defined in baside3.cxx
69
71 sal_uInt16 nCurKey;
74 OUString m_aCurLibName;
75 std::shared_ptr<LocalizationMgr> m_pCurLocalizationMgr;
76
77 // Current value of the zoom slider
81 VclPtr<TabBar> pTabBar; // basctl::TabBar
83
84 // layout windows
87 VclPtr<Layout> pLayout; // the active layout window
88 // common object catalog window
90
92 bool mbJustOpened = false;
93
95
97 css::uno::Reference< css::container::XContainerListener > m_xLibListener;
98 std::unique_ptr<SvxSearchItem> mpSearchItem;
99
100 void Init();
101 void InitTabBar();
102 void InitScrollBars();
103 void InitZoomLevel();
104 void CheckWindows();
105 void RemoveWindows( const ScriptDocument& rDocument, std::u16string_view rLibName );
106 void UpdateWindows();
107 static void InvalidateBasicIDESlots();
108 void StoreAllWindowData( bool bPersistent = true );
109 void SetMDITitle();
110 void SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows = true , bool bCheck = true );
111 void SetCurLibForLocalization( const ScriptDocument& rDocument, const OUString& aLibName );
112
113 DECL_LINK( TabBarHdl, ::TabBar*, void );
114
115 static unsigned nShellCount;
116
117private:
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;
122
123 void SetCurWindow (BaseWindow* pNewWin, bool bUpdateTabBar = false, bool bRememberAsCurrent = true);
124 void ManageToolbars();
125
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 );
128
130
131 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
132
133 virtual void Activate(bool bMDI) override;
134 virtual void Deactivate(bool bMDI) override;
135
136 virtual void Move() override;
137 virtual void ShowCursor( bool bOn = true ) override;
138
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;
149
150public:
151 SFX_DECL_INTERFACE( SVX_INTERFACE_BASIDE_VIEWSH )
153
154private:
156 static void InitInterface_Impl();
157
158public:
160 virtual ~Shell() override;
161
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; }
165
166 TabBar& GetTabBar() { return *pTabBar; }
168 sal_uInt16 GetWindowId (BaseWindow const* pWin) const;
169
170 SdrView* GetCurDlgView() const;
171
172 SfxUndoManager* GetUndoManager() override;
173
174 void SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel);
176 static sal_uInt16 GetMinZoom() { return MIN_ZOOM_LEVEL; }
177 static sal_uInt16 GetMaxZoom() { return MAX_ZOOM_LEVEL; }
178
179 virtual css::uno::Reference< css::view::XRenderable > GetRenderable() override;
180
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;
186
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 );
193
194 virtual bool HasUIFeature(SfxShellFeature nFeature) const override;
195
196 bool CallBasicErrorHdl( StarBASIC const * pBasic );
198
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 );
203 bool NextPage( bool bPrev );
204
205 bool IsAppBasicModified () const { return m_bAppBasicModified; }
206 void SetAppBasicModified (bool bModified) { m_bAppBasicModified = bModified; }
207
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 );
214
215 static void InvalidateControlSlots();
216
217 virtual css::uno::Reference< css::frame::XModel >
218 GetCurrentDocument() const override;
219
220 void UpdateObjectCatalog () { aObjectCatalog->UpdateEntries(); }
221
222 void RemoveWindow (BaseWindow* pWindow, bool bDestroy, bool bAllowChangeCurWindow = true);
223};
224
225} // namespace basctl
226
227// This typedef helps baside.sdi,
228// because I don't know how to use nested names in it.
230
231/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basctl::Shell basctl_Shell
Definition: basidesh.hxx:229
VclPtr< vcl::Window > pWindow
SfxViewFrame & rFrame
allows registering at theGlobalEventBroadcaster for global document events
encapsulates a document which contains Basic scripts and dialogs
virtual bool HasUIFeature(SfxShellFeature nFeature) const override
Definition: basides1.cxx:1256
bool CallBasicErrorHdl(StarBASIC const *pBasic)
Definition: basides1.cxx:1406
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
SFX_DECL_VIEWFACTORY(Shell)
DocumentEventNotifier m_aNotifier
Definition: basidesh.hxx:94
sal_uInt16 GetCurrentZoomSliderValue()
Definition: basidesh.hxx:175
static void InvalidateControlSlots()
Definition: basidesh.cxx:896
void UpdateObjectCatalog()
Definition: basidesh.hxx:220
virtual void ShowCursor(bool bOn=true) override
Definition: basides2.cxx:220
virtual bool PrepareClose(bool bUI=true) override
Definition: basidesh.cxx:430
void ExecuteCurrent(SfxRequest &rReq)
Definition: basides1.cxx:254
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
bool m_bAppBasicModified
Definition: basidesh.hxx:91
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
void ExecuteSearch(SfxRequest &rReq)
Definition: basides1.cxx:83
TabBar & GetTabBar()
Definition: basidesh.hxx:166
bool mbJustOpened
Definition: basidesh.hxx:92
virtual bool HasSelection(bool bText=true) const override
Definition: basides2.cxx:48
virtual css::uno::Reference< css::frame::XModel > GetCurrentDocument() const override
Definition: basides1.cxx:1515
VclPtr< BaseWindow > FindWindow(const ScriptDocument &rDocument, std::u16string_view rLibName, std::u16string_view rName, ItemType nType, bool bFindSuspended=false)
Definition: basides1.cxx:1391
BaseWindow * GetCurWindow() const
Definition: basidesh.hxx:162
sal_uInt16 GetWindowId(BaseWindow const *pWin) const
Definition: basides3.cxx:125
void SetCurLibForLocalization(const ScriptDocument &rDocument, const OUString &aLibName)
Definition: basidesh.cxx:973
void ExecuteGlobal(SfxRequest &rReq)
Definition: basides1.cxx:283
static unsigned nShellCount
Definition: basidesh.hxx:115
bool IsAppBasicModified() const
Definition: basidesh.hxx:205
VclPtr< TabBar > pTabBar
Definition: basidesh.hxx:81
virtual void onDocumentCreated(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:269
virtual void Activate(bool bMDI) override
Definition: basides1.cxx:1523
VclPtr< ModulWindow > ShowActiveModuleWindow(StarBASIC const *pBasic)
Definition: basides1.cxx:1444
std::map< sal_uInt16, VclPtr< BaseWindow > > WindowTable
Definition: basidesh.hxx:63
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
BasicDebugFlags CallBasicBreakHdl(StarBASIC const *pBasic)
Definition: basides1.cxx:1414
VclPtr< ModulWindowLayout > pModulLayout
Definition: basidesh.hxx:85
static void InitInterface_Impl()
SfxInterface initializer.
friend class JavaDebuggingListenerImpl
Definition: basidesh.hxx:66
OUString m_aCurLibName
Definition: basidesh.hxx:74
static sal_uInt16 GetMinZoom()
Definition: basidesh.hxx:176
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
SdrView * GetCurDlgView() const
Definition: basides3.cxx:133
virtual void onDocumentSave(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:284
void SetMDITitle()
Definition: basides2.cxx:100
void GetState(SfxItemSet &)
Definition: basides1.cxx:838
static void CopyDialogResources(css::uno::Reference< css::io::XInputStreamProvider > &io_xISP, const ScriptDocument &rSourceDoc, const OUString &rSourceLibName, const ScriptDocument &rDestDoc, const OUString &rDestLibName, std::u16string_view rDlgName)
Definition: moduldlg.cxx:131
bool bCreatingWindow
Definition: basidesh.hxx:82
WindowTable & GetWindowTable()
Definition: basidesh.hxx:167
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
const std::shared_ptr< LocalizationMgr > & GetCurLocalizationMgr() const
Definition: basidesh.hxx:164
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
virtual SfxPrinter * GetPrinter(bool bCreate=false) override
Definition: basides2.cxx:81
SfxUndoManager * GetUndoManager() override
Definition: basidesh.cxx:502
std::unique_ptr< SvxSearchItem > mpSearchItem
Definition: basidesh.hxx:98
void UpdateWindows()
Definition: basidesh.cxx:626
void InitZoomLevel()
Definition: basidesh.cxx:369
void ExecuteDialog(SfxRequest &rReq)
Definition: basides3.cxx:142
virtual void onDocumentTitleChanged(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:352
virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL) override
Definition: basides2.cxx:92
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
void ExecuteBasic(SfxRequest &rReq)
Definition: basides2.cxx:227
sal_uInt16 m_nCurrentZoomSliderValue
Definition: basidesh.hxx:78
virtual OUString GetSelectionText(bool bCompleteWords=false, bool bOnlyASample=false) override
Definition: basides2.cxx:59
virtual void onDocumentSaveDone(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:289
OUString const & GetCurLibName() const
Definition: basidesh.hxx:163
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
virtual css::uno::Reference< css::view::XRenderable > GetRenderable() override
Definition: basides2.cxx:43
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 Move() override
Definition: basides2.cxx:216
virtual void onDocumentModeChanged(const ScriptDocument &_rDocument) override
Definition: basidesh.cxx:359
void AdjustPosSizePixel(const Point &rPos, const Size &rSize)
Definition: basides1.cxx:1478
static sal_uInt16 GetMaxZoom()
Definition: basidesh.hxx:177
void StoreAllWindowData(bool bPersistent=true)
Definition: basidesh.cxx:407
friend bool implImportDialog(weld::Window *pWin, const ScriptDocument &rDocument, const OUString &rLibName)
Definition: baside3.cxx:784
virtual void Deactivate(bool bMDI) override
Definition: basides1.cxx:1534
void ManageToolbars()
Definition: basides1.cxx:1343
static void InvalidateBasicIDESlots()
Definition: basidesh.cxx:849
DECL_LINK(TabBarHdl, ::TabBar *, void)
VclPtr< DialogWindowLayout > pDialogLayout
Definition: basidesh.hxx:86
constexpr sal_uInt16 DEFAULT_ZOOM_LEVEL
Definition: basidesh.hxx:46
constexpr sal_uInt16 MIN_ZOOM_LEVEL
Definition: basidesh.hxx:45
constexpr sal_uInt16 MAX_ZOOM_LEVEL
Definition: basidesh.hxx:47
ItemType
Definition: sbxitem.hxx:28
BasicDebugFlags
SfxShellFeature
#define SFX_DECL_INTERFACE(nId)
SfxPrinterChangeFlags