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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 months 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_CheckBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_FormFiller.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 "../../include/formfiller/FormFiller.h" 7 #include "../../include/formfiller/FormFiller.h"
8 #include "../../include/formfiller/FFL_FormFiller.h" 8 #include "../../include/formfiller/FFL_FormFiller.h"
9 #include "../../include/formfiller/FFL_IFormFiller.h" 9 #include "../../include/formfiller/FFL_IFormFiller.h"
10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" 10 #include "../../include/formfiller/FFL_CBA_Fontmap.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 { 71 {
72 pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str()); 72 pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str());
73 } 73 }
74 74
75 pWnd->SetSelect(nCurSel); 75 pWnd->SetSelect(nCurSel);
76 pWnd->SetText(swText.c_str()); 76 pWnd->SetText(swText.c_str());
77 return pWnd; 77 return pWnd;
78 } 78 }
79 79
80 80
81 FX_BOOL»CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFla gs) 81 bool» CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFla gs)
82 { 82 {
83 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); 83 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
84 } 84 }
85 85
86 FX_BOOL»CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) 86 bool» CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView)
87 { 87 {
88 » if (CPWL_ComboBox * pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE )) 88 » if (CPWL_ComboBox * pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, false ))
89 { 89 {
90 int32_t nCurSel = pWnd->GetSelect(); 90 int32_t nCurSel = pWnd->GetSelect();
91 91
92 ASSERT(m_pWidget != NULL); 92 ASSERT(m_pWidget != NULL);
93 93
94 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) 94 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
95 { 95 {
96 if (nCurSel >= 0) 96 if (nCurSel >= 0)
97 { 97 {
98 return nCurSel != m_pWidget->GetSelectedIndex(0) ; 98 return nCurSel != m_pWidget->GetSelectedIndex(0) ;
99 } 99 }
100 else 100 else
101 { 101 {
102 return pWnd->GetText() != m_pWidget->GetValue(); 102 return pWnd->GetText() != m_pWidget->GetValue();
103 } 103 }
104 } 104 }
105 else 105 else
106 { 106 {
107 return nCurSel != m_pWidget->GetSelectedIndex(0); 107 return nCurSel != m_pWidget->GetSelectedIndex(0);
108 } 108 }
109 } 109 }
110 110
111 » return FALSE; 111 » return false;
112 } 112 }
113 113
114 void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView) 114 void CFFL_ComboBox::SaveData(CPDFSDK_PageView* pPageView)
115 { 115 {
116 ASSERT(m_pWidget != NULL); 116 ASSERT(m_pWidget != NULL);
117 117
118 » if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE) ) 118 » if (CPWL_ComboBox* pWnd = (CPWL_ComboBox*)GetPDFWindow(pPageView, false) )
119 { 119 {
120 CFX_WideString swText = pWnd->GetText(); 120 CFX_WideString swText = pWnd->GetText();
121 int32_t nCurSel = pWnd->GetSelect(); 121 int32_t nCurSel = pWnd->GetSelect();
122 122
123 //mantis:0004157 123 //mantis:0004157
124 » » FX_BOOL bSetValue = TRUE; 124 » » bool bSetValue = true;
125 125
126 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) 126 if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
127 { 127 {
128 if (nCurSel >= 0) 128 if (nCurSel >= 0)
129 { 129 {
130 if (swText != m_pWidget->GetOptionLabel(nCurSel) ) 130 if (swText != m_pWidget->GetOptionLabel(nCurSel) )
131 » » » » » bSetValue = TRUE; 131 » » » » » bSetValue = true;
132 else 132 else
133 » » » » » bSetValue = FALSE; 133 » » » » » bSetValue = false;
134 } 134 }
135 else 135 else
136 » » » » bSetValue = TRUE; 136 » » » » bSetValue = true;
137 } 137 }
138 else 138 else
139 » » » bSetValue = FALSE; 139 » » » bSetValue = false;
140 140
141 CFX_WideString sOldValue; 141 CFX_WideString sOldValue;
142 142
143 143
144 if (bSetValue) 144 if (bSetValue)
145 { 145 {
146 sOldValue = m_pWidget->GetValue(); 146 sOldValue = m_pWidget->GetValue();
147 » » » m_pWidget->SetValue(swText, FALSE); 147 » » » m_pWidget->SetValue(swText, false);
148 } 148 }
149 else 149 else
150 { 150 {
151 m_pWidget->GetSelectedIndex(0); 151 m_pWidget->GetSelectedIndex(0);
152 » » » m_pWidget->SetOptionSelection(nCurSel, TRUE, FALSE); 152 » » » m_pWidget->SetOptionSelection(nCurSel, true, false);
153 } 153 }
154 154
155 » » m_pWidget->ResetFieldAppearance(TRUE); 155 » » m_pWidget->ResetFieldAppearance(true);
156 m_pWidget->UpdateField(); 156 m_pWidget->UpdateField();
157 SetChangeMark(); 157 SetChangeMark();
158 158
159 m_pWidget->GetPDFPage(); 159 m_pWidget->GetPDFPage();
160 160
161 161
162 } 162 }
163 } 163 }
164 164
165 void CFFL_ComboBox::GetActionData( CPDFSDK_PageView* pPageView, CPDF_AAction::A ActionType type, PDFSDK_FieldAction& fa) 165 void CFFL_ComboBox::GetActionData( CPDFSDK_PageView* pPageView, CPDF_AAction::A ActionType type, PDFSDK_FieldAction& fa)
166 { 166 {
167 switch (type) 167 switch (type)
168 { 168 {
169 case CPDF_AAction::KeyStroke: 169 case CPDF_AAction::KeyStroke:
170 » » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, FALSE)) 170 » » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, false))
171 { 171 {
172 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 172 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
173 { 173 {
174 fa.bFieldFull = pEdit->IsTextFull(); 174 fa.bFieldFull = pEdit->IsTextFull();
175 int nSelStart = 0; 175 int nSelStart = 0;
176 int nSelEnd = 0; 176 int nSelEnd = 0;
177 pEdit->GetSel(nSelStart, nSelEnd); 177 pEdit->GetSel(nSelStart, nSelEnd);
178 fa.nSelEnd = nSelEnd; 178 fa.nSelEnd = nSelEnd;
179 fa.nSelStart = nSelStart; 179 fa.nSelStart = nSelStart;
180 fa.sValue = pEdit->GetText(); 180 fa.sValue = pEdit->GetText();
181 fa.sChangeEx = GetSelectExportText(); 181 fa.sChangeEx = GetSelectExportText();
182 182
183 if (fa.bFieldFull) 183 if (fa.bFieldFull)
184 { 184 {
185 fa.sChange = L""; 185 fa.sChange = L"";
186 fa.sChangeEx = L""; 186 fa.sChangeEx = L"";
187 } 187 }
188 } 188 }
189 } 189 }
190 break; 190 break;
191 case CPDF_AAction::Validate: 191 case CPDF_AAction::Validate:
192 » » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, FALSE)) 192 » » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, false))
193 { 193 {
194 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 194 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
195 { 195 {
196 fa.sValue = pEdit->GetText(); 196 fa.sValue = pEdit->GetText();
197 } 197 }
198 } 198 }
199 break; 199 break;
200 case CPDF_AAction::LoseFocus: 200 case CPDF_AAction::LoseFocus:
201 case CPDF_AAction::GetFocus: 201 case CPDF_AAction::GetFocus:
202 ASSERT(m_pWidget != NULL); 202 ASSERT(m_pWidget != NULL);
203 fa.sValue = m_pWidget->GetValue(); 203 fa.sValue = m_pWidget->GetValue();
204 break; 204 break;
205 default: 205 default:
206 break; 206 break;
207 } 207 }
208 } 208 }
209 209
210 210
211 211
212 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAc tionType type, 212 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAc tionType type,
213 const PD FSDK_FieldAction& fa) 213 const PD FSDK_FieldAction& fa)
214 { 214 {
215 switch (type) 215 switch (type)
216 { 216 {
217 case CPDF_AAction::KeyStroke: 217 case CPDF_AAction::KeyStroke:
218 » » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, FALSE)) 218 » » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPag eView, false))
219 { 219 {
220 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 220 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
221 { 221 {
222 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); 222 pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
223 pEdit->ReplaceSel(fa.sChange.c_str()); 223 pEdit->ReplaceSel(fa.sChange.c_str());
224 } 224 }
225 } 225 }
226 break; 226 break;
227 default: 227 default:
228 break; 228 break;
229 } 229 }
230 } 230 }
231 231
232 FX_BOOL»CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, 232 bool» CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
233 const PD FSDK_FieldAction& faNew) 233 const PD FSDK_FieldAction& faNew)
234 { 234 {
235 switch (type) 235 switch (type)
236 { 236 {
237 case CPDF_AAction::KeyStroke: 237 case CPDF_AAction::KeyStroke:
238 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart || 238 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || faOld.nSelStart != faNew.nSelStart ||
239 faOld.sChange != faNew.sChange; 239 faOld.sChange != faNew.sChange;
240 default: 240 default:
241 break; 241 break;
242 } 242 }
243 243
244 » return FALSE; 244 » return false;
245 } 245 }
246 246
247 void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView) 247 void CFFL_ComboBox::SaveState(CPDFSDK_PageView* pPageView)
248 { 248 {
249 ASSERT(pPageView != NULL); 249 ASSERT(pPageView != NULL);
250 250
251 » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, F ALSE)) 251 » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, f alse))
252 { 252 {
253 m_State.nIndex = pComboBox->GetSelect(); 253 m_State.nIndex = pComboBox->GetSelect();
254 254
255 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 255 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
256 { 256 {
257 pEdit->GetSel(m_State.nStart, m_State.nEnd); 257 pEdit->GetSel(m_State.nStart, m_State.nEnd);
258 m_State.sValue = pEdit->GetText(); 258 m_State.sValue = pEdit->GetText();
259 } 259 }
260 } 260 }
261 } 261 }
262 262
263 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) 263 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView)
264 { 264 {
265 ASSERT(pPageView != NULL); 265 ASSERT(pPageView != NULL);
266 266
267 » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, T RUE)) 267 » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, t rue))
268 { 268 {
269 if (m_State.nIndex >= 0) 269 if (m_State.nIndex >= 0)
270 pComboBox->SetSelect(m_State.nIndex); 270 pComboBox->SetSelect(m_State.nIndex);
271 else 271 else
272 { 272 {
273 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox) 273 if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
274 { 274 {
275 pEdit->SetText(m_State.sValue.c_str()); 275 pEdit->SetText(m_State.sValue.c_str());
276 pEdit->SetSel(m_State.nStart, m_State.nEnd); 276 pEdit->SetSel(m_State.nStart, m_State.nEnd);
277 } 277 }
278 } 278 }
279 } 279 }
280 } 280 }
281 281
282 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRe storeValue) 282 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, bool bResto reValue)
283 { 283 {
284 if (bRestoreValue) 284 if (bRestoreValue)
285 SaveState(pPageView); 285 SaveState(pPageView);
286 286
287 DestroyPDFWindow(pPageView); 287 DestroyPDFWindow(pPageView);
288 288
289 CPWL_Wnd* pRet = NULL; 289 CPWL_Wnd* pRet = NULL;
290 290
291 if (bRestoreValue) 291 if (bRestoreValue)
292 { 292 {
293 RestoreState(pPageView); 293 RestoreState(pPageView);
294 » » pRet = GetPDFWindow(pPageView, FALSE); 294 » » pRet = GetPDFWindow(pPageView, false);
295 } 295 }
296 else 296 else
297 » » pRet = GetPDFWindow(pPageView, TRUE); 297 » » pRet = GetPDFWindow(pPageView, true);
298 298
299 m_pWidget->UpdateField(); 299 m_pWidget->UpdateField();
300 300
301 return pRet; 301 return pRet;
302 } 302 }
303 303
304 void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag) 304 void CFFL_ComboBox::OnKeyStroke(bool bKeyDown, FX_UINT nFlag)
305 { 305 {
306 ASSERT(m_pWidget != NULL); 306 ASSERT(m_pWidget != NULL);
307 307
308 int nFlags = m_pWidget->GetFieldFlags(); 308 int nFlags = m_pWidget->GetFieldFlags();
309 309
310 if (nFlags & FIELDFLAG_COMMITONSELCHANGE) 310 if (nFlags & FIELDFLAG_COMMITONSELCHANGE)
311 { 311 {
312 if (m_bValid) 312 if (m_bValid)
313 { 313 {
314 CPDFSDK_PageView* pPageView = GetCurPageView(); 314 CPDFSDK_PageView* pPageView = GetCurPageView();
315 ASSERT(pPageView != NULL); 315 ASSERT(pPageView != NULL);
316 316
317 if (CommitData(pPageView, nFlag)) 317 if (CommitData(pPageView, nFlag))
318 { 318 {
319 DestroyPDFWindow(pPageView); 319 DestroyPDFWindow(pPageView);
320 » » » » m_bValid = FALSE; 320 » » » » m_bValid = false;
321 } 321 }
322 } 322 }
323 } 323 }
324 } 324 }
325 325
326 void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) 326 void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd)
327 { 327 {
328 ASSERT(m_pApp != NULL); 328 ASSERT(m_pApp != NULL);
329 329
330 ASSERT(pWnd != NULL); 330 ASSERT(pWnd != NULL);
331 331
332 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) 332 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT)
333 { 333 {
334 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; 334 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
335 pEdit->SetCharSet(134); 335 pEdit->SetCharSet(134);
336 pEdit->SetCodePage(936); 336 pEdit->SetCodePage(936);
337 337
338 pEdit->SetReadyToInput(); 338 pEdit->SetReadyToInput();
339 CFX_WideString wsText = pEdit->GetText(); 339 CFX_WideString wsText = pEdit->GetText();
340 int nCharacters = wsText.GetLength(); 340 int nCharacters = wsText.GetLength();
341 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); 341 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
342 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); 342 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
343 » » m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuf fer, nCharacters, TRUE); 343 » » m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuf fer, nCharacters, true);
344 344
345 pEdit->SetEditNotify(this); 345 pEdit->SetEditNotify(this);
346 } 346 }
347 } 347 }
348 348
349 void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd) 349 void CFFL_ComboBox::OnKillFocus(CPWL_Wnd* pWnd)
350 { 350 {
351 ASSERT(m_pApp != NULL); 351 ASSERT(m_pApp != NULL);
352 } 352 }
353 353
354 FX_BOOL»CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument) 354 bool» CFFL_ComboBox::CanCopy(CPDFSDK_Document* pDocument)
355 { 355 {
356 ASSERT(pDocument != NULL); 356 ASSERT(pDocument != NULL);
357 357
358 » return FALSE; 358 » return false;
359 } 359 }
360 360
361 FX_BOOL CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument) 361 bool CFFL_ComboBox::CanCut(CPDFSDK_Document* pDocument)
362 { 362 {
363 ASSERT(pDocument != NULL); 363 ASSERT(pDocument != NULL);
364 364
365 » return FALSE; 365 » return false;
366 } 366 }
367 367
368 FX_BOOL»CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument) 368 bool» CFFL_ComboBox::CanPaste(CPDFSDK_Document* pDocument)
369 { 369 {
370 ASSERT(pDocument != NULL); 370 ASSERT(pDocument != NULL);
371 371
372 » return FALSE; 372 » return false;
373 } 373 }
374 374
375 void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit) 375 void CFFL_ComboBox::OnAddUndo(CPWL_Edit* pEdit)
376 { 376 {
377 ASSERT(pEdit != NULL); 377 ASSERT(pEdit != NULL);
378 } 378 }
379 379
380 CFX_WideString CFFL_ComboBox::GetSelectExportText() 380 CFX_WideString CFFL_ComboBox::GetSelectExportText()
381 { 381 {
382 CFX_WideString swRet; 382 CFX_WideString swRet;
383 383
384 int nExport = -1; 384 int nExport = -1;
385 CPDFSDK_PageView *pPageView = GetCurPageView(); 385 CPDFSDK_PageView *pPageView = GetCurPageView();
386 » if (CPWL_ComboBox * pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE)) 386 » if (CPWL_ComboBox * pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, false))
387 { 387 {
388 nExport = pComboBox->GetSelect(); 388 nExport = pComboBox->GetSelect();
389 } 389 }
390 390
391 if (nExport >= 0) 391 if (nExport >= 0)
392 { 392 {
393 if (CPDF_FormField * pFormField = m_pWidget->GetFormField()) 393 if (CPDF_FormField * pFormField = m_pWidget->GetFormField())
394 { 394 {
395 swRet = pFormField->GetOptionValue(nExport); 395 swRet = pFormField->GetOptionValue(nExport);
396 if (swRet.IsEmpty()) 396 if (swRet.IsEmpty())
397 swRet = pFormField->GetOptionLabel(nExport); 397 swRet = pFormField->GetOptionLabel(nExport);
398 } 398 }
399 } 399 }
400 400
401 return swRet; 401 return swRet;
402 } 402 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_CheckBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_FormFiller.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698