summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-11-07 16:05:07 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-11-07 17:41:49 +0100
commit89780c208837973e21ddbf098d77f4369018ee9e (patch)
tree62fb9fa37ddce6bb2a500969d004afce567a99de /sfx2/source
parent505f97b5b23954d689d55640977da6ec1af523b9 (diff)
Pass XInteractionHandler to hasTrustedScriptingSignature instead of a bool
This allows to use the same interaction handler there, as used in DocumentMacroMode::adjustMacroMode. hasTrustedScriptingSignature used to find its own interaction handler; and that would conflict with e.g. ODatabaseModelImpl::adjustMacroMode_AutoReject, which passes nullptr to adjustMacroMode, with intention to not show any UI; but with signed macros (see tdf#97694), the UI would still appear. Change-Id: Ia209f96bef67dccfe1da23c4d172ac47497f8eb1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159070 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/doc/docmacromode.cxx2
-rw-r--r--sfx2/source/doc/objmisc.cxx26
-rw-r--r--sfx2/source/inc/objshimp.hxx3
3 files changed, 13 insertions, 18 deletions
diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx
index 637f137866ba..b1488b5dbe48 100644
--- a/sfx2/source/doc/docmacromode.cxx
+++ b/sfx2/source/doc/docmacromode.cxx
@@ -200,7 +200,7 @@ namespace sfx2
const bool bAllowUI = nMacroExecutionMode != MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN
&& (nMacroExecutionMode == MacroExecMode::ALWAYS_EXECUTE
|| !SvtSecurityOptions::IsReadOnly(SvtSecurityOptions::EOption::MacroTrustedAuthors));
- const bool bHasTrustedMacroSignature = m_xData->m_rDocumentAccess.hasTrustedScriptingSignature(bAllowUI);
+ const bool bHasTrustedMacroSignature = m_xData->m_rDocumentAccess.hasTrustedScriptingSignature(bAllowUI ? rxInteraction : nullptr);
SignatureState nSignatureState = m_xData->m_rDocumentAccess.getScriptingSignatureState();
if ( nSignatureState == SignatureState::BROKEN )
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index a8f39d06f492..c6bd3b62ddd6 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1847,7 +1847,8 @@ SignatureState SfxObjectShell_Impl::getScriptingSignatureState()
return nSignatureState;
}
-bool SfxObjectShell_Impl::hasTrustedScriptingSignature( bool bAllowUIToAddAuthor )
+bool SfxObjectShell_Impl::hasTrustedScriptingSignature(
+ const css::uno::Reference<css::task::XInteractionHandler>& _rxInteraction)
{
bool bResult = false;
@@ -1883,22 +1884,15 @@ bool SfxObjectShell_Impl::hasTrustedScriptingSignature( bool bAllowUIToAddAuthor
[&xSigner](const security::DocumentSignatureInformation& rInfo) {
return xSigner->isAuthorTrusted( rInfo.Signer ); });
- if ( !bResult && bAllowUIToAddAuthor )
+ if (!bResult && _rxInteraction)
{
- uno::Reference< task::XInteractionHandler > xInteraction;
- if ( rDocShell.GetMedium() )
- xInteraction = rDocShell.GetMedium()->GetInteractionHandler();
-
- if ( xInteraction.is() )
- {
- task::DocumentMacroConfirmationRequest aRequest;
- aRequest.DocumentURL = getDocumentLocation();
- aRequest.DocumentStorage = rDocShell.GetMedium()->GetZipStorageToSign_Impl();
- aRequest.DocumentSignatureInformation = aInfo;
- aRequest.DocumentVersion = aVersion;
- aRequest.Classification = task::InteractionClassification_QUERY;
- bResult = SfxMedium::CallApproveHandler( xInteraction, uno::Any( aRequest ), true );
- }
+ task::DocumentMacroConfirmationRequest aRequest;
+ aRequest.DocumentURL = getDocumentLocation();
+ aRequest.DocumentStorage = rDocShell.GetMedium()->GetZipStorageToSign_Impl();
+ aRequest.DocumentSignatureInformation = aInfo;
+ aRequest.DocumentVersion = aVersion;
+ aRequest.Classification = task::InteractionClassification_QUERY;
+ bResult = SfxMedium::CallApproveHandler( _rxInteraction, uno::Any( aRequest ), true );
}
}
}
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index 7f9624436a15..e7cf6e6ee062 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -149,7 +149,8 @@ struct SfxObjectShell_Impl final : public ::sfx2::IMacroDocumentAccess
virtual css::uno::Reference< css::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const override;
virtual SignatureState getScriptingSignatureState() override;
- virtual bool hasTrustedScriptingSignature( bool bAllowUIToAddAuthor ) override;
+ virtual bool hasTrustedScriptingSignature(
+ const css::uno::Reference<css::task::XInteractionHandler>& _rxInteraction) override;
};
#endif