summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2022-10-08 12:15:35 -0400
committerJustin Luth <jluth@mail.com>2022-10-11 20:39:04 +0200
commitffc15725b58d0988b4e2ed836c5751223ad00984 (patch)
treefccc8fe6d1e38b9d12f5dca96e0f71a8d3a5bf82 /vbahelper
parentb320ef30977144c52de9b39bc4db0db540727c79 (diff)
tdf#148806 tdf#151393 xls vba: no Auto_Open from ThisWorksheet
Unlike Word, ThisWorksheet cannot hold auto-running subroutines for Open/Close/New. This fixes a LO 7.4 regression caused by commit beb6c62e990599d91ac5d9183164c94d269027d3. Change-Id: Idb8f72775d9392b306cb924ee776821272b12f3b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141127 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/source/vbahelper/vbaeventshelperbase.cxx25
1 files changed, 23 insertions, 2 deletions
diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
index e9bd0f476f40..7d6e1bbb6ea9 100644
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -364,11 +364,32 @@ VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( co
sal_Int32 nModuleType = getModuleType( rModuleName );
// search for all event handlers
ModulePathMap& rPathMap = maEventPaths[ rModuleName ];
+
+ // Use WORKBOOK_OPEN as a way to get the codename for ThisWorkbook
+ OUString sThisWorkbook;
+ if (getImplementationName() == "ScVbaEventsHelper")
+ {
+ EventHandlerInfo& rThisWorksheetInfo
+ = maEventInfos[css::script::vba::VBAEventId::WORKBOOK_OPEN];
+ css::uno::Sequence<css::uno::Any> aNoArgs;
+ sThisWorkbook = implGetDocumentModuleName(rThisWorksheetInfo, aNoArgs);
+ }
+
for( const auto& rEventInfo : maEventInfos )
{
const EventHandlerInfo& rInfo = rEventInfo.second;
if( rInfo.mnModuleType == nModuleType )
{
+ OUString sSkipModule;
+ // Only in Calc, ignore Auto_* in ThisWorkbook
+ if (getImplementationName() == "ScVbaEventsHelper"
+ && (rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_NEW
+ || rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_OPEN
+ || rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_CLOSE))
+ {
+ sSkipModule = sThisWorkbook;
+ }
+
// Only in Word, Auto* only runs if defined as Public, not Private.
const bool bOnlyPublic
= getImplementationName() == "SwVbaEventsHelper"
@@ -380,7 +401,7 @@ VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( co
|| rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_CLOSE);
OUString sName = resolveVBAMacro(mpShell, maLibraryName, rModuleName,
- rInfo.maMacroName, bOnlyPublic);
+ rInfo.maMacroName, bOnlyPublic, sSkipModule);
// Only in Word (with lowest priority), an Auto* module can execute a "Public Sub Main"
if (sName.isEmpty() && rModuleName.isEmpty()
&& getImplementationName() == "SwVbaEventsHelper")
@@ -390,7 +411,7 @@ VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( co
|| rInfo.mnEventId == css::script::vba::VBAEventId::AUTO_CLOSE)
{
sName = resolveVBAMacro(mpShell, maLibraryName, rInfo.maMacroName, "Main",
- bOnlyPublic);
+ bOnlyPublic, sSkipModule);
}
}
rPathMap[rInfo.mnEventId] = sName;