diff options
Diffstat (limited to 'core/fpdfdoc/cpdf_formfield.cpp')
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 4cb9496af9..2b06161b06 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -251,15 +251,20 @@ bool CPDF_FormField::ResetField(NotificationOption notify) { } int CPDF_FormField::CountControls() const { - return pdfium::CollectionSize<int>(m_ControlList); + return pdfium::CollectionSize<int>(GetControls()); +} + +CPDF_FormControl* CPDF_FormField::GetControl(int index) const { + return GetControls()[index].Get(); } int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) const { if (!pControl) return -1; - auto it = std::find(m_ControlList.begin(), m_ControlList.end(), pControl); - return it != m_ControlList.end() ? it - m_ControlList.begin() : -1; + const auto& controls = GetControls(); + auto it = std::find(controls.begin(), controls.end(), pControl); + return it != controls.end() ? it - controls.begin() : -1; } FormFieldType CPDF_FormField::GetFieldType() const { @@ -426,10 +431,11 @@ int CPDF_FormField::GetMaxLen() const { if (const CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "MaxLen")) return pObj->GetInteger(); - for (auto& pControl : m_ControlList) { + for (auto& pControl : GetControls()) { if (!pControl) continue; - CPDF_Dictionary* pWidgetDict = pControl->GetWidget(); + + const CPDF_Dictionary* pWidgetDict = pControl->GetWidget(); if (pWidgetDict->KeyExist("MaxLen")) return pWidgetDict->GetIntegerFor("MaxLen"); } @@ -931,3 +937,8 @@ void CPDF_FormField::NotifyListOrComboBoxAfterChange() { break; } } + +const std::vector<UnownedPtr<CPDF_FormControl>>& CPDF_FormField::GetControls() + const { + return m_pForm->GetControlsForField(this); +} |