2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-05-29 00:10:54 +00:00

Tidy QPDFJob::doJSONObjects

This commit is contained in:
m-holger 2023-05-18 15:18:39 +01:00
parent 9db2965f62
commit 50bc82b4e0

View File

@ -1043,7 +1043,7 @@ QPDFJob::doJSONObjects(Pipeline* p, bool& first, QPDF& pdf)
bool first_object = true; bool first_object = true;
JSON::writeDictionaryOpen(p, first_object, 1); JSON::writeDictionaryOpen(p, first_object, 1);
bool all_objects = m->json_objects.empty(); bool all_objects = m->json_objects.empty();
std::set<QPDFObjGen> wanted_og = getWantedJSONObjects(); auto wanted_og = getWantedJSONObjects();
for (auto& obj: pdf.getAllObjects()) { for (auto& obj: pdf.getAllObjects()) {
std::string key = obj.unparse(); std::string key = obj.unparse();
if (this->m->json_version > 1) { if (this->m->json_version > 1) {
@ -1063,11 +1063,8 @@ QPDFJob::doJSONObjects(Pipeline* p, bool& first, QPDF& pdf)
if (this->m->json_objects.count("trailer")) { if (this->m->json_objects.count("trailer")) {
json_objects.insert("trailer"); json_objects.insert("trailer");
} }
auto wanted = getWantedJSONObjects(); for (auto og: getWantedJSONObjects()) {
for (auto const& og: wanted) { json_objects.emplace("obj:" + og.unparse(' ') + " R");
std::ostringstream s;
s << "obj:" << og.unparse(' ') << " R";
json_objects.insert(s.str());
} }
pdf.writeJSON( pdf.writeJSON(
this->m->json_version, this->m->json_version,
@ -1088,7 +1085,7 @@ QPDFJob::doJSONObjectinfo(Pipeline* p, bool& first, QPDF& pdf)
bool first_object = true; bool first_object = true;
JSON::writeDictionaryOpen(p, first_object, 1); JSON::writeDictionaryOpen(p, first_object, 1);
bool all_objects = m->json_objects.empty(); bool all_objects = m->json_objects.empty();
std::set<QPDFObjGen> wanted_og = getWantedJSONObjects(); auto wanted_og = getWantedJSONObjects();
for (auto& obj: pdf.getAllObjects()) { for (auto& obj: pdf.getAllObjects()) {
if (all_objects || wanted_og.count(obj.getObjGen())) { if (all_objects || wanted_og.count(obj.getObjGen())) {
auto j_details = JSON::makeDictionary(); auto j_details = JSON::makeDictionary();