summaryrefslogtreecommitdiff
path: root/cui/source/dialogs/SignSignatureLineDialog.cxx
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-04-20 12:19:12 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-05-15 16:16:22 +0200
commit86e8cfdd54ac1b9413f0c86cbc23a80162806685 (patch)
treee62c721f66cb95490fcedc41d3c22303d89de182 /cui/source/dialogs/SignSignatureLineDialog.cxx
parent863d2485e60251ac45b019b2c58ced7cfc9d978e (diff)
Sign Signature Line
This adds a new context menu entry "Sign Signature Line" to signature lines. You can directly sign the document from there. Still missing is the updating of the graphic to reflect the valid/invalid signature state. Change-Id: Ib8bc8c57f9d5370a10e379f86f9e41e57c715e3f Reviewed-on: https://gerrit.libreoffice.org/53778 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'cui/source/dialogs/SignSignatureLineDialog.cxx')
-rw-r--r--cui/source/dialogs/SignSignatureLineDialog.cxx77
1 files changed, 48 insertions, 29 deletions
diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx
index cd0295415410..454b6d42ec52 100644
--- a/cui/source/dialogs/SignSignatureLineDialog.cxx
+++ b/cui/source/dialogs/SignSignatureLineDialog.cxx
@@ -15,10 +15,12 @@
#include <strings.hrc>
#include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
#include <comphelper/xmltools.hxx>
#include <tools/stream.hxx>
#include <unotools/streamwrap.hxx>
#include <vcl/weld.hxx>
+#include <sfx2/objsh.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XShape.hpp>
@@ -137,40 +139,57 @@ void SignSignatureLineDialog::ValidateFields()
void SignSignatureLineDialog::Apply()
{
- // 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));
- aSvgImage = aSvgImage.replaceAll("[INVALID_SIGNATURE]", "");
-
- OUString aDate;
- if (m_bShowSignDate)
+ if (!m_xSelectedCertifate.is())
{
- const SvtSysLocale aSysLocale;
- const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
- Date aDateTime(Date::SYSTEM);
- aDate = rLocaleData.getDate(aDateTime);
+ SAL_WARN("cui.dialogs", "No certificate selected!");
}
- 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);
+ SfxObjectShell* pShell = SfxObjectShell::Current();
+ pShell->SignDocumentContent(m_xSelectedCertifate);
- Sequence<PropertyValue> aMediaProperties(1);
- aMediaProperties[0].Name = "InputStream";
- aMediaProperties[0].Value <<= xInputStream;
- Reference<XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties));
+ bool bSuccess = false; // TODO
- m_xShapeProperties->setPropertyValue("Graphic", Any(xGraphic));
+ 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));
+ 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
+ {
+ // TODO: Show error dialog
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */