diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-08-07 17:37:11 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-05-05 12:35:38 +0200 |
commit | a38c13bc7c5cabdc1db7124d40b6f54e3b500f9c (patch) | |
tree | 69213c689b4482e9e1a32aee7d3b4670b0543ef6 /include | |
parent | 0b6d22adbc1d811ab7c691bc929905d7267732c2 (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
Reviewed-on: https://gerrit.libreoffice.org/77387
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
(cherry picked from commit 35fe064a67b54b0680b4845477c9b8751edda160)
Change-Id: Ic1203d8ec7dfc217aa217135033ae9db2888e19b
Diffstat (limited to 'include')
-rw-r--r-- | include/comphelper/documentinfo.hxx | 5 | ||||
-rw-r--r-- | include/oox/ole/axcontrol.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/docmacromode.hxx | 7 | ||||
-rw-r--r-- | include/sfx2/objsh.hxx | 3 | ||||
-rw-r--r-- | include/xmloff/xmlimp.hxx | 3 |
5 files changed, 19 insertions, 1 deletions
diff --git a/include/comphelper/documentinfo.hxx b/include/comphelper/documentinfo.hxx index c30d79b40c95..e9c2b153885a 100644 --- a/include/comphelper/documentinfo.hxx +++ b/include/comphelper/documentinfo.hxx @@ -35,8 +35,11 @@ namespace comphelper { /** retrieves the UI title of the given document */ COMPHELPER_DLLPUBLIC OUString getDocumentTitle( const css::uno::Reference< css::frame::XModel >& _rxDocument ); - } + /** notify that this document contains a macro event handler + */ + COMPHELPER_DLLPUBLIC void notifyMacroEventRead( const css::uno::Reference< css::frame::XModel >& _rxDocument ); + } } // namespace comphelper diff --git a/include/oox/ole/axcontrol.hxx b/include/oox/ole/axcontrol.hxx index a932a7bcfcd2..434c0c43c49b 100644 --- a/include/oox/ole/axcontrol.hxx +++ b/include/oox/ole/axcontrol.hxx @@ -334,6 +334,8 @@ public: PropertySet const & rPropSet, sal_Int32& nOrientation ); + const css::uno::Reference<css::frame::XModel> GetDocModel() const { return mxDocModel; } + private: css::uno::Reference< css::frame::XModel > mxDocModel; const GraphicHelper& mrGraphicHelper; diff --git a/include/sfx2/docmacromode.hxx b/include/sfx2/docmacromode.hxx index f043e36a26d3..7e1511625086 100644 --- a/include/sfx2/docmacromode.hxx +++ b/include/sfx2/docmacromode.hxx @@ -111,6 +111,12 @@ namespace sfx2 virtual bool documentStorageHasMacros() const = 0; + /** checks whether the document's contained calls to macros or scripts after loading + + */ + virtual bool + macroCallsSeenWhileLoading() const = 0; + /** provides access to the XEmbeddedScripts interface of the document Implementations are allowed to return <NULL/> here if and only if they @@ -272,6 +278,7 @@ namespace sfx2 @see isMacroExecutionDisallowed @see IMacroDocumentAccess::documentStorageHasMacros + @see IMacroDocumentAccess::macroCallsSeenWhileLoading @see hasMacroLibrary @see IMacroDocumentAccess::checkForBrokenScriptingSignatures */ diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index ed09fc6e2acb..83033e57ed70 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -426,6 +426,9 @@ public: sal_uInt32 GetModifyPasswordHash() const; bool SetModifyPasswordHash( sal_uInt32 nHash ); + void SetMacroCallsSeenWhileLoading(); + bool GetMacroCallsSeenWhileLoading() const; + const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const; bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo ); diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index f213f21cd2fa..cfdd00bb0455 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -241,6 +241,7 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper< protected: bool mbIsFormsSupported; bool mbIsTableShapeSupported; + bool mbNotifyMacroEventRead; // Create top-level element context. // This method is called after the namespace map has been updated, but @@ -577,6 +578,8 @@ public: bool embeddedFontAlreadyProcessed( const OUString& url ); virtual void NotifyEmbeddedFontRead() {}; + // something referencing a macro/script was imported + void NotifyMacroEventRead(); bool needFixPositionAfterZ() const; }; |