poppler/Catalog.cc |   75 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 poppler/Catalog.h  |   20 ++++++++++++++
 2 files changed, 88 insertions(+), 7 deletions(-)

New commits:
commit 151715976509075e9b95e0ab86d1fcacb2c1580a
Author: Masamichi Hosoda <truer...@trueroad.jp>
Date:   Sat Aug 20 23:16:33 2016 +0900

    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);

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 312d179..0e37c84 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 3236487..81b0e12 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(); }
 
commit 99267c0b3f3aed520247dc0a5eb70df04b00df46
Author: Masamichi Hosoda <truer...@trueroad.jp>
Date:   Sat Aug 20 20:40:18 2016 +0900

    Add functions for named destination name in name-tree
    
    Get the number of named destinations in name-tree
    int Catalog::numDestNameTree();
    
    Get the i'th named destination name in name-tree
    GooString *Catalog::getDestNameTreeName(int i);
    
    Get the i'th named destination link destination in name-tree
    LinkDest *Catalog::getDestNameTreeDest(int i);

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 7754e47..312d179 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -504,6 +504,19 @@ LinkDest *Catalog::createLinkDest(Object *obj)
   return dest;
 }
 
+LinkDest *Catalog::getDestNameTreeDest(int i)
+{
+  LinkDest *dest;
+  Object obj;
+
+  catalogLocker();
+  getDestNameTree()->getValue(i).fetch(xref, &obj);
+  dest = createLinkDest(&obj);
+  obj.free();
+
+  return dest;
+}
+
 FileSpec *Catalog::embeddedFile(int i)
 {
     Object efDict;
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index c7cce92..3236487 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -151,6 +151,15 @@ public:
 
   Object *getDests();
 
+  // Get the number of named destinations in name-tree
+  int numDestNameTree() { return getDestNameTree()->numEntries(); }
+
+  // Get the i'th named destination name in name-tree
+  GooString *getDestNameTreeName(int i) { return 
getDestNameTree()->getName(i); }
+
+  // Get the i'th named destination link destination in name-tree
+  LinkDest *getDestNameTreeDest(int i);
+
   // Get the number of embedded files
   int numEmbeddedFiles() { return getEmbeddedFileNameTree()->numEntries(); }
 
commit 09ab87a9faf552b28eb7fe3e8ffd137390be5535
Author: Masamichi Hosoda <truer...@trueroad.jp>
Date:   Sat Aug 20 19:35:27 2016 +0900

    Divide Catalog::findDest()
    
    In order to use constructing LinkDest from other functions,
    this commit divides Catalog::findDest().

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index a8c96ac..7754e47 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -32,6 +32,7 @@
 // Copyright (C) 2013 José Aliste <jali...@src.gnome.org>
 // Copyright (C) 2014 Ed Porras <e...@moto-research.com>
 // Copyright (C) 2015 Even Rouault <even.roua...@spatialys.com>
+// Copyright (C) 2016 Masamichi Hosoda <truer...@trueroad.jp>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -451,7 +452,7 @@ int Catalog::findPage(int num, int gen) {
 
 LinkDest *Catalog::findDest(GooString *name) {
   LinkDest *dest;
-  Object obj1, obj2;
+  Object obj1;
   GBool found;
 
   // try named destination dictionary then name tree
@@ -472,12 +473,22 @@ LinkDest *Catalog::findDest(GooString *name) {
   if (!found)
     return NULL;
 
-  // construct LinkDest
+  dest = createLinkDest(&obj1);
+  obj1.free();
+
+  return dest;
+}
+
+LinkDest *Catalog::createLinkDest(Object *obj)
+{
+  LinkDest *dest;
+  Object obj2;
+
   dest = NULL;
-  if (obj1.isArray()) {
-    dest = new LinkDest(obj1.getArray());
-  } else if (obj1.isDict()) {
-    if (obj1.dictLookup("D", &obj2)->isArray())
+  if (obj->isArray()) {
+    dest = new LinkDest(obj->getArray());
+  } else if (obj->isDict()) {
+    if (obj->dictLookup("D", &obj2)->isArray())
       dest = new LinkDest(obj2.getArray());
     else
       error(errSyntaxWarning, -1, "Bad named destination value");
@@ -485,7 +496,6 @@ LinkDest *Catalog::findDest(GooString *name) {
   } else {
     error(errSyntaxWarning, -1, "Bad named destination value");
   }
-  obj1.free();
   if (dest && !dest->isOk()) {
     delete dest;
     dest = NULL;
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index bc9ce20..c7cce92 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -25,6 +25,7 @@
 // Copyright (C) 2013 Adrian Perez de Castro <ape...@igalia.com>
 // Copyright (C) 2013 Adrian Johnson <ajohn...@redneon.com>
 // Copyright (C) 2013 José Aliste <jali...@src.gnome.org>
+// Copyright (C) 2016 Masamichi Hosoda <truer...@trueroad.jp>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -263,6 +264,7 @@ private:
   NameTree *getDestNameTree();
   NameTree *getEmbeddedFileNameTree();
   NameTree *getJSNameTree();
+  LinkDest *createLinkDest(Object *obj);
 #if MULTITHREADED
   GooMutex mutex;
 #endif
_______________________________________________
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to