[Libreoffice-commits] core.git: vcl/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Mar 28 19:02:24 UTC 2017


 vcl/source/gdi/pdfwriter_impl.cxx |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

New commits:
commit f86c3fd8e95f378061d57b77d1c700e076996086
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Mar 28 17:55:06 2017 +0200

    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 <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

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<OString> 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<const sal_Char*>(rPageStream.GetData()), rPageStream.GetSize());
         aLine.append("\nendstream\nendobj\n\n");
+        if (!updateObject(nWrappedFormObject))
+            return;
         CHECK_RETURN2(writeBuffer(aLine.getStr(), aLine.getLength()));
     }
 


More information about the Libreoffice-commits mailing list