[poppler] poppler/Dict.cc poppler/Dict.h poppler/FontInfo.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 5 14:53:52 UTC 2019


 poppler/Dict.cc     |   11 +++++++++++
 poppler/Dict.h      |    2 ++
 poppler/FontInfo.cc |   11 +++++------
 3 files changed, 18 insertions(+), 6 deletions(-)

New commits:
commit 70845beb5ed8c9b20f3ff1b5054c58b35ebe4872
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Apr 5 16:46:29 2019 +0200

    Introduce Dict::getVal(int i, Ref *returnRef)
    
    And use it in FontInfoScanner::scanFonts

diff --git a/poppler/Dict.cc b/poppler/Dict.cc
index 17c2f98e..524a8622 100644
--- a/poppler/Dict.cc
+++ b/poppler/Dict.cc
@@ -202,6 +202,17 @@ bool Dict::lookupInt(const char *key, const char *alt_key, int *value) const
   return false;
 }
 
+Object Dict::getVal(int i, Ref *returnRef) const
+{
+    const DictEntry &entry = entries[i];
+    if (entry.second.getType() == objRef) {
+      *returnRef = entry.second.getRef();
+    } else {
+      *returnRef = Ref::INVALID();
+    }
+    return entry.second.fetch(xref);
+}
+
 bool Dict::hasKey(const char *key) const {
   return find(key) != nullptr;
 }
diff --git a/poppler/Dict.h b/poppler/Dict.h
index 6c1424a5..287d5a3c 100644
--- a/poppler/Dict.h
+++ b/poppler/Dict.h
@@ -84,6 +84,8 @@ public:
   // Iterative accessors.
   const char *getKey(int i) const { return entries[i].first.c_str(); }
   Object getVal(int i) const { return entries[i].second.fetch(xref); }
+  // Same as above but if the returned object is a fetched Ref returns such Ref in returnRef, otherwise returnRef is Ref::INVALID()
+  Object getVal(int i, Ref *returnRef) const;
   const Object &getValNF(int i) const { return entries[i].second; }
 
   // Set the xref pointer.  This is only used in one special case: the
diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc
index cd335771..b7e970d7 100644
--- a/poppler/FontInfo.cc
+++ b/poppler/FontInfo.cc
@@ -131,18 +131,17 @@ void FontInfoScanner::scanFonts(XRef *xrefA, Dict *resDict, std::vector<FontInfo
     Object objDict = resDict->lookup(resTypes[resType]);
     if (objDict.isDict()) {
       for (int i = 0; i < objDict.dictGetLength(); ++i) {
-        const Object &dictObjI = objDict.dictGetValNF(i);
-        if (dictObjI.isRef()) {
+        Ref obj2Ref;
+        const Object obj2 = objDict.getDict()->getVal(i, &obj2Ref);
+        if (obj2Ref != Ref::INVALID()) {
           // check for an already-seen object
-          const Ref r = dictObjI.getRef();
-          if (visitedObjects.find(r.num) != visitedObjects.end()) {
+          if (visitedObjects.find(obj2Ref.num) != visitedObjects.end()) {
             continue;
           }
 
-          visitedObjects.insert(r.num);
+          visitedObjects.insert(obj2Ref.num);
         }
 
-        Object obj2 = dictObjI.fetch(xrefA);
         if (obj2.isStream()) {
           Ref resourcesRef;
           const Object resObj = obj2.streamGetDict()->lookup("Resources", &resourcesRef);


More information about the poppler mailing list