fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / basctl / source / inc / bastypes.hxx
blobb5bb4004cac738bc67ff8c2f0724389070e3c624
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 BASCTL_BASTYPES_HXX
20 #define BASCTL_BASTYPES_HXX
22 #include "scriptdocument.hxx"
24 #include <sbxitem.hxx>
25 #include <iderid.hxx>
26 #include <svtools/tabbar.hxx>
27 #include <vcl/toolbox.hxx>
29 #include <boost/unordered_map.hpp>
31 class SbModule;
32 class SfxItemSet;
33 class SfxRequest;
34 class SvxSearchItem;
35 class Printer;
37 namespace svl
39 class IUndoManager;
42 namespace basctl
45 class Layout;
46 class ModulWindow;
47 class DialogWindow;
49 #define LINE_SEP_CR 0x0D
50 #define LINE_SEP 0x0A
52 // Implementation: baside2b.cxx
53 sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex );
55 // Meaning of bToBeKilled:
56 // While being in a reschedule-loop, I may not destroy the window.
57 // It must first break from the reschedule-loop to self-destroy then.
58 // Does unfortunately not work that way: Destroying Window with living Child!
60 struct BasicStatus
62 bool bIsRunning : 1;
63 bool bError : 1;
64 bool bIsInReschedule : 1;
65 sal_uInt16 nBasicFlags;
67 BasicStatus():
68 bIsRunning(false),
69 bError(false),
70 bIsInReschedule(false),
71 nBasicFlags(0) { }
75 // basctl::DockingWindow -- special docking window for the Basic IDE
76 // Not to be confused with ::DockingWindow from vcl.
78 class DockingWindow : public ::DockingWindow
80 public:
81 DockingWindow (Window* pParent);
82 DockingWindow (Layout* pParent);
83 public:
84 void ResizeIfDocking (Point const&, Size const&);
85 void ResizeIfDocking (Size const&);
86 Size GetDockingSize () const { return aDockingRect.GetSize(); }
87 void SetLayoutWindow (Layout*);
88 public:
89 void Show (bool = true);
90 void Hide ();
92 protected:
93 virtual sal_Bool Docking( const Point& rPos, Rectangle& rRect );
94 virtual void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
95 virtual void ToggleFloatingMode();
96 virtual sal_Bool PrepareToggleFloatingMode();
97 virtual void StartDocking();
99 private:
100 // the position and the size of the floating window
101 Rectangle aFloatingRect;
102 // the position and the size of the docking window
103 Rectangle aDockingRect;
104 // the parent layout window (only when docking)
105 Layout* pLayout;
106 // > 0: shown, <= 0: hidden, ++ by Show() and -- by Hide()
107 int nShowCount;
109 static WinBits const StyleBits;
111 private:
112 void DockThis ();
116 // basctl::TabBar
117 // Not to be confused with ::TabBar from svtools.
119 class TabBar : public ::TabBar
121 protected:
122 virtual void MouseButtonDown( const MouseEvent& rMEvt );
123 virtual void Command( const CommandEvent& rCEvt );
125 virtual long AllowRenaming();
126 virtual void EndRenaming();
128 public:
129 TabBar (Window* pParent);
131 void Sort();
134 enum BasicWindowStatus
136 BASWIN_OK = 0x00,
137 BASWIN_RUNNINGBASIC = 0x01,
138 BASWIN_TOBEKILLED = 0x02,
139 BASWIN_SUSPENDED = 0x04,
140 BASWIN_INRESCHEDULE = 0x08
143 class EntryDescriptor;
146 // BaseWindow -- the base of both ModulWindow and DialogWindow.
148 class BaseWindow : public Window
150 private:
151 ScrollBar* pShellHScrollBar;
152 ScrollBar* pShellVScrollBar;
154 DECL_LINK( ScrollHdl, ScrollBar * );
155 int nStatus;
157 ScriptDocument m_aDocument;
158 OUString m_aLibName;
159 OUString m_aName;
161 friend class ModulWindow;
162 friend class DialogWindow;
164 protected:
165 virtual void DoScroll( ScrollBar* pCurScrollBar );
167 public:
168 TYPEINFO();
169 BaseWindow( Window* pParent, const ScriptDocument& rDocument, OUString aLibName, OUString aName );
170 virtual ~BaseWindow();
172 void Init();
173 virtual void DoInit();
174 virtual void Activating () = 0;
175 virtual void Deactivating () = 0;
176 void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
178 ScrollBar* GetHScrollBar() const { return pShellHScrollBar; }
179 ScrollBar* GetVScrollBar() const { return pShellVScrollBar; }
181 virtual void ExecuteCommand (SfxRequest&);
182 virtual void ExecuteGlobal (SfxRequest&);
183 virtual void GetState (SfxItemSet&) = 0;
184 virtual long Notify( NotifyEvent& rNEvt );
186 virtual void StoreData();
187 virtual void UpdateData();
188 virtual bool CanClose();
190 // return number of pages to be printed
191 virtual sal_Int32 countPages( Printer* pPrinter ) = 0;
192 // print page
193 virtual void printPage( sal_Int32 nPage, Printer* pPrinter ) = 0;
195 virtual OUString GetTitle();
196 OUString CreateQualifiedName();
197 virtual EntryDescriptor CreateEntryDescriptor() = 0;
199 virtual bool IsModified();
200 virtual bool IsPasteAllowed();
202 virtual bool AllowUndo();
204 virtual void SetReadOnly (bool bReadOnly);
205 virtual bool IsReadOnly();
207 int GetStatus() { return nStatus; }
208 void SetStatus(int n) { nStatus = n; }
209 void AddStatus(int n) { nStatus |= n; }
210 void ClearStatus(int n) { nStatus &= ~n; }
212 virtual svl::IUndoManager* GetUndoManager ();
214 virtual sal_uInt16 GetSearchOptions();
215 virtual sal_uInt16 StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false);
217 virtual void BasicStarted();
218 virtual void BasicStopped();
220 bool IsSuspended() const { return nStatus & BASWIN_SUSPENDED; }
222 const ScriptDocument&
223 GetDocument() const { return m_aDocument; }
224 void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
225 bool IsDocument( const ScriptDocument& rDocument ) const { return rDocument == m_aDocument; }
226 const OUString& GetLibName() const { return m_aLibName; }
227 void SetLibName( const OUString& aLibName ) { m_aLibName = aLibName; }
228 const OUString& GetName() const { return m_aName; }
229 void SetName( const OUString& aName ) { m_aName = aName; }
231 virtual void OnNewDocument ();
232 virtual char const* GetHid () const = 0;
233 virtual ItemType GetType () const = 0;
234 void InsertLibInfo () const;
235 bool Is (ScriptDocument const&, OUString const&, OUString const&, ItemType, bool bFindSuspended);
236 virtual bool HasActiveEditor () const;
239 class LibInfos
241 public:
242 class Item;
243 public:
244 LibInfos ();
245 ~LibInfos ();
246 public:
247 void InsertInfo (ScriptDocument const&, OUString const& rLibName, OUString const& rCurrentName, ItemType eCurrentType);
248 void RemoveInfoFor (ScriptDocument const&);
249 Item const* GetInfo (ScriptDocument const&, OUString const& rLibName);
251 private:
252 class Key
254 private:
255 ScriptDocument m_aDocument;
256 OUString m_aLibName;
258 public:
259 Key (ScriptDocument const&, OUString const& rLibName);
260 ~Key ();
261 public:
262 bool operator == (Key const&) const;
263 struct Hash
265 size_t operator () (Key const&) const;
267 public:
268 const ScriptDocument& GetDocument() const { return m_aDocument; }
269 const OUString& GetLibName() const { return m_aLibName; }
271 public:
272 class Item
274 private:
275 ScriptDocument m_aDocument;
276 OUString m_aLibName;
277 OUString m_aCurrentName;
278 ItemType m_eCurrentType;
280 public:
281 Item (ScriptDocument const&, OUString const& rLibName, OUString const& rCurrentName, ItemType eCurrentType);
282 ~Item ();
283 public:
284 const ScriptDocument& GetDocument() const { return m_aDocument; }
285 const OUString& GetLibName() const { return m_aLibName; }
286 const OUString& GetCurrentName() const { return m_aCurrentName; }
287 ItemType GetCurrentType() const { return m_eCurrentType; }
289 private:
290 typedef boost::unordered_map<Key, Item, Key::Hash> Map;
291 Map m_aMap;
294 void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, bool bEraseTrailingEmptyLines = false );
295 OUString CreateMgrAndLibStr( const OUString& rMgrName, const OUString& rLibName );
296 sal_uLong CalcLineCount( SvStream& rStream );
298 bool QueryReplaceMacro( const OUString& rName, Window* pParent = 0 );
299 bool QueryDelMacro( const OUString& rName, Window* pParent = 0 );
300 bool QueryDelDialog( const OUString& rName, Window* pParent = 0 );
301 bool QueryDelModule( const OUString& rName, Window* pParent = 0 );
302 bool QueryDelLib( const OUString& rName, bool bRef = false, Window* pParent = 0 );
303 bool QueryPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xLibContainer, const OUString& rLibName, OUString& rPassword, bool bRepeat = false, bool bNewTitle = false );
305 class ModuleInfoHelper
307 // non-constructible class
308 ModuleInfoHelper ();
309 ModuleInfoHelper (const ModuleInfoHelper&);
310 ModuleInfoHelper& operator = (const ModuleInfoHelper&);
311 public:
312 static void getObjectName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const OUString& rModName, OUString& rObjName );
313 static sal_Int32 getModuleType( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const OUString& rModName );
316 } // namespace basctl
318 #endif // BASCTL_BASTYPES_HXX
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */