From 0b5fea74963d499be5d59acee29ba89137f9f0cd Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Wed, 11 Dec 2019 11:51:45 +0100 Subject: Correctly set the macro security auto confirm mode The code of adjustMacroMode() has one major problem: (almost) everything is handled by the single nMacroExecutionMode variable, which is even changed based on its initial setting. I don't know if this fixed functionality breaks something, but it doesn't look like it, as the enum AutoConfirmation is just used and defined locally. Change-Id: Iac305e9ec0020a11fd53b4bb87cc782686a247ac Reviewed-on: https://gerrit.libreoffice.org/85055 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski --- sfx2/source/doc/docmacromode.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx index 13954b06f6d8..ef5123a2c39d 100644 --- a/sfx2/source/doc/docmacromode.cxx +++ b/sfx2/source/doc/docmacromode.cxx @@ -166,6 +166,12 @@ namespace sfx2 || ( nMacroExecutionMode == MacroExecMode::USE_CONFIG_APPROVE_CONFIRMATION ) ) { + // check confirm first, as nMacroExecutionMode is always overwritten by the GetMacroSecurityLevel() switch + if (nMacroExecutionMode == MacroExecMode::USE_CONFIG_REJECT_CONFIRMATION) + eAutoConfirm = eAutoConfirmReject; + else if (nMacroExecutionMode == MacroExecMode::USE_CONFIG_APPROVE_CONFIRMATION) + eAutoConfirm = eAutoConfirmApprove; + SvtSecurityOptions aOpt; switch ( aOpt.GetMacroSecurityLevel() ) { @@ -185,11 +191,6 @@ namespace sfx2 OSL_FAIL( "DocumentMacroMode::adjustMacroMode: unexpected macro security level!" ); nMacroExecutionMode = MacroExecMode::NEVER_EXECUTE; } - - if ( nMacroExecutionMode == MacroExecMode::USE_CONFIG_REJECT_CONFIRMATION ) - eAutoConfirm = eAutoConfirmReject; - else if ( nMacroExecutionMode == MacroExecMode::USE_CONFIG_APPROVE_CONFIRMATION ) - eAutoConfirm = eAutoConfirmApprove; } if ( nMacroExecutionMode == MacroExecMode::NEVER_EXECUTE ) -- cgit