diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-08-16 20:53:58 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-16 20:53:58 +0000 |
commit | b2e6b4c44a38ea2ca9e021df31cd27eb67a45e35 (patch) | |
tree | 8e9392c73c3905d38d9e9e636adf8df9c7af072e /fpdfsdk | |
parent | aa987a9a895d42749c0f5e4092618fe7ded6667e (diff) | |
download | pdfium-b2e6b4c44a38ea2ca9e021df31cd27eb67a45e35.tar.xz |
Replace optional bool bNotify with enum type.
Adds clarity to the call sites.
Change-Id: Id4deed9adda2ad79f0847d618792429044d4f7d6
Reviewed-on: https://pdfium-review.googlesource.com/40351
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.cpp | 25 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.h | 8 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_checkbox.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_combobox.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_listbox.cpp | 15 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_radiobutton.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_textfield.cpp | 7 |
8 files changed, 47 insertions, 42 deletions
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index b9256aac35..0e44268b39 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -327,7 +327,7 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { Optional<IJS_Runtime::JS_Error> err = pContext->RunScript(csJS); if (!err && bRC && sValue.Compare(sOldValue) != 0) - pField->SetValue(sValue, true); + pField->SetValue(sValue, NotificationOption::kNotify); } } @@ -557,19 +557,17 @@ ByteString CPDFSDK_InterForm::ExportFormToFDFTextBuf() { void CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { ASSERT(action.GetDict()); - const CPDF_Dictionary* pActionDict = action.GetDict(); if (!pActionDict->KeyExist("Fields")) { - m_pInterForm->ResetForm(true); + m_pInterForm->ResetForm(NotificationOption::kNotify); return; } - CPDF_ActionFields af(&action); uint32_t dwFlags = action.GetFlags(); - std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields(); std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); - m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true); + m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), + NotificationOption::kNotify); } std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects( diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index f9fdef829b..8bd1f10177 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -526,44 +526,45 @@ int CPDFSDK_Widget::GetMaxLen() const { return pFormField->GetMaxLen(); } -void CPDFSDK_Widget::SetCheck(bool bChecked, bool bNotify) { +void CPDFSDK_Widget::SetCheck(bool bChecked, NotificationOption notify) { CPDF_FormControl* pFormCtrl = GetFormControl(); CPDF_FormField* pFormField = pFormCtrl->GetField(); pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, - bNotify); + notify); #ifdef PDF_ENABLE_XFA if (!IsWidgetAppearanceValid(CPDF_Annot::Normal)) ResetAppearance(true); - if (!bNotify) + if (notify == NotificationOption::kDoNotNotify) Synchronize(true); #endif // PDF_ENABLE_XFA } -void CPDFSDK_Widget::SetValue(const WideString& sValue, bool bNotify) { +void CPDFSDK_Widget::SetValue(const WideString& sValue, + NotificationOption notify) { CPDF_FormField* pFormField = GetFormField(); - pFormField->SetValue(sValue, bNotify); + pFormField->SetValue(sValue, notify); #ifdef PDF_ENABLE_XFA - if (!bNotify) + if (notify == NotificationOption::kDoNotNotify) Synchronize(true); #endif // PDF_ENABLE_XFA } void CPDFSDK_Widget::SetOptionSelection(int index, bool bSelected, - bool bNotify) { + NotificationOption notify) { CPDF_FormField* pFormField = GetFormField(); - pFormField->SetItemSelection(index, bSelected, bNotify); + pFormField->SetItemSelection(index, bSelected, notify); #ifdef PDF_ENABLE_XFA - if (!bNotify) + if (notify == NotificationOption::kDoNotNotify) Synchronize(true); #endif // PDF_ENABLE_XFA } -void CPDFSDK_Widget::ClearSelection(bool bNotify) { +void CPDFSDK_Widget::ClearSelection(NotificationOption notify) { CPDF_FormField* pFormField = GetFormField(); - pFormField->ClearSelection(bNotify); + pFormField->ClearSelection(notify); #ifdef PDF_ENABLE_XFA - if (!bNotify) + if (notify == NotificationOption::kDoNotNotify) Synchronize(true); #endif // PDF_ENABLE_XFA } diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h index 1349981293..f3bdc54944 100644 --- a/fpdfsdk/cpdfsdk_widget.h +++ b/fpdfsdk/cpdfsdk_widget.h @@ -81,10 +81,10 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { int GetMaxLen() const; WideString GetAlternateName() const; - void SetCheck(bool bChecked, bool bNotify); - void SetValue(const WideString& sValue, bool bNotify); - void SetOptionSelection(int index, bool bSelected, bool bNotify); - void ClearSelection(bool bNotify); + void SetCheck(bool bChecked, NotificationOption notify); + void SetValue(const WideString& sValue, NotificationOption notify); + void SetOptionSelection(int index, bool bSelected, NotificationOption notify); + void ClearSelection(NotificationOption notify); void SetTopVisibleIndex(int index); #ifdef PDF_ENABLE_XFA diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp index 57119c5c31..4308c1a1a5 100644 --- a/fpdfsdk/formfiller/cffl_checkbox.cpp +++ b/fpdfsdk/formfiller/cffl_checkbox.cpp @@ -113,13 +113,14 @@ void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) { } CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get()); CFFL_CheckBox::ObservedPtr observed_this(this); - - m_pWidget->SetCheck(bNewChecked, false); + m_pWidget->SetCheck(bNewChecked, NotificationOption::kDoNotNotify); if (!observed_widget) return; + m_pWidget->UpdateField(); if (!observed_widget || !observed_this) return; + SetChangeMark(); } diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp index 8aa656b856..e0f0f3fbe5 100644 --- a/fpdfsdk/formfiller/cffl_combobox.cpp +++ b/fpdfsdk/formfiller/cffl_combobox.cpp @@ -96,27 +96,27 @@ void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) { WideString swText = pWnd->GetText(); int32_t nCurSel = pWnd->GetSelect(); - bool bSetValue = false; - if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) bSetValue = (nCurSel < 0) || (swText != m_pWidget->GetOptionLabel(nCurSel)); if (bSetValue) { - m_pWidget->SetValue(swText, false); + m_pWidget->SetValue(swText, NotificationOption::kDoNotNotify); } else { m_pWidget->GetSelectedIndex(0); - m_pWidget->SetOptionSelection(nCurSel, true, false); + m_pWidget->SetOptionSelection(nCurSel, true, + NotificationOption::kDoNotNotify); } CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get()); CFFL_ComboBox::ObservedPtr observed_this(this); - m_pWidget->ResetFieldAppearance(true); if (!observed_widget) return; + m_pWidget->UpdateField(); if (!observed_widget || !observed_this) return; + SetChangeMark(); m_pWidget->GetPDFPage(); } diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp index bf24e116e5..c05400d13c 100644 --- a/fpdfsdk/formfiller/cffl_listbox.cpp +++ b/fpdfsdk/formfiller/cffl_listbox.cpp @@ -108,27 +108,32 @@ void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView) { return; int32_t nNewTopIndex = pListBox->GetTopVisibleIndex(); - m_pWidget->ClearSelection(false); + m_pWidget->ClearSelection(NotificationOption::kDoNotNotify); if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) { for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) { - if (pListBox->IsItemSelected(i)) - m_pWidget->SetOptionSelection(i, true, false); + if (pListBox->IsItemSelected(i)) { + m_pWidget->SetOptionSelection(i, true, + NotificationOption::kDoNotNotify); + } } } else { - m_pWidget->SetOptionSelection(pListBox->GetCurSel(), true, false); + m_pWidget->SetOptionSelection(pListBox->GetCurSel(), true, + NotificationOption::kDoNotNotify); } CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get()); CFFL_ListBox::ObservedPtr observed_this(this); - m_pWidget->SetTopVisibleIndex(nNewTopIndex); if (!observed_widget) return; + m_pWidget->ResetFieldAppearance(true); if (!observed_widget) return; + m_pWidget->UpdateField(); if (!observed_widget || !observed_this) return; + SetChangeMark(); } diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp index 73ac44de46..8105b0cdea 100644 --- a/fpdfsdk/formfiller/cffl_radiobutton.cpp +++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp @@ -91,26 +91,25 @@ void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) { return; bool bNewChecked = pWnd->IsChecked(); - if (bNewChecked) { CPDF_FormField* pField = m_pWidget->GetFormField(); for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) { if (CPDF_FormControl* pCtrl = pField->GetControl(i)) { - if (pCtrl->IsChecked()) { + if (pCtrl->IsChecked()) break; - } } } } CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get()); CFFL_RadioButton::ObservedPtr observed_this(this); - - m_pWidget->SetCheck(bNewChecked, false); + m_pWidget->SetCheck(bNewChecked, NotificationOption::kDoNotNotify); if (!observed_widget) return; + m_pWidget->UpdateField(); if (!observed_widget || !observed_this) return; + SetChangeMark(); } diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index da011e40ab..7293d426bc 100644 --- a/fpdfsdk/formfiller/cffl_textfield.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp @@ -138,19 +138,20 @@ void CFFL_TextField::SaveData(CPDFSDK_PageView* pPageView) { WideString sOldValue = m_pWidget->GetValue(); WideString sNewValue = pWnd->GetText(); - CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get()); CFFL_TextField::ObservedPtr observed_this(this); - - m_pWidget->SetValue(sNewValue, false); + m_pWidget->SetValue(sNewValue, NotificationOption::kDoNotNotify); if (!observed_widget) return; + m_pWidget->ResetFieldAppearance(true); if (!observed_widget) return; + m_pWidget->UpdateField(); if (!observed_widget || !observed_this) return; + SetChangeMark(); } |