summaryrefslogtreecommitdiff
path: root/xmlsecurity/source
diff options
context:
space:
mode:
Diffstat (limited to 'xmlsecurity/source')
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx13
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx10
2 files changed, 16 insertions, 7 deletions
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 07512080cf9e..af6551d7c7e5 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -85,6 +85,7 @@ private:
void ImplViewSignatures(const css::uno::Reference<css::embed::XStorage>& rxStorage,
const css::uno::Reference<css::io::XStream>& xSignStream,
DocumentSignatureMode eMode, bool bReadOnly,
+ SfxViewShell* pViewShell,
const std::function<void(bool)>& rCallback);
/// @throws css::uno::RuntimeException
void ImplViewSignatures(const css::uno::Reference<css::embed::XStorage>& rxStorage,
@@ -195,6 +196,7 @@ public:
/// See sfx2::DigitalSignatures::SignDocumentContentAsync().
void SignDocumentContentAsync(const css::uno::Reference<css::embed::XStorage>& xStorage,
const css::uno::Reference<css::io::XStream>& xSignStream,
+ SfxViewShell* pViewShell,
const std::function<void(bool)>& rCallback) override;
/// See sfx2::DigitalSignatures::SignScriptingContentAsync().
void SignScriptingContentAsync(const css::uno::Reference<css::embed::XStorage>& xStorage,
@@ -364,17 +366,17 @@ void DocumentDigitalSignatures::ImplViewSignatures(
Reference< io::XStream > xStream;
if ( xSignStream.is() )
xStream.set( xSignStream, UNO_QUERY );
- ImplViewSignatures( rxStorage, xStream, eMode, bReadOnly, [](bool /*bSuccess*/){} );
+ ImplViewSignatures( rxStorage, xStream, eMode, bReadOnly, nullptr, [](bool /*bSuccess*/){} );
}
void DocumentDigitalSignatures::ImplViewSignatures(
const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XStream >& xSignStream,
- DocumentSignatureMode eMode, bool bReadOnly, const std::function<void(bool)>& rCallback )
+ DocumentSignatureMode eMode, bool bReadOnly, SfxViewShell* pViewShell, const std::function<void(bool)>& rCallback )
{
bool bChanges = false;
auto xSignaturesDialog = std::make_shared<DigitalSignaturesDialog>(
Application::GetFrameWeld(mxParentWindow), mxCtx, eMode, bReadOnly, m_sODFVersion,
- m_bHasDocumentSignature);
+ m_bHasDocumentSignature, pViewShell);
bool bInit = xSignaturesDialog->Init();
SAL_WARN_IF( !bInit, "xmlsecurity.comp", "Error initializing security context!" );
if ( bInit )
@@ -773,10 +775,11 @@ bool DocumentDigitalSignatures::SignModelWithCertificate(
void DocumentDigitalSignatures::SignDocumentContentAsync(const css::uno::Reference<css::embed::XStorage>& rxStorage,
const css::uno::Reference<css::io::XStream>& xSignStream,
+ SfxViewShell* pViewShell,
const std::function<void(bool)>& rCallback)
{
OSL_ENSURE(!m_sODFVersion.isEmpty(), "DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2");
- ImplViewSignatures( rxStorage, xSignStream, DocumentSignatureMode::Content, false, rCallback );
+ ImplViewSignatures( rxStorage, xSignStream, DocumentSignatureMode::Content, false, pViewShell, rCallback );
}
void DocumentDigitalSignatures::SignScriptingContentAsync(
@@ -785,7 +788,7 @@ void DocumentDigitalSignatures::SignScriptingContentAsync(
{
OSL_ENSURE(!m_sODFVersion.isEmpty(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2");
OSL_ENSURE(m_nArgumentsCount == 2, "DocumentDigitalSignatures: Service was not initialized properly");
- ImplViewSignatures( rxStorage, xSignStream, DocumentSignatureMode::Macros, false, rCallback );
+ ImplViewSignatures( rxStorage, xSignStream, DocumentSignatureMode::Macros, false, nullptr, rCallback );
}
void DocumentDigitalSignatures::SetSignScriptingContent(
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index b66158e454ed..4dcd9d387ccc 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -52,6 +52,7 @@
#include <utility>
#include <vcl/weld.hxx>
#include <vcl/svapp.hxx>
+#include <sfx2/viewsh.hxx>
#ifdef _WIN32
#include <o3tl/char16_t2wchar_t.hxx>
@@ -192,7 +193,8 @@ bool IsThereCertificateMgr()
DigitalSignaturesDialog::DigitalSignaturesDialog(
weld::Window* pParent,
const uno::Reference< uno::XComponentContext >& rxCtx, DocumentSignatureMode eMode,
- bool bReadOnly, OUString sODFVersion, bool bHasDocumentSignature)
+ bool bReadOnly, OUString sODFVersion, bool bHasDocumentSignature,
+ SfxViewShell* pViewShell)
: GenericDialogController(pParent, u"xmlsec/ui/digitalsignaturesdialog.ui"_ustr, u"DigitalSignaturesDialog"_ustr)
, maSignatureManager(rxCtx, eMode)
, m_sODFVersion (std::move(sODFVersion))
@@ -259,7 +261,11 @@ DigitalSignaturesDialog::DigitalSignaturesDialog(
if (comphelper::LibreOfficeKit::isActive())
{
- m_xAddBtn->hide();
+ // If the view has a signing certificate, then allow adding a signature.
+ if (!pViewShell || !pViewShell->GetSigningCertificate().is())
+ {
+ m_xAddBtn->hide();
+ }
m_xStartCertMgrBtn->hide();
}