summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-06-08 17:14:14 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-06-26 08:53:20 +0200
commitd3506785b59442a7f747eccedea557f5645b33cb (patch)
tree6a376de4a0b7848ebf6e2bf35c9b895cc717cfb4 /cui
parenta78513a9396a313f28b276a0a691a1e425f9bbd4 (diff)
sd signature line: extract part of signature line UI from cui to svx
So the "sign existing pdf" code in sd can reuse that. (cherry picked from commit 85b68061a5a904ca82e5db40600af741d30f0bb8) Conflicts: cui/source/dialogs/SignSignatureLineDialog.cxx Change-Id: If51fae203ed0c68ed8e5e63368e60ae1c705bade Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97175 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/SignSignatureLineDialog.cxx37
-rw-r--r--cui/source/dialogs/SignatureLineDialog.cxx14
-rw-r--r--cui/source/dialogs/SignatureLineDialogBase.cxx14
-rw-r--r--cui/source/inc/SignatureLineDialogBase.hxx1
4 files changed, 11 insertions, 55 deletions
diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx
index 96fa94248106..10223e2b68fa 100644
--- a/cui/source/dialogs/SignSignatureLineDialog.cxx
+++ b/cui/source/dialogs/SignSignatureLineDialog.cxx
@@ -30,6 +30,7 @@
#include <utility>
#include <vcl/graph.hxx>
#include <vcl/weld.hxx>
+#include <svx/signaturelinehelper.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/graphic/GraphicProvider.hpp>
@@ -166,22 +167,14 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, chooseCertificate, weld::Button&, void)
if (!pShell->PrepareForSigning(m_xDialog.get()))
return;
- Reference<XDocumentDigitalSignatures> xSigner(DocumentDigitalSignatures::createWithVersion(
- comphelper::getProcessComponentContext(), "1.2"));
- xSigner->setParentWindow(m_xDialog->GetXWindow());
- OUString aDescription;
- CertificateKind certificateKind = CertificateKind_NONE;
- // When signing ooxml, we only want X.509 certificates
- if (pShell->GetMedium()->GetFilter()->IsAlienFormat())
- certificateKind = CertificateKind_X509;
Reference<XCertificate> xSignCertificate
- = xSigner->selectSigningCertificateWithType(certificateKind, aDescription);
+ = svx::SignatureLineHelper::getSignatureCertificate(pShell, m_xDialog.get());
if (xSignCertificate.is())
{
m_xSelectedCertifate = xSignCertificate;
- m_xBtnChooseCertificate->set_label(xmlsec::GetContentPart(
- xSignCertificate->getSubjectName(), xSignCertificate->getCertificateKind()));
+ m_xBtnChooseCertificate->set_label(
+ svx::SignatureLineHelper::getSignerName(xSignCertificate));
}
ValidateFields();
}
@@ -217,15 +210,13 @@ void SignSignatureLineDialog::Apply()
css::uno::Reference<css::graphic::XGraphic> SignSignatureLineDialog::getSignedGraphic(bool bValid)
{
// Read svg and replace placeholder texts
- OUString aSvgImage(getSignatureImage());
+ OUString aSvgImage(svx::SignatureLineHelper::getSignatureImage());
aSvgImage = aSvgImage.replaceAll("[SIGNER_NAME]", getCDataString(m_aSuggestedSignerName));
aSvgImage = aSvgImage.replaceAll("[SIGNER_TITLE]", getCDataString(m_aSuggestedSignerTitle));
OUString aIssuerLine
= CuiResId(RID_SVXSTR_SIGNATURELINE_SIGNED_BY)
- .replaceFirst("%1",
- xmlsec::GetContentPart(m_xSelectedCertifate->getSubjectName(),
- m_xSelectedCertifate->getCertificateKind()));
+ .replaceFirst("%1", svx::SignatureLineHelper::getSignerName(m_xSelectedCertifate));
aSvgImage = aSvgImage.replaceAll("[SIGNED_BY]", getCDataString(aIssuerLine));
if (bValid)
aSvgImage = aSvgImage.replaceAll("[INVALID_SIGNATURE]", "");
@@ -233,10 +224,7 @@ css::uno::Reference<css::graphic::XGraphic> SignSignatureLineDialog::getSignedGr
OUString aDate;
if (m_bShowSignDate && bValid)
{
- const SvtSysLocale aSysLocale;
- const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
- Date aDateTime(Date::SYSTEM);
- aDate = rLocaleData.getDate(aDateTime);
+ aDate = svx::SignatureLineHelper::getLocalizedDate();
}
aSvgImage = aSvgImage.replaceAll("[DATE]", aDate);
@@ -266,16 +254,7 @@ css::uno::Reference<css::graphic::XGraphic> SignSignatureLineDialog::getSignedGr
}
// 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;
- return xProvider->queryGraphic(aMediaProperties);
+ return svx::SignatureLineHelper::importSVG(aSvgImage);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/source/dialogs/SignatureLineDialog.cxx b/cui/source/dialogs/SignatureLineDialog.cxx
index 16f3b22ddd4a..efed5459bb6f 100644
--- a/cui/source/dialogs/SignatureLineDialog.cxx
+++ b/cui/source/dialogs/SignatureLineDialog.cxx
@@ -15,6 +15,7 @@
#include <unotools/streamwrap.hxx>
#include <utility>
#include <vcl/weld.hxx>
+#include <svx/signaturelinehelper.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
@@ -111,7 +112,7 @@ void SignatureLineDialog::Apply()
bool bShowSignDate(m_xCheckboxShowSignDate->get_active());
// Read svg and replace placeholder texts
- OUString aSvgImage(getSignatureImage());
+ OUString aSvgImage(svx::SignatureLineHelper::getSignatureImage());
aSvgImage = aSvgImage.replaceAll("[SIGNER_NAME]", getCDataString(aSignerName));
aSvgImage = aSvgImage.replaceAll("[SIGNER_TITLE]", getCDataString(aSignerTitle));
@@ -122,16 +123,7 @@ void SignatureLineDialog::Apply()
aSvgImage = aSvgImage.replaceAll("[DATE]", "");
// 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));
+ Reference<XGraphic> xGraphic = svx::SignatureLineHelper::importSVG(aSvgImage);
bool bIsExistingSignatureLine = m_xExistingShapeProperties.is();
Reference<XPropertySet> xShapeProps;
diff --git a/cui/source/dialogs/SignatureLineDialogBase.cxx b/cui/source/dialogs/SignatureLineDialogBase.cxx
index d72fa7b93f1d..50214308fe10 100644
--- a/cui/source/dialogs/SignatureLineDialogBase.cxx
+++ b/cui/source/dialogs/SignatureLineDialogBase.cxx
@@ -41,18 +41,4 @@ OUString SignatureLineDialogBase::getCDataString(const OUString& rString)
return "<![CDATA[" + rString + "]]>";
}
-OUString SignatureLineDialogBase::getSignatureImage()
-{
- OUString aPath("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/filter/signature-line.svg");
- rtl::Bootstrap::expandMacros(aPath);
- SvFileStream aStream(aPath, StreamMode::READ);
- if (aStream.GetError() != ERRCODE_NONE)
- {
- SAL_WARN("cui.dialogs", "failed to open signature-line.svg");
- }
-
- OString const svg = read_uInt8s_ToOString(aStream, aStream.remainingSize());
- return OUString::fromUtf8(svg);
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/source/inc/SignatureLineDialogBase.hxx b/cui/source/inc/SignatureLineDialogBase.hxx
index 2e046d945d80..3b065fe87838 100644
--- a/cui/source/inc/SignatureLineDialogBase.hxx
+++ b/cui/source/inc/SignatureLineDialogBase.hxx
@@ -24,7 +24,6 @@ public:
protected:
css::uno::Reference<css::frame::XModel> m_xModel;
- static OUString getSignatureImage();
virtual void Apply() = 0;
static OUString getCDataString(const OUString& rString);
};