131598a22SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
331598a22SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
431598a22SAndrew Rist * or more contributor license agreements. See the NOTICE file
531598a22SAndrew Rist * distributed with this work for additional information
631598a22SAndrew Rist * regarding copyright ownership. The ASF licenses this file
731598a22SAndrew Rist * to you under the Apache License, Version 2.0 (the
831598a22SAndrew Rist * "License"); you may not use this file except in compliance
931598a22SAndrew Rist * with the License. You may obtain a copy of the License at
1031598a22SAndrew Rist *
1131598a22SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1231598a22SAndrew Rist *
1331598a22SAndrew Rist * Unless required by applicable law or agreed to in writing,
1431598a22SAndrew Rist * software distributed under the License is distributed on an
1531598a22SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1631598a22SAndrew Rist * KIND, either express or implied. See the License for the
1731598a22SAndrew Rist * specific language governing permissions and limitations
1831598a22SAndrew Rist * under the License.
1931598a22SAndrew Rist *
2031598a22SAndrew Rist *************************************************************/
2131598a22SAndrew Rist
2231598a22SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_basctl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // CLOOKS:
28cdf0e10cSrcweir //#define _MENUBTN_HXX
29cdf0e10cSrcweir #define _SPIN_HXX
30cdf0e10cSrcweir #define _PRVWIN_HXX
31cdf0e10cSrcweir //#define _FIELD_HXX ***
32cdf0e10cSrcweir //#define _TAB_HXX ***
33cdf0e10cSrcweir #define _DIALOGS_HXX
34cdf0e10cSrcweir #define _SVRTF_HXX
35cdf0e10cSrcweir #define _ISETBRW_HXX
36cdf0e10cSrcweir #define _VCTRLS_HXX
37cdf0e10cSrcweir #define SI_NOCONTROL
38cdf0e10cSrcweir #define SI_NOSBXCONTROLS
39cdf0e10cSrcweir
40cdf0e10cSrcweir #define ITEMID_SIZE 0
41cdf0e10cSrcweir
42cdf0e10cSrcweir // Falls ohne PCH's:
43cdf0e10cSrcweir #include <ide_pch.hxx>
44cdf0e10cSrcweir
45cdf0e10cSrcweir
46cdf0e10cSrcweir #define _SOLAR__PRIVATE 1
47cdf0e10cSrcweir #include <basic/sbx.hxx>
48cdf0e10cSrcweir #include <svl/hint.hxx>
49cdf0e10cSrcweir #include <tools/diagnose_ex.h>
50cdf0e10cSrcweir #include <basidesh.hrc>
51cdf0e10cSrcweir #include <basidesh.hxx>
52cdf0e10cSrcweir #include <basdoc.hxx>
53cdf0e10cSrcweir #include <basobj.hxx>
54cdf0e10cSrcweir #include <bastypes.hxx>
55cdf0e10cSrcweir #include <basicbox.hxx>
56cdf0e10cSrcweir #include <objdlg.hxx>
57cdf0e10cSrcweir #include <sbxitem.hxx>
58cdf0e10cSrcweir #include <tbxctl.hxx>
59cdf0e10cSrcweir #include <iderdll2.hxx>
60cdf0e10cSrcweir #include <basidectrlr.hxx>
61cdf0e10cSrcweir #include <localizationmgr.hxx>
62cdf0e10cSrcweir
63cdf0e10cSrcweir #define BasicIDEShell
64cdf0e10cSrcweir #define SFX_TYPEMAP
65cdf0e10cSrcweir #include <idetemp.hxx>
66cdf0e10cSrcweir #include <basslots.hxx>
67cdf0e10cSrcweir #include <iderdll.hxx>
68cdf0e10cSrcweir #include <svx/pszctrl.hxx>
69cdf0e10cSrcweir #include <svx/insctrl.hxx>
70cdf0e10cSrcweir #include <svx/srchdlg.hxx>
71cdf0e10cSrcweir #include <svx/lboxctrl.hxx>
72cdf0e10cSrcweir #include <svx/tbcontrl.hxx>
73cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer.hpp>
74cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainerPassword.hpp>
75cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
76cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
77cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp>
78cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer.hpp>
79cdf0e10cSrcweir
80cdf0e10cSrcweir #include <svx/xmlsecctrl.hxx>
81cdf0e10cSrcweir
82cdf0e10cSrcweir using namespace ::com::sun::star::uno;
83cdf0e10cSrcweir using namespace ::com::sun::star;
84cdf0e10cSrcweir using ::rtl::OUString;
85cdf0e10cSrcweir
86cdf0e10cSrcweir static const rtl::OUString sStandardLibName( rtl::OUString::createFromAscii("Standard") );
87cdf0e10cSrcweir
88cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1< container::XContainerListener > ContainerListenerBASE;
89cdf0e10cSrcweir
90cdf0e10cSrcweir class ContainerListenerImpl : public ContainerListenerBASE
91cdf0e10cSrcweir {
92cdf0e10cSrcweir BasicIDEShell* mpShell;
93cdf0e10cSrcweir public:
94cdf0e10cSrcweir
ContainerListenerImpl(BasicIDEShell * pShell)95cdf0e10cSrcweir ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {}
96cdf0e10cSrcweir
~ContainerListenerImpl()97cdf0e10cSrcweir ~ContainerListenerImpl()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
addContainerListener(const ScriptDocument & rScriptDocument,const String & aLibName)101cdf0e10cSrcweir void addContainerListener( const ScriptDocument& rScriptDocument, const String& aLibName )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir try
104cdf0e10cSrcweir {
105cdf0e10cSrcweir uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, sal_False ), uno::UNO_QUERY );
106cdf0e10cSrcweir if ( xContainer.is() )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir uno::Reference< container::XContainerListener > xContainerListener( this );
109cdf0e10cSrcweir xContainer->addContainerListener( xContainerListener );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir }
112cdf0e10cSrcweir catch( uno::Exception& ) {}
113cdf0e10cSrcweir }
removeContainerListener(const ScriptDocument & rScriptDocument,const String & aLibName)114cdf0e10cSrcweir void removeContainerListener( const ScriptDocument& rScriptDocument, const String& aLibName )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir try
117cdf0e10cSrcweir {
118cdf0e10cSrcweir uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, sal_False ), uno::UNO_QUERY );
119cdf0e10cSrcweir if ( xContainer.is() )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir uno::Reference< container::XContainerListener > xContainerListener( this );
122cdf0e10cSrcweir xContainer->removeContainerListener( xContainerListener );
123cdf0e10cSrcweir }
124cdf0e10cSrcweir }
125cdf0e10cSrcweir catch( uno::Exception& ) {}
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir // XEventListener
disposing(const lang::EventObject &)129cdf0e10cSrcweir virtual void SAL_CALL disposing( const lang::EventObject& ) throw( uno::RuntimeException ) {}
130cdf0e10cSrcweir
131cdf0e10cSrcweir // XContainerListener
elementInserted(const container::ContainerEvent & Event)132cdf0e10cSrcweir virtual void SAL_CALL elementInserted( const container::ContainerEvent& Event ) throw( uno::RuntimeException )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir rtl::OUString sModuleName;
135cdf0e10cSrcweir if( mpShell && ( Event.Accessor >>= sModuleName ) )
136cdf0e10cSrcweir mpShell->FindBasWin( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, sal_True, sal_False );
137cdf0e10cSrcweir }
elementReplaced(const container::ContainerEvent &)138cdf0e10cSrcweir virtual void SAL_CALL elementReplaced( const container::ContainerEvent& ) throw( com::sun::star::uno::RuntimeException ) { }
elementRemoved(const container::ContainerEvent & Event)139cdf0e10cSrcweir virtual void SAL_CALL elementRemoved( const container::ContainerEvent& Event ) throw( com::sun::star::uno::RuntimeException )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir rtl::OUString sModuleName;
142cdf0e10cSrcweir if( mpShell && ( Event.Accessor >>= sModuleName ) )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, BASICIDE_TYPE_MODULE, sal_True );
145cdf0e10cSrcweir if( pWin )
146cdf0e10cSrcweir mpShell->RemoveWindow( pWin, sal_True, sal_True );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
150cdf0e10cSrcweir };
151cdf0e10cSrcweir
152cdf0e10cSrcweir TYPEINIT1( BasicIDEShell, SfxViewShell );
153cdf0e10cSrcweir
154cdf0e10cSrcweir SFX_IMPL_NAMED_VIEWFACTORY( BasicIDEShell, "Default" )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir SFX_VIEW_REGISTRATION( BasicDocShell );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
159cdf0e10cSrcweir
SFX_IMPL_INTERFACE(BasicIDEShell,SfxViewShell,IDEResId (RID_STR_IDENAME))160cdf0e10cSrcweir SFX_IMPL_INTERFACE( BasicIDEShell, SfxViewShell, IDEResId( RID_STR_IDENAME ) )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION( SID_SEARCH_DLG );
163cdf0e10cSrcweir SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_SHOW_PROPERTYBROWSER, BASICIDE_UI_FEATURE_SHOW_BROWSER);
164cdf0e10cSrcweir SFX_POPUPMENU_REGISTRATION( IDEResId( RID_POPUP_DLGED ) );
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir
168cdf0e10cSrcweir
169cdf0e10cSrcweir #define IDE_VIEWSHELL_FLAGS SFX_VIEW_CAN_PRINT|SFX_VIEW_NO_NEWWINDOW
170cdf0e10cSrcweir
171cdf0e10cSrcweir
172cdf0e10cSrcweir // Hack for #101048
173cdf0e10cSrcweir static sal_Int32 GnBasicIDEShellCount;
getBasicIDEShellCount(void)174cdf0e10cSrcweir sal_Int32 getBasicIDEShellCount( void )
175cdf0e10cSrcweir { return GnBasicIDEShellCount; }
176cdf0e10cSrcweir
BasicIDEShell(SfxViewFrame * pFrame_,SfxViewShell *)177cdf0e10cSrcweir BasicIDEShell::BasicIDEShell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) :
178cdf0e10cSrcweir SfxViewShell( pFrame_, IDE_VIEWSHELL_FLAGS ),
179cdf0e10cSrcweir m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ),
180cdf0e10cSrcweir aHScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG ) ),
181cdf0e10cSrcweir aVScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG ) ),
182cdf0e10cSrcweir aScrollBarBox( &GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE ) ),
183cdf0e10cSrcweir m_bAppBasicModified( sal_False ),
184cdf0e10cSrcweir m_aNotifier( *this )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir m_xLibListener = new ContainerListenerImpl( this );
187cdf0e10cSrcweir Init();
188cdf0e10cSrcweir GnBasicIDEShellCount++;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir
192cdf0e10cSrcweir
Init()193cdf0e10cSrcweir void BasicIDEShell::Init()
194cdf0e10cSrcweir {
195cdf0e10cSrcweir TbxControls::RegisterControl( SID_CHOOSE_CONTROLS );
196cdf0e10cSrcweir SvxPosSizeStatusBarControl::RegisterControl();
197cdf0e10cSrcweir SvxInsertStatusBarControl::RegisterControl();
198cdf0e10cSrcweir XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE );
199cdf0e10cSrcweir SvxSimpleUndoRedoController::RegisterControl( SID_UNDO );
200cdf0e10cSrcweir SvxSimpleUndoRedoController::RegisterControl( SID_REDO );
201cdf0e10cSrcweir
202cdf0e10cSrcweir SvxSearchDialogWrapper::RegisterChildWindow( sal_False );
203cdf0e10cSrcweir
204cdf0e10cSrcweir IDE_DLL()->GetExtraData()->ShellInCriticalSection() = sal_True;
205cdf0e10cSrcweir
206cdf0e10cSrcweir SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BasicIDE" ) ) );
207cdf0e10cSrcweir SetHelpId( SVX_INTERFACE_BASIDE_VIEWSH );
208cdf0e10cSrcweir
209cdf0e10cSrcweir LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
210cdf0e10cSrcweir LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );
211cdf0e10cSrcweir
212cdf0e10cSrcweir CreateModulWindowLayout();
213cdf0e10cSrcweir
214cdf0e10cSrcweir GetViewFrame()->GetWindow().SetBackground();
215cdf0e10cSrcweir
216cdf0e10cSrcweir pCurWin = 0;
217cdf0e10cSrcweir m_aCurDocument = ScriptDocument::getApplicationScriptDocument();
218cdf0e10cSrcweir pObjectCatalog = 0;
219cdf0e10cSrcweir bCreatingWindow = sal_False;
220cdf0e10cSrcweir
221cdf0e10cSrcweir m_pCurLocalizationMgr = NULL;
222cdf0e10cSrcweir
223cdf0e10cSrcweir pTabBar = new BasicIDETabBar( &GetViewFrame()->GetWindow() );
224cdf0e10cSrcweir pTabBar->SetSplitHdl( LINK( this, BasicIDEShell, TabBarSplitHdl ) );
225cdf0e10cSrcweir bTabBarSplitted = sal_False;
226cdf0e10cSrcweir
227cdf0e10cSrcweir nCurKey = 100;
228cdf0e10cSrcweir InitScrollBars();
229cdf0e10cSrcweir InitTabBar();
230cdf0e10cSrcweir
231cdf0e10cSrcweir SetCurLib( ScriptDocument::getApplicationScriptDocument(), String::CreateFromAscii( "Standard" ), false, false );
232cdf0e10cSrcweir
233cdf0e10cSrcweir if ( IDE_DLL() && IDE_DLL()->pShell == NULL )
234cdf0e10cSrcweir IDE_DLL()->pShell = this;
235cdf0e10cSrcweir
236cdf0e10cSrcweir IDE_DLL()->GetExtraData()->ShellInCriticalSection() = sal_False;
237cdf0e10cSrcweir
238cdf0e10cSrcweir // It's enough to create the controller ...
239cdf0e10cSrcweir // It will be public by using magic :-)
240cdf0e10cSrcweir new BasicIDEController( this );
241cdf0e10cSrcweir
242cdf0e10cSrcweir // Force updating the title ! Because it must be set to the controller
243cdf0e10cSrcweir // it has to be called directly after creating those controller.
244cdf0e10cSrcweir SetMDITitle ();
245cdf0e10cSrcweir
246cdf0e10cSrcweir UpdateWindows();
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
~BasicIDEShell()249cdf0e10cSrcweir __EXPORT BasicIDEShell::~BasicIDEShell()
250cdf0e10cSrcweir {
251cdf0e10cSrcweir m_aNotifier.dispose();
252cdf0e10cSrcweir
253cdf0e10cSrcweir if ( IDE_DLL() && IDE_DLL()->pShell == this )
254cdf0e10cSrcweir IDE_DLL()->pShell = NULL;
255cdf0e10cSrcweir
256cdf0e10cSrcweir // Damit bei einem Basic-Fehler beim Speichern die Shell nicht sofort
257cdf0e10cSrcweir // wieder hoch kommt:
258cdf0e10cSrcweir IDE_DLL()->GetExtraData()->ShellInCriticalSection() = sal_True;
259cdf0e10cSrcweir
260cdf0e10cSrcweir SetWindow( 0 );
261cdf0e10cSrcweir SetCurWindow( 0 );
262cdf0e10cSrcweir
263cdf0e10cSrcweir // Alle Fenster zerstoeren:
264cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.First();
265cdf0e10cSrcweir while ( pWin )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir // Kein Store, passiert bereits, wenn die BasicManager zerstoert werden.
268cdf0e10cSrcweir delete pWin;
269cdf0e10cSrcweir pWin = aIDEWindowTable.Next();
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
272cdf0e10cSrcweir aIDEWindowTable.Clear();
273cdf0e10cSrcweir delete pTabBar;
274cdf0e10cSrcweir delete pObjectCatalog;
275cdf0e10cSrcweir DestroyModulWindowLayout();
276cdf0e10cSrcweir
277cdf0e10cSrcweir ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
278cdf0e10cSrcweir // Destroy all ContainerListeners for Basic Container.
279cdf0e10cSrcweir if ( pListener )
280cdf0e10cSrcweir pListener->removeContainerListener( m_aCurDocument, m_aCurLibName );
281cdf0e10cSrcweir
282cdf0e10cSrcweir // MI: Das gab einen GPF im SDT beim Schliessen da dann der ViewFrame die
283cdf0e10cSrcweir // ObjSh loslaesst. Es wusste auch keiner mehr wozu das gut war.
284cdf0e10cSrcweir // GetViewFrame()->GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
285cdf0e10cSrcweir
286cdf0e10cSrcweir IDE_DLL()->GetExtraData()->ShellInCriticalSection() = sal_False;
287cdf0e10cSrcweir
288cdf0e10cSrcweir GnBasicIDEShellCount--;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
onDocumentCreated(const ScriptDocument &)291cdf0e10cSrcweir void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir UpdateWindows();
294cdf0e10cSrcweir }
295cdf0e10cSrcweir
onDocumentOpened(const ScriptDocument &)296cdf0e10cSrcweir void BasicIDEShell::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir UpdateWindows();
299cdf0e10cSrcweir }
300cdf0e10cSrcweir
onDocumentSave(const ScriptDocument &)301cdf0e10cSrcweir void BasicIDEShell::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir StoreAllWindowData();
304cdf0e10cSrcweir }
305cdf0e10cSrcweir
onDocumentSaveDone(const ScriptDocument &)306cdf0e10cSrcweir void BasicIDEShell::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir // #i115671: Update SID_SAVEDOC after saving is completed
309cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
310cdf0e10cSrcweir if ( pBindings )
311cdf0e10cSrcweir pBindings->Invalidate( SID_SAVEDOC );
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
onDocumentSaveAs(const ScriptDocument &)314cdf0e10cSrcweir void BasicIDEShell::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
315cdf0e10cSrcweir {
316cdf0e10cSrcweir StoreAllWindowData();
317cdf0e10cSrcweir }
318cdf0e10cSrcweir
onDocumentSaveAsDone(const ScriptDocument &)319cdf0e10cSrcweir void BasicIDEShell::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir // not interested in
322cdf0e10cSrcweir }
323cdf0e10cSrcweir
onDocumentClosed(const ScriptDocument & _rDocument)324cdf0e10cSrcweir void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir if ( !_rDocument.isValid() )
327cdf0e10cSrcweir return;
328cdf0e10cSrcweir
329cdf0e10cSrcweir bool bSetCurWindow = false;
330cdf0e10cSrcweir bool bSetCurLib = ( _rDocument == m_aCurDocument );
331cdf0e10cSrcweir
332cdf0e10cSrcweir // remove all windows which belong to this document
333cdf0e10cSrcweir for ( sal_uLong nWin = aIDEWindowTable.Count(); nWin; )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.GetObject( --nWin );
336cdf0e10cSrcweir if ( pWin->IsDocument( _rDocument ) )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir if ( pWin->GetStatus() & (BASWIN_RUNNINGBASIC|BASWIN_INRESCHEDULE) )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir pWin->AddStatus( BASWIN_TOBEKILLED );
341cdf0e10cSrcweir pWin->Hide();
342cdf0e10cSrcweir StarBASIC::Stop();
343cdf0e10cSrcweir // there's no notify
344cdf0e10cSrcweir pWin->BasicStopped();
345cdf0e10cSrcweir }
346cdf0e10cSrcweir else
347cdf0e10cSrcweir {
348cdf0e10cSrcweir pWin->StoreData();
349cdf0e10cSrcweir if ( pWin == pCurWin )
350cdf0e10cSrcweir bSetCurWindow = true;
351cdf0e10cSrcweir RemoveWindow( pWin, sal_True, sal_False );
352cdf0e10cSrcweir }
353cdf0e10cSrcweir }
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
356cdf0e10cSrcweir // remove lib info
357cdf0e10cSrcweir BasicIDEData* pData = IDE_DLL()->GetExtraData();
358cdf0e10cSrcweir if ( pData )
359cdf0e10cSrcweir pData->GetLibInfos().RemoveInfoFor( _rDocument );
360cdf0e10cSrcweir
361cdf0e10cSrcweir if ( bSetCurLib )
362cdf0e10cSrcweir SetCurLib( ScriptDocument::getApplicationScriptDocument(), String::CreateFromAscii( "Standard" ), true, false );
363cdf0e10cSrcweir else if ( bSetCurWindow )
364cdf0e10cSrcweir SetCurWindow( FindApplicationWindow(), sal_True );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir
onDocumentTitleChanged(const ScriptDocument &)367cdf0e10cSrcweir void BasicIDEShell::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
370cdf0e10cSrcweir if ( pBindings )
371cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR, sal_True, sal_False );
372cdf0e10cSrcweir SetMDITitle();
373cdf0e10cSrcweir }
374cdf0e10cSrcweir
onDocumentModeChanged(const ScriptDocument & _rDocument)375cdf0e10cSrcweir void BasicIDEShell::onDocumentModeChanged( const ScriptDocument& _rDocument )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir for ( sal_uLong nWin = aIDEWindowTable.Count(); nWin; )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.GetObject( --nWin );
380cdf0e10cSrcweir if ( pWin->IsDocument( _rDocument ) && _rDocument.isDocument() )
381cdf0e10cSrcweir pWin->SetReadOnly( _rDocument.isReadOnly() );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
StoreAllWindowData(sal_Bool bPersistent)385cdf0e10cSrcweir void BasicIDEShell::StoreAllWindowData( sal_Bool bPersistent )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
390cdf0e10cSrcweir DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" );
391cdf0e10cSrcweir if ( !pWin->IsSuspended() )
392cdf0e10cSrcweir pWin->StoreData();
393cdf0e10cSrcweir }
394cdf0e10cSrcweir
395cdf0e10cSrcweir if ( bPersistent )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir SFX_APP()->SaveBasicAndDialogContainer();
398cdf0e10cSrcweir SetAppBasicModified( sal_False );
399cdf0e10cSrcweir
400cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
401cdf0e10cSrcweir if ( pBindings )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir pBindings->Invalidate( SID_SAVEDOC );
404cdf0e10cSrcweir pBindings->Update( SID_SAVEDOC );
405cdf0e10cSrcweir }
406cdf0e10cSrcweir }
407cdf0e10cSrcweir }
408cdf0e10cSrcweir
409cdf0e10cSrcweir
PrepareClose(sal_Bool bUI,sal_Bool bForBrowsing)410cdf0e10cSrcweir sal_uInt16 __EXPORT BasicIDEShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir (void)bForBrowsing;
413cdf0e10cSrcweir
414cdf0e10cSrcweir // da es nach Drucken etc. (DocInfo) modifiziert ist, hier resetten
415cdf0e10cSrcweir GetViewFrame()->GetObjectShell()->SetModified(sal_False);
416cdf0e10cSrcweir
417cdf0e10cSrcweir if ( StarBASIC::IsRunning() )
418cdf0e10cSrcweir {
419cdf0e10cSrcweir if( bUI )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir String aErrorStr( IDEResId( RID_STR_CANNOTCLOSE ) );
422cdf0e10cSrcweir Window *pParent = &GetViewFrame()->GetWindow();
423cdf0e10cSrcweir InfoBox( pParent, aErrorStr ).Execute();
424cdf0e10cSrcweir }
425cdf0e10cSrcweir return sal_False;
426cdf0e10cSrcweir }
427cdf0e10cSrcweir else
428cdf0e10cSrcweir {
429cdf0e10cSrcweir // Hier unguenstig, wird zweimal gerufen...
430cdf0e10cSrcweir // StoreAllWindowData();
431cdf0e10cSrcweir
432cdf0e10cSrcweir sal_Bool bCanClose = sal_True;
433cdf0e10cSrcweir for ( sal_uLong nWin = 0; bCanClose && ( nWin < aIDEWindowTable.Count() ); nWin++ )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
436cdf0e10cSrcweir if ( /* !pWin->IsSuspended() && */ !pWin->CanClose() )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir if ( m_aCurLibName.Len() && ( pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) )
439cdf0e10cSrcweir SetCurLib( ScriptDocument::getApplicationScriptDocument(), String(), false );
440cdf0e10cSrcweir SetCurWindow( pWin, sal_True );
441cdf0e10cSrcweir bCanClose = sal_False;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir }
444cdf0e10cSrcweir
445cdf0e10cSrcweir if ( bCanClose )
446cdf0e10cSrcweir StoreAllWindowData( sal_False ); // Nicht auf Platte schreiben, das passiert am Ende automatisch
447cdf0e10cSrcweir
448cdf0e10cSrcweir return bCanClose;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
InitScrollBars()452cdf0e10cSrcweir void BasicIDEShell::InitScrollBars()
453cdf0e10cSrcweir {
454cdf0e10cSrcweir aVScrollBar.SetLineSize( 300 );
455cdf0e10cSrcweir aVScrollBar.SetPageSize( 2000 );
456cdf0e10cSrcweir aHScrollBar.SetLineSize( 300 );
457cdf0e10cSrcweir aHScrollBar.SetPageSize( 2000 );
458cdf0e10cSrcweir aHScrollBar.Enable();
459cdf0e10cSrcweir aVScrollBar.Enable();
460cdf0e10cSrcweir aVScrollBar.Show();
461cdf0e10cSrcweir aHScrollBar.Show();
462cdf0e10cSrcweir aScrollBarBox.Show();
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir
466cdf0e10cSrcweir
InitTabBar()467cdf0e10cSrcweir void BasicIDEShell::InitTabBar()
468cdf0e10cSrcweir {
469cdf0e10cSrcweir pTabBar->Enable();
470cdf0e10cSrcweir pTabBar->Show();
471cdf0e10cSrcweir pTabBar->SetSelectHdl( LINK( this, BasicIDEShell, TabBarHdl ) );
472cdf0e10cSrcweir }
473cdf0e10cSrcweir
474cdf0e10cSrcweir
GetOptimalSizePixel() const475cdf0e10cSrcweir Size __EXPORT BasicIDEShell::GetOptimalSizePixel() const
476cdf0e10cSrcweir {
477cdf0e10cSrcweir return Size( 400, 300 );
478cdf0e10cSrcweir }
479cdf0e10cSrcweir
480cdf0e10cSrcweir
481cdf0e10cSrcweir
OuterResizePixel(const Point & rPos,const Size & rSize)482cdf0e10cSrcweir void __EXPORT BasicIDEShell::OuterResizePixel( const Point &rPos, const Size &rSize )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir // Adjust fliegt irgendwann raus...
485cdf0e10cSrcweir AdjustPosSizePixel( rPos, rSize );
486cdf0e10cSrcweir }
487cdf0e10cSrcweir
488cdf0e10cSrcweir
IMPL_LINK_INLINE_START(BasicIDEShell,TabBarSplitHdl,TabBar *,pTBar)489cdf0e10cSrcweir IMPL_LINK_INLINE_START( BasicIDEShell, TabBarSplitHdl, TabBar *, pTBar )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir (void)pTBar;
492cdf0e10cSrcweir bTabBarSplitted = sal_True;
493cdf0e10cSrcweir ArrangeTabBar();
494cdf0e10cSrcweir
495cdf0e10cSrcweir return 0;
496cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(BasicIDEShell,TabBarSplitHdl,TabBar *,pTBar)497cdf0e10cSrcweir IMPL_LINK_INLINE_END( BasicIDEShell, TabBarSplitHdl, TabBar *, pTBar )
498cdf0e10cSrcweir
499cdf0e10cSrcweir
500cdf0e10cSrcweir
501cdf0e10cSrcweir IMPL_LINK( BasicIDEShell, TabBarHdl, TabBar *, pCurTabBar )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir sal_uInt16 nCurId = pCurTabBar->GetCurPageId();
504cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.Get( nCurId );
505cdf0e10cSrcweir DBG_ASSERT( pWin, "Eintrag in TabBar passt zu keinem Fenster!" );
506cdf0e10cSrcweir SetCurWindow( pWin );
507cdf0e10cSrcweir
508cdf0e10cSrcweir return 0;
509cdf0e10cSrcweir }
510cdf0e10cSrcweir
511cdf0e10cSrcweir
512cdf0e10cSrcweir
NextPage(sal_Bool bPrev)513cdf0e10cSrcweir sal_Bool BasicIDEShell::NextPage( sal_Bool bPrev )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir sal_Bool bRet = sal_False;
516cdf0e10cSrcweir sal_uInt16 nPos = pTabBar->GetPagePos( pTabBar->GetCurPageId() );
517cdf0e10cSrcweir
518cdf0e10cSrcweir if ( bPrev )
519cdf0e10cSrcweir --nPos;
520cdf0e10cSrcweir else
521cdf0e10cSrcweir ++nPos;
522cdf0e10cSrcweir
523cdf0e10cSrcweir if ( nPos < pTabBar->GetPageCount() )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.Get( pTabBar->GetPageId( nPos ) );
526cdf0e10cSrcweir SetCurWindow( pWin, sal_True );
527cdf0e10cSrcweir bRet = sal_True;
528cdf0e10cSrcweir }
529cdf0e10cSrcweir
530cdf0e10cSrcweir return bRet;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir
533cdf0e10cSrcweir
534cdf0e10cSrcweir
ArrangeTabBar()535cdf0e10cSrcweir void BasicIDEShell::ArrangeTabBar()
536cdf0e10cSrcweir {
537cdf0e10cSrcweir Size aSz( GetViewFrame()->GetWindow().GetOutputSizePixel() );
538cdf0e10cSrcweir long nBoxPos = aScrollBarBox.GetPosPixel().X() - 1;
539cdf0e10cSrcweir long nPos = pTabBar->GetSplitSize();
540cdf0e10cSrcweir if ( nPos <= nBoxPos )
541cdf0e10cSrcweir {
542cdf0e10cSrcweir Point aPnt( pTabBar->GetPosPixel() );
543cdf0e10cSrcweir long nH = aHScrollBar.GetSizePixel().Height();
544cdf0e10cSrcweir pTabBar->SetPosSizePixel( aPnt, Size( nPos, nH ) );
545cdf0e10cSrcweir long nScrlStart = aPnt.X() + nPos;
546cdf0e10cSrcweir aHScrollBar.SetPosSizePixel( Point( nScrlStart, aPnt.Y() ), Size( nBoxPos - nScrlStart + 2, nH ) );
547cdf0e10cSrcweir aHScrollBar.Update();
548cdf0e10cSrcweir }
549cdf0e10cSrcweir }
550cdf0e10cSrcweir
551cdf0e10cSrcweir
552cdf0e10cSrcweir
GetUndoManager()553cdf0e10cSrcweir ::svl::IUndoManager* BasicIDEShell::GetUndoManager()
554cdf0e10cSrcweir {
555cdf0e10cSrcweir ::svl::IUndoManager* pMgr = NULL;
556cdf0e10cSrcweir if( pCurWin )
557cdf0e10cSrcweir pMgr = pCurWin->GetUndoManager();
558cdf0e10cSrcweir
559cdf0e10cSrcweir return pMgr;
560cdf0e10cSrcweir }
561cdf0e10cSrcweir
562cdf0e10cSrcweir
563cdf0e10cSrcweir
ShowObjectDialog(sal_Bool bShow,sal_Bool bCreateOrDestroy)564cdf0e10cSrcweir void BasicIDEShell::ShowObjectDialog( sal_Bool bShow, sal_Bool bCreateOrDestroy )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir if ( bShow )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir if ( !pObjectCatalog && bCreateOrDestroy )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir pObjectCatalog = new ObjectCatalog( &GetViewFrame()->GetWindow() );
571cdf0e10cSrcweir // Position wird in BasicIDEData gemerkt und vom Dlg eingestellt
572cdf0e10cSrcweir if ( pObjectCatalog )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir pObjectCatalog->SetCancelHdl( LINK( this, BasicIDEShell, ObjectDialogCancelHdl ) );
575cdf0e10cSrcweir BasicEntryDescriptor aDesc;
576cdf0e10cSrcweir IDEBaseWindow* pCurWin_ = GetCurWindow();
577cdf0e10cSrcweir if ( pCurWin_ )
578cdf0e10cSrcweir aDesc = pCurWin_->CreateEntryDescriptor();
579cdf0e10cSrcweir pObjectCatalog->SetCurrentEntry( aDesc );
580cdf0e10cSrcweir }
581cdf0e10cSrcweir }
582cdf0e10cSrcweir
583cdf0e10cSrcweir // Die allerletzten Aenderungen...
584cdf0e10cSrcweir if ( pCurWin )
585cdf0e10cSrcweir pCurWin->StoreData();
586cdf0e10cSrcweir
587cdf0e10cSrcweir if ( pObjectCatalog )
588cdf0e10cSrcweir {
589cdf0e10cSrcweir pObjectCatalog->UpdateEntries();
590cdf0e10cSrcweir pObjectCatalog->Show();
591cdf0e10cSrcweir }
592cdf0e10cSrcweir }
593cdf0e10cSrcweir else if ( pObjectCatalog )
594cdf0e10cSrcweir {
595cdf0e10cSrcweir pObjectCatalog->Hide();
596cdf0e10cSrcweir if ( bCreateOrDestroy )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir // Wegen OS/2-Focus-Problem pObjectCatalog vorm delete auf NULL
599cdf0e10cSrcweir ObjectCatalog* pTemp = pObjectCatalog;
600cdf0e10cSrcweir pObjectCatalog = 0;
601cdf0e10cSrcweir delete pTemp;
602cdf0e10cSrcweir }
603cdf0e10cSrcweir }
604cdf0e10cSrcweir }
605cdf0e10cSrcweir
606cdf0e10cSrcweir
607cdf0e10cSrcweir
SFX_NOTIFY(SfxBroadcaster & rBC,const TypeId &,const SfxHint & rHint,const TypeId &)608cdf0e10cSrcweir void __EXPORT BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
609cdf0e10cSrcweir const SfxHint& rHint, const TypeId& )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir if ( IDE_DLL()->GetShell() )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir if ( rHint.IsA( TYPE( SfxSimpleHint ) ) )
614cdf0e10cSrcweir {
615cdf0e10cSrcweir switch ( ((SfxSimpleHint&)rHint).GetId() )
616cdf0e10cSrcweir {
617cdf0e10cSrcweir case SFX_HINT_DYING:
618cdf0e10cSrcweir {
619cdf0e10cSrcweir EndListening( rBC, sal_True /* Alle abmelden */ );
620cdf0e10cSrcweir if ( pObjectCatalog )
621cdf0e10cSrcweir pObjectCatalog->UpdateEntries();
622cdf0e10cSrcweir }
623cdf0e10cSrcweir break;
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir if ( rHint.IsA( TYPE( SbxHint ) ) )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir SbxHint& rSbxHint = (SbxHint&)rHint;
629cdf0e10cSrcweir sal_uLong nHintId = rSbxHint.GetId();
630cdf0e10cSrcweir if ( ( nHintId == SBX_HINT_BASICSTART ) ||
631cdf0e10cSrcweir ( nHintId == SBX_HINT_BASICSTOP ) )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
634cdf0e10cSrcweir if ( pBindings )
635cdf0e10cSrcweir {
636cdf0e10cSrcweir pBindings->Invalidate( SID_BASICRUN );
637cdf0e10cSrcweir pBindings->Update( SID_BASICRUN );
638cdf0e10cSrcweir pBindings->Invalidate( SID_BASICCOMPILE );
639cdf0e10cSrcweir pBindings->Update( SID_BASICCOMPILE );
640cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSTEPOVER );
641cdf0e10cSrcweir pBindings->Update( SID_BASICSTEPOVER );
642cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSTEPINTO );
643cdf0e10cSrcweir pBindings->Update( SID_BASICSTEPINTO );
644cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSTEPOUT );
645cdf0e10cSrcweir pBindings->Update( SID_BASICSTEPOUT );
646cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSTOP );
647cdf0e10cSrcweir pBindings->Update( SID_BASICSTOP );
648cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
649cdf0e10cSrcweir pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
650cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
651cdf0e10cSrcweir pBindings->Update( SID_BASICIDE_MANAGEBRKPNTS );
652cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
653cdf0e10cSrcweir pBindings->Update( SID_BASICIDE_MODULEDLG );
654cdf0e10cSrcweir pBindings->Invalidate( SID_BASICLOAD );
655cdf0e10cSrcweir pBindings->Update( SID_BASICLOAD );
656cdf0e10cSrcweir }
657cdf0e10cSrcweir
658cdf0e10cSrcweir if ( nHintId == SBX_HINT_BASICSTOP )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir // Nicht nur bei Error/Break oder explizitem anhalten,
661cdf0e10cSrcweir // falls durch einen Programmierfehler das Update abgeschaltet ist.
662cdf0e10cSrcweir BasicIDE::BasicStopped();
663cdf0e10cSrcweir UpdateModulWindowLayout( true ); // Leer machen...
664cdf0e10cSrcweir if( m_pCurLocalizationMgr )
665cdf0e10cSrcweir m_pCurLocalizationMgr->handleBasicStopped();
666cdf0e10cSrcweir }
667cdf0e10cSrcweir else if( m_pCurLocalizationMgr )
668cdf0e10cSrcweir {
669cdf0e10cSrcweir m_pCurLocalizationMgr->handleBasicStarted();
670cdf0e10cSrcweir }
671cdf0e10cSrcweir
672cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.First();
673cdf0e10cSrcweir while ( pWin )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir if ( nHintId == SBX_HINT_BASICSTART )
676cdf0e10cSrcweir pWin->BasicStarted();
677cdf0e10cSrcweir else
678cdf0e10cSrcweir pWin->BasicStopped();
679cdf0e10cSrcweir pWin = aIDEWindowTable.Next();
680cdf0e10cSrcweir }
681cdf0e10cSrcweir }
682cdf0e10cSrcweir }
683cdf0e10cSrcweir }
684cdf0e10cSrcweir }
685cdf0e10cSrcweir }
686cdf0e10cSrcweir
687cdf0e10cSrcweir
688cdf0e10cSrcweir
CheckWindows()689cdf0e10cSrcweir void BasicIDEShell::CheckWindows()
690cdf0e10cSrcweir {
691cdf0e10cSrcweir sal_Bool bSetCurWindow = sal_False;
692cdf0e10cSrcweir for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
695cdf0e10cSrcweir if ( pWin->GetStatus() & BASWIN_TOBEKILLED )
696cdf0e10cSrcweir {
697cdf0e10cSrcweir pWin->StoreData();
698cdf0e10cSrcweir if ( pWin == pCurWin )
699cdf0e10cSrcweir bSetCurWindow = sal_True;
700cdf0e10cSrcweir RemoveWindow( pWin, sal_True, sal_False );
701cdf0e10cSrcweir nWin--;
702cdf0e10cSrcweir }
703cdf0e10cSrcweir }
704cdf0e10cSrcweir if ( bSetCurWindow )
705cdf0e10cSrcweir SetCurWindow( FindApplicationWindow(), sal_True );
706cdf0e10cSrcweir }
707cdf0e10cSrcweir
708cdf0e10cSrcweir
709cdf0e10cSrcweir
RemoveWindows(const ScriptDocument & rDocument,const String & rLibName,sal_Bool bDestroy)710cdf0e10cSrcweir void BasicIDEShell::RemoveWindows( const ScriptDocument& rDocument, const String& rLibName, sal_Bool bDestroy )
711cdf0e10cSrcweir {
712cdf0e10cSrcweir sal_Bool bChangeCurWindow = pCurWin ? sal_False : sal_True;
713cdf0e10cSrcweir for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
714cdf0e10cSrcweir {
715cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
716cdf0e10cSrcweir if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName )
717cdf0e10cSrcweir {
718cdf0e10cSrcweir if ( pWin == pCurWin )
719cdf0e10cSrcweir bChangeCurWindow = sal_True;
720cdf0e10cSrcweir pWin->StoreData();
721cdf0e10cSrcweir RemoveWindow( pWin, bDestroy, sal_False );
722cdf0e10cSrcweir nWin--;
723cdf0e10cSrcweir }
724cdf0e10cSrcweir }
725cdf0e10cSrcweir if ( bChangeCurWindow )
726cdf0e10cSrcweir SetCurWindow( FindApplicationWindow(), sal_True );
727cdf0e10cSrcweir }
728cdf0e10cSrcweir
729cdf0e10cSrcweir
730cdf0e10cSrcweir
UpdateWindows()731cdf0e10cSrcweir void BasicIDEShell::UpdateWindows()
732cdf0e10cSrcweir {
733cdf0e10cSrcweir // Alle Fenster, die nicht angezeigt werden duerfen, entfernen
734cdf0e10cSrcweir sal_Bool bChangeCurWindow = pCurWin ? sal_False : sal_True;
735cdf0e10cSrcweir if ( m_aCurLibName.Len() )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir for ( sal_uLong nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
738cdf0e10cSrcweir {
739cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
740cdf0e10cSrcweir if ( !pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName )
741cdf0e10cSrcweir {
742cdf0e10cSrcweir if ( pWin == pCurWin )
743cdf0e10cSrcweir bChangeCurWindow = sal_True;
744cdf0e10cSrcweir pWin->StoreData();
745cdf0e10cSrcweir // Die Abfrage auf RUNNING verhindert den Absturz, wenn in Reschedule.
746cdf0e10cSrcweir // Fenster bleibt erstmal stehen, spaeter sowieso mal umstellen,
747cdf0e10cSrcweir // dass Fenster nur als Hidden markiert werden und nicht
748cdf0e10cSrcweir // geloescht.
749cdf0e10cSrcweir if ( !(pWin->GetStatus() & ( BASWIN_TOBEKILLED | BASWIN_RUNNINGBASIC | BASWIN_SUSPENDED ) ) )
750cdf0e10cSrcweir {
751cdf0e10cSrcweir RemoveWindow( pWin, sal_False, sal_False );
752cdf0e10cSrcweir nWin--;
753cdf0e10cSrcweir }
754cdf0e10cSrcweir }
755cdf0e10cSrcweir }
756cdf0e10cSrcweir }
757cdf0e10cSrcweir
758cdf0e10cSrcweir if ( bCreatingWindow )
759cdf0e10cSrcweir return;
760cdf0e10cSrcweir
761cdf0e10cSrcweir IDEBaseWindow* pNextActiveWindow = 0;
762cdf0e10cSrcweir
763cdf0e10cSrcweir // Alle anzuzeigenden Fenster anzeigen
764cdf0e10cSrcweir ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::AllWithApplication ) );
765cdf0e10cSrcweir for ( ScriptDocuments::const_iterator doc = aDocuments.begin();
766cdf0e10cSrcweir doc != aDocuments.end();
767cdf0e10cSrcweir ++doc
768cdf0e10cSrcweir )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir StartListening( *doc->getBasicManager(), sal_True /* Nur einmal anmelden */ );
771cdf0e10cSrcweir
772cdf0e10cSrcweir // libraries
773cdf0e10cSrcweir Sequence< ::rtl::OUString > aLibNames( doc->getLibraryNames() );
774cdf0e10cSrcweir sal_Int32 nLibCount = aLibNames.getLength();
775cdf0e10cSrcweir const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
776cdf0e10cSrcweir
777cdf0e10cSrcweir for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
778cdf0e10cSrcweir {
779cdf0e10cSrcweir String aLibName = pLibNames[ i ];
780cdf0e10cSrcweir
781cdf0e10cSrcweir if ( !m_aCurLibName.Len() || ( *doc == m_aCurDocument && aLibName == m_aCurLibName ) )
782cdf0e10cSrcweir {
783cdf0e10cSrcweir // check, if library is password protected and not verified
784cdf0e10cSrcweir sal_Bool bProtected = sal_False;
785cdf0e10cSrcweir Reference< script::XLibraryContainer > xModLibContainer( doc->getLibraryContainer( E_SCRIPTS ) );
786cdf0e10cSrcweir if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
789cdf0e10cSrcweir if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
790cdf0e10cSrcweir {
791cdf0e10cSrcweir bProtected = sal_True;
792cdf0e10cSrcweir }
793cdf0e10cSrcweir }
794cdf0e10cSrcweir
795cdf0e10cSrcweir if ( !bProtected )
796cdf0e10cSrcweir {
797cdf0e10cSrcweir LibInfoItem* pLibInfoItem = 0;
798cdf0e10cSrcweir BasicIDEData* pData = IDE_DLL()->GetExtraData();
799cdf0e10cSrcweir if ( pData )
800cdf0e10cSrcweir pLibInfoItem = pData->GetLibInfos().GetInfo( LibInfoKey( *doc, aLibName ) );
801cdf0e10cSrcweir
802cdf0e10cSrcweir // modules
803cdf0e10cSrcweir if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir StarBASIC* pLib = doc->getBasicManager()->GetLib( aLibName );
806cdf0e10cSrcweir if ( pLib )
807cdf0e10cSrcweir ImplStartListening( pLib );
808cdf0e10cSrcweir
809cdf0e10cSrcweir try
810cdf0e10cSrcweir {
811cdf0e10cSrcweir Sequence< ::rtl::OUString > aModNames( doc->getObjectNames( E_SCRIPTS, aLibName ) );
812cdf0e10cSrcweir sal_Int32 nModCount = aModNames.getLength();
813cdf0e10cSrcweir const ::rtl::OUString* pModNames = aModNames.getConstArray();
814cdf0e10cSrcweir
815cdf0e10cSrcweir for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir String aModName = pModNames[ j ];
818cdf0e10cSrcweir ModulWindow* pWin = FindBasWin( *doc, aLibName, aModName, sal_False );
819cdf0e10cSrcweir if ( !pWin )
820cdf0e10cSrcweir pWin = CreateBasWin( *doc, aLibName, aModName );
821cdf0e10cSrcweir if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aModName &&
822cdf0e10cSrcweir pLibInfoItem->GetCurrentType() == BASICIDE_TYPE_MODULE )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir pNextActiveWindow = (IDEBaseWindow*)pWin;
825cdf0e10cSrcweir }
826cdf0e10cSrcweir }
827cdf0e10cSrcweir }
828cdf0e10cSrcweir catch ( container::NoSuchElementException& )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
831cdf0e10cSrcweir }
832cdf0e10cSrcweir }
833cdf0e10cSrcweir
834cdf0e10cSrcweir // dialogs
835cdf0e10cSrcweir Reference< script::XLibraryContainer > xDlgLibContainer( doc->getLibraryContainer( E_DIALOGS ) );
836cdf0e10cSrcweir if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
837cdf0e10cSrcweir {
838cdf0e10cSrcweir try
839cdf0e10cSrcweir {
840cdf0e10cSrcweir Sequence< ::rtl::OUString > aDlgNames = doc->getObjectNames( E_DIALOGS, aLibName );
841cdf0e10cSrcweir sal_Int32 nDlgCount = aDlgNames.getLength();
842cdf0e10cSrcweir const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
843cdf0e10cSrcweir
844cdf0e10cSrcweir for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ )
845cdf0e10cSrcweir {
846cdf0e10cSrcweir String aDlgName = pDlgNames[ j ];
847cdf0e10cSrcweir // this find only looks for non-suspended windows;
848cdf0e10cSrcweir // suspended windows are handled in CreateDlgWin
849cdf0e10cSrcweir DialogWindow* pWin = FindDlgWin( *doc, aLibName, aDlgName, sal_False );
850cdf0e10cSrcweir if ( !pWin )
851cdf0e10cSrcweir pWin = CreateDlgWin( *doc, aLibName, aDlgName );
852cdf0e10cSrcweir if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aDlgName &&
853cdf0e10cSrcweir pLibInfoItem->GetCurrentType() == BASICIDE_TYPE_DIALOG )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir pNextActiveWindow = (IDEBaseWindow*)pWin;
856cdf0e10cSrcweir }
857cdf0e10cSrcweir }
858cdf0e10cSrcweir }
859cdf0e10cSrcweir catch ( container::NoSuchElementException& )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
862cdf0e10cSrcweir }
863cdf0e10cSrcweir }
864cdf0e10cSrcweir }
865cdf0e10cSrcweir }
866cdf0e10cSrcweir }
867cdf0e10cSrcweir }
868cdf0e10cSrcweir
869cdf0e10cSrcweir if ( bChangeCurWindow )
870cdf0e10cSrcweir {
871cdf0e10cSrcweir if ( !pNextActiveWindow )
872cdf0e10cSrcweir pNextActiveWindow = FindApplicationWindow();
873cdf0e10cSrcweir SetCurWindow( pNextActiveWindow, sal_True );
874cdf0e10cSrcweir }
875cdf0e10cSrcweir }
876cdf0e10cSrcweir
RemoveWindow(IDEBaseWindow * pWindow_,sal_Bool bDestroy,sal_Bool bAllowChangeCurWindow)877cdf0e10cSrcweir void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, sal_Bool bDestroy, sal_Bool bAllowChangeCurWindow )
878cdf0e10cSrcweir {
879cdf0e10cSrcweir DBG_ASSERT( pWindow_, "Kann keinen NULL-Pointer loeschen!" );
880cdf0e10cSrcweir sal_uLong nKey = aIDEWindowTable.GetKey( pWindow_ );
881cdf0e10cSrcweir pTabBar->RemovePage( (sal_uInt16)nKey );
882cdf0e10cSrcweir aIDEWindowTable.Remove( nKey );
883cdf0e10cSrcweir if ( pWindow_ == pCurWin )
884cdf0e10cSrcweir {
885cdf0e10cSrcweir if ( bAllowChangeCurWindow )
886cdf0e10cSrcweir SetCurWindow( FindApplicationWindow(), sal_True );
887cdf0e10cSrcweir else
888cdf0e10cSrcweir SetCurWindow( NULL, sal_False );
889cdf0e10cSrcweir }
890cdf0e10cSrcweir if ( bDestroy )
891cdf0e10cSrcweir {
892cdf0e10cSrcweir if ( !( pWindow_->GetStatus() & BASWIN_INRESCHEDULE ) )
893cdf0e10cSrcweir {
894cdf0e10cSrcweir delete pWindow_;
895cdf0e10cSrcweir }
896cdf0e10cSrcweir else
897cdf0e10cSrcweir {
898cdf0e10cSrcweir pWindow_->AddStatus( BASWIN_TOBEKILLED );
899cdf0e10cSrcweir pWindow_->Hide();
900cdf0e10cSrcweir // In normal mode stop basic in windows to be deleted
901cdf0e10cSrcweir // In VBA stop basic only if the running script is trying to delete
902cdf0e10cSrcweir // its parent module
903cdf0e10cSrcweir bool bStop = true;
904cdf0e10cSrcweir if ( pWindow_->GetDocument().isInVBAMode() )
905cdf0e10cSrcweir {
906cdf0e10cSrcweir SbModule* pMod = StarBASIC::GetActiveModule();
907cdf0e10cSrcweir if ( !pMod || ( pMod && ( pMod->GetName() != pWindow_->GetName() ) ) )
908cdf0e10cSrcweir bStop = false;
909cdf0e10cSrcweir }
910cdf0e10cSrcweir if ( bStop )
911cdf0e10cSrcweir {
912cdf0e10cSrcweir StarBASIC::Stop();
913cdf0e10cSrcweir // Es kommt kein Notify...
914cdf0e10cSrcweir pWindow_->BasicStopped();
915cdf0e10cSrcweir }
916cdf0e10cSrcweir aIDEWindowTable.Insert( nKey, pWindow_ ); // wieder einhaegen
917cdf0e10cSrcweir }
918cdf0e10cSrcweir }
919cdf0e10cSrcweir else
920cdf0e10cSrcweir {
921cdf0e10cSrcweir pWindow_->Hide();
922cdf0e10cSrcweir pWindow_->AddStatus( BASWIN_SUSPENDED );
923cdf0e10cSrcweir pWindow_->Deactivating();
924cdf0e10cSrcweir aIDEWindowTable.Insert( nKey, pWindow_ ); // wieder einhaegen
925cdf0e10cSrcweir }
926cdf0e10cSrcweir
927cdf0e10cSrcweir }
928cdf0e10cSrcweir
929cdf0e10cSrcweir
930cdf0e10cSrcweir
InsertWindowInTable(IDEBaseWindow * pNewWin)931cdf0e10cSrcweir sal_uInt16 BasicIDEShell::InsertWindowInTable( IDEBaseWindow* pNewWin )
932cdf0e10cSrcweir {
933cdf0e10cSrcweir // Eigentlich prueffen,
934cdf0e10cSrcweir nCurKey++;
935cdf0e10cSrcweir aIDEWindowTable.Insert( nCurKey, pNewWin );
936cdf0e10cSrcweir return nCurKey;
937cdf0e10cSrcweir }
938cdf0e10cSrcweir
939cdf0e10cSrcweir
940cdf0e10cSrcweir
InvalidateBasicIDESlots()941cdf0e10cSrcweir void BasicIDEShell::InvalidateBasicIDESlots()
942cdf0e10cSrcweir {
943cdf0e10cSrcweir // Nur die, die eine optische Auswirkung haben...
944cdf0e10cSrcweir
945cdf0e10cSrcweir if ( IDE_DLL()->GetShell() )
946cdf0e10cSrcweir {
947cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
948cdf0e10cSrcweir if ( pBindings )
949cdf0e10cSrcweir {
950*74932c38SAriel Constenla-Haile pBindings->Invalidate( SID_COPY );
951*74932c38SAriel Constenla-Haile pBindings->Invalidate( SID_CUT );
952*74932c38SAriel Constenla-Haile pBindings->Invalidate( SID_PASTE );
953cdf0e10cSrcweir pBindings->Invalidate( SID_UNDO );
954cdf0e10cSrcweir pBindings->Invalidate( SID_REDO );
955cdf0e10cSrcweir pBindings->Invalidate( SID_SAVEDOC );
956cdf0e10cSrcweir pBindings->Invalidate( SID_SIGNATURE );
957cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_CHOOSEMACRO );
958cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
959cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_OBJCAT );
960cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSTOP );
961cdf0e10cSrcweir pBindings->Invalidate( SID_BASICRUN );
962cdf0e10cSrcweir pBindings->Invalidate( SID_BASICCOMPILE );
963cdf0e10cSrcweir pBindings->Invalidate( SID_BASICLOAD );
964cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSAVEAS );
965cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_MATCHGROUP );
966cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSTEPINTO );
967cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSTEPOVER );
968cdf0e10cSrcweir pBindings->Invalidate( SID_BASICSTEPOUT );
969cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
970cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
971cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_ADDWATCH );
972cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_REMOVEWATCH );
973cdf0e10cSrcweir pBindings->Invalidate( SID_CHOOSE_CONTROLS );
974cdf0e10cSrcweir pBindings->Invalidate( SID_PRINTDOC );
975cdf0e10cSrcweir pBindings->Invalidate( SID_PRINTDOCDIRECT );
976cdf0e10cSrcweir pBindings->Invalidate( SID_SETUPPRINTER );
977cdf0e10cSrcweir pBindings->Invalidate( SID_DIALOG_TESTMODE );
978cdf0e10cSrcweir
979cdf0e10cSrcweir pBindings->Invalidate( SID_DOC_MODIFIED );
980cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
981cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_STAT_POS );
982cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_INSERT );
983cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_SIZE );
984cdf0e10cSrcweir }
985cdf0e10cSrcweir }
986cdf0e10cSrcweir }
987cdf0e10cSrcweir
EnableScrollbars(sal_Bool bEnable)988cdf0e10cSrcweir void BasicIDEShell::EnableScrollbars( sal_Bool bEnable )
989cdf0e10cSrcweir {
990cdf0e10cSrcweir if ( bEnable )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir aHScrollBar.Enable();
993cdf0e10cSrcweir aVScrollBar.Enable();
994cdf0e10cSrcweir }
995cdf0e10cSrcweir else
996cdf0e10cSrcweir {
997cdf0e10cSrcweir aHScrollBar.Disable();
998cdf0e10cSrcweir aVScrollBar.Disable();
999cdf0e10cSrcweir }
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir
SetCurLib(const ScriptDocument & rDocument,String aLibName,bool bUpdateWindows,bool bCheck)1002cdf0e10cSrcweir void BasicIDEShell::SetCurLib( const ScriptDocument& rDocument, String aLibName, bool bUpdateWindows, bool bCheck )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) )
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
1007cdf0e10cSrcweir
1008cdf0e10cSrcweir if ( pListener )
1009cdf0e10cSrcweir pListener->removeContainerListener( m_aCurDocument, m_aCurLibName );
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir m_aCurDocument = rDocument;
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir pListener->addContainerListener( m_aCurDocument, aLibName );
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir m_aCurLibName = aLibName;
1016cdf0e10cSrcweir
1017cdf0e10cSrcweir if ( bUpdateWindows )
1018cdf0e10cSrcweir UpdateWindows();
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir SetMDITitle();
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir SetCurLibForLocalization( rDocument, aLibName );
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
1025cdf0e10cSrcweir if ( pBindings )
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
1028cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
1029cdf0e10cSrcweir pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG );
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir
SetCurLibForLocalization(const ScriptDocument & rDocument,String aLibName)1034cdf0e10cSrcweir void BasicIDEShell::SetCurLibForLocalization( const ScriptDocument& rDocument, String aLibName )
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir // Create LocalizationMgr
1037cdf0e10cSrcweir delete m_pCurLocalizationMgr;
1038cdf0e10cSrcweir Reference< resource::XStringResourceManager > xStringResourceManager;
1039cdf0e10cSrcweir try
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir if( aLibName.Len() )
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, sal_True ) );
1044cdf0e10cSrcweir xStringResourceManager = LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
1045cdf0e10cSrcweir }
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir catch ( container::NoSuchElementException& )
1048cdf0e10cSrcweir {}
1049cdf0e10cSrcweir m_pCurLocalizationMgr = new LocalizationMgr
1050cdf0e10cSrcweir ( this, rDocument, aLibName, xStringResourceManager );
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir m_pCurLocalizationMgr->handleTranslationbar();
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir
ImplStartListening(StarBASIC * pBasic)1055cdf0e10cSrcweir void BasicIDEShell::ImplStartListening( StarBASIC* pBasic )
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir StartListening( pBasic->GetBroadcaster(), sal_True /* Nur einmal anmelden */ );
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir
1060cdf0e10cSrcweir
1061