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

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

Issue 1653253002: Kill CFX_ByteArray in master. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: ... and its gone. Created 4 years, 10 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/src/fpdfdoc/doc_formcontrol.cpp ('k') | core/src/fpdfdoc/doc_utils.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/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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 m_Type = Sign; 95 m_Type = Sign;
96 } 96 }
97 } 97 }
98 CFX_WideString CPDF_FormField::GetFullName() { 98 CFX_WideString CPDF_FormField::GetFullName() {
99 return ::GetFullName(m_pDict); 99 return ::GetFullName(m_pDict);
100 } 100 }
101 FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { 101 FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
102 switch (m_Type) { 102 switch (m_Type) {
103 case CPDF_FormField::CheckBox: 103 case CPDF_FormField::CheckBox:
104 case CPDF_FormField::RadioButton: { 104 case CPDF_FormField::RadioButton: {
105 CFX_ByteArray statusArray;
106 if (bNotify && m_pForm->m_pFormNotify) {
107 SaveCheckedFieldStatus(this, statusArray);
108 }
109 int iCount = CountControls(); 105 int iCount = CountControls();
110 if (iCount) { 106 if (iCount) {
111 if (PDF_FormField_IsUnison(this)) { 107 if (PDF_FormField_IsUnison(this)) {
112 for (int i = 0; i < iCount; i++) { 108 for (int i = 0; i < iCount; i++) {
113 CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE); 109 CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
114 } 110 }
115 } else { 111 } else {
116 for (int i = 0; i < iCount; i++) { 112 for (int i = 0; i < iCount; i++) {
117 CPDF_FormControl* pControl = GetControl(i); 113 CPDF_FormControl* pControl = GetControl(i);
118 FX_BOOL bChecked = pControl->IsDefaultChecked(); 114 FX_BOOL bChecked = pControl->IsDefaultChecked();
119 CheckControl(i, bChecked, FALSE); 115 CheckControl(i, bChecked, FALSE);
120 } 116 }
121 } 117 }
122 } 118 }
123 if (bNotify && m_pForm->m_pFormNotify) { 119 if (bNotify && m_pForm->m_pFormNotify) {
124 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); 120 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
125 } 121 }
126 } break; 122 } break;
127 case CPDF_FormField::ComboBox: { 123 case CPDF_FormField::ComboBox: {
128 CFX_WideString csValue; 124 CFX_WideString csValue;
129 ClearSelection(); 125 ClearSelection();
130 int iIndex = GetDefaultSelectedItem(); 126 int iIndex = GetDefaultSelectedItem();
131 if (iIndex >= 0) { 127 if (iIndex >= 0) {
132 csValue = GetOptionLabel(iIndex); 128 csValue = GetOptionLabel(iIndex);
133 } 129 }
134 if (bNotify && m_pForm->m_pFormNotify) { 130 if (bNotify && m_pForm->m_pFormNotify) {
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 FX_BOOL bChecked, 729 FX_BOOL bChecked,
734 FX_BOOL bNotify) { 730 FX_BOOL bNotify) {
735 ASSERT(GetType() == CheckBox || GetType() == RadioButton); 731 ASSERT(GetType() == CheckBox || GetType() == RadioButton);
736 CPDF_FormControl* pControl = GetControl(iControlIndex); 732 CPDF_FormControl* pControl = GetControl(iControlIndex);
737 if (!pControl) { 733 if (!pControl) {
738 return FALSE; 734 return FALSE;
739 } 735 }
740 if (!bChecked && pControl->IsChecked() == bChecked) { 736 if (!bChecked && pControl->IsChecked() == bChecked) {
741 return FALSE; 737 return FALSE;
742 } 738 }
743 CFX_ByteArray statusArray;
744 if (bNotify && m_pForm->m_pFormNotify) {
745 SaveCheckedFieldStatus(this, statusArray);
746 }
747 CFX_WideString csWExport = pControl->GetExportValue(); 739 CFX_WideString csWExport = pControl->GetExportValue();
748 CFX_ByteString csBExport = PDF_EncodeText(csWExport); 740 CFX_ByteString csBExport = PDF_EncodeText(csWExport);
749 int iCount = CountControls(); 741 int iCount = CountControls();
750 FX_BOOL bUnison = PDF_FormField_IsUnison(this); 742 FX_BOOL bUnison = PDF_FormField_IsUnison(this);
751 for (int i = 0; i < iCount; i++) { 743 for (int i = 0; i < iCount; i++) {
752 CPDF_FormControl* pCtrl = GetControl(i); 744 CPDF_FormControl* pCtrl = GetControl(i);
753 if (bUnison) { 745 if (bUnison) {
754 CFX_WideString csEValue = pCtrl->GetExportValue(); 746 CFX_WideString csEValue = pCtrl->GetExportValue();
755 if (csEValue == csWExport) { 747 if (csEValue == csWExport) {
756 if (pCtrl->GetOnStateName() == pControl->GetOnStateName()) { 748 if (pCtrl->GetOnStateName() == pControl->GetOnStateName()) {
(...skipping 25 matching lines...) Expand all
782 if (csV == csBExport) { 774 if (csV == csBExport) {
783 m_pDict->SetAtName("V", "Off"); 775 m_pDict->SetAtName("V", "Off");
784 } 776 }
785 } 777 }
786 } else if (bChecked) { 778 } else if (bChecked) {
787 CFX_ByteString csIndex; 779 CFX_ByteString csIndex;
788 csIndex.Format("%d", iControlIndex); 780 csIndex.Format("%d", iControlIndex);
789 m_pDict->SetAtName("V", csIndex); 781 m_pDict->SetAtName("V", csIndex);
790 } 782 }
791 if (bNotify && m_pForm->m_pFormNotify) { 783 if (bNotify && m_pForm->m_pFormNotify) {
792 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); 784 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
793 } 785 }
794 m_pForm->m_bUpdated = TRUE; 786 m_pForm->m_bUpdated = TRUE;
795 return TRUE; 787 return TRUE;
796 } 788 }
797 CFX_WideString CPDF_FormField::GetCheckValue(FX_BOOL bDefault) { 789 CFX_WideString CPDF_FormField::GetCheckValue(FX_BOOL bDefault) {
798 ASSERT(GetType() == CheckBox || GetType() == RadioButton); 790 ASSERT(GetType() == CheckBox || GetType() == RadioButton);
799 CFX_WideString csExport = L"Off"; 791 CFX_WideString csExport = L"Off";
800 FX_BOOL bChecked; 792 FX_BOOL bChecked;
801 int iCount = CountControls(); 793 int iCount = CountControls();
802 for (int i = 0; i < iCount; i++) { 794 for (int i = 0; i < iCount; i++) {
803 CPDF_FormControl* pControl = GetControl(i); 795 CPDF_FormControl* pControl = GetControl(i);
804 if (bDefault) { 796 if (bDefault) {
805 bChecked = pControl->IsDefaultChecked(); 797 bChecked = pControl->IsDefaultChecked();
806 } else { 798 } else {
807 bChecked = pControl->IsChecked(); 799 bChecked = pControl->IsChecked();
808 } 800 }
809 if (bChecked) { 801 if (bChecked) {
810 csExport = pControl->GetExportValue(); 802 csExport = pControl->GetExportValue();
811 break; 803 break;
812 } 804 }
813 } 805 }
814 return csExport; 806 return csExport;
815 } 807 }
816 FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value, 808 FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
817 FX_BOOL bDefault, 809 FX_BOOL bDefault,
818 FX_BOOL bNotify) { 810 FX_BOOL bNotify) {
819 ASSERT(GetType() == CheckBox || GetType() == RadioButton); 811 ASSERT(GetType() == CheckBox || GetType() == RadioButton);
820 CFX_ByteArray statusArray;
821 if (bNotify && m_pForm->m_pFormNotify) {
822 SaveCheckedFieldStatus(this, statusArray);
823 }
824 int iCount = CountControls(); 812 int iCount = CountControls();
825 for (int i = 0; i < iCount; i++) { 813 for (int i = 0; i < iCount; i++) {
826 CPDF_FormControl* pControl = GetControl(i); 814 CPDF_FormControl* pControl = GetControl(i);
827 CFX_WideString csExport = pControl->GetExportValue(); 815 CFX_WideString csExport = pControl->GetExportValue();
828 if (csExport == value) { 816 if (csExport == value) {
829 if (bDefault) { 817 if (bDefault) {
830 } else { 818 } else {
831 CheckControl(GetControlIndex(pControl), TRUE); 819 CheckControl(GetControlIndex(pControl), TRUE);
832 } 820 }
833 break; 821 break;
834 } else { 822 } else {
835 if (bDefault) { 823 if (bDefault) {
836 } else { 824 } else {
837 CheckControl(GetControlIndex(pControl), FALSE); 825 CheckControl(GetControlIndex(pControl), FALSE);
838 } 826 }
839 } 827 }
840 } 828 }
841 if (bNotify && m_pForm->m_pFormNotify) { 829 if (bNotify && m_pForm->m_pFormNotify) {
842 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); 830 m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
843 } 831 }
844 m_pForm->m_bUpdated = TRUE; 832 m_pForm->m_bUpdated = TRUE;
845 return TRUE; 833 return TRUE;
846 } 834 }
847 int CPDF_FormField::GetTopVisibleIndex() { 835 int CPDF_FormField::GetTopVisibleIndex() {
848 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI"); 836 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI");
849 if (!pObj) { 837 if (!pObj) {
850 return 0; 838 return 0;
851 } 839 }
852 return pObj->GetInteger(); 840 return pObj->GetInteger();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 pFontDict = m_pForm->m_pFormDict->GetDictBy("DR") 1008 pFontDict = m_pForm->m_pFormDict->GetDictBy("DR")
1021 ->GetDictBy("Font") 1009 ->GetDictBy("Font")
1022 ->GetDictBy(font_name); 1010 ->GetDictBy(font_name);
1023 1011
1024 if (!pFontDict) { 1012 if (!pFontDict) {
1025 return; 1013 return;
1026 } 1014 }
1027 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); 1015 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict);
1028 m_FontSize = FX_atof(syntax.GetWord()); 1016 m_FontSize = FX_atof(syntax.GetWord());
1029 } 1017 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_formcontrol.cpp ('k') | core/src/fpdfdoc/doc_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698