Commit e1560162f034c5087c4a5d5015b1dea95ab9a4d6

Authored by m-holger
1 parent a3e94eb4

Refactor: replace `isNull` calls with `null` and remove redundant `QTC::TC` call…

…s in `QPDFFormFieldObjectHelper`.
libqpdf/QPDFFormFieldObjectHelper.cc
... ... @@ -25,7 +25,7 @@ QPDFFormFieldObjectHelper::QPDFFormFieldObjectHelper() :
25 25 bool
26 26 QPDFFormFieldObjectHelper::isNull()
27 27 {
28   - return oh().isNull();
  28 + return oh().null();
29 29 }
30 30  
31 31 QPDFFormFieldObjectHelper
... ... @@ -39,7 +39,7 @@ QPDFFormFieldObjectHelper::getTopLevelField(bool* is_different)
39 39 {
40 40 auto top_field = oh();
41 41 QPDFObjGen::set seen;
42   - while (seen.add(top_field) && !top_field.getKeyIfDict("/Parent").isNull()) {
  42 + while (seen.add(top_field) && !top_field.getKeyIfDict("/Parent").null()) {
43 43 top_field = top_field.getKey("/Parent");
44 44 if (is_different) {
45 45 *is_different = true;
... ... @@ -72,13 +72,12 @@ QPDFFormFieldObjectHelper::getInheritableFieldValue(std::string const& name)
72 72 return QPDFObjectHandle::newNull();
73 73 }
74 74 QPDFObjectHandle result(node.getKey(name));
75   - if (result.isNull()) {
  75 + if (result.null()) {
76 76 QPDFObjGen::set seen;
77 77 while (seen.add(node) && node.hasKey("/Parent")) {
78 78 node = node.getKey("/Parent");
79 79 result = node.getKey(name);
80   - if (!result.isNull()) {
81   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper non-trivial inheritance");
  80 + if (!result.null()) {
82 81 return result;
83 82 }
84 83 }
... ... @@ -118,10 +117,9 @@ QPDFFormFieldObjectHelper::getFullyQualifiedName()
118 117 std::string result;
119 118 QPDFObjectHandle node = oh();
120 119 QPDFObjGen::set seen;
121   - while (!node.isNull() && seen.add(node)) {
  120 + while (!node.null() && seen.add(node)) {
122 121 if (node.getKey("/T").isString()) {
123 122 if (!result.empty()) {
124   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper non-trivial qualified name");
125 123 result = "." + result;
126 124 }
127 125 result = node.getKey("/T").getUTF8Value() + result;
... ... @@ -360,18 +358,17 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
360 358 // is a member, set /AS to /Off.
361 359 // Note that we never turn on /NeedAppearances when setting a radio button field.
362 360 QPDFObjectHandle parent = oh().getKey("/Parent");
363   - if (parent.isDictionary() && parent.getKey("/Parent").isNull()) {
  361 + if (parent.isDictionary() && parent.getKey("/Parent").null()) {
364 362 QPDFFormFieldObjectHelper ph(parent);
365 363 if (ph.isRadioButton()) {
366 364 // This is most likely one of the individual buttons. Try calling on the parent.
367   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper set parent radio button");
368 365 ph.setRadioButtonValue(name);
369 366 return;
370 367 }
371 368 }
372 369  
373 370 QPDFObjectHandle kids = oh().getKey("/Kids");
374   - if (!(isRadioButton() && parent.isNull() && kids.isArray())) {
  371 + if (!(isRadioButton() && parent.null() && kids.isArray())) {
375 372 warn("don't know how to set the value of this field as a radio button");
376 373 return;
377 374 }
... ... @@ -384,7 +381,6 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
384 381 for (auto const& grandkid: kid.getKey("/Kids").as_array()) {
385 382 AP = grandkid.getKey("/AP");
386 383 if (!AP.null()) {
387   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper radio button grandkid");
388 384 annot = grandkid;
389 385 break;
390 386 }
... ... @@ -393,16 +389,13 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
393 389 annot = kid;
394 390 }
395 391 if (!annot) {
396   - QTC::TC("qpdf", "QPDFObjectHandle broken radio button");
397 392 warn("unable to set the value of this radio button");
398 393 continue;
399 394 }
400 395 if (AP.isDictionary() && AP.getKey("/N").isDictionary() &&
401 396 AP.getKey("/N").hasKey(name.getName())) {
402   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper turn on radio button");
403 397 annot.replaceKey("/AS", name);
404 398 } else {
405   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper turn off radio button");
406 399 annot.replaceKey("/AS", QPDFObjectHandle::newName("/Off"));
407 400 }
408 401 }
... ... @@ -749,7 +742,7 @@ void
749 742 QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
750 743 {
751 744 QPDFObjectHandle AS = aoh.getAppearanceStream("/N");
752   - if (AS.isNull()) {
  745 + if (AS.null()) {
753 746 QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AS from scratch");
754 747 QPDFObjectHandle::Rectangle rect = aoh.getRect();
755 748 QPDFObjectHandle::Rectangle bbox(0, 0, rect.urx - rect.llx, rect.ury - rect.lly);
... ... @@ -759,8 +752,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao
759 752 AS = QPDFObjectHandle::newStream(oh().getOwningQPDF(), "/Tx BMC\nEMC\n");
760 753 AS.replaceDict(dict);
761 754 QPDFObjectHandle AP = aoh.getAppearanceDictionary();
762   - if (AP.isNull()) {
763   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AP from scratch");
  755 + if (AP.null()) {
764 756 aoh.getObjectHandle().replaceKey("/AP", QPDFObjectHandle::newDictionary());
765 757 AP = aoh.getAppearanceDictionary();
766 758 }
... ... @@ -808,7 +800,6 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao
808 800 found_font_in_dr = font.isDictionary();
809 801 }
810 802 if (found_font_in_dr && resources.isDictionary()) {
811   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper get font from /DR");
812 803 if (resources.isIndirect()) {
813 804 resources = resources.getQPDF().makeIndirectObject(resources.shallowCopy());
814 805 AS.getDict().replaceKey("/Resources", resources);
... ... @@ -821,7 +812,6 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao
821 812 if (font.isDictionary() && font.getKey("/Encoding").isName()) {
822 813 std::string encoding = font.getKey("/Encoding").getName();
823 814 if (encoding == "/WinAnsiEncoding") {
824   - QTC::TC("qpdf", "QPDFFormFieldObjectHelper WinAnsi");
825 815 encoder = &QUtil::utf8_to_win_ansi;
826 816 } else if (encoding == "/MacRomanEncoding") {
827 817 encoder = &QUtil::utf8_to_mac_roman;
... ...
qpdf/qpdf.testcov
... ... @@ -300,8 +300,6 @@ QPDFObjectHandle erase array bounds 0
300 300 qpdf-c called qpdf_check_pdf 0
301 301 QPDF xref loop 0
302 302 QPDFParser too deep 0
303   -QPDFFormFieldObjectHelper non-trivial inheritance 0
304   -QPDFFormFieldObjectHelper non-trivial qualified name 0
305 303 QPDFFormFieldObjectHelper TU present 0
306 304 QPDFFormFieldObjectHelper TM present 0
307 305 QPDFFormFieldObjectHelper TU absent 0
... ... @@ -349,12 +347,7 @@ QPDFObjectHandle replace with copy 0
349 347 QPDFPageDocumentHelper indirect as resources 0
350 348 QPDFAnnotationObjectHelper forbidden flags 0
351 349 QPDFAnnotationObjectHelper missing required flags 0
352   -QPDFFormFieldObjectHelper set parent radio button 0
353   -QPDFFormFieldObjectHelper radio button grandkid 0
354   -QPDFFormFieldObjectHelper turn on radio button 0
355   -QPDFFormFieldObjectHelper turn off radio button 0
356 350 QPDFFormFieldObjectHelper checkbox kid widget 0
357   -QPDFObjectHandle broken radio button 0
358 351 QPDFFormFieldObjectHelper set checkbox AS 0
359 352 QPDFObjectHandle broken checkbox 0
360 353 QPDFFormFieldObjectHelper list not found 0
... ... @@ -364,7 +357,6 @@ QPDFFormFieldObjectHelper list last too high 0
364 357 QPDFJob image optimize no pipeline 0
365 358 QPDFJob image optimize no shrink 0
366 359 QPDFJob image optimize too small 0
367   -QPDFFormFieldObjectHelper WinAnsi 0
368 360 QPDF pipe foreign encrypted stream 0
369 361 QPDF copy foreign stream with provider 0
370 362 QPDF copy foreign stream with buffer 0
... ... @@ -381,7 +373,6 @@ QPDFJob invalid utf-8 in auto 0
381 373 QPDFJob input password hex-bytes 0
382 374 QPDFPageDocumentHelper ignore annotation with no appearance 0
383 375 QPDFFormFieldObjectHelper create AS from scratch 0
384   -QPDFFormFieldObjectHelper create AP from scratch 0
385 376 QPDFFormFieldObjectHelper replaced BMC at EOF 0
386 377 QPDFFormFieldObjectHelper fallback Tf 0
387 378 QPDFPageObjectHelper non-trivial inheritance 0
... ... @@ -508,7 +499,6 @@ QPDFAcroFormDocumentHelper modify ap matrix 0
508 499 QPDFJob pages keeping field from original 0
509 500 QPDFObjectHandle merge reuse 0
510 501 QPDFObjectHandle merge generate 0
511   -QPDFFormFieldObjectHelper get font from /DR 0
512 502 QPDFAcroFormDocumentHelper replaced DA token 0
513 503 QPDFAcroFormDocumentHelper /DA parse error 0
514 504 QPDFAcroFormDocumentHelper AP parse error 1
... ...