コード例 #1
0
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();
}
コード例 #2
0
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();
}