LibreOffice Module basctl (master) 1
bastypes.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 "scriptdocument.hxx"
22
23#include "sbxitem.hxx"
25#include <svtools/tabbar.hxx>
26#include <basic/sbdef.hxx>
27#include <vcl/dockwin.hxx>
28#include <vcl/weld.hxx>
29
30#include <string_view>
31#include <unordered_map>
32
33class SbModule;
34class SfxItemSet;
35class SfxRequest;
36class SvxSearchItem;
37class Printer;
38enum class SearchOptionFlags;
39class SfxUndoManager;
40
41namespace weld
42{
43 class Widget;
44}
45
46namespace basctl
47{
48
49class Layout;
50class ModulWindow;
51class DialogWindow;
52
53constexpr auto LINE_SEP_CR = 0x0D;
54constexpr auto LINE_SEP = 0x0A;
55
56// Implementation: baside2b.cxx
57sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex );
58
59// Meaning of bToBeKilled:
60// While being in a reschedule-loop, I may not destroy the window.
61// It must first break from the reschedule-loop to self-destroy then.
62// Does unfortunately not work that way: Destroying Window with living Child!
63
65{
66 bool bIsRunning : 1;
67 bool bError : 1;
70
72 bIsRunning(false),
73 bError(false),
74 bIsInReschedule(false),
76};
77
78
79// basctl::DockingWindow -- special docking window for the Basic IDE
80// Not to be confused with ::DockingWindow from vcl.
81
83{
84public:
85 DockingWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OUString& rID);
86 DockingWindow(Layout* pParent);
87 virtual ~DockingWindow() override;
88 virtual void dispose() override;
89 void ResizeIfDocking (Point const&, Size const&);
90 void ResizeIfDocking (Size const&);
91 Size GetDockingSize () const { return aDockingRect.GetSize(); }
92 void SetLayoutWindow (Layout*);
93public:
94 void Show (bool = true);
95 void Hide ();
96
97protected:
98 virtual bool Docking( const Point& rPos, tools::Rectangle& rRect ) override;
99 virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) override;
100 virtual void ToggleFloatingMode() override;
101 virtual bool PrepareToggleFloatingMode() override;
102 virtual void StartDocking() override;
103
104protected:
105 std::unique_ptr<weld::Builder> m_xBuilder;
106 std::unique_ptr<weld::Container> m_xContainer;
107
108private:
109 // the position and the size of the floating window
111 // the position and the size of the docking window
113 // the parent layout window (only when docking)
115 // > 0: shown, <= 0: hidden, ++ by Show() and -- by Hide()
117
118 static WinBits const StyleBits;
119
120private:
121 void DockThis ();
122};
123
124
125// basctl::TabBar
126// Not to be confused with ::TabBar from svtools.
127
128class TabBar : public ::TabBar
129{
130protected:
131 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
132 virtual void Command( const CommandEvent& rCEvt ) override;
133
135 virtual void EndRenaming() override;
136
137public:
138 TabBar (vcl::Window* pParent);
139
140 void Sort();
141};
142
144{
150
151class EntryDescriptor;
152
153
154// BaseWindow -- the base of both ModulWindow and DialogWindow.
155
157{
158private:
161
162 DECL_LINK( VertScrollHdl, weld::Scrollbar&, void );
163 DECL_LINK( HorzScrollHdl, weld::Scrollbar&, void );
165
167 OUString m_aLibName;
168 OUString m_aName;
169
170 friend class ModulWindow;
171 friend class DialogWindow;
172
173protected:
174 virtual void DoScroll(Scrollable* pCurScrollBar);
175
176public:
177 BaseWindow( vcl::Window* pParent, ScriptDocument aDocument, OUString aLibName, OUString aName );
178 virtual ~BaseWindow() override;
179 virtual void dispose() override;
180
181 void Init();
182 virtual void DoInit();
183 virtual void Activating () = 0;
184 virtual void Deactivating () = 0;
185 void GrabScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll);
186
189 void ShowShellScrollBars(bool bVisible = true);
190
191 virtual void ExecuteCommand (SfxRequest&);
192 virtual void ExecuteGlobal (SfxRequest&);
193 virtual void GetState (SfxItemSet&) = 0;
194 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
195
196 virtual void StoreData();
197 virtual void UpdateData();
198
199 // return number of pages to be printed
200 virtual sal_Int32 countPages( Printer* pPrinter ) = 0;
201 // print page
202 virtual void printPage( sal_Int32 nPage, Printer* pPrinter ) = 0;
203
204 virtual OUString GetTitle();
205 OUString CreateQualifiedName();
207
208 virtual bool IsModified();
209
210 virtual bool AllowUndo();
211
212 virtual void SetReadOnly (bool bReadOnly);
213 virtual bool IsReadOnly();
214 void ShowReadOnlyInfoBar();
215
216 int GetStatus() const { return nStatus; }
217 void SetStatus(int n) { nStatus = n; }
218 void AddStatus(int n) { nStatus |= n; }
219 void ClearStatus(int n) { nStatus &= ~n; }
220
221 virtual SfxUndoManager* GetUndoManager ();
222
224 virtual sal_uInt16 StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false);
225
226 virtual void BasicStarted();
227 virtual void BasicStopped();
228
229 bool IsSuspended() const { return nStatus & BASWIN_SUSPENDED; }
230
231 const ScriptDocument&
232 GetDocument() const { return m_aDocument; }
233 bool IsDocument( const ScriptDocument& rDocument ) const { return rDocument == m_aDocument; }
234 const OUString& GetLibName() const { return m_aLibName; }
235
236 const OUString& GetName() const { return m_aName; }
237 void SetName( const OUString& aName ) { m_aName = aName; }
238
239 virtual void OnNewDocument ();
240 virtual OUString GetHid () const = 0;
241 virtual ItemType GetType () const = 0;
242 void InsertLibInfo () const;
243 bool Is (ScriptDocument const&, std::u16string_view, std::u16string_view, ItemType, bool bFindSuspended);
244 virtual bool HasActiveEditor () const;
245};
246
248{
249public:
250 class Item;
251public:
252 LibInfo ();
253 ~LibInfo ();
254public:
255 void InsertInfo (ScriptDocument const&, OUString const& rLibName, OUString const& rCurrentName, ItemType eCurrentType);
256 void RemoveInfoFor (ScriptDocument const&);
257 Item const* GetInfo (ScriptDocument const&, OUString const& rLibName);
258
259private:
260 class Key
261 {
262 private:
264 OUString m_aLibName;
265
266 public:
267 Key (ScriptDocument , OUString aLibName);
268 public:
269 bool operator == (Key const&) const;
270 struct Hash
271 {
272 size_t operator () (Key const&) const;
273 };
274 public:
275 const ScriptDocument& GetDocument() const { return m_aDocument; }
276 };
277public:
278 class Item
279 {
280 private:
283
284 public:
285 Item (OUString aCurrentName, ItemType eCurrentType);
286 const OUString& GetCurrentName() const { return m_aCurrentName; }
288 };
289private:
290 typedef std::unordered_map<Key, Item, Key::Hash> Map;
292};
293
294void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines );
295OUString CreateMgrAndLibStr( std::u16string_view rMgrName, std::u16string_view rLibName );
296sal_uInt32 CalcLineCount( SvStream& rStream );
297
298bool QueryReplaceMacro( std::u16string_view rName, weld::Widget* pParent );
299bool QueryDelMacro( std::u16string_view rName, weld::Widget* pParent );
300bool QueryDelDialog( std::u16string_view rName, weld::Widget* pParent );
301bool QueryDelModule( std::u16string_view rName, weld::Widget* pParent );
302bool QueryDelLib( std::u16string_view rName, bool bRef, weld::Widget* pParent );
303bool QueryPassword(weld::Widget* pDialogParent, const css::uno::Reference< css::script::XLibraryContainer >& xLibContainer, const OUString& rLibName, OUString& rPassword, bool bRepeat = false, bool bNewTitle = false);
304
306{
309public:
310 static void getObjectName( const css::uno::Reference< css::container::XNameContainer >& rLib, const OUString& rModName, OUString& rObjName );
311 static sal_Int32 getModuleType( const css::uno::Reference< css::container::XNameContainer >& rLib, const OUString& rModName );
312};
313
314} // namespace basctl
315
316/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScriptDocument aDocument
Definition: basobj2.cxx:194
reference_type * get() const
virtual bool AllowUndo()
Definition: bastypes.cxx:199
void SetName(const OUString &aName)
Definition: bastypes.hxx:237
virtual void BasicStopped()
Definition: bastypes.cxx:251
DECL_LINK(VertScrollHdl, weld::Scrollbar &, void)
virtual ItemType GetType() const =0
virtual bool IsReadOnly()
Definition: bastypes.cxx:229
virtual OUString GetTitle()
Definition: bastypes.cxx:208
void GrabScrollBars(ScrollAdaptor *pHScroll, ScrollAdaptor *pVScroll)
Definition: bastypes.cxx:108
virtual void dispose() override
Definition: bastypes.cxx:78
const OUString & GetLibName() const
Definition: bastypes.hxx:234
virtual void DoScroll(Scrollable *pCurScrollBar)
Definition: bastypes.cxx:191
bool IsDocument(const ScriptDocument &rDocument) const
Definition: bastypes.hxx:233
int GetStatus() const
Definition: bastypes.hxx:216
ScriptDocument m_aDocument
Definition: bastypes.hxx:166
virtual void SetReadOnly(bool bReadOnly)
Definition: bastypes.cxx:225
virtual void Deactivating()=0
virtual void printPage(sal_Int32 nPage, Printer *pPrinter)=0
OUString CreateQualifiedName()
Definition: bastypes.cxx:213
virtual OUString GetHid() const =0
VclPtr< ScrollAdaptor > pShellHScrollBar
Definition: bastypes.hxx:159
void ShowShellScrollBars(bool bVisible=true)
Definition: bastypes.cxx:161
VclPtr< ScrollAdaptor > pShellVScrollBar
Definition: bastypes.hxx:160
virtual SearchOptionFlags GetSearchOptions()
Definition: bastypes.cxx:265
virtual void UpdateData()
Definition: bastypes.cxx:204
virtual bool HasActiveEditor() const
Definition: bastypes.cxx:302
virtual void ExecuteGlobal(SfxRequest &)
Definition: bastypes.cxx:128
virtual EntryDescriptor CreateEntryDescriptor()=0
const OUString & GetName() const
Definition: bastypes.hxx:236
virtual void DoInit()
Definition: bastypes.cxx:104
void SetStatus(int n)
Definition: bastypes.hxx:217
virtual void ExecuteCommand(SfxRequest &)
Definition: bastypes.cxx:124
virtual bool IsModified()
Definition: bastypes.cxx:255
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: bastypes.cxx:132
BaseWindow(vcl::Window *pParent, ScriptDocument aDocument, OUString aLibName, OUString aName)
Definition: bastypes.cxx:62
OUString m_aLibName
Definition: bastypes.hxx:167
void ShowReadOnlyInfoBar()
Definition: bastypes.cxx:235
virtual SfxUndoManager * GetUndoManager()
Definition: bastypes.cxx:260
void AddStatus(int n)
Definition: bastypes.hxx:218
virtual void OnNewDocument()
Definition: bastypes.cxx:275
virtual void StoreData()
Definition: bastypes.cxx:195
virtual void BasicStarted()
Definition: bastypes.cxx:247
void ClearStatus(int n)
Definition: bastypes.hxx:219
const ScriptDocument & GetDocument() const
Definition: bastypes.hxx:232
DECL_LINK(HorzScrollHdl, weld::Scrollbar &, void)
bool IsSuspended() const
Definition: bastypes.hxx:229
ScrollAdaptor * GetHScrollBar() const
Definition: bastypes.hxx:187
virtual ~BaseWindow() override
Definition: bastypes.cxx:73
void InsertLibInfo() const
Definition: bastypes.cxx:278
virtual void Activating()=0
virtual sal_uInt16 StartSearchAndReplace(SvxSearchItem const &, bool bFromStart=false)
Definition: bastypes.cxx:270
bool Is(ScriptDocument const &, std::u16string_view, std::u16string_view, ItemType, bool bFindSuspended)
Definition: bastypes.cxx:284
virtual sal_Int32 countPages(Printer *pPrinter)=0
virtual void GetState(SfxItemSet &)=0
ScrollAdaptor * GetVScrollBar() const
Definition: bastypes.hxx:188
virtual void StartDocking() override
Definition: bastypes.cxx:448
static WinBits const StyleBits
Definition: bastypes.hxx:118
Size GetDockingSize() const
Definition: bastypes.hxx:91
virtual void ToggleFloatingMode() override
Definition: bastypes.cxx:422
std::unique_ptr< weld::Container > m_xContainer
Definition: bastypes.hxx:106
void SetLayoutWindow(Layout *)
Definition: bastypes.cxx:365
virtual bool Docking(const Point &rPos, tools::Rectangle &rRect) override
Definition: bastypes.cxx:396
virtual ~DockingWindow() override
Definition: bastypes.cxx:331
tools::Rectangle aFloatingRect
Definition: bastypes.hxx:110
virtual bool PrepareToggleFloatingMode() override
Definition: bastypes.cxx:435
std::unique_ptr< weld::Builder > m_xBuilder
Definition: bastypes.hxx:105
virtual void EndDocking(const tools::Rectangle &rRect, bool bFloatMode) override
Definition: bastypes.cxx:411
void Show(bool=true)
Definition: bastypes.cxx:375
void ResizeIfDocking(Point const &, Size const &)
Definition: bastypes.cxx:346
VclPtr< Layout > pLayout
Definition: bastypes.hxx:114
tools::Rectangle aDockingRect
Definition: bastypes.hxx:112
virtual void dispose() override
Definition: bastypes.cxx:336
ItemType GetCurrentType() const
Definition: bastypes.hxx:287
const OUString & GetCurrentName() const
Definition: bastypes.hxx:286
Item(OUString aCurrentName, ItemType eCurrentType)
Definition: bastypes.cxx:737
Key(ScriptDocument, OUString aLibName)
Definition: bastypes.cxx:720
bool operator==(Key const &) const
Definition: bastypes.cxx:724
ScriptDocument m_aDocument
Definition: bastypes.hxx:263
const ScriptDocument & GetDocument() const
Definition: bastypes.hxx:275
void InsertInfo(ScriptDocument const &, OUString const &rLibName, OUString const &rCurrentName, ItemType eCurrentType)
Definition: bastypes.cxx:692
std::unordered_map< Key, Item, Key::Hash > Map
Definition: bastypes.hxx:290
Item const * GetInfo(ScriptDocument const &, OUString const &rLibName)
Definition: bastypes.cxx:712
void RemoveInfoFor(ScriptDocument const &)
Definition: bastypes.cxx:704
static sal_Int32 getModuleType(const css::uno::Reference< css::container::XNameContainer > &rLib, const OUString &rModName)
Definition: bastype2.cxx:75
ModuleInfoHelper(const ModuleInfoHelper &)=delete
static void getObjectName(const css::uno::Reference< css::container::XNameContainer > &rLib, const OUString &rModName, OUString &rObjName)
Definition: bastype2.cxx:52
ModuleInfoHelper & operator=(const ModuleInfoHelper &)=delete
encapsulates a document which contains Basic scripts and dialogs
virtual void Command(const CommandEvent &rCEvt) override
Definition: bastypes.cxx:499
TabBar(vcl::Window *pParent)
Definition: bastypes.cxx:478
virtual void EndRenaming() override
Definition: bastypes.cxx:530
virtual TabBarAllowRenamingReturnCode AllowRenaming() override
Definition: bastypes.cxx:515
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: bastypes.cxx:486
constexpr Size GetSize() const
friend friend class DockingWindow
OUString aName
sal_Int64 n
NONE
constexpr auto LINE_SEP_CR
Definition: bastypes.hxx:53
OUString CreateMgrAndLibStr(std::u16string_view rMgrName, std::u16string_view rLibName)
Definition: bastype3.cxx:432
bool QueryReplaceMacro(std::u16string_view rName, weld::Widget *pParent)
Definition: bastypes.cxx:759
bool QueryDelLib(std::u16string_view rName, bool bRef, weld::Widget *pParent)
Definition: bastypes.cxx:769
bool QueryPassword(weld::Widget *pDialogParent, const Reference< script::XLibraryContainer > &xLibContainer, const OUString &rLibName, OUString &rPassword, bool bRepeat, bool bNewTitle)
Definition: bastypes.cxx:779
sal_Int32 searchEOL(std::u16string_view rStr, sal_Int32 fromIndex)
Definition: baside2b.cxx:1008
constexpr auto LINE_SEP
Definition: bastypes.hxx:54
sal_uInt32 CalcLineCount(SvStream &rStream)
Definition: bastypes.cxx:659
BasicWindowStatus
Definition: bastypes.hxx:144
@ BASWIN_INRESCHEDULE
Definition: bastypes.hxx:148
@ BASWIN_SUSPENDED
Definition: bastypes.hxx:147
@ BASWIN_TOBEKILLED
Definition: bastypes.hxx:146
@ BASWIN_RUNNINGBASIC
Definition: bastypes.hxx:145
bool QueryDelMacro(std::u16string_view rName, weld::Widget *pParent)
Definition: bastypes.cxx:754
bool QueryDelDialog(std::u16string_view rName, weld::Widget *pParent)
Definition: bastypes.cxx:764
ItemType
Definition: sbxitem.hxx:28
void CutLines(OUString &rStr, sal_Int32 nStartLine, sal_Int32 nLines)
Definition: bastypes.cxx:612
bool QueryDelModule(std::u16string_view rName, weld::Widget *pParent)
Definition: bastypes.cxx:774
Layout
BasicDebugFlags
SearchOptionFlags
BasicDebugFlags nBasicFlags
Definition: bastypes.hxx:69
size_t operator()(Key const &) const
Definition: bastypes.cxx:729
TabBarAllowRenamingReturnCode
sal_Int64 WinBits