Line data Source code
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 : #ifndef BASCTL_BASTYPES_HXX
20 : #define BASCTL_BASTYPES_HXX
21 :
22 : #include "scriptdocument.hxx"
23 :
24 : #include <sbxitem.hxx>
25 : #include <iderid.hxx>
26 : #include <svtools/tabbar.hxx>
27 : #include <vcl/toolbox.hxx>
28 :
29 : #include <boost/unordered_map.hpp>
30 :
31 : class SbModule;
32 : class SfxItemSet;
33 : class SfxRequest;
34 : class SvxSearchItem;
35 : class Printer;
36 :
37 : namespace svl
38 : {
39 : class IUndoManager;
40 : }
41 :
42 : namespace basctl
43 : {
44 :
45 : class Layout;
46 : class ModulWindow;
47 : class DialogWindow;
48 :
49 : #define LINE_SEP_CR 0x0D
50 : #define LINE_SEP 0x0A
51 :
52 : // Implementation: baside2b.cxx
53 : sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex );
54 :
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!
59 :
60 : struct BasicStatus
61 : {
62 : bool bIsRunning : 1;
63 : bool bError : 1;
64 : bool bIsInReschedule : 1;
65 : sal_uInt16 nBasicFlags;
66 :
67 0 : BasicStatus():
68 : bIsRunning(false),
69 : bError(false),
70 : bIsInReschedule(false),
71 0 : nBasicFlags(0) { }
72 : };
73 :
74 : //
75 : // basctl::DockingWindow -- special docking window for the Basic IDE
76 : // Not to be confused with ::DockingWindow from vcl.
77 : //
78 0 : class DockingWindow : public ::DockingWindow
79 : {
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 0 : Size GetDockingSize () const { return aDockingRect.GetSize(); }
87 : void SetLayoutWindow (Layout*);
88 : public:
89 : void Show (bool = true);
90 : void Hide ();
91 :
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();
98 :
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;
108 :
109 : static WinBits const StyleBits;
110 :
111 : private:
112 : void DockThis ();
113 : };
114 :
115 : //
116 : // basctl::TabBar
117 : // Not to be confused with ::TabBar from svtools.
118 : //
119 0 : class TabBar : public ::TabBar
120 : {
121 : protected:
122 : virtual void MouseButtonDown( const MouseEvent& rMEvt );
123 : virtual void Command( const CommandEvent& rCEvt );
124 :
125 : virtual long AllowRenaming();
126 : virtual void EndRenaming();
127 :
128 : public:
129 : TabBar (Window* pParent);
130 :
131 : void Sort();
132 : };
133 :
134 : enum BasicWindowStatus
135 : {
136 : BASWIN_OK = 0x00,
137 : BASWIN_RUNNINGBASIC = 0x01,
138 : BASWIN_TOBEKILLED = 0x02,
139 : BASWIN_SUSPENDED = 0x04,
140 : BASWIN_INRESCHEDULE = 0x08
141 : };
142 :
143 : class EntryDescriptor;
144 :
145 : //
146 : // BaseWindow -- the base of both ModulWindow and DialogWindow.
147 : //
148 : class BaseWindow : public Window
149 : {
150 : private:
151 : ScrollBar* pShellHScrollBar;
152 : ScrollBar* pShellVScrollBar;
153 :
154 : DECL_LINK( ScrollHdl, ScrollBar * );
155 : int nStatus;
156 :
157 : ScriptDocument m_aDocument;
158 : OUString m_aLibName;
159 : OUString m_aName;
160 :
161 : friend class ModulWindow;
162 : friend class DialogWindow;
163 :
164 : protected:
165 : virtual void DoScroll( ScrollBar* pCurScrollBar );
166 :
167 : public:
168 : TYPEINFO();
169 : BaseWindow( Window* pParent, const ScriptDocument& rDocument, OUString aLibName, OUString aName );
170 : virtual ~BaseWindow();
171 :
172 : void Init();
173 : virtual void DoInit();
174 : virtual void Activating () = 0;
175 : virtual void Deactivating () = 0;
176 : void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
177 :
178 0 : ScrollBar* GetHScrollBar() const { return pShellHScrollBar; }
179 0 : ScrollBar* GetVScrollBar() const { return pShellVScrollBar; }
180 :
181 : virtual void ExecuteCommand (SfxRequest&);
182 : virtual void ExecuteGlobal (SfxRequest&);
183 : virtual void GetState (SfxItemSet&) = 0;
184 : virtual long Notify( NotifyEvent& rNEvt );
185 :
186 : virtual void StoreData();
187 : virtual void UpdateData();
188 : virtual bool CanClose();
189 :
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;
194 :
195 : virtual OUString GetTitle();
196 : OUString CreateQualifiedName();
197 : virtual EntryDescriptor CreateEntryDescriptor() = 0;
198 :
199 : virtual bool IsModified();
200 : virtual bool IsPasteAllowed();
201 :
202 : virtual bool AllowUndo();
203 :
204 : virtual void SetReadOnly (bool bReadOnly);
205 : virtual bool IsReadOnly();
206 :
207 0 : int GetStatus() { return nStatus; }
208 0 : void SetStatus(int n) { nStatus = n; }
209 0 : void AddStatus(int n) { nStatus |= n; }
210 0 : void ClearStatus(int n) { nStatus &= ~n; }
211 :
212 : virtual svl::IUndoManager* GetUndoManager ();
213 :
214 : virtual sal_uInt16 GetSearchOptions();
215 : virtual sal_uInt16 StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false);
216 :
217 : virtual void BasicStarted();
218 : virtual void BasicStopped();
219 :
220 0 : bool IsSuspended() const { return nStatus & BASWIN_SUSPENDED; }
221 :
222 : const ScriptDocument&
223 0 : GetDocument() const { return m_aDocument; }
224 : void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
225 0 : bool IsDocument( const ScriptDocument& rDocument ) const { return rDocument == m_aDocument; }
226 0 : const OUString& GetLibName() const { return m_aLibName; }
227 : void SetLibName( const OUString& aLibName ) { m_aLibName = aLibName; }
228 0 : const OUString& GetName() const { return m_aName; }
229 0 : void SetName( const OUString& aName ) { m_aName = aName; }
230 :
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;
237 : };
238 :
239 : class LibInfos
240 : {
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);
250 :
251 : private:
252 0 : class Key
253 : {
254 : private:
255 : ScriptDocument m_aDocument;
256 : OUString m_aLibName;
257 :
258 : public:
259 : Key (ScriptDocument const&, OUString const& rLibName);
260 : ~Key ();
261 : public:
262 : bool operator == (Key const&) const;
263 : struct Hash
264 : {
265 : size_t operator () (Key const&) const;
266 : };
267 : public:
268 0 : const ScriptDocument& GetDocument() const { return m_aDocument; }
269 : const OUString& GetLibName() const { return m_aLibName; }
270 : };
271 : public:
272 0 : class Item
273 : {
274 : private:
275 : ScriptDocument m_aDocument;
276 : OUString m_aLibName;
277 : OUString m_aCurrentName;
278 : ItemType m_eCurrentType;
279 :
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 0 : const OUString& GetCurrentName() const { return m_aCurrentName; }
287 0 : ItemType GetCurrentType() const { return m_eCurrentType; }
288 : };
289 : private:
290 : typedef boost::unordered_map<Key, Item, Key::Hash> Map;
291 : Map m_aMap;
292 : };
293 :
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 );
297 :
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 );
304 :
305 : class ModuleInfoHelper
306 : {
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 );
314 : };
315 :
316 : } // namespace basctl
317 :
318 : #endif // BASCTL_BASTYPES_HXX
319 :
320 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|