[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Nov 12 11:36:38 UTC 2020
vcl/source/gdi/pdfobjectcopier.cxx | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
New commits:
commit 87e33231f8afc3e2d91f5f97a09743ee76fd46e9
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Nov 5 10:46:30 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Nov 12 12:36:06 2020 +0100
pdf: use object stream to copy dict or array content
Objects can be stored in a compressed stream inside a PDF stream,
so we can't assume that we always copy from a document stream, but
we need to check if we have an object stream available and use
that for copying.
Change-Id: I877a4d8e169919d26878cb9c98782c637479d77a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105490
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit a56ee7d45d82ce9ce47dab3fd95577a28b6f4db3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105636
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx b/vcl/source/gdi/pdfobjectcopier.cxx
index a953c864c122..129a4c8bda35 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -41,6 +41,12 @@ sal_Int32 PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer,
SAL_INFO("vcl.pdfwriter", "PDFObjectCopier::copyExternalResource: " << rObject.GetObjectValue()
<< " -> " << nObject);
+ SvMemoryStream* pObjectStream = rObject.GetStreamBuffer();
+ if (!pObjectStream)
+ {
+ pObjectStream = &rDocBuffer;
+ }
+
OStringBuffer aLine;
aLine.append(nObject);
aLine.append(" 0 obj\n");
@@ -71,7 +77,7 @@ sal_Int32 PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer,
else
// Previous reference end -> reference start.
nOffset = nCopyStart;
- aLine.append(static_cast<const char*>(rDocBuffer.GetData()) + nOffset,
+ aLine.append(static_cast<const char*>(pObjectStream->GetData()) + nOffset,
nReferenceStart - nOffset);
// Write the updated reference.
aLine.append(" ");
@@ -93,11 +99,11 @@ sal_Int32 PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer,
if (nLen < 0)
SAL_WARN("vcl.pdfwriter", "copyExternalResource() failed");
else
- aLine.append(static_cast<const char*>(rDocBuffer.GetData()) + nCopyStart, nLen);
+ aLine.append(static_cast<const char*>(pObjectStream->GetData()) + nCopyStart, nLen);
}
else
// Can copy it as-is.
- aLine.append(static_cast<const char*>(rDocBuffer.GetData())
+ aLine.append(static_cast<const char*>(pObjectStream->GetData())
+ rObject.GetDictionaryOffset(),
rObject.GetDictionaryLength());
@@ -141,7 +147,7 @@ sal_Int32 PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer,
else
// Previous reference end -> reference start.
nOffset = nCopyStart;
- aLine.append(static_cast<const char*>(rDocBuffer.GetData()) + nOffset,
+ aLine.append(static_cast<const char*>(pObjectStream->GetData()) + nOffset,
nReferenceStart - nOffset);
// Write the updated reference.
@@ -164,11 +170,12 @@ sal_Int32 PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer,
if (nLen < 0)
SAL_WARN("vcl.pdfwriter", "copyExternalResource() failed");
else
- aLine.append(static_cast<const char*>(rDocBuffer.GetData()) + nCopyStart, nLen);
+ aLine.append(static_cast<const char*>(pObjectStream->GetData()) + nCopyStart, nLen);
}
else
// Can copy it as-is.
- aLine.append(static_cast<const char*>(rDocBuffer.GetData()) + rObject.GetArrayOffset(),
+ aLine.append(static_cast<const char*>(pObjectStream->GetData())
+ + rObject.GetArrayOffset(),
rObject.GetArrayLength());
aLine.append("]\n");
@@ -177,7 +184,7 @@ sal_Int32 PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer,
// If the object has a number element outside a dictionary or array, copy that.
if (filter::PDFNumberElement* pNumber = rObject.GetNumberElement())
{
- aLine.append(static_cast<const char*>(rDocBuffer.GetData()) + pNumber->GetLocation(),
+ aLine.append(static_cast<const char*>(pObjectStream->GetData()) + pNumber->GetLocation(),
pNumber->GetLength());
aLine.append("\n");
}
More information about the Libreoffice-commits
mailing list