Commit 5f59c32f876556a031dd2536b5c7f0fb0b58968d
1 parent
a167ce81
Add a few minor enhancements to recent work
Test coverage case for new newStream method Expose decimal_places argument for double-based newReal All enhancements suggested by Tobias.
Showing
4 changed files
with
6 additions
and
5 deletions
examples/pdf-double-page-size.cc
| @@ -36,8 +36,7 @@ static void doubleBoxSize(QPDFObjectHandle& page, char const* box_name) | @@ -36,8 +36,7 @@ static void doubleBoxSize(QPDFObjectHandle& page, char const* box_name) | ||
| 36 | { | 36 | { |
| 37 | doubled.push_back( | 37 | doubled.push_back( |
| 38 | QPDFObjectHandle::newReal( | 38 | QPDFObjectHandle::newReal( |
| 39 | - QUtil::double_to_string( | ||
| 40 | - box.getArrayItem(i).getNumericValue() * 2.0, 2))); | 39 | + box.getArrayItem(i).getNumericValue() * 2.0, 2)); |
| 41 | } | 40 | } |
| 42 | page.replaceKey(box_name, QPDFObjectHandle::newArray(doubled)); | 41 | page.replaceKey(box_name, QPDFObjectHandle::newArray(doubled)); |
| 43 | } | 42 | } |
include/qpdf/QPDFObjectHandle.hh
| @@ -102,7 +102,7 @@ class QPDFObjectHandle | @@ -102,7 +102,7 @@ class QPDFObjectHandle | ||
| 102 | QPDF_DLL | 102 | QPDF_DLL |
| 103 | static QPDFObjectHandle newReal(std::string const& value); | 103 | static QPDFObjectHandle newReal(std::string const& value); |
| 104 | QPDF_DLL | 104 | QPDF_DLL |
| 105 | - static QPDFObjectHandle newReal(double value); | 105 | + static QPDFObjectHandle newReal(double value, int decimal_places = 0); |
| 106 | QPDF_DLL | 106 | QPDF_DLL |
| 107 | static QPDFObjectHandle newName(std::string const& name); | 107 | static QPDFObjectHandle newName(std::string const& name); |
| 108 | QPDF_DLL | 108 | QPDF_DLL |
libqpdf/QPDFObjectHandle.cc
| @@ -604,9 +604,9 @@ QPDFObjectHandle::newReal(std::string const& value) | @@ -604,9 +604,9 @@ QPDFObjectHandle::newReal(std::string const& value) | ||
| 604 | } | 604 | } |
| 605 | 605 | ||
| 606 | QPDFObjectHandle | 606 | QPDFObjectHandle |
| 607 | -QPDFObjectHandle::newReal(double value) | 607 | +QPDFObjectHandle::newReal(double value, int decimal_places) |
| 608 | { | 608 | { |
| 609 | - return QPDFObjectHandle(new QPDF_Real(value)); | 609 | + return QPDFObjectHandle(new QPDF_Real(value, decimal_places)); |
| 610 | } | 610 | } |
| 611 | 611 | ||
| 612 | QPDFObjectHandle | 612 | QPDFObjectHandle |
| @@ -683,6 +683,7 @@ QPDFObjectHandle::newStream(QPDF* qpdf, PointerHolder<Buffer> data) | @@ -683,6 +683,7 @@ QPDFObjectHandle::newStream(QPDF* qpdf, PointerHolder<Buffer> data) | ||
| 683 | QPDFObjectHandle | 683 | QPDFObjectHandle |
| 684 | QPDFObjectHandle::newStream(QPDF* qpdf, std::string const& data) | 684 | QPDFObjectHandle::newStream(QPDF* qpdf, std::string const& data) |
| 685 | { | 685 | { |
| 686 | + QTC::TC("qpdf", "QPDFObjectHandle newStream with string"); | ||
| 686 | PointerHolder<Buffer> b = new Buffer(data.length()); | 687 | PointerHolder<Buffer> b = new Buffer(data.length()); |
| 687 | unsigned char* bp = b->getBuffer(); | 688 | unsigned char* bp = b->getBuffer(); |
| 688 | memcpy(bp, (char*)data.c_str(), data.length()); | 689 | memcpy(bp, (char*)data.c_str(), data.length()); |
qpdf/qpdf.testcov
| @@ -213,3 +213,4 @@ QPDFObjectHandle ERR shallow copy stream 0 | @@ -213,3 +213,4 @@ QPDFObjectHandle ERR shallow copy stream 0 | ||
| 213 | QPDFObjectHandle shallow copy array 0 | 213 | QPDFObjectHandle shallow copy array 0 |
| 214 | QPDFObjectHandle shallow copy dictionary 0 | 214 | QPDFObjectHandle shallow copy dictionary 0 |
| 215 | QPDFObjectHandle shallow copy scalar 0 | 215 | QPDFObjectHandle shallow copy scalar 0 |
| 216 | +QPDFObjectHandle newStream with string 0 |