2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-31 02:48:31 +00:00

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.
This commit is contained in:
Jay Berkenbilt 2012-06-27 10:43:27 -04:00
parent a167ce8120
commit 5f59c32f87
4 changed files with 6 additions and 5 deletions

View File

@ -36,8 +36,7 @@ static void doubleBoxSize(QPDFObjectHandle& page, char const* box_name)
{
doubled.push_back(
QPDFObjectHandle::newReal(
QUtil::double_to_string(
box.getArrayItem(i).getNumericValue() * 2.0, 2)));
box.getArrayItem(i).getNumericValue() * 2.0, 2));
}
page.replaceKey(box_name, QPDFObjectHandle::newArray(doubled));
}

View File

@ -102,7 +102,7 @@ class QPDFObjectHandle
QPDF_DLL
static QPDFObjectHandle newReal(std::string const& value);
QPDF_DLL
static QPDFObjectHandle newReal(double value);
static QPDFObjectHandle newReal(double value, int decimal_places = 0);
QPDF_DLL
static QPDFObjectHandle newName(std::string const& name);
QPDF_DLL

View File

@ -604,9 +604,9 @@ QPDFObjectHandle::newReal(std::string const& value)
}
QPDFObjectHandle
QPDFObjectHandle::newReal(double value)
QPDFObjectHandle::newReal(double value, int decimal_places)
{
return QPDFObjectHandle(new QPDF_Real(value));
return QPDFObjectHandle(new QPDF_Real(value, decimal_places));
}
QPDFObjectHandle
@ -683,6 +683,7 @@ QPDFObjectHandle::newStream(QPDF* qpdf, PointerHolder<Buffer> data)
QPDFObjectHandle
QPDFObjectHandle::newStream(QPDF* qpdf, std::string const& data)
{
QTC::TC("qpdf", "QPDFObjectHandle newStream with string");
PointerHolder<Buffer> b = new Buffer(data.length());
unsigned char* bp = b->getBuffer();
memcpy(bp, (char*)data.c_str(), data.length());

View File

@ -213,3 +213,4 @@ QPDFObjectHandle ERR shallow copy stream 0
QPDFObjectHandle shallow copy array 0
QPDFObjectHandle shallow copy dictionary 0
QPDFObjectHandle shallow copy scalar 0
QPDFObjectHandle newStream with string 0