filter/source/msfilter/msvbahelper.cxx | 63 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 32 deletions(-)
New commits: commit d72571fdd47c627efcd0dff92fbe8a9747f92932 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Sat Oct 8 08:36:57 2022 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Sun Oct 9 01:10:59 2022 +0200 related tdf#148806 flatten filter/source/msfilter/msvbahelper.cxx I don't like mixing big formatting changes with logic changes. Change-Id: Id2dbdfd751ac86918fe39d6627aa9ce15c794323 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141113 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 95144adb6094..674530d1cbb1 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -179,40 +179,39 @@ static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, O (void) sMod; (void) sMacro; #else - if ( !sLibrary.isEmpty() && !sMacro.isEmpty() ) + if (sLibrary.isEmpty() || sMacro.isEmpty()) + return false; + + BasicManager* pBasicMgr = pShell->GetBasicManager(); + if (!pBasicMgr) + return false; + + StarBASIC* pBasic = pBasicMgr->GetLib(sLibrary); + if (!pBasic) + { + sal_uInt16 nId = pBasicMgr->GetLibId(sLibrary); + pBasicMgr->LoadLib(nId); + pBasic = pBasicMgr->GetLib(sLibrary); + } + if (!pBasic) + return false; + + if (!sMod.isEmpty()) // we wish to find the macro is a specific module + { + SbModule* pModule = pBasic->FindModule(sMod); + if (!pModule) + return false; + SbMethod* pMeth = pModule->FindMethod(sMacro, SbxClassType::Method); + return pMeth; + } + + for (auto const& rModuleRef : pBasic->GetModules()) { - BasicManager* pBasicMgr = pShell-> GetBasicManager(); - if ( pBasicMgr ) + SbMethod* pMeth = rModuleRef->FindMethod(sMacro, SbxClassType::Method); + if (pMeth) { - StarBASIC* pBasic = pBasicMgr->GetLib( sLibrary ); - if ( !pBasic ) - { - sal_uInt16 nId = pBasicMgr->GetLibId( sLibrary ); - pBasicMgr->LoadLib( nId ); - pBasic = pBasicMgr->GetLib( sLibrary ); - } - if ( pBasic ) - { - if ( !sMod.isEmpty() ) // we wish to find the macro is a specific module - { - SbModule* pModule = pBasic->FindModule( sMod ); - if ( pModule && pModule->FindMethod( sMacro, SbxClassType::Method )) - { - return true; - } - } - else - { - for (auto const& rModuleRef : pBasic->GetModules()) - { - if (rModuleRef && rModuleRef->FindMethod(sMacro, SbxClassType::Method)) - { - sMod = rModuleRef->GetName(); - return true; - } - } - } - } + sMod = rModuleRef->GetName(); + return true; } } #endif