[poppler] Branch 'xpdf303merge' - poppler/OptionalContent.cc poppler/OptionalContent.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sun Sep 18 06:09:55 PDT 2011


 poppler/OptionalContent.cc |   28 ++++++++++++++++++++++++++++
 poppler/OptionalContent.h  |   14 +++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

New commits:
commit 06c6660dc9fe326f185ff323e643af6714b32ec8
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Sep 18 15:08:44 2011 +0200

    xpdf303: Parse usage dictionary of optional content groups

diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index 8e22468..01a5a8b 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -360,6 +360,7 @@ bool OCGs::anyOff( Array *ocgArray )
 
 OptionalContentGroup::OptionalContentGroup(Dict *ocgDict) : m_name(NULL)
 {
+  Object obj1, obj2, obj3;
   Object ocgName;
   ocgDict->lookup("Name", &ocgName);
   if (!ocgName.isString()) {
@@ -368,6 +369,33 @@ OptionalContentGroup::OptionalContentGroup(Dict *ocgDict) : m_name(NULL)
     m_name = new GooString( ocgName.getString() );
   }
   ocgName.free();
+
+  viewState = printState = ocUsageUnset;
+  if (ocgDict->lookup("Usage", &obj1)->isDict()) {
+    if (obj1.dictLookup("View", &obj2)->isDict()) {
+      if (obj2.dictLookup("ViewState", &obj3)->isName()) {
+	if (obj3.isName("ON")) {
+	  viewState = ocUsageOn;
+	} else {
+	  viewState = ocUsageOff;
+	}
+      }
+      obj3.free();
+    }
+    obj2.free();
+    if (obj1.dictLookup("Print", &obj2)->isDict()) {
+      if (obj2.dictLookup("PrintState", &obj3)->isName()) {
+	if (obj3.isName("ON")) {
+	  printState = ocUsageOn;
+	} else {
+	  printState = ocUsageOff;
+	}
+      }
+      obj3.free();
+    }
+    obj2.free();
+  }
+  obj1.free();
 }
 
 OptionalContentGroup::OptionalContentGroup(GooString *label)
diff --git a/poppler/OptionalContent.h b/poppler/OptionalContent.h
index 9a5edac..56e6b71 100644
--- a/poppler/OptionalContent.h
+++ b/poppler/OptionalContent.h
@@ -70,6 +70,13 @@ class OptionalContentGroup {
 public:
   enum State { On, Off };
 
+  // Values from the optional content usage dictionary.
+  enum UsageState {
+    ocUsageOn,
+    ocUsageOff,
+    ocUsageUnset
+  };
+
   OptionalContentGroup(Dict *dict);
 
   OptionalContentGroup(GooString *label);
@@ -84,11 +91,16 @@ public:
   State getState() { return m_state; };
   void setState(State state) { m_state = state; };
 
+  UsageState getViewState() { return viewState; }
+  UsageState getPrintState() { return printState; }
+
 private:
   XRef *xref;
   GooString *m_name;
   Ref m_ref;
-  State m_state;  
+  State m_state;
+  UsageState viewState;	 // suggested state when viewing
+  UsageState printState; // suggested state when printing
 };
 
 #endif


More information about the poppler mailing list