diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-08-07 17:37:11 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-08-13 13:26:15 +0200 |
commit | b3edf85e0fe6ca03dc26e1bf531be82193bc9627 (patch) | |
tree | 62887e38b2f0b06ca8e74fffd126560b5b0c8049 /oox | |
parent | c78dd0a726b32d922a0d75a26a51d4c30612368c (diff) |
warn on load when a document binds an event to a macro
a) treat shared/Scripts equivalently to document scripts
This doesn't automatically warn/block running those scripts when used in a
freshly loaded document on its own however
because DocumentMacroMode::checkMacrosOnLoading will see at...
if ( m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() )
that the document contains no macros and flip the allow macros flag to true so
that potentially new uses of macros added by the user during the edit are
allowed to run
b) so, add an additional flag to indicate existence of use of macros in a document
c) for odf import, set it when a script:event-listener tag is encountered
d) for html import when registerScriptEvents or SwFormatINetFormat::SetMacroTable is called
e) for doc import when Read_F_Macro or StoreMacroCmds is called as well for good measure
f) for xls import when registerScriptEvent or ScMacroInfo::SetMacro is called
g) for oox import when VbaProject::attachMacros is called
Change-Id: Ic1203d8ec7dfc217aa217135033ae9db2888e19b
Reviewed-on: https://gerrit.libreoffice.org/77131
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/ole/vbaproject.cxx | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx index db8de0abf9c3..7cafeba3554a 100644 --- a/oox/source/ole/vbaproject.cxx +++ b/oox/source/ole/vbaproject.cxx @@ -31,6 +31,7 @@ #include <com/sun/star/script/vba/XVBAMacroResolver.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <comphelper/configurationhelper.hxx> +#include <comphelper/documentinfo.hxx> #include <comphelper/storagehelper.hxx> #include <osl/diagnose.h> #include <rtl/tencinfo.h> @@ -515,6 +516,8 @@ void VbaProject::attachMacros() { if( !maMacroAttachers.empty() && mxContext.is() ) try { + comphelper::DocumentInfo::notifyMacroEventRead(mxDocModel); + Reference< XMultiComponentFactory > xFactory( mxContext->getServiceManager(), UNO_SET_THROW ); Sequence< Any > aArgs( 2 ); aArgs[ 0 ] <<= mxDocModel; @@ -522,6 +525,7 @@ void VbaProject::attachMacros() Reference< XVBAMacroResolver > xResolver( xFactory->createInstanceWithArgumentsAndContext( "com.sun.star.script.vba.VBAMacroResolver", aArgs, mxContext ), UNO_QUERY_THROW ); maMacroAttachers.forEachMem( &VbaMacroAttacherBase::resolveAndAttachMacro, ::std::cref( xResolver ) ); + } catch(const Exception& ) { |