summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vbahelper/vbaeventshelperbase.hxx2
-rw-r--r--sc/source/ui/vba/vbaeventshelper.cxx5
-rw-r--r--vbahelper/source/vbahelper/vbaeventshelperbase.cxx17
3 files changed, 22 insertions, 2 deletions
diff --git a/include/vbahelper/vbaeventshelperbase.hxx b/include/vbahelper/vbaeventshelperbase.hxx
index 0126db442ee8..e7038da7ab75 100644
--- a/include/vbahelper/vbaeventshelperbase.hxx
+++ b/include/vbahelper/vbaeventshelperbase.hxx
@@ -78,6 +78,8 @@ public:
// little helpers ---------------------------------------------------------
+ bool hasModule(const OUString& rModuleName);
+
/** Helper to execute event handlers without throwing any exceptions. */
void processVbaEventNoThrow( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs );
diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx
index bd00fdcac3bd..d412af36b466 100644
--- a/sc/source/ui/vba/vbaeventshelper.cxx
+++ b/sc/source/ui/vba/vbaeventshelper.cxx
@@ -659,7 +659,8 @@ bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue,
rEventQueue.emplace_back(WORKBOOK_ACTIVATE );
uno::Sequence< uno::Any > aArgs{ uno::Any(mxModel->getCurrentController()) };
rEventQueue.emplace_back( WORKBOOK_WINDOWACTIVATE, aArgs );
- rEventQueue.emplace_back(AUTO_OPEN );
+ if (!hasModule("Auto_Open"))
+ rEventQueue.emplace_back(AUTO_OPEN );
// remember initial selection
maOldSelection <<= mxModel->getCurrentSelection();
}
@@ -779,7 +780,7 @@ void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue,
case WORKBOOK_BEFORECLOSE:
/* Execute Auto_Close only if not cancelled by event handler, but
before UI asks user whether to cancel closing the document. */
- if( !bCancel )
+ if (!bCancel && !hasModule("Auto_Close"))
rEventQueue.emplace_back(AUTO_CLOSE );
break;
}
diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
index 1f92e449a156..dbd345c9bac7 100644
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -320,6 +320,23 @@ void VbaEventsHelperBase::ensureVBALibrary()
}
}
+bool VbaEventsHelperBase::hasModule(const OUString& rModuleName)
+{
+ if (rModuleName.isEmpty())
+ return false;
+
+ bool bRet = false;
+ try
+ {
+ ensureVBALibrary();
+ bRet = mxModuleInfos->hasModuleInfo(rModuleName);
+ }
+ catch (uno::Exception&)
+ {}
+
+ return bRet;
+}
+
sal_Int32 VbaEventsHelperBase::getModuleType( const OUString& rModuleName )
{
// make sure the VBA library exists