Commit ab9d557cb051b3568add22790cc58143c823e8df

Authored by Jay Berkenbilt
1 parent d8fdf632

Use fluent replaceKey

examples/pdf-attach-file.cc
@@ -106,10 +106,10 @@ process( @@ -106,10 +106,10 @@ process(
106 // apdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject")); 106 // apdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"));
107 // apdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form")); 107 // apdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form"));
108 // apdict.replaceKey("/BBox", QPDFObjectHandle::parse("[ 0 0 20 20 ]")); 108 // apdict.replaceKey("/BBox", QPDFObjectHandle::parse("[ 0 0 20 20 ]"));
109 - apdict.replaceKey("/Resources", "<< >>"_qpdf);  
110 - apdict.replaceKey("/Type", "/XObject"_qpdf);  
111 - apdict.replaceKey("/Subtype", "/Form"_qpdf);  
112 - apdict.replaceKey("/BBox", "[ 0 0 20 20 ]"_qpdf); 109 + apdict.replaceKey("/Resources", "<< >>"_qpdf)
  110 + .replaceKey("/Type", "/XObject"_qpdf)
  111 + .replaceKey("/Subtype", "/Form"_qpdf)
  112 + .replaceKey("/BBox", "[ 0 0 20 20 ]"_qpdf);
113 auto annot = q.makeIndirectObject(QPDFObjectHandle::parse( 113 auto annot = q.makeIndirectObject(QPDFObjectHandle::parse(
114 &q, 114 &q,
115 ("<<" 115 ("<<"
examples/pdf-create.cc
@@ -183,9 +183,9 @@ add_page( @@ -183,9 +183,9 @@ add_page(
183 " /Subtype /Image" 183 " /Subtype /Image"
184 " /BitsPerComponent 8" 184 " /BitsPerComponent 8"
185 ">>"_qpdf; 185 ">>"_qpdf;
186 - image_dict.replaceKey("/ColorSpace", newName(color_space));  
187 - image_dict.replaceKey("/Width", newInteger(width));  
188 - image_dict.replaceKey("/Height", newInteger(height)); 186 + image_dict.replaceKey("/ColorSpace", newName(color_space))
  187 + .replaceKey("/Width", newInteger(width))
  188 + .replaceKey("/Height", newInteger(height));
189 image.replaceDict(image_dict); 189 image.replaceDict(image_dict);
190 190
191 // Provide the stream data. 191 // Provide the stream data.
@@ -202,9 +202,9 @@ add_page( @@ -202,9 +202,9 @@ add_page(
202 xobject.replaceKey("/Im1", image); 202 xobject.replaceKey("/Im1", image);
203 203
204 QPDFObjectHandle resources = QPDFObjectHandle::newDictionary(); 204 QPDFObjectHandle resources = QPDFObjectHandle::newDictionary();
205 - resources.replaceKey("/ProcSet", procset);  
206 - resources.replaceKey("/Font", rfont);  
207 - resources.replaceKey("/XObject", xobject); 205 + resources.replaceKey("/ProcSet", procset)
  206 + .replaceKey("/Font", rfont)
  207 + .replaceKey("/XObject", xobject);
208 208
209 // Create the page content stream 209 // Create the page content stream
210 QPDFObjectHandle contents = 210 QPDFObjectHandle contents =
@@ -215,8 +215,7 @@ add_page( @@ -215,8 +215,7 @@ add_page(
215 " /Type /Page" 215 " /Type /Page"
216 " /MediaBox [0 0 612 392]" 216 " /MediaBox [0 0 612 392]"
217 ">>"_qpdf); 217 ">>"_qpdf);
218 - page.replaceKey("/Contents", contents);  
219 - page.replaceKey("/Resources", resources); 218 + page.replaceKey("/Contents", contents).replaceKey("/Resources", resources);
220 219
221 // Add the page to the PDF file 220 // Add the page to the PDF file
222 dh.addPage(page, false); 221 dh.addPage(page, false);
libqpdf/NNTree.cc
@@ -341,9 +341,10 @@ NNTreeIterator::split( @@ -341,9 +341,10 @@ NNTreeIterator::split(
341 first_node.replaceKey(key, first_half); 341 first_node.replaceKey(key, first_half);
342 QPDFObjectHandle new_kids = QPDFObjectHandle::newArray(); 342 QPDFObjectHandle new_kids = QPDFObjectHandle::newArray();
343 new_kids.appendItem(first_node); 343 new_kids.appendItem(first_node);
344 - to_split.removeKey("/Limits"); // already shouldn't be there for root  
345 - to_split.removeKey(impl.details.itemsKey());  
346 - to_split.replaceKey("/Kids", new_kids); 344 + to_split
  345 + .removeKey("/Limits") // already shouldn't be there for root
  346 + .removeKey(impl.details.itemsKey())
  347 + .replaceKey("/Kids", new_kids);
347 if (is_leaf) { 348 if (is_leaf) {
348 QTC::TC("qpdf", "NNTree split root + leaf"); 349 QTC::TC("qpdf", "NNTree split root + leaf");
349 this->node = first_node; 350 this->node = first_node;
@@ -884,9 +885,8 @@ NNTreeImpl::repair() @@ -884,9 +885,8 @@ NNTreeImpl::repair()
884 for (auto const& i : *this) { 885 for (auto const& i : *this) {
885 repl.insert(i.first, i.second); 886 repl.insert(i.first, i.second);
886 } 887 }
887 - this->oh.replaceKey("/Kids", new_node.getKey("/Kids"));  
888 - this->oh.replaceKey(  
889 - details.itemsKey(), new_node.getKey(details.itemsKey())); 888 + this->oh.replaceKey("/Kids", new_node.getKey("/Kids"))
  889 + .replaceKey(details.itemsKey(), new_node.getKey(details.itemsKey()));
890 } 890 }
891 891
892 NNTreeImpl::iterator 892 NNTreeImpl::iterator
libqpdf/QPDF.cc
@@ -2436,13 +2436,11 @@ QPDF::replaceForeignIndirectObjects( @@ -2436,13 +2436,11 @@ QPDF::replaceForeignIndirectObjects(
2436 QTC::TC("qpdf", "QPDF replace dictionary"); 2436 QTC::TC("qpdf", "QPDF replace dictionary");
2437 result = QPDFObjectHandle::newDictionary(); 2437 result = QPDFObjectHandle::newDictionary();
2438 std::set<std::string> keys = foreign.getKeys(); 2438 std::set<std::string> keys = foreign.getKeys();
2439 - for (std::set<std::string>::iterator iter = keys.begin();  
2440 - iter != keys.end();  
2441 - ++iter) { 2439 + for (auto const& iter : keys) {
2442 result.replaceKey( 2440 result.replaceKey(
2443 - *iter, 2441 + iter,
2444 replaceForeignIndirectObjects( 2442 replaceForeignIndirectObjects(
2445 - foreign.getKey(*iter), obj_copier, false)); 2443 + foreign.getKey(iter), obj_copier, false));
2446 } 2444 }
2447 } else if (foreign.isStream()) { 2445 } else if (foreign.isStream()) {
2448 QTC::TC("qpdf", "QPDF replace stream"); 2446 QTC::TC("qpdf", "QPDF replace stream");
@@ -2452,13 +2450,11 @@ QPDF::replaceForeignIndirectObjects( @@ -2452,13 +2450,11 @@ QPDF::replaceForeignIndirectObjects(
2452 QPDFObjectHandle dict = result.getDict(); 2450 QPDFObjectHandle dict = result.getDict();
2453 QPDFObjectHandle old_dict = foreign.getDict(); 2451 QPDFObjectHandle old_dict = foreign.getDict();
2454 std::set<std::string> keys = old_dict.getKeys(); 2452 std::set<std::string> keys = old_dict.getKeys();
2455 - for (std::set<std::string>::iterator iter = keys.begin();  
2456 - iter != keys.end();  
2457 - ++iter) { 2453 + for (auto const& iter : keys) {
2458 dict.replaceKey( 2454 dict.replaceKey(
2459 - *iter, 2455 + iter,
2460 replaceForeignIndirectObjects( 2456 replaceForeignIndirectObjects(
2461 - old_dict.getKey(*iter), obj_copier, false)); 2457 + old_dict.getKey(iter), obj_copier, false));
2462 } 2458 }
2463 copyStreamData(result, foreign); 2459 copyStreamData(result, foreign);
2464 } else { 2460 } else {
libqpdf/QPDFAcroFormDocumentHelper.cc
@@ -748,8 +748,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream( @@ -748,8 +748,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
748 auto existing_old = subdict.getKey(old_key); 748 auto existing_old = subdict.getKey(old_key);
749 if (!existing_old.isNull()) { 749 if (!existing_old.isNull()) {
750 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper ap rename"); 750 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper ap rename");
751 - subdict.replaceKey(new_key, existing_old);  
752 - subdict.removeKey(old_key); 751 + subdict.replaceKey(new_key, existing_old).removeKey(old_key);
753 } 752 }
754 } 753 }
755 } 754 }
libqpdf/QPDFFileSpecObjectHelper.cc
@@ -103,8 +103,8 @@ QPDFFileSpecObjectHelper::createFileSpec( @@ -103,8 +103,8 @@ QPDFFileSpecObjectHelper::createFileSpec(
103 QPDFFileSpecObjectHelper result(oh); 103 QPDFFileSpecObjectHelper result(oh);
104 result.setFilename(filename); 104 result.setFilename(filename);
105 auto ef = QPDFObjectHandle::newDictionary(); 105 auto ef = QPDFObjectHandle::newDictionary();
106 - ef.replaceKey("/F", efsoh.getObjectHandle());  
107 - ef.replaceKey("/UF", efsoh.getObjectHandle()); 106 + ef.replaceKey("/F", efsoh.getObjectHandle())
  107 + .replaceKey("/UF", efsoh.getObjectHandle());
108 oh.replaceKey("/EF", ef); 108 oh.replaceKey("/EF", ef);
109 return result; 109 return result;
110 } 110 }
libqpdf/QPDFPageLabelDocumentHelper.cc
@@ -44,9 +44,8 @@ QPDFPageLabelDocumentHelper::getLabelForPage(long long page_idx) @@ -44,9 +44,8 @@ QPDFPageLabelDocumentHelper::getLabelForPage(long long page_idx)
44 QIntC::range_check(start, offset); 44 QIntC::range_check(start, offset);
45 start += offset; 45 start += offset;
46 result = QPDFObjectHandle::newDictionary(); 46 result = QPDFObjectHandle::newDictionary();
47 - result.replaceKey("/S", S);  
48 - result.replaceKey("/P", P);  
49 - result.replaceKey("/St", QPDFObjectHandle::newInteger(start)); 47 + result.replaceKey("/S", S).replaceKey("/P", P).replaceKey(
  48 + "/St", QPDFObjectHandle::newInteger(start));
50 return result; 49 return result;
51 } 50 }
52 51
libqpdf/QPDFPageObjectHelper.cc
@@ -78,8 +78,8 @@ QPDFObjectHandle @@ -78,8 +78,8 @@ QPDFObjectHandle
78 InlineImageTracker::convertIIDict(QPDFObjectHandle odict) 78 InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
79 { 79 {
80 QPDFObjectHandle dict = QPDFObjectHandle::newDictionary(); 80 QPDFObjectHandle dict = QPDFObjectHandle::newDictionary();
81 - dict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"));  
82 - dict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Image")); 81 + dict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"))
  82 + .replaceKey("/Subtype", QPDFObjectHandle::newName("/Image"));
83 std::set<std::string> keys = odict.getKeys(); 83 std::set<std::string> keys = odict.getKeys();
84 for (auto key : keys) { 84 for (auto key : keys) {
85 QPDFObjectHandle value = odict.getKey(key); 85 QPDFObjectHandle value = odict.getKey(key);
@@ -752,11 +752,11 @@ QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations) @@ -752,11 +752,11 @@ QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations)
752 } 752 }
753 QPDFObjectHandle result = QPDFObjectHandle::newStream(qpdf); 753 QPDFObjectHandle result = QPDFObjectHandle::newStream(qpdf);
754 QPDFObjectHandle newdict = result.getDict(); 754 QPDFObjectHandle newdict = result.getDict();
755 - newdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"));  
756 - newdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form"));  
757 - newdict.replaceKey(  
758 - "/Resources", getAttribute("/Resources", false).shallowCopy());  
759 - newdict.replaceKey("/Group", getAttribute("/Group", false).shallowCopy()); 755 + newdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"))
  756 + .replaceKey("/Subtype", QPDFObjectHandle::newName("/Form"))
  757 + .replaceKey(
  758 + "/Resources", getAttribute("/Resources", false).shallowCopy())
  759 + .replaceKey("/Group", getAttribute("/Group", false).shallowCopy());
760 QPDFObjectHandle bbox = getTrimBox(false).shallowCopy(); 760 QPDFObjectHandle bbox = getTrimBox(false).shallowCopy();
761 if (!bbox.isRectangle()) { 761 if (!bbox.isRectangle()) {
762 this->oh.warnIfPossible("bounding box is invalid; form" 762 this->oh.warnIfPossible("bounding box is invalid; form"
libqpdf/QPDF_Stream.cc
@@ -604,8 +604,8 @@ QPDF_Stream::replaceFilterData( @@ -604,8 +604,8 @@ QPDF_Stream::replaceFilterData(
604 QPDFObjectHandle const& decode_parms, 604 QPDFObjectHandle const& decode_parms,
605 size_t length) 605 size_t length)
606 { 606 {
607 - this->stream_dict.replaceKey("/Filter", filter);  
608 - this->stream_dict.replaceKey("/DecodeParms", decode_parms); 607 + this->stream_dict.replaceKey("/Filter", filter)
  608 + .replaceKey("/DecodeParms", decode_parms);
609 if (length == 0) { 609 if (length == 0) {
610 QTC::TC("qpdf", "QPDF_Stream unknown stream length"); 610 QTC::TC("qpdf", "QPDF_Stream unknown stream length");
611 this->stream_dict.removeKey("/Length"); 611 this->stream_dict.removeKey("/Length");
libtests/nntree.cc
@@ -70,8 +70,7 @@ test_bsearch() @@ -70,8 +70,7 @@ test_bsearch()
70 limits.appendItem(QPDFObjectHandle::newInteger(v.at(0))); 70 limits.appendItem(QPDFObjectHandle::newInteger(v.at(0)));
71 limits.appendItem(QPDFObjectHandle::newInteger(v.at(v.size() - 1))); 71 limits.appendItem(QPDFObjectHandle::newInteger(v.at(v.size() - 1)));
72 auto node = q.makeIndirectObject(QPDFObjectHandle::newDictionary()); 72 auto node = q.makeIndirectObject(QPDFObjectHandle::newDictionary());
73 - node.replaceKey("/Nums", nums);  
74 - node.replaceKey("/Limits", limits); 73 + node.replaceKey("/Nums", nums).replaceKey("/Limits", limits);
75 return node; 74 return node;
76 }; 75 };
77 76
qpdf/pdf_from_scratch.cc
@@ -60,15 +60,14 @@ runtest(int n) @@ -60,15 +60,14 @@ runtest(int n)
60 rfont.replaceKey("/F1", font); 60 rfont.replaceKey("/F1", font);
61 61
62 QPDFObjectHandle resources = QPDFObjectHandle::newDictionary(); 62 QPDFObjectHandle resources = QPDFObjectHandle::newDictionary();
63 - resources.replaceKey("/ProcSet", procset);  
64 - resources.replaceKey("/Font", rfont); 63 + resources.replaceKey("/ProcSet", procset).replaceKey("/Font", rfont);
65 64
66 QPDFObjectHandle page = 65 QPDFObjectHandle page =
67 pdf.makeIndirectObject(QPDFObjectHandle::newDictionary()); 66 pdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
68 - page.replaceKey("/Type", newName("/Page"));  
69 - page.replaceKey("/MediaBox", mediabox);  
70 - page.replaceKey("/Contents", contents);  
71 - page.replaceKey("/Resources", resources); 67 + page.replaceKey("/Type", newName("/Page"))
  68 + .replaceKey("/MediaBox", mediabox)
  69 + .replaceKey("/Contents", contents)
  70 + .replaceKey("/Resources", resources);
72 71
73 QPDFPageDocumentHelper(pdf).addPage(page, true); 72 QPDFPageDocumentHelper(pdf).addPage(page, true);
74 73
qpdf/test_driver.cc
@@ -538,8 +538,7 @@ test_9(QPDF&amp; pdf, char const* arg2) @@ -538,8 +538,7 @@ test_9(QPDF&amp; pdf, char const* arg2)
538 "data for other stream\n", 538 "data for other stream\n",
539 QPDFObjectHandle::newNull(), 539 QPDFObjectHandle::newNull(),
540 QPDFObjectHandle::newNull()); 540 QPDFObjectHandle::newNull());
541 - root.replaceKey("/QStream", qstream);  
542 - root.replaceKey("/RStream", rstream); 541 + root.replaceKey("/QStream", qstream).replaceKey("/RStream", rstream);
543 QPDFWriter w(pdf, "a.pdf"); 542 QPDFWriter w(pdf, "a.pdf");
544 w.setStaticID(true); 543 w.setStaticID(true);
545 w.setStreamDataMode(qpdf_s_preserve); 544 w.setStreamDataMode(qpdf_s_preserve);
@@ -909,8 +908,7 @@ test_24(QPDF&amp; pdf, char const* arg2) @@ -909,8 +908,7 @@ test_24(QPDF&amp; pdf, char const* arg2)
909 QPDFObjectHandle res1 = QPDFObjectHandle::newReserved(&pdf); 908 QPDFObjectHandle res1 = QPDFObjectHandle::newReserved(&pdf);
910 QPDFObjectHandle res2 = QPDFObjectHandle::newReserved(&pdf); 909 QPDFObjectHandle res2 = QPDFObjectHandle::newReserved(&pdf);
911 QPDFObjectHandle trailer = pdf.getTrailer(); 910 QPDFObjectHandle trailer = pdf.getTrailer();
912 - trailer.replaceKey("Array1", res1);  
913 - trailer.replaceKey("Array2", res2); 911 + trailer.replaceKey("Array1", res1).replaceKey("Array2", res2);
914 912
915 QPDFObjectHandle array1 = QPDFObjectHandle::newArray(); 913 QPDFObjectHandle array1 = QPDFObjectHandle::newArray();
916 QPDFObjectHandle array2 = QPDFObjectHandle::newArray(); 914 QPDFObjectHandle array2 = QPDFObjectHandle::newArray();
@@ -1086,8 +1084,9 @@ test_27(QPDF&amp; pdf, char const* arg2) @@ -1086,8 +1084,9 @@ test_27(QPDF&amp; pdf, char const* arg2)
1086 dh.addPage(O3.getKey("/OtherPage"), false); 1084 dh.addPage(O3.getKey("/OtherPage"), false);
1087 dh.addPage(O3, false); 1085 dh.addPage(O3, false);
1088 QPDFObjectHandle s2 = QPDFObjectHandle::newStream(&oldpdf, "potato\n"); 1086 QPDFObjectHandle s2 = QPDFObjectHandle::newStream(&oldpdf, "potato\n");
1089 - pdf.getTrailer().replaceKey("/QTest", pdf.copyForeignObject(qtest));  
1090 - pdf.getTrailer().replaceKey("/QTest2", QPDFObjectHandle::newArray()); 1087 + pdf.getTrailer()
  1088 + .replaceKey("/QTest", pdf.copyForeignObject(qtest))
  1089 + .replaceKey("/QTest2", QPDFObjectHandle::newArray());
1091 pdf.getTrailer().getKey("/QTest2").appendItem( 1090 pdf.getTrailer().getKey("/QTest2").appendItem(
1092 pdf.copyForeignObject(s1)); 1091 pdf.copyForeignObject(s1));
1093 pdf.getTrailer().getKey("/QTest2").appendItem( 1092 pdf.getTrailer().getKey("/QTest2").appendItem(
@@ -2259,9 +2258,10 @@ test_60(QPDF&amp; pdf, char const* arg2) @@ -2259,9 +2258,10 @@ test_60(QPDF&amp; pdf, char const* arg2)
2259 2258
2260 // The only differences between /QTest and /QTest3 should be 2259 // The only differences between /QTest and /QTest3 should be
2261 // the direct objects merged from r2. 2260 // the direct objects merged from r2.
2262 - pdf.getTrailer().replaceKey("/QTest1", r1);  
2263 - pdf.getTrailer().replaceKey("/QTest2", r2);  
2264 - pdf.getTrailer().replaceKey("/QTest3", r3); 2261 + pdf.getTrailer()
  2262 + .replaceKey("/QTest1", r1)
  2263 + .replaceKey("/QTest2", r2)
  2264 + .replaceKey("/QTest3", r3);
2265 QPDFWriter w(pdf, "a.pdf"); 2265 QPDFWriter w(pdf, "a.pdf");
2266 w.setQDFMode(true); 2266 w.setQDFMode(true);
2267 w.setStaticID(true); 2267 w.setStaticID(true);
@@ -2321,9 +2321,9 @@ test_62(QPDF&amp; pdf, char const* arg2) @@ -2321,9 +2321,9 @@ test_62(QPDF&amp; pdf, char const* arg2)
2321 long long q2 = QIntC::to_longlong(q2_l); 2321 long long q2 = QIntC::to_longlong(q2_l);
2322 unsigned int q3_i = UINT_MAX; 2322 unsigned int q3_i = UINT_MAX;
2323 long long q3 = QIntC::to_longlong(q3_i); 2323 long long q3 = QIntC::to_longlong(q3_i);
2324 - t.replaceKey("/Q1", QPDFObjectHandle::newInteger(q1));  
2325 - t.replaceKey("/Q2", QPDFObjectHandle::newInteger(q2));  
2326 - t.replaceKey("/Q3", QPDFObjectHandle::newInteger(q3)); 2324 + t.replaceKey("/Q1", QPDFObjectHandle::newInteger(q1))
  2325 + .replaceKey("/Q2", QPDFObjectHandle::newInteger(q2))
  2326 + .replaceKey("/Q3", QPDFObjectHandle::newInteger(q3));
2327 assert_compare_numbers(q1, t.getKey("/Q1").getIntValue()); 2327 assert_compare_numbers(q1, t.getKey("/Q1").getIntValue());
2328 assert_compare_numbers(q1_l, t.getKey("/Q1").getUIntValue()); 2328 assert_compare_numbers(q1_l, t.getKey("/Q1").getUIntValue());
2329 assert_compare_numbers(INT_MAX, t.getKey("/Q1").getIntValueAsInt()); 2329 assert_compare_numbers(INT_MAX, t.getKey("/Q1").getIntValueAsInt());
qpdf/test_large_file.cc
@@ -191,11 +191,11 @@ create_pdf(char const* filename) @@ -191,11 +191,11 @@ create_pdf(char const* filename)
191 191
192 QPDFObjectHandle font = 192 QPDFObjectHandle font =
193 pdf.makeIndirectObject(QPDFObjectHandle::newDictionary()); 193 pdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
194 - font.replaceKey("/Type", newName("/Font"));  
195 - font.replaceKey("/Subtype", newName("/Type1"));  
196 - font.replaceKey("/Name", newName("/F1"));  
197 - font.replaceKey("/BaseFont", newName("/Helvetica"));  
198 - font.replaceKey("/Encoding", newName("/WinAnsiEncoding")); 194 + font.replaceKey("/Type", newName("/Font"))
  195 + .replaceKey("/Subtype", newName("/Type1"))
  196 + .replaceKey("/Name", newName("/F1"))
  197 + .replaceKey("/BaseFont", newName("/Helvetica"))
  198 + .replaceKey("/Encoding", newName("/WinAnsiEncoding"));
199 199
200 QPDFObjectHandle procset = 200 QPDFObjectHandle procset =
201 pdf.makeIndirectObject(QPDFObjectHandle::newArray()); 201 pdf.makeIndirectObject(QPDFObjectHandle::newArray());
@@ -216,12 +216,12 @@ create_pdf(char const* filename) @@ -216,12 +216,12 @@ create_pdf(char const* filename)
216 for (size_t pageno = 1; pageno <= npages; ++pageno) { 216 for (size_t pageno = 1; pageno <= npages; ++pageno) {
217 QPDFObjectHandle image = QPDFObjectHandle::newStream(&pdf); 217 QPDFObjectHandle image = QPDFObjectHandle::newStream(&pdf);
218 QPDFObjectHandle image_dict = image.getDict(); 218 QPDFObjectHandle image_dict = image.getDict();
219 - image_dict.replaceKey("/Type", newName("/XObject"));  
220 - image_dict.replaceKey("/Subtype", newName("/Image"));  
221 - image_dict.replaceKey("/ColorSpace", newName("/DeviceGray"));  
222 - image_dict.replaceKey("/BitsPerComponent", newInteger(8));  
223 - image_dict.replaceKey("/Width", newInteger(width));  
224 - image_dict.replaceKey("/Height", newInteger(height)); 219 + image_dict.replaceKey("/Type", newName("/XObject"))
  220 + .replaceKey("/Subtype", newName("/Image"))
  221 + .replaceKey("/ColorSpace", newName("/DeviceGray"))
  222 + .replaceKey("/BitsPerComponent", newInteger(8))
  223 + .replaceKey("/Width", newInteger(width))
  224 + .replaceKey("/Height", newInteger(height));
225 ImageProvider* p = new ImageProvider(pageno); 225 ImageProvider* p = new ImageProvider(pageno);
226 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); 226 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
227 image.replaceStreamData( 227 image.replaceStreamData(
@@ -231,18 +231,18 @@ create_pdf(char const* filename) @@ -231,18 +231,18 @@ create_pdf(char const* filename)
231 xobject.replaceKey("/Im1", image); 231 xobject.replaceKey("/Im1", image);
232 232
233 QPDFObjectHandle resources = QPDFObjectHandle::newDictionary(); 233 QPDFObjectHandle resources = QPDFObjectHandle::newDictionary();
234 - resources.replaceKey("/ProcSet", procset);  
235 - resources.replaceKey("/Font", rfont);  
236 - resources.replaceKey("/XObject", xobject); 234 + resources.replaceKey("/ProcSet", procset)
  235 + .replaceKey("/Font", rfont)
  236 + .replaceKey("/XObject", xobject);
237 237
238 QPDFObjectHandle contents = create_page_contents(pdf, pageno); 238 QPDFObjectHandle contents = create_page_contents(pdf, pageno);
239 239
240 QPDFObjectHandle page = 240 QPDFObjectHandle page =
241 pdf.makeIndirectObject(QPDFObjectHandle::newDictionary()); 241 pdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
242 - page.replaceKey("/Type", newName("/Page"));  
243 - page.replaceKey("/MediaBox", mediabox);  
244 - page.replaceKey("/Contents", contents);  
245 - page.replaceKey("/Resources", resources); 242 + page.replaceKey("/Type", newName("/Page"))
  243 + .replaceKey("/MediaBox", mediabox)
  244 + .replaceKey("/Contents", contents)
  245 + .replaceKey("/Resources", resources);
246 246
247 dh.addPage(page, false); 247 dh.addPage(page, false);
248 } 248 }