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 "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
11 #include "core/fxcrt/include/fx_ext.h" | 11 #include "core/fxcrt/include/fx_ext.h" |
12 #include "fxjse/include/cfxjse_arguments.h" | 12 #include "fxjse/include/cfxjse_arguments.h" |
13 #include "fxjse/include/cfxjse_class.h" | 13 #include "fxjse/include/cfxjse_class.h" |
14 #include "fxjse/include/cfxjse_value.h" | 14 #include "fxjse/include/cfxjse_value.h" |
15 #include "xfa/fgas/localization/fgas_locale.h" | 15 #include "xfa/fgas/localization/fgas_locale.h" |
16 #include "xfa/fxfa/app/xfa_ffnotify.h" | 16 #include "xfa/fxfa/app/xfa_ffnotify.h" |
17 #include "xfa/fxfa/fm2js/xfa_program.h" | 17 #include "xfa/fxfa/fm2js/xfa_program.h" |
18 #include "xfa/fxfa/parser/xfa_document.h" | 18 #include "xfa/fxfa/parser/xfa_document.h" |
19 #include "xfa/fxfa/parser/xfa_localevalue.h" | 19 #include "xfa/fxfa/parser/xfa_localevalue.h" |
20 #include "xfa/fxfa/parser/xfa_parser.h" | |
21 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 20 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
22 #include "xfa/fxfa/parser/xfa_script_imp.h" | 21 #include "xfa/fxfa/parser/xfa_script_imp.h" |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 const double kFinancialPrecision = 0.00000001; | 25 const double kFinancialPrecision = 0.00000001; |
27 | 26 |
28 struct XFA_FMHtmlReserveCode { | 27 struct XFA_FMHtmlReserveCode { |
29 uint32_t m_uCode; | 28 uint32_t m_uCode; |
30 const FX_WCHAR* m_htmlReserve; | 29 const FX_WCHAR* m_htmlReserve; |
(...skipping 4877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4908 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 4907 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
4909 if (args.GetLength() != 1) { | 4908 if (args.GetLength() != 1) { |
4910 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get"); | 4909 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get"); |
4911 return; | 4910 return; |
4912 } | 4911 } |
4913 | 4912 |
4914 CXFA_Document* pDoc = pContext->GetDocument(); | 4913 CXFA_Document* pDoc = pContext->GetDocument(); |
4915 if (!pDoc) | 4914 if (!pDoc) |
4916 return; | 4915 return; |
4917 | 4916 |
4918 IXFA_AppProvider* pAppProvider = | 4917 IXFA_AppProvider* pAppProvider = pDoc->GetNotify()->GetAppProvider(); |
4919 pDoc->GetParser()->GetNotify()->GetAppProvider(); | |
4920 if (!pAppProvider) | 4918 if (!pAppProvider) |
4921 return; | 4919 return; |
4922 | 4920 |
4923 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4921 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4924 CFX_ByteString urlString; | 4922 CFX_ByteString urlString; |
4925 ValueToUTF8String(argOne.get(), urlString); | 4923 ValueToUTF8String(argOne.get(), urlString); |
4926 IFX_FileRead* pFile = pAppProvider->DownloadURL( | 4924 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
4927 CFX_WideString::FromUTF8(urlString.AsStringC())); | 4925 CFX_WideString::FromUTF8(urlString.AsStringC())); |
4928 if (!pFile) | 4926 if (!pFile) |
4929 return; | 4927 return; |
(...skipping 13 matching lines...) Expand all Loading... |
4943 int32_t argc = args.GetLength(); | 4941 int32_t argc = args.GetLength(); |
4944 if (argc < 2 || argc > 5) { | 4942 if (argc < 2 || argc > 5) { |
4945 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post"); | 4943 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post"); |
4946 return; | 4944 return; |
4947 } | 4945 } |
4948 | 4946 |
4949 CXFA_Document* pDoc = pContext->GetDocument(); | 4947 CXFA_Document* pDoc = pContext->GetDocument(); |
4950 if (!pDoc) | 4948 if (!pDoc) |
4951 return; | 4949 return; |
4952 | 4950 |
4953 IXFA_AppProvider* pAppProvider = | 4951 IXFA_AppProvider* pAppProvider = pDoc->GetNotify()->GetAppProvider(); |
4954 pDoc->GetParser()->GetNotify()->GetAppProvider(); | |
4955 if (!pAppProvider) | 4952 if (!pAppProvider) |
4956 return; | 4953 return; |
4957 | 4954 |
4958 CFX_ByteString bsURL; | 4955 CFX_ByteString bsURL; |
4959 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4956 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4960 ValueToUTF8String(argOne.get(), bsURL); | 4957 ValueToUTF8String(argOne.get(), bsURL); |
4961 | 4958 |
4962 CFX_ByteString bsData; | 4959 CFX_ByteString bsData; |
4963 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4960 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
4964 ValueToUTF8String(argTwo.get(), bsData); | 4961 ValueToUTF8String(argTwo.get(), bsData); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5005 int32_t argc = args.GetLength(); | 5002 int32_t argc = args.GetLength(); |
5006 if (argc < 2 || argc > 3) { | 5003 if (argc < 2 || argc > 3) { |
5007 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put"); | 5004 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put"); |
5008 return; | 5005 return; |
5009 } | 5006 } |
5010 | 5007 |
5011 CXFA_Document* pDoc = pContext->GetDocument(); | 5008 CXFA_Document* pDoc = pContext->GetDocument(); |
5012 if (!pDoc) | 5009 if (!pDoc) |
5013 return; | 5010 return; |
5014 | 5011 |
5015 IXFA_AppProvider* pAppProvider = | 5012 IXFA_AppProvider* pAppProvider = pDoc->GetNotify()->GetAppProvider(); |
5016 pDoc->GetParser()->GetNotify()->GetAppProvider(); | |
5017 if (!pAppProvider) | 5013 if (!pAppProvider) |
5018 return; | 5014 return; |
5019 | 5015 |
5020 CFX_ByteString bsURL; | 5016 CFX_ByteString bsURL; |
5021 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5017 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
5022 ValueToUTF8String(argOne.get(), bsURL); | 5018 ValueToUTF8String(argOne.get(), bsURL); |
5023 | 5019 |
5024 CFX_ByteString bsData; | 5020 CFX_ByteString bsData; |
5025 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 5021 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
5026 ValueToUTF8String(argTwo.get(), bsData); | 5022 ValueToUTF8String(argTwo.get(), bsData); |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6523 CFX_WideString wsFormat; | 6519 CFX_WideString wsFormat; |
6524 pAppProvider->LoadString(iStringID, wsFormat); | 6520 pAppProvider->LoadString(iStringID, wsFormat); |
6525 CFX_WideString wsMessage; | 6521 CFX_WideString wsMessage; |
6526 va_list arg_ptr; | 6522 va_list arg_ptr; |
6527 va_start(arg_ptr, iStringID); | 6523 va_start(arg_ptr, iStringID); |
6528 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 6524 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
6529 va_end(arg_ptr); | 6525 va_end(arg_ptr); |
6530 FXJSE_ThrowMessage( | 6526 FXJSE_ThrowMessage( |
6531 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 6527 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
6532 } | 6528 } |
OLD | NEW |