1*96821c26SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96821c26SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96821c26SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96821c26SAndrew Rist * distributed with this work for additional information 6*96821c26SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96821c26SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96821c26SAndrew Rist * "License"); you may not use this file except in compliance 9*96821c26SAndrew Rist * with the License. You may obtain a copy of the License at 10*96821c26SAndrew Rist * 11*96821c26SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*96821c26SAndrew Rist * 13*96821c26SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96821c26SAndrew Rist * software distributed under the License is distributed on an 15*96821c26SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96821c26SAndrew Rist * KIND, either express or implied. See the License for the 17*96821c26SAndrew Rist * specific language governing permissions and limitations 18*96821c26SAndrew Rist * under the License. 19*96821c26SAndrew Rist * 20*96821c26SAndrew Rist *************************************************************/ 21*96821c26SAndrew Rist 22*96821c26SAndrew Rist 23cdf0e10cSrcweir #ifndef _BASTYPES_HXX 24cdf0e10cSrcweir #define _BASTYPES_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <svheader.hxx> 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <iderid.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include "scriptdocument.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir class ModulWindow; 33cdf0e10cSrcweir class SfxRequest; 34cdf0e10cSrcweir class SvTreeListBox; 35cdf0e10cSrcweir class SvLBoxEntry; 36cdf0e10cSrcweir class ScrollBar; 37cdf0e10cSrcweir class SbModule; 38cdf0e10cSrcweir class BasicManager; 39cdf0e10cSrcweir class SfxItemSet; 40cdf0e10cSrcweir #include <vcl/dockwin.hxx> 41cdf0e10cSrcweir #include <vcl/toolbox.hxx> 42cdf0e10cSrcweir #include <basic/sbstar.hxx> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include <iderid.hxx> 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include <tools/table.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir #include <svtools/tabbar.hxx> 49cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer.hpp> 50cdf0e10cSrcweir 51cdf0e10cSrcweir #include <hash_map> 52cdf0e10cSrcweir 53cdf0e10cSrcweir #define LINE_SEP_CR 0x0D 54cdf0e10cSrcweir #define LINE_SEP 0x0A 55cdf0e10cSrcweir 56cdf0e10cSrcweir // Implementation: baside2b.cxx 57cdf0e10cSrcweir sal_Int32 searchEOL( const ::rtl::OUString& rStr, sal_Int32 fromIndex ); 58cdf0e10cSrcweir 59cdf0e10cSrcweir 60cdf0e10cSrcweir // Bedeutung von bToBeKilled: 61cdf0e10cSrcweir // Wenn in Reschedule-Schleife, darf ich das Fenster nicht zerstoeren. 62cdf0e10cSrcweir // Es muss erst aus der Reschedule-Schleife Fallen, um sich dann 63cdf0e10cSrcweir // selbst zu zerstoeren. 64cdf0e10cSrcweir // Geht so leider nicht: Destroying Window with living Child! 65cdf0e10cSrcweir 66cdf0e10cSrcweir 67cdf0e10cSrcweir struct BasicStatus 68cdf0e10cSrcweir { 69cdf0e10cSrcweir // sal_Bool bCompiled : 1; 70cdf0e10cSrcweir sal_Bool bIsRunning : 1; 71cdf0e10cSrcweir sal_Bool bError : 1; 72cdf0e10cSrcweir sal_Bool bIsInReschedule : 1; 73cdf0e10cSrcweir sal_uInt16 nBasicFlags; 74cdf0e10cSrcweir BasicStatusBasicStatus75cdf0e10cSrcweir BasicStatus() { 76cdf0e10cSrcweir bIsRunning = sal_False; bError = sal_False; 77cdf0e10cSrcweir nBasicFlags = 0; bIsInReschedule = sal_False; } 78cdf0e10cSrcweir }; 79cdf0e10cSrcweir 80cdf0e10cSrcweir struct BreakPoint 81cdf0e10cSrcweir { 82cdf0e10cSrcweir sal_Bool bEnabled; 83cdf0e10cSrcweir sal_Bool bTemp; 84cdf0e10cSrcweir sal_uLong nLine; 85cdf0e10cSrcweir sal_uLong nStopAfter; 86cdf0e10cSrcweir sal_uLong nHitCount; 87cdf0e10cSrcweir BreakPointBreakPoint88cdf0e10cSrcweir BreakPoint( sal_uLong nL ) { nLine = nL; nStopAfter = 0; nHitCount = 0; bEnabled = sal_True; bTemp = sal_False; } 89cdf0e10cSrcweir 90cdf0e10cSrcweir }; 91cdf0e10cSrcweir 92cdf0e10cSrcweir class BasicDockingWindow : public DockingWindow 93cdf0e10cSrcweir { 94cdf0e10cSrcweir Rectangle aFloatingPosAndSize; 95cdf0e10cSrcweir 96cdf0e10cSrcweir protected: 97cdf0e10cSrcweir virtual sal_Bool Docking( const Point& rPos, Rectangle& rRect ); 98cdf0e10cSrcweir virtual void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode ); 99cdf0e10cSrcweir virtual void ToggleFloatingMode(); 100cdf0e10cSrcweir virtual sal_Bool PrepareToggleFloatingMode(); 101cdf0e10cSrcweir virtual void StartDocking(); 102cdf0e10cSrcweir 103cdf0e10cSrcweir public: 104cdf0e10cSrcweir BasicDockingWindow( Window* pParent ); 105cdf0e10cSrcweir }; 106cdf0e10cSrcweir 107cdf0e10cSrcweir DECLARE_LIST( BreakPL, BreakPoint* ) 108cdf0e10cSrcweir class BreakPointList : public BreakPL 109cdf0e10cSrcweir { 110cdf0e10cSrcweir private: 111cdf0e10cSrcweir void operator =(BreakPointList); // not implemented 112cdf0e10cSrcweir 113cdf0e10cSrcweir public: 114cdf0e10cSrcweir BreakPointList(); 115cdf0e10cSrcweir 116cdf0e10cSrcweir BreakPointList(BreakPointList const & rList); 117cdf0e10cSrcweir 118cdf0e10cSrcweir ~BreakPointList(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir void reset(); 121cdf0e10cSrcweir 122cdf0e10cSrcweir void transfer(BreakPointList & rList); 123cdf0e10cSrcweir 124cdf0e10cSrcweir void InsertSorted( BreakPoint* pBrk ); 125cdf0e10cSrcweir BreakPoint* FindBreakPoint( sal_uLong nLine ); 126cdf0e10cSrcweir void AdjustBreakPoints( sal_uLong nLine, sal_Bool bInserted ); 127cdf0e10cSrcweir void SetBreakPointsInBasic( SbModule* pModule ); 128cdf0e10cSrcweir void ResetHitCount(); 129cdf0e10cSrcweir }; 130cdf0e10cSrcweir 131cdf0e10cSrcweir // helper class for sorting TabBar 132cdf0e10cSrcweir class TabBarSortHelper 133cdf0e10cSrcweir { 134cdf0e10cSrcweir public: 135cdf0e10cSrcweir sal_uInt16 nPageId; 136cdf0e10cSrcweir String aPageText; 137cdf0e10cSrcweir operator <(const TabBarSortHelper & rComp) const138cdf0e10cSrcweir bool operator<(const TabBarSortHelper& rComp) const { return (aPageText.CompareIgnoreCaseToAscii( rComp.aPageText ) == COMPARE_LESS); } 139cdf0e10cSrcweir }; 140cdf0e10cSrcweir 141cdf0e10cSrcweir class BasicIDETabBar : public TabBar 142cdf0e10cSrcweir { 143cdf0e10cSrcweir protected: 144cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 145cdf0e10cSrcweir virtual void Command( const CommandEvent& rCEvt ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir virtual long AllowRenaming(); 148cdf0e10cSrcweir virtual void EndRenaming(); 149cdf0e10cSrcweir 150cdf0e10cSrcweir public: 151cdf0e10cSrcweir BasicIDETabBar( Window* pParent ); 152cdf0e10cSrcweir 153cdf0e10cSrcweir void Sort(); 154cdf0e10cSrcweir }; 155cdf0e10cSrcweir 156cdf0e10cSrcweir #define BASWIN_OK 0x00 157cdf0e10cSrcweir #define BASWIN_RUNNINGBASIC 0x01 158cdf0e10cSrcweir #define BASWIN_TOBEKILLED 0x02 159cdf0e10cSrcweir #define BASWIN_SUSPENDED 0x04 160cdf0e10cSrcweir #define BASWIN_INRESCHEDULE 0x08 161cdf0e10cSrcweir 162cdf0e10cSrcweir class Printer; 163cdf0e10cSrcweir class BasicEntryDescriptor; 164cdf0e10cSrcweir 165cdf0e10cSrcweir namespace svl 166cdf0e10cSrcweir { 167cdf0e10cSrcweir class IUndoManager; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir class IDEBaseWindow : public Window 171cdf0e10cSrcweir { 172cdf0e10cSrcweir private: 173cdf0e10cSrcweir ScrollBar* pShellHScrollBar; 174cdf0e10cSrcweir ScrollBar* pShellVScrollBar; 175cdf0e10cSrcweir 176cdf0e10cSrcweir DECL_LINK( ScrollHdl, ScrollBar * ); 177cdf0e10cSrcweir sal_uInt8 nStatus; 178cdf0e10cSrcweir 179cdf0e10cSrcweir ScriptDocument m_aDocument; 180cdf0e10cSrcweir String m_aLibName; 181cdf0e10cSrcweir String m_aName; 182cdf0e10cSrcweir 183cdf0e10cSrcweir protected: 184cdf0e10cSrcweir virtual void DoScroll( ScrollBar* pCurScrollBar ); 185cdf0e10cSrcweir 186cdf0e10cSrcweir public: 187cdf0e10cSrcweir TYPEINFO(); 188cdf0e10cSrcweir IDEBaseWindow( Window* pParent, const ScriptDocument& rDocument, String aLibName, String aName ); 189cdf0e10cSrcweir virtual ~IDEBaseWindow(); 190cdf0e10cSrcweir 191cdf0e10cSrcweir void Init(); 192cdf0e10cSrcweir virtual void DoInit(); 193cdf0e10cSrcweir virtual void Deactivating(); 194cdf0e10cSrcweir void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll ); 195cdf0e10cSrcweir GetHScrollBar() const196cdf0e10cSrcweir ScrollBar* GetHScrollBar() const { return pShellHScrollBar; } GetVScrollBar() const197cdf0e10cSrcweir ScrollBar* GetVScrollBar() const { return pShellVScrollBar; } 198cdf0e10cSrcweir 199cdf0e10cSrcweir virtual void ExecuteCommand( SfxRequest& rReq ); 200cdf0e10cSrcweir virtual void GetState( SfxItemSet& ); 201cdf0e10cSrcweir virtual long Notify( NotifyEvent& rNEvt ); 202cdf0e10cSrcweir 203cdf0e10cSrcweir virtual void StoreData(); 204cdf0e10cSrcweir virtual void UpdateData(); 205cdf0e10cSrcweir virtual sal_Bool CanClose(); 206cdf0e10cSrcweir 207cdf0e10cSrcweir // return number of pages to be printed 208cdf0e10cSrcweir virtual sal_Int32 countPages( Printer* pPrinter ) = 0; 209cdf0e10cSrcweir // print page 210cdf0e10cSrcweir virtual void printPage( sal_Int32 nPage, Printer* pPrinter ) = 0; 211cdf0e10cSrcweir 212cdf0e10cSrcweir virtual String GetTitle(); 213cdf0e10cSrcweir String CreateQualifiedName(); 214cdf0e10cSrcweir virtual BasicEntryDescriptor CreateEntryDescriptor() = 0; 215cdf0e10cSrcweir 216cdf0e10cSrcweir virtual sal_Bool IsModified(); 217cdf0e10cSrcweir virtual sal_Bool IsPasteAllowed(); 218cdf0e10cSrcweir 219cdf0e10cSrcweir virtual sal_Bool AllowUndo(); 220cdf0e10cSrcweir 221cdf0e10cSrcweir virtual void SetReadOnly( sal_Bool bReadOnly ); 222cdf0e10cSrcweir virtual sal_Bool IsReadOnly(); 223cdf0e10cSrcweir GetStatus()224cdf0e10cSrcweir sal_uInt8 GetStatus() { return nStatus; } SetStatus(sal_uInt8 n)225cdf0e10cSrcweir void SetStatus( sal_uInt8 n ) { nStatus = n; } AddStatus(sal_uInt8 n)226cdf0e10cSrcweir void AddStatus( sal_uInt8 n ) { nStatus = nStatus | n; } ClearStatus(sal_uInt8 n)227cdf0e10cSrcweir void ClearStatus( sal_uInt8 n ) { nStatus = nStatus & ~n; } 228cdf0e10cSrcweir 229cdf0e10cSrcweir virtual Window* GetLayoutWindow(); 230cdf0e10cSrcweir 231cdf0e10cSrcweir virtual ::svl::IUndoManager* 232cdf0e10cSrcweir GetUndoManager(); 233cdf0e10cSrcweir 234cdf0e10cSrcweir virtual sal_uInt16 GetSearchOptions(); 235cdf0e10cSrcweir 236cdf0e10cSrcweir virtual void BasicStarted(); 237cdf0e10cSrcweir virtual void BasicStopped(); 238cdf0e10cSrcweir IsSuspended() const239cdf0e10cSrcweir sal_Bool IsSuspended() const 240cdf0e10cSrcweir { return ( nStatus & BASWIN_SUSPENDED ) ? sal_True : sal_False; } 241cdf0e10cSrcweir 242cdf0e10cSrcweir const ScriptDocument& GetDocument() const243cdf0e10cSrcweir GetDocument() const { return m_aDocument; } SetDocument(const ScriptDocument & rDocument)244cdf0e10cSrcweir void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; } IsDocument(const ScriptDocument & rDocument) const245cdf0e10cSrcweir bool IsDocument( const ScriptDocument& rDocument ) const { return rDocument == m_aDocument; } GetLibName() const246cdf0e10cSrcweir const String& GetLibName() const { return m_aLibName; } SetLibName(const String & aLibName)247cdf0e10cSrcweir void SetLibName( const String& aLibName ) { m_aLibName = aLibName; } GetName() const248cdf0e10cSrcweir const String& GetName() const { return m_aName; } SetName(const String & aName)249cdf0e10cSrcweir void SetName( const String& aName ) { m_aName = aName; } 250cdf0e10cSrcweir }; 251cdf0e10cSrcweir 252cdf0e10cSrcweir class LibInfoKey 253cdf0e10cSrcweir { 254cdf0e10cSrcweir private: 255cdf0e10cSrcweir ScriptDocument m_aDocument; 256cdf0e10cSrcweir String m_aLibName; 257cdf0e10cSrcweir 258cdf0e10cSrcweir public: 259cdf0e10cSrcweir LibInfoKey( const ScriptDocument& rDocument, const String& rLibName ); 260cdf0e10cSrcweir ~LibInfoKey(); 261cdf0e10cSrcweir 262cdf0e10cSrcweir LibInfoKey( const LibInfoKey& rKey ); 263cdf0e10cSrcweir LibInfoKey& operator=( const LibInfoKey& rKey ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir bool operator==( const LibInfoKey& rKey ) const; 266cdf0e10cSrcweir 267cdf0e10cSrcweir const ScriptDocument& GetDocument() const268cdf0e10cSrcweir GetDocument() const { return m_aDocument; } GetLibName() const269cdf0e10cSrcweir const String& GetLibName() const { return m_aLibName; } 270cdf0e10cSrcweir }; 271cdf0e10cSrcweir 272cdf0e10cSrcweir class LibInfoItem 273cdf0e10cSrcweir { 274cdf0e10cSrcweir private: 275cdf0e10cSrcweir ScriptDocument m_aDocument; 276cdf0e10cSrcweir String m_aLibName; 277cdf0e10cSrcweir String m_aCurrentName; 278cdf0e10cSrcweir sal_uInt16 m_nCurrentType; 279cdf0e10cSrcweir 280cdf0e10cSrcweir public: 281cdf0e10cSrcweir LibInfoItem( const ScriptDocument& rDocument, const String& rLibName, const String& rCurrentName, sal_uInt16 nCurrentType ); 282cdf0e10cSrcweir ~LibInfoItem(); 283cdf0e10cSrcweir 284cdf0e10cSrcweir LibInfoItem( const LibInfoItem& rItem ); 285cdf0e10cSrcweir LibInfoItem& operator=( const LibInfoItem& rItem ); 286cdf0e10cSrcweir 287cdf0e10cSrcweir const ScriptDocument& GetDocument() const288cdf0e10cSrcweir GetDocument() const { return m_aDocument; } GetLibName() const289cdf0e10cSrcweir const String& GetLibName() const { return m_aLibName; } GetCurrentName() const290cdf0e10cSrcweir const String& GetCurrentName() const { return m_aCurrentName; } GetCurrentType() const291cdf0e10cSrcweir sal_uInt16 GetCurrentType() const { return m_nCurrentType; } 292cdf0e10cSrcweir }; 293cdf0e10cSrcweir 294cdf0e10cSrcweir class LibInfos 295cdf0e10cSrcweir { 296cdf0e10cSrcweir private: 297cdf0e10cSrcweir 298cdf0e10cSrcweir struct LibInfoKeyHash 299cdf0e10cSrcweir { operator ()LibInfos::LibInfoKeyHash300cdf0e10cSrcweir size_t operator()( const LibInfoKey& rKey ) const 301cdf0e10cSrcweir { 302cdf0e10cSrcweir size_t nHash = (size_t) rKey.GetDocument().hashCode(); 303cdf0e10cSrcweir nHash += (size_t) ::rtl::OUString( rKey.GetLibName() ).hashCode(); 304cdf0e10cSrcweir return nHash; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir }; 307cdf0e10cSrcweir 308cdf0e10cSrcweir typedef ::std::hash_map< LibInfoKey, LibInfoItem*, LibInfoKeyHash, ::std::equal_to< LibInfoKey > > LibInfoMap; 309cdf0e10cSrcweir LibInfoMap m_aLibInfoMap; 310cdf0e10cSrcweir 311cdf0e10cSrcweir public: 312cdf0e10cSrcweir LibInfos(); 313cdf0e10cSrcweir ~LibInfos(); 314cdf0e10cSrcweir 315cdf0e10cSrcweir void InsertInfo( LibInfoItem* pItem ); 316cdf0e10cSrcweir void RemoveInfoFor( const ScriptDocument& _rDocument ); 317cdf0e10cSrcweir 318cdf0e10cSrcweir LibInfoItem* GetInfo( const LibInfoKey& rKey ); 319cdf0e10cSrcweir }; 320cdf0e10cSrcweir 321cdf0e10cSrcweir void CutLines( ::rtl::OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, sal_Bool bEraseTrailingEmptyLines = sal_False ); 322cdf0e10cSrcweir String CreateMgrAndLibStr( const String& rMgrName, const String& rLibName ); 323cdf0e10cSrcweir sal_uLong CalcLineCount( SvStream& rStream ); 324cdf0e10cSrcweir 325cdf0e10cSrcweir sal_Bool QueryReplaceMacro( const String& rName, Window* pParent = 0 ); 326cdf0e10cSrcweir sal_Bool QueryDelMacro( const String& rName, Window* pParent = 0 ); 327cdf0e10cSrcweir sal_Bool QueryDelDialog( const String& rName, Window* pParent = 0 ); 328cdf0e10cSrcweir sal_Bool QueryDelModule( const String& rName, Window* pParent = 0 ); 329cdf0e10cSrcweir sal_Bool QueryDelLib( const String& rName, sal_Bool bRef = sal_False, Window* pParent = 0 ); 330cdf0e10cSrcweir 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 ); 331cdf0e10cSrcweir 332cdf0e10cSrcweir class ModuleInfoHelper 333cdf0e10cSrcweir { 334cdf0e10cSrcweir ModuleInfoHelper(); 335cdf0e10cSrcweir ModuleInfoHelper(const ModuleInfoHelper&); 336cdf0e10cSrcweir ModuleInfoHelper& operator = (const ModuleInfoHelper&); 337cdf0e10cSrcweir public: 338cdf0e10cSrcweir static void getObjectName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName, String& rObjName ); 339cdf0e10cSrcweir static sal_Int32 getModuleType( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName ); 340cdf0e10cSrcweir }; 341cdf0e10cSrcweir #endif // _BASTYPES_HXX 342