Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: fpdfsdk/src/formfiller/FFL_RadioButton.cpp

Issue 1512763013: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_ListBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_TextField.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" 7 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
8 #include "fpdfsdk/include/formfiller/FFL_RadioButton.h" 8 #include "fpdfsdk/include/formfiller/FFL_RadioButton.h"
9 #include "fpdfsdk/include/formfiller/FormFiller.h" 9 #include "fpdfsdk/include/formfiller/FormFiller.h"
10 10
11 /* ------------------------------- CFFL_RadioButton 11 /* ------------------------------- CFFL_RadioButton
12 * ------------------------------- */ 12 * ------------------------------- */
13 13
14 CFFL_RadioButton::CFFL_RadioButton(CPDFDoc_Environment* pApp, 14 CFFL_RadioButton::CFFL_RadioButton(CPDFDoc_Environment* pApp,
15 CPDFSDK_Annot* pWidget) 15 CPDFSDK_Annot* pWidget)
16 : CFFL_Button(pApp, pWidget) {} 16 : CFFL_Button(pApp, pWidget) {}
17 17
18 CFFL_RadioButton::~CFFL_RadioButton() {} 18 CFFL_RadioButton::~CFFL_RadioButton() {}
19 19
20 CPWL_Wnd* CFFL_RadioButton::NewPDFWindow(const PWL_CREATEPARAM& cp, 20 CPWL_Wnd* CFFL_RadioButton::NewPDFWindow(const PWL_CREATEPARAM& cp,
21 CPDFSDK_PageView* pPageView) { 21 CPDFSDK_PageView* pPageView) {
22 CPWL_RadioButton* pWnd = new CPWL_RadioButton(); 22 CPWL_RadioButton* pWnd = new CPWL_RadioButton();
23 pWnd->Create(cp); 23 pWnd->Create(cp);
24 24
25 ASSERT(m_pWidget != NULL);
26 pWnd->SetCheck(m_pWidget->IsChecked()); 25 pWnd->SetCheck(m_pWidget->IsChecked());
27 26
28 return pWnd; 27 return pWnd;
29 } 28 }
30 29
31 FX_BOOL CFFL_RadioButton::OnKeyDown(CPDFSDK_Annot* pAnnot, 30 FX_BOOL CFFL_RadioButton::OnKeyDown(CPDFSDK_Annot* pAnnot,
32 FX_UINT nKeyCode, 31 FX_UINT nKeyCode,
33 FX_UINT nFlags) { 32 FX_UINT nFlags) {
34 switch (nKeyCode) { 33 switch (nKeyCode) {
35 case FWL_VKEY_Return: 34 case FWL_VKEY_Return:
36 case FWL_VKEY_Space: 35 case FWL_VKEY_Space:
37 return TRUE; 36 return TRUE;
38 default: 37 default:
39 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags); 38 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags);
40 } 39 }
41 } 40 }
42 41
43 FX_BOOL CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot, 42 FX_BOOL CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot,
44 FX_UINT nChar, 43 FX_UINT nChar,
45 FX_UINT nFlags) { 44 FX_UINT nFlags) {
46 switch (nChar) { 45 switch (nChar) {
47 case FWL_VKEY_Return: 46 case FWL_VKEY_Return:
48 case FWL_VKEY_Space: { 47 case FWL_VKEY_Space: {
49 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); 48 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
50 ASSERT(pIFormFiller != NULL);
51
52 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 49 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
53 ASSERT(pPageView != NULL); 50 ASSERT(pPageView);
54 51
55 FX_BOOL bReset = FALSE; 52 FX_BOOL bReset = FALSE;
56 FX_BOOL bExit = FALSE; 53 FX_BOOL bExit = FALSE;
57 54
58 pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags); 55 pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags);
59 56
60 if (bReset) 57 if (bReset)
61 return TRUE; 58 return TRUE;
62 if (bExit) 59 if (bExit)
63 return TRUE; 60 return TRUE;
(...skipping 23 matching lines...) Expand all
87 pWnd->SetCheck(TRUE); 84 pWnd->SetCheck(TRUE);
88 85
89 if (!CommitData(pPageView, nFlags)) 86 if (!CommitData(pPageView, nFlags))
90 return FALSE; 87 return FALSE;
91 } 88 }
92 89
93 return TRUE; 90 return TRUE;
94 } 91 }
95 92
96 FX_BOOL CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView) { 93 FX_BOOL CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView) {
97 ASSERT(m_pWidget != NULL);
98
99 if (CPWL_RadioButton* pWnd = 94 if (CPWL_RadioButton* pWnd =
100 (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) { 95 (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
101 return pWnd->IsChecked() != m_pWidget->IsChecked(); 96 return pWnd->IsChecked() != m_pWidget->IsChecked();
102 } 97 }
103 98
104 return FALSE; 99 return FALSE;
105 } 100 }
106 101
107 void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) { 102 void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) {
108 ASSERT(m_pWidget != NULL);
109
110 if (CPWL_RadioButton* pWnd = 103 if (CPWL_RadioButton* pWnd =
111 (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) { 104 (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
112 FX_BOOL bNewChecked = pWnd->IsChecked(); 105 FX_BOOL bNewChecked = pWnd->IsChecked();
113 106
114 if (bNewChecked) { 107 if (bNewChecked) {
115 CPDF_FormField* pField = m_pWidget->GetFormField(); 108 CPDF_FormField* pField = m_pWidget->GetFormField();
116 ASSERT(pField != NULL);
117
118 for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) { 109 for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
119 if (CPDF_FormControl* pCtrl = pField->GetControl(i)) { 110 if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
120 if (pCtrl->IsChecked()) { 111 if (pCtrl->IsChecked()) {
121 break; 112 break;
122 } 113 }
123 } 114 }
124 } 115 }
125 } 116 }
126 117
127 m_pWidget->SetCheck(bNewChecked, FALSE); 118 m_pWidget->SetCheck(bNewChecked, FALSE);
128 m_pWidget->UpdateField(); 119 m_pWidget->UpdateField();
129 SetChangeMark(); 120 SetChangeMark();
130 } 121 }
131 } 122 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_ListBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_TextField.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698