summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-01-31 15:46:30 +0900
committerTomaž Vajngerl <quikee@gmail.com>2022-02-01 02:13:24 +0100
commitbeb6c62e990599d91ac5d9183164c94d269027d3 (patch)
tree4dab11a9ce3614e615910a33638f694ce620b256 /filter
parentd140817428cdbb519efa496f578bf6c054c94361 (diff)
vba: fix registering shortcuts keys defined by the vba macros
On issue with registering was that the registering happened when the macro source was in the process to be read into the library, which is just a bit too early, because the macro wasn't found and not registered. Another issue was with searching for the macro method (hasMacro), which doesn't search the same when the module name is known and when it isn't. This was changed so we just iterate through the modules and call the same "FindMethod" method without any extra restrictions. Change-Id: I811cfcaca58e8dfa8bef6cf983a8aff2b60eba35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129196 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/msfilter/msvbahelper.cxx17
1 files changed, 7 insertions, 10 deletions
diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx
index ee40bede6bd4..60d842d0d87c 100644
--- a/filter/source/msfilter/msvbahelper.cxx
+++ b/filter/source/msfilter/msvbahelper.cxx
@@ -173,8 +173,6 @@ static SfxObjectShell* findShellForUrl( const OUString& sMacroURLOrPath )
// if sMod is empty, only standard modules will be searched (no class, document, form modules)
static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, OUString& sMod, const OUString& sMacro )
{
- bool bFound = false;
-
#if !HAVE_FEATURE_SCRIPTING
(void) pShell;
(void) sLibrary;
@@ -200,18 +198,17 @@ static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, O
SbModule* pModule = pBasic->FindModule( sMod );
if ( pModule && pModule->FindMethod( sMacro, SbxClassType::Method ))
{
- bFound = true;
+ return true;
}
}
- else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxClassType::Method ) ) )
+ else
{
- if( SbModule* pModule = pMethod->GetModule() )
+ for (auto const& rModuleRef : pBasic->GetModules())
{
- // when searching for a macro without module name, do not search in class/document/form modules
- if( pModule->GetModuleType() == script::ModuleType::NORMAL )
+ if (rModuleRef && rModuleRef->FindMethod(sMacro, SbxClassType::Method))
{
- sMod = pModule->GetName();
- bFound = true;
+ sMod = rModuleRef->GetName();
+ return true;
}
}
}
@@ -219,7 +216,7 @@ static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, O
}
}
#endif
- return bFound;
+ return false;
}
#endif