2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-08 06:15:23 +00:00

Refactor QPDFOutlineDocumentHelper::resolveNamedDest

This commit is contained in:
m-holger 2024-07-13 11:00:19 +01:00
parent f4e468b180
commit 963574f27f

View File

@ -68,30 +68,25 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name)
QPDFObjectHandle result;
if (name.isName()) {
if (!m->dest_dict.isInitialized()) {
m->dest_dict = this->qpdf.getRoot().getKey("/Dests");
}
if (m->dest_dict.isDictionary()) {
QTC::TC("qpdf", "QPDFOutlineDocumentHelper name named dest");
result = m->dest_dict.getKey(name.getName());
m->dest_dict = qpdf.getRoot().getKey("/Dests");
}
QTC::TC("qpdf", "QPDFOutlineDocumentHelper name named dest");
result= m->dest_dict.getKeyIfDict(name.getName());
} else if (name.isString()) {
if (nullptr == m->names_dest) {
QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names");
if (names.isDictionary()) {
QPDFObjectHandle dests = names.getKey("/Dests");
if (dests.isDictionary()) {
m->names_dest = std::make_shared<QPDFNameTreeObjectHelper>(dests, this->qpdf);
}
if (!m->names_dest) {
auto dests = qpdf.getRoot().getKey("/Names").getKeyIfDict("/Dests");
if (dests.isDictionary()) {
m->names_dest = std::make_shared<QPDFNameTreeObjectHelper>(dests, qpdf);
}
}
if (m->names_dest.get()) {
if (m->names_dest) {
if (m->names_dest->findObject(name.getUTF8Value(), result)) {
QTC::TC("qpdf", "QPDFOutlineDocumentHelper string named dest");
}
}
}
if (!result.isInitialized()) {
result = QPDFObjectHandle::newNull();
return QPDFObjectHandle::newNull();
}
return result;
}