Commit b9aded1a0062b52346ecb8aefb6035ad006ceba2
1 parent
b20e37a2
Favor string-based newStream method
Showing
1 changed file
with
11 additions
and
16 deletions
qpdf/test_driver.cc
| @@ -503,10 +503,8 @@ void runtest(int n, char const* filename) | @@ -503,10 +503,8 @@ void runtest(int n, char const* filename) | ||
| 503 | else if (n == 9) | 503 | else if (n == 9) |
| 504 | { | 504 | { |
| 505 | QPDFObjectHandle root = pdf.getRoot(); | 505 | QPDFObjectHandle root = pdf.getRoot(); |
| 506 | - PointerHolder<Buffer> b1 = new Buffer(20); | ||
| 507 | - unsigned char* bp = b1->getBuffer(); | ||
| 508 | - memcpy(bp, (char*)"data for new stream\n", 20); // no null! | ||
| 509 | - QPDFObjectHandle qstream = QPDFObjectHandle::newStream(&pdf, b1); | 506 | + QPDFObjectHandle qstream = QPDFObjectHandle::newStream( |
| 507 | + &pdf, "data for new stream\n"); | ||
| 510 | QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf); | 508 | QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf); |
| 511 | try | 509 | try |
| 512 | { | 510 | { |
| @@ -517,11 +515,11 @@ void runtest(int n, char const* filename) | @@ -517,11 +515,11 @@ void runtest(int n, char const* filename) | ||
| 517 | { | 515 | { |
| 518 | std::cout << "exception: " << e.what() << std::endl; | 516 | std::cout << "exception: " << e.what() << std::endl; |
| 519 | } | 517 | } |
| 520 | - PointerHolder<Buffer> b2 = new Buffer(22); | ||
| 521 | - bp = b2->getBuffer(); | 518 | + PointerHolder<Buffer> buf = new Buffer(22); |
| 519 | + unsigned char* bp = buf->getBuffer(); | ||
| 522 | memcpy(bp, (char*)"data for other stream\n", 22); // no null! | 520 | memcpy(bp, (char*)"data for other stream\n", 22); // no null! |
| 523 | rstream.replaceStreamData( | 521 | rstream.replaceStreamData( |
| 524 | - b2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | 522 | + buf, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); |
| 525 | root.replaceKey("/QStream", qstream); | 523 | root.replaceKey("/QStream", qstream); |
| 526 | root.replaceKey("/RStream", rstream); | 524 | root.replaceKey("/RStream", rstream); |
| 527 | QPDFWriter w(pdf, "a.pdf"); | 525 | QPDFWriter w(pdf, "a.pdf"); |
| @@ -531,16 +529,13 @@ void runtest(int n, char const* filename) | @@ -531,16 +529,13 @@ void runtest(int n, char const* filename) | ||
| 531 | } | 529 | } |
| 532 | else if (n == 10) | 530 | else if (n == 10) |
| 533 | { | 531 | { |
| 534 | - PointerHolder<Buffer> b1 = new Buffer(37); | ||
| 535 | - unsigned char* bp = b1->getBuffer(); | ||
| 536 | - memcpy(bp, (char*)"BT /F1 12 Tf 72 620 Td (Baked) Tj ET\n", 37); | ||
| 537 | - PointerHolder<Buffer> b2 = new Buffer(38); | ||
| 538 | - bp = b2->getBuffer(); | ||
| 539 | - memcpy(bp, (char*)"BT /F1 18 Tf 72 520 Td (Mashed) Tj ET\n", 38); | ||
| 540 | - | ||
| 541 | std::vector<QPDFObjectHandle> pages = pdf.getAllPages(); | 532 | std::vector<QPDFObjectHandle> pages = pdf.getAllPages(); |
| 542 | - pages[0].addPageContents(QPDFObjectHandle::newStream(&pdf, b1), true); | ||
| 543 | - pages[0].addPageContents(QPDFObjectHandle::newStream(&pdf, b2), false); | 533 | + pages[0].addPageContents( |
| 534 | + QPDFObjectHandle::newStream( | ||
| 535 | + &pdf, "BT /F1 12 Tf 72 620 Td (Baked) Tj ET\n"), true); | ||
| 536 | + pages[0].addPageContents( | ||
| 537 | + QPDFObjectHandle::newStream( | ||
| 538 | + &pdf, "BT /F1 18 Tf 72 520 Td (Mashed) Tj ET\n"), false); | ||
| 544 | 539 | ||
| 545 | QPDFWriter w(pdf, "a.pdf"); | 540 | QPDFWriter w(pdf, "a.pdf"); |
| 546 | w.setStaticID(true); | 541 | w.setStaticID(true); |