diff options
author | Justin Luth <justin.luth@collabora.com> | 2022-10-08 09:07:53 -0400 |
---|---|---|
committer | Justin Luth <jluth@mail.com> | 2022-10-11 03:08:13 +0200 |
commit | eaa38b0f9d672793af500222348a6cacd28910b0 (patch) | |
tree | 472b6de34fd2256bcf2871151aead5bde5689ac3 /filter | |
parent | ebeb4ce43d04dbbd329f19210c0db86e2b1cf2a0 (diff) |
tdf#148806 doc vba: only autoOpen PUBLIC macros
Note: this should NOT apply to Document_Open which normally
is a private subroutine and runs fine as private.
I tested and it DOES apply to all three version of AutoOpen:
-ThisDocument.AutoOpen,
-<AnyModule>.AutoOpen,
-AutoOpen.Main
Note: this is different from Excel.
Private Auto_Open runs just fine there.
Change-Id: If10c8c90c35275c2b14dc2e15fb357674fc580b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141114
Tested-by: Justin Luth <jluth@mail.com>
Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/msfilter/msvbahelper.cxx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 674530d1cbb1..a4e954531155 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -171,13 +171,15 @@ static SfxObjectShell* findShellForUrl( const OUString& sMacroURLOrPath ) // sMod can be empty ( but we really need the library to search in ) // if sMod is empty and a macro is found then sMod is updated // 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 ) +static bool hasMacro(SfxObjectShell const* pShell, const OUString& sLibrary, OUString& sMod, + const OUString& sMacro, bool bOnlyPublic) { #if !HAVE_FEATURE_SCRIPTING (void) pShell; (void) sLibrary; (void) sMod; (void) sMacro; + (void) bOnlyPublic; #else if (sLibrary.isEmpty() || sMacro.isEmpty()) return false; @@ -202,7 +204,7 @@ static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, O if (!pModule) return false; SbMethod* pMeth = pModule->FindMethod(sMacro, SbxClassType::Method); - return pMeth; + return pMeth && (!bOnlyPublic || !pMeth->IsSet(SbxFlagBits::Private)); } for (auto const& rModuleRef : pBasic->GetModules()) @@ -210,6 +212,8 @@ static bool hasMacro( SfxObjectShell const * pShell, const OUString& sLibrary, O SbMethod* pMeth = rModuleRef->FindMethod(sMacro, SbxClassType::Method); if (pMeth) { + if (bOnlyPublic && pMeth->IsSet(SbxFlagBits::Private)) + continue; sMod = rModuleRef->GetName(); return true; } @@ -257,7 +261,9 @@ static void parseMacro( const OUString& sMacro, OUString& sContainer, OUString& #endif -OUString resolveVBAMacro( SfxObjectShell const * pShell, const OUString& rLibName, const OUString& rModuleName, const OUString& rMacroName ) +OUString resolveVBAMacro(SfxObjectShell const* pShell, const OUString& rLibName, + const OUString& rModuleName, const OUString& rMacroName, + bool bOnlyPublic) { #if !HAVE_FEATURE_SCRIPTING (void) pShell; @@ -269,7 +275,7 @@ OUString resolveVBAMacro( SfxObjectShell const * pShell, const OUString& rLibNam { OUString aLibName = rLibName.isEmpty() ? getDefaultProjectName( pShell ) : rLibName ; OUString aModuleName = rModuleName; - if( hasMacro( pShell, aLibName, aModuleName, rMacroName ) ) + if (hasMacro( pShell, aLibName, aModuleName, rMacroName, bOnlyPublic)) return aLibName + "." + aModuleName + "." + rMacroName; } #endif @@ -440,7 +446,7 @@ MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const OUString& Macro for (auto const& search : sSearchList) { - aRes.mbFound = hasMacro( pShell, search, sModule, sProcedure ); + aRes.mbFound = hasMacro(pShell, search, sModule, sProcedure, /*bOnlyPublic=*/false); if ( aRes.mbFound ) { sContainer = search; |