Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / basctl / source / inc / bastypes.hxx
blob09820d2f6e439cf04724276e798b18b98ec4f6e3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_BASCTL_SOURCE_INC_BASTYPES_HXX
20 #define INCLUDED_BASCTL_SOURCE_INC_BASTYPES_HXX
22 #include "scriptdocument.hxx"
24 #include "sbxitem.hxx"
25 #include "iderid.hxx"
26 #include <svtools/tabbar.hxx>
27 #include <vcl/toolbox.hxx>
28 #include <basic/sbdef.hxx>
30 #include <unordered_map>
32 class SbModule;
33 class SfxItemSet;
34 class SfxRequest;
35 class SvxSearchItem;
36 class Printer;
37 enum class SearchOptionFlags;
39 namespace svl
41 class IUndoManager;
44 namespace weld
46 class Widget;
49 namespace basctl
52 class Layout;
53 class ModulWindow;
54 class DialogWindow;
56 #define LINE_SEP_CR 0x0D
57 #define LINE_SEP 0x0A
59 // Implementation: baside2b.cxx
60 sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex );
62 // Meaning of bToBeKilled:
63 // While being in a reschedule-loop, I may not destroy the window.
64 // It must first break from the reschedule-loop to self-destroy then.
65 // Does unfortunately not work that way: Destroying Window with living Child!
67 struct BasicStatus
69 bool bIsRunning : 1;
70 bool bError : 1;
71 bool bIsInReschedule : 1;
72 BasicDebugFlags nBasicFlags;
74 BasicStatus():
75 bIsRunning(false),
76 bError(false),
77 bIsInReschedule(false),
78 nBasicFlags(BasicDebugFlags::NONE) { }
82 // basctl::DockingWindow -- special docking window for the Basic IDE
83 // Not to be confused with ::DockingWindow from vcl.
85 class DockingWindow : public ::DockingWindow
87 public:
88 DockingWindow (vcl::Window* pParent);
89 DockingWindow (Layout* pParent);
90 virtual ~DockingWindow() override;
91 virtual void dispose() override;
92 void ResizeIfDocking (Point const&, Size const&);
93 void ResizeIfDocking (Size const&);
94 Size GetDockingSize () const { return aDockingRect.GetSize(); }
95 void SetLayoutWindow (Layout*);
96 public:
97 void Show (bool = true);
98 void Hide ();
100 protected:
101 virtual bool Docking( const Point& rPos, tools::Rectangle& rRect ) override;
102 virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) override;
103 virtual void ToggleFloatingMode() override;
104 virtual bool PrepareToggleFloatingMode() override;
105 virtual void StartDocking() override;
107 private:
108 // the position and the size of the floating window
109 tools::Rectangle aFloatingRect;
110 // the position and the size of the docking window
111 tools::Rectangle aDockingRect;
112 // the parent layout window (only when docking)
113 VclPtr<Layout> pLayout;
114 // > 0: shown, <= 0: hidden, ++ by Show() and -- by Hide()
115 int nShowCount;
117 static WinBits const StyleBits;
119 private:
120 void DockThis ();
124 // basctl::TabBar
125 // Not to be confused with ::TabBar from svtools.
127 class TabBar : public ::TabBar
129 protected:
130 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
131 virtual void Command( const CommandEvent& rCEvt ) override;
133 virtual TabBarAllowRenamingReturnCode AllowRenaming() override;
134 virtual void EndRenaming() override;
136 public:
137 TabBar (vcl::Window* pParent);
139 void Sort();
142 enum BasicWindowStatus
144 BASWIN_RUNNINGBASIC = 0x01,
145 BASWIN_TOBEKILLED = 0x02,
146 BASWIN_SUSPENDED = 0x04,
147 BASWIN_INRESCHEDULE = 0x08
150 class EntryDescriptor;
153 // BaseWindow -- the base of both ModulWindow and DialogWindow.
155 class BaseWindow : public vcl::Window
157 private:
158 VclPtr<ScrollBar> pShellHScrollBar;
159 VclPtr<ScrollBar> pShellVScrollBar;
161 DECL_LINK( ScrollHdl, ScrollBar*, void );
162 int nStatus;
164 ScriptDocument m_aDocument;
165 OUString m_aLibName;
166 OUString m_aName;
168 friend class ModulWindow;
169 friend class DialogWindow;
171 protected:
172 virtual void DoScroll( ScrollBar* pCurScrollBar );
174 public:
175 BaseWindow( vcl::Window* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName );
176 virtual ~BaseWindow() override;
177 virtual void dispose() override;
179 void Init();
180 virtual void DoInit();
181 virtual void Activating () = 0;
182 virtual void Deactivating () = 0;
183 void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
185 ScrollBar* GetHScrollBar() const { return pShellHScrollBar; }
186 ScrollBar* GetVScrollBar() const { return pShellVScrollBar; }
188 virtual void ExecuteCommand (SfxRequest&);
189 virtual void ExecuteGlobal (SfxRequest&);
190 virtual void GetState (SfxItemSet&) = 0;
191 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
193 virtual void StoreData();
194 virtual void UpdateData();
195 virtual bool CanClose();
197 // return number of pages to be printed
198 virtual sal_Int32 countPages( Printer* pPrinter ) = 0;
199 // print page
200 virtual void printPage( sal_Int32 nPage, Printer* pPrinter ) = 0;
202 virtual OUString GetTitle();
203 OUString CreateQualifiedName();
204 virtual EntryDescriptor CreateEntryDescriptor() = 0;
206 virtual bool IsModified();
208 virtual bool AllowUndo();
210 virtual void SetReadOnly (bool bReadOnly);
211 virtual bool IsReadOnly();
213 int GetStatus() { return nStatus; }
214 void SetStatus(int n) { nStatus = n; }
215 void AddStatus(int n) { nStatus |= n; }
216 void ClearStatus(int n) { nStatus &= ~n; }
218 virtual svl::IUndoManager* GetUndoManager ();
220 virtual SearchOptionFlags GetSearchOptions();
221 virtual sal_uInt16 StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false);
223 virtual void BasicStarted();
224 virtual void BasicStopped();
226 bool IsSuspended() const { return nStatus & BASWIN_SUSPENDED; }
228 const ScriptDocument&
229 GetDocument() const { return m_aDocument; }
230 bool IsDocument( const ScriptDocument& rDocument ) const { return rDocument == m_aDocument; }
231 const OUString& GetLibName() const { return m_aLibName; }
233 const OUString& GetName() const { return m_aName; }
234 void SetName( const OUString& aName ) { m_aName = aName; }
236 virtual void OnNewDocument ();
237 virtual char const* GetHid () const = 0;
238 virtual ItemType GetType () const = 0;
239 void InsertLibInfo () const;
240 bool Is (ScriptDocument const&, OUString const&, OUString const&, ItemType, bool bFindSuspended);
241 virtual bool HasActiveEditor () const;
244 class LibInfo
246 public:
247 class Item;
248 public:
249 LibInfo ();
250 ~LibInfo ();
251 public:
252 void InsertInfo (ScriptDocument const&, OUString const& rLibName, OUString const& rCurrentName, ItemType eCurrentType);
253 void RemoveInfoFor (ScriptDocument const&);
254 Item const* GetInfo (ScriptDocument const&, OUString const& rLibName);
256 private:
257 class Key
259 private:
260 ScriptDocument m_aDocument;
261 OUString m_aLibName;
263 public:
264 Key (ScriptDocument const&, OUString const& rLibName);
265 ~Key ();
266 public:
267 bool operator == (Key const&) const;
268 struct Hash
270 size_t operator () (Key const&) const;
272 public:
273 const ScriptDocument& GetDocument() const { return m_aDocument; }
275 public:
276 class Item
278 private:
279 OUString m_aCurrentName;
280 ItemType m_eCurrentType;
282 public:
283 Item (OUString const& rCurrentName, ItemType eCurrentType);
284 ~Item ();
285 const OUString& GetCurrentName() const { return m_aCurrentName; }
286 ItemType GetCurrentType() const { return m_eCurrentType; }
288 private:
289 typedef std::unordered_map<Key, Item, Key::Hash> Map;
290 Map m_aMap;
293 void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines );
294 OUString CreateMgrAndLibStr( const OUString& rMgrName, const OUString& rLibName );
295 sal_uInt32 CalcLineCount( SvStream& rStream );
297 bool QueryReplaceMacro( const OUString& rName, weld::Widget* pParent );
298 bool QueryDelMacro( const OUString& rName, weld::Widget* pParent );
299 bool QueryDelDialog( const OUString& rName, weld::Widget* pParent );
300 bool QueryDelModule( const OUString& rName, weld::Widget* pParent );
301 bool QueryDelLib( const OUString& rName, bool bRef, weld::Widget* pParent );
302 bool QueryPassword( const css::uno::Reference< css::script::XLibraryContainer >& xLibContainer, const OUString& rLibName, OUString& rPassword, bool bRepeat = false, bool bNewTitle = false );
304 class ModuleInfoHelper
306 ModuleInfoHelper (const ModuleInfoHelper&) = delete;
307 ModuleInfoHelper& operator = (const ModuleInfoHelper&) = delete;
308 public:
309 static void getObjectName( const css::uno::Reference< css::container::XNameContainer >& rLib, const OUString& rModName, OUString& rObjName );
310 static sal_Int32 getModuleType( const css::uno::Reference< css::container::XNameContainer >& rLib, const OUString& rModName );
313 } // namespace basctl
315 #endif // INCLUDED_BASCTL_SOURCE_INC_BASTYPES_HXX
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */