diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-17 17:34:08 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-17 18:39:50 +0200 |
commit | 59482c5323ff9164eb1515b46adc1deef300e9b0 (patch) | |
tree | fd2449c3fac0bdd74ae24f63714b863601c96fdf /vcl/source/filter | |
parent | 0c07d849a4709f896072cb9c707af17c309c2f7f (diff) |
sd signature line: separate alloc and write of xref entry
The problem is that we need an object ID for the appearance object
early, but by the time we ask for that we don't yet know the offset of
the object, as we typically have object dependencies we have to copy
over first.
Solve that by separating the ID allocation and the final object update
(remembering its offset).
Change-Id: I99a242028f6ef2fb907628b96121b6804b8395e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96548
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl/source/filter')
-rw-r--r-- | vcl/source/filter/ipdf/pdfdocument.cxx | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 928f22d8a8c7..ca6d8aa6e486 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -294,21 +294,29 @@ sal_Int32 PDFDocument::WriteAppearanceObject(tools::Rectangle& rSignatureRectang } m_aSignatureLine.clear(); - // Write appearance object. + // Write appearance object: allocate an ID. sal_Int32 nAppearanceId = m_aXRef.size(); + m_aXRef[nAppearanceId] = XRefEntry(); + + // Write the object content. + SvMemoryStream aEditBuffer; + aEditBuffer.WriteUInt32AsString(nAppearanceId); + aEditBuffer.WriteCharPtr(" 0 obj\n"); + aEditBuffer.WriteCharPtr("<</Type/XObject\n/Subtype/Form\n"); + aEditBuffer.WriteCharPtr("/BBox[0 0 "); + aEditBuffer.WriteOString(OString::number(rSignatureRectangle.getWidth())); + aEditBuffer.WriteCharPtr(" "); + aEditBuffer.WriteOString(OString::number(rSignatureRectangle.getHeight())); + aEditBuffer.WriteCharPtr("]\n/Length 0\n>>\n"); + aEditBuffer.WriteCharPtr("stream\n\nendstream\nendobj\n\n"); + + // Add the object to the doc-level edit buffer and update the offset. + aEditBuffer.Seek(0); XRefEntry aAppearanceEntry; aAppearanceEntry.SetOffset(m_aEditBuffer.Tell()); aAppearanceEntry.SetDirty(true); m_aXRef[nAppearanceId] = aAppearanceEntry; - m_aEditBuffer.WriteUInt32AsString(nAppearanceId); - m_aEditBuffer.WriteCharPtr(" 0 obj\n"); - m_aEditBuffer.WriteCharPtr("<</Type/XObject\n/Subtype/Form\n"); - m_aEditBuffer.WriteCharPtr("/BBox[0 0 "); - m_aEditBuffer.WriteOString(OString::number(rSignatureRectangle.getWidth())); - m_aEditBuffer.WriteCharPtr(" "); - m_aEditBuffer.WriteOString(OString::number(rSignatureRectangle.getHeight())); - m_aEditBuffer.WriteCharPtr("]\n/Length 0\n>>\n"); - m_aEditBuffer.WriteCharPtr("stream\n\nendstream\nendobj\n\n"); + m_aEditBuffer.WriteStream(aEditBuffer); return nAppearanceId; } |