本文整理汇总了C++中CPDF_FormField类的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_FormField类的具体用法?C++ CPDF_FormField怎么用?C++ CPDF_FormField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPDF_FormField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FPDPage_HasFormFieldAtPoint
DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page,double page_x, double page_y)
{
if(!page || !hHandle)
return -1;
CPDF_Page * pPage = (CPDF_Page*) page;
CPDF_InterForm * pInterForm = NULL;
pInterForm = new CPDF_InterForm(pPage->m_pDocument,FALSE);
if (!pInterForm)
return -1;
CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y);
if(!pFormCtrl)
{
delete pInterForm;
return -1;
}
CPDF_FormField* pFormField = pFormCtrl->GetField();
if(!pFormField)
{
delete pInterForm;
return -1;
}
int nType = pFormField->GetFieldType();
delete pInterForm;
return nType;
}
示例2: CheckRequiredFields
CPDF_FormField* CPDF_InterForm::CheckRequiredFields(
const std::vector<CPDF_FormField*>* fields,
bool bIncludeOrExclude) const {
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)
continue;
int32_t iType = pField->GetType();
if (iType == CPDF_FormField::PushButton ||
iType == CPDF_FormField::CheckBox || iType == CPDF_FormField::ListBox) {
continue;
}
uint32_t dwFlags = pField->GetFieldFlags();
// TODO(thestig): Look up these magic numbers and add constants for them.
if (dwFlags & 0x04)
continue;
bool bFind = true;
if (fields)
bFind = pdfium::ContainsValue(*fields, pField);
if (bIncludeOrExclude == bFind) {
CPDF_Dictionary* pFieldDict = pField->m_pDict;
if ((dwFlags & 0x02) != 0 && pFieldDict->GetStringBy("V").IsEmpty())
return pField;
}
}
return nullptr;
}
示例3: CheckRequiredFields
bool CPDF_InterForm::CheckRequiredFields(
const std::vector<CPDF_FormField*>* fields,
bool bIncludeOrExclude) const {
size_t nCount = m_pFieldTree->m_Root.CountFields();
for (size_t i = 0; i < nCount; ++i) {
CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(i);
if (!pField)
continue;
int32_t iType = pField->GetType();
if (iType == CPDF_FormField::PushButton ||
iType == CPDF_FormField::CheckBox || iType == CPDF_FormField::ListBox) {
continue;
}
uint32_t dwFlags = pField->GetFieldFlags();
// TODO(thestig): Look up these magic numbers and add constants for them.
if (dwFlags & FORMFLAG_NOEXPORT)
continue;
bool bFind = true;
if (fields)
bFind = pdfium::ContainsValue(*fields, pField);
if (bIncludeOrExclude == bFind) {
CPDF_Dictionary* pFieldDict = pField->m_pDict;
if ((dwFlags & FORMFLAG_REQUIRED) != 0 &&
pFieldDict->GetStringFor("V").IsEmpty()) {
return false;
}
}
}
return true;
}
示例4: GetCheckBox
void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) {
CPWL_CheckBox* pWnd = GetCheckBox(pPageView, false);
if (!pWnd)
return;
bool bNewChecked = pWnd->IsChecked();
if (bNewChecked) {
CPDF_FormField* pField = m_pWidget->GetFormField();
for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
if (pCtrl->IsChecked()) {
break;
}
}
}
}
CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get());
CFFL_CheckBox::ObservedPtr observed_this(this);
m_pWidget->SetCheck(bNewChecked, NotificationOption::kDoNotNotify);
if (!observed_widget)
return;
m_pWidget->UpdateField();
if (!observed_widget || !observed_this)
return;
SetChangeMark();
}
示例5: ASSERT
void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) {
ASSERT(m_pWidget != NULL);
if (CPWL_RadioButton* pWnd =
(CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
FX_BOOL bNewChecked = pWnd->IsChecked();
if (bNewChecked) {
CPDF_FormField* pField = m_pWidget->GetFormField();
ASSERT(pField != NULL);
for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
if (pCtrl->IsChecked()) {
break;
}
}
}
}
m_pWidget->SetCheck(bNewChecked, FALSE);
m_pWidget->UpdateField();
SetChangeMark();
}
}
示例6: ValidateFieldName
FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl,
CFX_WideString& csNewFieldName) {
if (pControl == NULL || csNewFieldName.IsEmpty()) {
return FALSE;
}
CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField();
return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField,
pControl);
}
示例7: ValidateFieldName
FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl,
CFX_WideString& csNewFieldName) {
if (!pControl || csNewFieldName.IsEmpty())
return FALSE;
CPDF_FormField* pField = pControl->GetField();
return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField,
pControl);
}
示例8: while
bool CPDF_InterForm::ValidateFieldName(
CFX_WideString& csNewFieldName,
int iType,
const CPDF_FormField* pExcludedField,
const CPDF_FormControl* pExcludedControl) const {
if (csNewFieldName.IsEmpty())
return false;
int iPos = 0;
int iLength = csNewFieldName.GetLength();
CFX_WideString csSub;
while (true) {
while (iPos < iLength &&
(csNewFieldName[iPos] == L'.' || csNewFieldName[iPos] == L' ')) {
iPos++;
}
if (iPos < iLength && !csSub.IsEmpty())
csSub += L'.';
while (iPos < iLength && csNewFieldName[iPos] != L'.')
csSub += csNewFieldName[iPos++];
for (int i = csSub.GetLength() - 1; i > -1; i--) {
if (csSub[i] != L' ' && csSub[i] != L'.')
break;
csSub.SetAt(i, L'\0');
}
size_t dwCount = m_pFieldTree->m_Root.CountFields();
for (size_t m = 0; m < dwCount; ++m) {
CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(m);
if (!pField)
continue;
if (pField == pExcludedField) {
if (!pExcludedControl || pField->CountControls() < 2)
continue;
}
CFX_WideString csFullName = pField->GetFullName();
int iRet = CompareFieldName(csSub, csFullName);
if (iRet == 1) {
if (pField->GetFieldType() != iType)
return false;
} else if (iRet == 2 && csSub == csNewFieldName) {
if (csFullName[iPos] == L'.')
return false;
} else if (iRet == 3 && csSub == csNewFieldName) {
if (csNewFieldName[csFullName.GetLength()] == L'.')
return false;
}
}
if (iPos >= iLength)
break;
}
if (csSub.IsEmpty())
return false;
csNewFieldName = csSub;
return true;
}
示例9: FDF_ImportField
void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict,
const CFX_WideString& parent_name,
FX_BOOL bNotify,
int nLevel) {
CFX_WideString name;
if (!parent_name.IsEmpty())
name = parent_name + L".";
name += pFieldDict->GetUnicodeTextBy("T");
CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids");
if (pKids) {
for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid)
continue;
if (nLevel <= nMaxRecursion)
FDF_ImportField(pKid, name, bNotify, nLevel + 1);
}
return;
}
if (!pFieldDict->KeyExist("V"))
return;
CPDF_FormField* pField = m_pFieldTree->GetField(name);
if (!pField)
return;
CFX_WideString csWValue = GetFieldValue(*pFieldDict, m_bsEncoding);
int iType = pField->GetFieldType();
if (bNotify && m_pFormNotify) {
int iRet = 0;
if (iType == FIELDTYPE_LISTBOX)
iRet = m_pFormNotify->BeforeSelectionChange(pField, csWValue);
else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD)
iRet = m_pFormNotify->BeforeValueChange(pField, csWValue);
if (iRet < 0)
return;
}
pField->SetValue(csWValue);
CPDF_FormField::Type eType = pField->GetType();
if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) &&
pFieldDict->KeyExist("Opt")) {
pField->m_pDict->SetAt(
"Opt", pFieldDict->GetDirectObjectBy("Opt")->CloneDirectObject());
}
if (bNotify && m_pFormNotify) {
if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON)
m_pFormNotify->AfterCheckedStatusChange(pField);
else if (iType == FIELDTYPE_LISTBOX)
m_pFormNotify->AfterSelectionChange(pField);
else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD)
m_pFormNotify->AfterValueChange(pField);
}
}
示例10: ASSERT
void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) {
CPDFSDK_Environment* pEnv = m_pDocument->GetEnv();
ASSERT(pEnv);
if (!pEnv->IsJSInitiated())
return;
if (m_bBusy)
return;
m_bBusy = TRUE;
if (!IsCalculateEnabled()) {
m_bBusy = FALSE;
return;
}
IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime();
pRuntime->SetReaderDocument(m_pDocument);
int nSize = m_pInterForm->CountFieldsInCalculationOrder();
for (int i = 0; i < nSize; i++) {
CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i);
if (!pField)
continue;
int nType = pField->GetFieldType();
if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD)
continue;
CPDF_AAction aAction = pField->GetAdditionalAction();
if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Calculate))
continue;
CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate);
if (!action.GetDict())
continue;
CFX_WideString csJS = action.GetJavaScript();
if (csJS.IsEmpty())
continue;
IJS_Context* pContext = pRuntime->NewContext();
CFX_WideString sOldValue = pField->GetValue();
CFX_WideString sValue = sOldValue;
FX_BOOL bRC = TRUE;
pContext->OnField_Calculate(pFormField, pField, sValue, bRC);
CFX_WideString sInfo;
FX_BOOL bRet = pContext->RunScript(csJS, &sInfo);
pRuntime->ReleaseContext(pContext);
if (bRet && bRC && sValue.Compare(sOldValue) != 0)
pField->SetValue(sValue, TRUE);
}
m_bBusy = FALSE;
}
示例11: GetAllFieldNames
void CPDF_InterForm::GetAllFieldNames(CFX_WideStringArray& allFieldNames) {
allFieldNames.RemoveAll();
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) {
CFX_WideString full_name = GetFullName(pField->GetFieldDict());
allFieldNames.Add(full_name);
}
}
}
示例12: ResetForm
bool CPDF_InterForm::ResetForm(bool bNotify) {
if (bNotify && m_pFormNotify && m_pFormNotify->BeforeFormReset(this) < 0)
return false;
size_t nCount = m_pFieldTree->m_Root.CountFields();
for (size_t i = 0; i < nCount; ++i) {
CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(i);
if (!pField)
continue;
pField->ResetField(bNotify);
}
if (bNotify && m_pFormNotify)
m_pFormNotify->AfterFormReset(this);
return true;
}
示例13: ResetForm
bool CPDF_InterForm::ResetForm(const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude,
bool bNotify) {
if (bNotify && m_pFormNotify && m_pFormNotify->BeforeFormReset(this) < 0)
return false;
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)
continue;
auto it = std::find(fields.begin(), fields.end(), pField);
if (bIncludeOrExclude == (it != fields.end()))
pField->ResetField(bNotify);
}
if (bNotify && m_pFormNotify)
m_pFormNotify->AfterFormReset(this);
return true;
}
示例14: 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;
}
示例15: JSGetStringFromID
//Gets the name of the nth field in the document
FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
CJS_Context* pContext = (CJS_Context*)cc;
if (params.size() != 1) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
int nIndex = params[0].ToInt();
if (nIndex < 0) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
return FALSE;
}
CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
CPDF_FormField* pField = pPDFForm->GetField(nIndex);
if (!pField)
return FALSE;
vRet = pField->GetFullName().c_str();
return TRUE;
}