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 "../../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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)->GetString(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 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->GetString("AS"); |
121 return csAS == csOn; | 121 return csAS == csOn; |
122 } | 122 } |
123 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(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->GetString("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 } |
149 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Annot::Appeara
nceMode mode); | 149 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Annot::Appeara
nceMode mode); |
150 void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, CFX_AffineMatrix*
pMatrix, CPDF_Page* pPage, | 150 void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, CFX_AffineMatrix*
pMatrix, CPDF_Page* pPage, |
151 CPDF_Annot::AppearanceMode mode, const CPDF_R
enderOptions* pOptions) | 151 CPDF_Annot::AppearanceMode mode, const CPDF_R
enderOptions* pOptions) |
152 { | 152 { |
153 if (m_pWidgetDict->GetInteger("F") & ANNOTFLAG_HIDDEN) { | 153 if (m_pWidgetDict->GetInteger("F") & ANNOTFLAG_HIDDEN) { |
154 return; | 154 return; |
155 } | 155 } |
156 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode); | 156 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode); |
157 if (pStream == NULL) { | 157 if (pStream == NULL) { |
(...skipping 21 matching lines...) Expand all Loading... |
179 CFX_ByteString csH = m_pWidgetDict->GetString("H", "I"); | 179 CFX_ByteString csH = m_pWidgetDict->GetString("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(bool bCreate) | 189 CPDF_ApSettings CPDF_FormControl::GetMK(FX_BOOL bCreate) |
190 { | 190 { |
191 if (!m_pWidgetDict) { | 191 if (!m_pWidgetDict) { |
192 return NULL; | 192 return NULL; |
193 } | 193 } |
194 CPDF_ApSettings mk = m_pWidgetDict->GetDict(FX_BSTRC("MK")); | 194 CPDF_ApSettings mk = m_pWidgetDict->GetDict(FX_BSTRC("MK")); |
195 if (!mk && bCreate) { | 195 if (!mk && bCreate) { |
196 mk = CPDF_Dictionary::Create(); | 196 mk = CPDF_Dictionary::Create(); |
197 if (mk == NULL) { | 197 if (mk == NULL) { |
198 return NULL; | 198 return NULL; |
199 } | 199 } |
200 m_pWidgetDict->SetAt(FX_BSTRC("MK"), mk); | 200 m_pWidgetDict->SetAt(FX_BSTRC("MK"), mk); |
201 } | 201 } |
202 return mk; | 202 return mk; |
203 } | 203 } |
204 bool CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) | 204 FX_BOOL CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) |
205 { | 205 { |
206 CPDF_ApSettings mk = GetMK(false); | 206 CPDF_ApSettings mk = GetMK(FALSE); |
207 return mk.HasMKEntry(csEntry); | 207 return mk.HasMKEntry(csEntry); |
208 } | 208 } |
209 int CPDF_FormControl::GetRotation() | 209 int CPDF_FormControl::GetRotation() |
210 { | 210 { |
211 CPDF_ApSettings mk = GetMK(false); | 211 CPDF_ApSettings mk = GetMK(FALSE); |
212 return mk.GetRotation(); | 212 return mk.GetRotation(); |
213 } | 213 } |
214 FX_ARGB CPDF_FormControl::GetColor(int& iColorType, CFX_ByteString csEntry) | 214 FX_ARGB CPDF_FormControl::GetColor(int& iColorType, CFX_ByteString csEntry) |
215 { | 215 { |
216 CPDF_ApSettings mk = GetMK(false); | 216 CPDF_ApSettings mk = GetMK(FALSE); |
217 return mk.GetColor(iColorType, csEntry); | 217 return mk.GetColor(iColorType, csEntry); |
218 } | 218 } |
219 FX_FLOAT CPDF_FormControl::GetOriginalColor(int index, CFX_ByteString csEntry) | 219 FX_FLOAT CPDF_FormControl::GetOriginalColor(int index, CFX_ByteString csEntry) |
220 { | 220 { |
221 CPDF_ApSettings mk = GetMK(false); | 221 CPDF_ApSettings mk = GetMK(FALSE); |
222 return mk.GetOriginalColor(index, csEntry); | 222 return mk.GetOriginalColor(index, csEntry); |
223 } | 223 } |
224 void CPDF_FormControl::GetOriginalColor(int& iColorType, FX_FLOAT fc[4], CFX_Byt
eString csEntry) | 224 void CPDF_FormControl::GetOriginalColor(int& iColorType, FX_FLOAT fc[4], CFX_Byt
eString csEntry) |
225 { | 225 { |
226 CPDF_ApSettings mk = GetMK(false); | 226 CPDF_ApSettings mk = GetMK(FALSE); |
227 mk.GetOriginalColor(iColorType, fc, csEntry); | 227 mk.GetOriginalColor(iColorType, fc, csEntry); |
228 } | 228 } |
229 CFX_WideString CPDF_FormControl::GetCaption(CFX_ByteString csEntry) | 229 CFX_WideString CPDF_FormControl::GetCaption(CFX_ByteString csEntry) |
230 { | 230 { |
231 CPDF_ApSettings mk = GetMK(false); | 231 CPDF_ApSettings mk = GetMK(FALSE); |
232 return mk.GetCaption(csEntry); | 232 return mk.GetCaption(csEntry); |
233 } | 233 } |
234 CPDF_Stream* CPDF_FormControl::GetIcon(CFX_ByteString csEntry) | 234 CPDF_Stream* CPDF_FormControl::GetIcon(CFX_ByteString csEntry) |
235 { | 235 { |
236 CPDF_ApSettings mk = GetMK(false); | 236 CPDF_ApSettings mk = GetMK(FALSE); |
237 return mk.GetIcon(csEntry); | 237 return mk.GetIcon(csEntry); |
238 } | 238 } |
239 CPDF_IconFit CPDF_FormControl::GetIconFit() | 239 CPDF_IconFit CPDF_FormControl::GetIconFit() |
240 { | 240 { |
241 CPDF_ApSettings mk = GetMK(false); | 241 CPDF_ApSettings mk = GetMK(FALSE); |
242 return mk.GetIconFit(); | 242 return mk.GetIconFit(); |
243 } | 243 } |
244 int CPDF_FormControl::GetTextPosition() | 244 int CPDF_FormControl::GetTextPosition() |
245 { | 245 { |
246 CPDF_ApSettings mk = GetMK(false); | 246 CPDF_ApSettings mk = GetMK(FALSE); |
247 return mk.GetTextPosition(); | 247 return mk.GetTextPosition(); |
248 } | 248 } |
249 CPDF_Action CPDF_FormControl::GetAction() | 249 CPDF_Action CPDF_FormControl::GetAction() |
250 { | 250 { |
251 if (!m_pWidgetDict) { | 251 if (!m_pWidgetDict) { |
252 return CPDF_Action(); | 252 return CPDF_Action(); |
253 } | 253 } |
254 if (m_pWidgetDict->KeyExist("A")) { | 254 if (m_pWidgetDict->KeyExist("A")) { |
255 return CPDF_Action(m_pWidgetDict->GetDict("A")); | 255 return CPDF_Action(m_pWidgetDict->GetDict("A")); |
256 } | 256 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 336 } |
337 if (m_pWidgetDict->KeyExist("Q")) { | 337 if (m_pWidgetDict->KeyExist("Q")) { |
338 return m_pWidgetDict->GetInteger("Q", 0); | 338 return m_pWidgetDict->GetInteger("Q", 0); |
339 } | 339 } |
340 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); | 340 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); |
341 if (pObj == NULL) { | 341 if (pObj == NULL) { |
342 return m_pField->m_pForm->GetFormAlignment(); | 342 return m_pField->m_pForm->GetFormAlignment(); |
343 } | 343 } |
344 return pObj->GetInteger(); | 344 return pObj->GetInteger(); |
345 } | 345 } |
346 bool CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry) | 346 FX_BOOL CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry) |
347 { | 347 { |
348 if (m_pDict == NULL) { | 348 if (m_pDict == NULL) { |
349 return false; | 349 return FALSE; |
350 } | 350 } |
351 return m_pDict->KeyExist(csEntry); | 351 return m_pDict->KeyExist(csEntry); |
352 } | 352 } |
353 int CPDF_ApSettings::GetRotation() | 353 int CPDF_ApSettings::GetRotation() |
354 { | 354 { |
355 if (m_pDict == NULL) { | 355 if (m_pDict == NULL) { |
356 return 0; | 356 return 0; |
357 } | 357 } |
358 return m_pDict->GetInteger(FX_BSTRC("R")); | 358 return m_pDict->GetInteger(FX_BSTRC("R")); |
359 } | 359 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 } | 455 } |
456 return m_pDict->GetDict(FX_BSTRC("IF")); | 456 return m_pDict->GetDict(FX_BSTRC("IF")); |
457 } | 457 } |
458 int CPDF_ApSettings::GetTextPosition() | 458 int CPDF_ApSettings::GetTextPosition() |
459 { | 459 { |
460 if (m_pDict == NULL) { | 460 if (m_pDict == NULL) { |
461 return TEXTPOS_CAPTION; | 461 return TEXTPOS_CAPTION; |
462 } | 462 } |
463 return m_pDict->GetInteger(FX_BSTRC("TP"), TEXTPOS_CAPTION); | 463 return m_pDict->GetInteger(FX_BSTRC("TP"), TEXTPOS_CAPTION); |
464 } | 464 } |
OLD | NEW |