| Index: fpdfsdk/javascript/Document.cpp
|
| diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
|
| index 540712aa4c8764a35a695356e26f265b7ff04bd9..0b08f66f338a7142a2ec76e187ab0d856a6c5fe5 100644
|
| --- a/fpdfsdk/javascript/Document.cpp
|
| +++ b/fpdfsdk/javascript/Document.cpp
|
| @@ -172,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;
|
| @@ -187,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;
|
| }
|
| @@ -217,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;
|
|
|
| @@ -298,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);
|
| @@ -337,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)
|
| @@ -383,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;
|
| }
|
| @@ -401,17 +396,16 @@ 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;
|
|
|
| pRuntime->BeginBlock();
|
| - CPDFSDK_FormFillEnvironment* pEnv = pContext->GetFormFillEnv();
|
| - pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI,
|
| - cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(),
|
| - cMsg.c_str());
|
| + CPDFSDK_FormFillEnvironment* pFormFillEnv = pContext->GetFormFillEnv();
|
| + pFormFillEnv->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;
|
| }
|
| @@ -501,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())
|
| @@ -531,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);
|
| @@ -540,7 +531,7 @@ FX_BOOL Document::removeField(IJS_Context* cc,
|
| pPageView->UpdateRects(aRefresh);
|
| }
|
| }
|
| - m_pFormFillEnv->GetSDKDocument()->SetChangeMark();
|
| + m_pFormFillEnv->SetChangeMark();
|
|
|
| return TRUE;
|
| }
|
| @@ -557,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;
|
| }
|
|
|
| @@ -598,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;
|
| @@ -663,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)) {
|
| @@ -762,9 +751,9 @@ FX_BOOL Document::mailDoc(IJS_Context* cc,
|
| }
|
|
|
| pRuntime->BeginBlock();
|
| - CPDFSDK_FormFillEnvironment* pEnv = pRuntime->GetFormFillEnv();
|
| - pEnv->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), cSubject.c_str(),
|
| - cCc.c_str(), cBcc.c_str(), cMsg.c_str());
|
| + CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
|
| + pFormFillEnv->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), cSubject.c_str(),
|
| + cCc.c_str(), cBcc.c_str(), cMsg.c_str());
|
| pRuntime->EndBlock();
|
|
|
| return TRUE;
|
| @@ -787,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;
|
|
|
| @@ -842,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;
|
| }
|
| @@ -884,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;
|
| }
|
| @@ -946,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;
|
| }
|
|
|
| @@ -994,7 +981,7 @@ FX_BOOL Document::URL(IJS_Context* cc,
|
| sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
|
| return FALSE;
|
| }
|
| - vp << m_pFormFillEnv->GetSDKDocument()->JS_docGetFilePath();
|
| + vp << m_pFormFillEnv->JS_docGetFilePath();
|
| return TRUE;
|
| }
|
|
|
| @@ -1016,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 {
|
| @@ -1039,8 +1025,7 @@ FX_BOOL Document::documentFileName(IJS_Context* cc,
|
| sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
|
| return FALSE;
|
| }
|
| - CFX_WideString wsFilePath =
|
| - m_pFormFillEnv->GetSDKDocument()->JS_docGetFilePath();
|
| + 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,8 +1050,7 @@ FX_BOOL Document::path(IJS_Context* cc,
|
| sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
|
| return FALSE;
|
| }
|
| - vp << app::SysPathToPDFPath(
|
| - m_pFormFillEnv->GetSDKDocument()->JS_docGetFilePath());
|
| + vp << app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath());
|
| return TRUE;
|
| }
|
|
|
| @@ -1119,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;
|
|
|
| @@ -1171,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;
|
|
|
| @@ -1393,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;
|
| }
|
|
|
| @@ -1417,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;
|
| }
|
| @@ -1430,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;
|
|
|
| @@ -1477,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;
|
| }
|
| @@ -1493,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;
|
| @@ -1687,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;
|
|
|
|
|