Commit a3e94eb4623b4e406ba26aac4654df35153047a7
1 parent
fe92a61d
Refactor: replace `isNull` calls with `null`, remove redundant `QTC::TC` calls i…
…n `QPDFAcroFormDocumentHelper`.
Showing
2 changed files
with
5 additions
and
17 deletions
libqpdf/QPDFAcroFormDocumentHelper.cc
| @@ -487,11 +487,7 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields( | @@ -487,11 +487,7 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields( | ||
| 487 | if (field.getObjectHandle().hasKey(key)) { | 487 | if (field.getObjectHandle().hasKey(key)) { |
| 488 | return true; | 488 | return true; |
| 489 | } | 489 | } |
| 490 | - auto oh = field.getInheritableFieldValue(key); | ||
| 491 | - if (!oh.isNull()) { | ||
| 492 | - return true; | ||
| 493 | - } | ||
| 494 | - return false; | 490 | + return !field.getInheritableFieldValue(key).null(); |
| 495 | }; | 491 | }; |
| 496 | 492 | ||
| 497 | if (override_da || override_q) { | 493 | if (override_da || override_q) { |
| @@ -499,19 +495,17 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields( | @@ -499,19 +495,17 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields( | ||
| 499 | if (override_da && (!has_explicit(cur_field, "/DA"))) { | 495 | if (override_da && (!has_explicit(cur_field, "/DA"))) { |
| 500 | std::string da = cur_field.getDefaultAppearance(); | 496 | std::string da = cur_field.getDefaultAppearance(); |
| 501 | if (da != from_default_da) { | 497 | if (da != from_default_da) { |
| 502 | - QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override da"); | ||
| 503 | obj.replaceKey("/DA", QPDFObjectHandle::newUnicodeString(from_default_da)); | 498 | obj.replaceKey("/DA", QPDFObjectHandle::newUnicodeString(from_default_da)); |
| 504 | } | 499 | } |
| 505 | } | 500 | } |
| 506 | if (override_q && (!has_explicit(cur_field, "/Q"))) { | 501 | if (override_q && (!has_explicit(cur_field, "/Q"))) { |
| 507 | int q = cur_field.getQuadding(); | 502 | int q = cur_field.getQuadding(); |
| 508 | if (q != from_default_q) { | 503 | if (q != from_default_q) { |
| 509 | - QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override q"); | ||
| 510 | obj.replaceKey("/Q", QPDFObjectHandle::newInteger(from_default_q)); | 504 | obj.replaceKey("/Q", QPDFObjectHandle::newInteger(from_default_q)); |
| 511 | - } | ||
| 512 | } | 505 | } |
| 513 | } | 506 | } |
| 514 | } | 507 | } |
| 508 | +} | ||
| 515 | 509 | ||
| 516 | namespace | 510 | namespace |
| 517 | { | 511 | { |
| @@ -675,17 +669,15 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream( | @@ -675,17 +669,15 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream( | ||
| 675 | std::string const& old_key = i2.first; | 669 | std::string const& old_key = i2.first; |
| 676 | std::string const& new_key = i2.second; | 670 | std::string const& new_key = i2.second; |
| 677 | auto existing_new = subdict.getKey(new_key); | 671 | auto existing_new = subdict.getKey(new_key); |
| 678 | - if (!existing_new.isNull()) { | 672 | + if (!existing_new.null()) { |
| 679 | // The resource dictionary already has a key in it matching what we remapped an old | 673 | // The resource dictionary already has a key in it matching what we remapped an old |
| 680 | // key to, so we'll have to move it out of the way. Stick it in merge_with, which we | 674 | // key to, so we'll have to move it out of the way. Stick it in merge_with, which we |
| 681 | // will re-merge with the dictionary when we're done. We know merge_with already has | 675 | // will re-merge with the dictionary when we're done. We know merge_with already has |
| 682 | // dictionaries for all the top keys. | 676 | // dictionaries for all the top keys. |
| 683 | - QTC::TC("qpdf", "QPDFAcroFormDocumentHelper ap conflict"); | ||
| 684 | merge_with.getKey(top_key).replaceKey(new_key, existing_new); | 677 | merge_with.getKey(top_key).replaceKey(new_key, existing_new); |
| 685 | } | 678 | } |
| 686 | auto existing_old = subdict.getKey(old_key); | 679 | auto existing_old = subdict.getKey(old_key); |
| 687 | - if (!existing_old.isNull()) { | ||
| 688 | - QTC::TC("qpdf", "QPDFAcroFormDocumentHelper ap rename"); | 680 | + if (!existing_old.null()) { |
| 689 | subdict.replaceKey(new_key, existing_old); | 681 | subdict.replaceKey(new_key, existing_old); |
| 690 | subdict.removeKey(old_key); | 682 | subdict.removeKey(old_key); |
| 691 | } | 683 | } |
| @@ -878,7 +870,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( | @@ -878,7 +870,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( | ||
| 878 | bool have_parent = false; | 870 | bool have_parent = false; |
| 879 | if (ffield_oh.isStream()) { | 871 | if (ffield_oh.isStream()) { |
| 880 | ffield.warn("ignoring form field that's a stream"); | 872 | ffield.warn("ignoring form field that's a stream"); |
| 881 | - } else if ((!ffield_oh.isNull()) && (!ffield_oh.isIndirect())) { | 873 | + } else if (!ffield_oh.null() && !ffield_oh.isIndirect()) { |
| 882 | ffield.warn("ignoring form field not indirect"); | 874 | ffield.warn("ignoring form field not indirect"); |
| 883 | } else if (!ffield.null()) { | 875 | } else if (!ffield.null()) { |
| 884 | // A field and its associated annotation can be the same object. This matters because we | 876 | // A field and its associated annotation can be the same object. This matters because we |
qpdf/qpdf.testcov
| @@ -509,11 +509,7 @@ QPDFJob pages keeping field from original 0 | @@ -509,11 +509,7 @@ QPDFJob pages keeping field from original 0 | ||
| 509 | QPDFObjectHandle merge reuse 0 | 509 | QPDFObjectHandle merge reuse 0 |
| 510 | QPDFObjectHandle merge generate 0 | 510 | QPDFObjectHandle merge generate 0 |
| 511 | QPDFFormFieldObjectHelper get font from /DR 0 | 511 | QPDFFormFieldObjectHelper get font from /DR 0 |
| 512 | -QPDFAcroFormDocumentHelper override da 0 | ||
| 513 | -QPDFAcroFormDocumentHelper override q 0 | ||
| 514 | QPDFAcroFormDocumentHelper replaced DA token 0 | 512 | QPDFAcroFormDocumentHelper replaced DA token 0 |
| 515 | -QPDFAcroFormDocumentHelper ap conflict 0 | ||
| 516 | -QPDFAcroFormDocumentHelper ap rename 0 | ||
| 517 | QPDFAcroFormDocumentHelper /DA parse error 0 | 513 | QPDFAcroFormDocumentHelper /DA parse error 0 |
| 518 | QPDFAcroFormDocumentHelper AP parse error 1 | 514 | QPDFAcroFormDocumentHelper AP parse error 1 |
| 519 | QPDFJob copy fields not this file 0 | 515 | QPDFJob copy fields not this file 0 |