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

Side by Side Diff: fpdfsdk/src/javascript/PublicMethods.cpp

Issue 1398703009: Next round of XFA changes to match master (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: remove arg Created 5 years, 2 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
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 "PublicMethods.h" 7 #include "PublicMethods.h"
8 8
9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment.
10 #include "../../include/javascript/IJavaScript.h" 10 #include "../../include/javascript/IJavaScript.h"
(...skipping 30 matching lines...) Expand all
41 JS_STATIC_GLOBAL_FUN_ENTRY(AFMakeNumber) 41 JS_STATIC_GLOBAL_FUN_ENTRY(AFMakeNumber)
42 JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple_Calculate) 42 JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple_Calculate)
43 JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate) 43 JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate)
44 JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange) 44 JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange)
45 JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx) 45 JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx)
46 JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums) 46 JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums)
47 END_JS_STATIC_GLOBAL_FUN() 47 END_JS_STATIC_GLOBAL_FUN()
48 48
49 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) 49 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods)
50 50
51 static const FX_WCHAR* months[] = {L"Jan", L"Feb", L"Mar", L"Apr", 51 static const FX_WCHAR* const months[] = {L"Jan",
52 L"May", L"Jun", L"Jul", L"Aug", 52 L"Feb",
53 L"Sep", L"Oct", L"Nov", L"Dec"}; 53 L"Mar",
54 L"Apr",
55 L"May",
56 L"Jun",
57 L"Jul",
58 L"Aug",
59 L"Sep",
60 L"Oct",
61 L"Nov",
62 L"Dec"};
54 63
55 static const FX_WCHAR* const fullmonths[] = { 64 static const FX_WCHAR* const fullmonths[] = {
56 L"January", L"February", L"March", L"April", 65 L"January", L"February", L"March", L"April",
57 L"May", L"June", L"July", L"August", 66 L"May", L"June", L"July", L"August",
58 L"September", L"October", L"November", L"December"}; 67 L"September", L"October", L"November", L"December"};
59 68
60 FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* string) { 69 FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* string) {
61 CFX_WideString sTrim = StrTrim(string); 70 CFX_WideString sTrim = StrTrim(string);
62 const FX_WCHAR* pTrim = sTrim.c_str(); 71 const FX_WCHAR* pTrim = sTrim.c_str();
63 const FX_WCHAR* p = pTrim; 72 const FX_WCHAR* p = pTrim;
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 iSepStyle = 0; 937 iSepStyle = 0;
929 938
930 if (iNegStyle < 0 || iNegStyle > 3) 939 if (iNegStyle < 0 || iNegStyle > 3)
931 iNegStyle = 0; 940 iNegStyle = 0;
932 941
933 ////////////////////////////////////////////////////// 942 //////////////////////////////////////////////////////
934 // for processing decimal places 943 // for processing decimal places
935 strValue.Replace(",", "."); 944 strValue.Replace(",", ".");
936 double dValue = atof(strValue); 945 double dValue = atof(strValue);
937 if (iDec > 0) 946 if (iDec > 0)
938 dValue += DOUBLE_CORRECT; // 947 dValue += DOUBLE_CORRECT;
939 948
940 int iDec2; 949 int iDec2;
941 int iNegative = 0; 950 int iNegative = 0;
942 951
943 strValue = fcvt(dValue, iDec, &iDec2, &iNegative); 952 strValue = fcvt(dValue, iDec, &iDec2, &iNegative);
944 if (strValue.IsEmpty()) { 953 if (strValue.IsEmpty()) {
945 dValue = 0; 954 dValue = 0;
946 strValue = fcvt(dValue, iDec, &iDec2, &iNegative); 955 strValue = fcvt(dValue, iDec, &iDec2, &iNegative);
947 if (strValue.IsEmpty()) { 956 if (strValue.IsEmpty()) {
948 strValue = "0"; 957 strValue = "0";
(...skipping 28 matching lines...) Expand all
977 if (iDec2 == 0) 986 if (iDec2 == 0)
978 strValue.Insert(iDec2, '0'); 987 strValue.Insert(iDec2, '0');
979 } 988 }
980 if (iSepStyle == 0 || iSepStyle == 2) { 989 if (iSepStyle == 0 || iSepStyle == 2) {
981 char cSeperator; 990 char cSeperator;
982 if (iSepStyle == 0) 991 if (iSepStyle == 0)
983 cSeperator = ','; 992 cSeperator = ',';
984 else 993 else
985 cSeperator = '.'; 994 cSeperator = '.';
986 995
987 int iDecPositive, iDecNegative; 996 for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
988 iDecPositive = iDec2;
989 iDecNegative = iDec2;
990
991 for (iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
992 strValue.Insert(iDecPositive, cSeperator); 997 strValue.Insert(iDecPositive, cSeperator);
993 iMax++; 998 iMax++;
994 } 999 }
995 } 1000 }
996 1001
997 ////////////////////////////////////////////////////////////////////// 1002 //////////////////////////////////////////////////////////////////////
998 // for processing currency string 1003 // for processing currency string
999 1004
1000 Value = CFX_WideString::FromLocal(strValue); 1005 Value = CFX_WideString::FromLocal(strValue);
1001 std::wstring strValue2 = Value.c_str(); 1006 std::wstring strValue2 = Value.c_str();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 if (iDec2 == 0) 1272 if (iDec2 == 0)
1268 strValue.Insert(iDec2, '0'); 1273 strValue.Insert(iDec2, '0');
1269 } 1274 }
1270 if (iSepStyle == 0 || iSepStyle == 2) { 1275 if (iSepStyle == 0 || iSepStyle == 2) {
1271 char cSeperator; 1276 char cSeperator;
1272 if (iSepStyle == 0) 1277 if (iSepStyle == 0)
1273 cSeperator = ','; 1278 cSeperator = ',';
1274 else 1279 else
1275 cSeperator = '.'; 1280 cSeperator = '.';
1276 1281
1277 int iDecPositive, iDecNegative; 1282 for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
1278 iDecPositive = iDec2;
1279 iDecNegative = iDec2;
1280
1281 for (iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
1282 strValue.Insert(iDecPositive, cSeperator); 1283 strValue.Insert(iDecPositive, cSeperator);
1283 iMax++; 1284 iMax++;
1284 } 1285 }
1285 } 1286 }
1286 //////////////////////////////////////////////////////////////////// 1287 ////////////////////////////////////////////////////////////////////
1287 // negative mark 1288 // negative mark
1288 if (iNegative) 1289 if (iNegative)
1289 strValue = "-" + strValue; 1290 strValue = "-" + strValue;
1290 strValue += "%"; 1291 strValue += "%";
1291 Value = CFX_WideString::FromLocal(strValue); 1292 Value = CFX_WideString::FromLocal(strValue);
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); 2069 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str()));
2069 } 2070 }
2070 2071
2071 if (nums.GetLength() > 0) 2072 if (nums.GetLength() > 0)
2072 vRet = nums; 2073 vRet = nums;
2073 else 2074 else
2074 vRet.SetNull(); 2075 vRet.SetNull();
2075 2076
2076 return TRUE; 2077 return TRUE;
2077 } 2078 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698