diff options
author | Mikhail Voytenko <mav@openoffice.org> | 2010-09-07 18:00:19 +0200 |
---|---|---|
committer | Mikhail Voytenko <mav@openoffice.org> | 2010-09-07 18:00:19 +0200 |
commit | d4aca024ba8ff204cebe7e917064d8b204a3795b (patch) | |
tree | 166d7604efe1c956adf2ee7ed1754a21442f27fe /vbahelper | |
parent | edcda911555753034afb2175a0c1a8b09f0e8210 (diff) |
mib19: #163433# let Application::Run find the correct document
Diffstat (limited to 'vbahelper')
-rw-r--r-- | vbahelper/source/vbahelper/vbaapplicationbase.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 8b0a52682ac0..cf6d655ff353 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -298,7 +298,20 @@ void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const u ::rtl::OUString aMacroName = MacroName.trim(); if (0 == aMacroName.indexOf('!')) aMacroName = aMacroName.copy(1).trim(); - VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( getCurrentDocument() ), aMacroName ); + + uno::Reference< frame::XModel > xModel; + SbMethod* pMeth = StarBASIC::GetActiveMethod(); + if ( pMeth ) + { + SbModule* pMod = dynamic_cast< SbModule* >( pMeth->GetParent() ); + if ( pMod ) + xModel = StarBASIC::GetModelFromBasic( pMod ); + } + + if ( !xModel.is() ) + xModel = getCurrentDocument(); + + VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( xModel ), aMacroName ); if( aMacroInfo.IsResolved() ) { // handle the arguments |