merge the formfield patch from ooo-build
[ooovba.git] / basctl / source / inc / bastypes.hxx
blobf3bd547f8fdd01243b2ec9df929d0c83f86bcca3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bastypes.hxx,v $
10 * $Revision: 1.10.30.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _BASTYPES_HXX
31 #define _BASTYPES_HXX
33 #include <svheader.hxx>
35 #include <iderid.hxx>
37 #include "scriptdocument.hxx"
39 class ModulWindow;
40 class SfxRequest;
41 class SvTreeListBox;
42 class SvLBoxEntry;
43 class ScrollBar;
44 class SbModule;
45 class BasicManager;
46 class SfxItemSet;
47 #include <vcl/dockwin.hxx>
48 #include <vcl/toolbox.hxx>
49 #include <basic/sbstar.hxx>
51 #include <iderid.hxx>
53 #include <tools/table.hxx>
55 #include <svtools/tabbar.hxx>
56 #include <com/sun/star/script/XLibraryContainer.hpp>
58 #include <hash_map>
60 #define LINE_SEP_CR 0x0D
61 #define LINE_SEP 0x0A
63 // Implementation: baside2b.cxx
64 sal_Int32 searchEOL( const ::rtl::OUString& rStr, sal_Int32 fromIndex );
67 // Bedeutung von bToBeKilled:
68 // Wenn in Reschedule-Schleife, darf ich das Fenster nicht zerstoeren.
69 // Es muss erst aus der Reschedule-Schleife Fallen, um sich dann
70 // selbst zu zerstoeren.
71 // Geht so leider nicht: Destroying Window with living Child!
74 struct BasicStatus
76 // BOOL bCompiled : 1;
77 BOOL bIsRunning : 1;
78 BOOL bError : 1;
79 BOOL bIsInReschedule : 1;
80 USHORT nBasicFlags;
82 BasicStatus() {
83 bIsRunning = FALSE; bError = FALSE;
84 nBasicFlags = 0; bIsInReschedule = FALSE; }
87 struct BreakPoint
89 BOOL bEnabled;
90 BOOL bTemp;
91 ULONG nLine;
92 ULONG nStopAfter;
93 ULONG nHitCount;
95 BreakPoint( ULONG nL ) { nLine = nL; nStopAfter = 0; nHitCount = 0; bEnabled = TRUE; bTemp = FALSE; }
99 class BasicDockingWindow : public DockingWindow
101 Rectangle aFloatingPosAndSize;
103 protected:
104 virtual BOOL Docking( const Point& rPos, Rectangle& rRect );
105 virtual void EndDocking( const Rectangle& rRect, BOOL bFloatMode );
106 virtual void ToggleFloatingMode();
107 virtual BOOL PrepareToggleFloatingMode();
108 virtual void StartDocking();
110 public:
111 BasicDockingWindow( Window* pParent );
114 DECLARE_LIST( BreakPL, BreakPoint* )
115 class BreakPointList : public BreakPL
117 private:
118 void operator =(BreakPointList); // not implemented
120 public:
121 BreakPointList();
123 BreakPointList(BreakPointList const & rList);
125 ~BreakPointList();
127 void reset();
129 void transfer(BreakPointList & rList);
131 void InsertSorted( BreakPoint* pBrk );
132 BreakPoint* FindBreakPoint( ULONG nLine );
133 void AdjustBreakPoints( ULONG nLine, BOOL bInserted );
134 void SetBreakPointsInBasic( SbModule* pModule );
135 void ResetHitCount();
138 // helper class for sorting TabBar
139 class TabBarSortHelper
141 public:
142 USHORT nPageId;
143 String aPageText;
145 bool operator<(const TabBarSortHelper& rComp) const { return (aPageText.CompareIgnoreCaseToAscii( rComp.aPageText ) == COMPARE_LESS); }
148 class BasicIDETabBar : public TabBar
150 protected:
151 virtual void MouseButtonDown( const MouseEvent& rMEvt );
152 virtual void Command( const CommandEvent& rCEvt );
154 virtual long AllowRenaming();
155 virtual void EndRenaming();
157 public:
158 BasicIDETabBar( Window* pParent );
160 void Sort();
163 #define BASWIN_OK 0x00
164 #define BASWIN_RUNNINGBASIC 0x01
165 #define BASWIN_TOBEKILLED 0x02
166 #define BASWIN_SUSPENDED 0x04
167 #define BASWIN_INRESCHEDULE 0x08
169 class Printer;
170 class SfxUndoManager;
171 class BasicEntryDescriptor;
173 class IDEBaseWindow : public Window
175 private:
176 ScrollBar* pShellHScrollBar;
177 ScrollBar* pShellVScrollBar;
179 DECL_LINK( ScrollHdl, ScrollBar * );
180 BYTE nStatus;
182 ScriptDocument m_aDocument;
183 String m_aLibName;
184 String m_aName;
186 protected:
187 virtual void DoScroll( ScrollBar* pCurScrollBar );
189 public:
190 TYPEINFO();
191 IDEBaseWindow( Window* pParent, const ScriptDocument& rDocument, String aLibName, String aName );
192 virtual ~IDEBaseWindow();
194 void Init();
195 virtual void DoInit();
196 virtual void Deactivating();
197 void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
199 ScrollBar* GetHScrollBar() const { return pShellHScrollBar; }
200 ScrollBar* GetVScrollBar() const { return pShellVScrollBar; }
202 virtual void ExecuteCommand( SfxRequest& rReq );
203 virtual void GetState( SfxItemSet& );
204 virtual long Notify( NotifyEvent& rNEvt );
206 virtual void StoreData();
207 virtual void UpdateData();
208 virtual void PrintData( Printer* pPrinter );
209 virtual BOOL CanClose();
211 virtual String GetTitle();
212 String CreateQualifiedName();
213 virtual BasicEntryDescriptor CreateEntryDescriptor() = 0;
215 virtual BOOL IsModified();
216 virtual BOOL IsPasteAllowed();
218 virtual BOOL AllowUndo();
220 virtual void SetReadOnly( BOOL bReadOnly );
221 virtual BOOL IsReadOnly();
223 BYTE GetStatus() { return nStatus; }
224 void SetStatus( BYTE n ) { nStatus = n; }
225 void AddStatus( BYTE n ) { nStatus = nStatus | n; }
226 void ClearStatus( BYTE n ) { nStatus = nStatus & ~n; }
228 virtual Window* GetLayoutWindow();
230 virtual SfxUndoManager* GetUndoManager();
232 virtual USHORT GetSearchOptions();
234 virtual void BasicStarted();
235 virtual void BasicStopped();
237 BOOL IsSuspended() const
238 { return ( nStatus & BASWIN_SUSPENDED ) ? TRUE : FALSE; }
240 const ScriptDocument&
241 GetDocument() const { return m_aDocument; }
242 void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
243 bool IsDocument( const ScriptDocument& rDocument ) const { return rDocument == m_aDocument; }
244 const String& GetLibName() const { return m_aLibName; }
245 void SetLibName( const String& aLibName ) { m_aLibName = aLibName; }
246 const String& GetName() const { return m_aName; }
247 void SetName( const String& aName ) { m_aName = aName; }
250 class LibInfoKey
252 private:
253 ScriptDocument m_aDocument;
254 String m_aLibName;
256 public:
257 LibInfoKey( const ScriptDocument& rDocument, const String& rLibName );
258 ~LibInfoKey();
260 LibInfoKey( const LibInfoKey& rKey );
261 LibInfoKey& operator=( const LibInfoKey& rKey );
263 bool operator==( const LibInfoKey& rKey ) const;
265 const ScriptDocument&
266 GetDocument() const { return m_aDocument; }
267 const String& GetLibName() const { return m_aLibName; }
270 class LibInfoItem
272 private:
273 ScriptDocument m_aDocument;
274 String m_aLibName;
275 String m_aCurrentName;
276 USHORT m_nCurrentType;
278 public:
279 LibInfoItem( const ScriptDocument& rDocument, const String& rLibName, const String& rCurrentName, USHORT nCurrentType );
280 ~LibInfoItem();
282 LibInfoItem( const LibInfoItem& rItem );
283 LibInfoItem& operator=( const LibInfoItem& rItem );
285 const ScriptDocument&
286 GetDocument() const { return m_aDocument; }
287 const String& GetLibName() const { return m_aLibName; }
288 const String& GetCurrentName() const { return m_aCurrentName; }
289 USHORT GetCurrentType() const { return m_nCurrentType; }
292 class LibInfos
294 private:
296 struct LibInfoKeyHash
298 size_t operator()( const LibInfoKey& rKey ) const
300 size_t nHash = (size_t) rKey.GetDocument().hashCode();
301 nHash += (size_t) ::rtl::OUString( rKey.GetLibName() ).hashCode();
302 return nHash;
306 typedef ::std::hash_map< LibInfoKey, LibInfoItem*, LibInfoKeyHash, ::std::equal_to< LibInfoKey > > LibInfoMap;
307 LibInfoMap m_aLibInfoMap;
309 public:
310 LibInfos();
311 ~LibInfos();
313 void InsertInfo( LibInfoItem* pItem );
314 void RemoveInfoFor( const ScriptDocument& _rDocument );
316 LibInfoItem* GetInfo( const LibInfoKey& rKey );
319 void CutLines( ::rtl::OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, BOOL bEraseTrailingEmptyLines = FALSE );
320 String CreateMgrAndLibStr( const String& rMgrName, const String& rLibName );
321 ULONG CalcLineCount( SvStream& rStream );
323 BOOL QueryReplaceMacro( const String& rName, Window* pParent = 0 );
324 BOOL QueryDelMacro( const String& rName, Window* pParent = 0 );
325 BOOL QueryDelDialog( const String& rName, Window* pParent = 0 );
326 BOOL QueryDelModule( const String& rName, Window* pParent = 0 );
327 BOOL QueryDelLib( const String& rName, BOOL bRef = FALSE, Window* pParent = 0 );
328 BOOL QueryPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xLibContainer, const String& rLibName, String& rPassword, BOOL bRepeat = FALSE, BOOL bNewTitle = FALSE );
331 #endif // _BASTYPES_HXX