[poppler] poppler/Form.cc poppler/Form.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 15 17:02:19 UTC 2018


 poppler/Form.cc |   38 +++++++++++++++++++-------------------
 poppler/Form.h  |   12 ++++++------
 2 files changed, 25 insertions(+), 25 deletions(-)

New commits:
commit aa864c8729595e64af136d181bfb581d80e03eb7
Author: Albert Astals Cid <aacid at kde.org>
Date:   Wed Nov 14 01:01:27 2018 +0100

    Save an incRef/decRef when creating FormField

diff --git a/poppler/Form.cc b/poppler/Form.cc
index e0e89006..db4fd1c2 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -608,11 +608,11 @@ void FormWidgetSignature::updateWidgetAppearance()
 // FormField
 //========================================================================
 
-FormField::FormField(PDFDoc *docA, Object *aobj, const Ref aref, FormField *parentA, std::set<int> *usedParents, FormFieldType ty)
+FormField::FormField(PDFDoc *docA, Object &&aobj, const Ref aref, FormField *parentA, std::set<int> *usedParents, FormFieldType ty)
 {
   doc = docA;
   xref = doc->getXRef();
-  obj = aobj->copy();
+  obj = std::move(aobj);
   Dict* dict = obj.getDict();
   ref.num = ref.gen = 0;
   type = ty;
@@ -664,7 +664,7 @@ FormField::FormField(PDFDoc *docA, Object *aobj, const Ref aref, FormField *pare
 
           numChildren++;
           children = (FormField**)greallocn(children, numChildren, sizeof(FormField*));
-          children[numChildren - 1] = Form::createFieldFromDict(&childObj, doc, ref, this, &usedParentsAux);
+          children[numChildren - 1] = Form::createFieldFromDict(std::move(childObj), doc, ref, this, &usedParentsAux);
         } else {
 	  obj2 = childObj.dictLookup("Subtype");
 	  if (obj2.isName("Widget")) {
@@ -966,8 +966,8 @@ void FormField::setReadOnly (bool value)
 //------------------------------------------------------------------------
 // FormFieldButton
 //------------------------------------------------------------------------
-FormFieldButton::FormFieldButton(PDFDoc *docA, Object *aobj, const Ref ref, FormField *parent, std::set<int> *usedParents)
-  : FormField(docA, aobj, ref, parent, usedParents, formButton)
+FormFieldButton::FormFieldButton(PDFDoc *docA, Object &&aobj, const Ref ref, FormField *parent, std::set<int> *usedParents)
+  : FormField(docA, std::move(aobj), ref, parent, usedParents, formButton)
 {
   Dict* dict = obj.getDict();
   active_child = -1;
@@ -1133,8 +1133,8 @@ FormFieldButton::~FormFieldButton()
 //------------------------------------------------------------------------
 // FormFieldText
 //------------------------------------------------------------------------
-FormFieldText::FormFieldText(PDFDoc *docA, Object *aobj, const Ref ref, FormField *parent, std::set<int> *usedParents)
-  : FormField(docA, aobj, ref, parent, usedParents, formText)
+FormFieldText::FormFieldText(PDFDoc *docA, Object &&aobj, const Ref ref, FormField *parent, std::set<int> *usedParents)
+  : FormField(docA, std::move(aobj), ref, parent, usedParents, formText)
 {
   Dict* dict = obj.getDict();
   Object obj1;
@@ -1296,8 +1296,8 @@ int FormFieldText::parseDA(GooList* daToks)
 //------------------------------------------------------------------------
 // FormFieldChoice
 //------------------------------------------------------------------------
-FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref ref, FormField *parent, std::set<int> *usedParents)
-  : FormField(docA, aobj, ref, parent, usedParents, formChoice)
+FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object &&aobj, const Ref ref, FormField *parent, std::set<int> *usedParents)
+  : FormField(docA, std::move(aobj), ref, parent, usedParents, formChoice)
 {
   numChoices = 0;
   choices = nullptr;
@@ -1588,8 +1588,8 @@ const GooString *FormFieldChoice::getSelectedChoice() const {
 //------------------------------------------------------------------------
 // FormFieldSignature
 //------------------------------------------------------------------------
-FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref ref, FormField *parent, std::set<int> *usedParents)
-  : FormField(docA, dict, ref, parent, usedParents, formSignature),
+FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object &&dict, const Ref ref, FormField *parent, std::set<int> *usedParents)
+  : FormField(docA, std::move(dict), ref, parent, usedParents, formSignature),
     signature_type(adbe_pkcs7_detached),
     signature(nullptr), signature_info(nullptr)
 {
@@ -1835,7 +1835,7 @@ Form::Form(PDFDoc *docA, Object* acroFormA)
       }
 
       std::set<int> usedParents;
-      rootFields[numFields++] = createFieldFromDict (&obj2, doc, oref.getRef(), nullptr, &usedParents);
+      rootFields[numFields++] = createFieldFromDict (std::move(obj2), doc, oref.getRef(), nullptr, &usedParents);
 
     }
   } else {
@@ -1898,21 +1898,21 @@ Object Form::fieldLookup(Dict *field, const char *key) {
   return ::fieldLookup(field, key, &usedParents);
 }
 
-FormField *Form::createFieldFromDict (Object* obj, PDFDoc *docA, const Ref pref, FormField *parent, std::set<int> *usedParents)
+FormField *Form::createFieldFromDict (Object &&obj, PDFDoc *docA, const Ref pref, FormField *parent, std::set<int> *usedParents)
 {
     FormField *field;
 
-    Object obj2 = Form::fieldLookup(obj->getDict (), "FT");
+    const Object obj2 = Form::fieldLookup(obj.getDict (), "FT");
     if (obj2.isName("Btn")) {
-      field = new FormFieldButton(docA, obj, pref, parent, usedParents);
+      field = new FormFieldButton(docA, std::move(obj), pref, parent, usedParents);
     } else if (obj2.isName("Tx")) {
-      field = new FormFieldText(docA, obj, pref, parent, usedParents);
+      field = new FormFieldText(docA, std::move(obj), pref, parent, usedParents);
     } else if (obj2.isName("Ch")) {
-      field = new FormFieldChoice(docA, obj, pref, parent, usedParents);
+      field = new FormFieldChoice(docA, std::move(obj), pref, parent, usedParents);
     } else if (obj2.isName("Sig")) {
-      field = new FormFieldSignature(docA, obj, pref, parent, usedParents);
+      field = new FormFieldSignature(docA, std::move(obj), pref, parent, usedParents);
     } else { //we don't have an FT entry => non-terminal field
-      field = new FormField(docA, obj, pref, parent, usedParents);
+      field = new FormField(docA, std::move(obj), pref, parent, usedParents);
     }
 
     return field;
diff --git a/poppler/Form.h b/poppler/Form.h
index e6c0b9c7..9b12146e 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -287,7 +287,7 @@ public:
 
 class FormField {
 public:
-  FormField(PDFDoc *docA, Object *aobj, const Ref aref, FormField *parent, std::set<int> *usedParents, FormFieldType t=formUndef);
+  FormField(PDFDoc *docA, Object &&aobj, const Ref aref, FormField *parent, std::set<int> *usedParents, FormFieldType t=formUndef);
 
   virtual ~FormField();
 
@@ -359,7 +359,7 @@ private:
 
 class FormFieldButton: public FormField {
 public:
-  FormFieldButton(PDFDoc *docA, Object *dict, const Ref ref, FormField *parent, std::set<int> *usedParents);
+  FormFieldButton(PDFDoc *docA, Object &&dict, const Ref ref, FormField *parent, std::set<int> *usedParents);
 
   FormButtonType getButtonType () const { return btype; }
 
@@ -403,7 +403,7 @@ protected:
 
 class FormFieldText: public FormField {
 public:
-  FormFieldText(PDFDoc *docA, Object *dict, const Ref ref, FormField *parent, std::set<int> *usedParents);
+  FormFieldText(PDFDoc *docA, Object &&dict, const Ref ref, FormField *parent, std::set<int> *usedParents);
   
   const GooString* getContent () const { return content; }
   void setContentCopy (const GooString* new_content);
@@ -448,7 +448,7 @@ protected:
 
 class FormFieldChoice: public FormField {
 public:
-  FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref ref, FormField *parent, std::set<int> *usedParents);
+  FormFieldChoice(PDFDoc *docA, Object &&aobj, const Ref ref, FormField *parent, std::set<int> *usedParents);
 
   ~FormFieldChoice();
 
@@ -516,7 +516,7 @@ protected:
 class FormFieldSignature: public FormField {
   friend class FormWidgetSignature;
 public:
-  FormFieldSignature(PDFDoc *docA, Object *dict, const Ref ref, FormField *parent, std::set<int> *usedParents);
+  FormFieldSignature(PDFDoc *docA, Object &&dict, const Ref ref, FormField *parent, std::set<int> *usedParents);
 
   // Use -1 for now as validationTime
   SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation, time_t validationTime);
@@ -557,7 +557,7 @@ public:
   
   /* Creates a new Field of the type specified in obj's dict.
      used in Form::Form and FormField::FormField */
-  static FormField *createFieldFromDict (Object* obj, PDFDoc *docA, const Ref aref, FormField *parent, std::set<int> *usedParents);
+  static FormField *createFieldFromDict (Object &&obj, PDFDoc *docA, const Ref aref, FormField *parent, std::set<int> *usedParents);
 
   Object *getObj () const { return acroForm; }
   bool getNeedAppearances () const { return needAppearances; }


More information about the poppler mailing list