vcl/source/filter/ipdf/pdfdocument.cxx |   28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

New commits:
commit a35b5c26691fe938843a48a56e471eb048b9a182
Author:     Miklos Vajna <[email protected]>
AuthorDate: Wed Jun 17 17:34:08 2020 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Jun 29 09:09:09 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).
    
    (cherry picked from commit 59482c5323ff9164eb1515b46adc1deef300e9b0)
    
    Change-Id: I99a242028f6ef2fb907628b96121b6804b8395e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97247
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index 2d98250bf3ae..f19925646f54 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -290,21 +290,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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to