12#include <com/sun/star/beans/XPropertySet.hpp>
13#include <com/sun/star/embed/XStorage.hpp>
14#include <com/sun/star/frame/XModel.hpp>
15#include <com/sun/star/frame/XStorable.hpp>
16#include <com/sun/star/graphic/XGraphic.hpp>
17#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
18#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
19#include <com/sun/star/xml/sax/XAttributeList.hpp>
29using namespace css::xml::sax;
30using namespace css::uno;
31using namespace css::drawing;
32using namespace css::embed;
33using namespace css::frame;
34using namespace css::io;
35using namespace css::graphic;
36using namespace css::security;
40 const Reference<XFastAttributeList>& xAttrList,
41 const Reference<XShape>& rxShape)
44 Reference<beans::XPropertySet> xPropSet(rxShape, UNO_QUERY_THROW);
46 xPropSet->setPropertyValue(
"IsSignatureLine",
Any(
true));
48 xPropSet->setPropertyValue(
"SignatureLineId",
50 xPropSet->setPropertyValue(
51 "SignatureLineSuggestedSignerName",
53 xPropSet->setPropertyValue(
54 "SignatureLineSuggestedSignerTitle",
56 xPropSet->setPropertyValue(
57 "SignatureLineSuggestedSignerEmail",
59 xPropSet->setPropertyValue(
60 "SignatureLineSigningInstructions",
67 xPropSet->setPropertyValue(
"SignatureLineShowSignDate",
Any(bShowSignDate));
68 xPropSet->setPropertyValue(
"SignatureLineCanAddComment",
Any(bCanAddComment));
71 Reference<XGraphic> xUnsignedGraphic;
72 xPropSet->getPropertyValue(
"Graphic") >>= xUnsignedGraphic;
73 if (xUnsignedGraphic.is())
74 xPropSet->setPropertyValue(
"SignatureLineUnsignedImage",
Any(xUnsignedGraphic));
76 Reference<XGraphic> xGraphic;
80 css::uno::Reference<XStorable> xStorable(
GetImport().GetModel(), UNO_QUERY_THROW);
91 Reference<XDocumentDigitalSignatures> xSignatures(
92 security::DocumentDigitalSignatures::createWithVersion(
95 const Sequence<DocumentSignatureInformation> xSignatureInfo
96 = xSignatures->verifyDocumentContentSignatures(xStorage, Reference<XInputStream>());
101 = std::find_if(xSignatureInfo.begin(), xSignatureInfo.end(),
102 [&xAttrList](
const DocumentSignatureInformation& rSignatureInfo) {
103 return rSignatureInfo.SignatureLineId
104 == xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_ID));
106 bool bIsSigned(
false);
107 if (pSignatureInfo != xSignatureInfo.end())
110 if (pSignatureInfo->SignatureIsValid)
113 SAL_WARN_IF(!pSignatureInfo->ValidSignatureLineImage.is(),
"xmloff",
114 "No ValidSignatureLineImage!");
115 xGraphic = pSignatureInfo->ValidSignatureLineImage;
120 SAL_WARN_IF(!pSignatureInfo->InvalidSignatureLineImage.is(),
"xmloff",
121 "No InvalidSignatureLineImage!");
122 xGraphic = pSignatureInfo->InvalidSignatureLineImage;
125 xPropSet->setPropertyValue(
"Graphic",
Any(xGraphic));
127 xPropSet->setPropertyValue(
"SignatureLineIsSigned",
Any(bIsSigned));
129 catch (css::uno::Exception&)
SignatureLineContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const css::uno::Reference< css::drawing::XShape > &rxShape)
This class deliberately does not support XWeak, to improve performance when loading large documents.
SvXMLImport & GetImport()
static OUString GetODFVersionFromStorage(const css::uno::Reference< css::embed::XStorage > &xStorage)
static css::uno::Reference< css::embed::XStorage > GetStorageOfFormatFromURL(const OUString &aFormat, const OUString &aURL, sal_Int32 nStorageMode, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()
Handling of tokens in XML:
@ XML_SUGGESTED_SIGNER_TITLE
@ XML_SUGGESTED_SIGNER_EMAIL
@ XML_SIGNING_INSTRUCTIONS
@ XML_SUGGESTED_SIGNER_NAME
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
constexpr OUStringLiteral ZIP_STORAGE_FORMAT_STRING
#define XML_ELEMENT(prefix, name)