Files
libreoffice/basctl/source/basicide/basobj3.cxx

510 lines
16 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-06-12 17:02:47 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-29 10:02:42 +00:00
2011-11-21 23:33:54 -05:00
#include <vcl/msgbox.hxx>
2001-09-04 10:52:52 +00:00
#include <vector>
#include <algorithm>
#include <basic/basmgr.hxx>
#include <basic/sbmeth.hxx>
#include <basic/sbx.hxx>
#include <unotools/moduleoptions.hxx>
2000-09-29 10:02:42 +00:00
#include <iderdll.hxx>
#include <iderdll2.hxx>
2000-09-29 10:02:42 +00:00
#include <basobj.hxx>
#include <basidesh.hxx>
#include <objdlg.hxx>
#include <bastypes.hxx>
2001-06-15 07:45:19 +00:00
#include <basdoc.hxx>
#include <basidesh.hrc>
2000-09-29 10:02:42 +00:00
#include <baside2.hxx>
2001-06-15 07:45:19 +00:00
#include <baside3.hxx>
#include <basicmod.hxx>
#include <localizationmgr.hxx>
2001-06-15 07:45:19 +00:00
#include "dlged.hxx"
#include <dlgeddef.hxx>
2001-06-15 07:45:19 +00:00
#include <comphelper/processfactory.hxx>
#include <com/sun/star/script/XLibraryContainer.hpp>
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
2001-06-15 07:45:19 +00:00
#include <xmlscript/xmldlg_imexp.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/request.hxx>
#include <rtl/uri.hxx>
#include <osl/process.h>
#include <osl/file.hxx>
2001-06-15 07:45:19 +00:00
using namespace comphelper;
using namespace ::com::sun::star;
2001-06-15 07:45:19 +00:00
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::container;
2000-09-29 10:02:42 +00:00
//----------------------------------------------------------------------------
extern "C" {
CWS-TOOLING: integrate CWS sb102 2008-12-11 16:18:12 +0100 sb r265332 : #i95065# cleanup, to make Windows linking work 2008-12-11 16:16:03 +0100 sb r265331 : #i95065# missing SAL_DLLPUBLIC_EXPORT 2008-12-09 17:40:28 +0100 sb r265122 : #i94469# move CJK specific configuration data to brand layer 2008-12-09 16:09:08 +0100 sb r265112 : #i96959# use PTHREAD_MUTEX_RECURSIVE on all platforms 2008-12-09 15:54:31 +0100 sb r265110 : #i95065# do not derive apphelper::LifeTimeGuard from osl::ResettableMutexGuard to avoid problems with VISIBILITY_HIDDEN=TRUE on MSC 2008-12-09 15:40:51 +0100 sb r265104 : #i95065# add VISIBILITY_HIDDEN=TRUE to connectivity/source/drivers/mozab 2008-12-09 15:36:21 +0100 sb r265102 : #i95501# updated SDK_HOME 2008-12-09 15:31:46 +0100 sb r265099 : typo (temppath vs. tmppath) 2008-12-08 11:48:08 +0100 sb r264979 : #i95065# removed spurious ExplicitCategoriesProvider.obj (ExplicitCategoriesProvider.cxx is not in this directory) 2008-12-07 19:41:07 +0100 sb r264960 : #i96994# erroneously doubled backslash caused visibility feature to be disabled for all GCC versions on Mac OS X 2008-12-06 23:54:49 +0100 sb r264948 : changes from trunk that CWS-TOOLING's rebase to DEV300:m37 (r264891) had missed, as files had been moved around on this CWS 2008-12-05 20:29:23 +0100 sb r264919 : #i85508# versions of flex apparently differ in whether input() resp. yyinput() returns zero or EOF upon end of file 2008-12-05 15:37:23 +0100 sb r264908 : #i95315# removed obsolete jut 2008-12-05 15:34:59 +0100 sb r264907 : #i95531# removed empty obsolete directories 2008-12-05 10:09:23 +0100 sb r264891 : CWS-TOOLING: rebase CWS sb102 to trunk@264807 (milestone: DEV300:m37) 2008-12-04 14:50:20 +0100 sb r264845 : #i95065# introduced VISIBILITY_HIDDEN makefile flag to reduce duplications; made additional libraries use VISIBILITY_HIDDEN=TRUE to avoid warnings with recent GCC 4 versions (had to split certain code directories to make changes that would otherwise erroneously affect multiple libraries built in the same makefile); changed connectivity::ORefVector to no longer derive from std::vector, as that caused problems with the MSC implementation of VISIBILITY_HIDDEN=TRUE; replaced uses of JNIEXPORT with SAL_DLLPUBLIC_EXPORT, as the former does not expand to visibility attributes on some platforms where the latter does 2008-12-03 11:29:38 +0100 sb r264759 : #i94583# remove unnecessary (and wrong) assertion check for rtl_getAppCommandArg return value (which is guaranteed to return osl_Process_E_None or not return at all) 2008-12-02 17:18:31 +0100 sb r264724 : #i96809# silenced GCC 4.3.2 warning 2008-12-02 13:29:34 +0100 sb r264695 : #i96797# make get_tmp_dir fail less often 2008-11-28 17:19:24 +0100 sb r264566 : #i95691# inadvertently missing from -c 264564 2008-11-28 17:07:50 +0100 sb r264564 : #i95691# only structs of exactly 1, 2, 4, or 8 bytes are returned through registers 2008-11-25 13:28:08 +0100 sb r264291 : #i96427# support for SAL_EXCEPTION_DLLPUBLIC_EXPORT (patch by np) 2008-11-21 14:45:22 +0100 sb r264140 : #i95428# added SAL_EXCEPTION_DLLPUBLIC_EXPORT and SAL_EXCEPTION_DLLPRIVATE 2008-11-19 13:19:37 +0100 sb r263984 : #i95525# removed erroneous application/octet-stream svn:mime-type properties
2008-12-30 13:32:01 +00:00
SAL_DLLPUBLIC_EXPORT long basicide_handle_basic_error( void* pPtr )
{
return BasicIDE::HandleBasicError( (StarBASIC*)pPtr );
}
}
namespace BasicIDE
{
//----------------------------------------------------------------------------
SbMethod* CreateMacro( SbModule* pModule, const String& rMacroName )
2000-09-29 10:02:42 +00:00
{
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
2001-09-06 08:21:02 +00:00
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
2000-09-29 10:02:42 +00:00
if( pDispatcher )
{
pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
}
if ( pModule->GetMethods()->Find( rMacroName, SbxCLASS_METHOD ) )
return 0;
String aMacroName( rMacroName );
if ( aMacroName.Len() == 0 )
{
if ( !pModule->GetMethods()->Count() )
aMacroName = String( RTL_CONSTASCII_USTRINGPARAM( "Main" ) );
else
{
bool bValid = false;
String aStdMacroText( RTL_CONSTASCII_USTRINGPARAM( "Macro" ) );
sal_uInt16 nMacro = 1;
2000-09-29 10:02:42 +00:00
while ( !bValid )
{
aMacroName = aStdMacroText;
aMacroName += String::CreateFromInt32( nMacro );
// test whether existing...
bValid = pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD ) ? false : true;
2000-09-29 10:02:42 +00:00
nMacro++;
}
}
}
::rtl::OUString aOUSource( pModule->GetSource32() );
2000-09-29 10:02:42 +00:00
// don't produce too many empty lines...
sal_Int32 nSourceLen = aOUSource.getLength();
if ( nSourceLen > 2 )
2000-09-29 10:02:42 +00:00
{
const sal_Unicode* pStr = aOUSource.getStr();
if ( pStr[ nSourceLen - 1 ] != LINE_SEP )
aOUSource += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n\n" ) );
else if ( pStr[ nSourceLen - 2 ] != LINE_SEP )
aOUSource += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n" ) );
else if ( pStr[ nSourceLen - 3 ] == LINE_SEP )
aOUSource = aOUSource.copy( 0, nSourceLen-1 );
2000-09-29 10:02:42 +00:00
}
::rtl::OUString aSubStr;
aSubStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Sub " ) );
2000-09-29 10:02:42 +00:00
aSubStr += aMacroName;
aSubStr += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n\nEnd Sub" ) );
2000-09-29 10:02:42 +00:00
aOUSource += aSubStr;
// update module in library
ScriptDocument aDocument( ScriptDocument::NoDocument );
SbxObject* pParent = pModule->GetParent();
StarBASIC* pBasic = PTR_CAST(StarBASIC,pParent);
DBG_ASSERT(pBasic, "BasicIDE::CreateMacro: No Basic found!");
if ( pBasic )
{
BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
DBG_ASSERT(pBasMgr, "BasicIDE::CreateMacro: No BasicManager found!");
if ( pBasMgr )
{
aDocument = ScriptDocument::getDocumentForBasicManager( pBasMgr );
OSL_ENSURE( aDocument.isValid(), "BasicIDE::CreateMacro: no document for the given BasicManager!" );
if ( aDocument.isValid() )
{
String aLibName = pBasic->GetName();
String aModName = pModule->GetName();
OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aOUSource ) );
}
}
}
2000-09-29 10:02:42 +00:00
SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD );
2001-09-06 08:21:02 +00:00
2000-09-29 10:02:42 +00:00
if( pDispatcher )
{
pDispatcher->Execute( SID_BASICIDE_UPDATEALLMODULESOURCES );
}
if ( aDocument.isAlive() )
BasicIDE::MarkDocumentModified( aDocument );
2000-09-29 10:02:42 +00:00
return pMethod;
}
//----------------------------------------------------------------------------
2011-12-10 02:54:11 -05:00
bool RenameDialog( Window* pErrorParent, const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rOldName, const ::rtl::OUString& rNewName )
2001-06-15 07:45:19 +00:00
throw(ElementExistException, NoSuchElementException)
{
if ( !rDocument.hasDialog( rLibName, rOldName ) )
2001-06-15 07:45:19 +00:00
{
OSL_FAIL( "BasicIDE::RenameDialog: old module name is invalid!" );
return false;
2001-06-15 07:45:19 +00:00
}
if ( rDocument.hasDialog( rLibName, rNewName ) )
2001-06-15 07:45:19 +00:00
{
ErrorBox aError( pErrorParent, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2) );
aError.Execute();
return false;
2001-06-15 07:45:19 +00:00
}
// #i74440
2011-12-10 02:54:11 -05:00
if ( rNewName.isEmpty() )
{
ErrorBox aError( pErrorParent, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_BADSBXNAME) );
aError.Execute();
return false;
}
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
IDEBaseWindow* pWin = pIDEShell ? pIDEShell->FindWindow( rDocument, rLibName, rOldName, BASICIDE_TYPE_DIALOG, sal_False ) : NULL;
Reference< XNameContainer > xExistingDialog;
if ( pWin )
xExistingDialog = ((DialogWindow*)pWin)->GetEditor()->GetDialog();
2001-06-15 07:45:19 +00:00
if ( xExistingDialog.is() )
LocalizationMgr::renameStringResourceIDs( rDocument, rLibName, rNewName, xExistingDialog );
if ( !rDocument.renameDialog( rLibName, rOldName, rNewName, xExistingDialog ) )
return false;
2001-06-15 07:45:19 +00:00
if ( pWin )
2001-06-15 07:45:19 +00:00
{
// set new name in window
pWin->SetName( rNewName );
2001-06-15 07:45:19 +00:00
// update property browser
((DialogWindow*)pWin)->UpdateBrowser();
2001-06-15 07:45:19 +00:00
// update tabwriter
sal_uInt16 nId = pIDEShell->GetIDEWindowId( pWin );
DBG_ASSERT( nId, "No entry in Tabbar!" );
if ( nId )
{
BasicIDETabBar* pTabBar = (BasicIDETabBar*)pIDEShell->GetTabBar();
pTabBar->SetPageText( nId, rNewName );
pTabBar->Sort();
pTabBar->MakeVisible( pTabBar->GetCurPageId() );
2000-09-29 10:02:42 +00:00
}
}
return true;
2000-09-29 10:02:42 +00:00
}
//----------------------------------------------------------------------------
2011-12-09 01:58:49 -05:00
bool RemoveDialog( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName )
2000-09-29 10:02:42 +00:00
{
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
if ( pIDEShell )
{
DialogWindow* pDlgWin = pIDEShell->FindDlgWin( rDocument, rLibName, rDlgName, false );
if( pDlgWin )
{
Reference< container::XNameContainer > xDialogModel = pDlgWin->GetDialog();
LocalizationMgr::removeResourceForDialog( rDocument, rLibName, rDlgName, xDialogModel );
}
}
return rDocument.removeDialog( rLibName, rDlgName );
2000-09-29 10:02:42 +00:00
}
//----------------------------------------------------------------------------
StarBASIC* FindBasic( const SbxVariable* pVar )
2000-09-29 10:02:42 +00:00
{
const SbxVariable* pSbx = pVar;
while ( pSbx && !pSbx->ISA( StarBASIC ) )
pSbx = pSbx->GetParent();
DBG_ASSERT( !pSbx || pSbx->ISA( StarBASIC ), "Find Basic: Kein Basic!" );
return (StarBASIC*)pSbx;
}
//----------------------------------------------------------------------------
BasicManager* FindBasicManager( StarBASIC* pLib )
2000-09-29 10:02:42 +00:00
{
ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::AllWithApplication ) );
for ( ScriptDocuments::const_iterator doc = aDocuments.begin();
doc != aDocuments.end();
++doc
)
{
BasicManager* pBasicMgr = doc->getBasicManager();
OSL_ENSURE( pBasicMgr, "BasicIDE::FindBasicManager: no basic manager for the document!" );
if ( !pBasicMgr )
continue;
Sequence< ::rtl::OUString > aLibNames( doc->getLibraryNames() );
sal_Int32 nLibCount = aLibNames.getLength();
const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
2000-09-29 10:02:42 +00:00
{
StarBASIC* pL = pBasicMgr->GetLib( pLibNames[ i ] );
2000-09-29 10:02:42 +00:00
if ( pL == pLib )
return pBasicMgr;
}
}
return NULL;
2000-09-29 10:02:42 +00:00
}
//----------------------------------------------------------------------------
void MarkDocumentModified( const ScriptDocument& rDocument )
2001-06-15 07:45:19 +00:00
{
// does not have to come from a document...
if ( rDocument.isApplication() )
2001-09-26 14:25:17 +00:00
{
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
2001-09-26 14:25:17 +00:00
if ( pIDEShell )
pIDEShell->SetAppBasicModified();
}
else
{
rDocument.setDocumentModified();
}
2001-06-15 07:45:19 +00:00
SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
if ( pBindings )
{
pBindings->Invalidate( SID_SIGNATURE );
pBindings->Invalidate( SID_SAVEDOC );
pBindings->Update( SID_SAVEDOC );
}
2001-06-15 07:45:19 +00:00
2011-08-24 11:13:33 +01:00
// Objectcatalog updaten...
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
2001-06-15 07:45:19 +00:00
ObjectCatalog* pObjCatalog = pIDEShell ? pIDEShell->GetObjectCatalog() : 0;
if ( pObjCatalog )
pObjCatalog->UpdateEntries();
}
//----------------------------------------------------------------------------
void RunMethod( SbMethod* pMethod )
2000-09-29 10:02:42 +00:00
{
SbxValues aRes;
aRes.eType = SbxVOID;
pMethod->Get( aRes );
}
//----------------------------------------------------------------------------
void StopBasic()
2000-09-29 10:02:42 +00:00
{
StarBASIC::Stop();
2011-08-24 11:13:33 +01:00
BasicIDEShell* pShell = BasicIDEGlobals::GetShell();
2000-09-29 10:02:42 +00:00
if ( pShell )
{
IDEWindowTable& rWindows = pShell->GetIDEWindowTable();
for( IDEWindowTable::const_iterator it = rWindows.begin(); it != rWindows.end(); ++it )
2000-09-29 10:02:42 +00:00
{
IDEBaseWindow* pWin = it->second;
// call BasicStopped manually because the Stop-Notify
// might not get through otherwise
2000-09-29 10:02:42 +00:00
pWin->BasicStopped();
}
}
BasicIDE::BasicStopped();
}
//----------------------------------------------------------------------------
void BasicStopped( bool* pbAppWindowDisabled,
bool* pbDispatcherLocked, sal_uInt16* pnWaitCount,
2000-09-29 10:02:42 +00:00
SfxUInt16Item** ppSWActionCount, SfxUInt16Item** ppSWLockViewCount )
{
// maybe there are some locks to be removed after an error
// or an explicit cancelling of the basic...
2000-09-29 10:02:42 +00:00
if ( pbAppWindowDisabled )
*pbAppWindowDisabled = false;
2000-09-29 10:02:42 +00:00
if ( pbDispatcherLocked )
*pbDispatcherLocked = false;
2000-09-29 10:02:42 +00:00
if ( pnWaitCount )
*pnWaitCount = 0;
if ( ppSWActionCount )
*ppSWActionCount = 0;
if ( ppSWLockViewCount )
*ppSWLockViewCount = 0;
// AppWait ?
2011-08-24 11:13:33 +01:00
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
if( pIDEShell )
2000-09-29 10:02:42 +00:00
{
sal_uInt16 nWait = 0;
while ( pIDEShell->GetViewFrame()->GetWindow().IsWait() )
{
pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
nWait++;
}
if ( pnWaitCount )
*pnWaitCount = nWait;
2000-09-29 10:02:42 +00:00
}
Window* pDefParent = Application::GetDefDialogParent();
if ( pDefParent && !pDefParent->IsEnabled() )
2000-09-29 10:02:42 +00:00
{
pDefParent->Enable( sal_True );
if ( pbAppWindowDisabled )
*pbAppWindowDisabled = true;
2000-09-29 10:02:42 +00:00
}
}
//----------------------------------------------------------------------------
void InvalidateDebuggerSlots()
2000-09-29 10:02:42 +00:00
{
SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
if ( pBindings )
{
pBindings->Invalidate( SID_BASICSTOP );
pBindings->Update( SID_BASICSTOP );
pBindings->Invalidate( SID_BASICRUN );
pBindings->Update( SID_BASICRUN );
pBindings->Invalidate( SID_BASICCOMPILE );
pBindings->Update( SID_BASICCOMPILE );
pBindings->Invalidate( SID_BASICSTEPOVER );
pBindings->Update( SID_BASICSTEPOVER );
pBindings->Invalidate( SID_BASICSTEPINTO );
pBindings->Update( SID_BASICSTEPINTO );
pBindings->Invalidate( SID_BASICSTEPOUT );
pBindings->Update( SID_BASICSTEPOUT );
pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
pBindings->Update( SID_BASICIDE_STAT_POS );
}
2000-09-29 10:02:42 +00:00
}
//----------------------------------------------------------------------------
long HandleBasicError( StarBASIC* pBasic )
2000-09-29 10:02:42 +00:00
{
BasicIDEGlobals::ensure();
BasicIDE::BasicStopped();
// no error output during macro choosing
2011-08-24 11:13:33 +01:00
if ( BasicIDEGlobals::GetExtraData()->ChoosingMacro() )
return 1;
2011-08-24 11:13:33 +01:00
if ( BasicIDEGlobals::GetExtraData()->ShellInCriticalSection() )
return 2;
long nRet = 0;
BasicIDEShell* pIDEShell = 0;
if ( SvtModuleOptions().IsBasicIDE() )
{
BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
if ( pBasMgr )
{
bool bProtected = false;
ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
OSL_ENSURE( aDocument.isValid(), "BasicIDE::HandleBasicError: no document for the given BasicManager!" );
if ( aDocument.isValid() )
{
::rtl::OUString aOULibName( pBasic->GetName() );
Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
{
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
{
bProtected = true;
}
}
}
if ( !bProtected )
{
2011-08-24 11:13:33 +01:00
pIDEShell = BasicIDEGlobals::GetShell();
if ( !pIDEShell )
{
SfxAllItemSet aArgs( SFX_APP()->GetPool() );
SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
SFX_APP()->ExecuteSlot( aRequest );
2011-08-24 11:13:33 +01:00
pIDEShell = BasicIDEGlobals::GetShell();
}
}
}
}
if ( pIDEShell )
nRet = pIDEShell->CallBasicErrorHdl( pBasic );
else
ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
return nRet;
2000-09-29 10:02:42 +00:00
}
//----------------------------------------------------------------------------
SfxBindings* GetBindingsPtr()
2000-09-29 10:02:42 +00:00
{
SfxBindings* pBindings = NULL;
SfxViewFrame* pFrame = NULL;
2011-08-24 11:13:33 +01:00
if ( BasicIDEGlobals::GetShell() )
2000-09-29 10:02:42 +00:00
{
2011-08-24 11:13:33 +01:00
pFrame = BasicIDEGlobals::GetShell()->GetViewFrame();
2000-09-29 10:02:42 +00:00
}
else
{
SfxViewFrame* pView = SfxViewFrame::GetFirst();
while ( pView )
{
SfxObjectShell* pObjShell = pView->GetObjectShell();
if ( pObjShell && pObjShell->ISA( BasicDocShell ) )
{
pFrame = pView;
break;
}
pView = SfxViewFrame::GetNext( *pView );
}
}
if ( pFrame != NULL )
pBindings = &pFrame->GetBindings();
return pBindings;
}
} //namespace BasicIDE
//----------------------------------------------------------------------------
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */