diff options
author | Lei Zhang <thestig@chromium.org> | 2017-06-15 12:37:33 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-15 20:42:01 +0000 |
commit | 77e3fc5cebfb19aed09f920536200e017cff9a0b (patch) | |
tree | 64700810faf138812cdcf7573a9caff08fb0411b /fpdfsdk/formfiller/cffl_radiobutton.cpp | |
parent | b7384b5b997975c36bb37d25c63e2c900eca41f9 (diff) | |
download | pdfium-77e3fc5cebfb19aed09f920536200e017cff9a0b.tar.xz |
Change some CFFL classes to use early returns.chromium/3132
Also switch C-style casts to the appropriate C++ casts, and add helper
functions in some cases.
Change-Id: I73f1ab36c6c89ced9d2b7b98393805142661dcac
Reviewed-on: https://pdfium-review.googlesource.com/6650
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/formfiller/cffl_radiobutton.cpp')
-rw-r--r-- | fpdfsdk/formfiller/cffl_radiobutton.cpp | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp index c6ce432d0c..9ffdf494ca 100644 --- a/fpdfsdk/formfiller/cffl_radiobutton.cpp +++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp @@ -57,8 +57,8 @@ bool CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot, return true; CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); - if (CPWL_RadioButton* pWnd = - (CPWL_RadioButton*)GetPDFWindow(pPageView, true)) + CPWL_RadioButton* pWnd = GetRadioButton(pPageView, true); + if (pWnd) pWnd->SetCheck(true); return CommitData(pPageView, nFlags); } @@ -73,44 +73,45 @@ bool CFFL_RadioButton::OnLButtonUp(CPDFSDK_PageView* pPageView, const CFX_PointF& point) { CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point); - if (IsValid()) { - if (CPWL_RadioButton* pWnd = - (CPWL_RadioButton*)GetPDFWindow(pPageView, true)) - pWnd->SetCheck(true); + if (!IsValid()) + return true; - return CommitData(pPageView, nFlags); - } + CPWL_RadioButton* pWnd = GetRadioButton(pPageView, true); + if (pWnd) + pWnd->SetCheck(true); - return true; + return CommitData(pPageView, nFlags); } bool CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView) { - if (CPWL_RadioButton* pWnd = - (CPWL_RadioButton*)GetPDFWindow(pPageView, false)) { - return pWnd->IsChecked() != m_pWidget->IsChecked(); - } - - return false; + CPWL_RadioButton* pWnd = GetRadioButton(pPageView, false); + return pWnd && pWnd->IsChecked() != m_pWidget->IsChecked(); } void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) { - if (CPWL_RadioButton* pWnd = - (CPWL_RadioButton*)GetPDFWindow(pPageView, false)) { - 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()) { - break; - } + CPWL_RadioButton* pWnd = GetRadioButton(pPageView, false); + if (!pWnd) + 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()) { + break; } } } - - m_pWidget->SetCheck(bNewChecked, false); - m_pWidget->UpdateField(); - SetChangeMark(); } + + m_pWidget->SetCheck(bNewChecked, false); + m_pWidget->UpdateField(); + SetChangeMark(); +} + +CPWL_RadioButton* CFFL_RadioButton::GetRadioButton(CPDFSDK_PageView* pPageView, + bool bNew) { + return static_cast<CPWL_RadioButton*>(GetPDFWindow(pPageView, bNew)); } |