| 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 |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 return; | 642 return; |
| 643 } | 643 } |
| 644 | 644 |
| 645 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 645 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 646 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 646 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 647 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 647 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 648 new CFXJSE_Value(pIsolate)); | 648 new CFXJSE_Value(pIsolate)); |
| 649 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 649 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
| 650 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); | 650 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); |
| 651 if (FXJSE_Value_IsNull(propertyValue.get())) { | 651 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 652 for (int32_t i = 2; i < iLength; i++) { | 652 for (int32_t j = 2; j < iLength; j++) { |
| 653 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | 653 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, |
| 654 jsObjectValue.get()); | 654 jsObjectValue.get()); |
| 655 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 655 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 656 if (!FXJSE_Value_IsNull(newPropertyValue.get())) | 656 if (!FXJSE_Value_IsNull(newPropertyValue.get())) |
| 657 iCount++; | 657 iCount++; |
| 658 } | 658 } |
| 659 } else { | 659 } else { |
| 660 CFX_ByteString propertyStr; | 660 CFX_ByteString propertyStr; |
| 661 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 661 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 662 for (int32_t i = 2; i < iLength; i++) { | 662 for (int32_t j = 2; j < iLength; j++) { |
| 663 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | 663 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, |
| 664 jsObjectValue.get()); | 664 jsObjectValue.get()); |
| 665 FXJSE_Value_GetObjectProp(jsObjectValue.get(), | 665 FXJSE_Value_GetObjectProp(jsObjectValue.get(), |
| 666 propertyStr.AsStringC(), | 666 propertyStr.AsStringC(), |
| 667 newPropertyValue.get()); | 667 newPropertyValue.get()); |
| 668 iCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1); | 668 iCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1); |
| 669 } | 669 } |
| 670 } | 670 } |
| 671 } else if (FXJSE_Value_IsObject(argValue.get())) { | 671 } else if (FXJSE_Value_IsObject(argValue.get())) { |
| 672 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 672 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 673 new CFXJSE_Value(pIsolate)); | 673 new CFXJSE_Value(pIsolate)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 return; | 726 return; |
| 727 } | 727 } |
| 728 | 728 |
| 729 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 729 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 730 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 730 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 731 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 731 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 732 new CFXJSE_Value(pIsolate)); | 732 new CFXJSE_Value(pIsolate)); |
| 733 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 733 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
| 734 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); | 734 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); |
| 735 if (FXJSE_Value_IsNull(propertyValue.get())) { | 735 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 736 for (int32_t i = 2; i < iLength; i++) { | 736 for (int32_t j = 2; j < iLength; j++) { |
| 737 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | 737 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, |
| 738 jsObjectValue.get()); | 738 jsObjectValue.get()); |
| 739 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 739 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 740 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 740 if (FXJSE_Value_IsNull(newPropertyValue.get())) |
| 741 continue; | 741 continue; |
| 742 | 742 |
| 743 uCount++; | 743 uCount++; |
| 744 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 744 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 745 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); | 745 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| 746 } | 746 } |
| 747 } else { | 747 } else { |
| 748 CFX_ByteString propertyStr; | 748 CFX_ByteString propertyStr; |
| 749 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 749 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 750 for (int32_t i = 2; i < iLength; i++) { | 750 for (int32_t j = 2; j < iLength; j++) { |
| 751 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | 751 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, |
| 752 jsObjectValue.get()); | 752 jsObjectValue.get()); |
| 753 FXJSE_Value_GetObjectProp(jsObjectValue.get(), | 753 FXJSE_Value_GetObjectProp(jsObjectValue.get(), |
| 754 propertyStr.AsStringC(), | 754 propertyStr.AsStringC(), |
| 755 newPropertyValue.get()); | 755 newPropertyValue.get()); |
| 756 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 756 if (FXJSE_Value_IsNull(newPropertyValue.get())) |
| 757 continue; | 757 continue; |
| 758 | 758 |
| 759 uCount++; | 759 uCount++; |
| 760 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 760 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 761 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); | 761 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 803 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 804 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 804 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 805 if (iLength > 2) { | 805 if (iLength > 2) { |
| 806 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 806 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 807 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 807 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 808 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 808 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 809 new CFXJSE_Value(pIsolate)); | 809 new CFXJSE_Value(pIsolate)); |
| 810 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 810 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
| 811 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); | 811 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); |
| 812 if (FXJSE_Value_IsNull(propertyValue.get())) { | 812 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 813 for (int32_t i = 2; i < iLength; i++) { | 813 for (int32_t j = 2; j < iLength; j++) { |
| 814 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | 814 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, |
| 815 jsObjectValue.get()); | 815 jsObjectValue.get()); |
| 816 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 816 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 817 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | 817 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { |
| 818 uCount++; | 818 uCount++; |
| 819 if (uCount == 1) { | 819 if (uCount == 1) { |
| 820 dMinValue = ValueToDouble(pThis, newPropertyValue.get()); | 820 dMinValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 821 } else { | 821 } else { |
| 822 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 822 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 823 if (dMinValue > dValue) { | 823 if (dMinValue > dValue) { |
| 824 dMinValue = dValue; | 824 dMinValue = dValue; |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 } else { | 829 } else { |
| 830 CFX_ByteString propertyStr; | 830 CFX_ByteString propertyStr; |
| 831 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 831 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 832 for (int32_t i = 2; i < iLength; i++) { | 832 for (int32_t j = 2; j < iLength; j++) { |
| 833 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | 833 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, |
| 834 jsObjectValue.get()); | 834 jsObjectValue.get()); |
| 835 FXJSE_Value_GetObjectProp(jsObjectValue.get(), | 835 FXJSE_Value_GetObjectProp(jsObjectValue.get(), |
| 836 propertyStr.AsStringC(), | 836 propertyStr.AsStringC(), |
| 837 newPropertyValue.get()); | 837 newPropertyValue.get()); |
| 838 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | 838 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { |
| 839 uCount++; | 839 uCount++; |
| 840 if (uCount == 1) { | 840 if (uCount == 1) { |
| 841 dMinValue = ValueToDouble(pThis, newPropertyValue.get()); | 841 dMinValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 842 } else { | 842 } else { |
| 843 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 843 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| (...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 ++iPos; | 2068 ++iPos; |
| 2069 } else if (iPos == 2) { | 2069 } else if (iPos == 2) { |
| 2070 iSecond = FXSYS_atoi(strTemp); | 2070 iSecond = FXSYS_atoi(strTemp); |
| 2071 ++iPos; | 2071 ++iPos; |
| 2072 } | 2072 } |
| 2073 iIndex += 2; | 2073 iIndex += 2; |
| 2074 } | 2074 } |
| 2075 } | 2075 } |
| 2076 if (*(pData + iIndex) == '.') { | 2076 if (*(pData + iIndex) == '.') { |
| 2077 ++iIndex; | 2077 ++iIndex; |
| 2078 FX_CHAR strTemp[4]; | 2078 FX_CHAR strSec[4]; |
| 2079 strTemp[3] = '\0'; | 2079 strSec[3] = '\0'; |
| 2080 if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { | 2080 if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { |
| 2081 return iRet; | 2081 return iRet; |
| 2082 } | 2082 } |
| 2083 strTemp[0] = *(pData + iIndex); | 2083 strSec[0] = *(pData + iIndex); |
| 2084 if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { | 2084 if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { |
| 2085 return iRet; | 2085 return iRet; |
| 2086 } | 2086 } |
| 2087 strTemp[1] = *(pData + iIndex + 1); | 2087 strSec[1] = *(pData + iIndex + 1); |
| 2088 if (*(pData + iIndex + 2) > '9' || *(pData + iIndex + 2) < '0') { | 2088 if (*(pData + iIndex + 2) > '9' || *(pData + iIndex + 2) < '0') { |
| 2089 return iRet; | 2089 return iRet; |
| 2090 } | 2090 } |
| 2091 strTemp[2] = *(pData + iIndex + 2); | 2091 strSec[2] = *(pData + iIndex + 2); |
| 2092 iMilliSecond = FXSYS_atoi(strTemp); | 2092 iMilliSecond = FXSYS_atoi(strSec); |
| 2093 if (iMilliSecond > 100) { | 2093 if (iMilliSecond > 100) { |
| 2094 iMilliSecond = 0; | 2094 iMilliSecond = 0; |
| 2095 return iRet; | 2095 return iRet; |
| 2096 } | 2096 } |
| 2097 iIndex += 3; | 2097 iIndex += 3; |
| 2098 } | 2098 } |
| 2099 int32_t iSign = 1; | 2099 int32_t iSign = 1; |
| 2100 if (*(pData + iIndex) == 'z' || *(pData + iIndex) == 'Z') { | 2100 if (*(pData + iIndex) == 'z' || *(pData + iIndex) == 'Z') { |
| 2101 iRet = 1; | 2101 iRet = 1; |
| 2102 return iRet; | 2102 return iRet; |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3168 L"Term"); | 3168 L"Term"); |
| 3169 } | 3169 } |
| 3170 } | 3170 } |
| 3171 | 3171 |
| 3172 // static | 3172 // static |
| 3173 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, | 3173 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, |
| 3174 const CFX_ByteStringC& szFuncName, | 3174 const CFX_ByteStringC& szFuncName, |
| 3175 CFXJSE_Arguments& args) { | 3175 CFXJSE_Arguments& args) { |
| 3176 CXFA_FM2JSContext* pContext = | 3176 CXFA_FM2JSContext* pContext = |
| 3177 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); | 3177 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); |
| 3178 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | |
| 3179 int32_t argc = args.GetLength(); | 3178 int32_t argc = args.GetLength(); |
| 3180 if (argc > 1) { | 3179 if (argc > 1) { |
| 3180 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3181 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3181 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 3182 FX_BOOL argOneIsNull = FALSE; | 3182 FX_BOOL argOneIsNull = FALSE; |
| 3183 int32_t iIndex = 0; | 3183 int32_t iIndex = 0; |
| 3184 argOneIsNull = ValueIsNull(pThis, argOne.get()); | 3184 argOneIsNull = ValueIsNull(pThis, argOne.get()); |
| 3185 if (!argOneIsNull) { | 3185 if (!argOneIsNull) { |
| 3186 iIndex = (int32_t)ValueToFloat(pThis, argOne.get()); | 3186 iIndex = (int32_t)ValueToFloat(pThis, argOne.get()); |
| 3187 } | 3187 } |
| 3188 if (argOneIsNull) { | 3188 if (argOneIsNull) { |
| 3189 FXJSE_Value_SetNull(args.GetReturnValue()); | 3189 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3190 } else if (iIndex < 1) { | 3190 } else if (iIndex < 1) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3243 bFound = TRUE; | 3243 bFound = TRUE; |
| 3244 } | 3244 } |
| 3245 } | 3245 } |
| 3246 iArgIndex++; | 3246 iArgIndex++; |
| 3247 } | 3247 } |
| 3248 if (!bFound) { | 3248 if (!bFound) { |
| 3249 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 3249 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 3250 } | 3250 } |
| 3251 } | 3251 } |
| 3252 } else { | 3252 } else { |
| 3253 CXFA_FM2JSContext* pContext = | |
| 3254 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); | |
| 3255 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3253 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3256 L"Choose"); | 3254 L"Choose"); |
| 3257 } | 3255 } |
| 3258 } | 3256 } |
| 3259 | 3257 |
| 3260 // static | 3258 // static |
| 3261 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, | 3259 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, |
| 3262 const CFX_ByteStringC& szFuncName, | 3260 const CFX_ByteStringC& szFuncName, |
| 3263 CFXJSE_Arguments& args) { | 3261 CFXJSE_Arguments& args) { |
| 3264 if (args.GetLength() == 1) { | 3262 if (args.GetLength() == 1) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3386 L"If"); | 3384 L"If"); |
| 3387 } | 3385 } |
| 3388 } | 3386 } |
| 3389 | 3387 |
| 3390 // static | 3388 // static |
| 3391 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, | 3389 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, |
| 3392 const CFX_ByteStringC& szFuncName, | 3390 const CFX_ByteStringC& szFuncName, |
| 3393 CFXJSE_Arguments& args) { | 3391 CFXJSE_Arguments& args) { |
| 3394 CXFA_FM2JSContext* pContext = | 3392 CXFA_FM2JSContext* pContext = |
| 3395 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); | 3393 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); |
| 3396 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | |
| 3397 if (args.GetLength() == 1) { | 3394 if (args.GetLength() == 1) { |
| 3395 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3398 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); | 3396 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); |
| 3399 CFX_ByteString utf8ScriptString; | 3397 CFX_ByteString utf8ScriptString; |
| 3400 ValueToUTF8String(scriptValue.get(), utf8ScriptString); | 3398 ValueToUTF8String(scriptValue.get(), utf8ScriptString); |
| 3401 if (utf8ScriptString.IsEmpty()) { | 3399 if (utf8ScriptString.IsEmpty()) { |
| 3402 FXJSE_Value_SetNull(args.GetReturnValue()); | 3400 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3403 } else { | 3401 } else { |
| 3404 CFX_WideTextBuf wsJavaScriptBuf; | 3402 CFX_WideTextBuf wsJavaScriptBuf; |
| 3405 CFX_WideString javaScript; | 3403 CFX_WideString javaScript; |
| 3406 CFX_WideString wsError; | 3404 CFX_WideString wsError; |
| 3407 CXFA_FM2JSContext::Translate( | 3405 CXFA_FM2JSContext::Translate( |
| 3408 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), | 3406 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), |
| 3409 wsJavaScriptBuf, wsError); | 3407 wsJavaScriptBuf, wsError); |
| 3410 CFXJSE_Context* pContext = | 3408 CFXJSE_Context* pNewContext = |
| 3411 FXJSE_Context_Create(pIsolate, nullptr, nullptr); | 3409 FXJSE_Context_Create(pIsolate, nullptr, nullptr); |
| 3412 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); | 3410 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); |
| 3413 javaScript = wsJavaScriptBuf.AsStringC(); | 3411 javaScript = wsJavaScriptBuf.AsStringC(); |
| 3414 FXJSE_ExecuteScript( | 3412 FXJSE_ExecuteScript( |
| 3415 pContext, | 3413 pNewContext, |
| 3416 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), | 3414 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), |
| 3417 returnValue.get()); | 3415 returnValue.get()); |
| 3418 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); | 3416 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); |
| 3419 FXJSE_Context_Release(pContext); | 3417 FXJSE_Context_Release(pNewContext); |
| 3420 } | 3418 } |
| 3421 } else { | 3419 } else { |
| 3422 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3420 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3423 L"Eval"); | 3421 L"Eval"); |
| 3424 } | 3422 } |
| 3425 } | 3423 } |
| 3426 | 3424 |
| 3427 // static | 3425 // static |
| 3428 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, | 3426 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, |
| 3429 const CFX_ByteStringC& szFuncName, | 3427 const CFX_ByteStringC& szFuncName, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3661 } | 3659 } |
| 3662 strFirstUnit += (*(pData + u)); | 3660 strFirstUnit += (*(pData + u)); |
| 3663 ++u; | 3661 ++u; |
| 3664 } | 3662 } |
| 3665 strFirstUnit.MakeLower(); | 3663 strFirstUnit.MakeLower(); |
| 3666 if (argc == 2) { | 3664 if (argc == 2) { |
| 3667 std::unique_ptr<CFXJSE_Value> unitValue = | 3665 std::unique_ptr<CFXJSE_Value> unitValue = |
| 3668 GetSimpleValue(pThis, args, 1); | 3666 GetSimpleValue(pThis, args, 1); |
| 3669 CFX_ByteString unitTempString; | 3667 CFX_ByteString unitTempString; |
| 3670 ValueToUTF8String(unitValue.get(), unitTempString); | 3668 ValueToUTF8String(unitValue.get(), unitTempString); |
| 3671 const FX_CHAR* pData = unitTempString.c_str(); | 3669 const FX_CHAR* pChar = unitTempString.c_str(); |
| 3672 int32_t u = 0; | 3670 int32_t uVal = 0; |
| 3673 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || | 3671 while (*(pChar + uVal) == ' ' || *(pChar + uVal) == 0x09 || |
| 3674 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3672 *(pChar + uVal) == 0x0B || *(pChar + uVal) == 0x0C || |
| 3675 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3673 *(pChar + uVal) == 0x0A || *(pChar + uVal) == 0x0D) { |
| 3676 ++u; | 3674 ++uVal; |
| 3677 } | 3675 } |
| 3678 while (u < unitTempString.GetLength()) { | 3676 while (uVal < unitTempString.GetLength()) { |
| 3679 if ((*(pData + u) > '9' || *(pData + u) < '0') && | 3677 if ((*(pChar + uVal) > '9' || *(pChar + uVal) < '0') && |
| 3680 *(pData + u) != '.') { | 3678 *(pChar + uVal) != '.') { |
| 3681 break; | 3679 break; |
| 3682 } | 3680 } |
| 3683 ++u; | 3681 ++uVal; |
| 3684 } | 3682 } |
| 3685 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || | 3683 while (*(pChar + uVal) == ' ' || *(pChar + uVal) == 0x09 || |
| 3686 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3684 *(pChar + uVal) == 0x0B || *(pChar + uVal) == 0x0C || |
| 3687 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3685 *(pChar + uVal) == 0x0A || *(pChar + uVal) == 0x0D) { |
| 3688 ++u; | 3686 ++uVal; |
| 3689 } | 3687 } |
| 3690 int32_t uLen = unitTempString.GetLength(); | 3688 int32_t uValLen = unitTempString.GetLength(); |
| 3691 while (u < uLen) { | 3689 while (uVal < uValLen) { |
| 3692 if (*(pData + u) == ' ') { | 3690 if (*(pChar + uVal) == ' ') { |
| 3693 break; | 3691 break; |
| 3694 } | 3692 } |
| 3695 strUnit += (*(pData + u)); | 3693 strUnit += (*(pChar + uVal)); |
| 3696 ++u; | 3694 ++uVal; |
| 3697 } | 3695 } |
| 3698 strUnit.MakeLower(); | 3696 strUnit.MakeLower(); |
| 3699 } else { | 3697 } else { |
| 3700 strUnit = strFirstUnit; | 3698 strUnit = strFirstUnit; |
| 3701 } | 3699 } |
| 3702 FX_DOUBLE dResult = 0; | 3700 FX_DOUBLE dResult = 0; |
| 3703 if (strFirstUnit == "in" || strFirstUnit == "inches") { | 3701 if (strFirstUnit == "in" || strFirstUnit == "inches") { |
| 3704 if (strUnit == "mm" || strUnit == "millimeters") { | 3702 if (strUnit == "mm" || strUnit == "millimeters") { |
| 3705 dResult = dFirstNumber * 25.4; | 3703 dResult = dFirstNumber * 25.4; |
| 3706 } else if (strUnit == "cm" || strUnit == "centimeters") { | 3704 } else if (strUnit == "cm" || strUnit == "centimeters") { |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4768 wsTestPattern = FX_WSTRC(L"num{") + wsPattern; | 4766 wsTestPattern = FX_WSTRC(L"num{") + wsPattern; |
| 4769 wsTestPattern += FX_WSTRC(L"}"); | 4767 wsTestPattern += FX_WSTRC(L"}"); |
| 4770 CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern, | 4768 CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern, |
| 4771 pLocale, (CXFA_LocaleMgr*)pMgr); | 4769 pLocale, (CXFA_LocaleMgr*)pMgr); |
| 4772 if (localeValue.IsValid()) { | 4770 if (localeValue.IsValid()) { |
| 4773 FXJSE_Value_SetDouble(args.GetReturnValue(), | 4771 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 4774 localeValue.GetDoubleNum()); | 4772 localeValue.GetDoubleNum()); |
| 4775 } else { | 4773 } else { |
| 4776 wsTestPattern = FX_WSTRC(L"text{") + wsPattern; | 4774 wsTestPattern = FX_WSTRC(L"text{") + wsPattern; |
| 4777 wsTestPattern += FX_WSTRC(L"}"); | 4775 wsTestPattern += FX_WSTRC(L"}"); |
| 4778 CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsTestPattern, | 4776 CXFA_LocaleValue localeValue2(XFA_VT_TEXT, wsValue, wsTestPattern, |
| 4779 pLocale, (CXFA_LocaleMgr*)pMgr); | 4777 pLocale, (CXFA_LocaleMgr*)pMgr); |
| 4780 if (localeValue.IsValid()) { | 4778 if (localeValue2.IsValid()) { |
| 4781 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); | 4779 szParsedValue = FX_UTF8Encode(localeValue2.GetValue()); |
| 4782 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4780 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4783 szParsedValue.AsStringC()); | 4781 szParsedValue.AsStringC()); |
| 4784 } else { | 4782 } else { |
| 4785 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4783 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 4786 } | 4784 } |
| 4787 } | 4785 } |
| 4788 } break; | 4786 } break; |
| 4789 } | 4787 } |
| 4790 } | 4788 } |
| 4791 } | 4789 } |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5461 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); | 5459 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); |
| 5462 iIndex += iCount; | 5460 iIndex += iCount; |
| 5463 if (iIndex < iInteger) { | 5461 if (iIndex < iInteger) { |
| 5464 strBuf << " Trillion "; | 5462 strBuf << " Trillion "; |
| 5465 } | 5463 } |
| 5466 } | 5464 } |
| 5467 strBuf << " Dollars"; | 5465 strBuf << " Dollars"; |
| 5468 if (iInteger < iLength) { | 5466 if (iInteger < iLength) { |
| 5469 strBuf << " And "; | 5467 strBuf << " And "; |
| 5470 iIndex = iInteger + 1; | 5468 iIndex = iInteger + 1; |
| 5471 int32_t iCount = 0; | |
| 5472 while (iIndex < iLength) { | 5469 while (iIndex < iLength) { |
| 5473 iCount = (iLength - iIndex) % 12; | 5470 int32_t iSize = (iLength - iIndex) % 12; |
| 5474 if (!iCount && iLength - iIndex > 0) { | 5471 if (!iSize && iLength - iIndex > 0) |
| 5475 iCount = 12; | 5472 iSize = 12; |
| 5476 } | 5473 TrillionUS(CFX_ByteStringC(pData + iIndex, iSize), strBuf); |
| 5477 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); | 5474 iIndex += iSize; |
| 5478 iIndex += iCount; | |
| 5479 if (iIndex < iLength) { | 5475 if (iIndex < iLength) { |
| 5480 strBuf << " Trillion "; | 5476 strBuf << " Trillion "; |
| 5481 } | 5477 } |
| 5482 } | 5478 } |
| 5483 strBuf << " Cents"; | 5479 strBuf << " Cents"; |
| 5484 } | 5480 } |
| 5485 } break; | 5481 } break; |
| 5486 default: | 5482 default: |
| 5487 break; | 5483 break; |
| 5488 } | 5484 } |
| (...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7171 CFX_WideString wsFormat; | 7167 CFX_WideString wsFormat; |
| 7172 pAppProvider->LoadString(iStringID, wsFormat); | 7168 pAppProvider->LoadString(iStringID, wsFormat); |
| 7173 CFX_WideString wsMessage; | 7169 CFX_WideString wsMessage; |
| 7174 va_list arg_ptr; | 7170 va_list arg_ptr; |
| 7175 va_start(arg_ptr, iStringID); | 7171 va_start(arg_ptr, iStringID); |
| 7176 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7172 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 7177 va_end(arg_ptr); | 7173 va_end(arg_ptr); |
| 7178 FXJSE_ThrowMessage( | 7174 FXJSE_ThrowMessage( |
| 7179 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7175 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 7180 } | 7176 } |
| OLD | NEW |