xref: /trunk/main/basctl/source/inc/basidesh.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 #ifndef _BASIDESH_HXX
28 #define _BASIDESH_HXX
29 
30 #include "sbxitem.hxx"
31 
32 #include "scriptdocument.hxx"
33 #include "doceventnotifier.hxx"
34 #include <sfx2/viewfac.hxx>
35 #include <sfx2/shell.hxx>
36 #ifndef _SCRBAR_HXX //autogen
37 #include <vcl/scrbar.hxx>
38 #endif
39 #ifndef _TABLE_HXX //autogen
40 #include <tools/table.hxx>
41 #endif
42 #include <sfx2/viewsh.hxx>
43 #include <svx/ifaceids.hxx>
44 
45 #ifndef _COM_SUN_STAR_IO_XINPUTSTREAMPROVIDER_HXX_
46 #include <com/sun/star/io/XInputStreamProvider.hpp>
47 #endif
48 
49 #include <com/sun/star/container/XContainerListener.hpp>
50 
51 //----------------------------------------------------------------------------
52 
53 const sal_uLong BASICIDE_UI_FEATURE_SHOW_BROWSER = 0x00000001;
54 
55 //----------------------------------------------------------------------------
56 
57 class ModulWindow;
58 class ModulWindowLayout;
59 class DialogWindow;
60 class SdrView;
61 class ObjectCatalog;
62 class BasicIDETabBar;
63 class TabBar;
64 class IDEBaseWindow;
65 class SbxObject;
66 class SbModule;
67 class StarBASIC;
68 class LocalizationMgr;
69 struct BasicIDEShell_Impl;
70 
71 #if _SOLAR__PRIVATE
72 DECLARE_TABLE( IDEWindowTable, IDEBaseWindow* )
73 #else
74 typedef Table IDEWindowTable;
75 #endif
76 
77 namespace BasicIDE
78 {
79     bool RemoveDialog( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName );
80 }
81 
82 class BasicIDEShell :public SfxViewShell
83                     ,public ::basctl::DocumentEventListener
84 {
85 friend class JavaDebuggingListenerImpl;
86 friend class LocalizationMgr;
87 friend sal_Bool implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocument& rDocument, const String& aLibName );
88 friend bool BasicIDE::RemoveDialog( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName );
89 
90     ObjectCatalog*      pObjectCatalog;
91 
92     IDEWindowTable      aIDEWindowTable;
93     sal_uInt16              nCurKey;
94     IDEBaseWindow*      pCurWin;
95     ScriptDocument      m_aCurDocument;
96     String              m_aCurLibName;
97     LocalizationMgr*    m_pCurLocalizationMgr;
98 
99     ScrollBar           aHScrollBar;
100     ScrollBar           aVScrollBar;
101     ScrollBarBox        aScrollBarBox;
102     BasicIDETabBar*     pTabBar;
103     sal_Bool                bTabBarSplitted;
104     sal_Bool                bCreatingWindow;
105     ModulWindowLayout*  pModulLayout;
106     sal_Bool                m_bAppBasicModified;
107     ::basctl::DocumentEventNotifier
108                         m_aNotifier;
109 friend class ContainerListenerImpl;
110     ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xLibListener;
111 
112 #if _SOLAR__PRIVATE
113     void                Init();
114     void                InitTabBar();
115     void                InitScrollBars();
116     void                CheckWindows();
117     void                RemoveWindows( const ScriptDocument& rDocument, const String& rLibName, sal_Bool bDestroy );
118     void                UpdateWindows();
119     void                ShowObjectDialog( sal_Bool bShow, sal_Bool bCreateOrDestroy );
120     void                InvalidateBasicIDESlots();
121     void                StoreAllWindowData( sal_Bool bPersistent = sal_True );
122     void                SetMDITitle();
123     void                EnableScrollbars( sal_Bool bEnable );
124     void                SetCurLib( const ScriptDocument& rDocument, String aLibName, bool bUpdateWindows = true , bool bCheck = true );
125     void                SetCurLibForLocalization( const ScriptDocument& rDocument, String aLibName );
126 
127     void                ImplStartListening( StarBASIC* pBasic );
128 
129     DECL_LINK( TabBarHdl, TabBar* );
130     DECL_LINK( AccelSelectHdl, Accelerator* );
131     DECL_LINK( ObjectDialogCancelHdl, ObjectCatalog * );
132     DECL_LINK( TabBarSplitHdl, TabBar * );
133 #endif
134 
135 protected:
136     virtual void        AdjustPosSizePixel( const Point &rPos, const Size &rSize );
137     virtual void        OuterResizePixel( const Point &rPos, const Size &rSize );
138     virtual Size        GetOptimalSizePixel() const;
139     sal_uInt16              InsertWindowInTable( IDEBaseWindow* pNewWin );
140     virtual sal_uInt16      PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing );
141 
142     void                SetCurWindow( IDEBaseWindow* pNewWin, sal_Bool bUpdateTabBar = sal_False, sal_Bool bRememberAsCurrent = sal_True );
143     void                ManageToolbars();
144     void                RemoveWindow( IDEBaseWindow* pWindow, sal_Bool bDestroy, sal_Bool bAllowChangeCurWindow = sal_True );
145     void                ArrangeTabBar();
146 
147     ModulWindow*        CreateBasWin( const ScriptDocument& rDocument, const String& rLibName, const String& rModName );
148     DialogWindow*       CreateDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName );
149 
150     ModulWindow*        FindBasWin( const ScriptDocument& rDocument, const String& rLibName, const String& rModName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended = sal_False );
151     ModulWindow*        ShowActiveModuleWindow( StarBASIC* pBasic );
152 
153     virtual void        SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
154                                 const SfxHint& rHint, const TypeId& rHintType );
155 
156     virtual void        Activate(sal_Bool bMDI);
157     virtual void        Deactivate(sal_Bool bMDI);
158 
159     virtual void        Move();
160     virtual void        ShowCursor( FASTBOOL bOn = sal_True );
161 
162     void                CreateModulWindowLayout();
163     void                DestroyModulWindowLayout();
164     void                UpdateModulWindowLayout( bool bBasicStopped );
165 
166     // DocumentEventListener
167     virtual void onDocumentCreated( const ScriptDocument& _rDocument );
168     virtual void onDocumentOpened( const ScriptDocument& _rDocument );
169     virtual void onDocumentSave( const ScriptDocument& _rDocument );
170     virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
171     virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
172     virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
173     virtual void onDocumentClosed( const ScriptDocument& _rDocument );
174     virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
175     virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
176 
177 public:
178                         TYPEINFO();
179                         SFX_DECL_INTERFACE( SVX_INTERFACE_BASIDE_VIEWSH )
180                         SFX_DECL_VIEWFACTORY(BasicIDEShell);
181 
182                         BasicIDEShell( SfxViewFrame *pFrame, SfxViewShell *pOldSh );
183                         ~BasicIDEShell();
184 
185     IDEBaseWindow*      GetCurWindow() const    { return pCurWin; }
186     const ScriptDocument&
187                         GetCurDocument() const { return m_aCurDocument; }
188     const String&       GetCurLibName() const { return m_aCurLibName; }
189     ObjectCatalog*      GetObjectCatalog() const    { return pObjectCatalog; }
190     LocalizationMgr*    GetCurLocalizationMgr() const { return m_pCurLocalizationMgr; }
191 
192     ScrollBar&          GetHScrollBar()         { return aHScrollBar; }
193     ScrollBar&          GetVScrollBar()         { return aVScrollBar; }
194     ScrollBarBox&       GetScrollBarBox()       { return aScrollBarBox; }
195     TabBar*             GetTabBar()             { return (TabBar*)pTabBar; }
196     IDEWindowTable&     GetIDEWindowTable()     { return aIDEWindowTable; }
197 
198     SdrView*            GetCurDlgView() const;
199 
200     ::svl::IUndoManager*
201                         GetUndoManager();
202 
203     virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
204 
205     // virtual sal_uInt16           Print( SfxProgress &rProgress, sal_Bool bIsAPI, PrintDialog *pPrintDialog = 0 );
206     virtual SfxPrinter*     GetPrinter( sal_Bool bCreate );
207     virtual sal_uInt16          SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
208     virtual String          GetSelectionText( sal_Bool bCompleteWords );
209     virtual sal_Bool            HasSelection( sal_Bool bText ) const;
210 
211     void                GetState( SfxItemSet& );
212     void                ExecuteGlobal( SfxRequest& rReq );
213     void                ExecuteCurrent( SfxRequest& rReq );
214     void                ExecuteBasic( SfxRequest& rReq );
215     void                ExecuteDialog( SfxRequest& rReq );
216 
217     virtual sal_Bool    HasUIFeature( sal_uInt32 nFeature );
218 
219     long                CallBasicErrorHdl( StarBASIC* pBasic );
220     long                CallBasicBreakHdl( StarBASIC* pBasic );
221 
222     ModulWindowLayout*  GetLayoutWindow() const { return pModulLayout; }
223 
224     IDEBaseWindow*      FindWindow( const ScriptDocument& rDocument, const String& rLibName = String(), const String& rName = String(), sal_uInt16 nType = BASICIDE_TYPE_UNKNOWN, sal_Bool bFindSuspended = sal_False );
225     DialogWindow*       FindDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended = sal_False );
226     IDEBaseWindow*      FindApplicationWindow();
227     sal_Bool                NextPage( sal_Bool bPrev = sal_False );
228 
229     sal_Bool                IsAppBasicModified() const { return m_bAppBasicModified; }
230     void                SetAppBasicModified( sal_Bool bModified = sal_True ) { m_bAppBasicModified = bModified; }
231 
232     // For Dialog Drag&Drop in Dialog Organizer
233     static void CopyDialogResources(
234         ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >& io_xISP,
235         const ScriptDocument& rSourceDoc, const String& rSourceLibName, const ScriptDocument& rDestDoc,
236         const String& rDestLibName, const String& rDlgName );
237 
238     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
239                         GetCurrentDocument() const;
240 
241 };
242 
243 #endif // _BASIDESH_HXX
244