30#include <com/sun/star/beans/XPropertySet.hpp>
31#include <com/sun/star/graphic/GraphicProvider.hpp>
32#include <com/sun/star/graphic/XGraphic.hpp>
33#include <com/sun/star/graphic/XGraphicProvider.hpp>
34#include <com/sun/star/security/CertificateKind.hpp>
35#include <com/sun/star/security/XCertificate.hpp>
36#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
37#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
41using namespace css::uno;
42using namespace css::beans;
43using namespace css::frame;
44using namespace css::io;
45using namespace css::lang;
46using namespace css::frame;
47using namespace css::text;
48using namespace css::graphic;
49using namespace css::security;
50using namespace css::ui::dialogs;
54 "SignSignatureLineDialog")
55 , m_xEditName(m_xBuilder->weld_entry(
"edit_name"))
56 , m_xEditComment(m_xBuilder->weld_text_view(
"edit_comment"))
57 , m_xBtnLoadImage(m_xBuilder->weld_button(
"btn_load_image"))
58 , m_xBtnClearImage(m_xBuilder->weld_button(
"btn_clear_image"))
59 , m_xBtnChooseCertificate(m_xBuilder->weld_button(
"btn_select_certificate"))
60 , m_xBtnSign(m_xBuilder->weld_button(
"ok"))
61 , m_xLabelHint(m_xBuilder->weld_label(
"label_hint"))
62 , m_xLabelHintText(m_xBuilder->weld_label(
"label_hint_text"))
63 , m_xLabelAddComment(m_xBuilder->weld_label(
"label_add_comment"))
64 , m_bShowSignDate(false)
66 Reference<container::XIndexAccess> xIndexAccess(
m_xModel->getCurrentSelection(),
70 bool bIsSignatureLine(
false);
72 if (!bIsSignatureLine)
74 SAL_WARN(
"cui.dialogs",
"No signature line selected!");
90 OUString aSigningInstructions;
92 >>= aSigningInstructions;
94 bool bCanAddComment(
false);
97 if (aSigningInstructions.isEmpty())
128 Reference<XFilePicker3> xFilePicker =
aHelper.GetFilePicker();
129 if (!xFilePicker->execute())
132 Sequence<OUString> aSelectedFiles = xFilePicker->getSelectedFiles();
133 if (!aSelectedFiles.hasElements())
136 Reference<XGraphicProvider> xProvider = GraphicProvider::create(xContext);
138 aSelectedFiles[0]) };
139 m_xSignatureImage = xProvider->queryGraphic(aMediaProperties);
140 m_sOriginalImageBtnLabel = m_xBtnLoadImage->get_label();
150 m_xSignatureImage.set(
nullptr);
151 m_xBtnLoadImage->set_label(m_sOriginalImageBtnLabel);
162 Reference<XCertificate> xSignCertificate
165 if (xSignCertificate.is())
167 m_xSelectedCertifate = xSignCertificate;
168 m_xBtnChooseCertificate->set_label(
191 SAL_WARN(
"cui.dialogs",
"No certificate selected!");
198 SAL_WARN(
"cui.dialogs",
"No SfxObjectShell!");
216 =
CuiResId(RID_CUISTR_SIGNATURELINE_SIGNED_BY)
218 aSvgImage = aSvgImage.replaceAll(
"[SIGNED_BY]",
getCDataString(aIssuerLine));
220 aSvgImage = aSvgImage.replaceAll(
"[INVALID_SIGNATURE]",
"");
227 aSvgImage = aSvgImage.replaceAll(
"[DATE]", aDate);
232 OUString aGraphicInBase64;
235 SAL_WARN(
"cui.dialogs",
"Could not convert graphic to base64");
237 OUString aImagePart =
"<image y=\"825\" x=\"1300\" "
238 "xlink:href=\"data:[MIMETYPE];base64,[BASE64_IMG]>\" "
239 "preserveAspectRatio=\"xMidYMid\" height=\"1520\" "
241 aImagePart = aImagePart.replaceAll(
243 aImagePart = aImagePart.replaceAll(
"[BASE64_IMG]", aGraphicInBase64);
244 aSvgImage = aSvgImage.replaceAll(
"[SIGNATURE_IMAGE]", aImagePart);
246 aSvgImage = aSvgImage.replaceAll(
"[SIGNATURE]",
"");
250 aSvgImage = aSvgImage.replaceAll(
"[SIGNATURE_IMAGE]",
"");
IMPL_LINK_NOARG(SignSignatureLineDialog, loadImage, weld::Button &, void)
Reference< XExecutableDialog > m_xDialog
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
void SignSignatureLine(weld::Window *pDialogParent, const OUString &aSignatureLineId, const css::uno::Reference< css::security::XCertificate > &xCert, const css::uno::Reference< css::graphic::XGraphic > &xValidGraphic, const css::uno::Reference< css::graphic::XGraphic > &xInvalidGraphic, const OUString &aComment)
bool PrepareForSigning(weld::Window *pDialogParent)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
css::uno::Reference< css::beans::XPropertySet > m_xShapeProperties
std::unique_ptr< weld::Button > m_xBtnSign
css::uno::Reference< css::graphic::XGraphic > getSignedGraphic(bool bValid)
SignSignatureLineDialog(weld::Widget *pParent, css::uno::Reference< css::frame::XModel > xModel)
OUString m_aSuggestedSignerName
std::unique_ptr< weld::Button > m_xBtnChooseCertificate
OUString m_aSuggestedSignerTitle
std::unique_ptr< weld::Button > m_xBtnClearImage
virtual void Apply() override
std::unique_ptr< weld::Label > m_xLabelAddComment
OUString m_aSignatureLineId
std::unique_ptr< weld::Entry > m_xEditName
std::unique_ptr< weld::Label > m_xLabelHint
css::uno::Reference< css::graphic::XGraphic > m_xSignatureImage
css::uno::Reference< css::security::XCertificate > m_xSelectedCertifate
std::unique_ptr< weld::Label > m_xLabelHintText
std::unique_ptr< weld::TextView > m_xEditComment
std::unique_ptr< weld::Button > m_xBtnLoadImage
static OUString getCDataString(std::u16string_view rString)
css::uno::Reference< css::frame::XModel > m_xModel
static bool GraphicToBase64(const Graphic &rGraphic, OUString &rOUString, bool bAddPrefix=true, ConvertDataFormat aTargetFormat=ConvertDataFormat::Unknown)
std::shared_ptr< weld::Dialog > m_xDialog
OUString CuiResId(TranslateId aKey)
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
OUString getSignerName(const css::uno::Reference< css::security::XCertificate > &xCertificate)
uno::Reference< graphic::XGraphic > importSVG(std::u16string_view rSVG)
uno::Reference< security::XCertificate > getSignatureCertificate(SfxObjectShell *pShell, weld::Window *pParent)
OUString getSignatureImage(const OUString &rType=OUString())
OUString getLocalizedDate()
Reference< XModel > xModel