CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) const { if (GetType() == CheckBox || GetType() == RadioButton) return GetCheckValue(bDefault); CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, bDefault ? "DV" : "V"); if (!pValue) { if (!bDefault) { if (m_Type == RichText) { pValue = FPDF_GetFieldAttr(m_pDict, "V"); } if (!pValue && m_Type != Text) { pValue = FPDF_GetFieldAttr(m_pDict, "DV"); } } if (!pValue) return CFX_WideString(); } switch (pValue->GetType()) { case CPDF_Object::STRING: case CPDF_Object::STREAM: return pValue->GetUnicodeText(); case CPDF_Object::ARRAY: pValue = pValue->AsArray()->GetDirectObjectAt(0); if (pValue) return pValue->GetUnicodeText(); break; default: break; } return CFX_WideString(); }
CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) { if (GetType() == CheckBox || GetType() == RadioButton) { return GetCheckValue(bDefault); } CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, bDefault ? "DV" : "V"); if (pValue == NULL) { if (!bDefault) { if (m_Type == RichText) { pValue = FPDF_GetFieldAttr(m_pDict, "V"); } if (pValue == NULL && m_Type != Text) { pValue = FPDF_GetFieldAttr(m_pDict, "DV"); } } if (pValue == NULL) { return CFX_WideString(); } } switch (pValue->GetType()) { case PDFOBJ_STRING: case PDFOBJ_STREAM: return pValue->GetUnicodeText(); case PDFOBJ_ARRAY: pValue = ((CPDF_Array*)pValue)->GetElementValue(0); return pValue->GetUnicodeText(); break; } return CFX_WideString(); }
CFX_WideString CPDF_FormField::GetMappingName() const { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM"); if (!pObj) { return L""; } return pObj->GetUnicodeText(); }
CFX_WideString CPDF_FormField::GetAlternateName() { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU"); if (!pObj) { return L""; } return pObj->GetUnicodeText(); }
CFX_WideString CPDF_FormField::GetRichTextString() const { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "RV"); if (!pObj) { return L""; } return pObj->GetUnicodeText(); }
CFX_WideString CPDF_Dictionary::GetUnicodeText(FX_BSTR key, CFX_CharMap* pCharMap) const { CPDF_Object* p = NULL; m_Map.Lookup(key, (void*&)p); if (p) { if(p->GetType() == PDFOBJ_REFERENCE) { p = ((CPDF_Reference*)p)->GetDirect(); if (p) { return p->GetUnicodeText(pCharMap); } } else { return p->GetUnicodeText(pCharMap); } } return CFX_WideString(); }
CFX_WideString CPDF_Dictionary::GetUnicodeText(const CFX_ByteStringC& key, CFX_CharMap* pCharMap) const { CPDF_Object* p = GetElement(key); if (CPDF_Reference* pRef = ToReference(p)) p = pRef->GetDirect(); return p ? p->GetUnicodeText(pCharMap) : CFX_WideString(); }
CFX_WideString CPDF_Action::GetJavaScript() const { CFX_WideString csJS; if (!m_pDict) { return csJS; } CPDF_Object* pJS = m_pDict->GetElementValue("JS"); return pJS ? pJS->GetUnicodeText() : csJS; }
CFX_WideString CPDF_Action::GetJavaScript() const { CFX_WideString csJS; if (!m_pDict) return csJS; CPDF_Object* pJS = m_pDict->GetDirectObjectFor("JS"); return pJS ? pJS->GetUnicodeText() : csJS; }
FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { ASSERT(m_pDocument != NULL); CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); if (!pDictionary)return FALSE; CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author"); CFX_WideString cwTitle = pDictionary->GetUnicodeText("Title"); CFX_WideString cwSubject = pDictionary->GetUnicodeText("Subject"); CFX_WideString cwKeywords = pDictionary->GetUnicodeText("Keywords"); CFX_WideString cwCreator = pDictionary->GetUnicodeText("Creator"); CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer"); CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate"); CFX_WideString cwModDate = pDictionary->GetUnicodeText("ModDate"); CFX_WideString cwTrapped = pDictionary->GetUnicodeText("Trapped"); v8::Isolate* isolate = GetIsolate(cc); if (vp.IsGetting()) { CJS_Context* pContext = (CJS_Context *)cc; CJS_Runtime* pRuntime = pContext->GetJSRuntime(); JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, -1); JS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); JS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); JS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); JS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str()); JS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str()); JS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str()); JS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate.c_str()); JS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str()); JS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str()); // It's to be compatible to non-standard info dictionary. FX_POSITION pos = pDictionary->GetStartPos(); while(pos) { CFX_ByteString bsKey; CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey); CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength()); if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->GetType()==PDFOBJ_NAME) ) JS_PutObjectString(isolate, pObj, wsKey.c_str(), pValueObj->GetUnicodeText().c_str()); if(pValueObj->GetType()==PDFOBJ_NUMBER) JS_PutObjectNumber(isolate,pObj, wsKey.c_str(), (float)pValueObj->GetNumber()); if(pValueObj->GetType()==PDFOBJ_BOOLEAN) JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(), (bool)pValueObj->GetInteger()); } vp << pObj; return TRUE; } else { return TRUE; } }
bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) return false; CFX_WideString opt_value = GetOptionValue(index); if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value)) return false; if (bSelected) { if (GetType() == ListBox) { SelectOption(index, true); if (!(m_Flags & kFormListMultiSelect)) { m_pDict->SetNewFor<CPDF_String>("V", PDF_EncodeText(opt_value), false); } else { CPDF_Array* pArray = m_pDict->SetNewFor<CPDF_Array>("V"); for (int i = 0; i < CountOptions(); i++) { if (i == index || IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddNew<CPDF_String>(PDF_EncodeText(opt_value), false); } } } } else { m_pDict->SetNewFor<CPDF_String>("V", PDF_EncodeText(opt_value), false); CPDF_Array* pI = m_pDict->SetNewFor<CPDF_Array>("I"); pI->AddNew<CPDF_Number>(index); } } else { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue) { if (GetType() == ListBox) { SelectOption(index, false); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) m_pDict->RemoveFor("V"); } else if (pValue->IsArray()) { std::unique_ptr<CPDF_Array> pArray(new CPDF_Array); for (int i = 0; i < CountOptions(); i++) { if (i != index && IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddNew<CPDF_String>(PDF_EncodeText(opt_value), false); } } if (pArray->GetCount() > 0) m_pDict->SetFor("V", std::move(pArray)); } } else { m_pDict->RemoveFor("V"); m_pDict->RemoveFor("I"); } } } if (bNotify) NotifyListOrComboBoxAfterChange(); return true; }
int CPDF_FormField::GetSelectedIndex(int index) { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue == NULL) { pValue = FPDF_GetFieldAttr(m_pDict, "I"); if (pValue == NULL) { return -1; } } if (pValue->GetType() == PDFOBJ_NUMBER) { return pValue->GetInteger(); } CFX_WideString sel_value; if (pValue->GetType() == PDFOBJ_STRING) { if (index != 0) { return -1; } sel_value = pValue->GetUnicodeText(); } else { if (pValue->GetType() != PDFOBJ_ARRAY) { return -1; } if (index < 0) { return -1; } CPDF_Object* elementValue = ((CPDF_Array*)pValue)->GetElementValue(index); sel_value = elementValue ? elementValue->GetUnicodeText() : CFX_WideString(); } if (index < CountSelectedOptions()) { int iOptIndex = GetSelectedOptionIndex(index); CFX_WideString csOpt = GetOptionValue(iOptIndex); if (csOpt == sel_value) { return iOptIndex; } } int nOpts = CountOptions(); for (int i = 0; i < nOpts; i++) { if (sel_value == GetOptionValue(i)) { return i; } } return -1; }
int CPDF_FormField::GetSelectedIndex(int index) { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (!pValue) { pValue = FPDF_GetFieldAttr(m_pDict, "I"); if (!pValue) return -1; } if (pValue->IsNumber()) return pValue->GetInteger(); CFX_WideString sel_value; if (pValue->IsString()) { if (index != 0) return -1; sel_value = pValue->GetUnicodeText(); } else { CPDF_Array* pArray = pValue->AsArray(); if (!pArray || index < 0) return -1; CPDF_Object* elementValue = pArray->GetElementValue(index); sel_value = elementValue ? elementValue->GetUnicodeText() : CFX_WideString(); } if (index < CountSelectedOptions()) { int iOptIndex = GetSelectedOptionIndex(index); CFX_WideString csOpt = GetOptionValue(iOptIndex); if (csOpt == sel_value) { return iOptIndex; } } int nOpts = CountOptions(); for (int i = 0; i < nOpts; i++) { if (sel_value == GetOptionValue(i)) { return i; } } return -1; }
int CPDF_FormField::GetDefaultSelectedItem() const { ASSERT(GetType() == ComboBox || GetType() == ListBox); CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "DV"); if (!pValue) return -1; CFX_WideString csDV = pValue->GetUnicodeText(); if (csDV.IsEmpty()) return -1; for (int i = 0; i < CountOptions(); i++) { if (csDV == GetOptionValue(i)) return i; } return -1; }
FX_BOOL CPDF_FormField::IsItemSelected(int index) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) { return FALSE; } if (IsOptionSelected(index)) { return TRUE; } CFX_WideString opt_value = GetOptionValue(index); CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue == NULL) { pValue = FPDF_GetFieldAttr(m_pDict, "I"); if (pValue == NULL) { return FALSE; } } if (pValue->GetType() == PDFOBJ_STRING) { if (pValue->GetUnicodeText() == opt_value) { return TRUE; } return FALSE; } if (pValue->GetType() == PDFOBJ_NUMBER) { if (pValue->GetString().IsEmpty()) { return FALSE; } if (pValue->GetInteger() == index) { return TRUE; } return FALSE; } if (pValue->GetType() != PDFOBJ_ARRAY) { return FALSE; } CPDF_Array* pArray = (CPDF_Array*)pValue; int iPos = -1; for (int j = 0; j < CountSelectedOptions(); j ++) { if (GetSelectedOptionIndex(j) == index) { iPos = j; break; } } for (FX_DWORD i = 0; i < pArray->GetCount(); i ++) if (pArray->GetElementValue(i)->GetUnicodeText() == opt_value && (int)i == iPos) { return TRUE; } return FALSE; }
FX_BOOL CPDF_FormField::IsItemSelected(int index) const { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) { return FALSE; } if (IsOptionSelected(index)) { return TRUE; } CFX_WideString opt_value = GetOptionValue(index); CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (!pValue) { pValue = FPDF_GetFieldAttr(m_pDict, "I"); if (!pValue) { return FALSE; } } if (pValue->IsString()) return pValue->GetUnicodeText() == opt_value; if (pValue->IsNumber()) { if (pValue->GetString().IsEmpty()) return FALSE; return (pValue->GetInteger() == index); } CPDF_Array* pArray = pValue->AsArray(); if (!pArray) return FALSE; int iPos = -1; for (int j = 0; j < CountSelectedOptions(); j++) { if (GetSelectedOptionIndex(j) == index) { iPos = j; break; } } for (int i = 0; i < static_cast<int>(pArray->GetCount()); i++) if (pArray->GetDirectObjectAt(i)->GetUnicodeText() == opt_value && i == iPos) { return TRUE; } return FALSE; }
CFX_WideString CPDF_FormField::GetAlternateName() const { CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU"); return pObj ? pObj->GetUnicodeText() : L""; }
FX_BOOL CPDF_FormField::SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) return FALSE; CFX_WideString opt_value = GetOptionValue(index); if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value)) return FALSE; if (bSelected) { if (GetType() == ListBox) { SelectOption(index, TRUE); if (!(m_Flags & FORMLIST_MULTISELECT)) { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = new CPDF_Array; for (int i = 0; i < CountOptions(); i++) { if (i == index || IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } m_pDict->SetAt("V", pArray); } } else { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = new CPDF_Array; pI->AddInteger(index); m_pDict->SetAt("I", pI); } } else { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue) { if (GetType() == ListBox) { SelectOption(index, FALSE); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) m_pDict->RemoveAt("V"); } else if (pValue->IsArray()) { CPDF_Array* pArray = new CPDF_Array; for (int i = 0; i < CountOptions(); i++) { if (i != index && IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } if (pArray->GetCount() < 1) pArray->Release(); else m_pDict->SetAt("V", pArray); } } else { m_pDict->RemoveAt("V"); m_pDict->RemoveAt("I"); } } } if (bNotify) NotifyListOrComboBoxAfterChange(); return TRUE; }
FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { switch (m_Type) { case CPDF_FormField::CheckBox: case CPDF_FormField::RadioButton: { int iCount = CountControls(); if (iCount) { if (PDF_FormField_IsUnison(this)) { for (int i = 0; i < iCount; i++) { CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE); } } else { for (int i = 0; i < iCount; i++) { CPDF_FormControl* pControl = GetControl(i); FX_BOOL bChecked = pControl->IsDefaultChecked(); CheckControl(i, bChecked, FALSE); } } } if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterCheckedStatusChange(this); } } break; case CPDF_FormField::ComboBox: { CFX_WideString csValue; ClearSelection(); int iIndex = GetDefaultSelectedItem(); if (iIndex >= 0) { csValue = GetOptionLabel(iIndex); } if (bNotify && m_pForm->m_pFormNotify) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); if (iRet < 0) { return FALSE; } } SetItemSelection(iIndex, TRUE); if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterValueChange(this); } } break; case CPDF_FormField::ListBox: { CFX_WideString csValue; ClearSelection(); int iIndex = GetDefaultSelectedItem(); if (iIndex >= 0) { csValue = GetOptionLabel(iIndex); } if (bNotify && m_pForm->m_pFormNotify) { int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); if (iRet < 0) { return FALSE; } } SetItemSelection(iIndex, TRUE); if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } } break; case CPDF_FormField::Text: case CPDF_FormField::RichText: case CPDF_FormField::File: default: { CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict, "DV"); CFX_WideString csDValue; if (pDV) { csDValue = pDV->GetUnicodeText(); } CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V"); CFX_WideString csValue; if (pV) { csValue = pV->GetUnicodeText(); } CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV"); if (!pRV && (csDValue == csValue)) { return FALSE; } if (bNotify && m_pForm->m_pFormNotify) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csDValue); if (iRet < 0) { return FALSE; } } if (pDV) { CPDF_Object* pClone = pDV->Clone(); if (!pClone) { return FALSE; } m_pDict->SetAt("V", pClone); if (pRV) { CPDF_Object* pCloneR = pDV->Clone(); m_pDict->SetAt("RV", pCloneR); } } else { m_pDict->RemoveAt("V"); m_pDict->RemoveAt("RV"); } if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterValueChange(this); } m_pForm->m_bUpdated = TRUE; } break; } return TRUE; }
FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { switch (m_Type) { case CPDF_FormField::CheckBox: case CPDF_FormField::RadioButton: { int iCount = CountControls(); if (iCount) { // TODO(weili): Check whether anything special needs to be done for // unison field. Otherwise, merge these branches. if (PDF_FormField_IsUnison(this)) { for (int i = 0; i < iCount; i++) { CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE); } } else { for (int i = 0; i < iCount; i++) { CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE); } } } if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterCheckedStatusChange(this); } } break; case CPDF_FormField::ComboBox: case CPDF_FormField::ListBox: { CFX_WideString csValue; ClearSelection(); int iIndex = GetDefaultSelectedItem(); if (iIndex >= 0) csValue = GetOptionLabel(iIndex); if (bNotify && !NotifyListOrComboBoxBeforeChange(csValue)) return FALSE; SetItemSelection(iIndex, TRUE); if (bNotify) NotifyListOrComboBoxAfterChange(); } break; case CPDF_FormField::Text: case CPDF_FormField::RichText: case CPDF_FormField::File: default: { CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict, "DV"); CFX_WideString csDValue; if (pDV) csDValue = pDV->GetUnicodeText(); CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V"); CFX_WideString csValue; if (pV) csValue = pV->GetUnicodeText(); CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV"); if (!pRV && (csDValue == csValue)) return FALSE; if (bNotify && !NotifyBeforeValueChange(csDValue)) return FALSE; if (pDV) { CPDF_Object* pClone = pDV->Clone(); if (!pClone) return FALSE; m_pDict->SetAt("V", pClone); if (pRV) { CPDF_Object* pCloneR = pDV->Clone(); m_pDict->SetAt("RV", pCloneR); } } else { m_pDict->RemoveAt("V"); m_pDict->RemoveAt("RV"); } if (bNotify) NotifyAfterValueChange(); } break; } return TRUE; }
FX_BOOL CPDF_FormField::SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) return FALSE; CFX_WideString opt_value = GetOptionValue(index); if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value)) return FALSE; if (bSelected) { if (GetType() == ListBox) { SelectOption(index, TRUE); if (!(m_Flags & kFormListMultiSelect)) { m_pDict->SetStringFor("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = new CPDF_Array; for (int i = 0; i < CountOptions(); i++) { if (i == index || IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } m_pDict->SetFor("V", pArray); } } else { m_pDict->SetStringFor("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = new CPDF_Array; pI->AddInteger(index); m_pDict->SetFor("I", pI); } } else { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue) { if (GetType() == ListBox) { SelectOption(index, FALSE); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) m_pDict->RemoveFor("V"); } else if (pValue->IsArray()) { std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray( new CPDF_Array); for (int i = 0; i < CountOptions(); i++) { if (i != index && IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } if (pArray->GetCount() > 0) m_pDict->SetFor("V", pArray.release()); // std::move someday } } else { m_pDict->RemoveFor("V"); m_pDict->RemoveFor("I"); } } } if (bNotify) NotifyListOrComboBoxAfterChange(); return TRUE; }
FX_BOOL CPDF_FormField::SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) { return FALSE; } CFX_WideString opt_value = GetOptionValue(index); if (bNotify && m_pForm->m_pFormNotify) { int iRet = 0; if (GetType() == ListBox) { iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, opt_value); } if (GetType() == ComboBox) { iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, opt_value); } if (iRet < 0) { return FALSE; } } if (!bSelected) { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue) { if (m_Type == ListBox) { SelectOption(index, FALSE); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) { m_pDict->RemoveAt("V"); } } else if (pValue->IsArray()) { CPDF_Array* pArray = new CPDF_Array; int iCount = CountOptions(); for (int i = 0; i < iCount; i++) { if (i != index) { if (IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } } if (pArray->GetCount() < 1) { pArray->Release(); } else { m_pDict->SetAt("V", pArray); } } } else if (m_Type == ComboBox) { m_pDict->RemoveAt("V"); m_pDict->RemoveAt("I"); } } } else { if (m_Type == ListBox) { SelectOption(index, TRUE); if (!(m_Flags & FORMLIST_MULTISELECT)) { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = new CPDF_Array; int iCount = CountOptions(); for (int i = 0; i < iCount; i++) { FX_BOOL bSelected; if (i != index) { bSelected = IsItemSelected(i); } else { bSelected = TRUE; } if (bSelected) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } m_pDict->SetAt("V", pArray); } } else if (m_Type == ComboBox) { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = new CPDF_Array; pI->AddInteger(index); m_pDict->SetAt("I", pI); } } if (bNotify && m_pForm->m_pFormNotify) { if (GetType() == ListBox) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } if (GetType() == ComboBox) { m_pForm->m_pFormNotify->AfterValueChange(this); } } if (CPDF_InterForm::m_bUpdateAP) { UpdateAP(NULL); } m_pForm->m_bUpdated = TRUE; return TRUE; }