1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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 ************************************************************************/
33 #include <svheader.hxx>
37 #include "scriptdocument.hxx"
47 #include <vcl/dockwin.hxx>
48 #include <vcl/toolbox.hxx>
49 #include <basic/sbstar.hxx>
53 #include <tools/table.hxx>
55 #include <svtools/tabbar.hxx>
56 #include <com/sun/star/script/XLibraryContainer.hpp>
60 #define LINE_SEP_CR 0x0D
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!
76 // BOOL bCompiled : 1;
79 BOOL bIsInReschedule
: 1;
83 bIsRunning
= FALSE
; bError
= FALSE
;
84 nBasicFlags
= 0; bIsInReschedule
= FALSE
; }
95 BreakPoint( ULONG nL
) { nLine
= nL
; nStopAfter
= 0; nHitCount
= 0; bEnabled
= TRUE
; bTemp
= FALSE
; }
99 class BasicDockingWindow
: public DockingWindow
101 Rectangle aFloatingPosAndSize
;
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();
111 BasicDockingWindow( Window
* pParent
);
114 DECLARE_LIST( BreakPL
, BreakPoint
* )
115 class BreakPointList
: public BreakPL
118 void operator =(BreakPointList
); // not implemented
123 BreakPointList(BreakPointList
const & rList
);
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
145 bool operator<(const TabBarSortHelper
& rComp
) const { return (aPageText
.CompareIgnoreCaseToAscii( rComp
.aPageText
) == COMPARE_LESS
); }
148 class BasicIDETabBar
: public TabBar
151 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
152 virtual void Command( const CommandEvent
& rCEvt
);
154 virtual long AllowRenaming();
155 virtual void EndRenaming();
158 BasicIDETabBar( Window
* pParent
);
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
170 class SfxUndoManager
;
171 class BasicEntryDescriptor
;
173 class IDEBaseWindow
: public Window
176 ScrollBar
* pShellHScrollBar
;
177 ScrollBar
* pShellVScrollBar
;
179 DECL_LINK( ScrollHdl
, ScrollBar
* );
182 ScriptDocument m_aDocument
;
187 virtual void DoScroll( ScrollBar
* pCurScrollBar
);
191 IDEBaseWindow( Window
* pParent
, const ScriptDocument
& rDocument
, String aLibName
, String aName
);
192 virtual ~IDEBaseWindow();
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
; }
253 ScriptDocument m_aDocument
;
257 LibInfoKey( const ScriptDocument
& rDocument
, const String
& rLibName
);
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
; }
273 ScriptDocument m_aDocument
;
275 String m_aCurrentName
;
276 USHORT m_nCurrentType
;
279 LibInfoItem( const ScriptDocument
& rDocument
, const String
& rLibName
, const String
& rCurrentName
, USHORT nCurrentType
);
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
; }
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();
306 typedef ::std::hash_map
< LibInfoKey
, LibInfoItem
*, LibInfoKeyHash
, ::std::equal_to
< LibInfoKey
> > LibInfoMap
;
307 LibInfoMap m_aLibInfoMap
;
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