7#include "fpdfsdk/formfiller/cffl_combobox.h"
11#include "constants/form_flags.h"
12#include "core/fpdfdoc/cpdf_bafontmap.h"
13#include "fpdfsdk/cpdfsdk_widget.h"
14#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
15#include "fpdfsdk/formfiller/cffl_perwindowdata.h"
16#include "fpdfsdk/pwl/cpwl_combo_box.h"
17#include "fpdfsdk/pwl/cpwl_edit.h"
20 CPDFSDK_Widget* pWidget)
32 if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceEdit)
41 std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData) {
42 static_cast<CFFL_PerWindowData*>(pAttachedData.get())
->SetFormField(
this);
43 auto pWnd =
std::make_unique<CPWL_ComboBox>(cp,
std::move(pAttachedData));
46 int32_t nCurSel = m_pWidget->GetSelectedIndex(0);
49 swText = m_pWidget->GetValue();
51 swText = m_pWidget->GetOptionLabel(nCurSel);
53 for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++)
54 pWnd->AddString(m_pWidget->GetOptionLabel(i));
56 pWnd->SetSelect(nCurSel);
57 pWnd->SetText(swText);
61bool CFFL_ComboBox::
OnChar(CPDFSDK_Widget* pWidget,
63 Mask<FWL_EVENTFLAG> nFlags) {
68 auto* pWnd = GetPWLComboBox(pPageView);
73 if (!(m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceEdit))
74 return nCurSel != m_pWidget->GetSelectedIndex(0);
77 return nCurSel != m_pWidget->GetSelectedIndex(0);
79 return pWnd->GetText() != m_pWidget->GetValue();
82void CFFL_ComboBox::
SaveData(
const CPDFSDK_PageView* pPageView) {
83 ObservedPtr<CFFL_ComboBox> observed_this(
this);
84 CPWL_ComboBox* pWnd = observed_this->GetPWLComboBox(pPageView);
90 bool bSetValue =
false;
91 ObservedPtr<CPDFSDK_Widget> observed_widget(observed_this->m_pWidget);
94 (nCurSel < 0) || (swText != observed_widget->GetOptionLabel(nCurSel));
97 observed_widget->SetValue(swText);
99 observed_widget->GetSelectedIndex(0);
100 observed_widget->SetOptionSelection(nCurSel);
102 if (!observed_widget) {
105 observed_widget->ResetFieldAppearance();
106 if (!observed_widget) {
109 observed_widget->UpdateField();
110 if (!observed_widget || !observed_this) {
113 observed_this->SetChangeMark();
121 if (CPWL_ComboBox* pComboBox = GetPWLComboBox(pPageView)) {
126 fa.sChangeEx = GetSelectExportText();
130 fa.sChangeEx.clear();
136 if (CPWL_ComboBox* pComboBox = GetPWLComboBox(pPageView)) {
142 case CPDF_AAction::kLoseFocus:
143 case CPDF_AAction::kGetFocus:
144 fa.sValue = m_pWidget->GetValue();
156 if (CPWL_ComboBox* pComboBox = GetPWLComboBox(pPageView)) {
169 CPWL_ComboBox* pComboBox = GetPWLComboBox(pPageView);
173 m_State.nIndex = pComboBox->GetSelect();
179 std::tie(m_State.nStart, m_State.nEnd) = pEdit->GetSelection();
180 m_State.sValue = pEdit->GetText();
184 const CPDFSDK_PageView* pPageView) {
185 CPWL_ComboBox* pComboBox = CreateOrUpdatePWLComboBox(pPageView);
189 if (m_State.nIndex >= 0) {
190 pComboBox->SetSelect(m_State.nIndex);
198 pEdit->SetText(m_State.sValue);
199 pEdit->SetSelection(m_State.nStart, m_State.nEnd);
206 if (index < 0 || index >= m_pWidget->CountOptions())
221 if (index < 0 || index >= m_pWidget->CountOptions())
229bool CFFL_ComboBox::IsFieldFull(
const CPDFSDK_PageView* pPageView) {
230 CPWL_ComboBox* pComboBox = GetPWLComboBox(pPageView);
234 CPWL_Edit* pEdit = pComboBox->GetEdit();
235 return pEdit && pEdit->IsTextFull();
242 m_pFormFiller->OnSetFieldInputFocus(pEdit->GetText());
245WideString CFFL_ComboBox::GetSelectExportText() {
248 return m_pWidget->GetSelectExportText(nExport);
251CPWL_ComboBox* CFFL_ComboBox::GetPWLComboBox(
252 const CPDFSDK_PageView* pPageView)
const {
253 return static_cast<CPWL_ComboBox*>(
GetPWLWindow(pPageView));
256CPWL_ComboBox* CFFL_ComboBox::CreateOrUpdatePWLComboBox(
257 const CPDFSDK_PageView* pPageView) {
bool OnChar(CPDFSDK_Widget *pWidget, uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags) override
void SavePWLWindowState(const CPDFSDK_PageView *pPageView) override
void SaveData(const CPDFSDK_PageView *pPageView) override
std::unique_ptr< CPWL_Wnd > NewPWLWindow(const CPWL_Wnd::CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData) override
void RecreatePWLWindowFromSavedState(const CPDFSDK_PageView *pPageView) override
void GetActionData(const CPDFSDK_PageView *pPageView, CPDF_AAction::AActionType type, CFFL_FieldAction &fa) override
bool IsDataChanged(const CPDFSDK_PageView *pPageView) override
~CFFL_ComboBox() override
CPWL_Wnd::CreateParams GetCreateParam() override
CFFL_ComboBox(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
void SetActionData(const CPDFSDK_PageView *pPageView, CPDF_AAction::AActionType type, const CFFL_FieldAction &fa) override
bool IsIndexSelected(int index) override
bool SetIndexSelected(int index, bool selected) override
void OnSetFocusForEdit(CPWL_Edit *pEdit) override
void SetFormField(CFFL_FormField *pFormField)
CPDF_BAFontMap * GetOrCreateFontMap()
CFFL_TextObject(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
void SetSelect(int32_t nItemIndex)
int32_t GetSelect() const
WideString GetText() override
CPWL_Edit * GetEdit() const
WideString GetText() override
void SetCharSet(FX_Charset nCharSet)
void SetSelection(int32_t nStartChar, int32_t nEndChar)
std::pair< int32_t, int32_t > GetSelection() const
void ReplaceSelection(const WideString &text) override
#define PCBS_ALLOWCUSTOMTEXT
fxcrt::WideString WideString