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
bool app::activeDocs(IJS_Context* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError) {
  if (!vp.IsGetting())
    return false;

  CJS_Context* pContext = (CJS_Context*)cc;
  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
  CJS_Document* pJSDocument = nullptr;
  v8::Local<v8::Object> pObj = pRuntime->GetThisObj();
  if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) {
    pJSDocument = static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj));
  }

  CJS_Array aDocs;
  aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument));

  if (aDocs.GetLength(pRuntime) > 0)
    vp << aDocs;
  else
    vp.GetJSValue()->SetNull(pRuntime);

  return true;
}