mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Overload StreamDataProvider::provideStreamData
Use 'QPDFObjGen const&' instead of 'int, int' in signature.
This commit is contained in:
parent
5d0469f1bc
commit
afd35f9a30
@ -29,8 +29,7 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider
|
||||
public:
|
||||
ImageProvider(std::string const& color_space, std::string const& filter);
|
||||
virtual ~ImageProvider() = default;
|
||||
virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* pipeline);
|
||||
virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
|
||||
size_t getWidth() const;
|
||||
size_t getHeight() const;
|
||||
|
||||
@ -93,7 +92,7 @@ ImageProvider::getHeight() const
|
||||
}
|
||||
|
||||
void
|
||||
ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline)
|
||||
ImageProvider::provideStreamData(QPDFObjGen const&, Pipeline* pipeline)
|
||||
{
|
||||
std::vector<std::shared_ptr<Pipeline>> to_delete;
|
||||
Pipeline* p = pipeline;
|
||||
@ -292,7 +291,7 @@ check(
|
||||
ImageProvider* p = new ImageProvider(desired_color_space, "null");
|
||||
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
|
||||
Pl_Buffer b_p("get image data");
|
||||
provider->provideStreamData(0, 0, &b_p);
|
||||
provider->provideStreamData(QPDFObjGen(), &b_p);
|
||||
std::shared_ptr<Buffer> desired_data(b_p.getBuffer());
|
||||
|
||||
if (desired_data->getSize() != actual_data->getSize()) {
|
||||
|
@ -201,7 +201,7 @@ class StreamReplacer: public QPDFObjectHandle::StreamDataProvider
|
||||
StreamReplacer(QPDF* pdf);
|
||||
virtual ~StreamReplacer() = default;
|
||||
virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* pipeline) override;
|
||||
provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
|
||||
|
||||
void registerStream(
|
||||
QPDFObjectHandle stream,
|
||||
@ -384,9 +384,8 @@ StreamReplacer::registerStream(
|
||||
}
|
||||
|
||||
void
|
||||
StreamReplacer::provideStreamData(int objid, int generation, Pipeline* pipeline)
|
||||
StreamReplacer::provideStreamData(QPDFObjGen const& og, Pipeline* pipeline)
|
||||
{
|
||||
QPDFObjGen og(objid, generation);
|
||||
QPDFObjectHandle orig = this->copied_streams[og];
|
||||
// call maybeReplace again, this time with the pipeline and no
|
||||
// dict_updates. In this mode, maybeReplace doesn't make any
|
||||
|
@ -35,7 +35,7 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider
|
||||
public:
|
||||
virtual ~ImageInverter() = default;
|
||||
virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* pipeline) override;
|
||||
provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
|
||||
|
||||
void registerImage(
|
||||
QPDFObjectHandle image,
|
||||
@ -82,12 +82,11 @@ ImageInverter::registerImage(
|
||||
}
|
||||
|
||||
void
|
||||
ImageInverter::provideStreamData(int objid, int generation, Pipeline* pipeline)
|
||||
ImageInverter::provideStreamData(QPDFObjGen const& og, Pipeline* pipeline)
|
||||
{
|
||||
// Use the object and generation number supplied to look up the
|
||||
// image data. Then invert the image data and write the inverted
|
||||
// data to the pipeline.
|
||||
QPDFObjGen og(objid, generation);
|
||||
std::shared_ptr<Buffer> data =
|
||||
this->copied_images[og].getStreamData(qpdf_dl_all);
|
||||
size_t size = data->getSize();
|
||||
|
@ -990,8 +990,7 @@ class QPDF
|
||||
CopiedStreamDataProvider(QPDF& destination_qpdf);
|
||||
virtual ~CopiedStreamDataProvider() = default;
|
||||
virtual bool provideStreamData(
|
||||
int objid,
|
||||
int generation,
|
||||
QPDFObjGen const& og,
|
||||
Pipeline* pipeline,
|
||||
bool suppress_warnings,
|
||||
bool will_retry) override;
|
||||
|
@ -116,9 +116,17 @@ class QPDFObjectHandle
|
||||
// indicating whether it ran without errors.
|
||||
QPDF_DLL
|
||||
virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* pipeline);
|
||||
provideStreamData(QPDFObjGen const& og, Pipeline* pipeline);
|
||||
QPDF_DLL
|
||||
virtual bool provideStreamData(
|
||||
QPDFObjGen const& og,
|
||||
Pipeline* pipeline,
|
||||
bool suppress_warnings,
|
||||
bool will_retry);
|
||||
// The following two overloads are deprecated.
|
||||
QPDF_DLL virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* pipeline);
|
||||
QPDF_DLL virtual bool provideStreamData(
|
||||
int objid,
|
||||
int generation,
|
||||
Pipeline* pipeline,
|
||||
|
@ -135,22 +135,19 @@ QPDF::CopiedStreamDataProvider::CopiedStreamDataProvider(
|
||||
|
||||
bool
|
||||
QPDF::CopiedStreamDataProvider::provideStreamData(
|
||||
int objid,
|
||||
int generation,
|
||||
QPDFObjGen const& og,
|
||||
Pipeline* pipeline,
|
||||
bool suppress_warnings,
|
||||
bool will_retry)
|
||||
{
|
||||
std::shared_ptr<ForeignStreamData> foreign_data =
|
||||
this->foreign_stream_data[QPDFObjGen(objid, generation)];
|
||||
std::shared_ptr<ForeignStreamData> foreign_data = foreign_stream_data[og];
|
||||
bool result = false;
|
||||
if (foreign_data.get()) {
|
||||
result = destination_qpdf.pipeForeignStreamData(
|
||||
foreign_data, pipeline, suppress_warnings, will_retry);
|
||||
QTC::TC("qpdf", "QPDF copy foreign with data", result ? 0 : 1);
|
||||
} else {
|
||||
QPDFObjectHandle foreign_stream =
|
||||
this->foreign_streams[QPDFObjGen(objid, generation)];
|
||||
auto foreign_stream = foreign_streams[og];
|
||||
result = foreign_stream.pipeStreamData(
|
||||
pipeline, nullptr, 0, qpdf_dl_none, suppress_warnings, will_retry);
|
||||
QTC::TC(
|
||||
|
@ -49,8 +49,7 @@ namespace
|
||||
size_t oi_min_area,
|
||||
QPDFObjectHandle& image);
|
||||
virtual ~ImageOptimizer() = default;
|
||||
virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* pipeline);
|
||||
virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
|
||||
std::shared_ptr<Pipeline>
|
||||
makePipeline(std::string const& description, Pipeline* next);
|
||||
bool evaluate(std::string const& description);
|
||||
@ -250,7 +249,7 @@ ImageOptimizer::evaluate(std::string const& description)
|
||||
}
|
||||
|
||||
void
|
||||
ImageOptimizer::provideStreamData(int, int, Pipeline* pipeline)
|
||||
ImageOptimizer::provideStreamData(QPDFObjGen const&, Pipeline* pipeline)
|
||||
{
|
||||
std::shared_ptr<Pipeline> p = makePipeline("", pipeline);
|
||||
if (p.get() == nullptr) {
|
||||
|
@ -51,6 +51,24 @@ QPDFObjectHandle::StreamDataProvider::~StreamDataProvider()
|
||||
// README-maintainer
|
||||
}
|
||||
|
||||
void
|
||||
QPDFObjectHandle::StreamDataProvider::provideStreamData(
|
||||
QPDFObjGen const& og, Pipeline* pipeline)
|
||||
{
|
||||
return provideStreamData(og.getObj(), og.getGen(), pipeline);
|
||||
}
|
||||
|
||||
bool
|
||||
QPDFObjectHandle::StreamDataProvider::provideStreamData(
|
||||
QPDFObjGen const& og,
|
||||
Pipeline* pipeline,
|
||||
bool suppress_warnings,
|
||||
bool will_retry)
|
||||
{
|
||||
return provideStreamData(
|
||||
og.getObj(), og.getGen(), pipeline, suppress_warnings, will_retry);
|
||||
}
|
||||
|
||||
void
|
||||
QPDFObjectHandle::StreamDataProvider::provideStreamData(
|
||||
int objid, int generation, Pipeline* pipeline)
|
||||
@ -90,8 +108,7 @@ namespace
|
||||
{
|
||||
}
|
||||
virtual ~CoalesceProvider() = default;
|
||||
virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* pipeline);
|
||||
virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
|
||||
|
||||
private:
|
||||
QPDFObjectHandle containing_page;
|
||||
@ -100,7 +117,7 @@ namespace
|
||||
} // namespace
|
||||
|
||||
void
|
||||
CoalesceProvider::provideStreamData(int, int, Pipeline* p)
|
||||
CoalesceProvider::provideStreamData(QPDFObjGen const&, Pipeline* p)
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFObjectHandle coalesce provide stream data");
|
||||
std::string description =
|
||||
@ -1425,15 +1442,14 @@ namespace
|
||||
}
|
||||
|
||||
virtual void
|
||||
provideStreamData(int, int, Pipeline* pipeline) override
|
||||
provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override
|
||||
{
|
||||
p1(pipeline);
|
||||
}
|
||||
|
||||
virtual bool
|
||||
provideStreamData(
|
||||
int,
|
||||
int,
|
||||
QPDFObjGen const&,
|
||||
Pipeline* pipeline,
|
||||
bool suppress_warnings,
|
||||
bool will_retry) override
|
||||
|
@ -21,8 +21,7 @@ namespace
|
||||
{
|
||||
}
|
||||
virtual ~ContentProvider() = default;
|
||||
virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* pipeline);
|
||||
virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
|
||||
|
||||
private:
|
||||
QPDFObjectHandle from_page;
|
||||
@ -30,7 +29,7 @@ namespace
|
||||
} // namespace
|
||||
|
||||
void
|
||||
ContentProvider::provideStreamData(int, int, Pipeline* p)
|
||||
ContentProvider::provideStreamData(QPDFObjGen const&, Pipeline* p)
|
||||
{
|
||||
Pl_Concatenate concat("concatenate", p);
|
||||
std::string description =
|
||||
|
@ -610,17 +610,12 @@ QPDF_Stream::pipeStreamData(
|
||||
Pl_Count count("stream provider count", pipeline);
|
||||
if (this->stream_provider->supportsRetry()) {
|
||||
if (!this->stream_provider->provideStreamData(
|
||||
og.getObj(),
|
||||
og.getGen(),
|
||||
&count,
|
||||
suppress_warnings,
|
||||
will_retry)) {
|
||||
og, &count, suppress_warnings, will_retry)) {
|
||||
filter = false;
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
this->stream_provider->provideStreamData(
|
||||
og.getObj(), og.getGen(), &count);
|
||||
this->stream_provider->provideStreamData(og, &count);
|
||||
}
|
||||
qpdf_offset_t actual_length = count.getCount();
|
||||
qpdf_offset_t desired_length = 0;
|
||||
|
@ -56,6 +56,8 @@ class Provider: public QPDFObjectHandle::StreamDataProvider
|
||||
virtual void
|
||||
provideStreamData(int objid, int generation, Pipeline* p)
|
||||
{
|
||||
// Don't change signature to use QPDFObjGen const& to detect
|
||||
// problems forwarding to legacy implementations.
|
||||
p->write(b->getBuffer(), b->getSize());
|
||||
if (this->bad_length) {
|
||||
unsigned char ch = ' ';
|
||||
|
Loading…
Reference in New Issue
Block a user