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