vcl/source/filter/ipdf/pdfdocument.cxx | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
New commits: commit 59482c5323ff9164eb1515b46adc1deef300e9b0 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Jun 17 17:34:08 2020 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Jun 17 18:39:50 2020 +0200 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 <vmik...@collabora.com> Tested-by: Jenkins 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits