| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/javascript/app.h" | 7 #include "fpdfsdk/javascript/app.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "fpdfsdk/cpdfsdk_document.h" | |
| 13 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 12 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 14 #include "fpdfsdk/cpdfsdk_interform.h" | 13 #include "fpdfsdk/cpdfsdk_interform.h" |
| 15 #include "fpdfsdk/javascript/Document.h" | 14 #include "fpdfsdk/javascript/Document.h" |
| 16 #include "fpdfsdk/javascript/JS_Define.h" | 15 #include "fpdfsdk/javascript/JS_Define.h" |
| 17 #include "fpdfsdk/javascript/JS_EventHandler.h" | 16 #include "fpdfsdk/javascript/JS_EventHandler.h" |
| 18 #include "fpdfsdk/javascript/JS_Object.h" | 17 #include "fpdfsdk/javascript/JS_Object.h" |
| 19 #include "fpdfsdk/javascript/JS_Value.h" | 18 #include "fpdfsdk/javascript/JS_Value.h" |
| 20 #include "fpdfsdk/javascript/cjs_context.h" | 19 #include "fpdfsdk/javascript/cjs_context.h" |
| 21 #include "fpdfsdk/javascript/cjs_runtime.h" | 20 #include "fpdfsdk/javascript/cjs_runtime.h" |
| 22 #include "fpdfsdk/javascript/resource.h" | 21 #include "fpdfsdk/javascript/resource.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 FX_BOOL app::calculate(IJS_Context* cc, | 237 FX_BOOL app::calculate(IJS_Context* cc, |
| 239 CJS_PropValue& vp, | 238 CJS_PropValue& vp, |
| 240 CFX_WideString& sError) { | 239 CFX_WideString& sError) { |
| 241 if (vp.IsSetting()) { | 240 if (vp.IsSetting()) { |
| 242 bool bVP; | 241 bool bVP; |
| 243 vp >> bVP; | 242 vp >> bVP; |
| 244 m_bCalculate = (FX_BOOL)bVP; | 243 m_bCalculate = (FX_BOOL)bVP; |
| 245 | 244 |
| 246 CJS_Context* pContext = (CJS_Context*)cc; | 245 CJS_Context* pContext = (CJS_Context*)cc; |
| 247 pContext->GetFormFillEnv() | 246 pContext->GetFormFillEnv() |
| 248 ->GetSDKDocument() | |
| 249 ->GetInterForm() | 247 ->GetInterForm() |
| 250 ->EnableCalculate((FX_BOOL)m_bCalculate); | 248 ->EnableCalculate((FX_BOOL)m_bCalculate); |
| 251 } else { | 249 } else { |
| 252 vp << (bool)m_bCalculate; | 250 vp << (bool)m_bCalculate; |
| 253 } | 251 } |
| 254 return TRUE; | 252 return TRUE; |
| 255 } | 253 } |
| 256 | 254 |
| 257 FX_BOOL app::formsVersion(IJS_Context* cc, | 255 FX_BOOL app::formsVersion(IJS_Context* cc, |
| 258 CJS_PropValue& vp, | 256 CJS_PropValue& vp, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 287 return FALSE; | 285 return FALSE; |
| 288 } | 286 } |
| 289 | 287 |
| 290 FX_BOOL app::viewerVersion(IJS_Context* cc, | 288 FX_BOOL app::viewerVersion(IJS_Context* cc, |
| 291 CJS_PropValue& vp, | 289 CJS_PropValue& vp, |
| 292 CFX_WideString& sError) { | 290 CFX_WideString& sError) { |
| 293 if (!vp.IsGetting()) | 291 if (!vp.IsGetting()) |
| 294 return FALSE; | 292 return FALSE; |
| 295 #ifdef PDF_ENABLE_XFA | 293 #ifdef PDF_ENABLE_XFA |
| 296 CJS_Context* pContext = (CJS_Context*)cc; | 294 CJS_Context* pContext = (CJS_Context*)cc; |
| 297 CPDFXFA_Document* pDoc = | 295 CPDFXFA_Document* pDoc = pContext->GetFormFillEnv()->GetXFADocument(); |
| 298 pContext->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 299 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) { | 296 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) { |
| 300 vp << JS_NUM_VIEWERVERSION_XFA; | 297 vp << JS_NUM_VIEWERVERSION_XFA; |
| 301 return TRUE; | 298 return TRUE; |
| 302 } | 299 } |
| 303 #endif // PDF_ENABLE_XFA | 300 #endif // PDF_ENABLE_XFA |
| 304 vp << JS_NUM_VIEWERVERSION; | 301 vp << JS_NUM_VIEWERVERSION; |
| 305 return TRUE; | 302 return TRUE; |
| 306 } | 303 } |
| 307 | 304 |
| 308 FX_BOOL app::platform(IJS_Context* cc, | 305 FX_BOOL app::platform(IJS_Context* cc, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 if (newParams[2].GetType() != CJS_Value::VT_unknown) | 413 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 417 iType = newParams[2].ToInt(pRuntime); | 414 iType = newParams[2].ToInt(pRuntime); |
| 418 | 415 |
| 419 CFX_WideString swTitle; | 416 CFX_WideString swTitle; |
| 420 if (newParams[3].GetType() != CJS_Value::VT_unknown) | 417 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 421 swTitle = newParams[3].ToCFXWideString(pRuntime); | 418 swTitle = newParams[3].ToCFXWideString(pRuntime); |
| 422 else | 419 else |
| 423 swTitle = JSGetStringFromID(IDS_STRING_JSALERT); | 420 swTitle = JSGetStringFromID(IDS_STRING_JSALERT); |
| 424 | 421 |
| 425 pRuntime->BeginBlock(); | 422 pRuntime->BeginBlock(); |
| 426 pFormFillEnv->GetSDKDocument()->KillFocusAnnot(0); | 423 pFormFillEnv->KillFocusAnnot(0); |
| 427 | 424 |
| 428 vRet = CJS_Value(pRuntime, pFormFillEnv->JS_appAlert( | 425 vRet = CJS_Value(pRuntime, pFormFillEnv->JS_appAlert( |
| 429 swMsg.c_str(), swTitle.c_str(), iType, iIcon)); | 426 swMsg.c_str(), swTitle.c_str(), iType, iIcon)); |
| 430 pRuntime->EndBlock(); | 427 pRuntime->EndBlock(); |
| 431 return TRUE; | 428 return TRUE; |
| 432 } | 429 } |
| 433 | 430 |
| 434 FX_BOOL app::beep(IJS_Context* cc, | 431 FX_BOOL app::beep(IJS_Context* cc, |
| 435 const std::vector<CJS_Value>& params, | 432 const std::vector<CJS_Value>& params, |
| 436 CJS_Value& vRet, | 433 CJS_Value& vRet, |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 796 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 800 return FALSE; | 797 return FALSE; |
| 801 } | 798 } |
| 802 | 799 |
| 803 FX_BOOL app::execDialog(IJS_Context* cc, | 800 FX_BOOL app::execDialog(IJS_Context* cc, |
| 804 const std::vector<CJS_Value>& params, | 801 const std::vector<CJS_Value>& params, |
| 805 CJS_Value& vRet, | 802 CJS_Value& vRet, |
| 806 CFX_WideString& sError) { | 803 CFX_WideString& sError) { |
| 807 return TRUE; | 804 return TRUE; |
| 808 } | 805 } |
| OLD | NEW |