本文整理汇总了C++中CJS_Context类的典型用法代码示例。如果您正苦于以下问题:C++ CJS_Context类的具体用法?C++ CJS_Context怎么用?C++ CJS_Context使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CJS_Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
ASSERT(m_pDocument != NULL);
if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE;
int iLength = params.size();
FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE;
CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L"";
CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L"";
CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L"";
CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"";
CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L"";
CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
ASSERT(pInterForm != NULL);
CFX_ByteTextBuf textBuf;
if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
return FALSE;
CJS_Context* pContext = (CJS_Context*)cc;
ASSERT(pContext != NULL);
CPDFDoc_Environment* pEnv = pContext->GetReaderApp();
ASSERT(pEnv != NULL);
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
ASSERT(pRuntime != NULL);
pRuntime->BeginBlock();
pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str());
pRuntime->EndBlock();
return TRUE;
}
示例2: activeDocs
FX_BOOL app::activeDocs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
if (!vp.IsGetting())
return FALSE;
CJS_Context* pContext = (CJS_Context *)cc;
CPDFDoc_Environment* pApp = pContext->GetReaderApp();
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
CJS_Array aDocs(pRuntime->GetIsolate());
if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
{
CJS_Document* pJSDocument = NULL;
if (pDoc == pCurDoc)
{
JSFXObject pObj = JS_GetThisObj(*pRuntime);
if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"Document"))
pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pObj);
}
else
{
JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime,L"Document"));
pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pObj);
ASSERT(pJSDocument != NULL);
}
aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolate(),pJSDocument));
}
if (aDocs.GetLength() > 0)
vp << aDocs;
else
vp.SetNull();
return TRUE;
}
示例3: getField
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;
}
示例4: calculate
FX_BOOL app::calculate(OBJ_PROP_PARAMS)
{
if (vp.IsSetting())
{
bool bVP;
vp >> bVP;
m_bCalculate = (FX_BOOL)bVP;
CJS_Context* pContext = (CJS_Context*)cc;
ASSERT(pContext != NULL);
CPDFDoc_Environment* pApp = pContext->GetReaderApp();
ASSERT(pApp != NULL);
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
ASSERT(pRuntime != NULL);
CJS_Array aDocs(pRuntime->GetIsolate());
// int iNumDocs = pApp->CountDocuments();
//
// for (int iIndex = 0;iIndex < iNumDocs; iIndex++)
// {
if (CPDFSDK_Document* pDoc = pApp->GetCurrentDoc())
{
CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDoc->GetInterForm();
ASSERT(pInterForm != NULL);
pInterForm->EnableCalculate((FX_BOOL)m_bCalculate);
}
// }
}
示例5: addIcon
FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
CJS_Context* pContext = (CJS_Context*)cc;
if (params.size() != 2) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
CFX_WideString swIconName = params[0].ToCFXWideString();
JSFXObject pJSIcon = params[1].ToV8Object();
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
return FALSE;
}
CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject();
if (!pEmbedObj) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
return FALSE;
}
Icon* pIcon = (Icon*)pEmbedObj;
if (!m_pIconTree)
m_pIconTree = new IconTree();
IconElement* pNewIcon = new IconElement();
pNewIcon->IconName = swIconName;
pNewIcon->NextIcon = NULL;
pNewIcon->IconStream = pIcon;
m_pIconTree->InsertIconElement(pNewIcon);
return TRUE;
}
示例6: GetIsolate
static v8::Isolate* GetIsolate(IFXJS_Context* cc) {
CJS_Context* pContext = (CJS_Context*)cc;
ASSERT(pContext != NULL);
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
ASSERT(pRuntime != NULL);
return pRuntime->GetIsolate();
}
示例7: activeDocs
FX_BOOL app::activeDocs(OBJ_PROP_PARAMS)
{
if (vp.IsGetting())
{
CJS_Context* pContext = (CJS_Context *)cc;
ASSERT(pContext != NULL);
CPDFDoc_Environment* pApp = pContext->GetReaderApp();
ASSERT(pApp != NULL);
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
ASSERT(pRuntime != NULL);
CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
CJS_Array aDocs(pRuntime->GetIsolate());
// int iNumDocs = pApp->CountDocuments();
// for(int iIndex = 0; iIndex<iNumDocs; iIndex++)
// {
CPDFSDK_Document* pDoc = pApp->GetCurrentDoc();
if (pDoc)
{
CJS_Document * pJSDocument = NULL;
if (pDoc == pCurDoc)
{
JSFXObject pObj = JS_GetThisObj(*pRuntime);
if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"Document"))
{
pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pObj);
}
}
else
{
JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime,L"Document"));
pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(),pObj);
ASSERT(pJSDocument != NULL);
// pDocument->AttachDoc(pDoc);
}
aDocs.SetElement(0,CJS_Value(pRuntime->GetIsolate(),pJSDocument));
}
// }
if (aDocs.GetLength() > 0)
vp << aDocs;
else
vp.SetNull();
return TRUE;
}
return FALSE;
}
示例8: getPrintParams
FX_BOOL Document::getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
CJS_Context* pContext = (CJS_Context*)cc;
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"PrintParamsObj"));
// Not implemented yet.
vRet = pRetObj;
return TRUE;
}
示例9:
FX_BOOL CJS_Document::InitInstance(IFXJS_Context* cc)
{
CJS_Context* pContext = (CJS_Context*)cc;
ASSERT(pContext != NULL);
Document* pDoc = (Document*)GetEmbedObject();
ASSERT(pDoc != NULL);
pDoc->AttachDoc(pContext->GetReaderDocument());
pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate());
return TRUE;
};
示例10:
FX_BOOL CJS_Global::InitInstance(IFXJS_Context* cc)
{
CJS_Context* pContext = (CJS_Context*)cc;
ASSERT(pContext != NULL);
global_alternate* pGlobal = (global_alternate*)GetEmbedObject();
ASSERT(pGlobal != NULL);
pGlobal->Initial(pContext->GetReaderApp());
return TRUE;
};
示例11: calculate
bool app::calculate(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
bool bVP;
vp >> bVP;
m_bCalculate = (bool)bVP;
CJS_Context* pContext = (CJS_Context*)cc;
pContext->GetFormFillEnv()->GetInterForm()->EnableCalculate(
(bool)m_bCalculate);
} else {
示例12: calculate
FX_BOOL app::calculate(IFXJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
if (vp.IsSetting()) {
bool bVP;
vp >> bVP;
m_bCalculate = (FX_BOOL)bVP;
CJS_Context* pContext = (CJS_Context*)cc;
CPDFDoc_Environment* pApp = pContext->GetReaderApp();
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
CJS_Array aDocs(pRuntime->GetIsolate());
if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument())
pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate);
} else {
示例13: JSGetStringFromID
FX_BOOL Document::icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
if (vp.IsSetting()) {
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
return FALSE;
}
if (!m_pIconTree)
{
vp.SetNull();
return TRUE;
}
CJS_Array Icons(m_isolate);
IconElement* pIconElement = NULL;
int iIconTreeLength = m_pIconTree->GetLength();
CJS_Context* pContext = (CJS_Context *)cc;
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
for (int i = 0; i < iIconTreeLength; i++)
{
pIconElement = (*m_pIconTree)[i];
JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Icon"));
if (pObj.IsEmpty()) return FALSE;
CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj);
if (!pJS_Icon) return FALSE;
Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
if (!pIcon)return FALSE;
pIcon->SetStream(pIconElement->IconStream->GetStream());
pIcon->SetIconName(pIconElement->IconName);
Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon));
}
vp << Icons;
return TRUE;
}
示例14: getIcon
FX_BOOL Document::getIcon(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;
}
if(!m_pIconTree)
return FALSE;
CFX_WideString swIconName = params[0].ToCFXWideString();
int iIconCounts = m_pIconTree->GetLength();
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
for (int i = 0; i < iIconCounts; i++)
{
if ((*m_pIconTree)[i]->IconName == swIconName)
{
Icon* pRetIcon = (*m_pIconTree)[i]->IconStream;
JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Icon"));
if (pObj.IsEmpty()) return FALSE;
CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj);
if (!pJS_Icon) return FALSE;
Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
if (!pIcon)return FALSE;
pIcon->SetIconName(swIconName);
pIcon->SetStream(pRetIcon->GetStream());
vRet = pJS_Icon;
return TRUE;
}
}
return FALSE;
}
示例15: activeDocs
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;
}