2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QPDFXRefEntry.hh>
|
2022-02-04 21:31:31 +00:00
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
#include <qpdf/QIntC.hh>
|
2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QPDFExc.hh>
|
|
|
|
#include <qpdf/QUtil.hh>
|
|
|
|
|
|
|
|
QPDFXRefEntry::QPDFXRefEntry() :
|
|
|
|
type(0),
|
|
|
|
field1(0),
|
|
|
|
field2(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-21 23:32:21 +00:00
|
|
|
QPDFXRefEntry::QPDFXRefEntry(int type, qpdf_offset_t field1, int field2) :
|
2008-04-29 12:55:25 +00:00
|
|
|
type(type),
|
|
|
|
field1(field1),
|
|
|
|
field2(field2)
|
|
|
|
{
|
2022-04-02 21:14:10 +00:00
|
|
|
if ((type < 1) || (type > 2)) {
|
2022-09-21 16:49:21 +00:00
|
|
|
throw std::logic_error("invalid xref type " + std::to_string(type));
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
QPDFXRefEntry::getType() const
|
|
|
|
{
|
|
|
|
return this->type;
|
|
|
|
}
|
|
|
|
|
2012-06-21 23:32:21 +00:00
|
|
|
qpdf_offset_t
|
2008-04-29 12:55:25 +00:00
|
|
|
QPDFXRefEntry::getOffset() const
|
|
|
|
{
|
2022-04-02 21:14:10 +00:00
|
|
|
if (this->type != 1) {
|
|
|
|
throw std::logic_error("getOffset called for xref entry of type != 1");
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
return this->field1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
QPDFXRefEntry::getObjStreamNumber() const
|
|
|
|
{
|
2022-04-02 21:14:10 +00:00
|
|
|
if (this->type != 2) {
|
2022-02-08 14:18:08 +00:00
|
|
|
throw std::logic_error(
|
|
|
|
"getObjStreamNumber called for xref entry of type != 2");
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
2019-06-21 03:35:23 +00:00
|
|
|
return QIntC::to_int(this->field1);
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
QPDFXRefEntry::getObjStreamIndex() const
|
|
|
|
{
|
2022-04-02 21:14:10 +00:00
|
|
|
if (this->type != 2) {
|
2022-02-08 14:18:08 +00:00
|
|
|
throw std::logic_error(
|
|
|
|
"getObjStreamIndex called for xref entry of type != 2");
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
return this->field2;
|
|
|
|
}
|