mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-02 22:50:20 +00:00
Update for clean compile with POINTERHOLDER_TRANSITION=2
This commit is contained in:
parent
3f22bea084
commit
c62e8e2b28
@ -22,7 +22,7 @@ LDFLAGS=@LDFLAGS@
|
||||
LIBS=@LIBS@
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
CXX=@CXX@
|
||||
CXXFLAGS=@CXXFLAGS@ $(CXXWFLAGS) $(WFLAGS)
|
||||
CXXFLAGS=@CXXFLAGS@ $(CXXWFLAGS) $(WFLAGS) -DPOINTERHOLDER_TRANSITION=2
|
||||
RPATH=@RPATH@
|
||||
AR=@AR@
|
||||
RANLIB=@RANLIB@
|
||||
|
@ -220,8 +220,11 @@ int main(int argc, char* argv[])
|
||||
// applied. See comments on the filters for additional
|
||||
// details.
|
||||
QPDFPageObjectHelper& page(*iter);
|
||||
page.addContentTokenFilter(new StringReverser);
|
||||
page.addContentTokenFilter(new ColorToGray);
|
||||
page.addContentTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter>(
|
||||
new StringReverser));
|
||||
page.addContentTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter>(new ColorToGray));
|
||||
}
|
||||
|
||||
QPDFWriter w(pdf, outfilename);
|
||||
|
@ -139,7 +139,7 @@ int main(int argc, char* argv[])
|
||||
qpdf.processFile(infilename, password);
|
||||
|
||||
ImageInverter* inv = new ImageInverter;
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> p = inv;
|
||||
auto p = PointerHolder<QPDFObjectHandle::StreamDataProvider>(inv);
|
||||
|
||||
// For each page...
|
||||
std::vector<QPDFPageObjectHelper> pages =
|
||||
|
@ -47,9 +47,9 @@ FuzzHelper::FuzzHelper(unsigned char const* data, size_t size) :
|
||||
PointerHolder<QPDF>
|
||||
FuzzHelper::getQpdf()
|
||||
{
|
||||
PointerHolder<InputSource> is =
|
||||
new BufferInputSource("fuzz input", &this->input_buffer);
|
||||
PointerHolder<QPDF> qpdf = new QPDF();
|
||||
auto is = PointerHolder<InputSource>(
|
||||
new BufferInputSource("fuzz input", &this->input_buffer));
|
||||
auto qpdf = make_pointer_holder<QPDF>();
|
||||
qpdf->processInputSource(is);
|
||||
return qpdf;
|
||||
}
|
||||
@ -57,7 +57,7 @@ FuzzHelper::getQpdf()
|
||||
PointerHolder<QPDFWriter>
|
||||
FuzzHelper::getWriter(PointerHolder<QPDF> qpdf)
|
||||
{
|
||||
PointerHolder<QPDFWriter> w = new QPDFWriter(*qpdf);
|
||||
auto w = make_pointer_holder<QPDFWriter>(*qpdf);
|
||||
w->setOutputPipeline(&this->discard);
|
||||
w->setDecodeLevel(qpdf_dl_all);
|
||||
return w;
|
||||
|
@ -24,7 +24,9 @@
|
||||
|
||||
#include <qpdf/DLL.h>
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <memory>
|
||||
|
||||
class Buffer
|
||||
{
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <qpdf/InputSource.hh>
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class FileInputSource;
|
||||
|
||||
class ClosedFileInputSource: public InputSource
|
||||
|
@ -25,8 +25,10 @@
|
||||
#include <qpdf/DLL.h>
|
||||
#include <qpdf/Types.h>
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class QPDF_DLL_CLASS InputSource
|
||||
{
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <qpdf/DLL.h>
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
@ -46,7 +46,9 @@
|
||||
|
||||
#include <qpdf/DLL.h>
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class QPDF_DLL_CLASS Pipeline
|
||||
{
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
#include <qpdf/Buffer.hh>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Pl_Buffer: public Pipeline
|
||||
{
|
||||
public:
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <qpdf/QPDFObjectHandle.hh>
|
||||
#include <qpdf/Pl_Buffer.hh>
|
||||
|
||||
#include <memory>
|
||||
|
||||
// Tokenize the incoming text using QPDFTokenizer and pass the tokens
|
||||
// in turn to a QPDFObjectHandle::TokenFilter object. All bytes of
|
||||
// incoming content will be included in exactly one token and passed
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <qpdf/QPDFObjGen.hh>
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
|
@ -26,8 +26,10 @@
|
||||
|
||||
#include <qpdf/InputSource.hh>
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <memory>
|
||||
|
||||
class QPDFTokenizer
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ Buffer::copy(Buffer const& rhs)
|
||||
{
|
||||
if (this != &rhs)
|
||||
{
|
||||
this->m = new Members(rhs.m->size, 0, true);
|
||||
this->m = PointerHolder<Members>(new Members(rhs.m->size, 0, true));
|
||||
if (this->m->size)
|
||||
{
|
||||
memcpy(this->m->buf, rhs.m->buf, this->m->size);
|
||||
|
@ -27,7 +27,7 @@ ClosedFileInputSource::before()
|
||||
{
|
||||
if (0 == this->m->fis.get())
|
||||
{
|
||||
this->m->fis = new FileInputSource();
|
||||
this->m->fis = make_pointer_holder<FileInputSource>();
|
||||
this->m->fis->setFilename(this->m->filename.c_str());
|
||||
this->m->fis->seek(this->m->offset, SEEK_SET);
|
||||
this->m->fis->setLastOffset(this->last_offset);
|
||||
|
@ -27,7 +27,7 @@ FileInputSource::FileInputSource() :
|
||||
void
|
||||
FileInputSource::setFilename(char const* filename)
|
||||
{
|
||||
this->m = new Members(true);
|
||||
this->m = PointerHolder<Members>(new Members(true));
|
||||
this->m->filename = filename;
|
||||
this->m->file = QUtil::safe_fopen(filename, "rb");
|
||||
}
|
||||
@ -36,7 +36,7 @@ void
|
||||
FileInputSource::setFile(
|
||||
char const* description, FILE* filep, bool close_file)
|
||||
{
|
||||
this->m = new Members(close_file);
|
||||
this->m = PointerHolder<Members>(new Members(close_file));
|
||||
this->m->filename = description;
|
||||
this->m->file = filep;
|
||||
this->seek(0, SEEK_SET);
|
||||
|
@ -31,14 +31,14 @@ Pl_Buffer::write(unsigned char* buf, size_t len)
|
||||
{
|
||||
if (this->m->data.get() == 0)
|
||||
{
|
||||
this->m->data = new Buffer(len);
|
||||
this->m->data = make_pointer_holder<Buffer>(len);
|
||||
}
|
||||
size_t cur_size = this->m->data->getSize();
|
||||
size_t left = cur_size - this->m->total_size;
|
||||
if (left < len)
|
||||
{
|
||||
size_t new_size = std::max(this->m->total_size + len, 2 * cur_size);
|
||||
PointerHolder<Buffer> b = new Buffer(new_size);
|
||||
auto b = make_pointer_holder<Buffer>(new_size);
|
||||
memcpy(b->getBuffer(), this->m->data->getBuffer(), this->m->total_size);
|
||||
this->m->data = b;
|
||||
}
|
||||
@ -108,5 +108,5 @@ Pl_Buffer::getMallocBuffer(unsigned char **buf, size_t* len)
|
||||
{
|
||||
*buf = nullptr;
|
||||
}
|
||||
this->m = new Members();
|
||||
this->m = PointerHolder<Members>(new Members());
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ void
|
||||
Pl_QPDFTokenizer::finish()
|
||||
{
|
||||
this->m->buf.finish();
|
||||
PointerHolder<InputSource> input =
|
||||
auto input = PointerHolder<InputSource>(
|
||||
new BufferInputSource("tokenizer data",
|
||||
this->m->buf.getBuffer(), true);
|
||||
|
||||
this->m->buf.getBuffer(), true));
|
||||
|
||||
while (true)
|
||||
{
|
||||
QPDFTokenizer::Token token = this->m->tokenizer.readToken(
|
||||
|
@ -269,7 +269,7 @@ QPDF::processFile(char const* filename, char const* password)
|
||||
{
|
||||
FileInputSource* fi = new FileInputSource();
|
||||
fi->setFilename(filename);
|
||||
processInputSource(fi, password);
|
||||
processInputSource(PointerHolder<InputSource>(fi), password);
|
||||
}
|
||||
|
||||
void
|
||||
@ -278,7 +278,7 @@ QPDF::processFile(char const* description, FILE* filep,
|
||||
{
|
||||
FileInputSource* fi = new FileInputSource();
|
||||
fi->setFile(description, filep, close_file);
|
||||
processInputSource(fi, password);
|
||||
processInputSource(PointerHolder<InputSource>(fi), password);
|
||||
}
|
||||
|
||||
void
|
||||
@ -287,10 +287,11 @@ QPDF::processMemoryFile(char const* description,
|
||||
char const* password)
|
||||
{
|
||||
processInputSource(
|
||||
new BufferInputSource(
|
||||
description,
|
||||
new Buffer(QUtil::unsigned_char_pointer(buf), length),
|
||||
true),
|
||||
PointerHolder<InputSource>(
|
||||
new BufferInputSource(
|
||||
description,
|
||||
new Buffer(QUtil::unsigned_char_pointer(buf), length),
|
||||
true)),
|
||||
password);
|
||||
}
|
||||
|
||||
@ -305,7 +306,7 @@ QPDF::processInputSource(PointerHolder<InputSource> source,
|
||||
void
|
||||
QPDF::closeInputSource()
|
||||
{
|
||||
this->m->file = new InvalidInputSource();
|
||||
this->m->file = PointerHolder<InputSource>(new InvalidInputSource());
|
||||
}
|
||||
|
||||
void
|
||||
@ -425,7 +426,8 @@ QPDF::findHeader()
|
||||
// offsets in the file are such that 0 points to the
|
||||
// beginning of the header.
|
||||
QTC::TC("qpdf", "QPDF global offset");
|
||||
this->m->file = new OffsetInputSource(this->m->file, global_offset);
|
||||
this->m->file = PointerHolder<InputSource>(
|
||||
new OffsetInputSource(this->m->file, global_offset));
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
@ -1607,7 +1609,8 @@ QPDF::readObject(PointerHolder<InputSource> input,
|
||||
StringDecrypter* decrypter = 0;
|
||||
if (this->m->encp->encrypted && (! in_object_stream))
|
||||
{
|
||||
decrypter_ph = new StringDecrypter(this, objid, generation);
|
||||
decrypter_ph = make_pointer_holder<StringDecrypter>(
|
||||
this, objid, generation);
|
||||
decrypter = decrypter_ph.get();
|
||||
}
|
||||
QPDFObjectHandle object = QPDFObjectHandle::parse(
|
||||
@ -2105,7 +2108,7 @@ QPDF::resolve(int objid, int generation)
|
||||
"loop detected resolving object " +
|
||||
QUtil::int_to_string(objid) + " " +
|
||||
QUtil::int_to_string(generation)));
|
||||
return new QPDF_Null;
|
||||
return PointerHolder<QPDFObject>(new QPDF_Null);
|
||||
}
|
||||
ResolveRecorder rr(this, og);
|
||||
|
||||
@ -2231,10 +2234,11 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
|
||||
std::map<int, int> offsets;
|
||||
|
||||
PointerHolder<Buffer> bp = obj_stream.getStreamData(qpdf_dl_specialized);
|
||||
PointerHolder<InputSource> input = new BufferInputSource(
|
||||
this->m->file->getName() +
|
||||
" object stream " + QUtil::int_to_string(obj_stream_number),
|
||||
bp.get());
|
||||
auto input = PointerHolder<InputSource>(
|
||||
new BufferInputSource(
|
||||
this->m->file->getName() +
|
||||
" object stream " + QUtil::int_to_string(obj_stream_number),
|
||||
bp.get()));
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
@ -2630,7 +2634,9 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||
{
|
||||
this->m->copied_stream_data_provider =
|
||||
new CopiedStreamDataProvider(*this);
|
||||
this->m->copied_streams = this->m->copied_stream_data_provider;
|
||||
this->m->copied_streams =
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider>(
|
||||
this->m->copied_stream_data_provider);
|
||||
}
|
||||
QPDFObjGen local_og(result.getObjGen());
|
||||
// Copy information from the foreign stream so we can pipe its
|
||||
@ -2686,8 +2692,8 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||
}
|
||||
else
|
||||
{
|
||||
PointerHolder<ForeignStreamData> foreign_stream_data =
|
||||
new ForeignStreamData(
|
||||
auto foreign_stream_data =
|
||||
make_pointer_holder<ForeignStreamData>(
|
||||
foreign_stream_qpdf->m->encp,
|
||||
foreign_stream_qpdf->m->file,
|
||||
foreign.getObjectID(),
|
||||
|
@ -768,7 +768,7 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances(
|
||||
ResourceReplacer rr(dr_map, rf.getNamesByResourceType());
|
||||
Pl_Buffer buf_pl("filtered DA");
|
||||
da_stream.filterAsContents(&rr, &buf_pl);
|
||||
PointerHolder<Buffer> buf = buf_pl.getBuffer();
|
||||
auto buf = buf_pl.getBufferSharedPointer();
|
||||
std::string new_da(
|
||||
reinterpret_cast<char*>(buf->getBuffer()), buf->getSize());
|
||||
obj.replaceKey("/DA", QPDFObjectHandle::newString(new_da));
|
||||
@ -871,7 +871,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
|
||||
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper AP parse error");
|
||||
}
|
||||
auto rr = new ResourceReplacer(dr_map, rf.getNamesByResourceType());
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter> tf = rr;
|
||||
auto tf = PointerHolder<QPDFObjectHandle::TokenFilter>(rr);
|
||||
stream.addTokenFilter(tf);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
@ -902,7 +902,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
|
||||
}
|
||||
else if ((from_qpdf != &this->qpdf) && (! from_afdh))
|
||||
{
|
||||
afdhph = new QPDFAcroFormDocumentHelper(*from_qpdf);
|
||||
afdhph = make_pointer_holder<QPDFAcroFormDocumentHelper>(*from_qpdf);
|
||||
from_afdh = afdhph.get();
|
||||
}
|
||||
bool foreign = (from_qpdf != &this->qpdf);
|
||||
|
@ -1008,5 +1008,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(
|
||||
opt.at(i) = (*encoder)(opt.at(i), '?');
|
||||
}
|
||||
|
||||
AS.addTokenFilter(new ValueSetter(DA, V, opt, tf, bbox));
|
||||
AS.addTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter>(
|
||||
new ValueSetter(DA, V, opt, tf, bbox)));
|
||||
}
|
||||
|
@ -2854,14 +2854,14 @@ QPDFJob::handlePageSpecs(
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFJob keep files open n");
|
||||
cis = new ClosedFileInputSource(page_spec.filename.c_str());
|
||||
is = cis;
|
||||
is = PointerHolder<InputSource>(cis);
|
||||
cis->stayOpen(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFJob keep files open y");
|
||||
FileInputSource* fis = new FileInputSource();
|
||||
is = fis;
|
||||
is = PointerHolder<InputSource>(fis);
|
||||
fis->setFilename(page_spec.filename.c_str());
|
||||
}
|
||||
std::shared_ptr<QPDF> qpdf_ph = processInputSource(is, password);
|
||||
@ -3489,9 +3489,10 @@ QPDFJob::setWriterOptions(QPDF& pdf, QPDFWriter& w)
|
||||
if (m->progress && m->outfilename)
|
||||
{
|
||||
w.registerProgressReporter(
|
||||
new ProgressReporter(
|
||||
*(this->m->cout), this->m->message_prefix,
|
||||
m->outfilename.get()));
|
||||
PointerHolder<QPDFWriter::ProgressReporter>(
|
||||
new ProgressReporter(
|
||||
*(this->m->cout), this->m->message_prefix,
|
||||
m->outfilename.get())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1603,7 +1603,7 @@ QPDFObjectHandle::replaceStreamData(std::string const& data,
|
||||
QPDFObjectHandle const& decode_parms)
|
||||
{
|
||||
assertStream();
|
||||
PointerHolder<Buffer> b = new Buffer(data.length());
|
||||
auto b = make_pointer_holder<Buffer>(data.length());
|
||||
unsigned char* bp = b->getBuffer();
|
||||
memcpy(bp, data.c_str(), data.length());
|
||||
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||
@ -1659,7 +1659,8 @@ QPDFObjectHandle::replaceStreamData(std::function<void(Pipeline*)> provider,
|
||||
QPDFObjectHandle const& decode_parms)
|
||||
{
|
||||
assertStream();
|
||||
PointerHolder<StreamDataProvider> sdp = new FunctionProvider(provider);
|
||||
auto sdp = PointerHolder<StreamDataProvider>(
|
||||
new FunctionProvider(provider));
|
||||
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||
sdp, filter, decode_parms);
|
||||
}
|
||||
@ -1671,7 +1672,8 @@ QPDFObjectHandle::replaceStreamData(
|
||||
QPDFObjectHandle const& decode_parms)
|
||||
{
|
||||
assertStream();
|
||||
PointerHolder<StreamDataProvider> sdp = new FunctionProvider(provider);
|
||||
auto sdp = PointerHolder<StreamDataProvider>(
|
||||
new FunctionProvider(provider));
|
||||
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||
sdp, filter, decode_parms);
|
||||
}
|
||||
@ -1886,8 +1888,8 @@ QPDFObjectHandle::coalesceContentStreams()
|
||||
QPDFObjectHandle new_contents = newStream(qpdf);
|
||||
this->replaceKey("/Contents", new_contents);
|
||||
|
||||
PointerHolder<StreamDataProvider> provider =
|
||||
new CoalesceProvider(*this, contents);
|
||||
auto provider = PointerHolder<StreamDataProvider>(
|
||||
new CoalesceProvider(*this, contents));
|
||||
new_contents.replaceStreamData(provider, newNull(), newNull());
|
||||
}
|
||||
|
||||
@ -1976,8 +1978,8 @@ QPDFObjectHandle::parse(QPDF* context,
|
||||
std::string const& object_str,
|
||||
std::string const& object_description)
|
||||
{
|
||||
PointerHolder<InputSource> input =
|
||||
new BufferInputSource("parsed object", object_str);
|
||||
auto input = PointerHolder<InputSource>(
|
||||
new BufferInputSource("parsed object", object_str));
|
||||
QPDFTokenizer tokenizer;
|
||||
bool empty = false;
|
||||
QPDFObjectHandle result =
|
||||
@ -2103,7 +2105,7 @@ QPDFObjectHandle::parseContentStream_internal(
|
||||
Pl_Buffer buf("concatenated stream data buffer");
|
||||
std::string all_description;
|
||||
pipeContentStreams(&buf, description, all_description);
|
||||
PointerHolder<Buffer> stream_data = buf.getBuffer();
|
||||
auto stream_data = buf.getBufferSharedPointer();
|
||||
callbacks->contentSize(stream_data->getSize());
|
||||
try
|
||||
{
|
||||
@ -2125,8 +2127,8 @@ QPDFObjectHandle::parseContentStream_data(
|
||||
QPDF* context)
|
||||
{
|
||||
size_t stream_length = stream_data->getSize();
|
||||
PointerHolder<InputSource> input =
|
||||
new BufferInputSource(description, stream_data.get());
|
||||
auto input = PointerHolder<InputSource>(
|
||||
new BufferInputSource(description, stream_data.get()));
|
||||
QPDFTokenizer tokenizer;
|
||||
tokenizer.allowEOF();
|
||||
bool empty = false;
|
||||
@ -3078,32 +3080,32 @@ QPDFObjectHandle::copyObject(std::set<QPDFObjGen>& visited,
|
||||
if (isBool())
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone bool");
|
||||
new_obj = new QPDF_Bool(getBoolValue());
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Bool(getBoolValue()));
|
||||
}
|
||||
else if (isNull())
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone null");
|
||||
new_obj = new QPDF_Null();
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Null());
|
||||
}
|
||||
else if (isInteger())
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone integer");
|
||||
new_obj = new QPDF_Integer(getIntValue());
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Integer(getIntValue()));
|
||||
}
|
||||
else if (isReal())
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone real");
|
||||
new_obj = new QPDF_Real(getRealValue());
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Real(getRealValue()));
|
||||
}
|
||||
else if (isName())
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone name");
|
||||
new_obj = new QPDF_Name(getName());
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Name(getName()));
|
||||
}
|
||||
else if (isString())
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFObjectHandle clone string");
|
||||
new_obj = new QPDF_String(getStringValue());
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_String(getStringValue()));
|
||||
}
|
||||
else if (isArray())
|
||||
{
|
||||
@ -3121,7 +3123,7 @@ QPDFObjectHandle::copyObject(std::set<QPDFObjGen>& visited,
|
||||
first_level_only, stop_at_streams);
|
||||
}
|
||||
}
|
||||
new_obj = new QPDF_Array(items);
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Array(items));
|
||||
}
|
||||
else if (isDictionary())
|
||||
{
|
||||
@ -3140,7 +3142,7 @@ QPDFObjectHandle::copyObject(std::set<QPDFObjGen>& visited,
|
||||
first_level_only, stop_at_streams);
|
||||
}
|
||||
}
|
||||
new_obj = new QPDF_Dictionary(items);
|
||||
new_obj = PointerHolder<QPDFObject>(new QPDF_Dictionary(items));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3461,7 +3463,7 @@ QPDFObjectHandle::dereference()
|
||||
{
|
||||
// QPDF::resolve never returns an uninitialized object, but
|
||||
// check just in case.
|
||||
this->obj = new QPDF_Null();
|
||||
this->obj = PointerHolder<QPDFObject>(new QPDF_Null());
|
||||
}
|
||||
else if (dynamic_cast<QPDF_Reserved*>(obj.get()))
|
||||
{
|
||||
|
@ -114,7 +114,8 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name)
|
||||
if (dests.isDictionary())
|
||||
{
|
||||
this->m->names_dest =
|
||||
new QPDFNameTreeObjectHelper(dests, this->qpdf);
|
||||
make_pointer_holder<QPDFNameTreeObjectHelper>(
|
||||
dests, this->qpdf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ QPDFOutlineObjectHelper::QPDFOutlineObjectHelper(
|
||||
while (! cur.isNull())
|
||||
{
|
||||
QPDFOutlineObjectHelper new_ooh(cur, dh, 1 + depth);
|
||||
new_ooh.m->parent = new QPDFOutlineObjectHelper(*this);
|
||||
new_ooh.m->parent = make_pointer_holder<QPDFOutlineObjectHelper>(*this);
|
||||
this->m->kids.push_back(new_ooh);
|
||||
cur = cur.getKey("/Next");
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ QPDFPageLabelDocumentHelper::QPDFPageLabelDocumentHelper(QPDF& qpdf) :
|
||||
QPDFObjectHandle root = qpdf.getRoot();
|
||||
if (root.hasKey("/PageLabels"))
|
||||
{
|
||||
this->m->labels = new QPDFNumberTreeObjectHelper(
|
||||
this->m->labels = make_pointer_holder<QPDFNumberTreeObjectHelper>(
|
||||
root.getKey("/PageLabels"), this->qpdf);
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ InlineImageTracker::handleToken(QPDFTokenizer::Token const& token)
|
||||
std::string name = resources.getUniqueResourceName(
|
||||
"/IIm", this->min_suffix);
|
||||
QPDFObjectHandle image = QPDFObjectHandle::newStream(
|
||||
this->qpdf, b.getBuffer());
|
||||
this->qpdf, b.getBufferSharedPointer());
|
||||
image.replaceDict(dict);
|
||||
resources.getKey("/XObject").replaceKey(name, image);
|
||||
write(name);
|
||||
@ -521,7 +521,7 @@ QPDFPageObjectHelper::externalizeInlineImages(size_t min_size, bool shallow)
|
||||
if (this->oh.isFormXObject())
|
||||
{
|
||||
this->oh.replaceStreamData(
|
||||
b.getBuffer(),
|
||||
b.getBufferSharedPointer(),
|
||||
QPDFObjectHandle::newNull(),
|
||||
QPDFObjectHandle::newNull());
|
||||
}
|
||||
@ -530,7 +530,8 @@ QPDFPageObjectHelper::externalizeInlineImages(size_t min_size, bool shallow)
|
||||
this->oh.replaceKey(
|
||||
"/Contents",
|
||||
QPDFObjectHandle::newStream(
|
||||
this->oh.getOwningQPDF(), b.getBuffer()));
|
||||
this->oh.getOwningQPDF(),
|
||||
b.getBufferSharedPointer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -914,8 +915,8 @@ QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations)
|
||||
" XObject created from page will not work");
|
||||
}
|
||||
newdict.replaceKey("/BBox", bbox);
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> provider =
|
||||
new ContentProvider(this->oh);
|
||||
auto provider = PointerHolder<QPDFObjectHandle::StreamDataProvider>(
|
||||
new ContentProvider(this->oh));
|
||||
result.replaceStreamData(
|
||||
provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
|
||||
QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false);
|
||||
@ -1221,7 +1222,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
|
||||
PointerHolder<QPDFAcroFormDocumentHelper> afdhph;
|
||||
if (! afdh)
|
||||
{
|
||||
afdhph = new QPDFAcroFormDocumentHelper(*qpdf);
|
||||
afdhph = make_pointer_holder<QPDFAcroFormDocumentHelper>(*qpdf);
|
||||
afdh = afdhph.get();
|
||||
}
|
||||
afdh->transformAnnotations(
|
||||
@ -1269,7 +1270,7 @@ QPDFPageObjectHelper::copyAnnotations(
|
||||
PointerHolder<QPDFAcroFormDocumentHelper> from_afdhph;
|
||||
if (! afdh)
|
||||
{
|
||||
afdhph = new QPDFAcroFormDocumentHelper(*this_qpdf);
|
||||
afdhph = make_pointer_holder<QPDFAcroFormDocumentHelper>(*this_qpdf);
|
||||
afdh = afdhph.get();
|
||||
}
|
||||
if (this_qpdf == from_qpdf)
|
||||
@ -1287,7 +1288,8 @@ QPDFPageObjectHelper::copyAnnotations(
|
||||
}
|
||||
else
|
||||
{
|
||||
from_afdhph = new QPDFAcroFormDocumentHelper(*from_qpdf);
|
||||
from_afdhph =
|
||||
make_pointer_holder<QPDFAcroFormDocumentHelper>(*from_qpdf);
|
||||
from_afdh = from_afdhph.get();
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1108,7 @@ QPDFWriter::PipelinePopper::~PipelinePopper()
|
||||
Pl_Buffer* buf = dynamic_cast<Pl_Buffer*>(p);
|
||||
if (bp && buf)
|
||||
{
|
||||
*bp = buf->getBuffer();
|
||||
*bp = buf->getBufferSharedPointer();
|
||||
}
|
||||
delete p;
|
||||
}
|
||||
@ -1918,7 +1918,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
|
||||
this->m->cur_data_key.length());
|
||||
pl.write(QUtil::unsigned_char_pointer(val), val.length());
|
||||
pl.finish();
|
||||
PointerHolder<Buffer> buf = bufpl.getBuffer();
|
||||
auto buf = bufpl.getBufferSharedPointer();
|
||||
val = QPDF_String(
|
||||
std::string(reinterpret_cast<char*>(buf->getBuffer()),
|
||||
buf->getSize())).unparse(true);
|
||||
@ -3231,8 +3231,8 @@ QPDFWriter::writeLinearized()
|
||||
// Write file in two passes. Part numbers refer to PDF spec 1.4.
|
||||
|
||||
FILE* lin_pass1_file = 0;
|
||||
PointerHolder<PipelinePopper> pp_pass1 = new PipelinePopper(this);
|
||||
PointerHolder<PipelinePopper> pp_md5 = new PipelinePopper(this);
|
||||
auto pp_pass1 = make_pointer_holder<PipelinePopper>(this);
|
||||
auto pp_md5 = make_pointer_holder<PipelinePopper>(this);
|
||||
for (int pass = 1; pass <= 2; ++pass)
|
||||
{
|
||||
if (pass == 1)
|
||||
@ -3623,7 +3623,7 @@ QPDFWriter::registerProgressReporter(PointerHolder<ProgressReporter> pr)
|
||||
void
|
||||
QPDFWriter::writeStandard()
|
||||
{
|
||||
PointerHolder<PipelinePopper> pp_md5 = new PipelinePopper(this);
|
||||
auto pp_md5 = make_pointer_holder<PipelinePopper>(this);
|
||||
if (this->m->deterministic_id)
|
||||
{
|
||||
pushMD5Pipeline(*pp_md5);
|
||||
|
@ -251,7 +251,7 @@ QPDF_Stream::getStreamData(qpdf_stream_decode_level_e decode_level)
|
||||
"getStreamData called on unfilterable stream");
|
||||
}
|
||||
QTC::TC("qpdf", "QPDF_Stream getStreamData");
|
||||
return buf.getBuffer();
|
||||
return buf.getBufferSharedPointer();
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
@ -265,7 +265,7 @@ QPDF_Stream::getRawStreamData()
|
||||
"error getting raw stream data");
|
||||
}
|
||||
QTC::TC("qpdf", "QPDF_Stream getRawStreamData");
|
||||
return buf.getBuffer();
|
||||
return buf.getBufferSharedPointer();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -479,7 +479,7 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp,
|
||||
|
||||
if (encode_flags & qpdf_ef_normalize)
|
||||
{
|
||||
normalizer = new ContentNormalizer();
|
||||
normalizer = make_pointer_holder<ContentNormalizer>();
|
||||
new_pipeline = std::make_shared<Pl_QPDFTokenizer>(
|
||||
"normalizer", normalizer.get(), pipeline);
|
||||
to_delete.push_back(new_pipeline);
|
||||
|
@ -245,7 +245,7 @@ process_with_aes(std::string const& key,
|
||||
aes.write(QUtil::unsigned_char_pointer(data), data.length());
|
||||
}
|
||||
aes.finish();
|
||||
PointerHolder<Buffer> bufp = buffer.getBuffer();
|
||||
auto bufp = buffer.getBufferSharedPointer();
|
||||
if (outlength == 0)
|
||||
{
|
||||
outlength = bufp->getSize();
|
||||
@ -1200,7 +1200,7 @@ QPDF::decryptString(std::string& str, int objid, int generation)
|
||||
key.length());
|
||||
pl.write(QUtil::unsigned_char_pointer(str), str.length());
|
||||
pl.finish();
|
||||
PointerHolder<Buffer> buf = bufpl.getBuffer();
|
||||
auto buf = bufpl.getBufferSharedPointer();
|
||||
str = std::string(reinterpret_cast<char*>(buf->getBuffer()),
|
||||
buf->getSize());
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ QPDF::readLinearizationData()
|
||||
QPDFObjectHandle HS = H0.getKey("/S"); // shared object
|
||||
QPDFObjectHandle HO = H0.getKey("/O"); // outline
|
||||
|
||||
PointerHolder<Buffer> hbp = pb.getBuffer();
|
||||
auto hbp = pb.getBufferSharedPointer();
|
||||
Buffer* hb = hbp.get();
|
||||
unsigned char const* h_buf = hb->getBuffer();
|
||||
size_t h_size = hb->getSize();
|
||||
@ -2282,5 +2282,5 @@ QPDF::generateHintStream(std::map<int, QPDFXRefEntry> const& xref,
|
||||
}
|
||||
c.finish();
|
||||
|
||||
hint_buffer = hint_stream.getBuffer();
|
||||
hint_buffer = hint_stream.getBufferSharedPointer();
|
||||
}
|
||||
|
@ -104,12 +104,13 @@ static void call_read_memory(qpdf_data qpdf)
|
||||
// must set qpdf->filename
|
||||
static void call_init_write(qpdf_data qpdf)
|
||||
{
|
||||
qpdf->qpdf_writer = new QPDFWriter(*(qpdf->qpdf), qpdf->filename);
|
||||
qpdf->qpdf_writer = make_pointer_holder<QPDFWriter>(
|
||||
*(qpdf->qpdf), qpdf->filename);
|
||||
}
|
||||
|
||||
static void call_init_write_memory(qpdf_data qpdf)
|
||||
{
|
||||
qpdf->qpdf_writer = new QPDFWriter(*(qpdf->qpdf));
|
||||
qpdf->qpdf_writer = make_pointer_holder<QPDFWriter>(*(qpdf->qpdf));
|
||||
qpdf->qpdf_writer->setOutputMemory();
|
||||
}
|
||||
|
||||
@ -137,17 +138,19 @@ static QPDF_ERROR_CODE trap_errors(
|
||||
}
|
||||
catch (QPDFExc& e)
|
||||
{
|
||||
qpdf->error = new QPDFExc(e);
|
||||
qpdf->error = make_pointer_holder<QPDFExc>(e);
|
||||
status |= QPDF_ERRORS;
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
qpdf->error = new QPDFExc(qpdf_e_system, "", "", 0, e.what());
|
||||
qpdf->error = make_pointer_holder<QPDFExc>(
|
||||
qpdf_e_system, "", "", 0, e.what());
|
||||
status |= QPDF_ERRORS;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
qpdf->error = new QPDFExc(qpdf_e_internal, "", "", 0, e.what());
|
||||
qpdf->error = make_pointer_holder<QPDFExc>(
|
||||
qpdf_e_internal, "", "", 0, e.what());
|
||||
status |= QPDF_ERRORS;
|
||||
}
|
||||
|
||||
@ -169,7 +172,7 @@ qpdf_data qpdf_init()
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c called qpdf_init");
|
||||
qpdf_data qpdf = new _qpdf_data();
|
||||
qpdf->qpdf = new QPDF();
|
||||
qpdf->qpdf = make_pointer_holder<QPDF>();
|
||||
return qpdf;
|
||||
}
|
||||
|
||||
@ -240,7 +243,8 @@ qpdf_error qpdf_next_warning(qpdf_data qpdf)
|
||||
{
|
||||
if (qpdf_more_warnings(qpdf))
|
||||
{
|
||||
qpdf->tmp_error.exc = new QPDFExc(qpdf->warnings.front());
|
||||
qpdf->tmp_error.exc = make_pointer_holder<QPDFExc>(
|
||||
qpdf->warnings.front());
|
||||
qpdf->warnings.pop_front();
|
||||
QTC::TC("qpdf", "qpdf-c qpdf_next_warning returned warning");
|
||||
return &qpdf->tmp_error;
|
||||
@ -543,7 +547,7 @@ static void qpdf_get_buffer_internal(qpdf_data qpdf)
|
||||
{
|
||||
if (qpdf->write_memory && (qpdf->output_buffer == 0))
|
||||
{
|
||||
qpdf->output_buffer = qpdf->qpdf_writer->getBuffer();
|
||||
qpdf->output_buffer = qpdf->qpdf_writer->getBufferSharedPointer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -852,7 +856,8 @@ void qpdf_register_progress_reporter(
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c registered progress reporter");
|
||||
qpdf->qpdf_writer->registerProgressReporter(
|
||||
new ProgressReporter(report_progress, data));
|
||||
PointerHolder<QPDFWriter::ProgressReporter>(
|
||||
new ProgressReporter(report_progress, data)));
|
||||
}
|
||||
|
||||
QPDF_ERROR_CODE qpdf_write(qpdf_data qpdf)
|
||||
@ -911,7 +916,7 @@ static qpdf_oh
|
||||
new_object(qpdf_data qpdf, QPDFObjectHandle const& qoh)
|
||||
{
|
||||
qpdf_oh oh = ++qpdf->next_oh; // never return 0
|
||||
qpdf->oh_cache[oh] = new QPDFObjectHandle(qoh);
|
||||
qpdf->oh_cache[oh] = make_pointer_holder<QPDFObjectHandle>(qoh);
|
||||
return oh;
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,12 @@ int main(int argc, char* argv[])
|
||||
pipeStringAndFinish(&concat, "-two-");
|
||||
concat.manualFinish();
|
||||
|
||||
PointerHolder<Buffer> b1_buf = b1.getBuffer();
|
||||
auto b1_buf = b1.getBufferSharedPointer();
|
||||
Pl_Buffer b2("uncompressed");
|
||||
Pl_Flate inflate("uncompress", &b2, Pl_Flate::a_inflate);
|
||||
inflate.write(b1_buf->getBuffer(), b1_buf->getSize());
|
||||
inflate.finish();
|
||||
PointerHolder<Buffer> b2_buf = b2.getBuffer();
|
||||
auto b2_buf = b2.getBufferSharedPointer();
|
||||
std::string result(reinterpret_cast<char*>(b2_buf->getBuffer()),
|
||||
b2_buf->getSize());
|
||||
if (result == "-one--two-")
|
||||
|
@ -65,8 +65,8 @@ int main()
|
||||
// Overlap so that the first check() would advance past the start
|
||||
// of the next match
|
||||
memcpy(b + 2037, "potato potato salad ", 20);
|
||||
PointerHolder<InputSource> is =
|
||||
new BufferInputSource("test buffer input source", b1.get());
|
||||
auto is = PointerHolder<InputSource>(
|
||||
new BufferInputSource("test buffer input source", b1.get()));
|
||||
Finder f1(is, "salad");
|
||||
check("find potato salad", true,
|
||||
is->findFirst("potato", 0, 0, f1));
|
||||
|
@ -545,7 +545,7 @@ void read_from_file_test()
|
||||
Pl_Buffer b2("buffer");
|
||||
// QUtil::file_provider also exercises QUtil::pipe_file
|
||||
QUtil::file_provider("other-file")(&b2);
|
||||
PointerHolder<Buffer> buf2 = b2.getBuffer();
|
||||
auto buf2 = b2.getBufferSharedPointer();
|
||||
assert(buf2->getSize() == size);
|
||||
assert(memcmp(buf2->getBuffer(), p, size) == 0);
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ static void test_0_1(QPDF& pdf, char const* arg2)
|
||||
std::cout << "Raw stream data:" << std::endl;
|
||||
std::cout.flush();
|
||||
QUtil::binary_stdout();
|
||||
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("raw", stdout);
|
||||
auto out = make_pointer_holder<Pl_StdioFile>("raw", stdout);
|
||||
qtest.pipeStreamData(out.get(), 0, qpdf_dl_none);
|
||||
|
||||
std::cout << std::endl << "Uncompressed stream data:" << std::endl;
|
||||
@ -302,7 +302,7 @@ static void test_0_1(QPDF& pdf, char const* arg2)
|
||||
{
|
||||
std::cout.flush();
|
||||
QUtil::binary_stdout();
|
||||
out = new Pl_StdioFile("filtered", stdout);
|
||||
out = make_pointer_holder<Pl_StdioFile>("filtered", stdout);
|
||||
qtest.pipeStreamData(out.get(), 0, qpdf_dl_all);
|
||||
std::cout << std::endl << "End of stream data" << std::endl;
|
||||
}
|
||||
@ -343,7 +343,7 @@ static void test_2(QPDF& pdf, char const* arg2)
|
||||
QPDFObjectHandle page = kids.getArrayItem(1); // second page
|
||||
QPDFObjectHandle contents = page.getKey("/Contents");
|
||||
QUtil::binary_stdout();
|
||||
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("filtered", stdout);
|
||||
auto out = make_pointer_holder<Pl_StdioFile>("filtered", stdout);
|
||||
contents.pipeStreamData(out.get(), 0, qpdf_dl_generalized);
|
||||
}
|
||||
|
||||
@ -356,8 +356,8 @@ static void test_3(QPDF& pdf, char const* arg2)
|
||||
std::cout << "-- stream " << i << " --" << std::endl;
|
||||
std::cout.flush();
|
||||
QUtil::binary_stdout();
|
||||
PointerHolder<Pl_StdioFile> out =
|
||||
new Pl_StdioFile("tokenized stream", stdout);
|
||||
auto out = make_pointer_holder<Pl_StdioFile>(
|
||||
"tokenized stream", stdout);
|
||||
stream.pipeStreamData(out.get(),
|
||||
qpdf_ef_normalize, qpdf_dl_generalized);
|
||||
}
|
||||
@ -538,11 +538,11 @@ static void test_8(QPDF& pdf, char const* arg2)
|
||||
p2.write(QUtil::unsigned_char_pointer("new data for stream\n"),
|
||||
20); // no null!
|
||||
p2.finish();
|
||||
PointerHolder<Buffer> b = p1.getBuffer();
|
||||
auto b = p1.getBufferSharedPointer();
|
||||
// This is a bogus way to use StreamDataProvider, but it does
|
||||
// adequately test its functionality.
|
||||
Provider* provider = new Provider(b);
|
||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> p = provider;
|
||||
auto p = PointerHolder<QPDFObjectHandle::StreamDataProvider>(provider);
|
||||
qstream.replaceStreamData(
|
||||
p, QPDFObjectHandle::newName("/FlateDecode"),
|
||||
QPDFObjectHandle::newNull());
|
||||
@ -572,7 +572,7 @@ static void test_9(QPDF& pdf, char const* arg2)
|
||||
{
|
||||
QPDFObjectHandle root = pdf.getRoot();
|
||||
// Explicitly exercise the Buffer version of newStream
|
||||
PointerHolder<Buffer> buf = new Buffer(20);
|
||||
auto buf = make_pointer_holder<Buffer>(20U);
|
||||
unsigned char* bp = buf->getBuffer();
|
||||
memcpy(bp, "data for new stream\n", 20); // no null!
|
||||
QPDFObjectHandle qstream = QPDFObjectHandle::newStream(
|
||||
@ -1100,9 +1100,9 @@ static void test_27(QPDF& pdf, char const* arg2)
|
||||
pl.write(QUtil::unsigned_char_pointer("new data for stream\n"),
|
||||
20); // no null!
|
||||
pl.finish();
|
||||
PointerHolder<Buffer> b = pl.getBuffer();
|
||||
auto b = pl.getBufferSharedPointer();
|
||||
Provider* provider = new Provider(b);
|
||||
p1 = provider;
|
||||
p1 = decltype(p1)(provider);
|
||||
}
|
||||
// Create a stream that uses a provider in empty1 and copy it
|
||||
// to empty2. It is copied from empty2 to the final pdf.
|
||||
@ -1129,9 +1129,9 @@ static void test_27(QPDF& pdf, char const* arg2)
|
||||
"more data for stream\n"),
|
||||
21); // no null!
|
||||
pl.finish();
|
||||
PointerHolder<Buffer> b = pl.getBuffer();
|
||||
auto b = pl.getBufferSharedPointer();
|
||||
Provider* provider = new Provider(b);
|
||||
p2 = provider;
|
||||
p2 = decltype(p2)(provider);
|
||||
}
|
||||
QPDF empty3;
|
||||
empty3.emptyPDF();
|
||||
@ -1315,7 +1315,7 @@ static void test_33(QPDF& pdf, char const* arg2)
|
||||
w.setStaticID(true);
|
||||
w.setOutputPipeline(&p);
|
||||
w.write();
|
||||
PointerHolder<Buffer> b = p.getBuffer();
|
||||
auto b = p.getBufferSharedPointer();
|
||||
FILE* f = QUtil::safe_fopen("a.pdf", "wb");
|
||||
fwrite(b->getBuffer(), b->getSize(), 1, f);
|
||||
fclose(f);
|
||||
@ -1414,7 +1414,7 @@ static void test_36(QPDF& pdf, char const* arg2)
|
||||
Pl_Buffer p1("buffer");
|
||||
Pl_Flate p2("compress", &p1, Pl_Flate::a_inflate);
|
||||
stream.pipeStreamData(&p2, 0, qpdf_dl_none);
|
||||
PointerHolder<Buffer> buf = p1.getBuffer();
|
||||
auto buf = p1.getBufferSharedPointer();
|
||||
std::string data = std::string(
|
||||
reinterpret_cast<char const*>(buf->getBuffer()),
|
||||
buf->getSize());
|
||||
@ -1497,7 +1497,8 @@ static void test_41(QPDF& pdf, char const* arg2)
|
||||
pages.begin();
|
||||
iter != pages.end(); ++iter)
|
||||
{
|
||||
(*iter).addContentTokenFilter(new TokenFilter);
|
||||
(*iter).addContentTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter>(new TokenFilter()));
|
||||
}
|
||||
QPDFWriter w(pdf, "a.pdf");
|
||||
w.setQDFMode(true);
|
||||
@ -2727,11 +2728,15 @@ static void test_72(QPDF& pdf, char const* arg2)
|
||||
Pl_Buffer b("buffer");
|
||||
if (i == 0)
|
||||
{
|
||||
fx1.addContentTokenFilter(new TokenFilter);
|
||||
fx1.addContentTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter>(
|
||||
new TokenFilter()));
|
||||
}
|
||||
else
|
||||
{
|
||||
fx1.getObjectHandle().addTokenFilter(new TokenFilter);
|
||||
fx1.getObjectHandle().addTokenFilter(
|
||||
PointerHolder<QPDFObjectHandle::TokenFilter>(
|
||||
new TokenFilter()));
|
||||
}
|
||||
fx1.pipeContents(&b);
|
||||
std::unique_ptr<Buffer> buf(b.getBuffer());
|
||||
@ -2890,7 +2895,7 @@ static void test_76(QPDF& pdf, char const* arg2)
|
||||
p.write(QUtil::unsigned_char_pointer("from buffer"), 11);
|
||||
p.finish();
|
||||
auto efs3 = QPDFEFStreamObjectHelper::createEFStream(
|
||||
pdf, p.getBuffer());
|
||||
pdf, p.getBufferSharedPointer());
|
||||
efs3.setSubtype("text/plain");
|
||||
efdh.replaceEmbeddedFile(
|
||||
"att2", QPDFFileSpecObjectHelper::createFileSpec(
|
||||
@ -3007,7 +3012,7 @@ static void test_79(QPDF& pdf, char const* arg2)
|
||||
Pl_Buffer b("buffer");
|
||||
b.write(QUtil::unsigned_char_pointer("from buffer"), 11);
|
||||
b.finish();
|
||||
PointerHolder<Buffer> bp = b.getBuffer();
|
||||
auto bp = b.getBufferSharedPointer();
|
||||
auto s3 = QPDFObjectHandle::newStream(&pdf, bp);
|
||||
|
||||
std::vector<QPDFObjectHandle> streams = {s1, s2, s3};
|
||||
|
@ -300,7 +300,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
std::map<QPDFObjGen, QPDFXRefEntry> xrefs_w
|
||||
= w.getWrittenXRefTable();
|
||||
PointerHolder<Buffer> buf = w.getBuffer();
|
||||
auto buf = w.getBufferSharedPointer();
|
||||
|
||||
QPDF qpdf_ren;
|
||||
qpdf_ren.processMemoryFile("renumbered",
|
||||
|
@ -205,7 +205,7 @@ static void process(char const* filename, bool include_ignorable,
|
||||
// Tokenize file, skipping streams
|
||||
FileInputSource* fis = new FileInputSource();
|
||||
fis->setFilename(filename);
|
||||
is = fis;
|
||||
is = PointerHolder<InputSource>(fis);
|
||||
dump_tokens(is, "FILE", max_len, include_ignorable, true, false);
|
||||
|
||||
// Tokenize content streams, skipping inline images
|
||||
@ -220,10 +220,10 @@ static void process(char const* filename, bool include_ignorable,
|
||||
++pageno;
|
||||
Pl_Buffer plb("buffer");
|
||||
(*iter).pipeContents(&plb);
|
||||
PointerHolder<Buffer> content_data = plb.getBuffer();
|
||||
auto content_data = plb.getBufferSharedPointer();
|
||||
BufferInputSource* bis = new BufferInputSource(
|
||||
"content data", content_data.get());
|
||||
is = bis;
|
||||
is = PointerHolder<InputSource>(bis);
|
||||
dump_tokens(is, "PAGE " + QUtil::int_to_string(pageno),
|
||||
max_len, include_ignorable, false, true);
|
||||
}
|
||||
@ -241,7 +241,7 @@ static void process(char const* filename, bool include_ignorable,
|
||||
(*iter).getStreamData(qpdf_dl_specialized);
|
||||
BufferInputSource* bis = new BufferInputSource(
|
||||
"object stream data", b.get());
|
||||
is = bis;
|
||||
is = PointerHolder<InputSource>(bis);
|
||||
dump_tokens(is, "OBJECT STREAM " +
|
||||
QUtil::int_to_string((*iter).getObjectID()),
|
||||
max_len, include_ignorable, false, false);
|
||||
|
@ -75,9 +75,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
QUtil::binary_stdout();
|
||||
QUtil::binary_stdin();
|
||||
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("stdout", stdout);
|
||||
PointerHolder<Pl_Flate> flate =
|
||||
new Pl_Flate("flate", out.get(), action);
|
||||
auto out = make_pointer_holder<Pl_StdioFile>("stdout", stdout);
|
||||
auto flate = make_pointer_holder<Pl_Flate>("flate", out.get(), action);
|
||||
bool warn = false;
|
||||
flate->setWarnCallback([&warn](char const* msg, int code) {
|
||||
warn = true;
|
||||
|
Loading…
Reference in New Issue
Block a user