From 89b5aa27141bb552363fccc2d62c94fe7e0f7561 Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Sat, 20 Aug 2016 23:16:33 +0900 Subject: [PATCH v2 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 32ab3d9..f7c2c9d 100644 --- a/poppler/Catalog.cc +++ b/poppler/Catalog.cc @@ -504,6 +504,44 @@ LinkDest *Catalog::createLinkDest(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 = createLinkDest(&obj1); + obj1.free(); + + return dest; +} + LinkDest *Catalog::getDestNameTreeDest(int i) { LinkDest *dest; diff --git a/poppler/Catalog.h b/poppler/Catalog.h index 59109df..7a517ff 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