From 77e889495f7c513ba8677df5fe662f08053709eb Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 3 Apr 2022 16:10:27 -0400 Subject: Update some code manually to get better formatting results Add comments to force line breaks, parenthesize function arguments that are contatenated strings, etc. -- these kinds of changes improve clang-format's results and also cause emacs cc-mode to match clang-format. After this type of change, most of the time, when clang-format and emacs disagree, clang-format is better. --- examples/pdf-attach-file.cc | 96 +++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 46 deletions(-) (limited to 'examples/pdf-attach-file.cc') diff --git a/examples/pdf-attach-file.cc b/examples/pdf-attach-file.cc index 964d247d..eb12a002 100644 --- a/examples/pdf-attach-file.cc +++ b/examples/pdf-attach-file.cc @@ -45,25 +45,29 @@ process( // Create an indirect object for the built-in Helvetica font. This // uses the qpdf literal syntax introduced in qpdf 10.6. - auto f1 = q.makeIndirectObject("<<" - " /Type /Font" - " /Subtype /Type1" - " /Name /F1" - " /BaseFont /Helvetica" - " /Encoding /WinAnsiEncoding" - ">>"_qpdf); + auto f1 = q.makeIndirectObject( + // force line-break + "<<" + " /Type /Font" + " /Subtype /Type1" + " /Name /F1" + " /BaseFont /Helvetica" + " /Encoding /WinAnsiEncoding" + ">>"_qpdf); // Create a resources dictionary with fonts. This uses the new // parse introduced in qpdf 10.2 that takes a QPDF* and allows // indirect object references. - auto resources = q.makeIndirectObject(QPDFObjectHandle::parse( - &q, - "<<" - " /Font <<" - " /F1 " + - f1.unparse() + - " >>" - ">>")); + auto resources = q.makeIndirectObject( + // line-break + QPDFObjectHandle::parse( + &q, + ("<<" + " /Font <<" + " /F1 " + + f1.unparse() + + " >>" + ">>"))); // Create a file spec. std::string key = QUtil::path_basename(attachment); @@ -108,45 +112,45 @@ process( apdict.replaceKey("/BBox", "[ 0 0 20 20 ]"_qpdf); auto annot = q.makeIndirectObject(QPDFObjectHandle::parse( &q, - "<<" - " /AP <<" - " /N " + - ap.unparse() + - " >>" - " /Contents " + - QPDFObjectHandle::newUnicodeString(attachment).unparse() + - " /FS " + fs.getObjectHandle().unparse() + " /NM " + - QPDFObjectHandle::newUnicodeString(attachment).unparse() + - " /Rect [ 72 700 92 720 ]" - " /Subtype /FileAttachment" - " /Type /Annot" - ">>")); + ("<<" + " /AP <<" + " /N " + + ap.unparse() + + " >>" + " /Contents " + + QPDFObjectHandle::newUnicodeString(attachment).unparse() + " /FS " + + fs.getObjectHandle().unparse() + " /NM " + + QPDFObjectHandle::newUnicodeString(attachment).unparse() + + " /Rect [ 72 700 92 720 ]" + " /Subtype /FileAttachment" + " /Type /Annot" + ">>"))); // Generate contents for the page. auto contents = QPDFObjectHandle::newStream( &q, - "q\n" - "BT\n" - " 102 700 Td\n" - " /F1 16 Tf\n" - " (Here is an attachment.) Tj\n" - "ET\n" - "Q\n"); + ("q\n" + "BT\n" + " 102 700 Td\n" + " /F1 16 Tf\n" + " (Here is an attachment.) Tj\n" + "ET\n" + "Q\n")); // Create the page object. auto page = QPDFObjectHandle::parse( &q, - "<<" - " /Annots [ " + - annot.unparse() + - " ]" - " /Contents " + - contents.unparse() + - " /MediaBox [0 0 612 792]" - " /Resources " + - resources.unparse() + - " /Type /Page" - ">>"); + ("<<" + " /Annots [ " + + annot.unparse() + + " ]" + " /Contents " + + contents.unparse() + + " /MediaBox [0 0 612 792]" + " /Resources " + + resources.unparse() + + " /Type /Page" + ">>")); // Add the page. q.addPage(page, true); -- cgit v1.2.3-54-g00ecf