[poppler] Branch 'xpdf303merge' - 4 commits - poppler/Annot.cc poppler/Gfx.cc poppler/OptionalContent.cc

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


 poppler/Annot.cc           |    5 +----
 poppler/Gfx.cc             |   22 +++++++---------------
 poppler/OptionalContent.cc |   14 +++++++++++---
 3 files changed, 19 insertions(+), 22 deletions(-)

New commits:
commit 6ddb51d81b064346dc85d2ae72570a956a184d74
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Sep 18 12:59:28 2011 +0200

    xpdf303: The spec doesn't say OC must be null or ref

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 2827e75..235120c 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1011,9 +1011,6 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) {
   obj1.free();
 
   dict->lookupNF("OC", &oc);
-  if (!oc.isRef() && !oc.isNull()) {
-    error (errSyntaxError, -1, "Annotation OC value not null or dict: {0:d}", oc.getType());
-  }
 }
 
 void Annot::getRect(double *x1, double *y1, double *x2, double *y2) const {
@@ -1338,7 +1335,7 @@ GBool Annot::isVisible(GBool printing) {
 
   // check the OC
   OCGs *optContentConfig = doc->getCatalog()->getOptContentConfig();
-  if (optContentConfig && oc.isRef()) {
+  if (optContentConfig) {
     if (! optContentConfig->optContentIsVisible(&oc))
       return gFalse;
   }
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index ded78c6..70c3b09 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3988,16 +3988,10 @@ void Gfx::opXObject(Object args[], int numArgs) {
   }
 
   obj1.streamGetDict()->lookupNF("OC", &obj2);
-  if (obj2.isNull()) {
-    // No OC entry - so we proceed as normal
-  } else if (obj2.isRef()) {
-    if ( catalog->getOptContentConfig() && ! catalog->getOptContentConfig()->optContentIsVisible( &obj2 ) ) {
-      obj2.free();
-      obj1.free();
-      return;
-    }
-  } else {
-    error(errSyntaxError, getPos(), "XObject OC value not null or dict: {0:d}", obj2.getType());
+  if (catalog->getOptContentConfig() && !catalog->getOptContentConfig()->optContentIsVisible(&obj2)) {
+    obj2.free();
+    obj1.free();
+    return;
   }
   obj2.free();
 
@@ -4804,11 +4798,9 @@ void Gfx::opBeginMarkedContent(Object args[], int numArgs) {
       char* name1 = args[1].getName();
       Object markedContent;
       if ( res->lookupMarkedContentNF( name1, &markedContent ) ) {
-	if ( markedContent.isRef() ) {
-	  bool visible = contentConfig->optContentIsVisible( &markedContent );
-	  MarkedContentStack *mc = mcStack;
-	  mc->ocSuppressed = !(visible);
-       }
+        bool visible = contentConfig->optContentIsVisible(&markedContent);
+        MarkedContentStack *mc = mcStack;
+        mc->ocSuppressed = !(visible);
       } else {
 	error(errSyntaxError, getPos(), "DID NOT find {0:s}", name1);
       }
commit 434bb9b38319edc7282be22044bd7761403a38a6
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Sep 18 12:45:12 2011 +0200

    xpdf303: OC entry can be an optional content group too
    
    Not only an optional content membership dictionary.

diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index 6badf54..8e22468 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -178,6 +178,16 @@ bool OCGs::optContentIsVisible( Object *dictRef )
   Object policy;
   Object ve;
   bool result = true;
+
+  if (dictRef->isNull())
+    return result;
+
+  if (dictRef->isRef()) {
+    OptionalContentGroup *oc = findOcgByRef(dictRef->getRef());
+    if (oc)
+      return oc->getState() == OptionalContentGroup::On;
+  }
+
   dictRef->fetch( m_xref, &dictObj );
   if ( ! dictObj.isDict() ) {
     error(errSyntaxWarning, -1, "Unexpected oc reference target: {0:d}", dictObj.getType() );
commit 56410b80fdabb99e2de0c6589de6ee745936c523
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Sep 18 12:44:02 2011 +0200

    xpdf303: Not finding an oc group is not necessarily a syntax error

diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index b13d897..6badf54 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -165,8 +165,6 @@ OptionalContentGroup* OCGs::findOcgByRef( const Ref &ref)
     }
   }
 
-  error(errSyntaxWarning, -1, "Could not find a OCG with Ref ({0:d}:{1:d})", ref.num, ref.gen);
-
   // not found
   return NULL;
 }
commit 4bb4439450e342479375cb56d10561457475bd13
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Sep 18 12:42:15 2011 +0200

    xpdf303: Fix check of OptionalContentGroup::getState()
    
    We use an enum, not a boolean.

diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index c564d06..b13d897 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -243,7 +243,7 @@ GBool OCGs::evalOCVisibilityExpr(Object *expr, int recursion) {
   }
   if (expr->isRef()) {
     if ((ocg = findOcgByRef(expr->getRef()))) {
-      return ocg->getState();
+      return ocg->getState() == OptionalContentGroup::On;
     }
   }
   expr->fetch(m_xref, &expr2);


More information about the poppler mailing list