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

Side by Side Diff: fpdfsdk/src/formfiller/FFL_CheckBox.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_CBA_Fontmap.cpp ('k') | fpdfsdk/src/formfiller/FFL_ComboBox.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_CheckBox.h" 7 #include "fpdfsdk/include/formfiller/FFL_CheckBox.h"
8 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" 8 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
9 #include "fpdfsdk/include/formfiller/FormFiller.h" 9 #include "fpdfsdk/include/formfiller/FormFiller.h"
10 10
11 /* ------------------------------- CFFL_CheckBox ------------------------------- 11 /* ------------------------------- CFFL_CheckBox -------------------------------
12 */ 12 */
13 13
14 CFFL_CheckBox::CFFL_CheckBox(CPDFDoc_Environment* pApp, CPDFSDK_Widget* pWidget) 14 CFFL_CheckBox::CFFL_CheckBox(CPDFDoc_Environment* pApp, CPDFSDK_Widget* pWidget)
15 : CFFL_Button(pApp, pWidget) {} 15 : CFFL_Button(pApp, pWidget) {}
16 16
17 CFFL_CheckBox::~CFFL_CheckBox() {} 17 CFFL_CheckBox::~CFFL_CheckBox() {}
18 18
19 CPWL_Wnd* CFFL_CheckBox::NewPDFWindow(const PWL_CREATEPARAM& cp, 19 CPWL_Wnd* CFFL_CheckBox::NewPDFWindow(const PWL_CREATEPARAM& cp,
20 CPDFSDK_PageView* pPageView) { 20 CPDFSDK_PageView* pPageView) {
21 CPWL_CheckBox* pWnd = new CPWL_CheckBox(); 21 CPWL_CheckBox* pWnd = new CPWL_CheckBox();
22 pWnd->Create(cp); 22 pWnd->Create(cp);
23
24 ASSERT(m_pWidget != NULL);
25 pWnd->SetCheck(m_pWidget->IsChecked()); 23 pWnd->SetCheck(m_pWidget->IsChecked());
26
27 return pWnd; 24 return pWnd;
28 } 25 }
29 26
30 FX_BOOL CFFL_CheckBox::OnKeyDown(CPDFSDK_Annot* pAnnot, 27 FX_BOOL CFFL_CheckBox::OnKeyDown(CPDFSDK_Annot* pAnnot,
31 FX_UINT nKeyCode, 28 FX_UINT nKeyCode,
32 FX_UINT nFlags) { 29 FX_UINT nFlags) {
33 switch (nKeyCode) { 30 switch (nKeyCode) {
34 case FWL_VKEY_Return: 31 case FWL_VKEY_Return:
35 case FWL_VKEY_Space: 32 case FWL_VKEY_Space:
36 return TRUE; 33 return TRUE;
37 default: 34 default:
38 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags); 35 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags);
39 } 36 }
40 } 37 }
41 FX_BOOL CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot, 38 FX_BOOL CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot,
42 FX_UINT nChar, 39 FX_UINT nChar,
43 FX_UINT nFlags) { 40 FX_UINT nFlags) {
44 switch (nChar) { 41 switch (nChar) {
45 case FWL_VKEY_Return: 42 case FWL_VKEY_Return:
46 case FWL_VKEY_Space: { 43 case FWL_VKEY_Space: {
47 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); 44 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
48 ASSERT(pIFormFiller != NULL); 45 ASSERT(pIFormFiller);
49 46
50 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 47 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
51 ASSERT(pPageView != NULL); 48 ASSERT(pPageView);
52 49
53 FX_BOOL bReset = FALSE; 50 FX_BOOL bReset = FALSE;
54 FX_BOOL bExit = FALSE; 51 FX_BOOL bExit = FALSE;
55 52
56 pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags); 53 pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags);
57 54
58 if (bReset) 55 if (bReset)
59 return TRUE; 56 return TRUE;
60 if (bExit) 57 if (bExit)
61 return TRUE; 58 return TRUE;
(...skipping 25 matching lines...) Expand all
87 } 84 }
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_CheckBox::IsDataChanged(CPDFSDK_PageView* pPageView) { 93 FX_BOOL CFFL_CheckBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
97 ASSERT(m_pWidget != NULL); 94 CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE);
98 95 return pWnd && pWnd->IsChecked() != m_pWidget->IsChecked();
99 if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE)) {
100 return pWnd->IsChecked() != m_pWidget->IsChecked();
101 }
102
103 return FALSE;
104 } 96 }
105 97
106 void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) { 98 void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) {
107 ASSERT(m_pWidget != NULL);
108
109 if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE)) { 99 if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE)) {
110 FX_BOOL bNewChecked = pWnd->IsChecked(); 100 FX_BOOL bNewChecked = pWnd->IsChecked();
111 101
112 if (bNewChecked) { 102 if (bNewChecked) {
113 CPDF_FormField* pField = m_pWidget->GetFormField(); 103 CPDF_FormField* pField = m_pWidget->GetFormField();
114 ASSERT(pField != NULL); 104 ASSERT(pField != NULL);
115 105
116 for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) { 106 for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
117 if (CPDF_FormControl* pCtrl = pField->GetControl(i)) { 107 if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
118 if (pCtrl->IsChecked()) { 108 if (pCtrl->IsChecked()) {
119 break; 109 break;
120 } 110 }
121 } 111 }
122 } 112 }
123 } 113 }
124 114
125 m_pWidget->SetCheck(bNewChecked, FALSE); 115 m_pWidget->SetCheck(bNewChecked, FALSE);
126 m_pWidget->UpdateField(); 116 m_pWidget->UpdateField();
127 SetChangeMark(); 117 SetChangeMark();
128 } 118 }
129 } 119 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp ('k') | fpdfsdk/src/formfiller/FFL_ComboBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698