1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
26 #include <svtools/tabbar.hxx>
27 #include <vcl/toolbox.hxx>
29 #include <boost/unordered_map.hpp>
49 #define LINE_SEP_CR 0x0D
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!
64 bool bIsInReschedule
: 1;
65 sal_uInt16 nBasicFlags
;
70 bIsInReschedule(false),
75 // basctl::DockingWindow -- special docking window for the Basic IDE
76 // Not to be confused with ::DockingWindow from vcl.
78 class DockingWindow
: public ::DockingWindow
81 DockingWindow (Window
* pParent
);
82 DockingWindow (Layout
* pParent
);
84 void ResizeIfDocking (Point
const&, Size
const&);
85 void ResizeIfDocking (Size
const&);
86 Size
GetDockingSize () const { return aDockingRect
.GetSize(); }
87 void SetLayoutWindow (Layout
*);
89 void Show (bool = true);
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();
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)
106 // > 0: shown, <= 0: hidden, ++ by Show() and -- by Hide()
109 static WinBits
const StyleBits
;
117 // Not to be confused with ::TabBar from svtools.
119 class TabBar
: public ::TabBar
122 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
123 virtual void Command( const CommandEvent
& rCEvt
);
125 virtual long AllowRenaming();
126 virtual void EndRenaming();
129 TabBar (Window
* pParent
);
134 enum BasicWindowStatus
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
151 ScrollBar
* pShellHScrollBar
;
152 ScrollBar
* pShellVScrollBar
;
154 DECL_LINK( ScrollHdl
, ScrollBar
* );
157 ScriptDocument m_aDocument
;
161 friend class ModulWindow
;
162 friend class DialogWindow
;
165 virtual void DoScroll( ScrollBar
* pCurScrollBar
);
169 BaseWindow( Window
* pParent
, const ScriptDocument
& rDocument
, OUString aLibName
, OUString aName
);
170 virtual ~BaseWindow();
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;
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;
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
);
255 ScriptDocument m_aDocument
;
259 Key (ScriptDocument
const&, OUString
const& rLibName
);
262 bool operator == (Key
const&) const;
265 size_t operator () (Key
const&) const;
268 const ScriptDocument
& GetDocument() const { return m_aDocument
; }
269 const OUString
& GetLibName() const { return m_aLibName
; }
275 ScriptDocument m_aDocument
;
277 OUString m_aCurrentName
;
278 ItemType m_eCurrentType
;
281 Item (ScriptDocument
const&, OUString
const& rLibName
, OUString
const& rCurrentName
, ItemType eCurrentType
);
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
; }
290 typedef boost::unordered_map
<Key
, Item
, Key::Hash
> Map
;
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
309 ModuleInfoHelper (const ModuleInfoHelper
&);
310 ModuleInfoHelper
& operator = (const ModuleInfoHelper
&);
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: */