summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2022-10-08 09:07:53 -0400
committerJustin Luth <jluth@mail.com>2022-10-11 03:08:13 +0200
commiteaa38b0f9d672793af500222348a6cacd28910b0 (patch)
tree472b6de34fd2256bcf2871151aead5bde5689ac3 /vbahelper
parentebeb4ce43d04dbbd329f19210c0db86e2b1cf2a0 (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 'vbahelper')
-rw-r--r--vbahelper/source/vbahelper/vbaeventshelperbase.cxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
index cbe8ca79bad7..e9bd0f476f40 100644
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -369,8 +369,18 @@ VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( co
const EventHandlerInfo& rInfo = rEventInfo.second;
if( rInfo.mnModuleType == nModuleType )
{
+ // Only in Word, Auto* only runs if defined as Public, not Private.
+ const bool bOnlyPublic
+ = getImplementationName() == "SwVbaEventsHelper"
+ && (rInfo.mnEventId == css::script::vba::VBAEventId::DOCUMENT_AUTO_NEW
+ || rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_NEW
+ || rInfo.mnEventId == css::script::vba::VBAEventId::DOCUMENT_AUTO_OPEN
+ || rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_OPEN
+ || rInfo.mnEventId == css::script::vba::VBAEventId::DOCUMENT_AUTO_CLOSE
+ || rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_CLOSE);
+
OUString sName = resolveVBAMacro(mpShell, maLibraryName, rModuleName,
- rInfo.maMacroName);
+ rInfo.maMacroName, bOnlyPublic);
// Only in Word (with lowest priority), an Auto* module can execute a "Public Sub Main"
if (sName.isEmpty() && rModuleName.isEmpty()
&& getImplementationName() == "SwVbaEventsHelper")
@@ -379,7 +389,8 @@ VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( co
|| rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_OPEN
|| rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_CLOSE)
{
- sName = resolveVBAMacro(mpShell, maLibraryName, rInfo.maMacroName, "Main");
+ sName = resolveVBAMacro(mpShell, maLibraryName, rInfo.maMacroName, "Main",
+ bOnlyPublic);
}
}
rPathMap[rInfo.mnEventId] = sName;