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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 auto subdict_it = pSubDict->begin(); | 72 auto subdict_it = pSubDict->begin(); |
73 while (subdict_it != pSubDict->end()) { | 73 while (subdict_it != pSubDict->end()) { |
74 const CFX_ByteString& csKey2 = subdict_it->first; | 74 const CFX_ByteString& csKey2 = subdict_it->first; |
75 CPDF_Object* pObj2 = subdict_it->second; | 75 CPDF_Object* pObj2 = subdict_it->second; |
76 ++subdict_it; | 76 ++subdict_it; |
77 if (!pObj2) { | 77 if (!pObj2) { |
78 continue; | 78 continue; |
79 } | 79 } |
80 if (csKey2 != "Off") { | 80 if (csKey2 != "Off") { |
81 pSubDict->ReplaceKey(csKey2, csValue); | 81 pSubDict->ReplaceKey(csKey2.AsByteStringC(), csValue.AsByteStringC()); |
82 break; | 82 break; |
83 } | 83 } |
84 } | 84 } |
85 } | 85 } |
86 } | 86 } |
87 CFX_ByteString CPDF_FormControl::GetCheckedAPState() { | 87 CFX_ByteString CPDF_FormControl::GetCheckedAPState() { |
88 ASSERT(GetType() == CPDF_FormField::CheckBox || | 88 ASSERT(GetType() == CPDF_FormField::CheckBox || |
89 GetType() == CPDF_FormField::RadioButton); | 89 GetType() == CPDF_FormField::RadioButton); |
90 CFX_ByteString csOn = GetOnStateName(); | 90 CFX_ByteString csOn = GetOnStateName(); |
91 if (GetType() == CPDF_FormField::RadioButton || | 91 if (GetType() == CPDF_FormField::RadioButton || |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 195 } |
196 return Invert; | 196 return Invert; |
197 } | 197 } |
198 | 198 |
199 CPDF_ApSettings CPDF_FormControl::GetMK() const { | 199 CPDF_ApSettings CPDF_FormControl::GetMK() const { |
200 return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDictBy("MK") | 200 return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDictBy("MK") |
201 : nullptr); | 201 : nullptr); |
202 } | 202 } |
203 | 203 |
204 bool CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) const { | 204 bool CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) const { |
205 return GetMK().HasMKEntry(csEntry); | 205 return GetMK().HasMKEntry(csEntry.AsByteStringC()); |
206 } | 206 } |
207 | 207 |
208 int CPDF_FormControl::GetRotation() { | 208 int CPDF_FormControl::GetRotation() { |
209 return GetMK().GetRotation(); | 209 return GetMK().GetRotation(); |
210 } | 210 } |
211 | 211 |
212 FX_ARGB CPDF_FormControl::GetColor(int& iColorType, CFX_ByteString csEntry) { | 212 FX_ARGB CPDF_FormControl::GetColor(int& iColorType, CFX_ByteString csEntry) { |
213 return GetMK().GetColor(iColorType, csEntry); | 213 return GetMK().GetColor(iColorType, csEntry.AsByteStringC()); |
214 } | 214 } |
215 | 215 |
216 FX_FLOAT CPDF_FormControl::GetOriginalColor(int index, CFX_ByteString csEntry) { | 216 FX_FLOAT CPDF_FormControl::GetOriginalColor(int index, CFX_ByteString csEntry) { |
217 return GetMK().GetOriginalColor(index, csEntry); | 217 return GetMK().GetOriginalColor(index, csEntry.AsByteStringC()); |
218 } | 218 } |
219 | 219 |
220 void CPDF_FormControl::GetOriginalColor(int& iColorType, | 220 void CPDF_FormControl::GetOriginalColor(int& iColorType, |
221 FX_FLOAT fc[4], | 221 FX_FLOAT fc[4], |
222 CFX_ByteString csEntry) { | 222 CFX_ByteString csEntry) { |
223 GetMK().GetOriginalColor(iColorType, fc, csEntry); | 223 GetMK().GetOriginalColor(iColorType, fc, csEntry.AsByteStringC()); |
224 } | 224 } |
225 CFX_WideString CPDF_FormControl::GetCaption(CFX_ByteString csEntry) { | 225 CFX_WideString CPDF_FormControl::GetCaption(CFX_ByteString csEntry) { |
226 return GetMK().GetCaption(csEntry); | 226 return GetMK().GetCaption(csEntry.AsByteStringC()); |
227 } | 227 } |
228 | 228 |
229 CPDF_Stream* CPDF_FormControl::GetIcon(CFX_ByteString csEntry) { | 229 CPDF_Stream* CPDF_FormControl::GetIcon(CFX_ByteString csEntry) { |
230 return GetMK().GetIcon(csEntry); | 230 return GetMK().GetIcon(csEntry.AsByteStringC()); |
231 } | 231 } |
232 | 232 |
233 CPDF_IconFit CPDF_FormControl::GetIconFit() { | 233 CPDF_IconFit CPDF_FormControl::GetIconFit() { |
234 return GetMK().GetIconFit(); | 234 return GetMK().GetIconFit(); |
235 } | 235 } |
236 | 236 |
237 int CPDF_FormControl::GetTextPosition() { | 237 int CPDF_FormControl::GetTextPosition() { |
238 return GetMK().GetTextPosition(); | 238 return GetMK().GetTextPosition(); |
239 } | 239 } |
240 | 240 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 CFX_ByteString csFontNameTag; | 279 CFX_ByteString csFontNameTag; |
280 FX_FLOAT fFontSize; | 280 FX_FLOAT fFontSize; |
281 cDA.GetFont(csFontNameTag, fFontSize); | 281 cDA.GetFont(csFontNameTag, fFontSize); |
282 if (csFontNameTag.IsEmpty()) | 282 if (csFontNameTag.IsEmpty()) |
283 return nullptr; | 283 return nullptr; |
284 | 284 |
285 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); | 285 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); |
286 if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { | 286 if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { |
287 CPDF_Dictionary* pFonts = pDict->GetDictBy("Font"); | 287 CPDF_Dictionary* pFonts = pDict->GetDictBy("Font"); |
288 if (pFonts) { | 288 if (pFonts) { |
289 CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag); | 289 CPDF_Dictionary* pElement = |
| 290 pFonts->GetDictBy(csFontNameTag.AsByteStringC()); |
290 if (pElement) { | 291 if (pElement) { |
291 CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); | 292 CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); |
292 if (pFont) { | 293 if (pFont) { |
293 return pFont; | 294 return pFont; |
294 } | 295 } |
295 } | 296 } |
296 } | 297 } |
297 } | 298 } |
298 if (CPDF_Font* pFormFont = m_pField->m_pForm->GetFormFont(csFontNameTag)) | 299 if (CPDF_Font* pFormFont = m_pField->m_pForm->GetFormFont(csFontNameTag)) |
299 return pFormFont; | 300 return pFormFont; |
300 | 301 |
301 CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDictBy("P"); | 302 CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDictBy("P"); |
302 pObj = FPDF_GetFieldAttr(pPageDict, "Resources"); | 303 pObj = FPDF_GetFieldAttr(pPageDict, "Resources"); |
303 if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { | 304 if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { |
304 CPDF_Dictionary* pFonts = pDict->GetDictBy("Font"); | 305 CPDF_Dictionary* pFonts = pDict->GetDictBy("Font"); |
305 if (pFonts) { | 306 if (pFonts) { |
306 CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag); | 307 CPDF_Dictionary* pElement = |
| 308 pFonts->GetDictBy(csFontNameTag.AsByteStringC()); |
307 if (pElement) { | 309 if (pElement) { |
308 CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); | 310 CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); |
309 if (pFont) { | 311 if (pFont) { |
310 return pFont; | 312 return pFont; |
311 } | 313 } |
312 } | 314 } |
313 } | 315 } |
314 } | 316 } |
315 return nullptr; | 317 return nullptr; |
316 } | 318 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 } | 428 } |
427 | 429 |
428 CPDF_IconFit CPDF_ApSettings::GetIconFit() const { | 430 CPDF_IconFit CPDF_ApSettings::GetIconFit() const { |
429 return CPDF_IconFit(m_pDict ? m_pDict->GetDictBy("IF") : nullptr); | 431 return CPDF_IconFit(m_pDict ? m_pDict->GetDictBy("IF") : nullptr); |
430 } | 432 } |
431 | 433 |
432 int CPDF_ApSettings::GetTextPosition() const { | 434 int CPDF_ApSettings::GetTextPosition() const { |
433 return m_pDict ? m_pDict->GetIntegerBy("TP", TEXTPOS_CAPTION) | 435 return m_pDict ? m_pDict->GetIntegerBy("TP", TEXTPOS_CAPTION) |
434 : TEXTPOS_CAPTION; | 436 : TEXTPOS_CAPTION; |
435 } | 437 } |
OLD | NEW |