Commit 7ac9a08615dc71ad4493f4d963a012f31738ecc2

Authored by m-holger
1 parent 2a33db91

Refactor `FormNode::generateTextAppearance`: Simplifyby using range-based `for` loop

libqpdf/QPDFFormFieldObjectHelper.cc
@@ -877,7 +877,6 @@ namespace @@ -877,7 +877,6 @@ namespace
877 }; 877 };
878 } // namespace 878 } // namespace
879 879
880 -  
881 void 880 void
882 FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) 881 FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
883 { 882 {
@@ -914,7 +913,7 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) @@ -914,7 +913,7 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
914 // and updating it could have unintended side effects. This threshold may need to be updated 913 // and updating it could have unintended side effects. This threshold may need to be updated
915 // if the internal reference counting changes in the future. 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 // running it through CI with a threshold of 0, unconditionally copying streams. 917 // running it through CI with a threshold of 0, unconditionally copying streams.
919 auto data = AS.getStreamData(qpdf_dl_all); 918 auto data = AS.getStreamData(qpdf_dl_all);
920 AS = AS.copy(); 919 AS = AS.copy();
@@ -934,10 +933,6 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) @@ -934,10 +933,6 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
934 QPDFObjectHandle::Rectangle bbox = bbox_obj.getArrayAsRectangle(); 933 QPDFObjectHandle::Rectangle bbox = bbox_obj.getArrayAsRectangle();
935 std::string DA = default_appearance(); 934 std::string DA = default_appearance();
936 std::string V = value(); 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 TfFinder tff; 937 TfFinder tff;
943 Pl_QPDFTokenizer tok("tf", &tff); 938 Pl_QPDFTokenizer tok("tf", &tff);
@@ -976,8 +971,13 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper&amp; aoh) @@ -976,8 +971,13 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper&amp; aoh)
976 } 971 }
977 972
978 V = (*encoder)(V, '?'); 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 std::string result; 983 std::string result;