summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript')
-rw-r--r--fpdfsdk/javascript/Document.cpp110
-rw-r--r--fpdfsdk/javascript/Field.cpp70
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp3
-rw-r--r--fpdfsdk/javascript/app.cpp7
4 files changed, 74 insertions, 116 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index ed87c2dbba..6b795a02ec 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -17,7 +17,6 @@
#include "core/fpdfdoc/cpdf_interform.h"
#include "core/fpdfdoc/cpdf_nametree.h"
#include "fpdfsdk/cpdfsdk_annotiterator.h"
-#include "fpdfsdk/cpdfsdk_document.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
@@ -173,8 +172,7 @@ FX_BOOL Document::numFields(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
vp << static_cast<int>(pPDFForm->CountFields(CFX_WideString()));
return TRUE;
@@ -188,15 +186,15 @@ FX_BOOL Document::dirty(IJS_Context* cc,
return FALSE;
}
if (vp.IsGetting()) {
- vp << !!m_pFormFillEnv->GetSDKDocument()->GetChangeMark();
+ vp << !!m_pFormFillEnv->GetChangeMark();
} else {
bool bChanged = false;
vp >> bChanged;
if (bChanged)
- m_pFormFillEnv->GetSDKDocument()->SetChangeMark();
+ m_pFormFillEnv->SetChangeMark();
else
- m_pFormFillEnv->GetSDKDocument()->ClearChangeMark();
+ m_pFormFillEnv->ClearChangeMark();
}
return TRUE;
}
@@ -218,12 +216,11 @@ FX_BOOL Document::pageNum(IJS_Context* cc,
return FALSE;
}
if (vp.IsGetting()) {
- if (CPDFSDK_PageView* pPageView =
- m_pFormFillEnv->GetSDKDocument()->GetCurrentView()) {
+ if (CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView()) {
vp << pPageView->GetPageIndex();
}
} else {
- int iPageCount = m_pFormFillEnv->GetSDKDocument()->GetPageCount();
+ int iPageCount = m_pFormFillEnv->GetPageCount();
int iPageNum = 0;
vp >> iPageNum;
@@ -299,8 +296,7 @@ FX_BOOL Document::getField(IJS_Context* cc,
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
CFX_WideString wideName = params[0].ToCFXWideString(pRuntime);
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
if (pPDFForm->CountFields(wideName) <= 0) {
vRet.SetNull(pRuntime);
@@ -338,8 +334,7 @@ FX_BOOL Document::getNthFieldName(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
return FALSE;
}
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
CPDF_FormField* pField = pPDFForm->GetField(nIndex, CFX_WideString());
if (!pField)
@@ -384,8 +379,7 @@ FX_BOOL Document::mailForm(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- if (!m_pFormFillEnv->GetSDKDocument()->GetPermissions(
- FPDFPERM_EXTRACT_ACCESS)) {
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) {
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return FALSE;
}
@@ -402,8 +396,7 @@ FX_BOOL Document::mailForm(IJS_Context* cc,
iLength > 4 ? params[4].ToCFXWideString(pRuntime) : L"";
CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString(pRuntime) : L"";
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CFX_ByteTextBuf textBuf;
if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
return FALSE;
@@ -502,17 +495,15 @@ FX_BOOL Document::removeField(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- if (!(m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_MODIFY) ||
- m_pFormFillEnv->GetSDKDocument()->GetPermissions(
- FPDFPERM_ANNOT_FORM))) {
+ if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM))) {
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return FALSE;
}
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
CFX_WideString sFieldName = params[0].ToCFXWideString(pRuntime);
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDFSDK_Widget*> widgets;
pInterForm->GetWidgets(sFieldName, &widgets);
if (widgets.empty())
@@ -532,8 +523,7 @@ FX_BOOL Document::removeField(IJS_Context* cc,
// If there is currently no pageview associated with the page being used
// do not create one. We may be in the process of tearing down the document
// and creating a new pageview at this point will cause bad things.
- CPDFSDK_PageView* pPageView =
- m_pFormFillEnv->GetSDKDocument()->GetPageView(pPage, false);
+ CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, false);
if (pPageView) {
#if PDF_ENABLE_XFA
pPageView->DeleteAnnot(pWidget);
@@ -541,7 +531,7 @@ FX_BOOL Document::removeField(IJS_Context* cc,
pPageView->UpdateRects(aRefresh);
}
}
- m_pFormFillEnv->GetSDKDocument()->SetChangeMark();
+ m_pFormFillEnv->SetChangeMark();
return TRUE;
}
@@ -558,21 +548,20 @@ FX_BOOL Document::resetForm(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- if (!(m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_MODIFY) ||
- m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_ANNOT_FORM) ||
- m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_FILL_FORM))) {
+ if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return FALSE;
}
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
CJS_Array aName;
if (params.empty()) {
pPDFForm->ResetForm(TRUE);
- m_pFormFillEnv->GetSDKDocument()->SetChangeMark();
+ m_pFormFillEnv->SetChangeMark();
return TRUE;
}
@@ -599,7 +588,7 @@ FX_BOOL Document::resetForm(IJS_Context* cc,
if (!aFields.empty()) {
pPDFForm->ResetForm(aFields, TRUE, TRUE);
- m_pFormFillEnv->GetSDKDocument()->SetChangeMark();
+ m_pFormFillEnv->SetChangeMark();
}
return TRUE;
@@ -664,8 +653,7 @@ FX_BOOL Document::submitForm(IJS_Context* cc,
aFields.Attach(CJS_Value(pRuntime, pValue).ToV8Array(pRuntime));
}
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
if (aFields.GetLength(pRuntime) == 0 && bEmpty) {
if (pPDFInterForm->CheckRequiredFields(nullptr, true)) {
@@ -788,8 +776,7 @@ FX_BOOL Document::info(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- CPDF_Dictionary* pDictionary =
- m_pFormFillEnv->GetSDKDocument()->GetPDFDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -843,22 +830,21 @@ FX_BOOL Document::getPropertyInternal(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- CPDF_Dictionary* pDictionary =
- m_pFormFillEnv->GetSDKDocument()->GetPDFDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
if (vp.IsGetting()) {
vp << pDictionary->GetUnicodeTextFor(propName);
} else {
- if (!m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_MODIFY)) {
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) {
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return FALSE;
}
CFX_WideString csProperty;
vp >> csProperty;
pDictionary->SetStringFor(propName, PDF_EncodeText(csProperty));
- m_pFormFillEnv->GetSDKDocument()->SetChangeMark();
+ m_pFormFillEnv->SetChangeMark();
}
return TRUE;
}
@@ -885,7 +871,7 @@ FX_BOOL Document::delay(IJS_Context* cc,
if (vp.IsGetting()) {
vp << m_bDelay;
} else {
- if (!m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_MODIFY)) {
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) {
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return FALSE;
}
@@ -947,7 +933,7 @@ FX_BOOL Document::numPages(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- vp << m_pFormFillEnv->GetSDKDocument()->GetPageCount();
+ vp << m_pFormFillEnv->GetPageCount();
return TRUE;
}
@@ -995,7 +981,7 @@ FX_BOOL Document::URL(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- vp << m_pFormFillEnv->GetSDKDocument()->GetPath();
+ vp << m_pFormFillEnv->JS_docGetFilePath();
return TRUE;
}
@@ -1017,8 +1003,7 @@ FX_BOOL Document::calculate(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
if (vp.IsGetting()) {
vp << !!pInterForm->IsCalculateEnabled();
} else {
@@ -1040,7 +1025,7 @@ FX_BOOL Document::documentFileName(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- CFX_WideString wsFilePath = m_pFormFillEnv->GetSDKDocument()->GetPath();
+ CFX_WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath();
int32_t i = wsFilePath.GetLength() - 1;
for (; i >= 0; i--) {
if (wsFilePath.GetAt(i) == L'\\' || wsFilePath.GetAt(i) == L'/')
@@ -1065,7 +1050,7 @@ FX_BOOL Document::path(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- vp << app::SysPathToPDFPath(m_pFormFillEnv->GetSDKDocument()->GetPath());
+ vp << app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath());
return TRUE;
}
@@ -1118,8 +1103,7 @@ FX_BOOL Document::getAnnot(IJS_Context* cc,
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
int nPageNo = params[0].ToInt(pRuntime);
CFX_WideString swAnnotName = params[1].ToCFXWideString(pRuntime);
- CPDFSDK_PageView* pPageView =
- m_pFormFillEnv->GetSDKDocument()->GetPageView(nPageNo);
+ CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(nPageNo);
if (!pPageView)
return FALSE;
@@ -1170,12 +1154,11 @@ FX_BOOL Document::getAnnots(IJS_Context* cc,
// TODO(tonikitoo): Add support supported parameters as per
// the PDF spec.
- int nPageNo = m_pFormFillEnv->GetSDKDocument()->GetPageCount();
+ int nPageNo = m_pFormFillEnv->GetPageCount();
CJS_Array annots;
for (int i = 0; i < nPageNo; ++i) {
- CPDFSDK_PageView* pPageView =
- m_pFormFillEnv->GetSDKDocument()->GetPageView(i);
+ CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(i);
if (!pPageView)
return FALSE;
@@ -1392,13 +1375,13 @@ FX_BOOL Document::calculateNow(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- if (!(m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_MODIFY) ||
- m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_ANNOT_FORM) ||
- m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_FILL_FORM))) {
+ if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return FALSE;
}
- m_pFormFillEnv->GetSDKDocument()->GetInterForm()->OnCalculate();
+ m_pFormFillEnv->GetInterForm()->OnCalculate();
return TRUE;
}
@@ -1416,8 +1399,7 @@ FX_BOOL Document::getPageNthWord(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- if (!m_pFormFillEnv->GetSDKDocument()->GetPermissions(
- FPDFPERM_EXTRACT_ACCESS)) {
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) {
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return FALSE;
}
@@ -1429,7 +1411,7 @@ FX_BOOL Document::getPageNthWord(IJS_Context* cc,
int nWordNo = params.size() > 1 ? params[1].ToInt(pRuntime) : 0;
bool bStrip = params.size() > 2 ? params[2].ToBool(pRuntime) : true;
- CPDF_Document* pDocument = m_pFormFillEnv->GetSDKDocument()->GetPDFDocument();
+ CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (!pDocument)
return FALSE;
@@ -1476,8 +1458,7 @@ FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- if (!m_pFormFillEnv->GetSDKDocument()->GetPermissions(
- FPDFPERM_EXTRACT_ACCESS)) {
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) {
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
@@ -1492,14 +1473,13 @@ FX_BOOL Document::getPageNumWords(IJS_Context* cc,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return FALSE;
}
- if (!m_pFormFillEnv->GetSDKDocument()->GetPermissions(
- FPDFPERM_EXTRACT_ACCESS)) {
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) {
sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
return FALSE;
}
CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
int nPageNo = params.size() > 0 ? params[0].ToInt(pRuntime) : 0;
- CPDF_Document* pDocument = m_pFormFillEnv->GetSDKDocument()->GetPDFDocument();
+ CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
return FALSE;
@@ -1686,7 +1666,7 @@ FX_BOOL Document::gotoNamedDest(IJS_Context* cc,
CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
CFX_WideString wideName = params[0].ToCFXWideString(pRuntime);
CFX_ByteString utf8Name = wideName.UTF8Encode();
- CPDF_Document* pDocument = m_pFormFillEnv->GetSDKDocument()->GetPDFDocument();
+ CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (!pDocument)
return FALSE;
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 652f1e640d..a2118a77c0 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -15,7 +15,6 @@
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfdoc/cpdf_interform.h"
-#include "fpdfsdk/cpdfsdk_document.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
@@ -213,13 +212,11 @@ FX_BOOL Field::AttachField(Document* pDocument,
const CFX_WideString& csFieldName) {
m_pJSDoc = pDocument;
m_pFormFillEnv.Reset(pDocument->GetFormFillEnv());
- m_bCanSet =
- m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_FILL_FORM) ||
- m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_ANNOT_FORM) ||
- m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_MODIFY);
+ m_bCanSet = m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY);
- CPDFSDK_InterForm* pRDInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
CFX_WideString swFieldNameTemp = csFieldName;
swFieldNameTemp.Replace(L"..", L".");
@@ -246,8 +243,7 @@ std::vector<CPDF_FormField*> Field::GetFormFields(
CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& csFieldName) {
std::vector<CPDF_FormField*> fields;
- CPDFSDK_InterForm* pReaderInterForm =
- pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pReaderInterForm = pFormFillEnv->GetInterForm();
CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) {
if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName))
@@ -266,8 +262,7 @@ void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
FX_BOOL bChangeMark,
FX_BOOL bResetAP,
FX_BOOL bRefresh) {
- CPDFSDK_InterForm* pInterForm =
- pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
if (bResetAP) {
std::vector<CPDFSDK_Widget*> widgets;
@@ -301,17 +296,16 @@ void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
// TODO(dsinclair): Determine if all widgets share the same
// CPDFSDK_InterForm. If that's the case, we can move the code to
- // |GetSDKDocument| out of the loop.
+ // |GetFormFillEnv| out of the loop.
for (CPDFSDK_Widget* pWidget : widgets) {
pWidget->GetInterForm()
->GetFormFillEnv()
- ->GetSDKDocument()
->UpdateAllViews(nullptr, pWidget);
}
}
if (bChangeMark)
- pFormFillEnv->GetSDKDocument()->SetChangeMark();
+ pFormFillEnv->SetChangeMark();
}
void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -321,7 +315,7 @@ void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
FX_BOOL bRefresh) {
ASSERT(pFormControl);
- CPDFSDK_InterForm* pForm = pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pForm = pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false);
if (pWidget) {
@@ -339,20 +333,19 @@ void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
if (bRefresh) {
CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
- pInterForm->GetFormFillEnv()->GetSDKDocument()->UpdateAllViews(nullptr,
- pWidget);
+ pInterForm->GetFormFillEnv()->UpdateAllViews(nullptr, pWidget);
}
}
if (bChangeMark)
- pFormFillEnv->GetSDKDocument()->SetChangeMark();
+ pFormFillEnv->SetChangeMark();
}
CPDFSDK_Widget* Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormControl* pFormControl,
bool createIfNeeded) {
- CPDFSDK_InterForm* pInterForm = static_cast<CPDFSDK_InterForm*>(
- pFormFillEnv->GetSDKDocument()->GetInterForm());
+ CPDFSDK_InterForm* pInterForm =
+ static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm());
return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded)
: nullptr;
}
@@ -865,8 +858,7 @@ FX_BOOL Field::calcOrderIndex(IJS_Context* cc,
return FALSE;
}
- CPDFSDK_InterForm* pRDInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField);
}
@@ -1270,8 +1262,7 @@ FX_BOOL Field::display(IJS_Context* cc,
CPDF_FormField* pFormField = FieldArray[0];
ASSERT(pFormField);
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
if (!pWidget)
@@ -1301,8 +1292,7 @@ void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& swFieldName,
int nControlIndex,
int number) {
- CPDFSDK_InterForm* pInterForm =
- pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray =
GetFormFields(pFormFillEnv, swFieldName);
for (CPDF_FormField* pFormField : FieldArray) {
@@ -1536,8 +1526,7 @@ FX_BOOL Field::hidden(IJS_Context* cc,
CPDF_FormField* pFormField = FieldArray[0];
ASSERT(pFormField);
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField), false);
if (!pWidget)
@@ -1650,8 +1639,7 @@ FX_BOOL Field::lineWidth(IJS_Context* cc,
if (!pFormControl)
return FALSE;
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
if (!pFormField->CountControls())
return FALSE;
@@ -1670,8 +1658,7 @@ void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& swFieldName,
int nControlIndex,
int number) {
- CPDFSDK_InterForm* pInterForm =
- pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray =
GetFormFields(pFormFillEnv, swFieldName);
for (CPDF_FormField* pFormField : FieldArray) {
@@ -1844,8 +1831,7 @@ FX_BOOL Field::page(IJS_Context* cc,
return FALSE;
std::vector<CPDFSDK_Widget*> widgets;
- m_pFormFillEnv->GetSDKDocument()->GetInterForm()->GetWidgets(pFormField,
- &widgets);
+ m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets);
if (widgets.empty()) {
vp << (int32_t)-1;
@@ -1913,8 +1899,7 @@ void Field::SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv,
FX_BOOL Field::print(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return FALSE;
@@ -2080,8 +2065,7 @@ FX_BOOL Field::rect(IJS_Context* cc,
return FALSE;
CPDF_FormField* pFormField = FieldArray[0];
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
if (!pWidget)
@@ -2107,8 +2091,7 @@ void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& swFieldName,
int nControlIndex,
const CFX_FloatRect& rect) {
- CPDFSDK_InterForm* pInterForm =
- pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray =
GetFormFields(pFormFillEnv, swFieldName);
for (CPDF_FormField* pFormField : FieldArray) {
@@ -3216,8 +3199,7 @@ FX_BOOL Field::setFocus(IJS_Context* cc,
if (nCount < 1)
return FALSE;
- CPDFSDK_InterForm* pInterForm =
- m_pFormFillEnv->GetSDKDocument()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget = nullptr;
if (nCount == 1) {
pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false);
@@ -3228,7 +3210,7 @@ FX_BOOL Field::setFocus(IJS_Context* cc,
if (!pPage)
return FALSE;
if (CPDFSDK_PageView* pCurPageView =
- m_pFormFillEnv->GetSDKDocument()->GetPageView(pPage, true)) {
+ m_pFormFillEnv->GetPageView(pPage, true)) {
for (int32_t i = 0; i < nCount; i++) {
if (CPDFSDK_Widget* pTempWidget =
pInterForm->GetWidget(pFormField->GetControl(i), false)) {
@@ -3243,7 +3225,7 @@ FX_BOOL Field::setFocus(IJS_Context* cc,
if (pWidget) {
CPDFSDK_Annot::ObservedPtr pObserved(pWidget);
- m_pFormFillEnv->GetSDKDocument()->SetFocusAnnot(&pObserved);
+ m_pFormFillEnv->SetFocusAnnot(&pObserved);
}
return TRUE;
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index d4f17a8b2e..344af5aa02 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -11,7 +11,6 @@
#include "core/fpdfdoc/cpdf_interform.h"
#include "core/fxcrt/fx_ext.h"
-#include "fpdfsdk/cpdfsdk_document.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/javascript/Field.h"
@@ -1660,7 +1659,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
CPDFSDK_InterForm* pReaderInterForm =
- pContext->GetFormFillEnv()->GetSDKDocument()->GetInterForm();
+ pContext->GetFormFillEnv()->GetInterForm();
CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
CFX_WideString sFunction = params[0].ToCFXWideString(pRuntime);
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index b41b8727ab..325a84b1f8 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -9,7 +9,6 @@
#include <memory>
#include <vector>
-#include "fpdfsdk/cpdfsdk_document.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/javascript/Document.h"
@@ -245,7 +244,6 @@ FX_BOOL app::calculate(IJS_Context* cc,
CJS_Context* pContext = (CJS_Context*)cc;
pContext->GetFormFillEnv()
- ->GetSDKDocument()
->GetInterForm()
->EnableCalculate((FX_BOOL)m_bCalculate);
} else {
@@ -294,8 +292,7 @@ FX_BOOL app::viewerVersion(IJS_Context* cc,
return FALSE;
#ifdef PDF_ENABLE_XFA
CJS_Context* pContext = (CJS_Context*)cc;
- CPDFXFA_Document* pDoc =
- pContext->GetFormFillEnv()->GetSDKDocument()->GetXFADocument();
+ CPDFXFA_Document* pDoc = pContext->GetFormFillEnv()->GetXFADocument();
if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) {
vp << JS_NUM_VIEWERVERSION_XFA;
return TRUE;
@@ -423,7 +420,7 @@ FX_BOOL app::alert(IJS_Context* cc,
swTitle = JSGetStringFromID(IDS_STRING_JSALERT);
pRuntime->BeginBlock();
- pFormFillEnv->GetSDKDocument()->KillFocusAnnot(0);
+ pFormFillEnv->KillFocusAnnot(0);
vRet = CJS_Value(pRuntime, pFormFillEnv->JS_appAlert(
swMsg.c_str(), swTitle.c_str(), iType, iIcon));