diff options
author | Thorsten Behrens <tbehrens@novell.com> | 2011-04-28 00:12:58 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-04-28 00:12:58 +0200 |
commit | f51c3f66b1034c9f15171678d1239c25d64341ba (patch) | |
tree | 438eb4b3d4da31d276dcb227da6afce76e165f00 /basic/source/classes/sbxmod.cxx | |
parent | b8502c8251b0760f1bf03c968974f1fe3f288ae2 (diff) | |
parent | 86e7ed8c72184b7a04b836848743979aa3f5fd3d (diff) |
Merge commit 'ooo/DEV300_m106' into integration/dev300_m106
Conflicts:
avmedia/source/gstreamer/gstframegrabber.cxx
avmedia/source/gstreamer/gstplayer.cxx
avmedia/source/gstreamer/gstplayer.hxx
basic/inc/basic/sbxdef.hxx
basic/source/classes/sbxmod.cxx
basic/source/comp/makefile.mk
basic/source/comp/sbcomp.cxx
basic/source/inc/namecont.hxx
basic/source/inc/scriptcont.hxx
basic/source/runtime/methods.cxx
basic/source/runtime/runtime.cxx
basic/source/runtime/stdobj.cxx
basic/source/runtime/step1.cxx
basic/source/uno/namecont.cxx
basic/util/makefile.mk
connectivity/source/commontools/predicateinput.cxx
connectivity/source/drivers/dbase/DNoException.cxx
connectivity/source/drivers/dbase/DTable.cxx
connectivity/source/drivers/file/fcomp.cxx
connectivity/source/drivers/jdbc/JConnection.cxx
connectivity/source/drivers/odbcbase/OResultSet.cxx
connectivity/source/drivers/odbcbase/OStatement.cxx
connectivity/source/parse/sqlnode.cxx
desktop/source/app/app.cxx
drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
drawinglayer/source/processor2d/vclprocessor2d.cxx
formula/inc/formula/token.hxx
formula/source/core/api/token.cxx
fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
fpicker/source/win32/filepicker/platform_vista.h
framework/source/helper/persistentwindowstate.cxx
framework/source/uielement/menubarmanager.cxx
oovbaapi/ooo/vba/XFoundFiles.idl
oovbaapi/ooo/vba/excel/XApplication.idl
oovbaapi/ooo/vba/msforms/XCheckBox.idl
oovbaapi/ooo/vba/msforms/XComboBox.idl
oovbaapi/ooo/vba/msforms/XControl.idl
oovbaapi/ooo/vba/msforms/XGroupBox.idl
oovbaapi/ooo/vba/msforms/XLabel.idl
oovbaapi/ooo/vba/msforms/XListBox.idl
oovbaapi/ooo/vba/msforms/XNewFont.idl
oovbaapi/ooo/vba/msforms/XRadioButton.idl
oovbaapi/ooo/vba/msforms/XTextBox.idl
oovbaapi/ooo/vba/msforms/XToggleButton.idl
scripting/source/dlgprov/dlgevtatt.cxx
sfx2/source/control/unoctitm.cxx
sfx2/source/doc/objstor.cxx
sfx2/source/doc/objxtor.cxx
svx/inc/svx/svdograf.hxx
svx/source/form/fmpage.cxx
svx/source/form/fmpgeimp.cxx
svx/source/svdraw/svdedtv.cxx
svx/source/svdraw/svdfmtf.cxx
svx/source/svdraw/svdograf.cxx
svx/source/svdraw/svdouno.cxx
svx/source/xml/xmlgrhlp.cxx
uui/source/iahndl-ssl.cxx
vbahelper/Library_msforms.mk
vbahelper/Library_vbahelper.mk
vbahelper/inc/vbahelper/vbahelper.hxx
vbahelper/prj/build.lst
vbahelper/source/msforms/vbacombobox.cxx
vbahelper/source/msforms/vbacontrol.cxx
vbahelper/source/msforms/vbacontrols.cxx
vbahelper/source/msforms/vbaframe.cxx
vbahelper/source/msforms/vbaframe.hxx
vbahelper/source/msforms/vbalabel.cxx
vbahelper/source/msforms/vbalabel.hxx
vbahelper/source/msforms/vbalistbox.cxx
vbahelper/source/msforms/vbalistbox.hxx
vbahelper/source/msforms/vbamultipage.cxx
vbahelper/source/msforms/vbatogglebutton.cxx
vbahelper/source/msforms/vbauserform.cxx
vbahelper/source/vbahelper/vbacommandbar.cxx
vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
vbahelper/source/vbahelper/vbahelper.cxx
vbahelper/source/vbahelper/vbawindowbase.cxx
xmloff/source/meta/xmlmetai.cxx
xmloff/source/style/PageMasterExportPropMapper.cxx
xmloff/source/style/PageMasterStyleMap.cxx
xmloff/source/text/txtexppr.cxx
xmloff/source/text/txtprmap.cxx
Diffstat (limited to 'basic/source/classes/sbxmod.cxx')
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 119 |
1 files changed, 93 insertions, 26 deletions
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 7e7304b6ce76..55460638e9b7 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -59,6 +59,7 @@ #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <com/sun/star/document/XVbaMethodParameter.hpp> +#include <com/sun/star/script/vba/VBAScriptEventId.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/document/XEventBroadcaster.hpp> #include <com/sun/star/document/XEventListener.hpp> @@ -86,10 +87,9 @@ using namespace com::sun::star; #include <cppuhelper/implbase1.hxx> #include <basic/sbobjmod.hxx> #include <com/sun/star/uno/XAggregation.hpp> -#include <map> #include <com/sun/star/script/XInvocation.hpp> - using namespace ::com::sun::star; +using namespace ::com::sun::star; using namespace com::sun::star::lang; using namespace com::sun::star::reflection; using namespace com::sun::star::beans; @@ -105,6 +105,7 @@ using namespace com::sun::star::script; #include <cppuhelper/implbase1.hxx> #include <comphelper/anytostring.hxx> #include <com/sun/star/beans/XPropertySet.hpp> +#include <ooo/vba/VbQueryClose.hpp> typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE; typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; @@ -448,24 +449,36 @@ TYPEINIT1(SbUserFormModule,SbObjModule) typedef std::vector<HighlightPortion> HighlightPortions; -bool getDefaultVBAMode( StarBASIC* pb ) +uno::Reference< frame::XModel > getDocumentModel( StarBASIC* pb ) { - bool bResult = false; - if ( pb && pb->IsDocBasic() ) + uno::Reference< frame::XModel > xModel; + if( pb && pb->IsDocBasic() ) { uno::Any aDoc; - if ( pb->GetUNOConstant( "ThisComponent", aDoc ) ) - { - uno::Reference< beans::XPropertySet > xProp( aDoc, uno::UNO_QUERY ); - if ( xProp.is() ) - { - uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY ); - if ( xVBAMode.is() ) - bResult = xVBAMode->getVBACompatibilityMode() == sal_True; - } - } + if( pb->GetUNOConstant( "ThisComponent", aDoc ) ) + xModel.set( aDoc, uno::UNO_QUERY ); + } + return xModel; +} + +uno::Reference< vba::XVBACompatibility > getVBACompatibility( const uno::Reference< frame::XModel >& rxModel ) +{ + uno::Reference< vba::XVBACompatibility > xVBACompat; + try + { + uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW ); + xVBACompat.set( xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY ); + } + catch( uno::Exception& ) + { } - return bResult; + return xVBACompat; +} + +bool getDefaultVBAMode( StarBASIC* pb ) +{ + uno::Reference< vba::XVBACompatibility > xVBACompat = getVBACompatibility( getDocumentModel( pb ) ); + return xVBACompat.is() && xVBACompat->getVBACompatibilityMode(); } class AsyncQuitHandler @@ -512,7 +525,6 @@ void VBAUnlockDocuments( StarBASIC* pBasic ) } } - // A Basic module has set EXTSEARCH, so that the elements, that the modul contains, // could be found from other module. @@ -903,7 +915,7 @@ void SbModule::SetSource( const String& r ) void SbModule::SetSource32( const ::rtl::OUString& r ) { // Default basic mode to library container mode, but.. allow Option VBASupport 0/1 override - SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) ); + SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) ); aOUSource = r; StartDefinitions(); SbiTokenizer aTok( r ); @@ -1104,6 +1116,8 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) sal_Bool bDelInst = sal_Bool( pINST == NULL ); bool bQuit = false; StarBASICRef xBasic; + uno::Reference< frame::XModel > xModel; + uno::Reference< script::vba::XVBACompatibility > xVBACompat; if( bDelInst ) { // #32779: Hold Basic during the execution @@ -1111,6 +1125,46 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) pINST = new SbiInstance( (StarBASIC*) GetParent() ); + /* If a VBA script in a document is started, get the VBA compatibility + interface from the document Basic library container, and notify all + VBA script listeners about the started script. */ + if( mbVBACompat ) + { + StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() ); + if( pBasic && pBasic->IsDocBasic() ) try + { + xModel.set( getDocumentModel( pBasic ), uno::UNO_SET_THROW ); + xVBACompat.set( getVBACompatibility( xModel ), uno::UNO_SET_THROW ); + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STARTED, GetName() ); + } + catch( uno::Exception& ) + { + } + } + + // Launcher problem + // i80726 The Find below will genarate an error in Testtool so we reset it unless there was one before already + sal_Bool bWasError = SbxBase::GetError() != 0; + SbxVariable* pMSOMacroRuntimeLibVar = Find( aMSOMacroRuntimeLibName, SbxCLASS_OBJECT ); + if ( !bWasError && (SbxBase::GetError() == SbxERR_PROC_UNDEFINED) ) + SbxBase::ResetError(); + if( pMSOMacroRuntimeLibVar ) + { + StarBASIC* pMSOMacroRuntimeLib = PTR_CAST(StarBASIC,pMSOMacroRuntimeLibVar); + if( pMSOMacroRuntimeLib ) + { + sal_uInt16 nGblFlag = pMSOMacroRuntimeLib->GetFlags() & SBX_GBLSEARCH; + pMSOMacroRuntimeLib->ResetFlag( SBX_GBLSEARCH ); + SbxVariable* pAppSymbol = pMSOMacroRuntimeLib->Find( aMSOMacroRuntimeAppSymbol, SbxCLASS_METHOD ); + pMSOMacroRuntimeLib->SetFlag( nGblFlag ); + if( pAppSymbol ) + { + pMSOMacroRuntimeLib->SetFlag( SBX_EXTSEARCH ); // Could have been disabled before + GetSbData()->pMSOMacroRuntimLib = pMSOMacroRuntimeLib; + } + } + } + // Delete the Error-Stack SbErrorStack*& rErrStack = GetSbData()->pErrStack; delete rErrStack; @@ -1220,9 +1274,20 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) ResetCapturedAssertions(); #endif - // VBA always ensures screenupdating is enabled after completing - if ( mbVBACompat ) - VBAUnlockDocuments( PTR_CAST( StarBASIC, GetParent() ) ); + if( xVBACompat.is() ) + { + // notify all VBA script listeners about the stopped script + try + { + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STOPPED, GetName() ); + } + catch( uno::Exception& ) + { + } + // VBA always ensures screenupdating is enabled after completing + ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False ); + ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True ); + } #ifdef DBG_TRACE_BASIC dbg_DeInitTrace(); @@ -2320,7 +2385,7 @@ public: if ( xVbaMethodParameter.is() ) { sal_Int8 nCancel = 0; - sal_Int8 nCloseMode = 0; + sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormControlMenu; Sequence< Any > aParams; aParams.realloc(2); @@ -2445,14 +2510,14 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun ) Sequence< Any > aArguments; triggerMethod( aMethodToRun, aArguments ); } -void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments) + +void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments ) { OSL_TRACE("*** trigger %s ***", rtl::OUStringToOString( aMethodToRun, RTL_TEXTENCODING_UTF8 ).getStr() ); // Search method SbxVariable* pMeth = SbObjModule::Find( aMethodToRun, SbxCLASS_METHOD ); if( pMeth ) { - if ( aArguments.getLength() > 0 ) // Setup parameters { SbxArrayRef xArray = new SbxArray; @@ -2480,7 +2545,6 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any pMeth->SetParameters( NULL ); } else - { SbxValues aVals; pMeth->Get( aVals ); @@ -2572,7 +2636,7 @@ void SbUserFormModule::Unload() OSL_TRACE("** Unload() "); sal_Int8 nCancel = 0; - sal_Int8 nCloseMode = 1; + sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormCode; Sequence< Any > aParams; aParams.realloc(2); @@ -2628,6 +2692,9 @@ void SbUserFormModule::InitObject() SbUnoObject* pGlobs = (SbUnoObject*)GetParent()->Find( aHook, SbxCLASS_DONTCARE ); if ( m_xModel.is() && pGlobs ) { + // broadcast INITIALIZE_USERFORM script event before the dialog is created + Reference< script::vba::XVBACompatibility > xVBACompat( getVBACompatibility( m_xModel ), uno::UNO_SET_THROW ); + xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::INITIALIZE_USERFORM, GetName() ); uno::Reference< lang::XMultiServiceFactory > xVBAFactory( pGlobs->getUnoAny(), uno::UNO_QUERY_THROW ); uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); |