2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-31 02:48:31 +00:00

Move QPDFObjectHandle::setObjectDescriptionFromInput to QPDFParser

Part of #729
This commit is contained in:
m-holger 2022-08-30 06:42:46 +01:00
parent 8ad1ea34fe
commit 6fc982b71a
4 changed files with 17 additions and 35 deletions

View File

@ -1587,12 +1587,6 @@ class QPDFObjectHandle
bool stop_at_streams);
void shallowCopyInternal(QPDFObjectHandle& oh, bool first_level_only);
void releaseResolved();
static void setObjectDescriptionFromInput(
QPDFObjectHandle,
QPDF*,
std::string const&,
std::shared_ptr<InputSource>,
qpdf_offset_t);
void setParsedOffset(qpdf_offset_t offset);
void parseContentStream_internal(

View File

@ -273,20 +273,6 @@ QPDFObjectHandle::releaseResolved()
}
}
void
QPDFObjectHandle::setObjectDescriptionFromInput(
QPDFObjectHandle object,
QPDF* context,
std::string const& description,
std::shared_ptr<InputSource> input,
qpdf_offset_t offset)
{
object.setObjectDescription(
context,
(input->getName() + ", " + description + " at offset " +
QUtil::int_to_string(offset)));
}
QPDFObject::object_type_e
QPDFObjectHandle::getTypeCode()
{

View File

@ -263,12 +263,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
case st_dictionary:
case st_array:
QPDFObjectHandle::setObjectDescriptionFromInput(
object,
context,
object_description,
input,
input->getLastOffset());
setDescriptionFromInput(object, input->getLastOffset());
object.setParsedOffset(input->getLastOffset());
set_offset = true;
olist.append(object);
@ -293,8 +288,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
// There's no newArray(SparseOHArray) since
// SparseOHArray is not part of the public API.
object = QPDFObjectHandle(QPDF_Array::create(olist));
QPDFObjectHandle::setObjectDescriptionFromInput(
object, context, object_description, input, offset);
setDescriptionFromInput(object, offset);
// The `offset` points to the next of "[". Set the
// rewind offset to point to the beginning of "[".
// This has been explicitly tested with whitespace
@ -347,8 +341,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
"dictionary ended prematurely; "
"using null as value for last key");
val = QPDFObjectHandle::newNull();
QPDFObjectHandle::setObjectDescriptionFromInput(
val, context, object_description, input, offset);
setDescriptionFromInput(val, offset);
} else {
val = olist.at(++i);
}
@ -372,8 +365,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
dict["/Contents"].setParsedOffset(contents_offset);
}
object = QPDFObjectHandle::newDictionary(dict);
QPDFObjectHandle::setObjectDescriptionFromInput(
object, context, object_description, input, offset);
setDescriptionFromInput(object, offset);
// The `offset` points to the next of "<<". Set the
// rewind offset to point to the beginning of "<<".
// This has been explicitly tested with whitespace
@ -396,13 +388,22 @@ QPDFParser::parse(bool& empty, bool content_stream)
}
if (!set_offset) {
QPDFObjectHandle::setObjectDescriptionFromInput(
object, context, object_description, input, offset);
setDescriptionFromInput(object, offset);
object.setParsedOffset(offset);
}
return object;
}
void
QPDFParser::setDescriptionFromInput(
QPDFObjectHandle oh, qpdf_offset_t offset) const
{
oh.setObjectDescription(
context,
(input->getName() + ", " + object_description + " at offset " +
QUtil::int_to_string(offset)));
}
void
QPDFParser::warn(QPDF* qpdf, QPDFExc const& e)
{

View File

@ -41,7 +41,8 @@ class QPDFParser
void warn(std::string const& msg) const;
static void warn(QPDF*, QPDFExc const&);
void setParsedOffset(qpdf_offset_t offset);
void
setDescriptionFromInput(QPDFObjectHandle oh, qpdf_offset_t offset) const;
std::shared_ptr<InputSource> input;
std::string const& object_description;
QPDFTokenizer& tokenizer;