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