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

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

Issue 1194933003: Make CPDF_Object::GetString() a virtual method. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase 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
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/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWid getDict) 8 CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWid getDict)
9 { 9 {
10 m_pField = pField; 10 m_pField = pField;
(...skipping 28 matching lines...) Expand all
39 void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) 39 void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn)
40 { 40 {
41 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton); 41 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton);
42 CFX_ByteString csValue = csOn; 42 CFX_ByteString csValue = csOn;
43 if (csValue.IsEmpty()) { 43 if (csValue.IsEmpty()) {
44 csValue = "Yes"; 44 csValue = "Yes";
45 } 45 }
46 if (csValue == "Off") { 46 if (csValue == "Off") {
47 csValue = "Yes"; 47 csValue = "Yes";
48 } 48 }
49 CFX_ByteString csAS = m_pWidgetDict->GetString("AS", "Off"); 49 CFX_ByteString csAS = m_pWidgetDict->GetStringAt("AS", "Off");
50 if (csAS != "Off") { 50 if (csAS != "Off") {
51 m_pWidgetDict->SetAtName("AS", csValue); 51 m_pWidgetDict->SetAtName("AS", csValue);
52 } 52 }
53 CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP"); 53 CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP");
54 if (pAP == NULL) { 54 if (pAP == NULL) {
55 return; 55 return;
56 } 56 }
57 FX_POSITION pos1 = pAP->GetStartPos(); 57 FX_POSITION pos1 = pAP->GetStartPos();
58 while (pos1) { 58 while (pos1) {
59 CFX_ByteString csKey1; 59 CFX_ByteString csKey1;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return csOn; 97 return csOn;
98 } 98 }
99 CFX_WideString CPDF_FormControl::GetExportValue() 99 CFX_WideString CPDF_FormControl::GetExportValue()
100 { 100 {
101 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton); 101 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton);
102 CFX_ByteString csOn = GetOnStateName(); 102 CFX_ByteString csOn = GetOnStateName();
103 if (GetType() == CPDF_FormField::RadioButton || GetType() == CPDF_FormField: :CheckBox) { 103 if (GetType() == CPDF_FormField::RadioButton || GetType() == CPDF_FormField: :CheckBox) {
104 CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"); 104 CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt");
105 if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) { 105 if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) {
106 int iIndex = m_pField->GetControlIndex(this); 106 int iIndex = m_pField->GetControlIndex(this);
107 csOn = ((CPDF_Array*)pOpt)->GetString(iIndex); 107 csOn = ((CPDF_Array*)pOpt)->GetStringAt(iIndex);
108 } 108 }
109 } 109 }
110 if (csOn.IsEmpty()) { 110 if (csOn.IsEmpty()) {
111 csOn = "Yes"; 111 csOn = "Yes";
112 } 112 }
113 CFX_WideString csWOn = PDF_DecodeText(csOn); 113 CFX_WideString csWOn = PDF_DecodeText(csOn);
114 return csWOn; 114 return csWOn;
115 } 115 }
116 FX_BOOL CPDF_FormControl::IsChecked() 116 FX_BOOL CPDF_FormControl::IsChecked()
117 { 117 {
118 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton); 118 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton);
119 CFX_ByteString csOn = GetOnStateName(); 119 CFX_ByteString csOn = GetOnStateName();
120 CFX_ByteString csAS = m_pWidgetDict->GetString("AS"); 120 CFX_ByteString csAS = m_pWidgetDict->GetStringAt("AS");
121 return csAS == csOn; 121 return csAS == csOn;
122 } 122 }
123 FX_BOOL CPDF_FormControl::IsDefaultChecked() 123 FX_BOOL CPDF_FormControl::IsDefaultChecked()
124 { 124 {
125 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton); 125 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton);
126 CPDF_Object* pDV = FPDF_GetFieldAttr(m_pField->m_pDict, "DV"); 126 CPDF_Object* pDV = FPDF_GetFieldAttr(m_pField->m_pDict, "DV");
127 if (pDV == NULL) { 127 if (pDV == NULL) {
128 return FALSE; 128 return FALSE;
129 } 129 }
130 CFX_ByteString csDV = pDV->GetString(); 130 CFX_ByteString csDV = pDV->GetString();
131 CFX_ByteString csOn = GetOnStateName(); 131 CFX_ByteString csOn = GetOnStateName();
132 return (csDV == csOn); 132 return (csDV == csOn);
133 } 133 }
134 void CPDF_FormControl::CheckControl(FX_BOOL bChecked) 134 void CPDF_FormControl::CheckControl(FX_BOOL bChecked)
135 { 135 {
136 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton); 136 ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField: :RadioButton);
137 CFX_ByteString csOn = GetOnStateName(); 137 CFX_ByteString csOn = GetOnStateName();
138 CFX_ByteString csOldAS = m_pWidgetDict->GetString("AS", "Off"); 138 CFX_ByteString csOldAS = m_pWidgetDict->GetStringAt("AS", "Off");
139 CFX_ByteString csAS = "Off"; 139 CFX_ByteString csAS = "Off";
140 if (bChecked) { 140 if (bChecked) {
141 csAS = csOn; 141 csAS = csOn;
142 } 142 }
143 if (csOldAS == csAS) { 143 if (csOldAS == csAS) {
144 return; 144 return;
145 } 145 }
146 m_pWidgetDict->SetAtName("AS", csAS); 146 m_pWidgetDict->SetAtName("AS", csAS);
147 m_pForm->m_bUpdated = TRUE; 147 m_pForm->m_bUpdated = TRUE;
148 } 148 }
(...skipping 20 matching lines...) Expand all
169 CPDF_RenderContext context; 169 CPDF_RenderContext context;
170 context.Create(pPage); 170 context.Create(pPage);
171 context.DrawObjectList(pDevice, &form, &matrix, pOptions); 171 context.DrawObjectList(pDevice, &form, &matrix, pOptions);
172 } 172 }
173 const FX_CHAR* g_sHighlightingMode[] = {"N", "I", "O", "P", "T", ""}; 173 const FX_CHAR* g_sHighlightingMode[] = {"N", "I", "O", "P", "T", ""};
174 CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() 174 CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode()
175 { 175 {
176 if (m_pWidgetDict == NULL) { 176 if (m_pWidgetDict == NULL) {
177 return Invert; 177 return Invert;
178 } 178 }
179 CFX_ByteString csH = m_pWidgetDict->GetString("H", "I"); 179 CFX_ByteString csH = m_pWidgetDict->GetStringAt("H", "I");
180 int i = 0; 180 int i = 0;
181 while (g_sHighlightingMode[i][0] != '\0') { 181 while (g_sHighlightingMode[i][0] != '\0') {
182 if (csH.Equal(g_sHighlightingMode[i])) { 182 if (csH.Equal(g_sHighlightingMode[i])) {
183 return (HighlightingMode)i; 183 return (HighlightingMode)i;
184 } 184 }
185 i ++; 185 i ++;
186 } 186 }
187 return Invert; 187 return Invert;
188 } 188 }
189 CPDF_ApSettings CPDF_FormControl::GetMK(FX_BOOL bCreate) 189 CPDF_ApSettings CPDF_FormControl::GetMK(FX_BOOL bCreate)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } else { 270 } else {
271 return m_pField->GetAdditionalAction(); 271 return m_pField->GetAdditionalAction();
272 } 272 }
273 } 273 }
274 CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() 274 CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance()
275 { 275 {
276 if (m_pWidgetDict == NULL) { 276 if (m_pWidgetDict == NULL) {
277 return CFX_ByteString(); 277 return CFX_ByteString();
278 } 278 }
279 if (m_pWidgetDict->KeyExist("DA")) { 279 if (m_pWidgetDict->KeyExist("DA")) {
280 return m_pWidgetDict->GetString("DA"); 280 return m_pWidgetDict->GetStringAt("DA");
281 } else { 281 } else {
282 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA"); 282 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA");
283 if (pObj == NULL) { 283 if (pObj == NULL) {
284 return m_pField->m_pForm->GetDefaultAppearance(); 284 return m_pField->m_pForm->GetDefaultAppearance();
285 } 285 }
286 return pObj->GetString(); 286 return pObj->GetString();
287 } 287 }
288 } 288 }
289 289
290 CPDF_Font* CPDF_FormControl::GetDefaultControlFont() 290 CPDF_Font* CPDF_FormControl::GetDefaultControlFont()
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 458 }
459 return m_pDict->GetDict(FX_BSTRC("IF")); 459 return m_pDict->GetDict(FX_BSTRC("IF"));
460 } 460 }
461 int CPDF_ApSettings::GetTextPosition() 461 int CPDF_ApSettings::GetTextPosition()
462 { 462 {
463 if (m_pDict == NULL) { 463 if (m_pDict == NULL) {
464 return TEXTPOS_CAPTION; 464 return TEXTPOS_CAPTION;
465 } 465 }
466 return m_pDict->GetInteger(FX_BSTRC("TP"), TEXTPOS_CAPTION); 466 return m_pDict->GetInteger(FX_BSTRC("TP"), TEXTPOS_CAPTION);
467 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698