Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 2027273002: Fix all the code which has duplicate variable declarations (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | xfa/fxfa/fm2js/xfa_fmparse.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 return; 640 return;
641 } 641 }
642 642
643 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 643 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
644 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 644 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
645 std::unique_ptr<CFXJSE_Value> newPropertyValue( 645 std::unique_ptr<CFXJSE_Value> newPropertyValue(
646 new CFXJSE_Value(pIsolate)); 646 new CFXJSE_Value(pIsolate));
647 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 647 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get());
648 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 648 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get());
649 if (FXJSE_Value_IsNull(propertyValue.get())) { 649 if (FXJSE_Value_IsNull(propertyValue.get())) {
650 for (int32_t i = 2; i < iLength; i++) { 650 for (int32_t j = 2; j < iLength; j++) {
651 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, 651 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j,
652 jsObjectValue.get()); 652 jsObjectValue.get());
653 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 653 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
654 if (!FXJSE_Value_IsNull(newPropertyValue.get())) 654 if (!FXJSE_Value_IsNull(newPropertyValue.get()))
655 iCount++; 655 iCount++;
656 } 656 }
657 } else { 657 } else {
658 CFX_ByteString propertyStr; 658 CFX_ByteString propertyStr;
659 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 659 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr);
660 for (int32_t i = 2; i < iLength; i++) { 660 for (int32_t j = 2; j < iLength; j++) {
661 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, 661 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j,
662 jsObjectValue.get()); 662 jsObjectValue.get());
663 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 663 FXJSE_Value_GetObjectProp(jsObjectValue.get(),
664 propertyStr.AsStringC(), 664 propertyStr.AsStringC(),
665 newPropertyValue.get()); 665 newPropertyValue.get());
666 iCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1); 666 iCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1);
667 } 667 }
668 } 668 }
669 } else if (FXJSE_Value_IsObject(argValue.get())) { 669 } else if (FXJSE_Value_IsObject(argValue.get())) {
670 std::unique_ptr<CFXJSE_Value> newPropertyValue( 670 std::unique_ptr<CFXJSE_Value> newPropertyValue(
671 new CFXJSE_Value(pIsolate)); 671 new CFXJSE_Value(pIsolate));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 return; 723 return;
724 } 724 }
725 725
726 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 726 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
727 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 727 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
728 std::unique_ptr<CFXJSE_Value> newPropertyValue( 728 std::unique_ptr<CFXJSE_Value> newPropertyValue(
729 new CFXJSE_Value(pIsolate)); 729 new CFXJSE_Value(pIsolate));
730 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 730 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get());
731 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 731 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get());
732 if (FXJSE_Value_IsNull(propertyValue.get())) { 732 if (FXJSE_Value_IsNull(propertyValue.get())) {
733 for (int32_t i = 2; i < iLength; i++) { 733 for (int32_t j = 2; j < iLength; j++) {
734 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, 734 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j,
735 jsObjectValue.get()); 735 jsObjectValue.get());
736 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 736 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
737 if (FXJSE_Value_IsNull(newPropertyValue.get())) 737 if (FXJSE_Value_IsNull(newPropertyValue.get()))
738 continue; 738 continue;
739 739
740 uCount++; 740 uCount++;
741 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 741 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
742 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); 742 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue);
743 } 743 }
744 } else { 744 } else {
745 CFX_ByteString propertyStr; 745 CFX_ByteString propertyStr;
746 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 746 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr);
747 for (int32_t i = 2; i < iLength; i++) { 747 for (int32_t j = 2; j < iLength; j++) {
748 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, 748 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j,
749 jsObjectValue.get()); 749 jsObjectValue.get());
750 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 750 FXJSE_Value_GetObjectProp(jsObjectValue.get(),
751 propertyStr.AsStringC(), 751 propertyStr.AsStringC(),
752 newPropertyValue.get()); 752 newPropertyValue.get());
753 if (FXJSE_Value_IsNull(newPropertyValue.get())) 753 if (FXJSE_Value_IsNull(newPropertyValue.get()))
754 continue; 754 continue;
755 755
756 uCount++; 756 uCount++;
757 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 757 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
758 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); 758 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 return; 805 return;
806 } 806 }
807 807
808 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 808 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
809 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 809 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
810 std::unique_ptr<CFXJSE_Value> newPropertyValue( 810 std::unique_ptr<CFXJSE_Value> newPropertyValue(
811 new CFXJSE_Value(pIsolate)); 811 new CFXJSE_Value(pIsolate));
812 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 812 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get());
813 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 813 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get());
814 if (FXJSE_Value_IsNull(propertyValue.get())) { 814 if (FXJSE_Value_IsNull(propertyValue.get())) {
815 for (int32_t i = 2; i < iLength; i++) { 815 for (int32_t j = 2; j < iLength; j++) {
816 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, 816 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j,
817 jsObjectValue.get()); 817 jsObjectValue.get());
818 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 818 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
819 if (FXJSE_Value_IsNull(newPropertyValue.get())) 819 if (FXJSE_Value_IsNull(newPropertyValue.get()))
820 continue; 820 continue;
821 821
822 uCount++; 822 uCount++;
823 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 823 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
824 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); 824 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue);
825 } 825 }
826 } else { 826 } else {
827 CFX_ByteString propertyStr; 827 CFX_ByteString propertyStr;
828 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 828 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr);
829 for (int32_t i = 2; i < iLength; i++) { 829 for (int32_t j = 2; j < iLength; j++) {
830 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, 830 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j,
831 jsObjectValue.get()); 831 jsObjectValue.get());
832 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 832 FXJSE_Value_GetObjectProp(jsObjectValue.get(),
833 propertyStr.AsStringC(), 833 propertyStr.AsStringC(),
834 newPropertyValue.get()); 834 newPropertyValue.get());
835 if (FXJSE_Value_IsNull(newPropertyValue.get())) 835 if (FXJSE_Value_IsNull(newPropertyValue.get()))
836 continue; 836 continue;
837 837
838 uCount++; 838 uCount++;
839 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 839 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
840 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); 840 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue);
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 ++iPos; 1936 ++iPos;
1937 } else if (iPos == 2) { 1937 } else if (iPos == 2) {
1938 iSecond = FXSYS_atoi(strTemp); 1938 iSecond = FXSYS_atoi(strTemp);
1939 ++iPos; 1939 ++iPos;
1940 } 1940 }
1941 iIndex += 2; 1941 iIndex += 2;
1942 } 1942 }
1943 } 1943 }
1944 if (*(pData + iIndex) == '.') { 1944 if (*(pData + iIndex) == '.') {
1945 ++iIndex; 1945 ++iIndex;
1946 FX_CHAR strTemp[4]; 1946 FX_CHAR strSec[4];
1947 strTemp[3] = '\0'; 1947 strSec[3] = '\0';
1948 if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') { 1948 if (*(pData + iIndex) > '9' || *(pData + iIndex) < '0') {
1949 return iRet; 1949 return iRet;
1950 } 1950 }
1951 strTemp[0] = *(pData + iIndex); 1951 strSec[0] = *(pData + iIndex);
1952 if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') { 1952 if (*(pData + iIndex + 1) > '9' || *(pData + iIndex + 1) < '0') {
1953 return iRet; 1953 return iRet;
1954 } 1954 }
1955 strTemp[1] = *(pData + iIndex + 1); 1955 strSec[1] = *(pData + iIndex + 1);
1956 if (*(pData + iIndex + 2) > '9' || *(pData + iIndex + 2) < '0') { 1956 if (*(pData + iIndex + 2) > '9' || *(pData + iIndex + 2) < '0') {
1957 return iRet; 1957 return iRet;
1958 } 1958 }
1959 strTemp[2] = *(pData + iIndex + 2); 1959 strSec[2] = *(pData + iIndex + 2);
1960 iMilliSecond = FXSYS_atoi(strTemp); 1960 iMilliSecond = FXSYS_atoi(strSec);
1961 if (iMilliSecond > 100) { 1961 if (iMilliSecond > 100) {
1962 iMilliSecond = 0; 1962 iMilliSecond = 0;
1963 return iRet; 1963 return iRet;
1964 } 1964 }
1965 iIndex += 3; 1965 iIndex += 3;
1966 } 1966 }
1967 int32_t iSign = 1; 1967 int32_t iSign = 1;
1968 if (*(pData + iIndex) == 'z' || *(pData + iIndex) == 'Z') { 1968 if (*(pData + iIndex) == 'z' || *(pData + iIndex) == 'Z') {
1969 iRet = 1; 1969 iRet = 1;
1970 return iRet; 1970 return iRet;
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Term"); 3026 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Term");
3027 } 3027 }
3028 } 3028 }
3029 3029
3030 // static 3030 // static
3031 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, 3031 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis,
3032 const CFX_ByteStringC& szFuncName, 3032 const CFX_ByteStringC& szFuncName,
3033 CFXJSE_Arguments& args) { 3033 CFXJSE_Arguments& args) {
3034 CXFA_FM2JSContext* pContext = 3034 CXFA_FM2JSContext* pContext =
3035 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3035 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3036 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3037 int32_t argc = args.GetLength(); 3036 int32_t argc = args.GetLength();
3038 if (argc > 1) { 3037 if (argc > 1) {
3038 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3039 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 3039 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
3040 FX_BOOL argOneIsNull = FALSE; 3040 FX_BOOL argOneIsNull = FALSE;
3041 int32_t iIndex = 0; 3041 int32_t iIndex = 0;
3042 argOneIsNull = ValueIsNull(pThis, argOne.get()); 3042 argOneIsNull = ValueIsNull(pThis, argOne.get());
3043 if (!argOneIsNull) { 3043 if (!argOneIsNull) {
3044 iIndex = (int32_t)ValueToFloat(pThis, argOne.get()); 3044 iIndex = (int32_t)ValueToFloat(pThis, argOne.get());
3045 } 3045 }
3046 if (argOneIsNull) { 3046 if (argOneIsNull) {
3047 FXJSE_Value_SetNull(args.GetReturnValue()); 3047 FXJSE_Value_SetNull(args.GetReturnValue());
3048 } else if (iIndex < 1) { 3048 } else if (iIndex < 1) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If"); 3238 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If");
3239 } 3239 }
3240 } 3240 }
3241 3241
3242 // static 3242 // static
3243 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, 3243 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
3244 const CFX_ByteStringC& szFuncName, 3244 const CFX_ByteStringC& szFuncName,
3245 CFXJSE_Arguments& args) { 3245 CFXJSE_Arguments& args) {
3246 CXFA_FM2JSContext* pContext = 3246 CXFA_FM2JSContext* pContext =
3247 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3247 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3248 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3249 if (args.GetLength() == 1) { 3248 if (args.GetLength() == 1) {
3249 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3250 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); 3250 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0);
3251 CFX_ByteString utf8ScriptString; 3251 CFX_ByteString utf8ScriptString;
3252 ValueToUTF8String(scriptValue.get(), utf8ScriptString); 3252 ValueToUTF8String(scriptValue.get(), utf8ScriptString);
3253 if (utf8ScriptString.IsEmpty()) { 3253 if (utf8ScriptString.IsEmpty()) {
3254 FXJSE_Value_SetNull(args.GetReturnValue()); 3254 FXJSE_Value_SetNull(args.GetReturnValue());
3255 } else { 3255 } else {
3256 CFX_WideTextBuf wsJavaScriptBuf; 3256 CFX_WideTextBuf wsJavaScriptBuf;
3257 CFX_WideString javaScript; 3257 CFX_WideString javaScript;
3258 CFX_WideString wsError; 3258 CFX_WideString wsError;
3259 CXFA_FM2JSContext::Translate( 3259 CXFA_FM2JSContext::Translate(
3260 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), 3260 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(),
3261 wsJavaScriptBuf, wsError); 3261 wsJavaScriptBuf, wsError);
3262 CFXJSE_Context* pContext = 3262 CFXJSE_Context* pNewContext =
3263 FXJSE_Context_Create(pIsolate, nullptr, nullptr); 3263 FXJSE_Context_Create(pIsolate, nullptr, nullptr);
3264 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); 3264 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate));
3265 javaScript = wsJavaScriptBuf.AsStringC(); 3265 javaScript = wsJavaScriptBuf.AsStringC();
3266 FXJSE_ExecuteScript( 3266 FXJSE_ExecuteScript(
3267 pContext, 3267 pNewContext,
3268 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), 3268 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(),
3269 returnValue.get()); 3269 returnValue.get());
3270 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); 3270 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get());
3271 FXJSE_Context_Release(pContext); 3271 FXJSE_Context_Release(pNewContext);
3272 } 3272 }
3273 } else { 3273 } else {
3274 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); 3274 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
3275 } 3275 }
3276 } 3276 }
3277 3277
3278 // static 3278 // static
3279 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, 3279 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis,
3280 const CFX_ByteStringC& szFuncName, 3280 const CFX_ByteStringC& szFuncName,
3281 CFXJSE_Arguments& args) { 3281 CFXJSE_Arguments& args) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 } 3510 }
3511 strFirstUnit += (*(pData + u)); 3511 strFirstUnit += (*(pData + u));
3512 ++u; 3512 ++u;
3513 } 3513 }
3514 strFirstUnit.MakeLower(); 3514 strFirstUnit.MakeLower();
3515 if (argc == 2) { 3515 if (argc == 2) {
3516 std::unique_ptr<CFXJSE_Value> unitValue = 3516 std::unique_ptr<CFXJSE_Value> unitValue =
3517 GetSimpleValue(pThis, args, 1); 3517 GetSimpleValue(pThis, args, 1);
3518 CFX_ByteString unitTempString; 3518 CFX_ByteString unitTempString;
3519 ValueToUTF8String(unitValue.get(), unitTempString); 3519 ValueToUTF8String(unitValue.get(), unitTempString);
3520 const FX_CHAR* pData = unitTempString.c_str(); 3520 const FX_CHAR* pChar = unitTempString.c_str();
3521 int32_t u = 0; 3521 int32_t uVal = 0;
3522 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || 3522 while (*(pChar + uVal) == ' ' || *(pChar + uVal) == 0x09 ||
3523 *(pData + u) == 0x0B || *(pData + u) == 0x0C || 3523 *(pChar + uVal) == 0x0B || *(pChar + uVal) == 0x0C ||
3524 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { 3524 *(pChar + uVal) == 0x0A || *(pChar + uVal) == 0x0D) {
3525 ++u; 3525 ++uVal;
3526 } 3526 }
3527 while (u < unitTempString.GetLength()) { 3527 while (uVal < unitTempString.GetLength()) {
3528 if ((*(pData + u) > '9' || *(pData + u) < '0') && 3528 if ((*(pChar + uVal) > '9' || *(pChar + uVal) < '0') &&
3529 *(pData + u) != '.') { 3529 *(pChar + uVal) != '.') {
3530 break; 3530 break;
3531 } 3531 }
3532 ++u; 3532 ++uVal;
3533 } 3533 }
3534 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || 3534 while (*(pChar + uVal) == ' ' || *(pChar + uVal) == 0x09 ||
3535 *(pData + u) == 0x0B || *(pData + u) == 0x0C || 3535 *(pChar + uVal) == 0x0B || *(pChar + uVal) == 0x0C ||
3536 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { 3536 *(pChar + uVal) == 0x0A || *(pChar + uVal) == 0x0D) {
3537 ++u; 3537 ++uVal;
3538 } 3538 }
3539 int32_t uLen = unitTempString.GetLength(); 3539 int32_t uValLen = unitTempString.GetLength();
3540 while (u < uLen) { 3540 while (uVal < uValLen) {
3541 if (*(pData + u) == ' ') { 3541 if (*(pChar + uVal) == ' ') {
3542 break; 3542 break;
3543 } 3543 }
3544 strUnit += (*(pData + u)); 3544 strUnit += (*(pChar + uVal));
3545 ++u; 3545 ++uVal;
3546 } 3546 }
3547 strUnit.MakeLower(); 3547 strUnit.MakeLower();
3548 } else { 3548 } else {
3549 strUnit = strFirstUnit; 3549 strUnit = strFirstUnit;
3550 } 3550 }
3551 FX_DOUBLE dResult = 0; 3551 FX_DOUBLE dResult = 0;
3552 if (strFirstUnit == "in" || strFirstUnit == "inches") { 3552 if (strFirstUnit == "in" || strFirstUnit == "inches") {
3553 if (strUnit == "mm" || strUnit == "millimeters") { 3553 if (strUnit == "mm" || strUnit == "millimeters") {
3554 dResult = dFirstNumber * 25.4; 3554 dResult = dFirstNumber * 25.4;
3555 } else if (strUnit == "cm" || strUnit == "centimeters") { 3555 } else if (strUnit == "cm" || strUnit == "centimeters") {
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
4607 wsTestPattern = FX_WSTRC(L"num{") + wsPattern; 4607 wsTestPattern = FX_WSTRC(L"num{") + wsPattern;
4608 wsTestPattern += FX_WSTRC(L"}"); 4608 wsTestPattern += FX_WSTRC(L"}");
4609 CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern, 4609 CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern,
4610 pLocale, (CXFA_LocaleMgr*)pMgr); 4610 pLocale, (CXFA_LocaleMgr*)pMgr);
4611 if (localeValue.IsValid()) { 4611 if (localeValue.IsValid()) {
4612 FXJSE_Value_SetDouble(args.GetReturnValue(), 4612 FXJSE_Value_SetDouble(args.GetReturnValue(),
4613 localeValue.GetDoubleNum()); 4613 localeValue.GetDoubleNum());
4614 } else { 4614 } else {
4615 wsTestPattern = FX_WSTRC(L"text{") + wsPattern; 4615 wsTestPattern = FX_WSTRC(L"text{") + wsPattern;
4616 wsTestPattern += FX_WSTRC(L"}"); 4616 wsTestPattern += FX_WSTRC(L"}");
4617 CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsTestPattern, 4617 CXFA_LocaleValue localeValue2(XFA_VT_TEXT, wsValue, wsTestPattern,
4618 pLocale, (CXFA_LocaleMgr*)pMgr); 4618 pLocale, (CXFA_LocaleMgr*)pMgr);
4619 if (localeValue.IsValid()) { 4619 if (localeValue2.IsValid()) {
4620 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); 4620 szParsedValue = FX_UTF8Encode(localeValue2.GetValue());
4621 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4621 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4622 szParsedValue.AsStringC()); 4622 szParsedValue.AsStringC());
4623 } else { 4623 } else {
4624 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4624 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
4625 } 4625 }
4626 } 4626 }
4627 } break; 4627 } break;
4628 } 4628 }
4629 } 4629 }
4630 } 4630 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
5289 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); 5289 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf);
5290 iIndex += iCount; 5290 iIndex += iCount;
5291 if (iIndex < iInteger) { 5291 if (iIndex < iInteger) {
5292 strBuf << " Trillion "; 5292 strBuf << " Trillion ";
5293 } 5293 }
5294 } 5294 }
5295 strBuf << " Dollars"; 5295 strBuf << " Dollars";
5296 if (iInteger < iLength) { 5296 if (iInteger < iLength) {
5297 strBuf << " And "; 5297 strBuf << " And ";
5298 iIndex = iInteger + 1; 5298 iIndex = iInteger + 1;
5299 int32_t iCount = 0;
5300 while (iIndex < iLength) { 5299 while (iIndex < iLength) {
5301 iCount = (iLength - iIndex) % 12; 5300 int32_t iSize = (iLength - iIndex) % 12;
5302 if (!iCount && iLength - iIndex > 0) { 5301 if (!iSize && iLength - iIndex > 0)
5303 iCount = 12; 5302 iSize = 12;
5304 } 5303 TrillionUS(CFX_ByteStringC(pData + iIndex, iSize), strBuf);
5305 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); 5304 iIndex += iSize;
5306 iIndex += iCount;
5307 if (iIndex < iLength) { 5305 if (iIndex < iLength) {
5308 strBuf << " Trillion "; 5306 strBuf << " Trillion ";
5309 } 5307 }
5310 } 5308 }
5311 strBuf << " Cents"; 5309 strBuf << " Cents";
5312 } 5310 }
5313 } break; 5311 } break;
5314 default: 5312 default:
5315 break; 5313 break;
5316 } 5314 }
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
7033 CFX_WideString wsFormat; 7031 CFX_WideString wsFormat;
7034 pAppProvider->LoadString(iStringID, wsFormat); 7032 pAppProvider->LoadString(iStringID, wsFormat);
7035 CFX_WideString wsMessage; 7033 CFX_WideString wsMessage;
7036 va_list arg_ptr; 7034 va_list arg_ptr;
7037 va_start(arg_ptr, iStringID); 7035 va_start(arg_ptr, iStringID);
7038 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); 7036 wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
7039 va_end(arg_ptr); 7037 va_end(arg_ptr);
7040 FXJSE_ThrowMessage( 7038 FXJSE_ThrowMessage(
7041 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 7039 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
7042 } 7040 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | xfa/fxfa/fm2js/xfa_fmparse.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698