| 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/include/fpdfdoc/fpdf_doc.h" |     7 #include "core/include/fpdfdoc/fpdf_doc.h" | 
|     8 #include "doc_utils.h" |     8 #include "doc_utils.h" | 
|     9  |     9  | 
|    10 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) { |    10 FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) { | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   177       CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV"); |   177       CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV"); | 
|   178       if (!pRV && (csDValue == csValue)) { |   178       if (!pRV && (csDValue == csValue)) { | 
|   179         return FALSE; |   179         return FALSE; | 
|   180       } |   180       } | 
|   181       if (bNotify && m_pForm->m_pFormNotify) { |   181       if (bNotify && m_pForm->m_pFormNotify) { | 
|   182         int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csDValue); |   182         int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csDValue); | 
|   183         if (iRet < 0) { |   183         if (iRet < 0) { | 
|   184           return FALSE; |   184           return FALSE; | 
|   185         } |   185         } | 
|   186       } |   186       } | 
|   187       if (pDV == NULL) { |   187       if (pDV) { | 
|   188         m_pDict->RemoveAt("V"); |  | 
|   189         m_pDict->RemoveAt("RV"); |  | 
|   190       } else { |  | 
|   191         CPDF_Object* pClone = pDV->Clone(); |   188         CPDF_Object* pClone = pDV->Clone(); | 
|   192         if (pClone == NULL) { |   189         if (!pClone) { | 
|   193           return FALSE; |   190           return FALSE; | 
|   194         } |   191         } | 
|   195         m_pDict->SetAt("V", pClone); |   192         m_pDict->SetAt("V", pClone); | 
|   196         if (pRV) { |   193         if (pRV) { | 
|   197           CPDF_Object* pCloneR = pDV->Clone(); |   194           CPDF_Object* pCloneR = pDV->Clone(); | 
|   198           m_pDict->SetAt("RV", pCloneR); |   195           m_pDict->SetAt("RV", pCloneR); | 
|   199         } |   196         } | 
 |   197       } else { | 
 |   198         m_pDict->RemoveAt("V"); | 
 |   199         m_pDict->RemoveAt("RV"); | 
|   200       } |   200       } | 
|   201       if (bNotify && m_pForm->m_pFormNotify) { |   201       if (bNotify && m_pForm->m_pFormNotify) { | 
|   202         m_pForm->m_pFormNotify->AfterValueChange(this); |   202         m_pForm->m_pFormNotify->AfterValueChange(this); | 
|   203       } |   203       } | 
|   204       m_pForm->m_bUpdated = TRUE; |   204       m_pForm->m_bUpdated = TRUE; | 
|   205     } break; |   205     } break; | 
|   206   } |   206   } | 
|   207   return TRUE; |   207   return TRUE; | 
|   208 } |   208 } | 
|   209 int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) { |   209 int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) { | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|   234       return FIELDTYPE_TEXTFIELD; |   234       return FIELDTYPE_TEXTFIELD; | 
|   235     case Sign: |   235     case Sign: | 
|   236       return FIELDTYPE_SIGNATURE; |   236       return FIELDTYPE_SIGNATURE; | 
|   237     default: |   237     default: | 
|   238       break; |   238       break; | 
|   239   } |   239   } | 
|   240   return FIELDTYPE_UNKNOWN; |   240   return FIELDTYPE_UNKNOWN; | 
|   241 } |   241 } | 
|   242 CPDF_AAction CPDF_FormField::GetAdditionalAction() { |   242 CPDF_AAction CPDF_FormField::GetAdditionalAction() { | 
|   243   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "AA"); |   243   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "AA"); | 
|   244   if (pObj == NULL) { |   244   if (!pObj) { | 
|   245     return NULL; |   245     return NULL; | 
|   246   } |   246   } | 
|   247   return pObj->GetDict(); |   247   return pObj->GetDict(); | 
|   248 } |   248 } | 
|   249 CFX_WideString CPDF_FormField::GetAlternateName() { |   249 CFX_WideString CPDF_FormField::GetAlternateName() { | 
|   250   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU"); |   250   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU"); | 
|   251   if (pObj == NULL) { |   251   if (!pObj) { | 
|   252     return L""; |   252     return L""; | 
|   253   } |   253   } | 
|   254   return pObj->GetUnicodeText(); |   254   return pObj->GetUnicodeText(); | 
|   255 } |   255 } | 
|   256 CFX_WideString CPDF_FormField::GetMappingName() { |   256 CFX_WideString CPDF_FormField::GetMappingName() { | 
|   257   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM"); |   257   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM"); | 
|   258   if (pObj == NULL) { |   258   if (!pObj) { | 
|   259     return L""; |   259     return L""; | 
|   260   } |   260   } | 
|   261   return pObj->GetUnicodeText(); |   261   return pObj->GetUnicodeText(); | 
|   262 } |   262 } | 
|   263 FX_DWORD CPDF_FormField::GetFieldFlags() { |   263 FX_DWORD CPDF_FormField::GetFieldFlags() { | 
|   264   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "Ff"); |   264   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "Ff"); | 
|   265   if (pObj == NULL) { |   265   if (!pObj) { | 
|   266     return 0; |   266     return 0; | 
|   267   } |   267   } | 
|   268   return pObj->GetInteger(); |   268   return pObj->GetInteger(); | 
|   269 } |   269 } | 
|   270 CFX_ByteString CPDF_FormField::GetDefaultStyle() { |   270 CFX_ByteString CPDF_FormField::GetDefaultStyle() { | 
|   271   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DS"); |   271   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DS"); | 
|   272   if (pObj == NULL) { |   272   if (!pObj) { | 
|   273     return ""; |   273     return ""; | 
|   274   } |   274   } | 
|   275   return pObj->GetString(); |   275   return pObj->GetString(); | 
|   276 } |   276 } | 
|   277 CFX_WideString CPDF_FormField::GetRichTextString() { |   277 CFX_WideString CPDF_FormField::GetRichTextString() { | 
|   278   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "RV"); |   278   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "RV"); | 
|   279   if (pObj == NULL) { |   279   if (!pObj) { | 
|   280     return L""; |   280     return L""; | 
|   281   } |   281   } | 
|   282   return pObj->GetUnicodeText(); |   282   return pObj->GetUnicodeText(); | 
|   283 } |   283 } | 
|   284 CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) { |   284 CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) { | 
|   285   if (GetType() == CheckBox || GetType() == RadioButton) { |   285   if (GetType() == CheckBox || GetType() == RadioButton) { | 
|   286     return GetCheckValue(bDefault); |   286     return GetCheckValue(bDefault); | 
|   287   } |   287   } | 
|   288   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, bDefault ? "DV" : "V"); |   288   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, bDefault ? "DV" : "V"); | 
|   289   if (pValue == NULL) { |   289   if (!pValue) { | 
|   290     if (!bDefault) { |   290     if (!bDefault) { | 
|   291       if (m_Type == RichText) { |   291       if (m_Type == RichText) { | 
|   292         pValue = FPDF_GetFieldAttr(m_pDict, "V"); |   292         pValue = FPDF_GetFieldAttr(m_pDict, "V"); | 
|   293       } |   293       } | 
|   294       if (pValue == NULL && m_Type != Text) { |   294       if (!pValue && m_Type != Text) { | 
|   295         pValue = FPDF_GetFieldAttr(m_pDict, "DV"); |   295         pValue = FPDF_GetFieldAttr(m_pDict, "DV"); | 
|   296       } |   296       } | 
|   297     } |   297     } | 
|   298     if (pValue == NULL) { |   298     if (!pValue) { | 
|   299       return CFX_WideString(); |   299       return CFX_WideString(); | 
|   300     } |   300     } | 
|   301   } |   301   } | 
|   302   switch (pValue->GetType()) { |   302   switch (pValue->GetType()) { | 
|   303     case PDFOBJ_STRING: |   303     case PDFOBJ_STRING: | 
|   304     case PDFOBJ_STREAM: |   304     case PDFOBJ_STREAM: | 
|   305       return pValue->GetUnicodeText(); |   305       return pValue->GetUnicodeText(); | 
|   306     case PDFOBJ_ARRAY: |   306     case PDFOBJ_ARRAY: | 
|   307       pValue = pValue->AsArray()->GetElementValue(0); |   307       pValue = pValue->AsArray()->GetElementValue(0); | 
|   308       if (pValue) |   308       if (pValue) | 
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   500 FX_BOOL CPDF_FormField::IsItemSelected(int index) { |   500 FX_BOOL CPDF_FormField::IsItemSelected(int index) { | 
|   501   ASSERT(GetType() == ComboBox || GetType() == ListBox); |   501   ASSERT(GetType() == ComboBox || GetType() == ListBox); | 
|   502   if (index < 0 || index >= CountOptions()) { |   502   if (index < 0 || index >= CountOptions()) { | 
|   503     return FALSE; |   503     return FALSE; | 
|   504   } |   504   } | 
|   505   if (IsOptionSelected(index)) { |   505   if (IsOptionSelected(index)) { | 
|   506     return TRUE; |   506     return TRUE; | 
|   507   } |   507   } | 
|   508   CFX_WideString opt_value = GetOptionValue(index); |   508   CFX_WideString opt_value = GetOptionValue(index); | 
|   509   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); |   509   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); | 
|   510   if (pValue == NULL) { |   510   if (!pValue) { | 
|   511     pValue = FPDF_GetFieldAttr(m_pDict, "I"); |   511     pValue = FPDF_GetFieldAttr(m_pDict, "I"); | 
|   512     if (pValue == NULL) { |   512     if (!pValue) { | 
|   513       return FALSE; |   513       return FALSE; | 
|   514     } |   514     } | 
|   515   } |   515   } | 
|   516  |   516  | 
|   517   if (pValue->IsString()) |   517   if (pValue->IsString()) | 
|   518     return pValue->GetUnicodeText() == opt_value; |   518     return pValue->GetUnicodeText() == opt_value; | 
|   519  |   519  | 
|   520   if (pValue->IsNumber()) { |   520   if (pValue->IsNumber()) { | 
|   521     if (pValue->GetString().IsEmpty()) |   521     if (pValue->GetString().IsEmpty()) | 
|   522       return FALSE; |   522       return FALSE; | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   592         m_pDict->RemoveAt("I"); |   592         m_pDict->RemoveAt("I"); | 
|   593       } |   593       } | 
|   594     } |   594     } | 
|   595   } else { |   595   } else { | 
|   596     if (m_Type == ListBox) { |   596     if (m_Type == ListBox) { | 
|   597       SelectOption(index, TRUE); |   597       SelectOption(index, TRUE); | 
|   598       if (!(m_Flags & FORMLIST_MULTISELECT)) { |   598       if (!(m_Flags & FORMLIST_MULTISELECT)) { | 
|   599         m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); |   599         m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); | 
|   600       } else { |   600       } else { | 
|   601         CPDF_Array* pArray = CPDF_Array::Create(); |   601         CPDF_Array* pArray = CPDF_Array::Create(); | 
|   602         if (pArray == NULL) { |   602         if (!pArray) { | 
|   603           return FALSE; |   603           return FALSE; | 
|   604         } |   604         } | 
|   605         FX_BOOL bSelected; |   605         FX_BOOL bSelected; | 
|   606         int iCount = CountOptions(); |   606         int iCount = CountOptions(); | 
|   607         for (int i = 0; i < iCount; i++) { |   607         for (int i = 0; i < iCount; i++) { | 
|   608           if (i != index) { |   608           if (i != index) { | 
|   609             bSelected = IsItemSelected(i); |   609             bSelected = IsItemSelected(i); | 
|   610           } else { |   610           } else { | 
|   611             bSelected = TRUE; |   611             bSelected = TRUE; | 
|   612           } |   612           } | 
|   613           if (bSelected) { |   613           if (bSelected) { | 
|   614             opt_value = GetOptionValue(i); |   614             opt_value = GetOptionValue(i); | 
|   615             pArray->AddString(PDF_EncodeText(opt_value)); |   615             pArray->AddString(PDF_EncodeText(opt_value)); | 
|   616           } |   616           } | 
|   617         } |   617         } | 
|   618         m_pDict->SetAt("V", pArray); |   618         m_pDict->SetAt("V", pArray); | 
|   619       } |   619       } | 
|   620     } else if (m_Type == ComboBox) { |   620     } else if (m_Type == ComboBox) { | 
|   621       m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); |   621       m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); | 
|   622       CPDF_Array* pI = CPDF_Array::Create(); |   622       CPDF_Array* pI = CPDF_Array::Create(); | 
|   623       if (pI == NULL) { |   623       if (!pI) { | 
|   624         return FALSE; |   624         return FALSE; | 
|   625       } |   625       } | 
|   626       pI->AddInteger(index); |   626       pI->AddInteger(index); | 
|   627       m_pDict->SetAt("I", pI); |   627       m_pDict->SetAt("I", pI); | 
|   628     } |   628     } | 
|   629   } |   629   } | 
|   630   if (bNotify && m_pForm->m_pFormNotify) { |   630   if (bNotify && m_pForm->m_pFormNotify) { | 
|   631     if (GetType() == ListBox) { |   631     if (GetType() == ListBox) { | 
|   632       m_pForm->m_pFormNotify->AfterSelectionChange(this); |   632       m_pForm->m_pFormNotify->AfterSelectionChange(this); | 
|   633     } |   633     } | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|   648   } |   648   } | 
|   649   int iDVIndex = GetDefaultSelectedItem(); |   649   int iDVIndex = GetDefaultSelectedItem(); | 
|   650   if (iDVIndex < 0) { |   650   if (iDVIndex < 0) { | 
|   651     return FALSE; |   651     return FALSE; | 
|   652   } |   652   } | 
|   653   return (iDVIndex == index); |   653   return (iDVIndex == index); | 
|   654 } |   654 } | 
|   655 int CPDF_FormField::GetDefaultSelectedItem() { |   655 int CPDF_FormField::GetDefaultSelectedItem() { | 
|   656   ASSERT(GetType() == ComboBox || GetType() == ListBox); |   656   ASSERT(GetType() == ComboBox || GetType() == ListBox); | 
|   657   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "DV"); |   657   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "DV"); | 
|   658   if (pValue == NULL) { |   658   if (!pValue) { | 
|   659     return -1; |   659     return -1; | 
|   660   } |   660   } | 
|   661   CFX_WideString csDV = pValue->GetUnicodeText(); |   661   CFX_WideString csDV = pValue->GetUnicodeText(); | 
|   662   if (csDV.IsEmpty()) { |   662   if (csDV.IsEmpty()) { | 
|   663     return -1; |   663     return -1; | 
|   664   } |   664   } | 
|   665   int iCount = CountOptions(); |   665   int iCount = CountOptions(); | 
|   666   for (int i = 0; i < iCount; i++) { |   666   for (int i = 0; i < iCount; i++) { | 
|   667     if (csDV == GetOptionValue(i)) { |   667     if (csDV == GetOptionValue(i)) { | 
|   668       return i; |   668       return i; | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   731       return iStartIndex; |   731       return iStartIndex; | 
|   732     } |   732     } | 
|   733   } |   733   } | 
|   734   return -1; |   734   return -1; | 
|   735 } |   735 } | 
|   736 FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, |   736 FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, | 
|   737                                      FX_BOOL bChecked, |   737                                      FX_BOOL bChecked, | 
|   738                                      FX_BOOL bNotify) { |   738                                      FX_BOOL bNotify) { | 
|   739   ASSERT(GetType() == CheckBox || GetType() == RadioButton); |   739   ASSERT(GetType() == CheckBox || GetType() == RadioButton); | 
|   740   CPDF_FormControl* pControl = GetControl(iControlIndex); |   740   CPDF_FormControl* pControl = GetControl(iControlIndex); | 
|   741   if (pControl == NULL) { |   741   if (!pControl) { | 
|   742     return FALSE; |   742     return FALSE; | 
|   743   } |   743   } | 
|   744   if (!bChecked && pControl->IsChecked() == bChecked) { |   744   if (!bChecked && pControl->IsChecked() == bChecked) { | 
|   745     return FALSE; |   745     return FALSE; | 
|   746   } |   746   } | 
|   747   CFX_ByteArray statusArray; |   747   CFX_ByteArray statusArray; | 
|   748   if (bNotify && m_pForm->m_pFormNotify) { |   748   if (bNotify && m_pForm->m_pFormNotify) { | 
|   749     SaveCheckedFieldStatus(this, statusArray); |   749     SaveCheckedFieldStatus(this, statusArray); | 
|   750   } |   750   } | 
|   751   CFX_WideString csWExport = pControl->GetExportValue(); |   751   CFX_WideString csWExport = pControl->GetExportValue(); | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   843     } |   843     } | 
|   844   } |   844   } | 
|   845   if (bNotify && m_pForm->m_pFormNotify) { |   845   if (bNotify && m_pForm->m_pFormNotify) { | 
|   846     m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); |   846     m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); | 
|   847   } |   847   } | 
|   848   m_pForm->m_bUpdated = TRUE; |   848   m_pForm->m_bUpdated = TRUE; | 
|   849   return TRUE; |   849   return TRUE; | 
|   850 } |   850 } | 
|   851 int CPDF_FormField::GetTopVisibleIndex() { |   851 int CPDF_FormField::GetTopVisibleIndex() { | 
|   852   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI"); |   852   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI"); | 
|   853   if (pObj == NULL) { |   853   if (!pObj) { | 
|   854     return 0; |   854     return 0; | 
|   855   } |   855   } | 
|   856   return pObj->GetInteger(); |   856   return pObj->GetInteger(); | 
|   857 } |   857 } | 
|   858 int CPDF_FormField::CountSelectedOptions() { |   858 int CPDF_FormField::CountSelectedOptions() { | 
|   859   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I"); |   859   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I"); | 
|   860   if (pObj == NULL) { |   860   if (!pObj) { | 
|   861     return 0; |   861     return 0; | 
|   862   } |   862   } | 
|   863   CPDF_Array* pArray = pObj->GetArray(); |   863   CPDF_Array* pArray = pObj->GetArray(); | 
|   864   if (pArray == NULL) { |   864   if (!pArray) { | 
|   865     return 0; |   865     return 0; | 
|   866   } |   866   } | 
|   867   return (int)pArray->GetCount(); |   867   return (int)pArray->GetCount(); | 
|   868 } |   868 } | 
|   869 int CPDF_FormField::GetSelectedOptionIndex(int index) { |   869 int CPDF_FormField::GetSelectedOptionIndex(int index) { | 
|   870   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I"); |   870   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I"); | 
|   871   if (pObj == NULL) { |   871   if (!pObj) { | 
|   872     return -1; |   872     return -1; | 
|   873   } |   873   } | 
|   874   CPDF_Array* pArray = pObj->GetArray(); |   874   CPDF_Array* pArray = pObj->GetArray(); | 
|   875   if (pArray == NULL) { |   875   if (!pArray) { | 
|   876     return -1; |   876     return -1; | 
|   877   } |   877   } | 
|   878   int iCount = (int)pArray->GetCount(); |   878   int iCount = (int)pArray->GetCount(); | 
|   879   if (iCount > 0 && index < iCount) { |   879   if (iCount > 0 && index < iCount) { | 
|   880     return pArray->GetInteger(index); |   880     return pArray->GetInteger(index); | 
|   881   } |   881   } | 
|   882   return -1; |   882   return -1; | 
|   883 } |   883 } | 
|   884 FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) { |   884 FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) { | 
|   885   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I"); |   885   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I"); | 
|   886   if (pObj == NULL) { |   886   if (!pObj) { | 
|   887     return FALSE; |   887     return FALSE; | 
|   888   } |   888   } | 
|   889   CPDF_Array* pArray = pObj->GetArray(); |   889   CPDF_Array* pArray = pObj->GetArray(); | 
|   890   if (pArray == NULL) { |   890   if (!pArray) { | 
|   891     return FALSE; |   891     return FALSE; | 
|   892   } |   892   } | 
|   893   int iCount = (int)pArray->GetCount(); |   893   int iCount = (int)pArray->GetCount(); | 
|   894   for (int i = 0; i < iCount; i++) { |   894   for (int i = 0; i < iCount; i++) { | 
|   895     if (pArray->GetInteger(i) == iOptIndex) { |   895     if (pArray->GetInteger(i) == iOptIndex) { | 
|   896       return TRUE; |   896       return TRUE; | 
|   897     } |   897     } | 
|   898   } |   898   } | 
|   899   return FALSE; |   899   return FALSE; | 
|   900 } |   900 } | 
|   901 FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, |   901 FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, | 
|   902                                      FX_BOOL bSelected, |   902                                      FX_BOOL bSelected, | 
|   903                                      FX_BOOL bNotify) { |   903                                      FX_BOOL bNotify) { | 
|   904   CPDF_Array* pArray = m_pDict->GetArray("I"); |   904   CPDF_Array* pArray = m_pDict->GetArray("I"); | 
|   905   if (pArray == NULL) { |   905   if (!pArray) { | 
|   906     if (!bSelected) { |   906     if (!bSelected) { | 
|   907       return TRUE; |   907       return TRUE; | 
|   908     } |   908     } | 
|   909     pArray = CPDF_Array::Create(); |   909     pArray = CPDF_Array::Create(); | 
|   910     if (pArray == NULL) { |   910     if (!pArray) { | 
|   911       return FALSE; |   911       return FALSE; | 
|   912     } |   912     } | 
|   913     m_pDict->SetAt("I", pArray); |   913     m_pDict->SetAt("I", pArray); | 
|   914   } |   914   } | 
|   915   FX_BOOL bReturn = FALSE; |   915   FX_BOOL bReturn = FALSE; | 
|   916   for (int i = 0; i < (int)pArray->GetCount(); i++) { |   916   for (int i = 0; i < (int)pArray->GetCount(); i++) { | 
|   917     int iFind = pArray->GetInteger(i); |   917     int iFind = pArray->GetInteger(i); | 
|   918     if (iFind == iOptIndex) { |   918     if (iFind == iOptIndex) { | 
|   919       if (bSelected) { |   919       if (bSelected) { | 
|   920         return TRUE; |   920         return TRUE; | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|   946           iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); |   946           iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); | 
|   947         } |   947         } | 
|   948         if (GetType() == ComboBox) { |   948         if (GetType() == ComboBox) { | 
|   949           iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); |   949           iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); | 
|   950         } |   950         } | 
|   951         if (iRet < 0) { |   951         if (iRet < 0) { | 
|   952           return FALSE; |   952           return FALSE; | 
|   953         } |   953         } | 
|   954       } |   954       } | 
|   955       CPDF_Number* pNum = CPDF_Number::Create(iOptIndex); |   955       CPDF_Number* pNum = CPDF_Number::Create(iOptIndex); | 
|   956       if (pNum == NULL) { |   956       if (!pNum) { | 
|   957         return FALSE; |   957         return FALSE; | 
|   958       } |   958       } | 
|   959       pArray->InsertAt(i, pNum); |   959       pArray->InsertAt(i, pNum); | 
|   960       bReturn = TRUE; |   960       bReturn = TRUE; | 
|   961       break; |   961       break; | 
|   962     } |   962     } | 
|   963   } |   963   } | 
|   964   if (!bReturn) { |   964   if (!bReturn) { | 
|   965     if (bSelected) { |   965     if (bSelected) { | 
|   966       pArray->AddInteger(iOptIndex); |   966       pArray->AddInteger(iOptIndex); | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1023   } |  1023   } | 
|  1024   CPDF_SimpleParser syntax(DA); |  1024   CPDF_SimpleParser syntax(DA); | 
|  1025   syntax.FindTagParam("Tf", 2); |  1025   syntax.FindTagParam("Tf", 2); | 
|  1026   CFX_ByteString font_name = syntax.GetWord(); |  1026   CFX_ByteString font_name = syntax.GetWord(); | 
|  1027   CPDF_Dictionary* pFontDict = NULL; |  1027   CPDF_Dictionary* pFontDict = NULL; | 
|  1028   if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDict("DR") && |  1028   if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDict("DR") && | 
|  1029       m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")) |  1029       m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")) | 
|  1030     pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict( |  1030     pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict( | 
|  1031         font_name); |  1031         font_name); | 
|  1032  |  1032  | 
|  1033   if (pFontDict == NULL) { |  1033   if (!pFontDict) { | 
|  1034     return; |  1034     return; | 
|  1035   } |  1035   } | 
|  1036   m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); |  1036   m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); | 
|  1037   m_FontSize = FX_atof(syntax.GetWord()); |  1037   m_FontSize = FX_atof(syntax.GetWord()); | 
|  1038 } |  1038 } | 
| OLD | NEW |