summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp50
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h12
2 files changed, 36 insertions, 26 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index d47c145700..0833759429 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -984,34 +984,44 @@ bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc,
return true;
}
-bool CPDFXFA_DocEnvironment::SetGlobalProperty(CXFA_FFDoc* hDoc,
- const ByteStringView& szPropName,
- CFXJSE_Value* pValue) {
+bool CPDFXFA_DocEnvironment::SetPropertyInNonXFAGlobalObject(
+ CXFA_FFDoc* hDoc,
+ const ByteStringView& szPropName,
+ CFXJSE_Value* pValue) {
if (hDoc != m_pContext->GetXFADoc())
return false;
- if (!m_pContext->GetFormFillEnv() ||
- !m_pContext->GetFormFillEnv()->GetIJSRuntime()) {
- return false;
- }
+
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
- IJS_EventContext* pContext = pFormFillEnv->GetIJSRuntime()->NewEventContext();
- bool bRet = pFormFillEnv->GetIJSRuntime()->SetValueByName(szPropName, pValue);
- pFormFillEnv->GetIJSRuntime()->ReleaseEventContext(pContext);
+ if (!pFormFillEnv)
+ return false;
+
+ IJS_Runtime* pIJSRuntime = pFormFillEnv->GetIJSRuntime();
+ if (!pIJSRuntime)
+ return false;
+
+ IJS_EventContext* pContext = pIJSRuntime->NewEventContext();
+ bool bRet = pIJSRuntime->SetValueByNameInGlobalObject(szPropName, pValue);
+ pIJSRuntime->ReleaseEventContext(pContext);
return bRet;
}
-bool CPDFXFA_DocEnvironment::GetGlobalProperty(CXFA_FFDoc* hDoc,
- const ByteStringView& szPropName,
- CFXJSE_Value* pValue) {
+bool CPDFXFA_DocEnvironment::GetPropertyFromNonXFAGlobalObject(
+ CXFA_FFDoc* hDoc,
+ const ByteStringView& szPropName,
+ CFXJSE_Value* pValue) {
if (hDoc != m_pContext->GetXFADoc())
return false;
- if (!m_pContext->GetFormFillEnv() ||
- !m_pContext->GetFormFillEnv()->GetIJSRuntime()) {
- return false;
- }
+
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
- IJS_EventContext* pContext = pFormFillEnv->GetIJSRuntime()->NewEventContext();
- bool bRet = pFormFillEnv->GetIJSRuntime()->GetValueByName(szPropName, pValue);
- pFormFillEnv->GetIJSRuntime()->ReleaseEventContext(pContext);
+ if (!pFormFillEnv)
+ return false;
+
+ IJS_Runtime* pIJSRuntime = pFormFillEnv->GetIJSRuntime();
+ if (!pIJSRuntime)
+ return false;
+
+ IJS_EventContext* pContext = pIJSRuntime->NewEventContext();
+ bool bRet = pIJSRuntime->GetValueByNameFromGlobalObject(szPropName, pValue);
+ pIJSRuntime->ReleaseEventContext(pContext);
return bRet;
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
index 4e037210b2..03aae3d765 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
@@ -64,12 +64,12 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment {
bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) override;
- bool GetGlobalProperty(CXFA_FFDoc* hDoc,
- const ByteStringView& szPropName,
- CFXJSE_Value* pValue) override;
- bool SetGlobalProperty(CXFA_FFDoc* hDoc,
- const ByteStringView& szPropName,
- CFXJSE_Value* pValue) override;
+ bool GetPropertyFromNonXFAGlobalObject(CXFA_FFDoc* hDoc,
+ const ByteStringView& szPropName,
+ CFXJSE_Value* pValue) override;
+ bool SetPropertyInNonXFAGlobalObject(CXFA_FFDoc* hDoc,
+ const ByteStringView& szPropName,
+ CFXJSE_Value* pValue) override;
RetainPtr<IFX_SeekableReadStream> OpenLinkedFile(
CXFA_FFDoc* hDoc,