Commit 0765872295e581ea6ae5a07e12916a552a1543ee

Authored by Jay Berkenbilt
1 parent 0a52e60e

Form field for non-widget just returns null

include/qpdf/QPDFAcroFormDocumentHelper.hh
@@ -134,8 +134,8 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper @@ -134,8 +134,8 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
134 // field dictionary, the underlying object will be the same, but 134 // field dictionary, the underlying object will be the same, but
135 // this is not always the case. Note that if you call this method 135 // this is not always the case. Note that if you call this method
136 // with an annotation that is not a widget annotation, there will 136 // with an annotation that is not a widget annotation, there will
137 - // not be an associated field, and this method will raise an  
138 - // exception. 137 + // not be an associated field, and this method will return a
  138 + // helper associated with a null object (isNull() == true).
139 QPDF_DLL 139 QPDF_DLL
140 QPDFFormFieldObjectHelper 140 QPDFFormFieldObjectHelper
141 getFieldForAnnotation(QPDFAnnotationObjectHelper); 141 getFieldForAnnotation(QPDFAnnotationObjectHelper);
libqpdf/QPDFAcroFormDocumentHelper.cc
@@ -70,16 +70,14 @@ QPDFFormFieldObjectHelper @@ -70,16 +70,14 @@ QPDFFormFieldObjectHelper
70 QPDFAcroFormDocumentHelper::getFieldForAnnotation(QPDFAnnotationObjectHelper h) 70 QPDFAcroFormDocumentHelper::getFieldForAnnotation(QPDFAnnotationObjectHelper h)
71 { 71 {
72 QPDFObjectHandle oh = h.getObjectHandle(); 72 QPDFObjectHandle oh = h.getObjectHandle();
  73 + QPDFFormFieldObjectHelper result(QPDFObjectHandle::newNull());
73 if (! (oh.isDictionary() && 74 if (! (oh.isDictionary() &&
74 oh.getKey("/Subtype").isName() && 75 oh.getKey("/Subtype").isName() &&
75 (oh.getKey("/Subtype").getName() == "/Widget"))) 76 (oh.getKey("/Subtype").getName() == "/Widget")))
76 { 77 {
77 - throw std::logic_error(  
78 - "QPDFAnnotationObjectHelper::getFieldForAnnotation called for"  
79 - " non-/Widget annotation"); 78 + return result;
80 } 79 }
81 analyze(); 80 analyze();
82 - QPDFFormFieldObjectHelper result(QPDFObjectHandle::newNull());  
83 QPDFObjGen og(oh.getObjGen()); 81 QPDFObjGen og(oh.getObjGen());
84 if (this->m->annotation_to_field.count(og)) 82 if (this->m->annotation_to_field.count(og))
85 { 83 {