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

Side by Side Diff: core/fpdfdoc/cpdf_formfield.cpp

Issue 2625483002: Remove some CFX_ArrayTemplate in fpdfapi and fpdfdoc (Closed)
Patch Set: Created 3 years, 11 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
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 "core/fpdfdoc/cpdf_formfield.h" 7 #include "core/fpdfdoc/cpdf_formfield.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 break; 238 break;
239 } 239 }
240 } 240 }
241 return true; 241 return true;
242 } 242 }
243 243
244 int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) const { 244 int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) const {
245 if (!pControl) 245 if (!pControl)
246 return -1; 246 return -1;
247 247
248 for (int i = 0; i < m_ControlList.GetSize(); i++) { 248 auto it = std::find(m_ControlList.begin(), m_ControlList.end(), pControl);
249 if (m_ControlList.GetAt(i) == pControl) 249 return it != m_ControlList.end() ? it - m_ControlList.begin() : -1;
dsinclair 2017/01/10 14:11:10 What are your thoughts on std::tie? It would be ni
Tom Sepez 2017/01/10 18:06:27 I really like this approach where there ain't no o
250 return i;
251 }
252 return -1;
253 } 250 }
254 251
255 int CPDF_FormField::GetFieldType() const { 252 int CPDF_FormField::GetFieldType() const {
256 switch (m_Type) { 253 switch (m_Type) {
257 case PushButton: 254 case PushButton:
258 return FIELDTYPE_PUSHBUTTON; 255 return FIELDTYPE_PUSHBUTTON;
259 case CheckBox: 256 case CheckBox:
260 return FIELDTYPE_CHECKBOX; 257 return FIELDTYPE_CHECKBOX;
261 case RadioButton: 258 case RadioButton:
262 return FIELDTYPE_RADIOBUTTON; 259 return FIELDTYPE_RADIOBUTTON;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 404 }
408 405
409 bool CPDF_FormField::SetValue(const CFX_WideString& value, bool bNotify) { 406 bool CPDF_FormField::SetValue(const CFX_WideString& value, bool bNotify) {
410 return SetValue(value, false, bNotify); 407 return SetValue(value, false, bNotify);
411 } 408 }
412 409
413 int CPDF_FormField::GetMaxLen() const { 410 int CPDF_FormField::GetMaxLen() const {
414 if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen")) 411 if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen"))
415 return pObj->GetInteger(); 412 return pObj->GetInteger();
416 413
417 for (int i = 0; i < m_ControlList.GetSize(); i++) { 414 for (const CPDF_FormControl* pControl : m_ControlList) {
dsinclair 2017/01/10 14:11:11 auto?
Tom Sepez 2017/01/10 18:06:27 Done.
418 CPDF_FormControl* pControl = m_ControlList.GetAt(i);
419 if (!pControl) 415 if (!pControl)
420 continue; 416 continue;
421
422 CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; 417 CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict;
423 if (pWidgetDict->KeyExist("MaxLen")) 418 if (pWidgetDict->KeyExist("MaxLen"))
424 return pWidgetDict->GetIntegerFor("MaxLen"); 419 return pWidgetDict->GetIntegerFor("MaxLen");
425 } 420 }
426 return 0; 421 return 0;
427 } 422 }
428 423
429 int CPDF_FormField::CountSelectedItems() const { 424 int CPDF_FormField::CountSelectedItems() const {
430 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); 425 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
431 if (!pValue) { 426 if (!pValue) {
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 case ListBox: 979 case ListBox:
985 NotifyAfterSelectionChange(); 980 NotifyAfterSelectionChange();
986 break; 981 break;
987 case ComboBox: 982 case ComboBox:
988 NotifyAfterValueChange(); 983 NotifyAfterValueChange();
989 break; 984 break;
990 default: 985 default:
991 break; 986 break;
992 } 987 }
993 } 988 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698