Commit d77e3d7fa39427e71595293ab185f4d052cafe03

Authored by m-holger
1 parent b5af953b

Refactor: replace `isNull` calls with `null`, remove redundant `QTC::TC` calls i…

…n `QPDFPageDocumentHelper`, `QPDFPageObjectHelper` and `QPDFPageLabelDocumentHelper`.
libqpdf/QPDFPageDocumentHelper.cc
1 1 #include <qpdf/QPDFPageDocumentHelper.hh>
2 2  
3 3 #include <qpdf/QPDFAcroFormDocumentHelper.hh>
  4 +#include <qpdf/QPDFObjectHandle_private.hh>
4 5 #include <qpdf/QPDF_private.hh>
5 6 #include <qpdf/QTC.hh>
6 7 #include <qpdf/QUtil.hh>
... ... @@ -127,7 +128,7 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
127 128 ++next_fx;
128 129 }
129 130 new_content += content;
130   - } else if (process && !aoh.getAppearanceDictionary().isNull()) {
  131 + } else if (process && !aoh.getAppearanceDictionary().null()) {
131 132 // If an annotation has no selected appearance stream, just drop the annotation when
132 133 // flattening. This can happen for unchecked checkboxes and radio buttons, popup windows
133 134 // associated with comments that aren't visible, and other types of annotations that
... ...
libqpdf/QPDFPageLabelDocumentHelper.cc
1 1 #include <qpdf/QPDFPageLabelDocumentHelper.hh>
2 2  
3   -#include <qpdf/QTC.hh>
  3 +#include <qpdf/QPDFObjectHandle_private.hh>
4 4  
5 5 class QPDFPageLabelDocumentHelper::Members
6 6 {
... ... @@ -72,7 +72,7 @@ QPDFPageLabelDocumentHelper::getLabelsForPageRange(
72 72 // prior entry. If there is no entry for the first page, fabricate one that would match how the
73 73 // page would look in a new file in which it also didn't have an explicit label.
74 74 QPDFObjectHandle label = getLabelForPage(start_idx);
75   - if (label.isNull()) {
  75 + if (label.null()) {
76 76 label = QPDFObjectHandle::newDictionary();
77 77 label.replaceKey("/St", QPDFObjectHandle::newInteger(1 + new_start_idx));
78 78 }
... ...
libqpdf/QPDFPageObjectHelper.cc
... ... @@ -238,15 +238,14 @@ QPDFPageObjectHelper::getAttribute(
238 238 auto dict = is_form_xobject ? oh().getDict() : oh();
239 239 auto result = dict.getKey(name);
240 240  
241   - if (!is_form_xobject && result.isNull() &&
  241 + if (!is_form_xobject && result.null() &&
242 242 (name == "/MediaBox" || name == "/CropBox" || name == "/Resources" || name == "/Rotate")) {
243 243 QPDFObjectHandle node = dict;
244 244 QPDFObjGen::set seen{};
245 245 while (seen.add(node) && node.hasKey("/Parent")) {
246 246 node = node.getKey("/Parent");
247 247 result = node.getKey(name);
248   - if (!result.isNull()) {
249   - QTC::TC("qpdf", "QPDFPageObjectHelper non-trivial inheritance");
  248 + if (!result.null()) {
250 249 inherited = true;
251 250 break;
252 251 }
... ... @@ -256,10 +255,9 @@ QPDFPageObjectHelper::getAttribute(
256 255 QTC::TC("qpdf", "QPDFPageObjectHelper copy shared attribute", is_form_xobject ? 0 : 1);
257 256 result = dict.replaceKeyAndGetNew(name, result.shallowCopy());
258 257 }
259   - if (result.isNull() && get_fallback) {
  258 + if (result.null() && get_fallback) {
260 259 result = get_fallback();
261   - if (copy_if_fallback && !result.isNull()) {
262   - QTC::TC("qpdf", "QPDFPageObjectHelper copied fallback");
  260 + if (copy_if_fallback && !result.null()) {
263 261 result = dict.replaceKeyAndGetNew(name, result.shallowCopy());
264 262 } else {
265 263 QTC::TC("qpdf", "QPDFPageObjectHelper used fallback without copying");
... ... @@ -670,7 +668,7 @@ QPDFPageObjectHelper::getMatrixForTransformations(bool invert)
670 668 }
671 669 QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false);
672 670 QPDFObjectHandle scale_obj = getAttribute("/UserUnit", false);
673   - if (!(rotate_obj.isNull() && scale_obj.isNull())) {
  671 + if (!(rotate_obj.null() && scale_obj.null())) {
674 672 QPDFObjectHandle::Rectangle rect = bbox.getArrayAsRectangle();
675 673 double width = rect.urx - rect.llx;
676 674 double height = rect.ury - rect.lly;
... ... @@ -724,7 +722,7 @@ QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations)
724 722 result.replaceStreamData(provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
725 723 QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false);
726 724 QPDFObjectHandle scale_obj = getAttribute("/UserUnit", false);
727   - if (handle_transformations && (!(rotate_obj.isNull() && scale_obj.isNull()))) {
  725 + if (handle_transformations && !(rotate_obj.null() && scale_obj.null())) {
728 726 newdict.replaceKey("/Matrix", QPDFObjectHandle::newArray(getMatrixForTransformations()));
729 727 }
730 728  
... ... @@ -963,8 +961,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
963 961 oh().addPageContents(qpdf.newStream("\nQ\n"), false);
964 962 oh().removeKey("/Rotate");
965 963 QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false);
966   - if (!rotate_obj.isNull()) {
967   - QTC::TC("qpdf", "QPDFPageObjectHelper flatten inherit rotate");
  964 + if (!rotate_obj.null()) {
968 965 oh().replaceKey("/Rotate", QPDFObjectHandle::newInteger(0));
969 966 }
970 967  
... ...
qpdf/qpdf.testcov
... ... @@ -374,7 +374,6 @@ QPDFPageDocumentHelper ignore annotation with no appearance 0
374 374 QPDFFormFieldObjectHelper create AS from scratch 0
375 375 QPDFFormFieldObjectHelper replaced BMC at EOF 0
376 376 QPDFFormFieldObjectHelper fallback Tf 0
377   -QPDFPageObjectHelper non-trivial inheritance 0
378 377 QPDFPageObjectHelper copy shared attribute 1
379 378 QPDFJob from_nr from repeat_nr 0
380 379 QPDF resolve duplicated page object 0
... ... @@ -491,7 +490,6 @@ QPDFPageObjectHelper unresolved names 0
491 490 QPDFPageObjectHelper resolving unresolved 0
492 491 QPDFFileSpecObjectHelper empty compat_name 0
493 492 QPDFFileSpecObjectHelper non-empty compat_name 0
494   -QPDFPageObjectHelper flatten inherit rotate 0
495 493 QPDFAcroFormDocumentHelper copy annotation 3
496 494 QPDFAcroFormDocumentHelper field with parent 3
497 495 QPDFAcroFormDocumentHelper modify ap matrix 0
... ... @@ -587,7 +585,6 @@ QPDF_json missing json version 0
587 585 QPDF_json bad json version 0
588 586 QPDF_json bad calledgetallpages 0
589 587 QPDF_json bad pushedinheritedpageresources 0
590   -QPDFPageObjectHelper copied fallback 0
591 588 QPDFPageObjectHelper used fallback without copying 0
592 589 QPDF skipping cache for known unchecked object 0
593 590 QPDF fix dangling triggered xref reconstruction 0
... ...