[poppler] poppler/Catalog.cc poppler/Catalog.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Thu Aug 1 03:14:17 PDT 2013


 poppler/Catalog.cc |   45 +++++++++++++++++++++++++++++++++++++++++++++
 poppler/Catalog.h  |   10 ++++++++++
 2 files changed, 55 insertions(+)

New commits:
commit 9a232273988c0d2fd752dc2016e5111227ae6646
Author: Adrian Perez de Castro <aperez at igalia.com>
Date:   Thu Apr 25 09:52:56 2013 +0300

    Tagged-PDF: Accessors in Catalog for the MarkInfo dictionary

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 6bd511a..25a8997 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -97,6 +97,7 @@ Catalog::Catalog(PDFDoc *docA) {
   attrsList = NULL;
   kidsIdxList = NULL;
   lastCachedPage = 0;
+  markInfo = markInfoNull;
 
   xref->getCatalog(&catDict);
   if (!catDict.isDict()) {
@@ -857,6 +858,50 @@ Object *Catalog::getStructTreeRoot()
   return &structTreeRoot;
 }
 
+Guint Catalog::getMarkInfo()
+{
+  if (markInfo == markInfoNull) {
+    markInfo = 0;
+
+    Object catDict;
+    catalogLocker();
+    xref->getCatalog(&catDict);
+
+    if (catDict.isDict()) {
+      Object markInfoDict;
+      catDict.dictLookup("MarkInfo", &markInfoDict);
+      if (markInfoDict.isDict()) {
+        Object value;
+
+        if (markInfoDict.dictLookup("Marked", &value)->isBool() && value.getBool())
+          markInfo |= markInfoMarked;
+        else if (!value.isNull())
+          error(errSyntaxError, -1, "Marked object is wrong type ({0:s})", value.getTypeName());
+        value.free();
+
+        if (markInfoDict.dictLookup("Suspects", &value)->isBool() && value.getBool())
+          markInfo |= markInfoSuspects;
+        else if (!value.isNull())
+          error(errSyntaxError, -1, "Suspects object is wrong type ({0:s})", value.getTypeName());
+        value.free();
+
+        if (markInfoDict.dictLookup("UserProperties", &value)->isBool() && value.getBool())
+          markInfo |= markInfoUserProperties;
+        else if (!value.isNull())
+          error(errSyntaxError, -1, "UserProperties object is wrong type ({0:s})", value.getTypeName());
+        value.free();
+      } else if (!markInfoDict.isNull()) {
+        error(errSyntaxError, -1, "MarkInfo object is wrong type ({0:s})", markInfoDict.getTypeName());
+      }
+      markInfoDict.free();
+    } else {
+      error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
+    }
+    catDict.free();
+  }
+  return markInfo;
+}
+
 Object *Catalog::getOutline()
 {
   catalogLocker();
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index 24a3dcf..a89d9aa 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -125,6 +125,15 @@ public:
   // Return the structure tree root object.
   Object *getStructTreeRoot();
 
+  // Return values from the MarkInfo dictionary as flags in a bitfield.
+  enum MarkInfoFlags {
+    markInfoNull           = 1 << 0,
+    markInfoMarked         = 1 << 1,
+    markInfoUserProperties = 1 << 2,
+    markInfoSuspects       = 1 << 3,
+  };
+  Guint getMarkInfo();
+
   // Find a page, given its object ID.  Returns page number, or 0 if
   // not found.
   int findPage(int num, int gen);
@@ -219,6 +228,7 @@ private:
   GooString *baseURI;		// base URI for URI-type links
   Object metadata;		// metadata stream
   Object structTreeRoot;	// structure tree root dictionary
+  Guint markInfo;               // Flags from MarkInfo dictionary
   Object outline;		// outline dictionary
   Object acroForm;		// AcroForm dictionary
   Object viewerPreferences;     // ViewerPreference dictionary


More information about the poppler mailing list