bool CPDF_FormField::SetValue(const CFX_WideString& value, bool bDefault, bool bNotify) { switch (m_Type) { case CheckBox: case RadioButton: { SetCheckValue(value, bDefault, bNotify); return true; } case File: case RichText: case Text: case ComboBox: { CFX_WideString csValue = value; if (bNotify && !NotifyBeforeValueChange(csValue)) return false; CFX_ByteString key(bDefault ? "DV" : "V"); int iIndex = FindOptionValue(csValue); if (iIndex < 0) { CFX_ByteString bsEncodeText = PDF_EncodeText(csValue); m_pDict->SetNewFor<CPDF_String>(key, bsEncodeText, false); if (m_Type == RichText && !bDefault) m_pDict->SetNewFor<CPDF_String>("RV", bsEncodeText, false); m_pDict->RemoveFor("I"); } else { m_pDict->SetNewFor<CPDF_String>(key, PDF_EncodeText(csValue), false); if (!bDefault) { ClearSelection(); SetItemSelection(iIndex, true); } } if (bNotify) NotifyAfterValueChange(); break; } case ListBox: { int iIndex = FindOptionValue(value); if (iIndex < 0) return false; if (bDefault && iIndex == GetDefaultSelectedItem()) return false; if (bNotify && !NotifyBeforeSelectionChange(value)) return false; if (!bDefault) { ClearSelection(); SetItemSelection(iIndex, true); } if (bNotify) NotifyAfterSelectionChange(); break; } default: break; } return true; }
FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify) { switch (m_Type) { case CheckBox: case RadioButton: { SetCheckValue(value, bDefault, bNotify); return TRUE; } case File: case RichText: case Text: case ComboBox: { CFX_WideString csValue = value; if (bNotify && !NotifyBeforeValueChange(csValue)) return FALSE; int iIndex = FindOptionValue(csValue); if (iIndex < 0) { CFX_ByteString bsEncodeText = PDF_EncodeText(csValue); m_pDict->SetAtString(bDefault ? "DV" : "V", bsEncodeText); if (m_Type == RichText && !bDefault) m_pDict->SetAtString("RV", bsEncodeText); m_pDict->RemoveAt("I"); } else { m_pDict->SetAtString(bDefault ? "DV" : "V", PDF_EncodeText(csValue)); if (!bDefault) { ClearSelection(); SetItemSelection(iIndex, TRUE); } } if (bNotify) NotifyAfterValueChange(); } break; case ListBox: { int iIndex = FindOptionValue(value); if (iIndex < 0) return FALSE; if (bDefault && iIndex == GetDefaultSelectedItem()) return FALSE; if (bNotify && !NotifyBeforeSelectionChange(value)) return FALSE; if (!bDefault) { ClearSelection(); SetItemSelection(iIndex, TRUE); } if (bNotify) NotifyAfterSelectionChange(); break; } default: break; } return TRUE; }
FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify) { switch (m_Type) { case CheckBox: case RadioButton: { SetCheckValue(value, bDefault, bNotify); return TRUE; } case File: case RichText: case Text: case ComboBox: { CFX_WideString csValue = value; if (bNotify && m_pForm->m_pFormNotify != NULL) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); if (iRet < 0) { return FALSE; } } int iIndex = FindOptionValue(csValue); if (iIndex < 0) { CFX_ByteString bsEncodeText = PDF_EncodeText(csValue); m_pDict->SetAtString(bDefault ? "DV" : "V", bsEncodeText); if (m_Type == RichText && !bDefault) { m_pDict->SetAtString("RV", bsEncodeText); } m_pDict->RemoveAt("I"); } else { m_pDict->SetAtString(bDefault ? "DV" : "V", PDF_EncodeText(csValue)); if (bDefault) { } else { ClearSelection(); SetItemSelection(iIndex, TRUE); } } if (bNotify && m_pForm->m_pFormNotify != NULL) { m_pForm->m_pFormNotify->AfterValueChange(this); } m_pForm->m_bUpdated = TRUE; } break; case ListBox: { int iIndex = FindOptionValue(value); if (iIndex < 0) { return FALSE; } if (bDefault && iIndex == GetDefaultSelectedItem()) { return FALSE; } if (bNotify && m_pForm->m_pFormNotify != NULL) { CFX_WideString csValue = value; int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); if (iRet < 0) { return FALSE; } } if (bDefault) { } else { ClearSelection(); SetItemSelection(iIndex, TRUE); } if (bNotify && m_pForm->m_pFormNotify != NULL) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } m_pForm->m_bUpdated = TRUE; break; } default: break; } if (CPDF_InterForm::m_bUpdateAP) { UpdateAP(NULL); } return TRUE; }