当前位置: 首页>>代码示例>>C++>>正文


C++ FPDF_GetFieldAttr函数代码示例

本文整理汇总了C++中FPDF_GetFieldAttr函数的典型用法代码示例。如果您正苦于以下问题:C++ FPDF_GetFieldAttr函数的具体用法?C++ FPDF_GetFieldAttr怎么用?C++ FPDF_GetFieldAttr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FPDF_GetFieldAttr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetCheckValue

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();
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:31,代码来源:doc_formfield.cpp

示例2: FPDF_GetFieldAttr

int CPDF_FormField::CountSelectedItems()
{
    CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
    if (pValue == NULL) {
        pValue = FPDF_GetFieldAttr(m_pDict, "I");
        if (pValue == NULL) {
            return 0;
        }
    }
    if (pValue->GetType() == PDFOBJ_STRING) {
        if (pValue->GetString().IsEmpty()) {
            return 0;
        }
        return 1;
    }
    if (pValue->GetType() == PDFOBJ_NUMBER) {
        if (pValue->GetString().IsEmpty()) {
            return 0;
        }
        return 1;
    }
    if (pValue->GetType() != PDFOBJ_ARRAY) {
        return 0;
    }
    return ((CPDF_Array*)pValue)->GetCount();
}
开发者ID:MWisBest,项目名称:android_external_pdfium,代码行数:26,代码来源:doc_formfield.cpp

示例3: PDF_EncodeText

CFDF_Document* CPDF_InterForm::ExportToFDF(
    const CFX_WideStringC& pdf_path,
    const std::vector<CPDF_FormField*>& fields,
    bool bIncludeOrExclude,
    bool bSimpleFileSpec) const {
  CFDF_Document* pDoc = CFDF_Document::CreateNewDoc();
  if (!pDoc)
    return nullptr;

  CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictBy("FDF");
  if (!pdf_path.IsEmpty()) {
    if (bSimpleFileSpec) {
      CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path);
      pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath));
      pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath));
    } else {
      CPDF_FileSpec filespec;
      filespec.SetFileName(pdf_path);
      pMainDict->SetAt("F", filespec.GetObj());
    }
  }

  CPDF_Array* pFields = new CPDF_Array;
  pMainDict->SetAt("Fields", pFields);
  int nCount = m_pFieldTree->m_Root.CountFields();
  for (int i = 0; i < nCount; i++) {
    CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
    if (!pField || pField->GetType() == CPDF_FormField::PushButton)
      continue;

    uint32_t dwFlags = pField->GetFieldFlags();
    if (dwFlags & 0x04)
      continue;

    if (bIncludeOrExclude == pdfium::ContainsValue(fields, pField)) {
      if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetStringBy("V").IsEmpty())
        continue;

      CFX_WideString fullname = FPDF_GetFullName(pField->GetFieldDict());
      CPDF_Dictionary* pFieldDict = new CPDF_Dictionary;
      pFieldDict->SetAt("T", new CPDF_String(fullname));
      if (pField->GetType() == CPDF_FormField::CheckBox ||
          pField->GetType() == CPDF_FormField::RadioButton) {
        CFX_WideString csExport = pField->GetCheckValue(FALSE);
        CFX_ByteString csBExport = PDF_EncodeText(csExport);
        CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt");
        if (pOpt)
          pFieldDict->SetAtString("V", csBExport);
        else
          pFieldDict->SetAtName("V", csBExport);
      } else {
        CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V");
        if (pV)
          pFieldDict->SetAt("V", pV->CloneDirectObject());
      }
      pFields->Add(pFieldDict);
    }
  }
  return pDoc;
}
开发者ID:gradescope,项目名称:pdfium,代码行数:60,代码来源:cpdf_interform.cpp

示例4: GetCheckValue

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();
}
开发者ID:MWisBest,项目名称:android_external_pdfium,代码行数:30,代码来源:doc_formfield.cpp

示例5: ASSERT

FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
                                     bool bChecked,
                                     bool bNotify) {
  ASSERT(GetType() == CheckBox || GetType() == RadioButton);
  CPDF_FormControl* pControl = GetControl(iControlIndex);
  if (!pControl) {
    return FALSE;
  }
  if (!bChecked && pControl->IsChecked() == bChecked) {
    return FALSE;
  }
  CFX_WideString csWExport = pControl->GetExportValue();
  CFX_ByteString csBExport = PDF_EncodeText(csWExport);
  int iCount = CountControls();
  bool bUnison = PDF_FormField_IsUnison(this);
  for (int i = 0; i < iCount; i++) {
    CPDF_FormControl* pCtrl = GetControl(i);
    if (bUnison) {
      CFX_WideString csEValue = pCtrl->GetExportValue();
      if (csEValue == csWExport) {
        if (pCtrl->GetOnStateName() == pControl->GetOnStateName()) {
          pCtrl->CheckControl(bChecked);
        } else if (bChecked) {
          pCtrl->CheckControl(FALSE);
        }
      } else if (bChecked) {
        pCtrl->CheckControl(FALSE);
      }
    } else {
      if (i == iControlIndex) {
        pCtrl->CheckControl(bChecked);
      } else if (bChecked) {
        pCtrl->CheckControl(FALSE);
      }
    }
  }
  CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pDict, "Opt");
  if (!ToArray(pOpt)) {
    if (bChecked) {
      m_pDict->SetAtName("V", csBExport);
    } else {
      CFX_ByteString csV;
      CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V");
      if (pV) {
        csV = pV->GetString();
      }
      if (csV == csBExport) {
        m_pDict->SetAtName("V", "Off");
      }
    }
  } else if (bChecked) {
    CFX_ByteString csIndex;
    csIndex.Format("%d", iControlIndex);
    m_pDict->SetAtName("V", csIndex);
  }
  if (bNotify && m_pForm->m_pFormNotify)
    m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
  return TRUE;
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:59,代码来源:doc_formfield.cpp

示例6: FPDF_GetFieldAttr

void CPDF_FormField::SyncFieldFlags() {
  CFX_ByteString type_name = FPDF_GetFieldAttr(m_pDict, "FT")
                                 ? FPDF_GetFieldAttr(m_pDict, "FT")->GetString()
                                 : CFX_ByteString();
  uint32_t flags = FPDF_GetFieldAttr(m_pDict, "Ff")
                       ? FPDF_GetFieldAttr(m_pDict, "Ff")->GetInteger()
                       : 0;
  m_Flags = 0;
  if (flags & 1)
    m_Flags |= kFormFieldReadOnly;
  if (flags & 2)
    m_Flags |= kFormFieldRequired;
  if (flags & 4)
    m_Flags |= kFormFieldNoExport;

  if (type_name == "Btn") {
    if (flags & 0x8000) {
      m_Type = RadioButton;
      if (flags & 0x4000)
        m_Flags |= kFormRadioNoToggleOff;
      if (flags & 0x2000000)
        m_Flags |= kFormRadioUnison;
    } else if (flags & 0x10000) {
      m_Type = PushButton;
    } else {
      m_Type = CheckBox;
    }
  } else if (type_name == "Tx") {
    if (flags & 0x100000) {
      m_Type = File;
    } else if (flags & 0x2000000) {
      m_Type = RichText;
    } else {
      m_Type = Text;
      if (flags & 0x1000)
        m_Flags |= kFormTextMultiLine;
      if (flags & 0x2000)
        m_Flags |= kFormTextPassword;
      if (flags & 0x800000)
        m_Flags |= kFormTextNoScroll;
      if (flags & 0x100000)
        m_Flags |= kFormTextComb;
    }
    LoadDA();
  } else if (type_name == "Ch") {
    if (flags & 0x20000) {
      m_Type = ComboBox;
      if (flags & 0x40000)
        m_Flags |= kFormComboEdit;
    } else {
      m_Type = ListBox;
      if (flags & 0x200000)
        m_Flags |= kFormListMultiSelect;
    }
    LoadDA();
  } else if (type_name == "Sig") {
    m_Type = Sign;
  }
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:59,代码来源:cpdf_formfield.cpp

示例7: ASSERT

CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
  ASSERT(m_pAnnotDict != NULL);
  ASSERT(m_pDocument != NULL);

  CPDF_Dictionary* pAcroFormDict = NULL;

  FX_BOOL bWidget = (m_pAnnotDict->GetString("Subtype") == "Widget");

  if (bWidget) {
    if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot())
      pAcroFormDict = pRootDict->GetDict("AcroForm");
  }

  CFX_ByteString sDA;
  CPDF_Object* pObj;
  if ((pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA")))
    sDA = pObj->GetString();

  if (bWidget) {
    if (sDA.IsEmpty()) {
      pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA");
      sDA = pObj ? pObj->GetString() : CFX_ByteString();
    }
  }

  CPDF_Dictionary* pFontDict = NULL;

  if (!sDA.IsEmpty()) {
    CPDF_SimpleParser syntax(sDA);
    syntax.FindTagParam("Tf", 2);
    CFX_ByteString sFontName = syntax.GetWord();
    sAlias = PDF_NameDecode(sFontName).Mid(1);

    if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDict("DR"))
      if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDict("Font"))
        pFontDict = pDRFontDict->GetDict(sAlias);

    if (!pFontDict)
      if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP"))
        if (CPDF_Dictionary* pNormalDict = pAPDict->GetDict("N"))
          if (CPDF_Dictionary* pNormalResDict =
                  pNormalDict->GetDict("Resources"))
            if (CPDF_Dictionary* pResFontDict = pNormalResDict->GetDict("Font"))
              pFontDict = pResFontDict->GetDict(sAlias);

    if (bWidget) {
      if (!pFontDict) {
        if (pAcroFormDict) {
          if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDict("DR"))
            if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDict("Font"))
              pFontDict = pDRFontDict->GetDict(sAlias);
        }
      }
    }
  }

  return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr;
}
开发者ID:azunite,项目名称:libpdfium,代码行数:58,代码来源:FFL_CBA_Fontmap.cpp

示例8: FPDF_GetFieldAttr

int CPDF_FormField::CountSelectedItems() const {
  CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
  if (!pValue) {
    pValue = FPDF_GetFieldAttr(m_pDict, "I");
    if (!pValue)
      return 0;
  }

  if (pValue->IsString() || pValue->IsNumber())
    return pValue->GetString().IsEmpty() ? 0 : 1;
  if (CPDF_Array* pArray = pValue->AsArray())
    return pArray->GetCount();
  return 0;
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:14,代码来源:doc_formfield.cpp

示例9: ASSERT

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;
}
开发者ID:MWisBest,项目名称:android_external_pdfium,代码行数:49,代码来源:doc_formfield.cpp

示例10: FPDF_GetFieldAttr

CFX_WideString CPDF_FormField::GetAlternateName() {
  CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU");
  if (!pObj) {
    return L"";
  }
  return pObj->GetUnicodeText();
}
开发者ID:andoma,项目名称:pdfium,代码行数:7,代码来源:doc_formfield.cpp

示例11: LoadDA

void CPDF_FormField::LoadDA() {
  CPDF_Dictionary* pFormDict = m_pForm->m_pFormDict;
  if (!pFormDict)
    return;

  CFX_ByteString DA;
  if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DA"))
    DA = pObj->GetString();

  if (DA.IsEmpty())
    DA = pFormDict->GetStringBy("DA");

  if (DA.IsEmpty())
    return;

  CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR");
  if (!pDR)
    return;

  CPDF_Dictionary* pFont = pDR->GetDictBy("Font");
  if (!pFont)
    return;

  CPDF_SimpleParser syntax(DA.AsStringC());
  syntax.FindTagParamFromStart("Tf", 2);
  CFX_ByteString font_name(syntax.GetWord());
  CPDF_Dictionary* pFontDict = pFont->GetDictBy(font_name);
  if (!pFontDict)
    return;

  m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict);
  m_FontSize = FX_atof(syntax.GetWord());
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:33,代码来源:doc_formfield.cpp

示例12: LoadDA

void CPDF_FormField::LoadDA() {
  CFX_ByteString DA;
  if (CPDF_Object* pObj_t = FPDF_GetFieldAttr(m_pDict, "DA")) {
    DA = pObj_t->GetString();
  }
  if (DA.IsEmpty() && m_pForm->m_pFormDict) {
    DA = m_pForm->m_pFormDict->GetStringBy("DA");
  }
  if (DA.IsEmpty()) {
    return;
  }
  CPDF_SimpleParser syntax(DA);
  syntax.FindTagParam("Tf", 2);
  CFX_ByteString font_name = syntax.GetWord();
  CPDF_Dictionary* pFontDict = NULL;
  if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDictBy("DR") &&
      m_pForm->m_pFormDict->GetDictBy("DR")->GetDictBy("Font"))
    pFontDict = m_pForm->m_pFormDict->GetDictBy("DR")
                    ->GetDictBy("Font")
                    ->GetDictBy(font_name);

  if (!pFontDict) {
    return;
  }
  m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict);
  m_FontSize = FX_atof(syntax.GetWord());
}
开发者ID:andoma,项目名称:pdfium,代码行数:27,代码来源:doc_formfield.cpp

示例13: FPDF_GetFieldAttr

int CPDF_FormField::CountOptions() {
  CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "Opt");
  if (pValue == NULL || pValue->GetType() != PDFOBJ_ARRAY) {
    return 0;
  }
  return ((CPDF_Array*)pValue)->GetCount();
}
开发者ID:azunite,项目名称:libpdfium,代码行数:7,代码来源:doc_formfield.cpp

示例14: PDF_EncodeText

int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
                                 int index,
                                 bool bNotify) {
  if (csOptLabel.IsEmpty())
    return -1;

  if (bNotify && !NotifyListOrComboBoxBeforeChange(csOptLabel))
    return -1;

  CFX_ByteString csStr =
      PDF_EncodeText(csOptLabel.c_str(), csOptLabel.GetLength());
  CPDF_Array* pOpt = ToArray(FPDF_GetFieldAttr(m_pDict, "Opt"));
  if (!pOpt)
    pOpt = m_pDict->SetNewFor<CPDF_Array>("Opt");

  int iCount = pdfium::base::checked_cast<int>(pOpt->GetCount());
  if (index >= iCount) {
    pOpt->AddNew<CPDF_String>(csStr, false);
    index = iCount;
  } else {
    pOpt->InsertNewAt<CPDF_String>(index, csStr, false);
  }

  if (bNotify)
    NotifyListOrComboBoxAfterChange();
  return index;
}
开发者ID:documentcloud,项目名称:pdfium,代码行数:27,代码来源:cpdf_formfield.cpp

示例15: PDF_EncodeText

int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
                                 int index,
                                 FX_BOOL bNotify) {
  if (csOptLabel.IsEmpty())
    return -1;

  if (bNotify && !NotifyListOrComboBoxBeforeChange(csOptLabel))
    return -1;

  CFX_ByteString csStr =
      PDF_EncodeText(csOptLabel.c_str(), csOptLabel.GetLength());
  CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "Opt");
  CPDF_Array* pOpt = ToArray(pValue);
  if (!pOpt) {
    pOpt = new CPDF_Array;
    m_pDict->SetAt("Opt", pOpt);
  }

  int iCount = (int)pOpt->GetCount();
  if (index < 0 || index >= iCount) {
    pOpt->AddString(csStr);
    index = iCount;
  } else {
    CPDF_String* pString = new CPDF_String(csStr, FALSE);
    pOpt->InsertAt(index, pString);
  }

  if (bNotify)
    NotifyListOrComboBoxAfterChange();
  return index;
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:31,代码来源:doc_formfield.cpp


注:本文中的FPDF_GetFieldAttr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。