diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-11-12 22:24:02 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-11-13 11:15:42 +0100 |
commit | 7abf7e4194d30a716f24c6557e70891e29d0fee3 (patch) | |
tree | 5219d491ae215550f43230156b5d503e70f6f97c | |
parent | 8dd0c96f2e39803c158c6ace0dc45de4a3eec731 (diff) |
pdf: Improve dict and array format when copying with PDFObjectCopier
Change-Id: I4fcc4d912d4ce9d7800782b69811f877b85d9857
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105782
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | vcl/source/gdi/pdfobjectcopier.cxx | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx b/vcl/source/gdi/pdfobjectcopier.cxx index 4e5575c25952..0d67fe735561 100644 --- a/vcl/source/gdi/pdfobjectcopier.cxx +++ b/vcl/source/gdi/pdfobjectcopier.cxx @@ -100,17 +100,21 @@ sal_Int32 PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer, if (rObject.GetDictionary()) { aLine.append("<< "); - + bool bFirst = true; for (auto const& rPair : rObject.GetDictionaryItems()) { + if (bFirst) + bFirst = false; + else + aLine.append(" "); + aLine.append("/"); aLine.append(rPair.first); aLine.append(" "); copyRecursively(aLine, rPair.second, rDocBuffer, rCopiedResources); - aLine.append(" "); } - aLine.append(">>\n"); + aLine.append(" >>\n"); } if (filter::PDFStreamElement* pStream = rObject.GetStream()) @@ -127,10 +131,14 @@ sal_Int32 PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer, const std::vector<filter::PDFElement*>& rElements = pArray->GetElements(); + bool bFirst = true; for (auto const& pElement : rElements) { + if (bFirst) + bFirst = false; + else + aLine.append(" "); copyRecursively(aLine, pElement, rDocBuffer, rCopiedResources); - aLine.append(" "); } aLine.append("]\n"); } @@ -138,8 +146,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*>(pObjectStream->GetData()) + pNumber->GetLocation(), - pNumber->GetLength()); + pNumber->writeString(aLine); aLine.append("\n"); } |