mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-02 22:50:20 +00:00
Make use of the new Pipeline methods in some places
This commit is contained in:
parent
f1c6bb97db
commit
21d6e3231f
@ -118,9 +118,7 @@ ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline)
|
|||||||
|
|
||||||
for (size_t i = 0; i < n_stripes; ++i) {
|
for (size_t i = 0; i < n_stripes; ++i) {
|
||||||
for (size_t j = 0; j < width * stripe_height; ++j) {
|
for (size_t j = 0; j < width * stripe_height; ++j) {
|
||||||
p->write(
|
p->writeString(stripes[i]);
|
||||||
QUtil::unsigned_char_pointer(stripes[i].c_str()),
|
|
||||||
stripes[i].length());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p->finish();
|
p->finish();
|
||||||
|
@ -348,9 +348,7 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b)
|
|||||||
(void)jpeg_start_decompress(cinfo);
|
(void)jpeg_start_decompress(cinfo);
|
||||||
while (cinfo->output_scanline < cinfo->output_height) {
|
while (cinfo->output_scanline < cinfo->output_height) {
|
||||||
(void)jpeg_read_scanlines(cinfo, buffer, 1);
|
(void)jpeg_read_scanlines(cinfo, buffer, 1);
|
||||||
this->getNext()->write(
|
this->getNext()->write(buffer[0], width * sizeof(buffer[0][0]));
|
||||||
reinterpret_cast<unsigned char*>(buffer[0]),
|
|
||||||
width * sizeof(buffer[0][0]));
|
|
||||||
}
|
}
|
||||||
(void)jpeg_finish_decompress(cinfo);
|
(void)jpeg_finish_decompress(cinfo);
|
||||||
this->getNext()->finish();
|
this->getNext()->finish();
|
||||||
|
@ -2739,7 +2739,7 @@ QPDF::pipeStreamData(
|
|||||||
"unexpected EOF reading stream data");
|
"unexpected EOF reading stream data");
|
||||||
}
|
}
|
||||||
length -= len;
|
length -= len;
|
||||||
pipeline->write(QUtil::unsigned_char_pointer(buf), len);
|
pipeline->write(buf, len);
|
||||||
}
|
}
|
||||||
pipeline->finish();
|
pipeline->finish();
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -863,7 +863,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(
|
|||||||
|
|
||||||
TfFinder tff;
|
TfFinder tff;
|
||||||
Pl_QPDFTokenizer tok("tf", &tff);
|
Pl_QPDFTokenizer tok("tf", &tff);
|
||||||
tok.write(QUtil::unsigned_char_pointer(DA.c_str()), DA.length());
|
tok.writeString(DA);
|
||||||
tok.finish();
|
tok.finish();
|
||||||
double tf = tff.getTf();
|
double tf = tff.getTf();
|
||||||
DA = tff.getDA();
|
DA = tff.getDA();
|
||||||
|
@ -127,7 +127,7 @@ QPDFObjectHandle::TokenFilter::write(char const* data, size_t len)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (len) {
|
if (len) {
|
||||||
this->pipeline->write(QUtil::unsigned_char_pointer(data), len);
|
this->pipeline->write(data, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1857,7 +1857,7 @@ QPDFObjectHandle::pipeContentStreams(
|
|||||||
Pl_Buffer buf("concatenated content stream buffer");
|
Pl_Buffer buf("concatenated content stream buffer");
|
||||||
for (auto stream: streams) {
|
for (auto stream: streams) {
|
||||||
if (need_newline) {
|
if (need_newline) {
|
||||||
buf.write(QUtil::unsigned_char_pointer("\n"), 1);
|
buf.writeCStr("\n");
|
||||||
}
|
}
|
||||||
LastChar lc(&buf);
|
LastChar lc(&buf);
|
||||||
std::string og = QUtil::int_to_string(stream.getObjectID()) + " " +
|
std::string og = QUtil::int_to_string(stream.getObjectID()) + " " +
|
||||||
|
@ -190,7 +190,7 @@ InlineImageTracker::handleToken(QPDFTokenizer::Token const& token)
|
|||||||
QTC::TC(
|
QTC::TC(
|
||||||
"qpdf", "QPDFPageObjectHelper externalize inline image");
|
"qpdf", "QPDFPageObjectHelper externalize inline image");
|
||||||
Pl_Buffer b("image_data");
|
Pl_Buffer b("image_data");
|
||||||
b.write(QUtil::unsigned_char_pointer(image_data), len);
|
b.writeString(image_data);
|
||||||
b.finish();
|
b.finish();
|
||||||
QPDFObjectHandle dict =
|
QPDFObjectHandle dict =
|
||||||
convertIIDict(QPDFObjectHandle::parse(dict_str));
|
convertIIDict(QPDFObjectHandle::parse(dict_str));
|
||||||
|
@ -961,7 +961,7 @@ QPDFWriter::writeBinary(unsigned long long val, unsigned int bytes)
|
|||||||
void
|
void
|
||||||
QPDFWriter::writeString(std::string const& str)
|
QPDFWriter::writeString(std::string const& str)
|
||||||
{
|
{
|
||||||
this->m->pipeline->write(QUtil::unsigned_char_pointer(str), str.length());
|
this->m->pipeline->writeString(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1736,7 +1736,7 @@ QPDFWriter::unparseObject(
|
|||||||
true,
|
true,
|
||||||
QUtil::unsigned_char_pointer(this->m->cur_data_key),
|
QUtil::unsigned_char_pointer(this->m->cur_data_key),
|
||||||
this->m->cur_data_key.length());
|
this->m->cur_data_key.length());
|
||||||
pl.write(QUtil::unsigned_char_pointer(val), val.length());
|
pl.writeString(val);
|
||||||
pl.finish();
|
pl.finish();
|
||||||
auto buf = bufpl.getBufferSharedPointer();
|
auto buf = bufpl.getBufferSharedPointer();
|
||||||
val = QPDF_String(std::string(
|
val = QPDF_String(std::string(
|
||||||
|
@ -235,7 +235,7 @@ process_with_aes(
|
|||||||
}
|
}
|
||||||
aes.disablePadding();
|
aes.disablePadding();
|
||||||
for (unsigned int i = 0; i < repetitions; ++i) {
|
for (unsigned int i = 0; i < repetitions; ++i) {
|
||||||
aes.write(QUtil::unsigned_char_pointer(data), data.length());
|
aes.writeString(data);
|
||||||
}
|
}
|
||||||
aes.finish();
|
aes.finish();
|
||||||
auto bufp = buffer.getBufferSharedPointer();
|
auto bufp = buffer.getBufferSharedPointer();
|
||||||
@ -255,9 +255,9 @@ hash_V5(
|
|||||||
QPDF::EncryptionData const& data)
|
QPDF::EncryptionData const& data)
|
||||||
{
|
{
|
||||||
Pl_SHA2 hash(256);
|
Pl_SHA2 hash(256);
|
||||||
hash.write(QUtil::unsigned_char_pointer(password), password.length());
|
hash.writeString(password);
|
||||||
hash.write(QUtil::unsigned_char_pointer(salt), salt.length());
|
hash.writeString(salt);
|
||||||
hash.write(QUtil::unsigned_char_pointer(udata), udata.length());
|
hash.writeString(udata);
|
||||||
hash.finish();
|
hash.finish();
|
||||||
std::string K = hash.getRawDigest();
|
std::string K = hash.getRawDigest();
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ hash_V5(
|
|||||||
E_mod_3 %= 3;
|
E_mod_3 %= 3;
|
||||||
int next_hash = ((E_mod_3 == 0) ? 256 : (E_mod_3 == 1) ? 384 : 512);
|
int next_hash = ((E_mod_3 == 0) ? 256 : (E_mod_3 == 1) ? 384 : 512);
|
||||||
Pl_SHA2 sha2(next_hash);
|
Pl_SHA2 sha2(next_hash);
|
||||||
sha2.write(QUtil::unsigned_char_pointer(E), E.length());
|
sha2.writeString(E);
|
||||||
sha2.finish();
|
sha2.finish();
|
||||||
K = sha2.getRawDigest();
|
K = sha2.getRawDigest();
|
||||||
|
|
||||||
@ -1151,7 +1151,7 @@ QPDF::decryptString(std::string& str, int objid, int generation)
|
|||||||
false,
|
false,
|
||||||
QUtil::unsigned_char_pointer(key),
|
QUtil::unsigned_char_pointer(key),
|
||||||
key.length());
|
key.length());
|
||||||
pl.write(QUtil::unsigned_char_pointer(str), str.length());
|
pl.writeString(str);
|
||||||
pl.finish();
|
pl.finish();
|
||||||
auto buf = bufpl.getBufferSharedPointer();
|
auto buf = bufpl.getBufferSharedPointer();
|
||||||
str = std::string(
|
str = std::string(
|
||||||
|
@ -477,9 +477,7 @@ test_8(QPDF& pdf, char const* arg2)
|
|||||||
}
|
}
|
||||||
Pl_Buffer p1("buffer");
|
Pl_Buffer p1("buffer");
|
||||||
Pl_Flate p2("compress", &p1, Pl_Flate::a_deflate);
|
Pl_Flate p2("compress", &p1, Pl_Flate::a_deflate);
|
||||||
p2.write(
|
p2 << "new data for stream\n";
|
||||||
QUtil::unsigned_char_pointer("new data for stream\n"),
|
|
||||||
20); // no null!
|
|
||||||
p2.finish();
|
p2.finish();
|
||||||
auto b = p1.getBufferSharedPointer();
|
auto b = p1.getBufferSharedPointer();
|
||||||
// This is a bogus way to use StreamDataProvider, but it does
|
// This is a bogus way to use StreamDataProvider, but it does
|
||||||
@ -1021,9 +1019,7 @@ test_27(QPDF& pdf, char const* arg2)
|
|||||||
{
|
{
|
||||||
// Local scope
|
// Local scope
|
||||||
Pl_Buffer pl("buffer");
|
Pl_Buffer pl("buffer");
|
||||||
pl.write(
|
pl.writeCStr("new data for stream\n");
|
||||||
QUtil::unsigned_char_pointer("new data for stream\n"),
|
|
||||||
20); // no null!
|
|
||||||
pl.finish();
|
pl.finish();
|
||||||
auto b = pl.getBufferSharedPointer();
|
auto b = pl.getBufferSharedPointer();
|
||||||
Provider* provider = new Provider(b);
|
Provider* provider = new Provider(b);
|
||||||
@ -1050,9 +1046,7 @@ test_27(QPDF& pdf, char const* arg2)
|
|||||||
{
|
{
|
||||||
// Local scope
|
// Local scope
|
||||||
Pl_Buffer pl("buffer");
|
Pl_Buffer pl("buffer");
|
||||||
pl.write(
|
pl.writeCStr("more data for stream\n");
|
||||||
QUtil::unsigned_char_pointer("more data for stream\n"),
|
|
||||||
21); // no null!
|
|
||||||
pl.finish();
|
pl.finish();
|
||||||
auto b = pl.getBufferSharedPointer();
|
auto b = pl.getBufferSharedPointer();
|
||||||
Provider* provider = new Provider(b);
|
Provider* provider = new Provider(b);
|
||||||
@ -2648,7 +2642,8 @@ test_76(QPDF& pdf, char const* arg2)
|
|||||||
auto efs2 = QPDFEFStreamObjectHelper::createEFStream(pdf, "from string");
|
auto efs2 = QPDFEFStreamObjectHelper::createEFStream(pdf, "from string");
|
||||||
efs2.setSubtype("text/plain");
|
efs2.setSubtype("text/plain");
|
||||||
Pl_Buffer p("buffer");
|
Pl_Buffer p("buffer");
|
||||||
p.write(QUtil::unsigned_char_pointer("from buffer"), 11);
|
// exercise Pipeline::operator<<(std::string const&)
|
||||||
|
p << std::string("from buffer");
|
||||||
p.finish();
|
p.finish();
|
||||||
auto efs3 = QPDFEFStreamObjectHelper::createEFStream(
|
auto efs3 = QPDFEFStreamObjectHelper::createEFStream(
|
||||||
pdf, p.getBufferSharedPointer());
|
pdf, p.getBufferSharedPointer());
|
||||||
@ -2700,7 +2695,7 @@ test_78(QPDF& pdf, char const* arg2)
|
|||||||
// Test functional versions of replaceStreamData()
|
// Test functional versions of replaceStreamData()
|
||||||
|
|
||||||
auto f1 = [](Pipeline* p) {
|
auto f1 = [](Pipeline* p) {
|
||||||
p->write(QUtil::unsigned_char_pointer("potato"), 6);
|
p->writeCStr("potato");
|
||||||
p->finish();
|
p->finish();
|
||||||
};
|
};
|
||||||
auto f2 = [](Pipeline* p, bool suppress_warnings, bool will_retry) {
|
auto f2 = [](Pipeline* p, bool suppress_warnings, bool will_retry) {
|
||||||
@ -2712,7 +2707,7 @@ test_78(QPDF& pdf, char const* arg2)
|
|||||||
if (!suppress_warnings) {
|
if (!suppress_warnings) {
|
||||||
std::cerr << "warning" << std::endl;
|
std::cerr << "warning" << std::endl;
|
||||||
}
|
}
|
||||||
p->write(QUtil::unsigned_char_pointer("salad"), 5);
|
p->writeCStr("salad");
|
||||||
p->finish();
|
p->finish();
|
||||||
std::cerr << "f2 done" << std::endl;
|
std::cerr << "f2 done" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
@ -2767,7 +2762,7 @@ test_79(QPDF& pdf, char const* arg2)
|
|||||||
|
|
||||||
// Use a provider
|
// Use a provider
|
||||||
Pl_Buffer b("buffer");
|
Pl_Buffer b("buffer");
|
||||||
b.write(QUtil::unsigned_char_pointer("from buffer"), 11);
|
b.writeCStr("from buffer");
|
||||||
b.finish();
|
b.finish();
|
||||||
auto bp = b.getBufferSharedPointer();
|
auto bp = b.getBufferSharedPointer();
|
||||||
auto s3 = QPDFObjectHandle::newStream(&pdf, bp);
|
auto s3 = QPDFObjectHandle::newStream(&pdf, bp);
|
||||||
|
Loading…
Reference in New Issue
Block a user