Esempio n. 1
0
Field* CJS_EventHandler::Target_Field() {
  CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
  v8::Local<v8::Object> pDocObj =
      pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
  if (pDocObj.IsEmpty())
    return nullptr;

  v8::Local<v8::Object> pFieldObj =
      pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
  if (pFieldObj.IsEmpty())
    return nullptr;

  CJS_Document* pJSDocument =
      static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
  CJS_Field* pJSField =
      static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));

  Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject());
  pDocument->SetFormFillEnv(m_pTargetFormFillEnv
                                ? m_pTargetFormFillEnv.Get()
                                : m_pJSEventContext->GetFormFillEnv());

  Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
  pField->AttachField(pDocument, m_strTargetName);
  return pField;
}
Esempio n. 2
0
FX_BOOL Document::getField(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;
	}

	CFX_WideString wideName = params[0].ToCFXWideString();

	CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
	CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
	if (pPDFForm->CountFields(wideName) <= 0)
	{
		vRet.SetNull();
		return TRUE;
	}

	CJS_Runtime* pRuntime = pContext->GetJSRuntime();
	JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Field"));

	v8::Isolate* isolate = GetIsolate(cc);
	CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj);
	Field* pField = (Field *)pJSField->GetEmbedObject();
	pField->AttachField(this, wideName);

	vRet = pJSField;
	return TRUE;
}
Esempio n. 3
0
Field* CJS_EventHandler::Target_Field() {
  CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
  v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj(
      pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID);
  ASSERT(!pDocObj.IsEmpty());

  v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj(
      pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID);
  ASSERT(!pFieldObj.IsEmpty());

  CJS_Document* pJSDocument =
      (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj);
  Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
  pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc
                                    : m_pJSContext->GetReaderDocument());

  CJS_Field* pJSField =
      (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pFieldObj);
  Field* pField = (Field*)pJSField->GetEmbedObject();
  pField->AttachField(pDocument, m_strTargetName);
  return pField;
}