OLD | NEW |
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/include/fpdfdoc/fpdf_doc.h" | 7 #include "core/include/fpdfdoc/fpdf_doc.h" |
8 #include "doc_utils.h" | 8 #include "doc_utils.h" |
9 | 9 |
10 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) { | 10 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) { |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 if (!bSelected) { | 564 if (!bSelected) { |
565 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); | 565 CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); |
566 if (pValue) { | 566 if (pValue) { |
567 if (m_Type == ListBox) { | 567 if (m_Type == ListBox) { |
568 SelectOption(index, FALSE); | 568 SelectOption(index, FALSE); |
569 if (pValue->IsString()) { | 569 if (pValue->IsString()) { |
570 if (pValue->GetUnicodeText() == opt_value) { | 570 if (pValue->GetUnicodeText() == opt_value) { |
571 m_pDict->RemoveAt("V"); | 571 m_pDict->RemoveAt("V"); |
572 } | 572 } |
573 } else if (pValue->IsArray()) { | 573 } else if (pValue->IsArray()) { |
574 CPDF_Array* pArray = CPDF_Array::Create(); | 574 CPDF_Array* pArray = new CPDF_Array; |
575 int iCount = CountOptions(); | 575 int iCount = CountOptions(); |
576 for (int i = 0; i < iCount; i++) { | 576 for (int i = 0; i < iCount; i++) { |
577 if (i != index) { | 577 if (i != index) { |
578 if (IsItemSelected(i)) { | 578 if (IsItemSelected(i)) { |
579 opt_value = GetOptionValue(i); | 579 opt_value = GetOptionValue(i); |
580 pArray->AddString(PDF_EncodeText(opt_value)); | 580 pArray->AddString(PDF_EncodeText(opt_value)); |
581 } | 581 } |
582 } | 582 } |
583 } | 583 } |
584 if (pArray->GetCount() < 1) { | 584 if (pArray->GetCount() < 1) { |
585 pArray->Release(); | 585 pArray->Release(); |
586 } else { | 586 } else { |
587 m_pDict->SetAt("V", pArray); | 587 m_pDict->SetAt("V", pArray); |
588 } | 588 } |
589 } | 589 } |
590 } else if (m_Type == ComboBox) { | 590 } else if (m_Type == ComboBox) { |
591 m_pDict->RemoveAt("V"); | 591 m_pDict->RemoveAt("V"); |
592 m_pDict->RemoveAt("I"); | 592 m_pDict->RemoveAt("I"); |
593 } | 593 } |
594 } | 594 } |
595 } else { | 595 } else { |
596 if (m_Type == ListBox) { | 596 if (m_Type == ListBox) { |
597 SelectOption(index, TRUE); | 597 SelectOption(index, TRUE); |
598 if (!(m_Flags & FORMLIST_MULTISELECT)) { | 598 if (!(m_Flags & FORMLIST_MULTISELECT)) { |
599 m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); | 599 m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); |
600 } else { | 600 } else { |
601 CPDF_Array* pArray = CPDF_Array::Create(); | 601 CPDF_Array* pArray = new CPDF_Array; |
602 if (!pArray) { | |
603 return FALSE; | |
604 } | |
605 FX_BOOL bSelected; | |
606 int iCount = CountOptions(); | 602 int iCount = CountOptions(); |
607 for (int i = 0; i < iCount; i++) { | 603 for (int i = 0; i < iCount; i++) { |
| 604 FX_BOOL bSelected; |
608 if (i != index) { | 605 if (i != index) { |
609 bSelected = IsItemSelected(i); | 606 bSelected = IsItemSelected(i); |
610 } else { | 607 } else { |
611 bSelected = TRUE; | 608 bSelected = TRUE; |
612 } | 609 } |
613 if (bSelected) { | 610 if (bSelected) { |
614 opt_value = GetOptionValue(i); | 611 opt_value = GetOptionValue(i); |
615 pArray->AddString(PDF_EncodeText(opt_value)); | 612 pArray->AddString(PDF_EncodeText(opt_value)); |
616 } | 613 } |
617 } | 614 } |
618 m_pDict->SetAt("V", pArray); | 615 m_pDict->SetAt("V", pArray); |
619 } | 616 } |
620 } else if (m_Type == ComboBox) { | 617 } else if (m_Type == ComboBox) { |
621 m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); | 618 m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); |
622 CPDF_Array* pI = CPDF_Array::Create(); | 619 CPDF_Array* pI = new CPDF_Array; |
623 if (!pI) { | |
624 return FALSE; | |
625 } | |
626 pI->AddInteger(index); | 620 pI->AddInteger(index); |
627 m_pDict->SetAt("I", pI); | 621 m_pDict->SetAt("I", pI); |
628 } | 622 } |
629 } | 623 } |
630 if (bNotify && m_pForm->m_pFormNotify) { | 624 if (bNotify && m_pForm->m_pFormNotify) { |
631 if (GetType() == ListBox) { | 625 if (GetType() == ListBox) { |
632 m_pForm->m_pFormNotify->AfterSelectionChange(this); | 626 m_pForm->m_pFormNotify->AfterSelectionChange(this); |
633 } | 627 } |
634 if (GetType() == ComboBox) { | 628 if (GetType() == ComboBox) { |
635 m_pForm->m_pFormNotify->AfterValueChange(this); | 629 m_pForm->m_pFormNotify->AfterValueChange(this); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 return FALSE; | 893 return FALSE; |
900 } | 894 } |
901 FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, | 895 FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, |
902 FX_BOOL bSelected, | 896 FX_BOOL bSelected, |
903 FX_BOOL bNotify) { | 897 FX_BOOL bNotify) { |
904 CPDF_Array* pArray = m_pDict->GetArray("I"); | 898 CPDF_Array* pArray = m_pDict->GetArray("I"); |
905 if (!pArray) { | 899 if (!pArray) { |
906 if (!bSelected) { | 900 if (!bSelected) { |
907 return TRUE; | 901 return TRUE; |
908 } | 902 } |
909 pArray = CPDF_Array::Create(); | 903 pArray = new CPDF_Array; |
910 if (!pArray) { | |
911 return FALSE; | |
912 } | |
913 m_pDict->SetAt("I", pArray); | 904 m_pDict->SetAt("I", pArray); |
914 } | 905 } |
915 FX_BOOL bReturn = FALSE; | 906 FX_BOOL bReturn = FALSE; |
916 for (int i = 0; i < (int)pArray->GetCount(); i++) { | 907 for (int i = 0; i < (int)pArray->GetCount(); i++) { |
917 int iFind = pArray->GetInteger(i); | 908 int iFind = pArray->GetInteger(i); |
918 if (iFind == iOptIndex) { | 909 if (iFind == iOptIndex) { |
919 if (bSelected) { | 910 if (bSelected) { |
920 return TRUE; | 911 return TRUE; |
921 } | 912 } |
922 if (bNotify && m_pForm->m_pFormNotify) { | 913 if (bNotify && m_pForm->m_pFormNotify) { |
(...skipping 22 matching lines...) Expand all Loading... |
945 if (GetType() == ListBox) { | 936 if (GetType() == ListBox) { |
946 iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); | 937 iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); |
947 } | 938 } |
948 if (GetType() == ComboBox) { | 939 if (GetType() == ComboBox) { |
949 iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); | 940 iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); |
950 } | 941 } |
951 if (iRet < 0) { | 942 if (iRet < 0) { |
952 return FALSE; | 943 return FALSE; |
953 } | 944 } |
954 } | 945 } |
955 CPDF_Number* pNum = CPDF_Number::Create(iOptIndex); | 946 CPDF_Number* pNum = new CPDF_Number(iOptIndex); |
956 if (!pNum) { | |
957 return FALSE; | |
958 } | |
959 pArray->InsertAt(i, pNum); | 947 pArray->InsertAt(i, pNum); |
960 bReturn = TRUE; | 948 bReturn = TRUE; |
961 break; | 949 break; |
962 } | 950 } |
963 } | 951 } |
964 if (!bReturn) { | 952 if (!bReturn) { |
965 if (bSelected) { | 953 if (bSelected) { |
966 pArray->AddInteger(iOptIndex); | 954 pArray->AddInteger(iOptIndex); |
967 } | 955 } |
968 if (pArray->GetCount() == 0) { | 956 if (pArray->GetCount() == 0) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")) | 1017 m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")) |
1030 pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict( | 1018 pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict( |
1031 font_name); | 1019 font_name); |
1032 | 1020 |
1033 if (!pFontDict) { | 1021 if (!pFontDict) { |
1034 return; | 1022 return; |
1035 } | 1023 } |
1036 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); | 1024 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); |
1037 m_FontSize = FX_atof(syntax.GetWord()); | 1025 m_FontSize = FX_atof(syntax.GetWord()); |
1038 } | 1026 } |
OLD | NEW |