| 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> |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 FX_BOOL app::calculate(IJS_Context* cc, | 237 FX_BOOL app::calculate(IJS_Context* cc, |
| 238 CJS_PropValue& vp, | 238 CJS_PropValue& vp, |
| 239 CFX_WideString& sError) { | 239 CFX_WideString& sError) { |
| 240 if (vp.IsSetting()) { | 240 if (vp.IsSetting()) { |
| 241 bool bVP; | 241 bool bVP; |
| 242 vp >> bVP; | 242 vp >> bVP; |
| 243 m_bCalculate = (FX_BOOL)bVP; | 243 m_bCalculate = (FX_BOOL)bVP; |
| 244 | 244 |
| 245 CJS_Context* pContext = (CJS_Context*)cc; | 245 CJS_Context* pContext = (CJS_Context*)cc; |
| 246 pContext->GetFormFillEnv() | 246 pContext->GetFormFillEnv() |
| 247 ->GetSDKDocument() | |
| 248 ->GetInterForm() | 247 ->GetInterForm() |
| 249 ->EnableCalculate((FX_BOOL)m_bCalculate); | 248 ->EnableCalculate((FX_BOOL)m_bCalculate); |
| 250 } else { | 249 } else { |
| 251 vp << (bool)m_bCalculate; | 250 vp << (bool)m_bCalculate; |
| 252 } | 251 } |
| 253 return TRUE; | 252 return TRUE; |
| 254 } | 253 } |
| 255 | 254 |
| 256 FX_BOOL app::formsVersion(IJS_Context* cc, | 255 FX_BOOL app::formsVersion(IJS_Context* cc, |
| 257 CJS_PropValue& vp, | 256 CJS_PropValue& vp, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 286 return FALSE; | 285 return FALSE; |
| 287 } | 286 } |
| 288 | 287 |
| 289 FX_BOOL app::viewerVersion(IJS_Context* cc, | 288 FX_BOOL app::viewerVersion(IJS_Context* cc, |
| 290 CJS_PropValue& vp, | 289 CJS_PropValue& vp, |
| 291 CFX_WideString& sError) { | 290 CFX_WideString& sError) { |
| 292 if (!vp.IsGetting()) | 291 if (!vp.IsGetting()) |
| 293 return FALSE; | 292 return FALSE; |
| 294 #ifdef PDF_ENABLE_XFA | 293 #ifdef PDF_ENABLE_XFA |
| 295 CJS_Context* pContext = (CJS_Context*)cc; | 294 CJS_Context* pContext = (CJS_Context*)cc; |
| 296 CPDFXFA_Document* pDoc = | 295 CPDFXFA_Document* pDoc = pContext->GetFormFillEnv()->GetXFADocument(); |
| 297 pContext->GetFormFillEnv()->GetSDKDocument()->GetXFADocument(); | |
| 298 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) { | 296 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) { |
| 299 vp << JS_NUM_VIEWERVERSION_XFA; | 297 vp << JS_NUM_VIEWERVERSION_XFA; |
| 300 return TRUE; | 298 return TRUE; |
| 301 } | 299 } |
| 302 #endif // PDF_ENABLE_XFA | 300 #endif // PDF_ENABLE_XFA |
| 303 vp << JS_NUM_VIEWERVERSION; | 301 vp << JS_NUM_VIEWERVERSION; |
| 304 return TRUE; | 302 return TRUE; |
| 305 } | 303 } |
| 306 | 304 |
| 307 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... |
| 415 if (newParams[2].GetType() != CJS_Value::VT_unknown) | 413 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 416 iType = newParams[2].ToInt(pRuntime); | 414 iType = newParams[2].ToInt(pRuntime); |
| 417 | 415 |
| 418 CFX_WideString swTitle; | 416 CFX_WideString swTitle; |
| 419 if (newParams[3].GetType() != CJS_Value::VT_unknown) | 417 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 420 swTitle = newParams[3].ToCFXWideString(pRuntime); | 418 swTitle = newParams[3].ToCFXWideString(pRuntime); |
| 421 else | 419 else |
| 422 swTitle = JSGetStringFromID(IDS_STRING_JSALERT); | 420 swTitle = JSGetStringFromID(IDS_STRING_JSALERT); |
| 423 | 421 |
| 424 pRuntime->BeginBlock(); | 422 pRuntime->BeginBlock(); |
| 425 pFormFillEnv->GetSDKDocument()->KillFocusAnnot(0); | 423 pFormFillEnv->KillFocusAnnot(0); |
| 426 | 424 |
| 427 vRet = CJS_Value(pRuntime, pFormFillEnv->JS_appAlert( | 425 vRet = CJS_Value(pRuntime, pFormFillEnv->JS_appAlert( |
| 428 swMsg.c_str(), swTitle.c_str(), iType, iIcon)); | 426 swMsg.c_str(), swTitle.c_str(), iType, iIcon)); |
| 429 pRuntime->EndBlock(); | 427 pRuntime->EndBlock(); |
| 430 return TRUE; | 428 return TRUE; |
| 431 } | 429 } |
| 432 | 430 |
| 433 FX_BOOL app::beep(IJS_Context* cc, | 431 FX_BOOL app::beep(IJS_Context* cc, |
| 434 const std::vector<CJS_Value>& params, | 432 const std::vector<CJS_Value>& params, |
| 435 CJS_Value& vRet, | 433 CJS_Value& vRet, |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 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) { |
| 799 return FALSE; | 797 return FALSE; |
| 800 } | 798 } |
| 801 | 799 |
| 802 FX_BOOL app::execDialog(IJS_Context* cc, | 800 FX_BOOL app::execDialog(IJS_Context* cc, |
| 803 const std::vector<CJS_Value>& params, | 801 const std::vector<CJS_Value>& params, |
| 804 CJS_Value& vRet, | 802 CJS_Value& vRet, |
| 805 CFX_WideString& sError) { | 803 CFX_WideString& sError) { |
| 806 return TRUE; | 804 return TRUE; |
| 807 } | 805 } |
| OLD | NEW |