2022-08-02 20:35:04 +00:00
|
|
|
#include <qpdf/QPDFValue.hh>
|
|
|
|
|
2022-09-08 15:12:10 +00:00
|
|
|
#include <qpdf/QPDFObject_private.hh>
|
2022-08-02 20:35:04 +00:00
|
|
|
|
2022-09-08 15:29:23 +00:00
|
|
|
std::shared_ptr<QPDFObject>
|
2022-08-02 20:35:04 +00:00
|
|
|
QPDFValue::do_create(QPDFValue* object)
|
|
|
|
{
|
2022-09-08 15:29:23 +00:00
|
|
|
std::shared_ptr<QPDFObject> obj(new QPDFObject());
|
2022-08-02 20:35:04 +00:00
|
|
|
obj->value = std::shared_ptr<QPDFValue>(object);
|
|
|
|
return obj;
|
|
|
|
}
|
2023-02-15 10:35:10 +00:00
|
|
|
|
|
|
|
std::string
|
|
|
|
QPDFValue::getDescription()
|
|
|
|
{
|
2023-02-15 10:11:38 +00:00
|
|
|
if (object_description) {
|
|
|
|
switch (object_description->index()) {
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
auto description = std::get<0>(*object_description);
|
|
|
|
|
|
|
|
if (auto pos = description.find("$OG");
|
|
|
|
pos != std::string::npos) {
|
|
|
|
description.replace(pos, 3, og.unparse(' '));
|
|
|
|
}
|
|
|
|
if (auto pos = description.find("$PO");
|
|
|
|
pos != std::string::npos) {
|
|
|
|
qpdf_offset_t shift = (type_code == ::ot_dictionary) ? 2
|
|
|
|
: (type_code == ::ot_array) ? 1
|
|
|
|
: 0;
|
2023-02-15 10:35:10 +00:00
|
|
|
|
2023-02-15 10:11:38 +00:00
|
|
|
description.replace(
|
|
|
|
pos, 3, std::to_string(parsed_offset + shift));
|
|
|
|
}
|
|
|
|
return description;
|
|
|
|
}
|
2023-02-09 12:43:56 +00:00
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
auto j_descr = std::get<1>(*object_description);
|
|
|
|
return (
|
|
|
|
*j_descr.input +
|
|
|
|
(j_descr.object.empty() ? "" : ", " + j_descr.object) +
|
|
|
|
" at offset " + std::to_string(parsed_offset));
|
|
|
|
}
|
2023-02-15 10:11:38 +00:00
|
|
|
}
|
2023-02-15 11:30:33 +00:00
|
|
|
} else if (og.isIndirect()) {
|
|
|
|
return "object " + og.unparse(' ');
|
2023-02-15 10:35:10 +00:00
|
|
|
}
|
2023-02-15 10:11:38 +00:00
|
|
|
return {};
|
2023-02-15 10:35:10 +00:00
|
|
|
}
|