[poppler] poppler/poppler: Annot.cc, 1.7, 1.8 Annot.h, 1.4, 1.5 Form.cc, 1.1, 1.2 Form.h, 1.1, 1.2

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Feb 24 16:34:23 PST 2007


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

Modified Files:
	Annot.cc Annot.h Form.cc Form.h 
Log Message:
007-02-25  Julien Rebetez  <julienr at svn.gnome.org>

        reviewed by: Albert Astals Cid <aacid at kde.org>

        * poppler/Annot.cc:
        * poppler/Annot.h:
        * poppler/Form.cc:
        * poppler/Form.h:
        Fix compilation warnings.


Index: Annot.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Annot.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Annot.cc	24 Feb 2007 23:32:23 -0000	1.7
+++ Annot.cc	25 Feb 2007 00:34:21 -0000	1.8
@@ -29,7 +29,19 @@
 // Annot
 //------------------------------------------------------------------------
 
-Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Ref* aref, Catalog* catalog) {
+Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict, const Ref& aref, Catalog* catalog)
+{
+  hasRef = true;
+  ref = aref; 
+  initialize (xrefA, acroForm, dict, catalog);
+}
+
+Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog* catalog) {
+  hasRef = false;
+  initialize (xrefA, acroForm, dict, catalog);
+}
+
+void Annot::initialize(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog) {
   Object apObj, asObj, obj1, obj2;
   double t;
 
@@ -39,12 +51,6 @@
   fontSize = 0;
   widget = NULL;
 
-  if (aref) {
-    hasRef = true;
-    ref = *aref;
-  } else 
-    hasRef = false;
-
   if (dict->lookup("Rect", &obj1)->isArray() &&
       obj1.arrayGetLength() == 4) {
     readArrayNum(&obj1, 0, &xMin);
@@ -496,13 +502,11 @@
       //form widget
       Object obj2;
       Ref* pref;
-      if (annotsObj->arrayGetNF(i, &obj2)->isRef())
-        pref = &obj2.getRef();
-      else 
-        pref = NULL;
-
       if (annotsObj->arrayGet(i, &obj1)->isDict()) {
-        annot = new Annot(xref, acroForm, obj1.getDict(), pref, catalog);
+        if (annotsObj->arrayGetNF(i, &obj2)->isRef())
+          annot = new Annot(xref, acroForm, obj1.getDict(), obj2.getRef(), catalog);
+        else 
+          annot = new Annot(xref, acroForm, obj1.getDict(), catalog);
 	if (annot->isOk()) {
 	  if (nAnnots >= size) {
 	    size += 16;

Index: Annot.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Annot.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Annot.h	24 Feb 2007 23:32:23 -0000	1.4
+++ Annot.h	25 Feb 2007 00:34:21 -0000	1.5
@@ -27,7 +27,8 @@
 class Annot {
 public:
 
-  Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Ref* aref, Catalog* catalog);
+  Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog);
+  Annot(XRef *xrefA, Dict *acroForm, Dict *dict, const Ref& aref, Catalog *catalog);
   ~Annot();
   GBool isOk() { return ok; }
 
@@ -47,6 +48,8 @@
   void generateAppearance(Dict *acroForm, Dict *dict);
   void readArrayNum(Object *pdfArray, int key, double *value);
 
+  void initialize (XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog);
+
   XRef *xref;			// the xref table for this PDF file
   Object appearance;		// a reference to the Form XObject stream
 				//   for the normal appearance

Index: Form.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Form.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Form.cc	24 Feb 2007 23:32:23 -0000	1.1
+++ Form.cc	25 Feb 2007 00:34:21 -0000	1.2
@@ -187,7 +187,6 @@
 
   //pushButtons don't have state
   if (parent->getButtonType() != formButtonPush ){
-    printf("type : %i\n", parent->getButtonType());
     //find the name of the state in the AP dictionnary (/Yes, /Off)
     //The reference say the Off state, if it existe, _must_ be stored in the AP dict under the name /Off
     //The "on" state may be stored under any other name
@@ -640,7 +639,7 @@
 // FormField
 //========================================================================
 
-FormField::FormField(XRef* xrefA, Object *aobj, Ref *aref, Form* aform, FormFieldType ty) 
+FormField::FormField(XRef* xrefA, Object *aobj, const Ref& aref, Form* aform, FormFieldType ty) 
 {
   double t;
   xref = xrefA;
@@ -654,13 +653,7 @@
   widgets = NULL;
   readOnly = false;
   form = aform;
-
-  if (!aref) {
-    direct = true;
-  } else { 
-    ref = *aref;
-    direct = false;
-  }
+  ref = aref;
 
   Object obj1;
   //childs
@@ -681,7 +674,7 @@
         children = (FormField**)greallocn(children, numChildren, sizeof(FormField*));
 
         obj3.free();
-        form->createFieldFromDict (&obj2, &children[numChildren-1], xrefA, &childRef.getRef());
+        form->createFieldFromDict (&obj2, &children[numChildren-1], xrefA, childRef.getRef());
       }
       // 1 - we will handle 'collapsed' fields (field + annot in the same dict)
       // as if the annot was in the Kids array of the field
@@ -696,9 +689,6 @@
   // As said in 1, if this is a 'collapsed' field, behave like if we had a
   // child annot
   if (dict->lookup("Subtype", &obj1)->isName()) {
-    if (direct) {
-      error(-1, "direct annot object\n");
-    }
     _createWidget(aobj, ref);
   }
   obj1.free();
@@ -789,7 +779,7 @@
 //------------------------------------------------------------------------
 // FormFieldButton
 //------------------------------------------------------------------------
-FormFieldButton::FormFieldButton(XRef *xrefA, Object *aobj, Ref *ref, Form* form) 
+FormFieldButton::FormFieldButton(XRef *xrefA, Object *aobj, const Ref& ref, Form* form) 
                                  : FormField(xrefA, aobj, ref, form, formButton)
 {
   type = formButton;
@@ -876,7 +866,7 @@
 //------------------------------------------------------------------------
 // FormFieldText
 //------------------------------------------------------------------------
-FormFieldText::FormFieldText(XRef *xrefA, Object *aobj, Ref *ref, Form* form) 
+FormFieldText::FormFieldText(XRef *xrefA, Object *aobj, const Ref& ref, Form* form) 
                              : FormField(xrefA, aobj, ref, form, formText)
 {
   type = formText;
@@ -928,7 +918,7 @@
 //------------------------------------------------------------------------
 // FormFieldChoice
 //------------------------------------------------------------------------
-FormFieldChoice::FormFieldChoice(XRef *xrefA, Object *aobj, Ref *ref, Form* form) 
+FormFieldChoice::FormFieldChoice(XRef *xrefA, Object *aobj, const Ref& ref, Form* form) 
                                  : FormField(xrefA, aobj, ref, form, formChoice)
 {
   numChoices = 0;
@@ -1021,7 +1011,7 @@
 //------------------------------------------------------------------------
 // FormFieldSignature
 //------------------------------------------------------------------------
-FormFieldSignature::FormFieldSignature(XRef *xrefA, Object *dict, Ref *ref, Form* form)
+FormFieldSignature::FormFieldSignature(XRef *xrefA, Object *dict, const Ref& ref, Form* form)
                                       : FormField(xrefA, dict, ref, form, formSignature)
 {
 }
@@ -1049,18 +1039,19 @@
   rootFields = NULL;
   for(int i=0; i<array->getLength(); i++) {
     Object oref;
-    Ref* pref;
     array->get(i, &obj1);
     array->getNF(i, &oref);
-    if (!oref.isRef()) pref = NULL;
-    else pref = &oref.getRef();
+    if (!oref.isRef()) {
+      error(-1, "Direct object in rootFields");
+      continue;
+    }
 
     if (numFields >= size) {
       size += 16;
       rootFields = (FormField**)greallocn(rootFields,size,sizeof(FormField*));
     }
 
-    createFieldFromDict (&obj1, &rootFields[numFields++], xrefA, pref);
+    createFieldFromDict (&obj1, &rootFields[numFields++], xrefA, oref.getRef());
 
     //Mark readonly field
     Object obj3;
@@ -1104,7 +1095,7 @@
 }
 
 
-void Form::createFieldFromDict (Object* obj, FormField** ptr, XRef *xrefA, Ref* pref)
+void Form::createFieldFromDict (Object* obj, FormField** ptr, XRef *xrefA, const Ref& pref)
 {
     Object obj2;
     if(obj->dictLookup("FT", &obj2)->isName("Btn")) {
@@ -1173,7 +1164,7 @@
         //create a temporary Annot to get the font size
         Object obj2;
         if (annots->arrayGet(i, &obj2)->isDict()) {
-          Annot* ann = new Annot(xref, NULL ,obj2.getDict(), NULL, NULL);
+          Annot* ann = new Annot(xref, NULL ,obj2.getDict(), NULL);
           tmp->setFontSize(ann->getFontSize());
           delete ann;
         }

Index: Form.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Form.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Form.h	24 Feb 2007 23:32:23 -0000	1.1
+++ Form.h	25 Feb 2007 00:34:21 -0000	1.2
@@ -241,7 +241,7 @@
 
 class FormField {
 public:
-  FormField(XRef* xrefa, Object *aobj, Ref *aref, Form* aform, FormFieldType t=formUndef);
+  FormField(XRef* xrefa, Object *aobj, const Ref& aref, Form* aform, FormFieldType t=formUndef);
 
   virtual ~FormField();
 
@@ -269,7 +269,6 @@
 
   FormFieldType type;           // field type
   Ref ref;
-  bool direct;
   bool terminal;
   Object obj;
   XRef *xref;
@@ -291,7 +290,7 @@
 
 class FormFieldButton: public FormField {
 public:
-  FormFieldButton(XRef *xrefA, Object *dict, Ref *ref, Form* form);
+  FormFieldButton(XRef *xrefA, Object *dict, const Ref& ref, Form* form);
 
   FormButtonType getButtonType () { return btype; }
 
@@ -316,7 +315,7 @@
 
 class FormFieldText: public FormField {
 public:
-  FormFieldText(XRef *xrefA, Object *dict, Ref *ref, Form* form);
+  FormFieldText(XRef *xrefA, Object *dict, const Ref& ref, Form* form);
   
   GooString* getContent () { return content; }
   GooString* getContentCopy ();
@@ -347,7 +346,7 @@
 
 class FormFieldChoice: public FormField {
 public:
-  FormFieldChoice(XRef *xrefA, Object *aobj, Ref *ref, Form* form);
+  FormFieldChoice(XRef *xrefA, Object *aobj, const Ref& ref, Form* form);
 
   virtual ~FormFieldChoice();
 
@@ -410,7 +409,7 @@
 
 class FormFieldSignature: public FormField {
 public:
-  FormFieldSignature(XRef *xrefA, Object *dict, Ref *ref, Form* form);
+  FormFieldSignature(XRef *xrefA, Object *dict, const Ref& ref, Form* form);
 
   virtual ~FormFieldSignature();
 };
@@ -434,7 +433,7 @@
 
   /* Creates a new Field of the type specified in obj's dict. 
      used in Form::Form and FormField::FormField */
-  void createFieldFromDict (Object* obj, FormField** ptr, XRef *xref, Ref* pref);
+  void createFieldFromDict (Object* obj, FormField** ptr, XRef *xref, const Ref& aref);
 
   void postWidgetsLoad();
   void checkForNeedAppearances ();



More information about the poppler mailing list