|
|
|
@ -124,6 +124,38 @@ module HexaPDF
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module CycleSafeEachField
|
|
|
|
|
|
|
|
def each_field(terminal_only: true)
|
|
|
|
|
|
|
|
return to_enum(__method__, terminal_only:) unless block_given?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
seen = Set.new.compare_by_identity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
process_field_array = lambda do |array|
|
|
|
|
|
|
|
|
array.each_with_index do |field, index|
|
|
|
|
|
|
|
|
next if field.nil?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unless field.respond_to?(:type) && field.type == :XXAcroFormField
|
|
|
|
|
|
|
|
array[index] = field = HexaPDF::Type::AcroForm::Field.wrap(document, field)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
next unless seen.add?(field.value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if field.terminal_field?
|
|
|
|
|
|
|
|
yield(field)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
yield(field) unless terminal_only
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
process_field_array.call(field[:Kids])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
process_field_array.call(root_fields)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
module CycleSafeFullFieldName
|
|
|
|
module CycleSafeFullFieldName
|
|
|
|
def full_field_name(seen = Set.new.compare_by_identity)
|
|
|
|
def full_field_name(seen = Set.new.compare_by_identity)
|
|
|
|
return field_name unless seen.add?(value)
|
|
|
|
return field_name unless seen.add?(value)
|
|
|
|
@ -139,3 +171,4 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
HexaPDF::Type::AcroForm::Field.singleton_class.prepend(HexaPDF::CycleSafeInheritedValue)
|
|
|
|
HexaPDF::Type::AcroForm::Field.singleton_class.prepend(HexaPDF::CycleSafeInheritedValue)
|
|
|
|
HexaPDF::Type::AcroForm::Field.prepend(HexaPDF::CycleSafeFullFieldName)
|
|
|
|
HexaPDF::Type::AcroForm::Field.prepend(HexaPDF::CycleSafeFullFieldName)
|
|
|
|
|
|
|
|
HexaPDF::Type::AcroForm::Form.prepend(HexaPDF::CycleSafeEachField)
|
|
|
|
|