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

231 lines
6.8 KiB
C++
Raw Normal View History

2000-09-29 10:02:42 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-29 10:02:42 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-29 10:02:42 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-29 10:02:42 +00:00
*
* This file is part of OpenOffice.org.
2000-09-29 10:02:42 +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
*
* 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
*
* 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
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_basctl.hxx"
2000-09-29 10:02:42 +00:00
#include <ide_pch.hxx>
#include <svheader.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/genlink.hxx>
#include <svl/solar.hrc>
2000-09-29 10:02:42 +00:00
#include <iderdll.hxx>
#include <iderdll2.hxx>
#include <iderid.hxx>
#include <svx/svxids.hrc>
#include <basidesh.hxx>
#include <basidesh.hrc>
#include <basobj.hxx>
#include <bastypes.hxx>
2001-07-20 09:49:36 +00:00
#include <basdoc.hxx>
#include <basicmod.hxx>
#include <propbrw.hxx>
2000-09-29 10:02:42 +00:00
#define ITEMID_SEARCH 0
2009-12-10 23:06:35 +01:00
#include <svl/srchitem.hxx>
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
using ::rtl::OUString;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
2001-07-20 09:49:36 +00:00
static BasicIDEDLL* pBasicIDEDLL = 0;
BasicIDEDLL* BasicIDEDLL::GetDLL()
2000-09-29 10:02:42 +00:00
{
2001-07-20 09:49:36 +00:00
return pBasicIDEDLL;
}
2000-09-29 10:02:42 +00:00
2001-07-20 09:49:36 +00:00
IDEResId::IDEResId( USHORT nId ):
ResId( nId, *(*(BasicIDEModule**)GetAppData(SHL_IDE))->GetResMgr() )
2001-07-20 09:49:36 +00:00
{
}
BasicIDEDLL::BasicIDEDLL()
{
pBasicIDEDLL = this;
2000-09-29 10:02:42 +00:00
pShell = 0;
pExtraData = 0;
2001-07-20 09:49:36 +00:00
2000-09-29 10:02:42 +00:00
GetExtraData(); // damit GlobalErrorHdl gesetzt wird.
}
BasicIDEDLL::~BasicIDEDLL()
{
delete pExtraData;
*(BasicIDEDLL**)GetAppData(SHL_IDE) = NULL;
}
2001-07-20 09:49:36 +00:00
void BasicIDEDLL::Init()
{
if ( pBasicIDEDLL )
return;
2001-07-20 09:49:36 +00:00
SfxObjectFactory* pFact = &BasicDocShell::Factory();
(void)pFact;
2001-07-20 09:49:36 +00:00
ByteString aResMgrName( "basctl" );
ResMgr* pMgr = ResMgr::CreateResMgr(
aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
2001-07-20 09:49:36 +00:00
BASIC_MOD() = new BasicIDEModule( pMgr, &BasicDocShell::Factory() );
2001-07-20 09:49:36 +00:00
new BasicIDEDLL;
SfxModule* pMod = BASIC_MOD();
SfxObjectFactory& rFactory = BasicDocShell::Factory();
rFactory.SetDocumentServiceName( String::CreateFromAscii( "com.sun.star.script.BasicIDE" ) );
2001-07-20 09:49:36 +00:00
BasicDocShell::RegisterInterface( pMod );
BasicIDEShell::RegisterFactory( SVX_INTERFACE_BASIDE_VIEWSH );
BasicIDEShell::RegisterInterface( pMod );
PropBrwMgr::RegisterChildWindow();
2001-07-20 09:49:36 +00:00
}
/*************************************************************************
|*
|* Deinitialisierung
|*
\************************************************************************/
void BasicIDEDLL::Exit()
{
// the BasicIDEModule must be destroyed
BasicIDEModule** ppShlPtr = (BasicIDEModule**) GetAppData(SHL_IDE);
delete (*ppShlPtr);
(*ppShlPtr) = NULL;
2001-07-20 09:49:36 +00:00
DELETEZ( pBasicIDEDLL );
}
2000-09-29 10:02:42 +00:00
BasicIDEData* BasicIDEDLL::GetExtraData()
{
if ( !pExtraData )
pExtraData = new BasicIDEData;
return pExtraData;
}
BasicIDEData::BasicIDEData() : aObjCatPos( INVPOSITION, INVPOSITION )
{
nBasicDialogCount = 0;
bChoosingMacro = FALSE;
bShellInCriticalSection = FALSE;
pSearchItem = new SvxSearchItem( SID_SEARCH_ITEM );
2000-09-29 10:02:42 +00:00
StarBASIC::SetGlobalBreakHdl( LINK( this, BasicIDEData, GlobalBasicBreakHdl ) );
pAccelerator = 0;
}
BasicIDEData::~BasicIDEData()
{
// ErrorHdl zuruecksetzen ist zwar sauberer, aber diese Instanz wird
// sowieso sehr spaet, nach dem letzten Basic, zerstoert.
// Durch den Aufruf werden dann aber wieder AppDaten erzeugt und nicht
// mehr zerstoert => MLK's beim Purify
// StarBASIC::SetGlobalErrorHdl( Link() );
// StarBASIC::SetGlobalBreakHdl( Link() );
// StarBASIC::setGlobalStarScriptListener( XEngineListenerRef() );
delete pSearchItem;
//delete pAccelerator;
2000-09-29 10:02:42 +00:00
}
SvxSearchItem& BasicIDEData::GetSearchItem() const
{
return *pSearchItem;
}
void BasicIDEData::SetSearchItem( const SvxSearchItem& rItem )
{
delete pSearchItem;
pSearchItem = (SvxSearchItem*)rItem.Clone();
}
IMPL_LINK( BasicIDEData, GlobalBasicBreakHdl, StarBASIC *, pBasic )
{
long nRet = 0;
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
if ( pIDEShell )
2000-09-29 10:02:42 +00:00
{
BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
if ( pBasMgr )
2000-09-29 10:02:42 +00:00
{
// Hier lande ich zweimal, wenn Step into protected Basic
// => schlecht, wenn Passwortabfrage 2x, ausserdem sieht man in
// dem PasswordDlg nicht, fuer welche Lib...
// => An dieser Stelle keine Passwort-Abfrage starten
ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
OSL_ENSURE( aDocument.isValid(), "BasicIDEData::GlobalBasicBreakHdl: no document for the basic manager!" );
if ( aDocument.isValid() )
2000-09-29 10:02:42 +00:00
{
::rtl::OUString aOULibName( pBasic->GetName() );
Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
{
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
{
// Ein Step-Out muesste mich aus den geschuetzten Bereich befoerdern...
nRet = SbDEBUG_STEPOUT;
}
else
{
nRet = pIDEShell->CallBasicBreakHdl( pBasic );
}
}
2000-09-29 10:02:42 +00:00
}
}
}
return nRet;
2000-09-29 10:02:42 +00:00
}
IMPL_LINK( BasicIDEData, ExecuteMacroEvent, void *, pData )
{
if ( pData )
{
SFX_APP()->EnterBasicCall();
SbMethod* pMethod = (SbMethod*)pData;
// Ist es eine StarScript-Methode? Am Parent erkennen
DBG_ASSERT( pMethod->GetParent()->GetFlags() & SBX_EXTSEARCH, "Kein EXTSEARCH!" );
BasicIDE::RunMethod( pMethod );
pMethod->ReleaseRef(); // muss vorher inkrementiert worden sein!
SFX_APP()->LeaveBasicCall();
}
return 0;
}