diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 0893b45..6a6ffa7 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -578,49 +578,41 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top) } if (foreign.isPagesObject()) { - QTC::TC("qpdf", "QPDF not copying pages object"); return; } if (foreign.isIndirect()) { QPDFObjGen foreign_og(foreign.getObjGen()); if (!obj_copier.visiting.add(foreign_og)) { - QTC::TC("qpdf", "QPDF loop reserving objects"); return; } if (obj_copier.object_map.contains(foreign_og)) { - QTC::TC("qpdf", "QPDF already reserved object"); - if (!(top && foreign.isPageObject() && obj_copier.object_map[foreign_og].isNull())) { + if (!(top && foreign.isPageObject() && obj_copier.object_map[foreign_og].null())) { obj_copier.visiting.erase(foreign); return; } } else { - QTC::TC("qpdf", "QPDF copy indirect"); obj_copier.object_map[foreign_og] = foreign.isStream() ? newStream() : newIndirectNull(); - if ((!top) && foreign.isPageObject()) { - QTC::TC("qpdf", "QPDF not crossing page boundary"); + if (!top && foreign.isPageObject()) { obj_copier.visiting.erase(foreign_og); return; } } - obj_copier.to_copy.push_back(foreign); + obj_copier.to_copy.emplace_back(foreign); } if (foreign_tc == ::ot_array) { - QTC::TC("qpdf", "QPDF reserve array"); for (auto const& item: foreign.as_array()) { reserveObjects(item, obj_copier, false); } } else if (foreign_tc == ::ot_dictionary) { - QTC::TC("qpdf", "QPDF reserve dictionary"); for (auto const& item: foreign.as_dictionary()) { if (!item.second.null()) { reserveObjects(item.second, obj_copier, false); } } } else if (foreign_tc == ::ot_stream) { - QTC::TC("qpdf", "QPDF reserve stream"); reserveObjects(foreign.getDict(), obj_copier, false); } diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc index e3a0c95..7adbe08 100644 --- a/libqpdf/QPDFAcroFormDocumentHelper.cc +++ b/libqpdf/QPDFAcroFormDocumentHelper.cc @@ -487,11 +487,7 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields( if (field.getObjectHandle().hasKey(key)) { return true; } - auto oh = field.getInheritableFieldValue(key); - if (!oh.isNull()) { - return true; - } - return false; + return !field.getInheritableFieldValue(key).null(); }; if (override_da || override_q) { @@ -499,14 +495,12 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields( if (override_da && (!has_explicit(cur_field, "/DA"))) { std::string da = cur_field.getDefaultAppearance(); if (da != from_default_da) { - QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override da"); obj.replaceKey("/DA", QPDFObjectHandle::newUnicodeString(from_default_da)); } } if (override_q && (!has_explicit(cur_field, "/Q"))) { int q = cur_field.getQuadding(); if (q != from_default_q) { - QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override q"); obj.replaceKey("/Q", QPDFObjectHandle::newInteger(from_default_q)); } } @@ -675,17 +669,15 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream( std::string const& old_key = i2.first; std::string const& new_key = i2.second; auto existing_new = subdict.getKey(new_key); - if (!existing_new.isNull()) { + if (!existing_new.null()) { // The resource dictionary already has a key in it matching what we remapped an old // key to, so we'll have to move it out of the way. Stick it in merge_with, which we // will re-merge with the dictionary when we're done. We know merge_with already has // dictionaries for all the top keys. - QTC::TC("qpdf", "QPDFAcroFormDocumentHelper ap conflict"); merge_with.getKey(top_key).replaceKey(new_key, existing_new); } auto existing_old = subdict.getKey(old_key); - if (!existing_old.isNull()) { - QTC::TC("qpdf", "QPDFAcroFormDocumentHelper ap rename"); + if (!existing_old.null()) { subdict.replaceKey(new_key, existing_old); subdict.removeKey(old_key); } @@ -878,7 +870,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( bool have_parent = false; if (ffield_oh.isStream()) { ffield.warn("ignoring form field that's a stream"); - } else if ((!ffield_oh.isNull()) && (!ffield_oh.isIndirect())) { + } else if (!ffield_oh.null() && !ffield_oh.isIndirect()) { ffield.warn("ignoring form field not indirect"); } else if (!ffield.null()) { // A field and its associated annotation can be the same object. This matters because we diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc index 59d12dc..fe9ff1c 100644 --- a/libqpdf/QPDFFormFieldObjectHelper.cc +++ b/libqpdf/QPDFFormFieldObjectHelper.cc @@ -25,7 +25,7 @@ QPDFFormFieldObjectHelper::QPDFFormFieldObjectHelper() : bool QPDFFormFieldObjectHelper::isNull() { - return oh().isNull(); + return oh().null(); } QPDFFormFieldObjectHelper @@ -39,7 +39,7 @@ QPDFFormFieldObjectHelper::getTopLevelField(bool* is_different) { auto top_field = oh(); QPDFObjGen::set seen; - while (seen.add(top_field) && !top_field.getKeyIfDict("/Parent").isNull()) { + while (seen.add(top_field) && !top_field.getKeyIfDict("/Parent").null()) { top_field = top_field.getKey("/Parent"); if (is_different) { *is_different = true; @@ -72,13 +72,12 @@ QPDFFormFieldObjectHelper::getInheritableFieldValue(std::string const& name) return QPDFObjectHandle::newNull(); } QPDFObjectHandle result(node.getKey(name)); - if (result.isNull()) { + if (result.null()) { QPDFObjGen::set seen; while (seen.add(node) && node.hasKey("/Parent")) { node = node.getKey("/Parent"); result = node.getKey(name); - if (!result.isNull()) { - QTC::TC("qpdf", "QPDFFormFieldObjectHelper non-trivial inheritance"); + if (!result.null()) { return result; } } @@ -118,10 +117,9 @@ QPDFFormFieldObjectHelper::getFullyQualifiedName() std::string result; QPDFObjectHandle node = oh(); QPDFObjGen::set seen; - while (!node.isNull() && seen.add(node)) { + while (!node.null() && seen.add(node)) { if (node.getKey("/T").isString()) { if (!result.empty()) { - QTC::TC("qpdf", "QPDFFormFieldObjectHelper non-trivial qualified name"); result = "." + result; } result = node.getKey("/T").getUTF8Value() + result; @@ -360,18 +358,17 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name) // is a member, set /AS to /Off. // Note that we never turn on /NeedAppearances when setting a radio button field. QPDFObjectHandle parent = oh().getKey("/Parent"); - if (parent.isDictionary() && parent.getKey("/Parent").isNull()) { + if (parent.isDictionary() && parent.getKey("/Parent").null()) { QPDFFormFieldObjectHelper ph(parent); if (ph.isRadioButton()) { // This is most likely one of the individual buttons. Try calling on the parent. - QTC::TC("qpdf", "QPDFFormFieldObjectHelper set parent radio button"); ph.setRadioButtonValue(name); return; } } QPDFObjectHandle kids = oh().getKey("/Kids"); - if (!(isRadioButton() && parent.isNull() && kids.isArray())) { + if (!(isRadioButton() && parent.null() && kids.isArray())) { warn("don't know how to set the value of this field as a radio button"); return; } @@ -384,7 +381,6 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name) for (auto const& grandkid: kid.getKey("/Kids").as_array()) { AP = grandkid.getKey("/AP"); if (!AP.null()) { - QTC::TC("qpdf", "QPDFFormFieldObjectHelper radio button grandkid"); annot = grandkid; break; } @@ -393,16 +389,13 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name) annot = kid; } if (!annot) { - QTC::TC("qpdf", "QPDFObjectHandle broken radio button"); warn("unable to set the value of this radio button"); continue; } if (AP.isDictionary() && AP.getKey("/N").isDictionary() && AP.getKey("/N").hasKey(name.getName())) { - QTC::TC("qpdf", "QPDFFormFieldObjectHelper turn on radio button"); annot.replaceKey("/AS", name); } else { - QTC::TC("qpdf", "QPDFFormFieldObjectHelper turn off radio button"); annot.replaceKey("/AS", QPDFObjectHandle::newName("/Off")); } } @@ -749,7 +742,7 @@ void QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) { QPDFObjectHandle AS = aoh.getAppearanceStream("/N"); - if (AS.isNull()) { + if (AS.null()) { QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AS from scratch"); QPDFObjectHandle::Rectangle rect = aoh.getRect(); QPDFObjectHandle::Rectangle bbox(0, 0, rect.urx - rect.llx, rect.ury - rect.lly); @@ -759,8 +752,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao AS = QPDFObjectHandle::newStream(oh().getOwningQPDF(), "/Tx BMC\nEMC\n"); AS.replaceDict(dict); QPDFObjectHandle AP = aoh.getAppearanceDictionary(); - if (AP.isNull()) { - QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AP from scratch"); + if (AP.null()) { aoh.getObjectHandle().replaceKey("/AP", QPDFObjectHandle::newDictionary()); AP = aoh.getAppearanceDictionary(); } @@ -808,7 +800,6 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao found_font_in_dr = font.isDictionary(); } if (found_font_in_dr && resources.isDictionary()) { - QTC::TC("qpdf", "QPDFFormFieldObjectHelper get font from /DR"); if (resources.isIndirect()) { resources = resources.getQPDF().makeIndirectObject(resources.shallowCopy()); AS.getDict().replaceKey("/Resources", resources); @@ -821,7 +812,6 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao if (font.isDictionary() && font.getKey("/Encoding").isName()) { std::string encoding = font.getKey("/Encoding").getName(); if (encoding == "/WinAnsiEncoding") { - QTC::TC("qpdf", "QPDFFormFieldObjectHelper WinAnsi"); encoder = &QUtil::utf8_to_win_ansi; } else if (encoding == "/MacRomanEncoding") { encoder = &QUtil::utf8_to_mac_roman; diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index 3748701..c9e91a1 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -464,7 +464,7 @@ QPDFJob::createQPDF() if (m->remove_info) { auto trailer = pdf.getTrailer(); auto mod_date = trailer.getKey("/Info").getKeyIfDict("/ModDate"); - if (mod_date.isNull()) { + if (mod_date.null()) { trailer.removeKey("/Info"); } else { auto info = trailer.replaceKeyAndGetNew( @@ -2064,7 +2064,7 @@ static void maybe_set_pagemode(QPDF& pdf, std::string const& pagemode) { auto root = pdf.getRoot(); - if (root.getKey("/PageMode").isNull()) { + if (root.getKey("/PageMode").null()) { root.replaceKey("/PageMode", QPDFObjectHandle::newName(pagemode)); } } diff --git a/libqpdf/QPDFOutlineDocumentHelper.cc b/libqpdf/QPDFOutlineDocumentHelper.cc index f1774ff..bcba309 100644 --- a/libqpdf/QPDFOutlineDocumentHelper.cc +++ b/libqpdf/QPDFOutlineDocumentHelper.cc @@ -1,5 +1,6 @@ #include +#include #include class QPDFOutlineDocumentHelper::Members @@ -36,7 +37,7 @@ QPDFOutlineDocumentHelper::QPDFOutlineDocumentHelper(QPDF& qpdf) : } QPDFObjectHandle cur = outlines.getKey("/First"); QPDFObjGen::set seen; - while (!cur.isNull() && seen.add(cur)) { + while (!cur.null() && seen.add(cur)) { m->outlines.emplace_back(QPDFOutlineObjectHelper::Accessor::create(cur, *this, 1)); cur = cur.getKey("/Next"); } diff --git a/libqpdf/QPDFOutlineObjectHelper.cc b/libqpdf/QPDFOutlineObjectHelper.cc index 640826a..4c3a2bf 100644 --- a/libqpdf/QPDFOutlineObjectHelper.cc +++ b/libqpdf/QPDFOutlineObjectHelper.cc @@ -1,5 +1,6 @@ #include +#include #include #include @@ -19,13 +20,12 @@ QPDFOutlineObjectHelper::QPDFOutlineObjectHelper( return; } if (QPDFOutlineDocumentHelper::Accessor::checkSeen(m->dh, a_oh.getObjGen())) { - QTC::TC("qpdf", "QPDFOutlineObjectHelper loop"); return; } QPDFObjGen::set children; QPDFObjectHandle cur = a_oh.getKey("/First"); - while (!cur.isNull() && cur.isIndirect() && children.add(cur)) { + while (!cur.null() && cur.isIndirect() && children.add(cur)) { QPDFOutlineObjectHelper new_ooh(cur, dh, 1 + depth); new_ooh.m->parent = std::make_shared(*this); m->kids.push_back(new_ooh); diff --git a/libqpdf/QPDFPageDocumentHelper.cc b/libqpdf/QPDFPageDocumentHelper.cc index 3d0fbdb..154443e 100644 --- a/libqpdf/QPDFPageDocumentHelper.cc +++ b/libqpdf/QPDFPageDocumentHelper.cc @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -127,7 +128,7 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage( ++next_fx; } new_content += content; - } else if (process && !aoh.getAppearanceDictionary().isNull()) { + } else if (process && !aoh.getAppearanceDictionary().null()) { // If an annotation has no selected appearance stream, just drop the annotation when // flattening. This can happen for unchecked checkboxes and radio buttons, popup windows // associated with comments that aren't visible, and other types of annotations that diff --git a/libqpdf/QPDFPageLabelDocumentHelper.cc b/libqpdf/QPDFPageLabelDocumentHelper.cc index 54f8238..878c54e 100644 --- a/libqpdf/QPDFPageLabelDocumentHelper.cc +++ b/libqpdf/QPDFPageLabelDocumentHelper.cc @@ -1,6 +1,6 @@ #include -#include +#include class QPDFPageLabelDocumentHelper::Members { @@ -72,7 +72,7 @@ QPDFPageLabelDocumentHelper::getLabelsForPageRange( // prior entry. If there is no entry for the first page, fabricate one that would match how the // page would look in a new file in which it also didn't have an explicit label. QPDFObjectHandle label = getLabelForPage(start_idx); - if (label.isNull()) { + if (label.null()) { label = QPDFObjectHandle::newDictionary(); label.replaceKey("/St", QPDFObjectHandle::newInteger(1 + new_start_idx)); } diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc index 1a0098c..530247f 100644 --- a/libqpdf/QPDFPageObjectHelper.cc +++ b/libqpdf/QPDFPageObjectHelper.cc @@ -238,15 +238,14 @@ QPDFPageObjectHelper::getAttribute( auto dict = is_form_xobject ? oh().getDict() : oh(); auto result = dict.getKey(name); - if (!is_form_xobject && result.isNull() && + if (!is_form_xobject && result.null() && (name == "/MediaBox" || name == "/CropBox" || name == "/Resources" || name == "/Rotate")) { QPDFObjectHandle node = dict; QPDFObjGen::set seen{}; while (seen.add(node) && node.hasKey("/Parent")) { node = node.getKey("/Parent"); result = node.getKey(name); - if (!result.isNull()) { - QTC::TC("qpdf", "QPDFPageObjectHelper non-trivial inheritance"); + if (!result.null()) { inherited = true; break; } @@ -256,10 +255,9 @@ QPDFPageObjectHelper::getAttribute( QTC::TC("qpdf", "QPDFPageObjectHelper copy shared attribute", is_form_xobject ? 0 : 1); result = dict.replaceKeyAndGetNew(name, result.shallowCopy()); } - if (result.isNull() && get_fallback) { + if (result.null() && get_fallback) { result = get_fallback(); - if (copy_if_fallback && !result.isNull()) { - QTC::TC("qpdf", "QPDFPageObjectHelper copied fallback"); + if (copy_if_fallback && !result.null()) { result = dict.replaceKeyAndGetNew(name, result.shallowCopy()); } else { QTC::TC("qpdf", "QPDFPageObjectHelper used fallback without copying"); @@ -670,7 +668,7 @@ QPDFPageObjectHelper::getMatrixForTransformations(bool invert) } QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false); QPDFObjectHandle scale_obj = getAttribute("/UserUnit", false); - if (!(rotate_obj.isNull() && scale_obj.isNull())) { + if (!(rotate_obj.null() && scale_obj.null())) { QPDFObjectHandle::Rectangle rect = bbox.getArrayAsRectangle(); double width = rect.urx - rect.llx; double height = rect.ury - rect.lly; @@ -724,7 +722,7 @@ QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations) result.replaceStreamData(provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false); QPDFObjectHandle scale_obj = getAttribute("/UserUnit", false); - if (handle_transformations && (!(rotate_obj.isNull() && scale_obj.isNull()))) { + if (handle_transformations && !(rotate_obj.null() && scale_obj.null())) { newdict.replaceKey("/Matrix", QPDFObjectHandle::newArray(getMatrixForTransformations())); } @@ -963,8 +961,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh) oh().addPageContents(qpdf.newStream("\nQ\n"), false); oh().removeKey("/Rotate"); QPDFObjectHandle rotate_obj = getAttribute("/Rotate", false); - if (!rotate_obj.isNull()) { - QTC::TC("qpdf", "QPDFPageObjectHelper flatten inherit rotate"); + if (!rotate_obj.null()) { oh().replaceKey("/Rotate", QPDFObjectHandle::newInteger(0)); } diff --git a/libqpdf/QPDFStreamFilter.cc b/libqpdf/QPDFStreamFilter.cc index 66a2f76..a4949de 100644 --- a/libqpdf/QPDFStreamFilter.cc +++ b/libqpdf/QPDFStreamFilter.cc @@ -1,9 +1,11 @@ #include +#include + bool QPDFStreamFilter::setDecodeParms(QPDFObjectHandle decode_parms) { - return decode_parms.isNull(); + return decode_parms.null(); } bool diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 66f0dd0..3ac9942 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1782,12 +1782,11 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) write(" /Filter /FlateDecode"); } write(" /N ").write(offsets.size()).write_qdf("\n ").write(" /First ").write(first); - if (!object.isNull()) { + if (!object.null()) { // If the original object has an /Extends key, preserve it. QPDFObjectHandle dict = object.getDict(); QPDFObjectHandle extends = dict.getKey("/Extends"); if (extends.isIndirect()) { - QTC::TC("qpdf", "QPDFWriter copy Extends"); write_qdf("\n ").write(" /Extends "); unparseChild(extends, 1, f_in_ostream); } diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index f02a7bb..f606b2b 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -40,7 +40,7 @@ BaseDictionary::getKeys() { std::set result; for (auto& iter: dict()->items) { - if (!iter.second.isNull()) { + if (!iter.second.null()) { result.insert(iter.first); } } diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc index 992cc84..73a9b38 100644 --- a/libqpdf/QPDF_Stream.cc +++ b/libqpdf/QPDF_Stream.cc @@ -376,7 +376,7 @@ Stream::filterable( auto filter_obj = s->stream_dict.getKey("/Filter"); - if (filter_obj.isNull()) { + if (filter_obj.null()) { // No filters return true; } diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc index e5dca43..8be325a 100644 --- a/libqpdf/QPDF_encryption.cc +++ b/libqpdf/QPDF_encryption.cc @@ -681,7 +681,7 @@ QPDF::EncryptionParameters::initialize(QPDF& qpdf) (encryption_dict.getKey("/Filter").getName() == "/Standard"))) { throw unsupported("unsupported encryption filter"); } - if (!encryption_dict.getKey("/SubFilter").isNull()) { + if (!encryption_dict.getKey("/SubFilter").null()) { qpdf.warn(unsupported("file uses encryption SubFilters, which qpdf does not support")); } diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index 8ac8e51..bcce0e6 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -167,7 +167,7 @@ QPDF::readLinearizationData() QPDFObjectHandle P = m->lindict.getKey("/P"); if (!(H.isArray() && O.isInteger() && E.isInteger() && N.isInteger() && T.isInteger() && - (P.isInteger() || P.isNull()))) { + (P.isInteger() || P.null()))) { throw damagedPDF( "linearization dictionary", "some keys in linearization dictionary are of the wrong type"); @@ -577,7 +577,7 @@ QPDF::getUncompressedObject(QPDFObjectHandle& oh, QPDFWriter::ObjTable const& ob { if (obj.contains(oh)) { if (auto id = obj[oh].object_stream; id > 0) { - return oh.isNull() ? oh : getObject(id, 0); + return oh.null() ? oh : getObject(id, 0); } } return oh; @@ -1284,7 +1284,7 @@ QPDF::calculateLinearizationData(T const& object_stream_data) thumb = getUncompressedObject(thumb, object_stream_data); QPDFObjGen thumb_og(thumb.getObjGen()); // Output the thumbnail itself - if (lc_thumbnail_private.erase(thumb_og) && !thumb.isNull()) { + if (lc_thumbnail_private.erase(thumb_og) && !thumb.null()) { m->part9.emplace_back(thumb); } else { // No internal error this time...there's nothing to stop this object from having @@ -1394,7 +1394,7 @@ QPDF::pushOutlinesToPart( { QPDFObjectHandle root = getRoot(); QPDFObjectHandle outlines = root.getKey("/Outlines"); - if (outlines.isNull()) { + if (outlines.null()) { return; } outlines = getUncompressedObject(outlines, object_stream_data); diff --git a/libqpdf/QPDF_objects.cc b/libqpdf/QPDF_objects.cc index aa65e0d..354af00 100644 --- a/libqpdf/QPDF_objects.cc +++ b/libqpdf/QPDF_objects.cc @@ -910,8 +910,7 @@ QPDF::processXRefIndex( } QTC::TC("qpdf", "QPDF xref /Index is array", index_vec.size() == 2 ? 0 : 1); return {num_entries, indx}; - } else if (Index_obj.isNull()) { - QTC::TC("qpdf", "QPDF xref /Index is null"); + } else if (Index_obj.null()) { return {size, {{0, size}}}; } else { throw damaged("Cross-reference stream does not have a proper /Index key"); @@ -1256,11 +1255,9 @@ QPDF::readStream(QPDFObjectHandle& object, QPDFObjGen og, qpdf_offset_t offset) auto length_obj = object.getKey("/Length"); if (!length_obj.isInteger()) { - if (length_obj.isNull()) { - QTC::TC("qpdf", "QPDF stream without length"); + if (length_obj.null()) { throw damagedPDF(offset, "stream dictionary lacks /Length key"); } - QTC::TC("qpdf", "QPDF stream length not integer"); throw damagedPDF(offset, "/Length key in stream dictionary is not an integer"); } @@ -1269,7 +1266,6 @@ QPDF::readStream(QPDFObjectHandle& object, QPDFObjGen og, qpdf_offset_t offset) m->file->seek(stream_offset, SEEK_SET); m->file->seek(toO(length), SEEK_CUR); if (!readToken(*m->file).isWord("endstream")) { - QTC::TC("qpdf", "QPDF missing endstream"); throw damagedPDF("expected endstream"); } } catch (QPDFExc& e) { diff --git a/libqpdf/SF_FlateLzwDecode.cc b/libqpdf/SF_FlateLzwDecode.cc index bd5454d..e71cb24 100644 --- a/libqpdf/SF_FlateLzwDecode.cc +++ b/libqpdf/SF_FlateLzwDecode.cc @@ -5,12 +5,13 @@ #include #include #include +#include #include bool SF_FlateLzwDecode::setDecodeParms(QPDFObjectHandle decode_parms) { - if (decode_parms.isNull()) { + if (decode_parms.null()) { return true; } diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov index a4136fb..2fee084 100644 --- a/qpdf/qpdf.testcov +++ b/qpdf/qpdf.testcov @@ -64,9 +64,6 @@ QPDFParser bad brace 0 QPDFParser bad brace in parseRemainder 0 QPDFParser bad array close 0 QPDFParser bad array close in parseRemainder 0 -QPDF stream without length 0 -QPDF stream length not integer 0 -QPDF missing endstream 0 QPDFParser bad dictionary close 0 QPDFParser bad dictionary close in parseRemainder 0 QPDF can't find xref 0 @@ -87,9 +84,7 @@ QPDF found xref stream 0 QPDF ignoring XRefStm in trailer 0 QPDF xref deleted object 0 SF_FlateLzwDecode PNG filter 0 -QPDF xref /Index is null 0 QPDF xref /Index is array 1 -QPDFWriter copy Extends 0 QPDFWriter encrypt object stream 0 QPDFWriter uncompressing page dictionary 0 QPDFWriter uncompressing root 0 @@ -204,18 +199,11 @@ QPDF_Stream unknown stream length 0 QPDF replaceReserved 0 QPDF copyForeign direct 0 QPDF copyForeign not foreign 0 -QPDF copy indirect 0 -QPDF loop reserving objects 0 QPDF replace indirect 0 QPDF replace array 0 QPDF replace dictionary 0 QPDF replace stream 0 -QPDF reserve array 0 -QPDF reserve dictionary 0 -QPDF reserve stream 0 -QPDF not crossing page boundary 0 QPDF replace foreign indirect with null 0 -QPDF not copying pages object 0 QPDF insert foreign page 0 QPDFWriter foreign object 0 QPDFWriter copy use_aes 1 @@ -249,7 +237,6 @@ QPDF_optimization indirect outlines 0 QPDF xref space 2 QPDFJob pages range omitted in middle 0 QPDFJob npages 0 -QPDF already reserved object 0 QPDFWriter standard deterministic ID 1 QPDFWriter linearized deterministic ID 1 qpdf-c called qpdf_set_deterministic_ID 0 @@ -312,8 +299,6 @@ QPDFObjectHandle erase array bounds 0 qpdf-c called qpdf_check_pdf 0 QPDF xref loop 0 QPDFParser too deep 0 -QPDFFormFieldObjectHelper non-trivial inheritance 0 -QPDFFormFieldObjectHelper non-trivial qualified name 0 QPDFFormFieldObjectHelper TU present 0 QPDFFormFieldObjectHelper TM present 0 QPDFFormFieldObjectHelper TU absent 0 @@ -340,7 +325,6 @@ QPDFOutlineObjectHelper direct dest 0 QPDFOutlineObjectHelper action dest 0 QPDFOutlineObjectHelper named dest 0 QPDFOutlineDocumentHelper string named dest 0 -QPDFOutlineObjectHelper loop 0 QPDFObjectHandle merge top type mismatch 0 QPDFObjectHandle merge shallow copy 0 QPDFObjectHandle merge array 0 @@ -361,12 +345,7 @@ QPDFObjectHandle replace with copy 0 QPDFPageDocumentHelper indirect as resources 0 QPDFAnnotationObjectHelper forbidden flags 0 QPDFAnnotationObjectHelper missing required flags 0 -QPDFFormFieldObjectHelper set parent radio button 0 -QPDFFormFieldObjectHelper radio button grandkid 0 -QPDFFormFieldObjectHelper turn on radio button 0 -QPDFFormFieldObjectHelper turn off radio button 0 QPDFFormFieldObjectHelper checkbox kid widget 0 -QPDFObjectHandle broken radio button 0 QPDFFormFieldObjectHelper set checkbox AS 0 QPDFObjectHandle broken checkbox 0 QPDFFormFieldObjectHelper list not found 0 @@ -376,7 +355,6 @@ QPDFFormFieldObjectHelper list last too high 0 QPDFJob image optimize no pipeline 0 QPDFJob image optimize no shrink 0 QPDFJob image optimize too small 0 -QPDFFormFieldObjectHelper WinAnsi 0 QPDF pipe foreign encrypted stream 0 QPDF copy foreign stream with provider 0 QPDF copy foreign stream with buffer 0 @@ -393,10 +371,8 @@ QPDFJob invalid utf-8 in auto 0 QPDFJob input password hex-bytes 0 QPDFPageDocumentHelper ignore annotation with no appearance 0 QPDFFormFieldObjectHelper create AS from scratch 0 -QPDFFormFieldObjectHelper create AP from scratch 0 QPDFFormFieldObjectHelper replaced BMC at EOF 0 QPDFFormFieldObjectHelper fallback Tf 0 -QPDFPageObjectHelper non-trivial inheritance 0 QPDFPageObjectHelper copy shared attribute 1 QPDFJob from_nr from repeat_nr 0 QPDF resolve duplicated page object 0 @@ -513,19 +489,13 @@ QPDFPageObjectHelper unresolved names 0 QPDFPageObjectHelper resolving unresolved 0 QPDFFileSpecObjectHelper empty compat_name 0 QPDFFileSpecObjectHelper non-empty compat_name 0 -QPDFPageObjectHelper flatten inherit rotate 0 QPDFAcroFormDocumentHelper copy annotation 3 QPDFAcroFormDocumentHelper field with parent 3 QPDFAcroFormDocumentHelper modify ap matrix 0 QPDFJob pages keeping field from original 0 QPDFObjectHandle merge reuse 0 QPDFObjectHandle merge generate 0 -QPDFFormFieldObjectHelper get font from /DR 0 -QPDFAcroFormDocumentHelper override da 0 -QPDFAcroFormDocumentHelper override q 0 QPDFAcroFormDocumentHelper replaced DA token 0 -QPDFAcroFormDocumentHelper ap conflict 0 -QPDFAcroFormDocumentHelper ap rename 0 QPDFAcroFormDocumentHelper /DA parse error 0 QPDFAcroFormDocumentHelper AP parse error 1 QPDFJob copy fields not this file 0 @@ -614,7 +584,6 @@ QPDF_json missing json version 0 QPDF_json bad json version 0 QPDF_json bad calledgetallpages 0 QPDF_json bad pushedinheritedpageresources 0 -QPDFPageObjectHelper copied fallback 0 QPDFPageObjectHelper used fallback without copying 0 QPDF skipping cache for known unchecked object 0 QPDF fix dangling triggered xref reconstruction 0