merged tag ooo/DEV300_m102
[LibreOffice.git] / basctl / source / inc / bastypes.hxx
blob1a5283ae06916b42d18f73bbad6b50e2ebd164c5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef _BASTYPES_HXX
28 #define _BASTYPES_HXX
30 #include <svheader.hxx>
32 #include <iderid.hxx>
34 #include "scriptdocument.hxx"
36 class ModulWindow;
37 class SfxRequest;
38 class SvTreeListBox;
39 class SvLBoxEntry;
40 class ScrollBar;
41 class SbModule;
42 class BasicManager;
43 class SfxItemSet;
44 #include <vcl/dockwin.hxx>
45 #include <vcl/toolbox.hxx>
46 #include <basic/sbstar.hxx>
48 #include <iderid.hxx>
50 #include <tools/table.hxx>
52 #include <svtools/tabbar.hxx>
53 #include <com/sun/star/script/XLibraryContainer.hpp>
55 #include <hash_map>
57 #define LINE_SEP_CR 0x0D
58 #define LINE_SEP 0x0A
60 // Implementation: baside2b.cxx
61 sal_Int32 searchEOL( const ::rtl::OUString& rStr, sal_Int32 fromIndex );
64 // Bedeutung von bToBeKilled:
65 // Wenn in Reschedule-Schleife, darf ich das Fenster nicht zerstoeren.
66 // Es muss erst aus der Reschedule-Schleife Fallen, um sich dann
67 // selbst zu zerstoeren.
68 // Geht so leider nicht: Destroying Window with living Child!
71 struct BasicStatus
73 // sal_Bool bCompiled : 1;
74 sal_Bool bIsRunning : 1;
75 sal_Bool bError : 1;
76 sal_Bool bIsInReschedule : 1;
77 sal_uInt16 nBasicFlags;
79 BasicStatus() {
80 bIsRunning = sal_False; bError = sal_False;
81 nBasicFlags = 0; bIsInReschedule = sal_False; }
84 struct BreakPoint
86 sal_Bool bEnabled;
87 sal_Bool bTemp;
88 sal_uLong nLine;
89 sal_uLong nStopAfter;
90 sal_uLong nHitCount;
92 BreakPoint( sal_uLong nL ) { nLine = nL; nStopAfter = 0; nHitCount = 0; bEnabled = sal_True; bTemp = sal_False; }
96 class BasicDockingWindow : public DockingWindow
98 Rectangle aFloatingPosAndSize;
100 protected:
101 virtual sal_Bool Docking( const Point& rPos, Rectangle& rRect );
102 virtual void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
103 virtual void ToggleFloatingMode();
104 virtual sal_Bool PrepareToggleFloatingMode();
105 virtual void StartDocking();
107 public:
108 BasicDockingWindow( Window* pParent );
111 DECLARE_LIST( BreakPL, BreakPoint* )
112 class BreakPointList : public BreakPL
114 private:
115 void operator =(BreakPointList); // not implemented
117 public:
118 BreakPointList();
120 BreakPointList(BreakPointList const & rList);
122 ~BreakPointList();
124 void reset();
126 void transfer(BreakPointList & rList);
128 void InsertSorted( BreakPoint* pBrk );
129 BreakPoint* FindBreakPoint( sal_uLong nLine );
130 void AdjustBreakPoints( sal_uLong nLine, sal_Bool bInserted );
131 void SetBreakPointsInBasic( SbModule* pModule );
132 void ResetHitCount();
135 // helper class for sorting TabBar
136 class TabBarSortHelper
138 public:
139 sal_uInt16 nPageId;
140 String aPageText;
142 bool operator<(const TabBarSortHelper& rComp) const { return (aPageText.CompareIgnoreCaseToAscii( rComp.aPageText ) == COMPARE_LESS); }
145 class BasicIDETabBar : public TabBar
147 protected:
148 virtual void MouseButtonDown( const MouseEvent& rMEvt );
149 virtual void Command( const CommandEvent& rCEvt );
151 virtual long AllowRenaming();
152 virtual void EndRenaming();
154 public:
155 BasicIDETabBar( Window* pParent );
157 void Sort();
160 #define BASWIN_OK 0x00
161 #define BASWIN_RUNNINGBASIC 0x01
162 #define BASWIN_TOBEKILLED 0x02
163 #define BASWIN_SUSPENDED 0x04
164 #define BASWIN_INRESCHEDULE 0x08
166 class Printer;
167 class BasicEntryDescriptor;
169 namespace svl
171 class IUndoManager;
174 class IDEBaseWindow : public Window
176 private:
177 ScrollBar* pShellHScrollBar;
178 ScrollBar* pShellVScrollBar;
180 DECL_LINK( ScrollHdl, ScrollBar * );
181 sal_uInt8 nStatus;
183 ScriptDocument m_aDocument;
184 String m_aLibName;
185 String m_aName;
187 protected:
188 virtual void DoScroll( ScrollBar* pCurScrollBar );
190 public:
191 TYPEINFO();
192 IDEBaseWindow( Window* pParent, const ScriptDocument& rDocument, String aLibName, String aName );
193 virtual ~IDEBaseWindow();
195 void Init();
196 virtual void DoInit();
197 virtual void Deactivating();
198 void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
200 ScrollBar* GetHScrollBar() const { return pShellHScrollBar; }
201 ScrollBar* GetVScrollBar() const { return pShellVScrollBar; }
203 virtual void ExecuteCommand( SfxRequest& rReq );
204 virtual void GetState( SfxItemSet& );
205 virtual long Notify( NotifyEvent& rNEvt );
207 virtual void StoreData();
208 virtual void UpdateData();
209 virtual sal_Bool CanClose();
211 // return number of pages to be printed
212 virtual sal_Int32 countPages( Printer* pPrinter ) = 0;
213 // print page
214 virtual void printPage( sal_Int32 nPage, Printer* pPrinter ) = 0;
216 virtual String GetTitle();
217 String CreateQualifiedName();
218 virtual BasicEntryDescriptor CreateEntryDescriptor() = 0;
220 virtual sal_Bool IsModified();
221 virtual sal_Bool IsPasteAllowed();
223 virtual sal_Bool AllowUndo();
225 virtual void SetReadOnly( sal_Bool bReadOnly );
226 virtual sal_Bool IsReadOnly();
228 sal_uInt8 GetStatus() { return nStatus; }
229 void SetStatus( sal_uInt8 n ) { nStatus = n; }
230 void AddStatus( sal_uInt8 n ) { nStatus = nStatus | n; }
231 void ClearStatus( sal_uInt8 n ) { nStatus = nStatus & ~n; }
233 virtual Window* GetLayoutWindow();
235 virtual ::svl::IUndoManager*
236 GetUndoManager();
238 virtual sal_uInt16 GetSearchOptions();
240 virtual void BasicStarted();
241 virtual void BasicStopped();
243 sal_Bool IsSuspended() const
244 { return ( nStatus & BASWIN_SUSPENDED ) ? sal_True : sal_False; }
246 const ScriptDocument&
247 GetDocument() const { return m_aDocument; }
248 void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
249 bool IsDocument( const ScriptDocument& rDocument ) const { return rDocument == m_aDocument; }
250 const String& GetLibName() const { return m_aLibName; }
251 void SetLibName( const String& aLibName ) { m_aLibName = aLibName; }
252 const String& GetName() const { return m_aName; }
253 void SetName( const String& aName ) { m_aName = aName; }
256 class LibInfoKey
258 private:
259 ScriptDocument m_aDocument;
260 String m_aLibName;
262 public:
263 LibInfoKey( const ScriptDocument& rDocument, const String& rLibName );
264 ~LibInfoKey();
266 LibInfoKey( const LibInfoKey& rKey );
267 LibInfoKey& operator=( const LibInfoKey& rKey );
269 bool operator==( const LibInfoKey& rKey ) const;
271 const ScriptDocument&
272 GetDocument() const { return m_aDocument; }
273 const String& GetLibName() const { return m_aLibName; }
276 class LibInfoItem
278 private:
279 ScriptDocument m_aDocument;
280 String m_aLibName;
281 String m_aCurrentName;
282 sal_uInt16 m_nCurrentType;
284 public:
285 LibInfoItem( const ScriptDocument& rDocument, const String& rLibName, const String& rCurrentName, sal_uInt16 nCurrentType );
286 ~LibInfoItem();
288 LibInfoItem( const LibInfoItem& rItem );
289 LibInfoItem& operator=( const LibInfoItem& rItem );
291 const ScriptDocument&
292 GetDocument() const { return m_aDocument; }
293 const String& GetLibName() const { return m_aLibName; }
294 const String& GetCurrentName() const { return m_aCurrentName; }
295 sal_uInt16 GetCurrentType() const { return m_nCurrentType; }
298 class LibInfos
300 private:
302 struct LibInfoKeyHash
304 size_t operator()( const LibInfoKey& rKey ) const
306 size_t nHash = (size_t) rKey.GetDocument().hashCode();
307 nHash += (size_t) ::rtl::OUString( rKey.GetLibName() ).hashCode();
308 return nHash;
312 typedef ::std::hash_map< LibInfoKey, LibInfoItem*, LibInfoKeyHash, ::std::equal_to< LibInfoKey > > LibInfoMap;
313 LibInfoMap m_aLibInfoMap;
315 public:
316 LibInfos();
317 ~LibInfos();
319 void InsertInfo( LibInfoItem* pItem );
320 void RemoveInfoFor( const ScriptDocument& _rDocument );
322 LibInfoItem* GetInfo( const LibInfoKey& rKey );
325 void CutLines( ::rtl::OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, sal_Bool bEraseTrailingEmptyLines = sal_False );
326 String CreateMgrAndLibStr( const String& rMgrName, const String& rLibName );
327 sal_uLong CalcLineCount( SvStream& rStream );
329 sal_Bool QueryReplaceMacro( const String& rName, Window* pParent = 0 );
330 sal_Bool QueryDelMacro( const String& rName, Window* pParent = 0 );
331 sal_Bool QueryDelDialog( const String& rName, Window* pParent = 0 );
332 sal_Bool QueryDelModule( const String& rName, Window* pParent = 0 );
333 sal_Bool QueryDelLib( const String& rName, sal_Bool bRef = sal_False, Window* pParent = 0 );
334 sal_Bool QueryPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xLibContainer, const String& rLibName, String& rPassword, sal_Bool bRepeat = sal_False, sal_Bool bNewTitle = sal_False );
336 class ModuleInfoHelper
338 ModuleInfoHelper();
339 ModuleInfoHelper(const ModuleInfoHelper&);
340 ModuleInfoHelper& operator = (const ModuleInfoHelper&);
341 public:
342 static void getObjectName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName, String& rObjName );
343 static sal_Int32 getModuleType( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName );
345 #endif // _BASTYPES_HXX