| 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" | 
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 298     } | 298     } | 
| 299     if (!pValue) { | 299     if (!pValue) { | 
| 300       return CFX_WideString(); | 300       return CFX_WideString(); | 
| 301     } | 301     } | 
| 302   } | 302   } | 
| 303   switch (pValue->GetType()) { | 303   switch (pValue->GetType()) { | 
| 304     case CPDF_Object::STRING: | 304     case CPDF_Object::STRING: | 
| 305     case CPDF_Object::STREAM: | 305     case CPDF_Object::STREAM: | 
| 306       return pValue->GetUnicodeText(); | 306       return pValue->GetUnicodeText(); | 
| 307     case CPDF_Object::ARRAY: | 307     case CPDF_Object::ARRAY: | 
| 308       pValue = pValue->AsArray()->GetElementValue(0); | 308       pValue = pValue->AsArray()->GetDirectObjectAt(0); | 
| 309       if (pValue) | 309       if (pValue) | 
| 310         return pValue->GetUnicodeText(); | 310         return pValue->GetUnicodeText(); | 
| 311       break; | 311       break; | 
| 312     default: | 312     default: | 
| 313       break; | 313       break; | 
| 314   } | 314   } | 
| 315   return CFX_WideString(); | 315   return CFX_WideString(); | 
| 316 } | 316 } | 
| 317 CFX_WideString CPDF_FormField::GetValue() { | 317 CFX_WideString CPDF_FormField::GetValue() { | 
| 318   return GetValue(FALSE); | 318   return GetValue(FALSE); | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 440   CFX_WideString sel_value; | 440   CFX_WideString sel_value; | 
| 441   if (pValue->IsString()) { | 441   if (pValue->IsString()) { | 
| 442     if (index != 0) | 442     if (index != 0) | 
| 443       return -1; | 443       return -1; | 
| 444     sel_value = pValue->GetUnicodeText(); | 444     sel_value = pValue->GetUnicodeText(); | 
| 445   } else { | 445   } else { | 
| 446     CPDF_Array* pArray = pValue->AsArray(); | 446     CPDF_Array* pArray = pValue->AsArray(); | 
| 447     if (!pArray || index < 0) | 447     if (!pArray || index < 0) | 
| 448       return -1; | 448       return -1; | 
| 449 | 449 | 
| 450     CPDF_Object* elementValue = pArray->GetElementValue(index); | 450     CPDF_Object* elementValue = pArray->GetDirectObjectAt(index); | 
| 451     sel_value = | 451     sel_value = | 
| 452         elementValue ? elementValue->GetUnicodeText() : CFX_WideString(); | 452         elementValue ? elementValue->GetUnicodeText() : CFX_WideString(); | 
| 453   } | 453   } | 
| 454   if (index < CountSelectedOptions()) { | 454   if (index < CountSelectedOptions()) { | 
| 455     int iOptIndex = GetSelectedOptionIndex(index); | 455     int iOptIndex = GetSelectedOptionIndex(index); | 
| 456     CFX_WideString csOpt = GetOptionValue(iOptIndex); | 456     CFX_WideString csOpt = GetOptionValue(iOptIndex); | 
| 457     if (csOpt == sel_value) { | 457     if (csOpt == sel_value) { | 
| 458       return iOptIndex; | 458       return iOptIndex; | 
| 459     } | 459     } | 
| 460   } | 460   } | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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 (uint32_t 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->GetDirectObjectAt(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); | 
| 551   if (index < 0 || index >= CountOptions()) { | 551   if (index < 0 || index >= CountOptions()) { | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 684 } | 684 } | 
| 685 int CPDF_FormField::CountOptions() { | 685 int CPDF_FormField::CountOptions() { | 
| 686   CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt")); | 686   CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt")); | 
| 687   return pArray ? pArray->GetCount() : 0; | 687   return pArray ? pArray->GetCount() : 0; | 
| 688 } | 688 } | 
| 689 CFX_WideString CPDF_FormField::GetOptionText(int index, int sub_index) { | 689 CFX_WideString CPDF_FormField::GetOptionText(int index, int sub_index) { | 
| 690   CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt")); | 690   CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt")); | 
| 691   if (!pArray) | 691   if (!pArray) | 
| 692     return CFX_WideString(); | 692     return CFX_WideString(); | 
| 693 | 693 | 
| 694   CPDF_Object* pOption = pArray->GetElementValue(index); | 694   CPDF_Object* pOption = pArray->GetDirectObjectAt(index); | 
| 695   if (!pOption) | 695   if (!pOption) | 
| 696     return CFX_WideString(); | 696     return CFX_WideString(); | 
| 697   if (CPDF_Array* pOptionArray = pOption->AsArray()) | 697   if (CPDF_Array* pOptionArray = pOption->AsArray()) | 
| 698     pOption = pOptionArray->GetElementValue(sub_index); | 698     pOption = pOptionArray->GetDirectObjectAt(sub_index); | 
| 699 | 699 | 
| 700   CPDF_String* pString = ToString(pOption); | 700   CPDF_String* pString = ToString(pOption); | 
| 701   return pString ? pString->GetUnicodeText() : CFX_WideString(); | 701   return pString ? pString->GetUnicodeText() : CFX_WideString(); | 
| 702 } | 702 } | 
| 703 CFX_WideString CPDF_FormField::GetOptionLabel(int index) { | 703 CFX_WideString CPDF_FormField::GetOptionLabel(int index) { | 
| 704   return GetOptionText(index, 1); | 704   return GetOptionText(index, 1); | 
| 705 } | 705 } | 
| 706 CFX_WideString CPDF_FormField::GetOptionValue(int index) { | 706 CFX_WideString CPDF_FormField::GetOptionValue(int index) { | 
| 707   return GetOptionText(index, 0); | 707   return GetOptionText(index, 0); | 
| 708 } | 708 } | 
| (...skipping 379 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 | 
|---|