summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-08-07 17:37:11 +0100
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2019-08-28 22:25:40 +0200
commit35fe064a67b54b0680b4845477c9b8751edda160 (patch)
tree32f344c90c4cd7b8cc4b9fdd5135ddea88617eee /oox
parent4a4e0cb67eab422dffda6f3339031db5b62be77a (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/77387 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/ole/vbaproject.cxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index bba778658ae5..62ec72070b46 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& )
{