| 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/fpdfapi/fpdf_parser/include/cfdf_document.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h" |
| 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" |
| 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" |
| 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" |
| 13 #include "core/fpdfdoc/doc_utils.h" | 13 #include "core/fpdfdoc/doc_utils.h" |
| 14 #include "core/include/fpdfdoc/fpdf_doc.h" | 14 #include "core/include/fpdfdoc/fpdf_doc.h" |
| 15 | 15 |
| 16 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) { | 16 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) { |
| 17 FX_BOOL bUnison = FALSE; | 17 FX_BOOL bUnison = FALSE; |
| 18 if (pField->GetType() == CPDF_FormField::CheckBox) { | 18 if (pField->GetType() == CPDF_FormField::CheckBox) { |
| 19 bUnison = TRUE; | 19 bUnison = TRUE; |
| 20 } else { | 20 } else { |
| 21 FX_DWORD dwFlags = pField->GetFieldFlags(); | 21 uint32_t dwFlags = pField->GetFieldFlags(); |
| 22 bUnison = ((dwFlags & 0x2000000) != 0); | 22 bUnison = ((dwFlags & 0x2000000) != 0); |
| 23 } | 23 } |
| 24 return bUnison; | 24 return bUnison; |
| 25 } | 25 } |
| 26 CPDF_FormField::CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict) { | 26 CPDF_FormField::CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict) { |
| 27 m_pDict = pDict; | 27 m_pDict = pDict; |
| 28 m_Type = Unknown; | 28 m_Type = Unknown; |
| 29 m_pForm = pForm; | 29 m_pForm = pForm; |
| 30 m_pFont = NULL; | 30 m_pFont = NULL; |
| 31 m_FontSize = 0; | 31 m_FontSize = 0; |
| 32 SyncFieldFlags(); | 32 SyncFieldFlags(); |
| 33 } | 33 } |
| 34 CPDF_FormField::~CPDF_FormField() {} | 34 CPDF_FormField::~CPDF_FormField() {} |
| 35 void CPDF_FormField::SyncFieldFlags() { | 35 void CPDF_FormField::SyncFieldFlags() { |
| 36 CFX_ByteString type_name = FPDF_GetFieldAttr(m_pDict, "FT") | 36 CFX_ByteString type_name = FPDF_GetFieldAttr(m_pDict, "FT") |
| 37 ? FPDF_GetFieldAttr(m_pDict, "FT")->GetString() | 37 ? FPDF_GetFieldAttr(m_pDict, "FT")->GetString() |
| 38 : CFX_ByteString(); | 38 : CFX_ByteString(); |
| 39 FX_DWORD flags = FPDF_GetFieldAttr(m_pDict, "Ff") | 39 uint32_t flags = FPDF_GetFieldAttr(m_pDict, "Ff") |
| 40 ? FPDF_GetFieldAttr(m_pDict, "Ff")->GetInteger() | 40 ? FPDF_GetFieldAttr(m_pDict, "Ff")->GetInteger() |
| 41 : 0; | 41 : 0; |
| 42 m_Flags = 0; | 42 m_Flags = 0; |
| 43 if (flags & 1) { | 43 if (flags & 1) { |
| 44 m_Flags |= FORMFIELD_READONLY; | 44 m_Flags |= FORMFIELD_READONLY; |
| 45 } | 45 } |
| 46 if (flags & 2) { | 46 if (flags & 2) { |
| 47 m_Flags |= FORMFIELD_REQUIRED; | 47 m_Flags |= FORMFIELD_REQUIRED; |
| 48 } | 48 } |
| 49 if (flags & 4) { | 49 if (flags & 4) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 return pObj->GetUnicodeText(); | 255 return pObj->GetUnicodeText(); |
| 256 } | 256 } |
| 257 CFX_WideString CPDF_FormField::GetMappingName() { | 257 CFX_WideString CPDF_FormField::GetMappingName() { |
| 258 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM"); | 258 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM"); |
| 259 if (!pObj) { | 259 if (!pObj) { |
| 260 return L""; | 260 return L""; |
| 261 } | 261 } |
| 262 return pObj->GetUnicodeText(); | 262 return pObj->GetUnicodeText(); |
| 263 } | 263 } |
| 264 FX_DWORD CPDF_FormField::GetFieldFlags() { | 264 uint32_t CPDF_FormField::GetFieldFlags() { |
| 265 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "Ff"); | 265 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "Ff"); |
| 266 if (!pObj) { | 266 if (!pObj) { |
| 267 return 0; | 267 return 0; |
| 268 } | 268 } |
| 269 return pObj->GetInteger(); | 269 return pObj->GetInteger(); |
| 270 } | 270 } |
| 271 CFX_ByteString CPDF_FormField::GetDefaultStyle() { | 271 CFX_ByteString CPDF_FormField::GetDefaultStyle() { |
| 272 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DS"); | 272 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DS"); |
| 273 if (!pObj) { | 273 if (!pObj) { |
| 274 return ""; | 274 return ""; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 if (!pArray) | 530 if (!pArray) |
| 531 return FALSE; | 531 return FALSE; |
| 532 | 532 |
| 533 int iPos = -1; | 533 int iPos = -1; |
| 534 for (int j = 0; j < CountSelectedOptions(); j++) { | 534 for (int j = 0; j < CountSelectedOptions(); j++) { |
| 535 if (GetSelectedOptionIndex(j) == index) { | 535 if (GetSelectedOptionIndex(j) == index) { |
| 536 iPos = j; | 536 iPos = j; |
| 537 break; | 537 break; |
| 538 } | 538 } |
| 539 } | 539 } |
| 540 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) | 540 for (uint32_t i = 0; i < pArray->GetCount(); i++) |
| 541 if (pArray->GetElementValue(i)->GetUnicodeText() == opt_value && | 541 if (pArray->GetElementValue(i)->GetUnicodeText() == opt_value && |
| 542 (int)i == iPos) { | 542 (int)i == iPos) { |
| 543 return TRUE; | 543 return TRUE; |
| 544 } | 544 } |
| 545 return FALSE; | 545 return FALSE; |
| 546 } | 546 } |
| 547 FX_BOOL CPDF_FormField::SetItemSelection(int index, | 547 FX_BOOL CPDF_FormField::SetItemSelection(int index, |
| 548 FX_BOOL bSelected, | 548 FX_BOOL bSelected, |
| 549 FX_BOOL bNotify) { | 549 FX_BOOL bNotify) { |
| 550 ASSERT(GetType() == ComboBox || GetType() == ListBox); | 550 ASSERT(GetType() == ComboBox || GetType() == ListBox); |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 pFontDict = m_pForm->m_pFormDict->GetDictBy("DR") | 1088 pFontDict = m_pForm->m_pFormDict->GetDictBy("DR") |
| 1089 ->GetDictBy("Font") | 1089 ->GetDictBy("Font") |
| 1090 ->GetDictBy(font_name); | 1090 ->GetDictBy(font_name); |
| 1091 | 1091 |
| 1092 if (!pFontDict) { | 1092 if (!pFontDict) { |
| 1093 return; | 1093 return; |
| 1094 } | 1094 } |
| 1095 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); | 1095 m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); |
| 1096 m_FontSize = FX_atof(syntax.GetWord()); | 1096 m_FontSize = FX_atof(syntax.GetWord()); |
| 1097 } | 1097 } |
| OLD | NEW |