LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/basicide - baside2.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 27 0.0 %
Date: 2012-12-17 Functions: 0 29 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef BASCTL_BASIDE2_HXX
      21             : #define BASCTL_BASIDE2_HXX
      22             : 
      23             : #include "layout.hxx"
      24             : #include "bastypes.hxx"
      25             : #include "bastype3.hxx"
      26             : #include "basidesh.hxx"
      27             : #include "breakpoint.hxx"
      28             : #include "linenumberwindow.hxx"
      29             : 
      30             : #include <svheader.hxx>
      31             : 
      32             : class ExtTextEngine;
      33             : class ExtTextView;
      34             : class SvxSearchItem;
      35             : #include <svtools/svtabbx.hxx>
      36             : #include <svtools/headbar.hxx>
      37             : 
      38             : #include <vcl/button.hxx>
      39             : #include <basic/sbstar.hxx>
      40             : #include <basic/sbmod.hxx>
      41             : #include <vcl/split.hxx>
      42             : #include <svl/lstner.hxx>
      43             : #include <svtools/colorcfg.hxx>
      44             : 
      45             : #include <sfx2/progress.hxx>
      46             : #include <unotools/options.hxx>
      47             : #include <rtl/ref.hxx>
      48             : 
      49             : #include <set>
      50             : #include <boost/scoped_ptr.hpp>
      51             : 
      52             : namespace com { namespace sun { namespace star { namespace beans {
      53             :     class XMultiPropertySet;
      54             : } } } }
      55             : 
      56             : namespace basctl
      57             : {
      58             : 
      59             : class ObjectCatalog;
      60             : 
      61             : DBG_NAMEEX( ModulWindow )
      62             : 
      63             : // #108672 Helper functions to get/set text in TextEngine
      64             : // using the stream interface (get/setText() only supports
      65             : // tools Strings limited to 64K).
      66             : // defined in baside2b.cxx
      67             : OUString getTextEngineText (ExtTextEngine&);
      68             : void setTextEngineText (ExtTextEngine&, OUString const&);
      69             : 
      70             : 
      71             : class EditorWindow : public Window, public SfxListener
      72             : {
      73             : private:
      74             :     class ChangesListener;
      75             : 
      76             :     boost::scoped_ptr<ExtTextView> pEditView;
      77             :     boost::scoped_ptr<ExtTextEngine> pEditEngine;
      78             :     ModulWindow&    rModulWindow;
      79             : 
      80             :     rtl::Reference< ChangesListener > listener_;
      81             :     osl::Mutex mutex_;
      82             :     com::sun::star::uno::Reference< com::sun::star::beans::XMultiPropertySet >
      83             :         notifier_;
      84             : 
      85             :     long            nCurTextWidth;
      86             : 
      87             :     SyntaxHighlighter   aHighlighter;
      88             :     Timer           aSyntaxIdleTimer;
      89             :     typedef std::set<sal_uInt16> SyntaxLineSet;
      90             :     SyntaxLineSet   aSyntaxLineTable;
      91             :     DECL_LINK(SyntaxTimerHdl, void *);
      92             : 
      93             :     // progress bar
      94             :     class ProgressInfo;
      95             :     boost::scoped_ptr<ProgressInfo> pProgress;
      96             : 
      97             :     virtual void DataChanged(DataChangedEvent const & rDCEvt);
      98             : 
      99             :     using           Window::Notify;
     100             :     virtual void    Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     101             : 
     102             :     void            ImpDoHighlight( sal_uLong nLineOff );
     103             :     void            ImplSetFont();
     104             : 
     105             :     bool            bHighlightning;
     106             :     bool            bDoSyntaxHighlight;
     107             :     bool            bDelayHighlight;
     108             : 
     109             :     virtual
     110             :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
     111             :     GetComponentInterface(sal_Bool bCreate = true);
     112             : 
     113             : protected:
     114             :     virtual void    Paint( const Rectangle& );
     115             :     virtual void    Resize();
     116             :     virtual void    KeyInput( const KeyEvent& rKeyEvt );
     117             :     virtual void    MouseMove( const MouseEvent& rMEvt );
     118             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
     119             :     virtual void    MouseButtonUp( const MouseEvent& rMEvt );
     120             :     virtual void    Command( const CommandEvent& rCEvt );
     121             :     virtual void    LoseFocus();
     122             :     virtual void    RequestHelp( const HelpEvent& rHEvt );
     123             : 
     124             :     void            DoSyntaxHighlight( sal_uLong nPara );
     125             :     String          GetWordAtCursor();
     126             :     bool            ImpCanModify();
     127             : 
     128             : public:
     129             :                     EditorWindow (Window* pParent, ModulWindow*);
     130             :                     ~EditorWindow();
     131             : 
     132           0 :     ExtTextEngine*  GetEditEngine() const   { return pEditEngine.get(); }
     133           0 :     ExtTextView*    GetEditView() const     { return pEditView.get(); }
     134             : 
     135             :     void            CreateProgress( const String& rText, sal_uLong nRange );
     136             :     void            DestroyProgress();
     137             : 
     138             :     void            ParagraphInsertedDeleted( sal_uLong nNewPara, bool bInserted );
     139             :     void            DoDelayedSyntaxHighlight( sal_uLong nPara );
     140             : 
     141             :     void            CreateEditEngine();
     142             :     void            SetScrollBarRanges();
     143             :     void            InitScrollBars();
     144             : 
     145             :     void            ForceSyntaxTimeout();
     146             :     bool            SetSourceInBasic();
     147             : 
     148           0 :     bool            CanModify() { return ImpCanModify(); }
     149             : 
     150             :     void            UpdateSyntaxHighlighting ();
     151             : };
     152             : 
     153             : 
     154             : class BreakPointWindow : public Window
     155             : {
     156             : private:
     157             :     ModulWindow&    rModulWindow;
     158             :     long            nCurYOffset;
     159             :     sal_uInt16      nMarkerPos;
     160             :     BreakPointList  aBreakPointList;
     161             :     bool            bErrorMarker;
     162             : 
     163             :     virtual void DataChanged(DataChangedEvent const & rDCEvt);
     164             : 
     165             :     void setBackgroundColor(Color aColor);
     166             : 
     167             : protected:
     168             :     virtual void    Paint( const Rectangle& );
     169             :     BreakPoint*     FindBreakPoint( const Point& rMousePos );
     170             :     void            ShowMarker( bool bShow );
     171             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
     172             :     virtual void    Command( const CommandEvent& rCEvt );
     173             : 
     174             :     bool            SyncYOffset();
     175             : 
     176             : public:
     177             :                     BreakPointWindow (Window* pParent, ModulWindow*);
     178             :                     ~BreakPointWindow();
     179             : 
     180             :     void            SetMarkerPos( sal_uInt16 nLine, bool bErrorMarker = false );
     181             :     void            SetNoMarker ();
     182             : 
     183             :     void            DoScroll( long nHorzScroll, long nVertScroll );
     184           0 :     long&           GetCurYOffset()         { return nCurYOffset; }
     185           0 :     BreakPointList& GetBreakPoints()        { return aBreakPointList; }
     186             : };
     187             : 
     188             : 
     189             : class WatchTreeListBox : public SvHeaderTabListBox
     190             : {
     191             :     String aEditingRes;
     192             : 
     193             : protected:
     194             :     virtual sal_Bool    EditingEntry( SvTreeListEntry* pEntry, Selection& rSel  );
     195             :     virtual sal_Bool    EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText );
     196             : 
     197             :     bool            ImplBasicEntryEdited( SvTreeListEntry* pEntry, const String& rResult );
     198             :     SbxBase*        ImplGetSBXForEntry( SvTreeListEntry* pEntry, bool& rbArrayElement );
     199             : 
     200             : public:
     201             :     WatchTreeListBox( Window* pParent, WinBits nWinBits );
     202             :     ~WatchTreeListBox();
     203             : 
     204             :     void            RequestingChildren( SvTreeListEntry * pParent );
     205             :     void            UpdateWatches( bool bBasicStopped = false );
     206             : 
     207             :     using           SvTabListBox::SetTabs;
     208             :     virtual void    SetTabs();
     209             : };
     210             : 
     211             : 
     212             : 
     213             : class WatchWindow : public DockingWindow
     214             : {
     215             : private:
     216             :     String              aWatchStr;
     217             :     ExtendedEdit        aXEdit;
     218             :     ImageButton         aRemoveWatchButton;
     219             :     WatchTreeListBox    aTreeListBox;
     220             :     HeaderBar           aHeaderBar;
     221             : 
     222             : protected:
     223             :     virtual void    Resize();
     224             :     virtual void    Paint( const Rectangle& rRect );
     225             : 
     226             :     DECL_LINK( ButtonHdl, ImageButton * );
     227             :     DECL_LINK(TreeListHdl, void *);
     228             :     DECL_LINK( implEndDragHdl, HeaderBar * );
     229             :     DECL_LINK( EditAccHdl, Accelerator * );
     230             : 
     231             : 
     232             : public:
     233             :                     WatchWindow (Layout* pParent);
     234             :                     ~WatchWindow();
     235             : 
     236             :     void            AddWatch( const String& rVName );
     237             :     bool            RemoveSelectedWatch();
     238             :     void            UpdateWatches( bool bBasicStopped = false );
     239             : 
     240             :     WatchTreeListBox&   GetWatchTreeListBox() { return aTreeListBox; }
     241             : };
     242             : 
     243             : 
     244             : class StackWindow : public DockingWindow
     245             : {
     246             : private:
     247             :     SvTreeListBox   aTreeListBox;
     248             :     String          aStackStr;
     249             : 
     250             : protected:
     251             :     virtual void    Resize();
     252             :     virtual void    Paint( const Rectangle& rRect );
     253             : 
     254             : public:
     255             :                     StackWindow (Layout* pParent);
     256             :                     ~StackWindow();
     257             : 
     258             :     void            UpdateCalls();
     259             : };
     260             : 
     261             : 
     262           0 : class ComplexEditorWindow : public Window
     263             : {
     264             : private:
     265             :     BreakPointWindow    aBrkWindow;
     266             :     LineNumberWindow    aLineNumberWindow;
     267             :     EditorWindow        aEdtWindow;
     268             :     ScrollBar           aEWVScrollBar;
     269             : 
     270             :     virtual void DataChanged(DataChangedEvent const & rDCEvt);
     271             : 
     272             : protected:
     273             :     virtual void        Resize();
     274             :     DECL_LINK( ScrollHdl, ScrollBar * );
     275             : 
     276             : public:
     277             :                         ComplexEditorWindow( ModulWindow* pParent );
     278             : 
     279           0 :     BreakPointWindow&   GetBrkWindow()      { return aBrkWindow; }
     280           0 :     LineNumberWindow&   GetLineNumberWindow() { return aLineNumberWindow; }
     281           0 :     EditorWindow&       GetEdtWindow()      { return aEdtWindow; }
     282           0 :     ScrollBar&          GetEWVScrollBar()   { return aEWVScrollBar; }
     283             : 
     284             :     void SetLineNumberDisplay(bool b);
     285             : };
     286             : 
     287             : 
     288             : class ModulWindow: public BaseWindow
     289             : {
     290             : private:
     291             :     ModulWindowLayout&  rLayout;
     292             :     StarBASICRef        xBasic;
     293             :     short               nValid;
     294             :     ComplexEditorWindow aXEditorWindow;
     295             :     BasicStatus         aStatus;
     296             :     SbModuleRef         xModule;
     297             :     OUString            aCurPath;
     298             :     OUString            m_aModule;
     299             : 
     300             :     void                CheckCompileBasic();
     301             :     bool                BasicExecute();
     302             : 
     303             :     void                GoOnTop();
     304             : 
     305             :     sal_Int32           FormatAndPrint( Printer* pPrinter, sal_Int32 nPage = -1 );
     306             :     SbModuleRef         XModule();
     307             : protected:
     308             :     virtual void    Resize();
     309             :     virtual void    GetFocus();
     310             :     virtual void    Paint( const Rectangle& );
     311             :     virtual void    DoInit();
     312             :     virtual void    DoScroll( ScrollBar* pCurScrollBar );
     313             : 
     314             : public:
     315             :                     TYPEINFO();
     316             : 
     317             :     ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, OUString aLibName, OUString aName, OUString& aModule );
     318             : 
     319             :                     ~ModulWindow();
     320             : 
     321             :     virtual void    ExecuteCommand (SfxRequest& rReq);
     322             :     virtual void    ExecuteGlobal (SfxRequest& rReq);
     323             :     virtual void    GetState( SfxItemSet& );
     324             :     virtual void    StoreData();
     325             :     virtual void    UpdateData();
     326             :     virtual bool    CanClose();
     327             :     // return number of pages to be printed
     328             :     virtual sal_Int32 countPages( Printer* pPrinter );
     329             :     // print page
     330             :     virtual void printPage( sal_Int32 nPage, Printer* pPrinter );
     331             :     virtual OUString  GetTitle();
     332             :     virtual EntryDescriptor CreateEntryDescriptor();
     333             :     virtual bool    AllowUndo();
     334             :     virtual void    SetReadOnly (bool bReadOnly);
     335             :     virtual bool    IsReadOnly();
     336             : 
     337           0 :     StarBASIC*      GetBasic() { XModule(); return xBasic; }
     338             : 
     339             :     SbModule*       GetSbModule() { return xModule; }
     340           0 :     void            SetSbModule( SbModule* pModule ) { xModule = pModule; }
     341             :     OUString        GetSbModuleName();
     342             : 
     343             :     bool            CompileBasic();
     344             :     bool            BasicRun();
     345             :     bool            BasicStepOver();
     346             :     bool            BasicStepInto();
     347             :     bool            BasicStepOut();
     348             :     void            BasicStop();
     349             :     bool            BasicToggleBreakPoint();
     350             :     void            BasicToggleBreakPointEnabled();
     351             :     void            ManageBreakPoints();
     352             :     void            UpdateBreakPoint( const BreakPoint& rBrk );
     353             :     void            BasicAddWatch();
     354             :     void            BasicRemoveWatch();
     355             : 
     356             :     long            BasicErrorHdl( StarBASIC* pBasic );
     357             :     long            BasicBreakHdl( StarBASIC* pBasic );
     358             :     void            AssertValidEditEngine();
     359             : 
     360             :     bool            LoadBasic();
     361             :     bool            SaveBasicSource();
     362             :     bool            ImportDialog();
     363             : 
     364             :     void            EditMacro( const String& rMacroName );
     365             : 
     366             :     bool            ToggleBreakPoint( sal_uLong nLine );
     367             : 
     368           0 :     BasicStatus&    GetBasicStatus() { return aStatus; }
     369             : 
     370             :     virtual bool    IsModified ();
     371             :     virtual bool    IsPasteAllowed ();
     372             : 
     373             :     void            FrameWindowMoved();
     374             :     void            ShowCursor( bool bOn );
     375             : 
     376             :     virtual sal_uInt16  GetSearchOptions();
     377             :     virtual sal_uInt16  StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false);
     378             : 
     379           0 :     EditorWindow&       GetEditorWindow()       { return aXEditorWindow.GetEdtWindow(); }
     380           0 :     BreakPointWindow&   GetBreakPointWindow()   { return aXEditorWindow.GetBrkWindow(); }
     381           0 :     LineNumberWindow&   GetLineNumberWindow()   { return aXEditorWindow.GetLineNumberWindow(); }
     382           0 :     ScrollBar&          GetEditVScrollBar()     { return aXEditorWindow.GetEWVScrollBar(); }
     383           0 :     ExtTextEngine*      GetEditEngine()         { return GetEditorWindow().GetEditEngine(); }
     384           0 :     ExtTextView*        GetEditView()           { return GetEditorWindow().GetEditView(); }
     385           0 :     BreakPointList&     GetBreakPoints()        { return GetBreakPointWindow().GetBreakPoints(); }
     386           0 :     ModulWindowLayout&  GetLayout ()            { return rLayout; }
     387             : 
     388             :     virtual void        BasicStarted();
     389             :     virtual void        BasicStopped();
     390             : 
     391             :     virtual ::svl::IUndoManager*
     392             :                         GetUndoManager();
     393             : 
     394           0 :     const OUString&         GetModule() const { return m_aModule; }
     395           0 :     void                    SetModule( const OUString& aModule ) { m_aModule = aModule; }
     396             : 
     397             :     virtual void Activating ();
     398             :     virtual void Deactivating ();
     399             : 
     400             :     virtual void OnNewDocument ();
     401             :     virtual char const* GetHid () const;
     402             :     virtual ItemType GetType () const;
     403             :     virtual bool HasActiveEditor () const;
     404             : 
     405             :     void UpdateModule ();
     406             : };
     407             : 
     408           0 : class ModulWindowLayout: public Layout
     409             : {
     410             : public:
     411             :     ModulWindowLayout (Window* pParent, ObjectCatalog&);
     412             : public:
     413             :     // Layout:
     414             :     virtual void Activating (BaseWindow&);
     415             :     virtual void Deactivating ();
     416             :     virtual void GetState (SfxItemSet&, unsigned nWhich);
     417             :     virtual void UpdateDebug (bool bBasicStopped);
     418             : public:
     419             :     void BasicAddWatch (String const&);
     420             :     void BasicRemoveWatch ();
     421           0 :     Color GetSyntaxColor (TokenTypes eType) const { return aSyntaxColors.GetColor(eType); }
     422             : 
     423             : protected:
     424             :     // Window:
     425             :     virtual void Paint (const Rectangle& rRect);
     426             :     // Layout:
     427             :     virtual void OnFirstSize (long nWidth, long nHeight);
     428             : 
     429             : private:
     430             :     // main child window
     431             :     ModulWindow* pChild;
     432             :     // dockable windows
     433             :     WatchWindow aWatchWindow;
     434             :     StackWindow aStackWindow;
     435             :     ObjectCatalog& rObjectCatalog;
     436             : private:
     437             :     virtual void DataChanged (DataChangedEvent const& rDCEvt);
     438             : private:
     439             :     // SyntaxColors -- stores Basic syntax highlighting colors
     440             :     class SyntaxColors : public utl::ConfigurationListener
     441             :     {
     442             :     public:
     443             :         SyntaxColors ();
     444             :         ~SyntaxColors ();
     445             :     public:
     446           0 :         void SetActiveEditor (EditorWindow* pEditor_) { pEditor = pEditor_; }
     447             :         void SettingsChanged ();
     448             :     public:
     449           0 :         Color GetColor (TokenTypes eType) const { return aColors[eType]; }
     450             : 
     451             :     private:
     452             :         virtual void ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32);
     453             :         void NewConfig (bool bFirst);
     454             : 
     455             :     private:
     456             :         // the color values (the indexes are TokenTypes, see svtools/syntaxhighlight.hxx)
     457             :         Color aColors[TT_KEYWORDS + 1];
     458             :         // the configuration
     459             :         svtools::ColorConfig aConfig;
     460             :         // the active editor
     461             :         EditorWindow* pEditor;
     462             : 
     463             :     } aSyntaxColors;
     464             : };
     465             : 
     466             : } // namespace basctl
     467             : 
     468             : #endif // BASCTL_BASIDE2_HXX
     469             : 
     470             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10