2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-29 10:02:42 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:38:47 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:38:47 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:38:47 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:38:47 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:38:47 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:38:47 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 23:27:06 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <ide_pch.hxx>
|
|
|
|
|
2011-11-21 23:33:54 -05:00
|
|
|
#include <vcl/msgbox.hxx>
|
2001-09-04 10:52:52 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
2005-04-13 08:50:48 +00:00
|
|
|
#include <basic/sbx.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/moduleoptions.hxx>
|
2001-09-11 14:40:15 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <iderdll.hxx>
|
2001-09-11 14:40:15 +00:00
|
|
|
#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>
|
2007-03-15 14:54:47 +00:00
|
|
|
#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>
|
2001-09-11 14:40:15 +00:00
|
|
|
#include <basicmod.hxx>
|
2007-01-02 14:50:19 +00:00
|
|
|
#include <localizationmgr.hxx>
|
2001-06-15 07:45:19 +00:00
|
|
|
#include "dlged.hxx"
|
2004-12-10 16:01:36 +00:00
|
|
|
#include <dlgeddef.hxx>
|
2001-06-15 07:45:19 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2001-03-28 10:27:57 +00:00
|
|
|
#include <com/sun/star/script/XLibraryContainer.hpp>
|
2001-11-02 12:45:10 +00:00
|
|
|
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
|
2001-03-28 10:27:57 +00:00
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
2001-06-15 07:45:19 +00:00
|
|
|
#include <xmlscript/xmldlg_imexp.hxx>
|
2004-07-23 11:03:28 +00:00
|
|
|
#include <rtl/uri.hxx>
|
|
|
|
#include <osl/process.h>
|
|
|
|
#include <osl/file.hxx>
|
2001-03-28 10:27:57 +00:00
|
|
|
|
2001-06-15 07:45:19 +00:00
|
|
|
using namespace comphelper;
|
2001-03-28 10:27:57 +00:00
|
|
|
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;
|
2001-03-28 10:27:57 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2001-09-11 14:40:15 +00:00
|
|
|
extern "C" {
|
2008-12-30 13:32:01 +00:00
|
|
|
SAL_DLLPUBLIC_EXPORT long basicide_handle_basic_error( void* pPtr )
|
2001-09-11 14:40:15 +00:00
|
|
|
{
|
|
|
|
return BasicIDE::HandleBasicError( (StarBASIC*)pPtr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
namespace BasicIDE
|
|
|
|
{
|
2001-09-11 14:40:15 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
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
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bValid = sal_False;
|
2000-12-05 07:46:58 +00:00
|
|
|
String aStdMacroText( RTL_CONSTASCII_USTRINGPARAM( "Macro" ) );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nMacro = 1;
|
2000-09-29 10:02:42 +00:00
|
|
|
while ( !bValid )
|
|
|
|
{
|
|
|
|
aMacroName = aStdMacroText;
|
|
|
|
aMacroName += String::CreateFromInt32( nMacro );
|
2011-08-22 11:39:37 +02:00
|
|
|
// test whether existing...
|
2011-01-14 11:16:25 +01:00
|
|
|
bValid = pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD ) ? sal_False : sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
nMacro++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-23 15:39:29 +00:00
|
|
|
::rtl::OUString aOUSource( pModule->GetSource32() );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
// don't produce too many empty lines...
|
2003-04-23 15:39:29 +00:00
|
|
|
sal_Int32 nSourceLen = aOUSource.getLength();
|
|
|
|
if ( nSourceLen > 2 )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-04-23 15:39:29 +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
|
|
|
}
|
|
|
|
|
2003-04-23 15:39:29 +00:00
|
|
|
::rtl::OUString aSubStr;
|
|
|
|
aSubStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Sub " ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
aSubStr += aMacroName;
|
2003-04-23 15:39:29 +00:00
|
|
|
aSubStr += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n\nEnd Sub" ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2003-04-23 15:39:29 +00:00
|
|
|
aOUSource += aSubStr;
|
2001-08-29 11:29:09 +00:00
|
|
|
|
|
|
|
// update module in library
|
2007-03-15 14:54:47 +00:00
|
|
|
ScriptDocument aDocument( ScriptDocument::NoDocument );
|
2001-08-29 11:29:09 +00:00
|
|
|
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 )
|
|
|
|
{
|
2007-03-15 14:54:47 +00:00
|
|
|
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 ) );
|
|
|
|
}
|
2001-08-29 11:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 );
|
|
|
|
}
|
2001-08-29 11:29:09 +00:00
|
|
|
|
2007-10-09 14:22:16 +00:00
|
|
|
if ( aDocument.isAlive() )
|
2007-03-15 14:54:47 +00:00
|
|
|
BasicIDE::MarkDocumentModified( aDocument );
|
2001-08-29 11:29:09 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
return pMethod;
|
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
bool RenameDialog( Window* pErrorParent, const ScriptDocument& rDocument, const String& rLibName, const String& rOldName, const String& rNewName )
|
2001-06-15 07:45:19 +00:00
|
|
|
throw(ElementExistException, NoSuchElementException)
|
|
|
|
{
|
2007-03-15 14:54:47 +00:00
|
|
|
if ( !rDocument.hasDialog( rLibName, rOldName ) )
|
2001-06-15 07:45:19 +00:00
|
|
|
{
|
2011-03-12 11:29:14 +01:00
|
|
|
OSL_FAIL( "BasicIDE::RenameDialog: old module name is invalid!" );
|
2007-03-15 14:54:47 +00:00
|
|
|
return false;
|
2001-06-15 07:45:19 +00:00
|
|
|
}
|
2007-03-15 14:54:47 +00:00
|
|
|
|
|
|
|
if ( rDocument.hasDialog( rLibName, rNewName ) )
|
2001-06-15 07:45:19 +00:00
|
|
|
{
|
2007-03-15 14:54:47 +00:00
|
|
|
ErrorBox aError( pErrorParent, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) );
|
|
|
|
aError.Execute();
|
|
|
|
return false;
|
2001-06-15 07:45:19 +00:00
|
|
|
}
|
|
|
|
|
2007-08-03 08:58:33 +00:00
|
|
|
// #i74440
|
|
|
|
if ( rNewName.Len() == 0 )
|
|
|
|
{
|
|
|
|
ErrorBox aError( pErrorParent, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) );
|
|
|
|
aError.Execute();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-24 11:13:33 +01:00
|
|
|
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
|
2011-11-30 02:11:15 -05:00
|
|
|
IDEBaseWindow* pWin = pIDEShell ? pIDEShell->FindWindow( rDocument, rLibName, rOldName, BasicIDEType::Dialog, sal_False ) : NULL;
|
2007-03-15 14:54:47 +00:00
|
|
|
Reference< XNameContainer > xExistingDialog;
|
|
|
|
if ( pWin )
|
|
|
|
xExistingDialog = ((DialogWindow*)pWin)->GetEditor()->GetDialog();
|
2001-06-15 07:45:19 +00:00
|
|
|
|
2007-03-15 14:54:47 +00:00
|
|
|
if ( xExistingDialog.is() )
|
|
|
|
LocalizationMgr::renameStringResourceIDs( rDocument, rLibName, rNewName, xExistingDialog );
|
2007-01-29 15:44:37 +00:00
|
|
|
|
2007-03-15 14:54:47 +00:00
|
|
|
if ( !rDocument.renameDialog( rLibName, rOldName, rNewName, xExistingDialog ) )
|
|
|
|
return false;
|
2001-06-15 07:45:19 +00:00
|
|
|
|
2007-01-29 15:44:37 +00:00
|
|
|
if ( pWin )
|
2001-06-15 07:45:19 +00:00
|
|
|
{
|
2007-01-29 15:44:37 +00:00
|
|
|
// set new name in window
|
|
|
|
pWin->SetName( rNewName );
|
2001-06-15 07:45:19 +00:00
|
|
|
|
2007-01-29 15:44:37 +00:00
|
|
|
// update property browser
|
|
|
|
((DialogWindow*)pWin)->UpdateBrowser();
|
2001-06-15 07:45:19 +00:00
|
|
|
|
2007-01-29 15:44:37 +00:00
|
|
|
// update tabwriter
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nId = (sal_uInt16)(pIDEShell->GetIDEWindowTable()).GetKey( pWin );
|
2007-01-29 15:44:37 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2007-03-15 14:54:47 +00:00
|
|
|
return true;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
bool RemoveDialog( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-08-24 11:13:33 +01:00
|
|
|
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
|
2007-01-02 14:50:19 +00:00
|
|
|
if ( pIDEShell )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
DialogWindow* pDlgWin = pIDEShell->FindDlgWin( rDocument, rLibName, rDlgName, sal_False );
|
2007-01-02 14:50:19 +00:00
|
|
|
if( pDlgWin )
|
|
|
|
{
|
|
|
|
Reference< container::XNameContainer > xDialogModel = pDlgWin->GetDialog();
|
2007-03-15 14:54:47 +00:00
|
|
|
LocalizationMgr::removeResourceForDialog( rDocument, rLibName, rDlgName, xDialogModel );
|
2007-01-02 14:50:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-15 14:54:47 +00:00
|
|
|
return rDocument.removeDialog( rLibName, rDlgName );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +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;
|
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
BasicManager* FindBasicManager( StarBASIC* pLib )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2007-10-09 14:22:16 +00:00
|
|
|
ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::AllWithApplication ) );
|
2007-03-15 14:54:47 +00:00
|
|
|
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() );
|
2001-09-03 10:56:10 +00:00
|
|
|
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
|
|
|
{
|
2001-09-03 10:56:10 +00:00
|
|
|
StarBASIC* pL = pBasicMgr->GetLib( pLibNames[ i ] );
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pL == pLib )
|
|
|
|
return pBasicMgr;
|
|
|
|
}
|
|
|
|
}
|
2007-03-15 14:54:47 +00:00
|
|
|
return NULL;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
void MarkDocumentModified( const ScriptDocument& rDocument )
|
2001-06-15 07:45:19 +00:00
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// does not have to come from a document...
|
2007-03-15 14:54:47 +00:00
|
|
|
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();
|
|
|
|
}
|
2007-03-15 14:54:47 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
rDocument.setDocumentModified();
|
|
|
|
}
|
2001-06-15 07:45:19 +00:00
|
|
|
|
2003-04-24 13:08:39 +00:00
|
|
|
SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
|
|
|
|
if ( pBindings )
|
|
|
|
{
|
2004-08-31 11:20:43 +00:00
|
|
|
pBindings->Invalidate( SID_SIGNATURE );
|
2003-04-24 13:08:39 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
void RunMethod( SbMethod* pMethod )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
SbxValues aRes;
|
|
|
|
aRes.eType = SbxVOID;
|
|
|
|
pMethod->Get( aRes );
|
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
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();
|
|
|
|
IDEBaseWindow* pWin = rWindows.First();
|
|
|
|
while ( pWin )
|
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// call BasicStopped manually because the Stop-Notify
|
|
|
|
// might not get through otherwise
|
2000-09-29 10:02:42 +00:00
|
|
|
pWin->BasicStopped();
|
|
|
|
pWin = rWindows.Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BasicIDE::BasicStopped();
|
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
void BasicStopped( sal_Bool* pbAppWindowDisabled,
|
|
|
|
sal_Bool* pbDispatcherLocked, sal_uInt16* pnWaitCount,
|
2000-09-29 10:02:42 +00:00
|
|
|
SfxUInt16Item** ppSWActionCount, SfxUInt16Item** ppSWLockViewCount )
|
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// 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 )
|
2011-01-14 11:16:25 +01:00
|
|
|
*pbAppWindowDisabled = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( pbDispatcherLocked )
|
2011-01-14 11:16:25 +01:00
|
|
|
*pbDispatcherLocked = sal_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();
|
2004-03-30 13:27:13 +00:00
|
|
|
if( pIDEShell )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-03-12 23:58:22 -06:00
|
|
|
sal_uInt16 nWait = 0;
|
2004-03-30 13:27:13 +00:00
|
|
|
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();
|
2000-10-19 08:19:37 +00:00
|
|
|
if ( pDefParent && !pDefParent->IsEnabled() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
pDefParent->Enable( sal_True );
|
2004-01-06 16:12:59 +00:00
|
|
|
if ( pbAppWindowDisabled )
|
2011-01-14 11:16:25 +01:00
|
|
|
*pbAppWindowDisabled = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
void InvalidateDebuggerSlots()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-04-24 13:08:39 +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
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
long HandleBasicError( StarBASIC* pBasic )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-08-24 10:04:16 +01:00
|
|
|
BasicIDEGlobals::ensure();
|
2001-09-11 14:40:15 +00:00
|
|
|
BasicIDE::BasicStopped();
|
|
|
|
|
|
|
|
// no error output during macro choosing
|
2011-08-24 11:13:33 +01:00
|
|
|
if ( BasicIDEGlobals::GetExtraData()->ChoosingMacro() )
|
2001-09-11 14:40:15 +00:00
|
|
|
return 1;
|
2011-08-24 11:13:33 +01:00
|
|
|
if ( BasicIDEGlobals::GetExtraData()->ShellInCriticalSection() )
|
2001-09-11 14:40:15 +00:00
|
|
|
return 2;
|
|
|
|
|
|
|
|
long nRet = 0;
|
2001-11-02 12:45:10 +00:00
|
|
|
BasicIDEShell* pIDEShell = 0;
|
2001-09-11 14:40:15 +00:00
|
|
|
if ( SvtModuleOptions().IsBasicIDE() )
|
|
|
|
{
|
2001-11-02 12:45:10 +00:00
|
|
|
BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
|
|
|
|
if ( pBasMgr )
|
2001-09-11 14:40:15 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bProtected = sal_False;
|
2007-03-15 14:54:47 +00:00
|
|
|
ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
|
|
|
|
OSL_ENSURE( aDocument.isValid(), "BasicIDE::HandleBasicError: no document for the given BasicManager!" );
|
|
|
|
if ( aDocument.isValid() )
|
2001-11-02 12:45:10 +00:00
|
|
|
{
|
2007-03-15 14:54:47 +00:00
|
|
|
::rtl::OUString aOULibName( pBasic->GetName() );
|
|
|
|
Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
|
|
|
|
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
|
2001-11-02 12:45:10 +00:00
|
|
|
{
|
2007-03-15 14:54:47 +00:00
|
|
|
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
|
|
|
|
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
bProtected = sal_True;
|
2007-03-15 14:54:47 +00:00
|
|
|
}
|
2001-11-02 12:45:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bProtected )
|
|
|
|
{
|
2011-08-24 11:13:33 +01:00
|
|
|
pIDEShell = BasicIDEGlobals::GetShell();
|
2001-11-02 12:45:10 +00:00
|
|
|
if ( !pIDEShell )
|
2001-09-11 14:40:15 +00:00
|
|
|
{
|
2004-10-04 18:39:44 +00:00
|
|
|
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();
|
2001-09-11 14:40:15 +00:00
|
|
|
}
|
2001-11-02 12:45:10 +00:00
|
|
|
}
|
2001-09-11 14:40:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-02 12:45:10 +00:00
|
|
|
if ( pIDEShell )
|
|
|
|
nRet = pIDEShell->CallBasicErrorHdl( pBasic );
|
2001-09-11 14:40:15 +00:00
|
|
|
else
|
|
|
|
ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
|
|
|
|
|
|
|
|
return nRet;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
SfxBindings* GetBindingsPtr()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2006-01-03 11:43:23 +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
|
|
|
}
|
2002-11-01 10:36:29 +00:00
|
|
|
else
|
2006-01-03 11:43:23 +00:00
|
|
|
{
|
|
|
|
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 )
|
2002-11-01 10:36:29 +00:00
|
|
|
pBindings = &pFrame->GetBindings();
|
2006-01-03 11:43:23 +00:00
|
|
|
|
2002-11-01 10:36:29 +00:00
|
|
|
return pBindings;
|
|
|
|
}
|
|
|
|
|
2008-07-07 11:20:17 +00:00
|
|
|
} //namespace BasicIDE
|
|
|
|
|
2001-06-22 13:45:11 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2010-10-12 15:57:08 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|