summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-08-07 17:37:11 +0100
committerAndras Timar <andras.timar@collabora.com>2019-09-05 12:32:33 +0200
commit2b802429df9ef3f802da269b29f9e872dc254c0f (patch)
tree663e21de9b7d9c940b91186ad01f0f12e3f7af5f /xmloff
parent4984dbdef324ebe709f03144ef2808dbef09ba83 (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 'xmloff')
-rw-r--r--xmloff/source/core/xmlimp.cxx14
-rw-r--r--xmloff/source/script/XMLEventImportHelper.cxx3
2 files changed, 15 insertions, 2 deletions
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 556e39299454..0c5437b93ad9 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -58,6 +58,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/extract.hxx>
#include <comphelper/documentconstants.hxx>
+#include <comphelper/documentinfo.hxx>
#include <comphelper/storagehelper.hxx>
#include <unotools/fontcvt.hxx>
#include <o3tl/make_unique.hxx>
@@ -398,7 +399,8 @@ SvXMLImport::SvXMLImport(
isFastContext( false ),
maNamespaceHandler( new SvXMLImportFastNamespaceHandler() ),
mbIsFormsSupported( true ),
- mbIsTableShapeSupported( false )
+ mbIsTableShapeSupported( false ),
+ mbNotifyMacroEventRead( false )
{
SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
InitCtor_();
@@ -2163,6 +2165,16 @@ void SvXMLImport::registerNamespaces()
}
}
+void SvXMLImport::NotifyMacroEventRead()
+{
+ if (mbNotifyMacroEventRead)
+ return;
+
+ comphelper::DocumentInfo::notifyMacroEventRead(mxModel);
+
+ mbNotifyMacroEventRead = true;
+}
+
SvXMLImportFastNamespaceHandler::SvXMLImportFastNamespaceHandler()
{
}
diff --git a/xmloff/source/script/XMLEventImportHelper.cxx b/xmloff/source/script/XMLEventImportHelper.cxx
index 26048e86bacf..92e79af02433 100644
--- a/xmloff/source/script/XMLEventImportHelper.cxx
+++ b/xmloff/source/script/XMLEventImportHelper.cxx
@@ -36,7 +36,6 @@ XMLEventImportHelper::XMLEventImportHelper() :
{
}
-
XMLEventImportHelper::~XMLEventImportHelper()
{
// delete factories
@@ -107,6 +106,8 @@ SvXMLImportContext* XMLEventImportHelper::CreateContext(
const OUString& rXmlEventName,
const OUString& rLanguage)
{
+ rImport.NotifyMacroEventRead();
+
SvXMLImportContext* pContext = nullptr;
// translate event name form xml to api