diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc index 65f103c..ac65a73 100644 --- a/libqpdf/QPDFAcroFormDocumentHelper.cc +++ b/libqpdf/QPDFAcroFormDocumentHelper.cc @@ -1,5 +1,7 @@ #include +#include + #include #include #include @@ -14,29 +16,20 @@ using namespace qpdf; using namespace std::literals; -class QPDFAcroFormDocumentHelper::Members +using AcroForm = impl::AcroForm; + +class QPDFAcroFormDocumentHelper::Members: public AcroForm { public: - Members() = default; - Members(Members const&) = delete; - ~Members() = default; - - struct FieldData + Members(QPDF& qpdf) : + AcroForm(qpdf.doc()) { - std::vector annotations; - std::string name; - }; - - bool cache_valid{false}; - std::map field_to; - std::map annotation_to_field; - std::map> name_to_fields; - std::set bad_fields; + } }; QPDFAcroFormDocumentHelper::QPDFAcroFormDocumentHelper(QPDF& qpdf) : QPDFDocumentHelper(qpdf), - m(std::make_shared()) + m(std::make_shared(qpdf)) { // We have to analyze up front. Otherwise, when we are adding annotations and fields, we are in // a temporarily unstable configuration where some widget annotations are not reachable. @@ -62,6 +55,7 @@ QPDFAcroFormDocumentHelper::invalidateCache() m->cache_valid = false; m->field_to.clear(); m->annotation_to_field.clear(); + m->bad_fields.clear(); } bool diff --git a/libqpdf/qpdf/FormField.hh b/libqpdf/qpdf/FormField.hh index 6a15023..8ea8a10 100644 --- a/libqpdf/qpdf/FormField.hh +++ b/libqpdf/qpdf/FormField.hh @@ -3,6 +3,7 @@ #include #include +#include #include @@ -10,6 +11,34 @@ class QPDFAnnotationObjectHelper; namespace qpdf::impl { + class AcroForm: public Doc::Common + { + public: + AcroForm() = delete; + AcroForm(AcroForm const&) = delete; + AcroForm(AcroForm&&) = delete; + AcroForm& operator=(AcroForm const&) = delete; + AcroForm& operator=(AcroForm&&) = delete; + ~AcroForm() = default; + + AcroForm(impl::Doc& doc) : + Common(doc) + { + } + + struct FieldData + { + std::vector annotations; + std::string name; + }; + + bool cache_valid{false}; + std::map field_to; + std::map annotation_to_field; + std::map> name_to_fields; + std::set bad_fields; + }; // class AcroForm + /// @class FormNode /// @brief Represents a node in the interactive forms tree of a PDF document. /// @@ -390,7 +419,7 @@ namespace qpdf::impl getFontFromResource(QPDFObjectHandle resources, std::string const& font_name); static const QPDFObjectHandle null_oh; - }; + }; // class FormNode } // namespace qpdf::impl #endif // FORMFIELD_HH