Commit 7ac9a08615dc71ad4493f4d963a012f31738ecc2
1 parent
2a33db91
Refactor `FormNode::generateTextAppearance`: Simplifyby using range-based `for` loop
Showing
1 changed file
with
8 additions
and
8 deletions
libqpdf/QPDFFormFieldObjectHelper.cc
| ... | ... | @@ -877,7 +877,6 @@ namespace |
| 877 | 877 | }; |
| 878 | 878 | } // namespace |
| 879 | 879 | |
| 880 | - | |
| 881 | 880 | void |
| 882 | 881 | FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) |
| 883 | 882 | { |
| ... | ... | @@ -914,7 +913,7 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) |
| 914 | 913 | // and updating it could have unintended side effects. This threshold may need to be updated |
| 915 | 914 | // if the internal reference counting changes in the future. |
| 916 | 915 | // |
| 917 | - // There is currently no explicit CI test for this code> I has been manually tested bu | |
| 916 | + // There is currently no explicit CI test for this code. It has been manually tested by | |
| 918 | 917 | // running it through CI with a threshold of 0, unconditionally copying streams. |
| 919 | 918 | auto data = AS.getStreamData(qpdf_dl_all); |
| 920 | 919 | AS = AS.copy(); |
| ... | ... | @@ -934,10 +933,6 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) |
| 934 | 933 | QPDFObjectHandle::Rectangle bbox = bbox_obj.getArrayAsRectangle(); |
| 935 | 934 | std::string DA = default_appearance(); |
| 936 | 935 | std::string V = value(); |
| 937 | - std::vector<std::string> opt; | |
| 938 | - if (isChoice() && (getFlags() & ff_ch_combo) == 0) { | |
| 939 | - opt = getChoices(); | |
| 940 | - } | |
| 941 | 936 | |
| 942 | 937 | TfFinder tff; |
| 943 | 938 | Pl_QPDFTokenizer tok("tf", &tff); |
| ... | ... | @@ -976,8 +971,13 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) |
| 976 | 971 | } |
| 977 | 972 | |
| 978 | 973 | V = (*encoder)(V, '?'); |
| 979 | - for (size_t i = 0; i < opt.size(); ++i) { | |
| 980 | - opt.at(i) = (*encoder)(opt.at(i), '?'); | |
| 974 | + | |
| 975 | + std::vector<std::string> opt; | |
| 976 | + if (isChoice() && (getFlags() & ff_ch_combo) == 0) { | |
| 977 | + opt = getChoices(); | |
| 978 | + for (auto& o: opt) { | |
| 979 | + o = (*encoder)(o, '?'); | |
| 980 | + } | |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | std::string result; | ... | ... |