From f825422d50eea25a390abc4c14cd325514a67d3f Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Sat, 20 Aug 2016 23:16:33 +0900 Subject: [PATCH 3/3] Add functions for named destination name in name-dict Get the number of named destinations in name-dict int numDests(); Get the i'th named destination name in name-dict char *getDestsName(int i); Get the i'th named destination link destination in name-dict LinkDest *getDestsDest(int i); --- poppler/Catalog.cc | 38 ++++++++++++++++++++++++++++++++++++++ poppler/Catalog.h | 9 +++++++++ 2 files changed, 47 insertions(+) diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc index 783e28d..a612bbd 100644 --- a/poppler/Catalog.cc +++ b/poppler/Catalog.cc @@ -504,6 +504,44 @@ LinkDest *Catalog::constructLinkDest(Object *obj) return dest; } +int Catalog::numDests() +{ + Object *obj; + + obj= getDests(); + if (!obj->isDict()) { + return 0; + } + return obj->dictGetLength(); +} + +char *Catalog::getDestsName(int i) +{ + Object *obj; + + obj= getDests(); + if (!obj->isDict()) { + return NULL; + } + return obj->dictGetKey(i); +} + +LinkDest *Catalog::getDestsDest(int i) +{ + LinkDest *dest; + Object *obj, obj1; + + obj= getDests(); + if (!obj->isDict()) { + return NULL; + } + obj->dictGetVal(i, &obj1); + dest = constructLinkDest(&obj1); + obj1.free(); + + return dest; +} + LinkDest *Catalog::getDestNameTreeDest(int i) { LinkDest *dest; diff --git a/poppler/Catalog.h b/poppler/Catalog.h index cca43e0..261eb68 100644 --- a/poppler/Catalog.h +++ b/poppler/Catalog.h @@ -151,6 +151,15 @@ public: Object *getDests(); + // Get the number of named destinations in name-dict + int numDests(); + + // Get the i'th named destination name in name-dict + char *getDestsName(int i); + + // Get the i'th named destination link destination in name-dict + LinkDest *getDestsDest(int i); + // Get the number of named destinations in name-tree int numDestNameTree() { return getDestNameTree()->numEntries(); } -- 2.8.3