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