diff options
Diffstat (limited to 'libqpdf/QPDFOutlineDocumentHelper.cc')
-rw-r--r-- | libqpdf/QPDFOutlineDocumentHelper.cc | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/libqpdf/QPDFOutlineDocumentHelper.cc b/libqpdf/QPDFOutlineDocumentHelper.cc index c8d08288..6f3711de 100644 --- a/libqpdf/QPDFOutlineDocumentHelper.cc +++ b/libqpdf/QPDFOutlineDocumentHelper.cc @@ -15,22 +15,18 @@ QPDFOutlineDocumentHelper::QPDFOutlineDocumentHelper(QPDF& qpdf) : m(new Members()) { QPDFObjectHandle root = qpdf.getRoot(); - if (! root.hasKey("/Outlines")) - { + if (!root.hasKey("/Outlines")) { return; } QPDFObjectHandle outlines = root.getKey("/Outlines"); - if (! (outlines.isDictionary() && outlines.hasKey("/First"))) - { + if (!(outlines.isDictionary() && outlines.hasKey("/First"))) { return; } QPDFObjectHandle cur = outlines.getKey("/First"); std::set<QPDFObjGen> seen; - while (! cur.isNull()) - { + while (!cur.isNull()) { auto og = cur.getObjGen(); - if (seen.count(og)) - { + if (seen.count(og)) { break; } seen.insert(og); @@ -47,7 +43,7 @@ QPDFOutlineDocumentHelper::~QPDFOutlineDocumentHelper() bool QPDFOutlineDocumentHelper::hasOutlines() { - return ! this->m->outlines.empty(); + return !this->m->outlines.empty(); } std::vector<QPDFOutlineObjectHelper> @@ -60,10 +56,10 @@ void QPDFOutlineDocumentHelper::initializeByPage() { std::list<QPDFOutlineObjectHelper> queue; - queue.insert(queue.end(), this->m->outlines.begin(), this->m->outlines.end()); + queue.insert( + queue.end(), this->m->outlines.begin(), this->m->outlines.end()); - while (! queue.empty()) - { + while (!queue.empty()) { QPDFOutlineObjectHelper oh = queue.front(); queue.pop_front(); this->m->by_page[oh.getDestPage().getObjGen()].push_back(oh); @@ -75,13 +71,11 @@ QPDFOutlineDocumentHelper::initializeByPage() std::vector<QPDFOutlineObjectHelper> QPDFOutlineDocumentHelper::getOutlinesForPage(QPDFObjGen const& og) { - if (this->m->by_page.empty()) - { + if (this->m->by_page.empty()) { initializeByPage(); } std::vector<QPDFOutlineObjectHelper> result; - if (this->m->by_page.count(og)) - { + if (this->m->by_page.count(og)) { result = this->m->by_page[og]; } return result; @@ -91,44 +85,33 @@ QPDFObjectHandle QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name) { QPDFObjectHandle result; - if (name.isName()) - { - if (! this->m->dest_dict.isInitialized()) - { + if (name.isName()) { + if (!this->m->dest_dict.isInitialized()) { this->m->dest_dict = this->qpdf.getRoot().getKey("/Dests"); } - if (this->m->dest_dict.isDictionary()) - { + if (this->m->dest_dict.isDictionary()) { QTC::TC("qpdf", "QPDFOutlineDocumentHelper name named dest"); result = this->m->dest_dict.getKey(name.getName()); } - } - else if (name.isString()) - { - if (0 == this->m->names_dest.get()) - { + } else if (name.isString()) { + if (0 == this->m->names_dest.get()) { QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names"); - if (names.isDictionary()) - { + if (names.isDictionary()) { QPDFObjectHandle dests = names.getKey("/Dests"); - if (dests.isDictionary()) - { + if (dests.isDictionary()) { this->m->names_dest = make_pointer_holder<QPDFNameTreeObjectHelper>( dests, this->qpdf); } } } - if (this->m->names_dest.get()) - { - if (this->m->names_dest->findObject(name.getUTF8Value(), result)) - { + if (this->m->names_dest.get()) { + if (this->m->names_dest->findObject(name.getUTF8Value(), result)) { QTC::TC("qpdf", "QPDFOutlineDocumentHelper string named dest"); } } } - if (! result.isInitialized()) - { + if (!result.isInitialized()) { result = QPDFObjectHandle::newNull(); } return result; @@ -137,8 +120,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name) bool QPDFOutlineDocumentHelper::checkSeen(QPDFObjGen const& og) { - if (this->m->seen.count(og) > 0) - { + if (this->m->seen.count(og) > 0) { return true; } this->m->seen.insert(og); |