[poppler] poppler/poppler: Annot.cc,1.10,1.11

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Sat May 12 17:53:45 PDT 2007


Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv28604/poppler

Modified Files:
	Annot.cc 
Log Message:
2007-05-12  Jeff Muizelaar  <jeff at infidigm.net>

	* poppler/Annot.cc: Only do appearance generation for text, choice or
	other fields that contain text. Patch by Julien Rebetez.


Index: Annot.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Annot.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Annot.cc	25 Apr 2007 19:59:10 -0000	1.10
+++ Annot.cc	13 May 2007 00:53:43 -0000	1.11
@@ -166,15 +166,50 @@
   obj3.free();
 
   // check if field apperances need to be regenerated
+  // Only text or choice fields needs to have appearance regenerated
+  // see section 8.6.2 "Variable Text" of PDFReference
   regen = gFalse;
-  if (acroForm) {
-    acroForm->lookup("NeedAppearances", &obj1);
-    if (obj1.isBool() && obj1.getBool()) {
-      regen = gTrue;
+  fieldLookup(dict, "FT", &obj3);
+
+  if (obj3.isName("Tx") || obj3.isName("Ch")) {
+    if (acroForm) {
+      acroForm->lookup("NeedAppearances", &obj1);
+      if (obj1.isBool() && obj1.getBool()) {
+        regen = gTrue;
+      }
+      obj1.free();
     }
-    obj1.free();
+  } else {
+    //for other type of annots, lookup for AP and copy it to the appearance stream
+    Object apObj, asObj;
+    if (dict->lookup("AP", &apObj)->isDict()) {
+      if (dict->lookup("AS", &asObj)->isName()) {
+        if (apObj.dictLookup("N", &obj1)->isDict()) {
+          if (obj1.dictLookupNF(asObj.getName(), &obj2)->isRef()) {
+            obj2.copy(&appearance);
+            ok = gTrue;
+          } else {
+            obj2.free();
+            if (obj1.dictLookupNF("Off", &obj2)->isRef()) {
+              obj2.copy(&appearance);
+              ok = gTrue;
+            }
+          }
+          obj2.free();
+        }
+        obj1.free();
+      } else {
+        if (apObj.dictLookupNF("N", &obj1)->isRef()) {
+          obj1.copy(&appearance);
+          ok = gTrue;
+        }
+        obj1.free();
+      }
+      asObj.free();
+    }
+    apObj.free();
+
   }
-  regen = gTrue;
 
   //----- parse the border style
 
@@ -306,6 +341,11 @@
   GooString **text;
   GBool *selection;
   int dashLength, ff, quadding, comb, nOptions, topIdx, i, j;
+
+  //do not regenerate appearance if we don't need to
+  if (!regen) 
+    return;
+
   // must be a Widget annotation
   if (type->cmp("Widget")) {
     return;



More information about the poppler mailing list