From f86c3fd8e95f378061d57b77d1c700e076996086 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 28 Mar 2017 17:55:06 +0200 Subject: vcl PDF export, norefxobj: have the list of keys to copy at one place To avoid repeting ourselves. Change-Id: I39667620b9cf391251327c8f66ad8b9649ead36f Reviewed-on: https://gerrit.libreoffice.org/35810 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- vcl/source/gdi/pdfwriter_impl.cxx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'vcl') diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 4b8b9542b46a..3b3a6d706a6d 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -11078,11 +11078,6 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit) return; } - OString sColorSpaces = copyExternalResources(*pPage, "ColorSpace"); - OString sExtGStates = copyExternalResources(*pPage, "ExtGState"); - OString sFonts = copyExternalResources(*pPage, "Font"); - OString sXObjects = copyExternalResources(*pPage, "XObject"); - filter::PDFObjectElement* pPageContents = pPage->LookupObject("Contents"); if (!pPageContents) { @@ -11093,8 +11088,6 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit) nWrappedFormObject = createObject(); // Write the form XObject wrapped below. This is a separate object from // the wrapper, this way there is no need to alter the stream contents. - if (!updateObject(nWrappedFormObject)) - return; OStringBuffer aLine; aLine.append(nWrappedFormObject); @@ -11102,10 +11095,15 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit) aLine.append("<< /Type /XObject"); aLine.append(" /Subtype /Form"); aLine.append(" /Resources <<"); - aLine.append(sColorSpaces); - aLine.append(sExtGStates); - aLine.append(sFonts); - aLine.append(sXObjects); + static const std::initializer_list aKeys = + { + "ColorSpace", + "ExtGState", + "Font", + "XObject" + }; + for (const auto& rKey : aKeys) + aLine.append(copyExternalResources(*pPage, rKey)); aLine.append(">>"); aLine.append(" /BBox [ 0 0 "); aLine.append(aSize.Width()); @@ -11137,6 +11135,8 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit) // Copy the original page stream to the form XObject stream. aLine.append(static_cast(rPageStream.GetData()), rPageStream.GetSize()); aLine.append("\nendstream\nendobj\n\n"); + if (!updateObject(nWrappedFormObject)) + return; CHECK_RETURN2(writeBuffer(aLine.getStr(), aLine.getLength())); } -- cgit