diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-05-18 08:08:16 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-05-22 09:43:10 +0200 |
commit | 6499ea2ff45fa42094d41c5c417f66a3ae5a22ae (patch) | |
tree | 3536b7bdc40b5e3f0f3b475ec34fc56f14601d90 /cui/source | |
parent | b6dda60b3e888f67d76402f29d7b5576814786dd (diff) |
tdf#83877 Add valid/invalid images to signatures
Change-Id: I958c1bad2f32383ebaaeb7d42c761f0d1dfefc35
Reviewed-on: https://gerrit.libreoffice.org/54513
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/dialogs/SignSignatureLineDialog.cxx | 78 | ||||
-rw-r--r-- | cui/source/inc/SignSignatureLineDialog.hxx | 2 |
2 files changed, 40 insertions, 40 deletions
diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx index 9f793884862e..78cb0bd88b17 100644 --- a/cui/source/dialogs/SignSignatureLineDialog.cxx +++ b/cui/source/dialogs/SignSignatureLineDialog.cxx @@ -145,51 +145,49 @@ void SignSignatureLineDialog::Apply() } SfxObjectShell* pShell = SfxObjectShell::Current(); - pShell->SignSignatureLine(m_aSignatureLineId, m_xSelectedCertifate); - - const bool bSuccess = false; // TODO + Reference<XGraphic> xValidGraphic = getSignedGraphic(true); + Reference<XGraphic> xInvalidGraphic = getSignedGraphic(false); + pShell->SignSignatureLine(m_aSignatureLineId, m_xSelectedCertifate, xValidGraphic, + xInvalidGraphic); +} - if (bSuccess) - { - // Read svg and replace placeholder texts - OUString aSvgImage(getSignatureImage()); - aSvgImage = aSvgImage.replaceAll("[SIGNER_NAME]", getCDataString(m_aSuggestedSignerName)); - aSvgImage = aSvgImage.replaceAll("[SIGNER_TITLE]", getCDataString(m_aSuggestedSignerTitle)); - - aSvgImage = aSvgImage.replaceAll("[SIGNATURE]", getCDataString(m_xEditName->get_text())); - OUString aIssuerLine = CuiResId(RID_SVXSTR_SIGNATURELINE_SIGNED_BY) - .replaceFirst("%1", m_xSelectedCertifate->getIssuerName()); - aSvgImage = aSvgImage.replaceAll("[SIGNED_BY]", getCDataString(aIssuerLine)); +const css::uno::Reference<css::graphic::XGraphic> +SignSignatureLineDialog::getSignedGraphic(bool bValid) +{ + // Read svg and replace placeholder texts + OUString aSvgImage(getSignatureImage()); + aSvgImage = aSvgImage.replaceAll("[SIGNER_NAME]", getCDataString(m_aSuggestedSignerName)); + aSvgImage = aSvgImage.replaceAll("[SIGNER_TITLE]", getCDataString(m_aSuggestedSignerTitle)); + + aSvgImage = aSvgImage.replaceAll("[SIGNATURE]", getCDataString(m_xEditName->get_text())); + OUString aIssuerLine = CuiResId(RID_SVXSTR_SIGNATURELINE_SIGNED_BY) + .replaceFirst("%1", m_xSelectedCertifate->getIssuerName()); + aSvgImage = aSvgImage.replaceAll("[SIGNED_BY]", getCDataString(aIssuerLine)); + if (!bValid) aSvgImage = aSvgImage.replaceAll("[INVALID_SIGNATURE]", ""); - OUString aDate; - if (m_bShowSignDate) - { - const SvtSysLocale aSysLocale; - const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData(); - Date aDateTime(Date::SYSTEM); - aDate = rLocaleData.getDate(aDateTime); - } - aSvgImage = aSvgImage.replaceAll("[DATE]", aDate); - - // Insert/Update graphic - SvMemoryStream aSvgStream(4096, 4096); - aSvgStream.WriteOString(OUStringToOString(aSvgImage, RTL_TEXTENCODING_UTF8)); - Reference<XInputStream> xInputStream(new utl::OSeekableInputStreamWrapper(aSvgStream)); - Reference<XComponentContext> xContext(comphelper::getProcessComponentContext()); - Reference<XGraphicProvider> xProvider = css::graphic::GraphicProvider::create(xContext); - - Sequence<PropertyValue> aMediaProperties(1); - aMediaProperties[0].Name = "InputStream"; - aMediaProperties[0].Value <<= xInputStream; - Reference<XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties)); - - m_xShapeProperties->setPropertyValue("Graphic", Any(xGraphic)); - } - else + OUString aDate; + if (m_bShowSignDate && bValid) { - // TODO: Show error dialog + const SvtSysLocale aSysLocale; + const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData(); + Date aDateTime(Date::SYSTEM); + aDate = rLocaleData.getDate(aDateTime); } + aSvgImage = aSvgImage.replaceAll("[DATE]", aDate); + + // Create graphic + SvMemoryStream aSvgStream(4096, 4096); + aSvgStream.WriteOString(OUStringToOString(aSvgImage, RTL_TEXTENCODING_UTF8)); + Reference<XInputStream> xInputStream(new utl::OSeekableInputStreamWrapper(aSvgStream)); + Reference<XComponentContext> xContext(comphelper::getProcessComponentContext()); + Reference<XGraphicProvider> xProvider = css::graphic::GraphicProvider::create(xContext); + + Sequence<PropertyValue> aMediaProperties(1); + aMediaProperties[0].Name = "InputStream"; + aMediaProperties[0].Value <<= xInputStream; + Reference<XGraphic> xGraphic = xProvider->queryGraphic(aMediaProperties); + return xGraphic; } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/cui/source/inc/SignSignatureLineDialog.hxx b/cui/source/inc/SignSignatureLineDialog.hxx index 72f9c1a40882..a78124bc2679 100644 --- a/cui/source/inc/SignSignatureLineDialog.hxx +++ b/cui/source/inc/SignSignatureLineDialog.hxx @@ -12,6 +12,7 @@ #include "SignatureLineDialogBase.hxx" #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/security/XCertificate.hpp> #include <com/sun/star/uno/Reference.hxx> @@ -37,6 +38,7 @@ private: bool m_bShowSignDate; void ValidateFields(); + const css::uno::Reference<css::graphic::XGraphic> getSignedGraphic(bool bValid); virtual void Apply() override; DECL_LINK(chooseCertificate, weld::Button&, void); |