sd signature line: access the pdf shape from the appearance writer

PDFDocument::WriteAppearanceObject() is where we can turn the pdf data
(containing a single shape only) into a form XObject, later.

Change-Id: Id042c95af4a867d3997d6f7742a18659b8925c12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96455
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna 2020-06-16 14:31:55 +02:00
parent ea45b306d8
commit 058c21ac4a
3 changed files with 15 additions and 0 deletions

View file

@ -344,6 +344,9 @@ class VCL_DLLPUBLIC PDFDocument
/// All editing takes place in this buffer, if it happens.
SvMemoryStream m_aEditBuffer;
/// Signature line in PDF format, to be consumed by the next Sign() invocation.
std::vector<sal_Int8> m_aSignatureLine;
/// Suggest a minimal, yet free signature ID to use for the next signature.
sal_uInt32 GetNextSignature();
/// Write the signature object as part of signing.
@ -397,6 +400,7 @@ public:
//@{
/// Read elements from the start of the stream till its end.
bool Read(SvStream& rStream);
void SetSignatureLine(const std::vector<sal_Int8>& rSignatureLine);
/// Sign the read document with xCertificate in the edit buffer.
bool Sign(const css::uno::Reference<css::security::XCertificate>& xCertificate,
const OUString& rDescription, bool bAdES);

View file

@ -151,6 +151,11 @@ bool PDFDocument::RemoveSignature(size_t nPosition)
return m_aEditBuffer.good();
}
void PDFDocument::SetSignatureLine(const std::vector<sal_Int8>& rSignatureLine)
{
m_aSignatureLine = rSignatureLine;
}
sal_uInt32 PDFDocument::GetNextSignature()
{
sal_uInt32 nRet = 0;
@ -233,6 +238,8 @@ sal_Int32 PDFDocument::WriteSignatureObject(const OUString& rDescription, bool b
sal_Int32 PDFDocument::WriteAppearanceObject()
{
m_aSignatureLine.clear();
// Write appearance object.
sal_Int32 nAppearanceId = m_aXRef.size();
XRefEntry aAppearanceEntry;

View file

@ -202,6 +202,10 @@ bool PDFSignatureHelper::Sign(const uno::Reference<io::XInputStream>& xInputStre
std::vector<sal_Int8> aSignatureLineShape;
GetSignatureLineShape(aSignatureLineShape);
if (!aSignatureLineShape.empty())
{
aDocument.SetSignatureLine(aSignatureLineShape);
}
if (!aDocument.Sign(m_xCertificate, m_aDescription, bAdES))
{