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

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

Issue 2049003003: Add some consts and remove more casts in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 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 | « core/fpdfdoc/doc_form.cpp ('k') | core/fpdfdoc/include/fpdf_doc.h » ('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 "core/fpdfapi/fpdf_parser/include/cfdf_document.h" 7 #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h"
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 m_Type = ListBox; 98 m_Type = ListBox;
99 if (flags & 0x200000) { 99 if (flags & 0x200000) {
100 m_Flags |= FORMLIST_MULTISELECT; 100 m_Flags |= FORMLIST_MULTISELECT;
101 } 101 }
102 } 102 }
103 LoadDA(); 103 LoadDA();
104 } else if (type_name == "Sig") { 104 } else if (type_name == "Sig") {
105 m_Type = Sign; 105 m_Type = Sign;
106 } 106 }
107 } 107 }
108 CFX_WideString CPDF_FormField::GetFullName() { 108 CFX_WideString CPDF_FormField::GetFullName() const {
109 return ::GetFullName(m_pDict); 109 return ::GetFullName(m_pDict);
110 } 110 }
111 111
112 FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { 112 FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
113 switch (m_Type) { 113 switch (m_Type) {
114 case CPDF_FormField::CheckBox: 114 case CPDF_FormField::CheckBox:
115 case CPDF_FormField::RadioButton: { 115 case CPDF_FormField::RadioButton: {
116 int iCount = CountControls(); 116 int iCount = CountControls();
117 if (iCount) { 117 if (iCount) {
118 // TODO(weili): Check whether anything special needs to be done for 118 // TODO(weili): Check whether anything special needs to be done for
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 m_pDict->RemoveAt("V"); 181 m_pDict->RemoveAt("V");
182 m_pDict->RemoveAt("RV"); 182 m_pDict->RemoveAt("RV");
183 } 183 }
184 if (bNotify) 184 if (bNotify)
185 NotifyAfterValueChange(); 185 NotifyAfterValueChange();
186 } break; 186 } break;
187 } 187 }
188 return TRUE; 188 return TRUE;
189 } 189 }
190 190
191 int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) { 191 int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) const {
192 if (!pControl) 192 if (!pControl)
193 return -1; 193 return -1;
194 194
195 for (int i = 0; i < m_ControlList.GetSize(); i++) { 195 for (int i = 0; i < m_ControlList.GetSize(); i++) {
196 if (m_ControlList.GetAt(i) == pControl) 196 if (m_ControlList.GetAt(i) == pControl)
197 return i; 197 return i;
198 } 198 }
199 return -1; 199 return -1;
200 } 200 }
201 int CPDF_FormField::GetFieldType() { 201
202 int CPDF_FormField::GetFieldType() const {
202 switch (m_Type) { 203 switch (m_Type) {
203 case PushButton: 204 case PushButton:
204 return FIELDTYPE_PUSHBUTTON; 205 return FIELDTYPE_PUSHBUTTON;
205 case CheckBox: 206 case CheckBox:
206 return FIELDTYPE_CHECKBOX; 207 return FIELDTYPE_CHECKBOX;
207 case RadioButton: 208 case RadioButton:
208 return FIELDTYPE_RADIOBUTTON; 209 return FIELDTYPE_RADIOBUTTON;
209 case ComboBox: 210 case ComboBox:
210 return FIELDTYPE_COMBOBOX; 211 return FIELDTYPE_COMBOBOX;
211 case ListBox: 212 case ListBox:
212 return FIELDTYPE_LISTBOX; 213 return FIELDTYPE_LISTBOX;
213 case Text: 214 case Text:
214 case RichText: 215 case RichText:
215 case File: 216 case File:
216 return FIELDTYPE_TEXTFIELD; 217 return FIELDTYPE_TEXTFIELD;
217 case Sign: 218 case Sign:
218 return FIELDTYPE_SIGNATURE; 219 return FIELDTYPE_SIGNATURE;
219 default: 220 default:
220 break; 221 break;
221 } 222 }
222 return FIELDTYPE_UNKNOWN; 223 return FIELDTYPE_UNKNOWN;
223 } 224 }
224 225
225 CPDF_AAction CPDF_FormField::GetAdditionalAction() { 226 CPDF_AAction CPDF_FormField::GetAdditionalAction() const {
226 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "AA"); 227 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "AA");
227 return CPDF_AAction(pObj ? pObj->GetDict() : nullptr); 228 return CPDF_AAction(pObj ? pObj->GetDict() : nullptr);
228 } 229 }
229 230
230 CFX_WideString CPDF_FormField::GetAlternateName() { 231 CFX_WideString CPDF_FormField::GetAlternateName() const {
231 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU"); 232 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU");
232 if (!pObj) { 233 if (!pObj) {
233 return L""; 234 return L"";
234 } 235 }
235 return pObj->GetUnicodeText(); 236 return pObj->GetUnicodeText();
236 } 237 }
237 CFX_WideString CPDF_FormField::GetMappingName() { 238 CFX_WideString CPDF_FormField::GetMappingName() const {
238 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM"); 239 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM");
239 if (!pObj) { 240 if (!pObj) {
240 return L""; 241 return L"";
241 } 242 }
242 return pObj->GetUnicodeText(); 243 return pObj->GetUnicodeText();
243 } 244 }
244 uint32_t CPDF_FormField::GetFieldFlags() { 245 uint32_t CPDF_FormField::GetFieldFlags() const {
245 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "Ff"); 246 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "Ff");
246 if (!pObj) { 247 if (!pObj) {
247 return 0; 248 return 0;
248 } 249 }
249 return pObj->GetInteger(); 250 return pObj->GetInteger();
250 } 251 }
251 CFX_ByteString CPDF_FormField::GetDefaultStyle() { 252 CFX_ByteString CPDF_FormField::GetDefaultStyle() const {
252 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DS"); 253 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DS");
253 if (!pObj) { 254 if (!pObj) {
254 return ""; 255 return "";
255 } 256 }
256 return pObj->GetString(); 257 return pObj->GetString();
257 } 258 }
258 CFX_WideString CPDF_FormField::GetRichTextString() { 259 CFX_WideString CPDF_FormField::GetRichTextString() const {
259 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "RV"); 260 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "RV");
260 if (!pObj) { 261 if (!pObj) {
261 return L""; 262 return L"";
262 } 263 }
263 return pObj->GetUnicodeText(); 264 return pObj->GetUnicodeText();
264 } 265 }
265 CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) { 266 CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) const {
266 if (GetType() == CheckBox || GetType() == RadioButton) 267 if (GetType() == CheckBox || GetType() == RadioButton)
267 return GetCheckValue(bDefault); 268 return GetCheckValue(bDefault);
268 269
269 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, bDefault ? "DV" : "V"); 270 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, bDefault ? "DV" : "V");
270 if (!pValue) { 271 if (!pValue) {
271 if (!bDefault) { 272 if (!bDefault) {
272 if (m_Type == RichText) { 273 if (m_Type == RichText) {
273 pValue = FPDF_GetFieldAttr(m_pDict, "V"); 274 pValue = FPDF_GetFieldAttr(m_pDict, "V");
274 } 275 }
275 if (!pValue && m_Type != Text) { 276 if (!pValue && m_Type != Text) {
(...skipping 11 matching lines...) Expand all
287 pValue = pValue->AsArray()->GetDirectObjectAt(0); 288 pValue = pValue->AsArray()->GetDirectObjectAt(0);
288 if (pValue) 289 if (pValue)
289 return pValue->GetUnicodeText(); 290 return pValue->GetUnicodeText();
290 break; 291 break;
291 default: 292 default:
292 break; 293 break;
293 } 294 }
294 return CFX_WideString(); 295 return CFX_WideString();
295 } 296 }
296 297
297 CFX_WideString CPDF_FormField::GetValue() { 298 CFX_WideString CPDF_FormField::GetValue() const {
298 return GetValue(FALSE); 299 return GetValue(FALSE);
299 } 300 }
300 301
301 CFX_WideString CPDF_FormField::GetDefaultValue() { 302 CFX_WideString CPDF_FormField::GetDefaultValue() const {
302 return GetValue(TRUE); 303 return GetValue(TRUE);
303 } 304 }
304 305
305 FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, 306 FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value,
306 FX_BOOL bDefault, 307 FX_BOOL bDefault,
307 FX_BOOL bNotify) { 308 FX_BOOL bNotify) {
308 switch (m_Type) { 309 switch (m_Type) {
309 case CheckBox: 310 case CheckBox:
310 case RadioButton: { 311 case RadioButton: {
311 SetCheckValue(value, bDefault, bNotify); 312 SetCheckValue(value, bDefault, bNotify);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 default: 359 default:
359 break; 360 break;
360 } 361 }
361 return TRUE; 362 return TRUE;
362 } 363 }
363 364
364 FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bNotify) { 365 FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bNotify) {
365 return SetValue(value, FALSE, bNotify); 366 return SetValue(value, FALSE, bNotify);
366 } 367 }
367 368
368 int CPDF_FormField::GetMaxLen() { 369 int CPDF_FormField::GetMaxLen() const {
369 if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen")) 370 if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "MaxLen"))
370 return pObj->GetInteger(); 371 return pObj->GetInteger();
371 372
372 for (int i = 0; i < m_ControlList.GetSize(); i++) { 373 for (int i = 0; i < m_ControlList.GetSize(); i++) {
373 CPDF_FormControl* pControl = m_ControlList.GetAt(i); 374 CPDF_FormControl* pControl = m_ControlList.GetAt(i);
374 if (!pControl) 375 if (!pControl)
375 continue; 376 continue;
376 377
377 CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; 378 CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict;
378 if (pWidgetDict->KeyExist("MaxLen")) 379 if (pWidgetDict->KeyExist("MaxLen"))
379 return pWidgetDict->GetIntegerBy("MaxLen"); 380 return pWidgetDict->GetIntegerBy("MaxLen");
380 } 381 }
381 return 0; 382 return 0;
382 } 383 }
383 384
384 int CPDF_FormField::CountSelectedItems() { 385 int CPDF_FormField::CountSelectedItems() const {
385 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); 386 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
386 if (!pValue) { 387 if (!pValue) {
387 pValue = FPDF_GetFieldAttr(m_pDict, "I"); 388 pValue = FPDF_GetFieldAttr(m_pDict, "I");
388 if (!pValue) 389 if (!pValue)
389 return 0; 390 return 0;
390 } 391 }
391 392
392 if (pValue->IsString() || pValue->IsNumber()) 393 if (pValue->IsString() || pValue->IsNumber())
393 return pValue->GetString().IsEmpty() ? 0 : 1; 394 return pValue->GetString().IsEmpty() ? 0 : 1;
394 if (CPDF_Array* pArray = pValue->AsArray()) 395 if (CPDF_Array* pArray = pValue->AsArray())
395 return pArray->GetCount(); 396 return pArray->GetCount();
396 return 0; 397 return 0;
397 } 398 }
398 399
399 int CPDF_FormField::GetSelectedIndex(int index) { 400 int CPDF_FormField::GetSelectedIndex(int index) const {
400 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); 401 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
401 if (!pValue) { 402 if (!pValue) {
402 pValue = FPDF_GetFieldAttr(m_pDict, "I"); 403 pValue = FPDF_GetFieldAttr(m_pDict, "I");
403 if (!pValue) 404 if (!pValue)
404 return -1; 405 return -1;
405 } 406 }
406 if (pValue->IsNumber()) 407 if (pValue->IsNumber())
407 return pValue->GetInteger(); 408 return pValue->GetInteger();
408 409
409 CFX_WideString sel_value; 410 CFX_WideString sel_value;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if (!NotifyListOrComboBoxBeforeChange(csValue)) 445 if (!NotifyListOrComboBoxBeforeChange(csValue))
445 return FALSE; 446 return FALSE;
446 } 447 }
447 m_pDict->RemoveAt("V"); 448 m_pDict->RemoveAt("V");
448 m_pDict->RemoveAt("I"); 449 m_pDict->RemoveAt("I");
449 if (bNotify) 450 if (bNotify)
450 NotifyListOrComboBoxAfterChange(); 451 NotifyListOrComboBoxAfterChange();
451 return TRUE; 452 return TRUE;
452 } 453 }
453 454
454 FX_BOOL CPDF_FormField::IsItemSelected(int index) { 455 FX_BOOL CPDF_FormField::IsItemSelected(int index) const {
455 ASSERT(GetType() == ComboBox || GetType() == ListBox); 456 ASSERT(GetType() == ComboBox || GetType() == ListBox);
456 if (index < 0 || index >= CountOptions()) { 457 if (index < 0 || index >= CountOptions()) {
457 return FALSE; 458 return FALSE;
458 } 459 }
459 if (IsOptionSelected(index)) { 460 if (IsOptionSelected(index)) {
460 return TRUE; 461 return TRUE;
461 } 462 }
462 CFX_WideString opt_value = GetOptionValue(index); 463 CFX_WideString opt_value = GetOptionValue(index);
463 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); 464 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
464 if (!pValue) { 465 if (!pValue) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 m_pDict->RemoveAt("V"); 554 m_pDict->RemoveAt("V");
554 m_pDict->RemoveAt("I"); 555 m_pDict->RemoveAt("I");
555 } 556 }
556 } 557 }
557 } 558 }
558 if (bNotify) 559 if (bNotify)
559 NotifyListOrComboBoxAfterChange(); 560 NotifyListOrComboBoxAfterChange();
560 return TRUE; 561 return TRUE;
561 } 562 }
562 563
563 FX_BOOL CPDF_FormField::IsItemDefaultSelected(int index) { 564 FX_BOOL CPDF_FormField::IsItemDefaultSelected(int index) const {
564 ASSERT(GetType() == ComboBox || GetType() == ListBox); 565 ASSERT(GetType() == ComboBox || GetType() == ListBox);
565 if (index < 0 || index >= CountOptions()) 566 if (index < 0 || index >= CountOptions())
566 return FALSE; 567 return FALSE;
567 int iDVIndex = GetDefaultSelectedItem(); 568 int iDVIndex = GetDefaultSelectedItem();
568 return iDVIndex >= 0 && iDVIndex == index; 569 return iDVIndex >= 0 && iDVIndex == index;
569 } 570 }
570 571
571 int CPDF_FormField::GetDefaultSelectedItem() { 572 int CPDF_FormField::GetDefaultSelectedItem() const {
572 ASSERT(GetType() == ComboBox || GetType() == ListBox); 573 ASSERT(GetType() == ComboBox || GetType() == ListBox);
573 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "DV"); 574 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "DV");
574 if (!pValue) 575 if (!pValue)
575 return -1; 576 return -1;
576 CFX_WideString csDV = pValue->GetUnicodeText(); 577 CFX_WideString csDV = pValue->GetUnicodeText();
577 if (csDV.IsEmpty()) 578 if (csDV.IsEmpty())
578 return -1; 579 return -1;
579 for (int i = 0; i < CountOptions(); i++) { 580 for (int i = 0; i < CountOptions(); i++) {
580 if (csDV == GetOptionValue(i)) 581 if (csDV == GetOptionValue(i))
581 return i; 582 return i;
582 } 583 }
583 return -1; 584 return -1;
584 } 585 }
585 586
586 int CPDF_FormField::CountOptions() { 587 int CPDF_FormField::CountOptions() const {
587 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt")); 588 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt"));
588 return pArray ? pArray->GetCount() : 0; 589 return pArray ? pArray->GetCount() : 0;
589 } 590 }
590 591
591 CFX_WideString CPDF_FormField::GetOptionText(int index, int sub_index) { 592 CFX_WideString CPDF_FormField::GetOptionText(int index, int sub_index) const {
592 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt")); 593 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt"));
593 if (!pArray) 594 if (!pArray)
594 return CFX_WideString(); 595 return CFX_WideString();
595 596
596 CPDF_Object* pOption = pArray->GetDirectObjectAt(index); 597 CPDF_Object* pOption = pArray->GetDirectObjectAt(index);
597 if (!pOption) 598 if (!pOption)
598 return CFX_WideString(); 599 return CFX_WideString();
599 if (CPDF_Array* pOptionArray = pOption->AsArray()) 600 if (CPDF_Array* pOptionArray = pOption->AsArray())
600 pOption = pOptionArray->GetDirectObjectAt(sub_index); 601 pOption = pOptionArray->GetDirectObjectAt(sub_index);
601 602
602 CPDF_String* pString = ToString(pOption); 603 CPDF_String* pString = ToString(pOption);
603 return pString ? pString->GetUnicodeText() : CFX_WideString(); 604 return pString ? pString->GetUnicodeText() : CFX_WideString();
604 } 605 }
605 CFX_WideString CPDF_FormField::GetOptionLabel(int index) { 606 CFX_WideString CPDF_FormField::GetOptionLabel(int index) const {
606 return GetOptionText(index, 1); 607 return GetOptionText(index, 1);
607 } 608 }
608 CFX_WideString CPDF_FormField::GetOptionValue(int index) { 609 CFX_WideString CPDF_FormField::GetOptionValue(int index) const {
609 return GetOptionText(index, 0); 610 return GetOptionText(index, 0);
610 } 611 }
611 612
612 int CPDF_FormField::FindOption(CFX_WideString csOptLabel) { 613 int CPDF_FormField::FindOption(CFX_WideString csOptLabel) const {
613 for (int i = 0; i < CountOptions(); i++) { 614 for (int i = 0; i < CountOptions(); i++) {
614 if (GetOptionValue(i) == csOptLabel) 615 if (GetOptionValue(i) == csOptLabel)
615 return i; 616 return i;
616 } 617 }
617 return -1; 618 return -1;
618 } 619 }
619 620
620 int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) { 621 int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) const {
621 for (int i = 0; i < CountOptions(); i++) { 622 for (int i = 0; i < CountOptions(); i++) {
622 if (GetOptionValue(i) == csOptValue) 623 if (GetOptionValue(i) == csOptValue)
623 return i; 624 return i;
624 } 625 }
625 return -1; 626 return -1;
626 } 627 }
627 628
628 #ifdef PDF_ENABLE_XFA 629 #ifdef PDF_ENABLE_XFA
629 int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, 630 int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
630 int index, 631 int index,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 } else if (bChecked) { 735 } else if (bChecked) {
735 CFX_ByteString csIndex; 736 CFX_ByteString csIndex;
736 csIndex.Format("%d", iControlIndex); 737 csIndex.Format("%d", iControlIndex);
737 m_pDict->SetAtName("V", csIndex); 738 m_pDict->SetAtName("V", csIndex);
738 } 739 }
739 if (bNotify && m_pForm->m_pFormNotify) 740 if (bNotify && m_pForm->m_pFormNotify)
740 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this); 741 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
741 return TRUE; 742 return TRUE;
742 } 743 }
743 744
744 CFX_WideString CPDF_FormField::GetCheckValue(FX_BOOL bDefault) { 745 CFX_WideString CPDF_FormField::GetCheckValue(FX_BOOL bDefault) const {
745 ASSERT(GetType() == CheckBox || GetType() == RadioButton); 746 ASSERT(GetType() == CheckBox || GetType() == RadioButton);
746 CFX_WideString csExport = L"Off"; 747 CFX_WideString csExport = L"Off";
747 int iCount = CountControls(); 748 int iCount = CountControls();
748 for (int i = 0; i < iCount; i++) { 749 for (int i = 0; i < iCount; i++) {
749 CPDF_FormControl* pControl = GetControl(i); 750 CPDF_FormControl* pControl = GetControl(i);
750 FX_BOOL bChecked = 751 FX_BOOL bChecked =
751 bDefault ? pControl->IsDefaultChecked() : pControl->IsChecked(); 752 bDefault ? pControl->IsDefaultChecked() : pControl->IsChecked();
752 if (bChecked) { 753 if (bChecked) {
753 csExport = pControl->GetExportValue(); 754 csExport = pControl->GetExportValue();
754 break; 755 break;
(...skipping 14 matching lines...) Expand all
769 if (!bDefault) 770 if (!bDefault)
770 CheckControl(GetControlIndex(pControl), val); 771 CheckControl(GetControlIndex(pControl), val);
771 if (val) 772 if (val)
772 break; 773 break;
773 } 774 }
774 if (bNotify && m_pForm->m_pFormNotify) 775 if (bNotify && m_pForm->m_pFormNotify)
775 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this); 776 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
776 return TRUE; 777 return TRUE;
777 } 778 }
778 779
779 int CPDF_FormField::GetTopVisibleIndex() { 780 int CPDF_FormField::GetTopVisibleIndex() const {
780 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI"); 781 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI");
781 return pObj ? pObj->GetInteger() : 0; 782 return pObj ? pObj->GetInteger() : 0;
782 } 783 }
783 784
784 int CPDF_FormField::CountSelectedOptions() { 785 int CPDF_FormField::CountSelectedOptions() const {
785 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I")); 786 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I"));
786 return pArray ? pArray->GetCount() : 0; 787 return pArray ? pArray->GetCount() : 0;
787 } 788 }
788 789
789 int CPDF_FormField::GetSelectedOptionIndex(int index) { 790 int CPDF_FormField::GetSelectedOptionIndex(int index) const {
790 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I")); 791 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I"));
791 if (!pArray) 792 if (!pArray)
792 return -1; 793 return -1;
793 794
794 int iCount = pArray->GetCount(); 795 int iCount = pArray->GetCount();
795 if (iCount < 0 || index >= iCount) 796 if (iCount < 0 || index >= iCount)
796 return -1; 797 return -1;
797 return pArray->GetIntegerAt(index); 798 return pArray->GetIntegerAt(index);
798 } 799 }
799 800
800 FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) { 801 FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) const {
801 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I")); 802 CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I"));
802 if (!pArray) 803 if (!pArray)
803 return FALSE; 804 return FALSE;
804 805
805 for (CPDF_Object* pObj : *pArray) { 806 for (CPDF_Object* pObj : *pArray) {
806 if (pObj->GetInteger() == iOptIndex) 807 if (pObj->GetInteger() == iOptIndex)
807 return TRUE; 808 return TRUE;
808 } 809 }
809 return FALSE; 810 return FALSE;
810 } 811 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 case ListBox: 958 case ListBox:
958 NotifyAfterSelectionChange(); 959 NotifyAfterSelectionChange();
959 break; 960 break;
960 case ComboBox: 961 case ComboBox:
961 NotifyAfterValueChange(); 962 NotifyAfterValueChange();
962 break; 963 break;
963 default: 964 default:
964 break; 965 break;
965 } 966 }
966 } 967 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_form.cpp ('k') | core/fpdfdoc/include/fpdf_doc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698