本文整理汇总了C++中CPDF_FormField::GetFieldType方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_FormField::GetFieldType方法的具体用法?C++ CPDF_FormField::GetFieldType怎么用?C++ CPDF_FormField::GetFieldType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_FormField
的用法示例。
在下文中一共展示了CPDF_FormField::GetFieldType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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: ValidateFieldName
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;
}
示例3: 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);
}
}
示例4: 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);
}
示例5: OnCalculate
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;
}
示例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: 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->GetUnicodeText("T");
CPDF_Array* pKids = pFieldDict->GetArray("Kids");
if (pKids) {
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDict(i);
if (pKid == NULL) {
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 == NULL) {
return;
}
CFX_WideString csWValue;
FPDFDOC_FDF_GetFieldValue(pFieldDict, csWValue, m_bsEncoding);
int iType = pField->GetFieldType();
if (bNotify && m_pFormNotify != NULL) {
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;
}
}
CFX_ByteArray statusArray;
if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) {
SaveCheckedFieldStatus(pField, statusArray);
}
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->GetElementValue("Opt")->Clone(TRUE));
}
if (bNotify && m_pFormNotify != NULL) {
if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) {
m_pFormNotify->AfterCheckedStatusChange(pField, statusArray);
} else if (iType == FIELDTYPE_LISTBOX) {
m_pFormNotify->AfterSelectionChange(pField);
} else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) {
m_pFormNotify->AfterValueChange(pField);
}
}
if (CPDF_InterForm::m_bUpdateAP) {
pField->UpdateAP(NULL);
}
}
示例8: interform
DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page,
double page_x,
double page_y) {
if (!hHandle)
return -1;
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (pPage) {
CPDF_InterForm interform(pPage->m_pDocument, FALSE);
CPDF_FormControl* pFormCtrl =
interform.GetControlAtPoint(pPage, static_cast<FX_FLOAT>(page_x),
static_cast<FX_FLOAT>(page_y), nullptr);
if (!pFormCtrl)
return -1;
CPDF_FormField* pFormField = pFormCtrl->GetField();
return pFormField ? pFormField->GetFieldType() : -1;
}
#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* pXFAPage = UnderlyingFromFPDFPage(page);
if (!pXFAPage)
return -1;
IXFA_PageView* pPageView = pXFAPage->GetXFAPageView();
if (!pPageView)
return -1;
IXFA_DocView* pDocView = pPageView->GetDocView();
if (!pDocView)
return -1;
IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
if (!pWidgetHandler)
return -1;
std::unique_ptr<IXFA_WidgetIterator, ReleaseDeleter<IXFA_WidgetIterator>>
pWidgetIterator(pPageView->CreateWidgetIterator(
XFA_TRAVERSEWAY_Form,
XFA_WIDGETFILTER_Viewable | XFA_WIDGETFILTER_AllType));
if (!pWidgetIterator)
return -1;
IXFA_Widget* pXFAAnnot = pWidgetIterator->MoveToNext();
while (pXFAAnnot) {
CFX_RectF rcBBox;
pWidgetHandler->GetBBox(pXFAAnnot, rcBBox, 0);
CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
rcBBox.top + rcBBox.height);
rcWidget.left -= 1.0f;
rcWidget.right += 1.0f;
rcWidget.bottom -= 1.0f;
rcWidget.top += 1.0f;
if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x),
static_cast<FX_FLOAT>(page_y))) {
return FPDF_FORMFIELD_XFA;
}
pXFAAnnot = pWidgetIterator->MoveToNext();
}
#endif // PDF_ENABLE_XFA
return -1;
}