summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2022-10-07 19:35:59 -0400
committerJustin Luth <jluth@mail.com>2022-10-09 01:07:23 +0200
commite2abb5bbc03cca884fa89345003d013688f0d94d (patch)
tree1b782dab4003cd4f8b413a53313d1fff8fd55823 /vbahelper
parent1754b02e6acd5d0c03bdcf46151d166a07806506 (diff)
tdf#148806 doc vba: accept module AutoOpen.Main
This is the lowest priority way of running AutoOpen, and it only applies to Word, not Excel. There is some code in basic/source/classes/sb.cxx that was somewhat finding this before it got lost in LO 7.4 with commit beb6c62e990599d91ac5d9183164c94d269027d3. TODO: these AutoOpens should only run with a public sub, not a private one. Change-Id: I8a733cde13f96636942d84a0b05520692aac3e52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141094 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/source/vbahelper/vbaeventshelperbase.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
index dbd345c9bac7..cbe8ca79bad7 100644
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/document/XEventBroadcaster.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/script/ModuleType.hpp>
+#include <com/sun/star/script/vba/VBAEventId.hpp>
#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
#include <com/sun/star/script/XLibraryContainer.hpp>
#include <com/sun/star/util/VetoException.hpp>
@@ -367,7 +368,22 @@ VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( co
{
const EventHandlerInfo& rInfo = rEventInfo.second;
if( rInfo.mnModuleType == nModuleType )
- rPathMap[ rInfo.mnEventId ] = resolveVBAMacro( mpShell, maLibraryName, rModuleName, rInfo.maMacroName );
+ {
+ OUString sName = resolveVBAMacro(mpShell, maLibraryName, rModuleName,
+ rInfo.maMacroName);
+ // Only in Word (with lowest priority), an Auto* module can execute a "Public Sub Main"
+ if (sName.isEmpty() && rModuleName.isEmpty()
+ && getImplementationName() == "SwVbaEventsHelper")
+ {
+ if (rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_NEW
+ || rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_OPEN
+ || rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_CLOSE)
+ {
+ sName = resolveVBAMacro(mpShell, maLibraryName, rInfo.maMacroName, "Main");
+ }
+ }
+ rPathMap[rInfo.mnEventId] = sName;
+ }
}
return rPathMap;
}