diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-01-18 15:24:48 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-01-29 23:43:22 +0100 |
commit | 7df8b437b721b25561995346abfb55dca0d500b5 (patch) | |
tree | 08af82986feb44492bce67f5db9fe6dc653efdd5 /sfx2/source/doc/docmacromode.cxx | |
parent | e6a367b07f23810c649804145a03ef4a16751773 (diff) |
Improve macro checks
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109552
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
(cherry picked from commit 1dc71daf7fa7204a98c75dac680af664ab9c8edb)
Change-Id: Ie40801df8866b52c1458e020ffa9cba120720af7
Diffstat (limited to 'sfx2/source/doc/docmacromode.cxx')
-rw-r--r-- | sfx2/source/doc/docmacromode.cxx | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx index dc84f4e58598..4c27b767c80d 100644 --- a/sfx2/source/doc/docmacromode.cxx +++ b/sfx2/source/doc/docmacromode.cxx @@ -111,6 +111,10 @@ namespace sfx2 #endif } + void lcl_showMacrosDisabledUnsignedContentError( const Reference< XInteractionHandler >& rxHandler, bool& rbAlreadyShown ) + { + lcl_showGeneralSfxErrorOnce( rxHandler, ERRCODE_SFX_DOCUMENT_MACRO_DISABLED, rbAlreadyShown ); + } bool lcl_showMacroWarning( const Reference< XInteractionHandler >& rxHandler, const OUString& rDocumentLocation ) @@ -123,7 +127,8 @@ namespace sfx2 //= DocumentMacroMode DocumentMacroMode::DocumentMacroMode( IMacroDocumentAccess& rDocumentAccess ) - :m_xData( new DocumentMacroMode_Data( rDocumentAccess ) ) + :m_xData( new DocumentMacroMode_Data( rDocumentAccess ) ), + m_bNeedsContentSigned(false) { } @@ -139,7 +144,7 @@ namespace sfx2 return false; } - bool DocumentMacroMode::adjustMacroMode( const Reference< XInteractionHandler >& rxInteraction ) + bool DocumentMacroMode::adjustMacroMode( const Reference< XInteractionHandler >& rxInteraction, bool bHasValidContentSignature ) { sal_uInt16 nMacroExecutionMode = m_xData->m_rDocumentAccess.getCurrentMacroExecMode(); @@ -236,6 +241,14 @@ namespace sfx2 lcl_showDocumentMacrosDisabledError(rxInteraction, m_xData->m_bDocMacroDisabledMessageShown); return disallowMacroExecution(); } + else if ( m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading() && + bHasTrustedMacroSignature && + !bHasValidContentSignature) + { + // When macros are signed, and the document has events which call macros, the document content needs to be signed too. + lcl_showMacrosDisabledUnsignedContentError(rxInteraction, m_xData->m_bDocMacroDisabledMessageShown); + return disallowMacroExecution(); + } else if ( bHasTrustedMacroSignature ) { // there is trusted macro signature, allow macro execution @@ -395,7 +408,7 @@ namespace sfx2 } - bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction ) + bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction, bool bHasValidContentSignature ) { bool bAllow = false; if ( SvtSecurityOptions().IsMacroDisabled() ) @@ -407,7 +420,9 @@ namespace sfx2 { if (m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading()) { - bAllow = adjustMacroMode( rxInteraction ); + if (m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading()) + m_bNeedsContentSigned = true; + bAllow = adjustMacroMode( rxInteraction, bHasValidContentSignature ); } else if ( !isMacroExecutionDisallowed() ) { |