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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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 | « fpdfsdk/src/javascript/JS_Value.cpp ('k') | fpdfsdk/src/javascript/app.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 "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_Object.h" 10 #include "../../include/javascript/JS_Object.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 static const FX_WCHAR* months[] = 65 static const FX_WCHAR* months[] =
66 { 66 {
67 L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" 67 L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
68 }; 68 };
69 69
70 static const FX_WCHAR* fullmonths[] = 70 static const FX_WCHAR* fullmonths[] =
71 { 71 {
72 L"January", L"February", L"March", L"April", L"May", L"June", L"July", L "August", L"September", L"October", L"November", L"December" 72 L"January", L"February", L"March", L"April", L"May", L"June", L"July", L "August", L"September", L"October", L"November", L"December"
73 }; 73 };
74 74
75 FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* string) 75 bool CJS_PublicMethods::IsNumber(const FX_WCHAR* string)
76 { 76 {
77 CFX_WideString sTrim = StrTrim(string); 77 CFX_WideString sTrim = StrTrim(string);
78 const FX_WCHAR* pTrim = sTrim.c_str(); 78 const FX_WCHAR* pTrim = sTrim.c_str();
79 const FX_WCHAR* p = pTrim; 79 const FX_WCHAR* p = pTrim;
80 80
81 81
82 » FX_BOOL bDot = FALSE; 82 » bool bDot = false;
83 » FX_BOOL bKXJS = FALSE; 83 » bool bKXJS = false;
84 84
85 wchar_t c; 85 wchar_t c;
86 while ((c = *p)) 86 while ((c = *p))
87 { 87 {
88 if (c == '.' || c == ',') 88 if (c == '.' || c == ',')
89 { 89 {
90 » » » if (bDot) return FALSE; 90 » » » if (bDot) return false;
91 » » » bDot = TRUE; 91 » » » bDot = true;
92 } 92 }
93 else if (c == '-' || c == '+') 93 else if (c == '-' || c == '+')
94 { 94 {
95 if (p != pTrim) 95 if (p != pTrim)
96 » » » » return FALSE; 96 » » » » return false;
97 } 97 }
98 else if (c == 'e' || c == 'E') 98 else if (c == 'e' || c == 'E')
99 { 99 {
100 » » » if (bKXJS) return FALSE; 100 » » » if (bKXJS) return false;
101 101
102 p++; 102 p++;
103 c = *p; 103 c = *p;
104 if (c == '+' || c == '-') 104 if (c == '+' || c == '-')
105 { 105 {
106 » » » » bKXJS = TRUE; 106 » » » » bKXJS = true;
107 } 107 }
108 else 108 else
109 { 109 {
110 » » » » return FALSE; 110 » » » » return false;
111 } 111 }
112 } 112 }
113 else if (!IsDigit(c)) 113 else if (!IsDigit(c))
114 { 114 {
115 » » » return FALSE; 115 » » » return false;
116 } 116 }
117 p++; 117 p++;
118 } 118 }
119 119
120 » return TRUE; 120 » return true;
121 } 121 }
122 122
123 FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch) 123 bool CJS_PublicMethods::IsDigit(wchar_t ch)
124 { 124 {
125 return (ch >= L'0' && ch <= L'9'); 125 return (ch >= L'0' && ch <= L'9');
126 } 126 }
127 127
128 FX_BOOL CJS_PublicMethods::IsDigit(char ch) 128 bool CJS_PublicMethods::IsDigit(char ch)
129 { 129 {
130 return (ch >= '0' && ch <= '9'); 130 return (ch >= '0' && ch <= '9');
131 } 131 }
132 132
133 FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch) 133 bool CJS_PublicMethods::IsAlphabetic(wchar_t ch)
134 { 134 {
135 return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z')); 135 return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z'));
136 } 136 }
137 137
138 FX_BOOL CJS_PublicMethods::IsAlphaNumeric(wchar_t ch) 138 bool CJS_PublicMethods::IsAlphaNumeric(wchar_t ch)
139 { 139 {
140 return (IsDigit(ch) || IsAlphabetic(ch)); 140 return (IsDigit(ch) || IsAlphabetic(ch));
141 } 141 }
142 142
143 FX_BOOL CJS_PublicMethods::maskSatisfied(wchar_t c_Change,wchar_t c_Mask) 143 bool CJS_PublicMethods::maskSatisfied(wchar_t c_Change,wchar_t c_Mask)
144 { 144 {
145 switch (c_Mask) 145 switch (c_Mask)
146 { 146 {
147 case L'9': 147 case L'9':
148 return IsDigit(c_Change); 148 return IsDigit(c_Change);
149 case L'A': 149 case L'A':
150 return IsAlphabetic(c_Change); 150 return IsAlphabetic(c_Change);
151 case L'O': 151 case L'O':
152 return IsAlphaNumeric(c_Change); 152 return IsAlphaNumeric(c_Change);
153 case L'X': 153 case L'X':
154 return TRUE; 154 return true;
155 default: 155 default:
156 return (c_Change == c_Mask); 156 return (c_Change == c_Mask);
157 } 157 }
158 } 158 }
159 159
160 FX_BOOL CJS_PublicMethods::isReservedMaskChar(wchar_t ch) 160 bool CJS_PublicMethods::isReservedMaskChar(wchar_t ch)
161 { 161 {
162 return ch == L'9' || ch == L'A' || ch == L'O' || ch == L'X'; 162 return ch == L'9' || ch == L'A' || ch == L'O' || ch == L'X';
163 } 163 }
164 164
165 double CJS_PublicMethods::AF_Simple(const FX_WCHAR* sFuction, double dValue1, do uble dValue2) 165 double CJS_PublicMethods::AF_Simple(const FX_WCHAR* sFuction, double dValue1, do uble dValue2)
166 { 166 {
167 if (FXSYS_wcsicmp(sFuction,L"AVG") == 0 || FXSYS_wcsicmp(sFuction,L"SUM" ) == 0) 167 if (FXSYS_wcsicmp(sFuction,L"AVG") == 0 || FXSYS_wcsicmp(sFuction,L"SUM" ) == 0)
168 { 168 {
169 return dValue1 + dValue2; 169 return dValue1 + dValue2;
170 } 170 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 while (p > pStr && *(p - 1) == L' ') p--; 219 while (p > pStr && *(p - 1) == L' ') p--;
220 220
221 return CFX_ByteString(pStr,p-pStr); 221 return CFX_ByteString(pStr,p-pStr);
222 } 222 }
223 223
224 CFX_ByteString CJS_PublicMethods::StrTrim(const FX_CHAR* pStr) 224 CFX_ByteString CJS_PublicMethods::StrTrim(const FX_CHAR* pStr)
225 { 225 {
226 return StrRTrim(StrLTrim(pStr)); 226 return StrRTrim(StrLTrim(pStr));
227 } 227 }
228 228
229 double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig its, FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS) 229 double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, bool& bAllDigits , bool& bDot, bool& bSign, bool& bKXJS)
230 { 230 {
231 » bDot = FALSE; 231 » bDot = false;
232 » bSign = FALSE; 232 » bSign = false;
233 » bKXJS = FALSE; 233 » bKXJS = false;
234 234
235 » FX_BOOL bDigitExist = FALSE; 235 » bool bDigitExist = false;
236 236
237 const FX_WCHAR* p = swSource; 237 const FX_WCHAR* p = swSource;
238 wchar_t c; 238 wchar_t c;
239 239
240 const FX_WCHAR* pStart = NULL; 240 const FX_WCHAR* pStart = NULL;
241 const FX_WCHAR* pEnd = NULL; 241 const FX_WCHAR* pEnd = NULL;
242 242
243 while ((c = *p)) 243 while ((c = *p))
244 { 244 {
245 if (!pStart && c != L' ') 245 if (!pStart && c != L' ')
246 { 246 {
247 pStart = p; 247 pStart = p;
248 } 248 }
249 249
250 pEnd = p; 250 pEnd = p;
251 p++; 251 p++;
252 } 252 }
253 253
254 if (!pStart) 254 if (!pStart)
255 { 255 {
256 » » bAllDigits = FALSE; 256 » » bAllDigits = false;
257 return 0; 257 return 0;
258 } 258 }
259 259
260 while (pEnd != pStart) 260 while (pEnd != pStart)
261 { 261 {
262 if (*pEnd == L' ') 262 if (*pEnd == L' ')
263 pEnd --; 263 pEnd --;
264 else 264 else
265 break; 265 break;
266 } 266 }
267 267
268 double dRet = 0; 268 double dRet = 0;
269 p = pStart; 269 p = pStart;
270 » bAllDigits = TRUE; 270 » bAllDigits = true;
271 CFX_WideString swDigits; 271 CFX_WideString swDigits;
272 272
273 while (p <= pEnd) 273 while (p <= pEnd)
274 { 274 {
275 c = *p; 275 c = *p;
276 276
277 if (IsDigit(c)) 277 if (IsDigit(c))
278 { 278 {
279 swDigits += c; 279 swDigits += c;
280 » » » bDigitExist = TRUE; 280 » » » bDigitExist = true;
281 } 281 }
282 else 282 else
283 { 283 {
284 switch (c) 284 switch (c)
285 { 285 {
286 case L' ': 286 case L' ':
287 » » » » bAllDigits = FALSE; 287 » » » » bAllDigits = false;
288 break; 288 break;
289 case L'.': 289 case L'.':
290 case L',': 290 case L',':
291 if (!bDot) 291 if (!bDot)
292 { 292 {
293 if (bDigitExist) 293 if (bDigitExist)
294 { 294 {
295 swDigits += L'.'; 295 swDigits += L'.';
296 } 296 }
297 else 297 else
298 { 298 {
299 swDigits += L'0'; 299 swDigits += L'0';
300 swDigits += L'.'; 300 swDigits += L'.';
301 » » » » » » bDigitExist = TRUE; 301 » » » » » » bDigitExist = true;
302 } 302 }
303 303
304 » » » » » bDot = TRUE; 304 » » » » » bDot = true;
305 break; 305 break;
306 } 306 }
307 case 'e': 307 case 'e':
308 case 'E': 308 case 'E':
309 if (!bKXJS) 309 if (!bKXJS)
310 { 310 {
311 p++; 311 p++;
312 c = *p; 312 c = *p;
313 if (c == '+' || c == '-') 313 if (c == '+' || c == '-')
314 { 314 {
315 » » » » » » bKXJS = TRUE; 315 » » » » » » bKXJS = true;
316 swDigits += 'e'; 316 swDigits += 'e';
317 swDigits += c; 317 swDigits += c;
318 } 318 }
319 break; 319 break;
320 } 320 }
321 case L'-': 321 case L'-':
322 if (!bDigitExist && !bSign) 322 if (!bDigitExist && !bSign)
323 { 323 {
324 swDigits += c; 324 swDigits += c;
325 » » » » » bSign = TRUE; 325 » » » » » bSign = true;
326 break; 326 break;
327 } 327 }
328 default: 328 default:
329 » » » » bAllDigits = FALSE; 329 » » » » bAllDigits = false;
330 330
331 if (p != pStart && !bDot && bDigitExist) 331 if (p != pStart && !bDot && bDigitExist)
332 { 332 {
333 swDigits += L'.'; 333 swDigits += L'.';
334 » » » » » bDot = TRUE; 334 » » » » » bDot = true;
335 } 335 }
336 else 336 else
337 { 337 {
338 » » » » » bDot = FALSE; 338 » » » » » bDot = false;
339 » » » » » bDigitExist = FALSE; 339 » » » » » bDigitExist = false;
340 swDigits = L""; 340 swDigits = L"";
341 } 341 }
342 break; 342 break;
343 } 343 }
344 } 344 }
345 345
346 p++; 346 p++;
347 } 347 }
348 348
349 if (swDigits.GetLength() > 0 && swDigits.GetLength() < 17) 349 if (swDigits.GetLength() > 0 && swDigits.GetLength() < 17)
(...skipping 17 matching lines...) Expand all
367 } 367 }
368 } 368 }
369 369
370 } 370 }
371 371
372 return dRet; 372 return dRet;
373 } 373 }
374 374
375 double CJS_PublicMethods::ParseStringToNumber(const FX_WCHAR* swSource) 375 double CJS_PublicMethods::ParseStringToNumber(const FX_WCHAR* swSource)
376 { 376 {
377 » FX_BOOL bAllDigits = FALSE; 377 » bool bAllDigits = false;
378 » FX_BOOL bDot = FALSE; 378 » bool bDot = false;
379 » FX_BOOL bSign = FALSE; 379 » bool bSign = false;
380 » FX_BOOL bKXJS = FALSE; 380 » bool bKXJS = false;
381 381
382 return ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS); 382 return ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS);
383 } 383 }
384 384
385 FX_BOOL»CJS_PublicMethods::ConvertStringToNumber(const FX_WCHAR* swSource, doubl e & dRet, FX_BOOL & bDot) 385 bool» CJS_PublicMethods::ConvertStringToNumber(const FX_WCHAR* swSource, doubl e & dRet, bool & bDot)
386 { 386 {
387 » FX_BOOL bAllDigits = FALSE; 387 » bool bAllDigits = false;
388 » FX_BOOL bSign = FALSE; 388 » bool bSign = false;
389 » FX_BOOL bKXJS = FALSE; 389 » bool bKXJS = false;
390 390
391 dRet = ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS); 391 dRet = ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS);
392 392
393 return bAllDigits; 393 return bAllDigits;
394 } 394 }
395 395
396 CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu e val) 396 CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu e val)
397 { 397 {
398 CJS_Array StrArray(isolate); 398 CJS_Array StrArray(isolate);
399 if(val.IsArrayObject()) 399 if(val.IsArrayObject())
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 swRet += c; 470 swRet += c;
471 nSkip = i - nStart + 1; 471 nSkip = i - nStart + 1;
472 } 472 }
473 else 473 else
474 break; 474 break;
475 } 475 }
476 476
477 return swRet; 477 return swRet;
478 } 478 }
479 479
480 double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, FX_BOOL& bWrongFormat) 480 double CJS_PublicMethods::ParseNormalDate(const CFX_WideString & value, bool& bW rongFormat)
481 { 481 {
482 double dt = JS_GetDateTime(); 482 double dt = JS_GetDateTime();
483 483
484 int nYear = JS_GetYearFromTime(dt); 484 int nYear = JS_GetYearFromTime(dt);
485 int nMonth = JS_GetMonthFromTime(dt) + 1; 485 int nMonth = JS_GetMonthFromTime(dt) + 1;
486 int nDay = JS_GetDayFromTime(dt); 486 int nDay = JS_GetDayFromTime(dt);
487 int nHour = JS_GetHourFromTime(dt); 487 int nHour = JS_GetHourFromTime(dt);
488 int nMin = JS_GetMinFromTime(dt); 488 int nMin = JS_GetMinFromTime(dt);
489 int nSec = JS_GetSecFromTime(dt); 489 int nSec = JS_GetSecFromTime(dt);
490 490
(...skipping 27 matching lines...) Expand all
518 { 518 {
519 nMonth = number[0]; 519 nMonth = number[0];
520 nDay = number[1]; 520 nDay = number[1];
521 } 521 }
522 else if ((number[0] >= 1 && number[0] <= 31) && (number[1] >= 1 && number[1] <= 12)) 522 else if ((number[0] >= 1 && number[0] <= 31) && (number[1] >= 1 && number[1] <= 12))
523 { 523 {
524 nDay = number[0]; 524 nDay = number[0];
525 nMonth = number[1]; 525 nMonth = number[1];
526 } 526 }
527 527
528 » » bWrongFormat = FALSE; 528 » » bWrongFormat = false;
529 } 529 }
530 else if (nIndex == 3) 530 else if (nIndex == 3)
531 { 531 {
532 // case1: year/month/day 532 // case1: year/month/day
533 // case2: month/day/year 533 // case2: month/day/year
534 // case3: day/month/year 534 // case3: day/month/year
535 535
536 if (number[0] > 12 && (number[1] >= 1 && number[1] <= 12) && (nu mber[2] >= 1 && number[2] <= 31)) 536 if (number[0] > 12 && (number[1] >= 1 && number[1] <= 12) && (nu mber[2] >= 1 && number[2] <= 31))
537 { 537 {
538 nYear = number[0]; 538 nYear = number[0];
539 nMonth = number[1]; 539 nMonth = number[1];
540 nDay = number[2]; 540 nDay = number[2];
541 } 541 }
542 else if ((number[0] >= 1 && number[0] <= 12) && (number[1] >= 1 && number[1] <= 31) && number[2] > 31) 542 else if ((number[0] >= 1 && number[0] <= 12) && (number[1] >= 1 && number[1] <= 31) && number[2] > 31)
543 { 543 {
544 nMonth = number[0]; 544 nMonth = number[0];
545 nDay = number[1]; 545 nDay = number[1];
546 nYear = number[2]; 546 nYear = number[2];
547 } 547 }
548 else if ((number[0] >= 1 && number[0] <= 31) && (number[1] >= 1 && number[1] <= 12) && number[2] > 31) 548 else if ((number[0] >= 1 && number[0] <= 31) && (number[1] >= 1 && number[1] <= 12) && number[2] > 31)
549 { 549 {
550 nDay = number[0]; 550 nDay = number[0];
551 nMonth = number[1]; 551 nMonth = number[1];
552 nYear = number[2]; 552 nYear = number[2];
553 } 553 }
554 554
555 » » bWrongFormat = FALSE; 555 » » bWrongFormat = false;
556 } 556 }
557 else 557 else
558 { 558 {
559 » » bWrongFormat = TRUE; 559 » » bWrongFormat = true;
560 return dt; 560 return dt;
561 } 561 }
562 562
563 CFX_WideString swTemp; 563 CFX_WideString swTemp;
564 swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec); 564 swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec);
565 return JS_DateParse(swTemp.c_str()); 565 return JS_DateParse(swTemp.c_str());
566 } 566 }
567 567
568 double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF X_WideString & format, FX_BOOL& bWrongFormat) 568 double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF X_WideString & format, bool& bWrongFormat)
569 { 569 {
570 double dt = JS_GetDateTime(); 570 double dt = JS_GetDateTime();
571 571
572 if (format.IsEmpty() || value.IsEmpty()) 572 if (format.IsEmpty() || value.IsEmpty())
573 return dt; 573 return dt;
574 574
575 int nYear = JS_GetYearFromTime(dt); 575 int nYear = JS_GetYearFromTime(dt);
576 int nMonth = JS_GetMonthFromTime(dt) + 1; 576 int nMonth = JS_GetMonthFromTime(dt) + 1;
577 int nDay = JS_GetDayFromTime(dt); 577 int nDay = JS_GetDayFromTime(dt);
578 int nHour = JS_GetHourFromTime(dt); 578 int nHour = JS_GetHourFromTime(dt);
579 int nMin = JS_GetMinFromTime(dt); 579 int nMin = JS_GetMinFromTime(dt);
580 int nSec = JS_GetSecFromTime(dt); 580 int nSec = JS_GetSecFromTime(dt);
581 581
582 int nYearSub = 99; //nYear - 2000; 582 int nYearSub = 99; //nYear - 2000;
583 583
584 » FX_BOOL bPm = FALSE; 584 » bool bPm = false;
585 » FX_BOOL bExit = FALSE; 585 » bool bExit = false;
586 » bWrongFormat = FALSE; 586 » bWrongFormat = false;
587 587
588 int i=0; 588 int i=0;
589 int j=0; 589 int j=0;
590 590
591 while (i < format.GetLength()) 591 while (i < format.GetLength())
592 { 592 {
593 if (bExit) break; 593 if (bExit) break;
594 594
595 FX_WCHAR c = format.GetAt(i); 595 FX_WCHAR c = format.GetAt(i);
596 switch (c) 596 switch (c)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 break; 708 break;
709 } 709 }
710 } 710 }
711 else if (remaining == 2 || format.GetAt( i+3) != c) 711 else if (remaining == 2 || format.GetAt( i+3) != c)
712 { 712 {
713 switch (c) 713 switch (c)
714 { 714 {
715 case 'm': 715 case 'm':
716 { 716 {
717 CFX_Wide String sMonth = ParseStringString(value, j, nSkip); 717 CFX_Wide String sMonth = ParseStringString(value, j, nSkip);
718 » » » » » » » » » FX_BOOL bFind = FALSE; 718 » » » » » » » » » bool bFi nd = false;
719 for (int m = 0; m < 12; m++) 719 for (int m = 0; m < 12; m++)
720 { 720 {
721 if (sMonth.CompareNoCase(months[m]) == 0) 721 if (sMonth.CompareNoCase(months[m]) == 0)
722 { 722 {
723 nMonth = m + 1; 723 nMonth = m + 1;
724 i+=3; 724 i+=3;
725 j+=nSkip; 725 j+=nSkip;
726 » » » » » » » » » » » bFind = TRUE; 726 » » » » » » » » » » » bFind = true;
727 break; 727 break;
728 } 728 }
729 } 729 }
730 730
731 if (!bFi nd) 731 if (!bFi nd)
732 { 732 {
733 nMonth = ParseStringInteger(value, j, nSkip, 3); 733 nMonth = ParseStringInteger(value, j, nSkip, 3);
734 i+=3; 734 i+=3;
735 j += nSkip; 735 j += nSkip;
736 } 736 }
(...skipping 13 matching lines...) Expand all
750 { 750 {
751 751
752 752
753 case 'y': 753 case 'y':
754 nYear = ParseStr ingInteger(value, j, nSkip, 4); 754 nYear = ParseStr ingInteger(value, j, nSkip, 4);
755 j += nSkip; 755 j += nSkip;
756 i += 4; 756 i += 4;
757 break; 757 break;
758 case 'm': 758 case 'm':
759 { 759 {
760 » » » » » » » » » FX_BOOL bFind = FALSE; 760 » » » » » » » » » bool bFi nd = false;
761 761
762 CFX_Wide String sMonth = ParseStringString(value, j, nSkip); 762 CFX_Wide String sMonth = ParseStringString(value, j, nSkip);
763 sMonth.M akeLower(); 763 sMonth.M akeLower();
764 764
765 for (int m = 0; m < 12; m++) 765 for (int m = 0; m < 12; m++)
766 { 766 {
767 CFX_WideString sFullMonths = fullmonths[m]; 767 CFX_WideString sFullMonths = fullmonths[m];
768 sFullMonths.MakeLower(); 768 sFullMonths.MakeLower();
769 769
770 if (sFullMonths.Find(sMonth.c_str(), 0) != -1) 770 if (sFullMonths.Find(sMonth.c_str(), 0) != -1)
771 { 771 {
772 nMonth = m + 1; 772 nMonth = m + 1;
773 i += 4; 773 i += 4;
774 j += nSkip; 774 j += nSkip;
775 » » » » » » » » » » » bFind = TRUE; 775 » » » » » » » » » » » bFind = true;
776 break; 776 break;
777 } 777 }
778 } 778 }
779 779
780 if (!bFi nd) 780 if (!bFi nd)
781 { 781 {
782 nMonth = ParseStringInteger(value, j, nSkip, 4); 782 nMonth = ParseStringInteger(value, j, nSkip, 4);
783 i+=4; 783 i+=4;
784 j += nSkip; 784 j += nSkip;
785 } 785 }
786 } 786 }
787 break; 787 break;
788 default: 788 default:
789 i += 4; 789 i += 4;
790 j += 4; 790 j += 4;
791 break; 791 break;
792 } 792 }
793 } 793 }
794 else 794 else
795 { 795 {
796 if (j >= value.GetLength() || fo rmat.GetAt(i) != value.GetAt(j)) 796 if (j >= value.GetLength() || fo rmat.GetAt(i) != value.GetAt(j))
797 { 797 {
798 » » » » » » » bWrongFormat = TRUE; 798 » » » » » » » bWrongFormat = true;
799 » » » » » » » bExit = TRUE; 799 » » » » » » » bExit = true;
800 } 800 }
801 i++; 801 i++;
802 j++; 802 j++;
803 } 803 }
804 804
805 if (oldj == j) 805 if (oldj == j)
806 { 806 {
807 » » » » » » bWrongFormat = TRUE; 807 » » » » » » bWrongFormat = true;
808 » » » » » » bExit = TRUE; 808 » » » » » » bExit = true;
809 } 809 }
810 } 810 }
811 811
812 break; 812 break;
813 default: 813 default:
814 if (value.GetLength() <= j) 814 if (value.GetLength() <= j)
815 { 815 {
816 » » » » » bExit = TRUE; 816 » » » » » bExit = true;
817 } 817 }
818 else if (format.GetAt(i) != value.GetAt(j)) 818 else if (format.GetAt(i) != value.GetAt(j))
819 { 819 {
820 » » » » » bWrongFormat = TRUE; 820 » » » » » bWrongFormat = true;
821 » » » » » bExit = TRUE; 821 » » » » » bExit = true;
822 } 822 }
823 823
824 i++; 824 i++;
825 j++; 825 j++;
826 break; 826 break;
827 } 827 }
828 } 828 }
829 829
830 if (bPm) nHour += 12; 830 if (bPm) nHour += 12;
831 831
832 if (nYear >= 0 && nYear <= nYearSub) 832 if (nYear >= 0 && nYear <= nYearSub)
833 nYear += 2000; 833 nYear += 2000;
834 834
835 if (nMonth < 1 || nMonth > 12) 835 if (nMonth < 1 || nMonth > 12)
836 » » bWrongFormat = TRUE; 836 » » bWrongFormat = true;
837 837
838 if (nDay < 1 || nDay > 31) 838 if (nDay < 1 || nDay > 31)
839 » » bWrongFormat = TRUE; 839 » » bWrongFormat = true;
840 840
841 if (nHour < 0 || nHour > 24) 841 if (nHour < 0 || nHour > 24)
842 » » bWrongFormat = TRUE; 842 » » bWrongFormat = true;
843 843
844 if (nMin < 0 || nMin > 60) 844 if (nMin < 0 || nMin > 60)
845 » » bWrongFormat = TRUE; 845 » » bWrongFormat = true;
846 846
847 if (nSec < 0 || nSec > 60) 847 if (nSec < 0 || nSec > 60)
848 » » bWrongFormat = TRUE; 848 » » bWrongFormat = true;
849 849
850 double dRet = 0; 850 double dRet = 0;
851 851
852 if (bWrongFormat) 852 if (bWrongFormat)
853 { 853 {
854 dRet = ParseNormalDate(value, bWrongFormat); 854 dRet = ParseNormalDate(value, bWrongFormat);
855 } 855 }
856 else 856 else
857 { 857 {
858 dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime (nHour, nMin, nSec, 0)); 858 dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime (nHour, nMin, nSec, 0));
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 1014
1015 sRet += sPart; 1015 sRet += sPart;
1016 } 1016 }
1017 1017
1018 return sRet; 1018 return sRet;
1019 } 1019 }
1020 1020
1021 /* -------------------------------------------------------------------------- */ 1021 /* -------------------------------------------------------------------------- */
1022 1022
1023 //function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, bCu rrencyPrepend) 1023 //function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, bCu rrencyPrepend)
1024 FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Paramete rs& params, CJS_Value& vRet, CFX_WideString& sError) 1024 bool CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
1025 { 1025 {
1026 #if _FX_OS_ != _FX_ANDROID_ 1026 #if _FX_OS_ != _FX_ANDROID_
1027 v8::Isolate* isolate = ::GetIsolate(cc); 1027 v8::Isolate* isolate = ::GetIsolate(cc);
1028 CJS_Context* pContext = (CJS_Context *)cc; 1028 CJS_Context* pContext = (CJS_Context *)cc;
1029 ASSERT(pContext != NULL); 1029 ASSERT(pContext != NULL);
1030 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1030 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1031 ASSERT(pEvent != NULL); 1031 ASSERT(pEvent != NULL);
1032 1032
1033 if (params.size() != 6) 1033 if (params.size() != 6)
1034 { 1034 {
1035 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1035 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1036 » » return FALSE; 1036 » » return false;
1037 } 1037 }
1038 if(!pEvent->m_pValue) 1038 if(!pEvent->m_pValue)
1039 » » return FALSE; 1039 » » return false;
1040 CFX_WideString& Value = pEvent->Value(); 1040 CFX_WideString& Value = pEvent->Value();
1041 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); 1041 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
1042 1042
1043 » if (strValue.IsEmpty()) return TRUE; 1043 » if (strValue.IsEmpty()) return true;
1044 1044
1045 int iDec = params[0].ToInt(); 1045 int iDec = params[0].ToInt();
1046 int iSepStyle = params[1].ToInt(); 1046 int iSepStyle = params[1].ToInt();
1047 int iNegStyle = params[2].ToInt(); 1047 int iNegStyle = params[2].ToInt();
1048 // params[3] is iCurrStyle, it's not used. 1048 // params[3] is iCurrStyle, it's not used.
1049 std::wstring wstrCurrency(params[4].ToCFXWideString().c_str()); 1049 std::wstring wstrCurrency(params[4].ToCFXWideString().c_str());
1050 » FX_BOOL bCurrencyPrepend = params[5].ToBool(); 1050 » bool bCurrencyPrepend = params[5].ToBool();
1051 1051
1052 if (iDec < 0) iDec = -iDec; 1052 if (iDec < 0) iDec = -iDec;
1053 1053
1054 if (iSepStyle < 0 || iSepStyle > 3) 1054 if (iSepStyle < 0 || iSepStyle > 3)
1055 iSepStyle = 0; 1055 iSepStyle = 0;
1056 1056
1057 if (iNegStyle < 0 || iNegStyle > 3) 1057 if (iNegStyle < 0 || iNegStyle > 3)
1058 iNegStyle = 0; 1058 iNegStyle = 0;
1059 1059
1060 1060
1061 ////////////////////////////////////////////////////// 1061 //////////////////////////////////////////////////////
1062 //for processing decimal places 1062 //for processing decimal places
1063 strValue.Replace(",", "."); 1063 strValue.Replace(",", ".");
1064 double dValue = atof(strValue); 1064 double dValue = atof(strValue);
1065 if (iDec > 0) 1065 if (iDec > 0)
1066 dValue += DOUBLE_CORRECT; 1066 dValue += DOUBLE_CORRECT;
1067 1067
1068 int iDec2; 1068 int iDec2;
1069 » FX_BOOL bNegative = FALSE; 1069 » int iNegative = 0;
1070 1070
1071 » strValue = fcvt(dValue,iDec,&iDec2,&bNegative); 1071 » strValue = fcvt(dValue, iDec, &iDec2, &iNegative);
1072 if (strValue.IsEmpty()) 1072 if (strValue.IsEmpty())
1073 { 1073 {
1074 dValue = 0; 1074 dValue = 0;
1075 » » strValue = fcvt(dValue,iDec,&iDec2,&bNegative); 1075 » » strValue = fcvt(dValue, iDec, &iDec2, &iNegative);
1076 if (strValue.IsEmpty()) 1076 if (strValue.IsEmpty())
1077 { 1077 {
1078 strValue = "0"; 1078 strValue = "0";
1079 iDec2 = 1; 1079 iDec2 = 1;
1080 } 1080 }
1081 1081
1082 } 1082 }
1083 1083
1084 if (iDec2 < 0) 1084 if (iDec2 < 0)
1085 { 1085 {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 1143
1144 if (bCurrencyPrepend) 1144 if (bCurrencyPrepend)
1145 strValue2 = wstrCurrency + strValue2; 1145 strValue2 = wstrCurrency + strValue2;
1146 else 1146 else
1147 strValue2 = strValue2 + wstrCurrency; 1147 strValue2 = strValue2 + wstrCurrency;
1148 1148
1149 1149
1150 1150
1151 //////////////////////////////////////////////////////////////////////// / 1151 //////////////////////////////////////////////////////////////////////// /
1152 //for processing negative style 1152 //for processing negative style
1153 » if (bNegative) 1153 » if (iNegative)
1154 { 1154 {
1155 if (iNegStyle == 0) 1155 if (iNegStyle == 0)
1156 { 1156 {
1157 strValue2.insert(0,L"-"); 1157 strValue2.insert(0,L"-");
1158 } 1158 }
1159 if (iNegStyle == 2 || iNegStyle == 3) 1159 if (iNegStyle == 2 || iNegStyle == 3)
1160 { 1160 {
1161 strValue2.insert(0,L"("); 1161 strValue2.insert(0,L"(");
1162 strValue2.insert(strValue2.length(),L")"); 1162 strValue2.insert(strValue2.length(),L")");
1163 } 1163 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 vProp2.StartGetting(); 1217 vProp2.StartGetting();
1218 vProp2<<arColor; 1218 vProp2<<arColor;
1219 vProp2.StartSetting(); 1219 vProp2.StartSetting();
1220 fTarget->textColor(cc,vProp2,sError); 1220 fTarget->textColor(cc,vProp2,sError);
1221 } 1221 }
1222 } 1222 }
1223 } 1223 }
1224 } 1224 }
1225 Value = strValue2.c_str(); 1225 Value = strValue2.c_str();
1226 #endif 1226 #endif
1227 » return TRUE; 1227 » return true;
1228 } 1228 }
1229 1229
1230 //function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend) 1230 //function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend)
1231 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param eters& params, CJS_Value& vRet, CFX_WideString& sError) 1231 bool CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Paramete rs& params, CJS_Value& vRet, CFX_WideString& sError)
1232 { 1232 {
1233 CJS_Context* pContext = (CJS_Context *)cc; 1233 CJS_Context* pContext = (CJS_Context *)cc;
1234 ASSERT(pContext != NULL); 1234 ASSERT(pContext != NULL);
1235 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1235 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1236 ASSERT(pEvent != NULL); 1236 ASSERT(pEvent != NULL);
1237 1237
1238 if(params.size() < 2) 1238 if(params.size() < 2)
1239 » » return FALSE; 1239 » » return false;
1240 int iSepStyle = params[1].ToInt(); 1240 int iSepStyle = params[1].ToInt();
1241 1241
1242 if (iSepStyle < 0 || iSepStyle > 3) 1242 if (iSepStyle < 0 || iSepStyle > 3)
1243 iSepStyle = 0; 1243 iSepStyle = 0;
1244 if(!pEvent->m_pValue) 1244 if(!pEvent->m_pValue)
1245 » » return FALSE; 1245 » » return false;
1246 CFX_WideString & val = pEvent->Value(); 1246 CFX_WideString & val = pEvent->Value();
1247 CFX_WideString & w_strChange = pEvent->Change(); 1247 CFX_WideString & w_strChange = pEvent->Change();
1248 CFX_WideString w_strValue = val; 1248 CFX_WideString w_strValue = val;
1249 1249
1250 if (pEvent->WillCommit()) 1250 if (pEvent->WillCommit())
1251 { 1251 {
1252 CFX_WideString wstrChange = w_strChange; 1252 CFX_WideString wstrChange = w_strChange;
1253 CFX_WideString wstrValue = StrLTrim(w_strValue.c_str()); 1253 CFX_WideString wstrValue = StrLTrim(w_strValue.c_str());
1254 if (wstrValue.IsEmpty()) 1254 if (wstrValue.IsEmpty())
1255 » » » return TRUE; 1255 » » » return true;
1256 1256
1257 CFX_WideString swTemp = wstrValue; 1257 CFX_WideString swTemp = wstrValue;
1258 swTemp.Replace(L",", L"."); 1258 swTemp.Replace(L",", L".");
1259 if (!IsNumber(swTemp.c_str())) 1259 if (!IsNumber(swTemp.c_str()))
1260 { 1260 {
1261 » » » pEvent->Rc() = FALSE; 1261 » » » pEvent->Rc() = false;
1262 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMB ER_KEYSTROKE); 1262 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMB ER_KEYSTROKE);
1263 Alert(pContext, sError.c_str()); 1263 Alert(pContext, sError.c_str());
1264 » » » return TRUE; 1264 » » » return true;
1265 } 1265 }
1266 » » return TRUE; // it happens after the last keystroke and before v alidating, 1266 » » return true; // it happens after the last keystroke and before v alidating,
1267 } 1267 }
1268 1268
1269 std::wstring w_strValue2 = w_strValue.c_str(); 1269 std::wstring w_strValue2 = w_strValue.c_str();
1270 std::wstring w_strChange2 = w_strChange.c_str(); 1270 std::wstring w_strChange2 = w_strChange.c_str();
1271 std::wstring w_strSelected; 1271 std::wstring w_strSelected;
1272 if(-1 != pEvent->SelStart()) 1272 if(-1 != pEvent->SelStart())
1273 w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->S elEnd() - pEvent->SelStart())); 1273 w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->S elEnd() - pEvent->SelStart()));
1274 » FX_BOOL bHasSign = (w_strValue2.find('-') != -1) && (w_strSelected.find( '-') == -1); 1274 » bool bHasSign = (w_strValue2.find('-') != -1) && (w_strSelected.find('-' ) == -1);
1275 if (bHasSign) 1275 if (bHasSign)
1276 { 1276 {
1277 //can't insert "change" in front to sign postion. 1277 //can't insert "change" in front to sign postion.
1278 if (pEvent->SelStart() == 0) 1278 if (pEvent->SelStart() == 0)
1279 { 1279 {
1280 FX_BOOL &bRc = pEvent->Rc(); 1280 bool &bRc = pEvent->Rc();
1281 » » » bRc = FALSE; 1281 » » » bRc = false;
1282 » » » return TRUE; 1282 » » » return true;
1283 } 1283 }
1284 } 1284 }
1285 1285
1286 char cSep = L'.'; 1286 char cSep = L'.';
1287 1287
1288 switch (iSepStyle) 1288 switch (iSepStyle)
1289 { 1289 {
1290 case 0: 1290 case 0:
1291 case 1: 1291 case 1:
1292 cSep = L'.'; 1292 cSep = L'.';
1293 break; 1293 break;
1294 case 2: 1294 case 2:
1295 case 3: 1295 case 3:
1296 cSep = L','; 1296 cSep = L',';
1297 break; 1297 break;
1298 } 1298 }
1299 1299
1300 » FX_BOOL bHasSep = (w_strValue2.find(cSep) != -1); 1300 » bool bHasSep = (w_strValue2.find(cSep) != -1);
1301 for (std::wstring::iterator it = w_strChange2.begin(); it != w_strChange 2.end(); it++) 1301 for (std::wstring::iterator it = w_strChange2.begin(); it != w_strChange 2.end(); it++)
1302 { 1302 {
1303 if (*it == cSep) 1303 if (*it == cSep)
1304 { 1304 {
1305 if (bHasSep) 1305 if (bHasSep)
1306 { 1306 {
1307 » » » » FX_BOOL &bRc = pEvent->Rc(); 1307 » » » » bool &bRc = pEvent->Rc();
1308 » » » » bRc = FALSE; 1308 » » » » bRc = false;
1309 » » » » return TRUE; 1309 » » » » return true;
1310 } 1310 }
1311 else 1311 else
1312 { 1312 {
1313 » » » » bHasSep = TRUE; 1313 » » » » bHasSep = true;
1314 continue; 1314 continue;
1315 } 1315 }
1316 } 1316 }
1317 if (*it == L'-') 1317 if (*it == L'-')
1318 { 1318 {
1319 if (bHasSign) 1319 if (bHasSign)
1320 { 1320 {
1321 » » » » FX_BOOL &bRc = pEvent->Rc(); 1321 » » » » bool &bRc = pEvent->Rc();
1322 » » » » bRc = FALSE; 1322 » » » » bRc = false;
1323 » » » » return TRUE; 1323 » » » » return true;
1324 } 1324 }
1325 else if (it != w_strChange2.begin()) //sign's position i s not correct 1325 else if (it != w_strChange2.begin()) //sign's position i s not correct
1326 { 1326 {
1327 » » » » FX_BOOL &bRc = pEvent->Rc(); 1327 » » » » bool &bRc = pEvent->Rc();
1328 » » » » bRc = FALSE; 1328 » » » » bRc = false;
1329 » » » » return TRUE; 1329 » » » » return true;
1330 } 1330 }
1331 else if (pEvent->SelStart() != 0) 1331 else if (pEvent->SelStart() != 0)
1332 { 1332 {
1333 » » » » FX_BOOL &bRc = pEvent->Rc(); 1333 » » » » bool &bRc = pEvent->Rc();
1334 » » » » bRc = FALSE; 1334 » » » » bRc = false;
1335 » » » » return TRUE; 1335 » » » » return true;
1336 } 1336 }
1337 » » » bHasSign = TRUE; 1337 » » » bHasSign = true;
1338 continue; 1338 continue;
1339 } 1339 }
1340 1340
1341 if (!IsDigit(*it)) 1341 if (!IsDigit(*it))
1342 { 1342 {
1343 » » » FX_BOOL &bRc = pEvent->Rc(); 1343 » » » bool &bRc = pEvent->Rc();
1344 » » » bRc = FALSE; 1344 » » » bRc = false;
1345 » » » return TRUE; 1345 » » » return true;
1346 } 1346 }
1347 } 1347 }
1348 1348
1349 1349
1350 std::wstring w_prefix = w_strValue2.substr(0,pEvent->SelStart()); 1350 std::wstring w_prefix = w_strValue2.substr(0,pEvent->SelStart());
1351 std::wstring w_postfix; 1351 std::wstring w_postfix;
1352 if (pEvent->SelEnd()<(int)w_strValue2.length()) 1352 if (pEvent->SelEnd()<(int)w_strValue2.length())
1353 w_postfix = w_strValue2.substr(pEvent->SelEnd()); 1353 w_postfix = w_strValue2.substr(pEvent->SelEnd());
1354 w_strValue2 = w_prefix + w_strChange2 + w_postfix; 1354 w_strValue2 = w_prefix + w_strChange2 + w_postfix;
1355 w_strValue = w_strValue2.c_str(); 1355 w_strValue = w_strValue2.c_str();
1356 val = w_strValue; 1356 val = w_strValue;
1357 » return TRUE; 1357 » return true;
1358 1358
1359 } 1359 }
1360 1360
1361 //function AFPercent_Format(nDec, sepStyle) 1361 //function AFPercent_Format(nDec, sepStyle)
1362 FX_BOOL CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Paramet ers& params, CJS_Value& vRet, CFX_WideString& sError) 1362 bool CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError)
1363 { 1363 {
1364 #if _FX_OS_ != _FX_ANDROID_ 1364 #if _FX_OS_ != _FX_ANDROID_
1365 CJS_Context* pContext = (CJS_Context *)cc; 1365 CJS_Context* pContext = (CJS_Context *)cc;
1366 ASSERT(pContext != NULL); 1366 ASSERT(pContext != NULL);
1367 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1367 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1368 ASSERT(pEvent != NULL); 1368 ASSERT(pEvent != NULL);
1369 1369
1370 if (params.size() != 2) 1370 if (params.size() != 2)
1371 { 1371 {
1372 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1372 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1373 » » return FALSE; 1373 » » return false;
1374 } 1374 }
1375 if(!pEvent->m_pValue) 1375 if(!pEvent->m_pValue)
1376 » » return FALSE; 1376 » » return false;
1377 1377
1378 CFX_WideString& Value = pEvent->Value(); 1378 CFX_WideString& Value = pEvent->Value();
1379 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); 1379 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
1380 if (strValue.IsEmpty()) 1380 if (strValue.IsEmpty())
1381 » » return TRUE; 1381 » » return true;
1382 1382
1383 int iDec = params[0].ToInt(); 1383 int iDec = params[0].ToInt();
1384 if (iDec < 0) 1384 if (iDec < 0)
1385 iDec = -iDec; 1385 iDec = -iDec;
1386 1386
1387 int iSepStyle = params[1].ToInt(); 1387 int iSepStyle = params[1].ToInt();
1388 if (iSepStyle < 0 || iSepStyle > 3) 1388 if (iSepStyle < 0 || iSepStyle > 3)
1389 iSepStyle = 0; 1389 iSepStyle = 0;
1390 1390
1391 ////////////////////////////////////////////////////// 1391 //////////////////////////////////////////////////////
1392 //for processing decimal places 1392 //for processing decimal places
1393 double dValue = atof(strValue); 1393 double dValue = atof(strValue);
1394 dValue *= 100; 1394 dValue *= 100;
1395 if (iDec > 0) 1395 if (iDec > 0)
1396 dValue += DOUBLE_CORRECT;//УÕý 1396 dValue += DOUBLE_CORRECT;//УÕý
1397 1397
1398 int iDec2; 1398 int iDec2;
1399 » FX_BOOL bNegative = FALSE; 1399 » int iNegative = 0;
1400 » strValue = fcvt(dValue,iDec,&iDec2,&bNegative); 1400 » strValue = fcvt(dValue, iDec, &iDec2, &iNegative);
1401 if (strValue.IsEmpty()) 1401 if (strValue.IsEmpty())
1402 { 1402 {
1403 dValue = 0; 1403 dValue = 0;
1404 » » strValue = fcvt(dValue,iDec,&iDec2,&bNegative); 1404 » » strValue = fcvt(dValue, iDec, &iDec2, &iNegative);
1405 } 1405 }
1406 1406
1407 if (iDec2 < 0) 1407 if (iDec2 < 0)
1408 { 1408 {
1409 for (int iNum = 0; iNum < abs(iDec2); iNum++) 1409 for (int iNum = 0; iNum < abs(iDec2); iNum++)
1410 { 1410 {
1411 strValue = "0" + strValue; 1411 strValue = "0" + strValue;
1412 } 1412 }
1413 iDec2 = 0; 1413 iDec2 = 0;
1414 1414
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 iDecPositive = iDec2; 1452 iDecPositive = iDec2;
1453 1453
1454 for (iDecPositive = iDec2 -3; iDecPositive > 0; iDecPositive -= 3) 1454 for (iDecPositive = iDec2 -3; iDecPositive > 0; iDecPositive -= 3)
1455 { 1455 {
1456 strValue.Insert(iDecPositive,cSeperator); 1456 strValue.Insert(iDecPositive,cSeperator);
1457 iMax++; 1457 iMax++;
1458 } 1458 }
1459 } 1459 }
1460 //////////////////////////////////////////////////////////////////// 1460 ////////////////////////////////////////////////////////////////////
1461 //negative mark 1461 //negative mark
1462 » if(bNegative) 1462 » if (iNegative)
1463 strValue = "-" + strValue; 1463 strValue = "-" + strValue;
1464 strValue += "%"; 1464 strValue += "%";
1465 Value = CFX_WideString::FromLocal(strValue); 1465 Value = CFX_WideString::FromLocal(strValue);
1466 #endif 1466 #endif
1467 » return TRUE; 1467 » return true;
1468 } 1468 }
1469 //AFPercent_Keystroke(nDec, sepStyle) 1469 //AFPercent_Keystroke(nDec, sepStyle)
1470 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Para meters& params, CJS_Value& vRet, CFX_WideString& sError) 1470 bool CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Paramet ers& params, CJS_Value& vRet, CFX_WideString& sError)
1471 { 1471 {
1472 return AFNumber_Keystroke(cc,params,vRet,sError); 1472 return AFNumber_Keystroke(cc,params,vRet,sError);
1473 } 1473 }
1474 1474
1475 //function AFDate_FormatEx(cFormat) 1475 //function AFDate_FormatEx(cFormat)
1476 FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Paramete rs& params, CJS_Value& vRet, CFX_WideString& sError) 1476 bool CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
1477 { 1477 {
1478 CJS_Context* pContext = (CJS_Context *)cc; 1478 CJS_Context* pContext = (CJS_Context *)cc;
1479 ASSERT(pContext != NULL); 1479 ASSERT(pContext != NULL);
1480 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1480 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1481 ASSERT(pEvent != NULL); 1481 ASSERT(pEvent != NULL);
1482 1482
1483 if (params.size() != 1) 1483 if (params.size() != 1)
1484 { 1484 {
1485 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1485 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1486 » » return FALSE; 1486 » » return false;
1487 } 1487 }
1488 if(!pEvent->m_pValue) 1488 if(!pEvent->m_pValue)
1489 » » return FALSE; 1489 » » return false;
1490 1490
1491 CFX_WideString& val = pEvent->Value(); 1491 CFX_WideString& val = pEvent->Value();
1492 CFX_WideString strValue = val; 1492 CFX_WideString strValue = val;
1493 if (strValue.IsEmpty()) 1493 if (strValue.IsEmpty())
1494 » » return TRUE; 1494 » » return true;
1495 1495
1496 CFX_WideString sFormat = params[0].ToCFXWideString(); 1496 CFX_WideString sFormat = params[0].ToCFXWideString();
1497 » FX_BOOL bWrongFormat = FALSE; 1497 » bool bWrongFormat = false;
1498 double dDate = 0.0f; 1498 double dDate = 0.0f;
1499 1499
1500 if(strValue.Find(L"GMT") != -1) 1500 if(strValue.Find(L"GMT") != -1)
1501 { 1501 {
1502 //for GMT format time 1502 //for GMT format time
1503 //such as "Tue Aug 11 14:24:16 GMT+08002009" 1503 //such as "Tue Aug 11 14:24:16 GMT+08002009"
1504 dDate = MakeInterDate(strValue); 1504 dDate = MakeInterDate(strValue);
1505 } 1505 }
1506 else 1506 else
1507 { 1507 {
1508 dDate = MakeRegularDate(strValue,sFormat,bWrongFormat); 1508 dDate = MakeRegularDate(strValue,sFormat,bWrongFormat);
1509 } 1509 }
1510 1510
1511 if (JS_PortIsNan(dDate)) 1511 if (JS_PortIsNan(dDate))
1512 { 1512 {
1513 CFX_WideString swMsg; 1513 CFX_WideString swMsg;
1514 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE) .c_str(), sFormat.c_str()); 1514 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE) .c_str(), sFormat.c_str());
1515 Alert(pContext, swMsg.c_str()); 1515 Alert(pContext, swMsg.c_str());
1516 » » return FALSE; 1516 » » return false;
1517 } 1517 }
1518 1518
1519 val = MakeFormatDate(dDate,sFormat); 1519 val = MakeFormatDate(dDate,sFormat);
1520 » return TRUE; 1520 » return true;
1521 } 1521 }
1522 1522
1523 double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) 1523 double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue)
1524 { 1524 {
1525 int nHour; 1525 int nHour;
1526 int nMin; 1526 int nMin;
1527 int nSec; 1527 int nSec;
1528 int nYear; 1528 int nYear;
1529 int nMonth; 1529 int nMonth;
1530 int nDay; 1530 int nDay;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1574
1575 if (JS_PortIsNan(dRet)) 1575 if (JS_PortIsNan(dRet))
1576 { 1576 {
1577 dRet = JS_DateParse(strValue.c_str()); 1577 dRet = JS_DateParse(strValue.c_str());
1578 } 1578 }
1579 1579
1580 return dRet; 1580 return dRet;
1581 } 1581 }
1582 1582
1583 //AFDate_KeystrokeEx(cFormat) 1583 //AFDate_KeystrokeEx(cFormat)
1584 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Param eters& params, CJS_Value& vRet, CFX_WideString& sError) 1584 bool CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Paramete rs& params, CJS_Value& vRet, CFX_WideString& sError)
1585 { 1585 {
1586 CJS_Context* pContext = (CJS_Context *)cc; 1586 CJS_Context* pContext = (CJS_Context *)cc;
1587 ASSERT(pContext != NULL); 1587 ASSERT(pContext != NULL);
1588 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1588 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1589 ASSERT(pEvent != NULL); 1589 ASSERT(pEvent != NULL);
1590 1590
1591 if (params.size() != 1) 1591 if (params.size() != 1)
1592 { 1592 {
1593 sError = L"AFDate_KeystrokeEx's parameters' size r not correct"; 1593 sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
1594 » » return FALSE; 1594 » » return false;
1595 } 1595 }
1596 1596
1597 if (pEvent->WillCommit()) 1597 if (pEvent->WillCommit())
1598 { 1598 {
1599 if(!pEvent->m_pValue) 1599 if(!pEvent->m_pValue)
1600 » » » return FALSE; 1600 » » » return false;
1601 CFX_WideString strValue = pEvent->Value(); 1601 CFX_WideString strValue = pEvent->Value();
1602 if (strValue.IsEmpty()) 1602 if (strValue.IsEmpty())
1603 » » » return TRUE; 1603 » » » return true;
1604 1604
1605 CFX_WideString sFormat = params[0].ToCFXWideString(); 1605 CFX_WideString sFormat = params[0].ToCFXWideString();
1606 » » FX_BOOL bWrongFormat = FALSE; 1606 » » bool bWrongFormat = false;
1607 double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat); 1607 double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat);
1608 if (bWrongFormat || JS_PortIsNan(dRet)) 1608 if (bWrongFormat || JS_PortIsNan(dRet))
1609 { 1609 {
1610 CFX_WideString swMsg; 1610 CFX_WideString swMsg;
1611 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPA RSEDATE).c_str(), sFormat.c_str()); 1611 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPA RSEDATE).c_str(), sFormat.c_str());
1612 Alert(pContext, swMsg.c_str()); 1612 Alert(pContext, swMsg.c_str());
1613 » » » pEvent->Rc() = FALSE; 1613 » » » pEvent->Rc() = false;
1614 » » » return TRUE; 1614 » » » return true;
1615 } 1615 }
1616 } 1616 }
1617 » return TRUE; 1617 » return true;
1618 } 1618 }
1619 1619
1620 FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError) 1620 bool CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters& p arams, CJS_Value& vRet, CFX_WideString& sError)
1621 { 1621 {
1622 v8::Isolate* isolate = ::GetIsolate(cc); 1622 v8::Isolate* isolate = ::GetIsolate(cc);
1623 1623
1624 if (params.size() != 1) 1624 if (params.size() != 1)
1625 { 1625 {
1626 CJS_Context* pContext = (CJS_Context*)cc; 1626 CJS_Context* pContext = (CJS_Context*)cc;
1627 ASSERT(pContext != NULL); 1627 ASSERT(pContext != NULL);
1628 1628
1629 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1629 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1630 » » return FALSE; 1630 » » return false;
1631 } 1631 }
1632 1632
1633 int iIndex = params[0].ToInt(); 1633 int iIndex = params[0].ToInt();
1634 const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy", 1634 const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
1635 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy yy", 1635 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy yy",
1636 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; 1636 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
1637 1637
1638 ASSERT(iIndex < FX_ArraySize(cFormats)); 1638 ASSERT(iIndex < FX_ArraySize(cFormats));
1639 1639
1640 if (iIndex < 0) 1640 if (iIndex < 0)
1641 iIndex = 0; 1641 iIndex = 0;
1642 if (iIndex >= FX_ArraySize(cFormats)) 1642 if (iIndex >= FX_ArraySize(cFormats))
1643 iIndex = 0; 1643 iIndex = 0;
1644 CJS_Parameters newParams; 1644 CJS_Parameters newParams;
1645 CJS_Value val(isolate,cFormats[iIndex]); 1645 CJS_Value val(isolate,cFormats[iIndex]);
1646 newParams.push_back(val); 1646 newParams.push_back(val);
1647 return AFDate_FormatEx(cc,newParams,vRet,sError); 1647 return AFDate_FormatEx(cc,newParams,vRet,sError);
1648 } 1648 }
1649 1649
1650 //AFDate_KeystrokeEx(cFormat) 1650 //AFDate_KeystrokeEx(cFormat)
1651 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Paramet ers& params, CJS_Value& vRet, CFX_WideString& sError) 1651 bool CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError)
1652 { 1652 {
1653 v8::Isolate* isolate = ::GetIsolate(cc); 1653 v8::Isolate* isolate = ::GetIsolate(cc);
1654 1654
1655 if (params.size() != 1) 1655 if (params.size() != 1)
1656 { 1656 {
1657 CJS_Context* pContext = (CJS_Context*)cc; 1657 CJS_Context* pContext = (CJS_Context*)cc;
1658 ASSERT(pContext != NULL); 1658 ASSERT(pContext != NULL);
1659 1659
1660 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1660 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1661 » » return FALSE; 1661 » » return false;
1662 } 1662 }
1663 1663
1664 int iIndex = params[0].ToInt(); 1664 int iIndex = params[0].ToInt();
1665 const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy", 1665 const FX_WCHAR* cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-mmm", L"d-mmm-yy", L"dd-mmm-yy",
1666 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy yy", 1666 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy yy",
1667 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; 1667 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" };
1668 1668
1669 ASSERT(iIndex<FX_ArraySize(cFormats)); 1669 ASSERT(iIndex<FX_ArraySize(cFormats));
1670 1670
1671 if (iIndex < 0) 1671 if (iIndex < 0)
1672 iIndex = 0; 1672 iIndex = 0;
1673 if (iIndex >= FX_ArraySize(cFormats)) 1673 if (iIndex >= FX_ArraySize(cFormats))
1674 iIndex = 0; 1674 iIndex = 0;
1675 CJS_Parameters newParams; 1675 CJS_Parameters newParams;
1676 CJS_Value val(isolate,cFormats[iIndex]); 1676 CJS_Value val(isolate,cFormats[iIndex]);
1677 newParams.push_back(val); 1677 newParams.push_back(val);
1678 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); 1678 return AFDate_KeystrokeEx(cc,newParams,vRet,sError);
1679 } 1679 }
1680 1680
1681 //function AFTime_Format(ptf) 1681 //function AFTime_Format(ptf)
1682 FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError) 1682 bool CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters& p arams, CJS_Value& vRet, CFX_WideString& sError)
1683 { 1683 {
1684 v8::Isolate* isolate = ::GetIsolate(cc); 1684 v8::Isolate* isolate = ::GetIsolate(cc);
1685 1685
1686 if (params.size() != 1) 1686 if (params.size() != 1)
1687 { 1687 {
1688 CJS_Context* pContext = (CJS_Context*)cc; 1688 CJS_Context* pContext = (CJS_Context*)cc;
1689 ASSERT(pContext != NULL); 1689 ASSERT(pContext != NULL);
1690 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1690 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1691 » » return FALSE; 1691 » » return false;
1692 } 1692 }
1693 1693
1694 int iIndex = params[0].ToInt(); 1694 int iIndex = params[0].ToInt();
1695 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM: ss tt"}; 1695 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM: ss tt"};
1696 1696
1697 ASSERT(iIndex<FX_ArraySize(cFormats)); 1697 ASSERT(iIndex<FX_ArraySize(cFormats));
1698 1698
1699 if (iIndex < 0) 1699 if (iIndex < 0)
1700 iIndex = 0; 1700 iIndex = 0;
1701 if (iIndex >= FX_ArraySize(cFormats)) 1701 if (iIndex >= FX_ArraySize(cFormats))
1702 iIndex = 0; 1702 iIndex = 0;
1703 CJS_Parameters newParams; 1703 CJS_Parameters newParams;
1704 CJS_Value val(isolate,cFormats[iIndex]); 1704 CJS_Value val(isolate,cFormats[iIndex]);
1705 newParams.push_back(val); 1705 newParams.push_back(val);
1706 return AFDate_FormatEx(cc,newParams,vRet,sError); 1706 return AFDate_FormatEx(cc,newParams,vRet,sError);
1707 } 1707 }
1708 1708
1709 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Paramet ers& params, CJS_Value& vRet, CFX_WideString& sError) 1709 bool CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError)
1710 { 1710 {
1711 v8::Isolate* isolate = ::GetIsolate(cc); 1711 v8::Isolate* isolate = ::GetIsolate(cc);
1712 if (params.size() != 1) 1712 if (params.size() != 1)
1713 { 1713 {
1714 CJS_Context* pContext = (CJS_Context*)cc; 1714 CJS_Context* pContext = (CJS_Context*)cc;
1715 ASSERT(pContext != NULL); 1715 ASSERT(pContext != NULL);
1716 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1716 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1717 » » return FALSE; 1717 » » return false;
1718 } 1718 }
1719 1719
1720 int iIndex = params[0].ToInt(); 1720 int iIndex = params[0].ToInt();
1721 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM: ss tt"}; 1721 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM: ss tt"};
1722 1722
1723 ASSERT(iIndex<FX_ArraySize(cFormats)); 1723 ASSERT(iIndex<FX_ArraySize(cFormats));
1724 1724
1725 if (iIndex < 0) 1725 if (iIndex < 0)
1726 iIndex = 0; 1726 iIndex = 0;
1727 if (iIndex >= FX_ArraySize(cFormats)) 1727 if (iIndex >= FX_ArraySize(cFormats))
1728 iIndex = 0; 1728 iIndex = 0;
1729 CJS_Parameters newParams; 1729 CJS_Parameters newParams;
1730 CJS_Value val(isolate,cFormats[iIndex]); 1730 CJS_Value val(isolate,cFormats[iIndex]);
1731 newParams.push_back(val); 1731 newParams.push_back(val);
1732 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); 1732 return AFDate_KeystrokeEx(cc,newParams,vRet,sError);
1733 } 1733 }
1734 1734
1735 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IFXJS_Context* cc, const CJS_Paramete rs& params, CJS_Value& vRet, CFX_WideString& sError) 1735 bool CJS_PublicMethods::AFTime_FormatEx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
1736 { 1736 {
1737 return AFDate_FormatEx(cc,params,vRet,sError); 1737 return AFDate_FormatEx(cc,params,vRet,sError);
1738 } 1738 }
1739 1739
1740 FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(IFXJS_Context* cc, const CJS_Param eters& params, CJS_Value& vRet, CFX_WideString& sError) 1740 bool CJS_PublicMethods::AFTime_KeystrokeEx(IFXJS_Context* cc, const CJS_Paramete rs& params, CJS_Value& vRet, CFX_WideString& sError)
1741 { 1741 {
1742 return AFDate_KeystrokeEx(cc,params,vRet,sError); 1742 return AFDate_KeystrokeEx(cc,params,vRet,sError);
1743 } 1743 }
1744 1744
1745 //function AFSpecial_Format(psf) 1745 //function AFSpecial_Format(psf)
1746 FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Paramet ers& params, CJS_Value& vRet, CFX_WideString& sError) 1746 bool CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError)
1747 { 1747 {
1748 CJS_Context* pContext = (CJS_Context *)cc; 1748 CJS_Context* pContext = (CJS_Context *)cc;
1749 ASSERT(pContext != NULL); 1749 ASSERT(pContext != NULL);
1750 1750
1751 if (params.size() != 1) 1751 if (params.size() != 1)
1752 { 1752 {
1753 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1753 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1754 » » return FALSE; 1754 » » return false;
1755 } 1755 }
1756 1756
1757 std::string cFormat; 1757 std::string cFormat;
1758 int iIndex = params[0].ToInt(); 1758 int iIndex = params[0].ToInt();
1759 1759
1760 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1760 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1761 ASSERT(pEvent != NULL); 1761 ASSERT(pEvent != NULL);
1762 1762
1763 if(!pEvent->m_pValue) 1763 if(!pEvent->m_pValue)
1764 » » return FALSE; 1764 » » return false;
1765 CFX_WideString& Value = pEvent->Value(); 1765 CFX_WideString& Value = pEvent->Value();
1766 std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str(); 1766 std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str();
1767 1767
1768 switch (iIndex) 1768 switch (iIndex)
1769 { 1769 {
1770 case 0: 1770 case 0:
1771 cFormat = "99999"; 1771 cFormat = "99999";
1772 break; 1772 break;
1773 case 1: 1773 case 1:
1774 cFormat = "99999-9999"; 1774 cFormat = "99999-9999";
1775 break; 1775 break;
1776 case 2: 1776 case 2:
1777 { 1777 {
1778 std::string NumberStr; 1778 std::string NumberStr;
1779 util::printx("9999999999", strSrc,NumberStr); 1779 util::printx("9999999999", strSrc,NumberStr);
1780 if (NumberStr.length() >= 10 ) 1780 if (NumberStr.length() >= 10 )
1781 cFormat = "(999) 999-9999"; 1781 cFormat = "(999) 999-9999";
1782 else 1782 else
1783 cFormat = "999-9999"; 1783 cFormat = "999-9999";
1784 break; 1784 break;
1785 } 1785 }
1786 case 3: 1786 case 3:
1787 cFormat = "999-99-9999"; 1787 cFormat = "999-99-9999";
1788 break; 1788 break;
1789 } 1789 }
1790 1790
1791 std::string strDes; 1791 std::string strDes;
1792 util::printx(cFormat,strSrc,strDes); 1792 util::printx(cFormat,strSrc,strDes);
1793 Value = CFX_WideString::FromLocal(strDes.c_str()); 1793 Value = CFX_WideString::FromLocal(strDes.c_str());
1794 » return TRUE; 1794 » return true;
1795 } 1795 }
1796 1796
1797 1797
1798 //function AFSpecial_KeystrokeEx(mask) 1798 //function AFSpecial_KeystrokeEx(mask)
1799 FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Pa rameters& params, CJS_Value& vRet, CFX_WideString& sError) 1799 bool CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, const CJS_Param eters& params, CJS_Value& vRet, CFX_WideString& sError)
1800 { 1800 {
1801 CJS_Context* pContext = (CJS_Context *)cc; 1801 CJS_Context* pContext = (CJS_Context *)cc;
1802 ASSERT(pContext != NULL); 1802 ASSERT(pContext != NULL);
1803 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1803 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1804 1804
1805 ASSERT(pEvent != NULL); 1805 ASSERT(pEvent != NULL);
1806 1806
1807 if (params.size() < 1) 1807 if (params.size() < 1)
1808 { 1808 {
1809 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1809 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1810 » » return FALSE; 1810 » » return false;
1811 } 1811 }
1812 1812
1813 if(!pEvent->m_pValue) 1813 if(!pEvent->m_pValue)
1814 » » return FALSE; 1814 » » return false;
1815 CFX_WideString& valEvent = pEvent->Value(); 1815 CFX_WideString& valEvent = pEvent->Value();
1816 1816
1817 CFX_WideString wstrMask = params[0].ToCFXWideString(); 1817 CFX_WideString wstrMask = params[0].ToCFXWideString();
1818 if (wstrMask.IsEmpty()) 1818 if (wstrMask.IsEmpty())
1819 » » return TRUE; 1819 » » return true;
1820 1820
1821 std::wstring wstrValue = valEvent.c_str(); 1821 std::wstring wstrValue = valEvent.c_str();
1822 1822
1823 if (pEvent->WillCommit()) 1823 if (pEvent->WillCommit())
1824 { 1824 {
1825 if (wstrValue.empty()) 1825 if (wstrValue.empty())
1826 » » » return TRUE; 1826 » » » return true;
1827 int iIndexMask = 0; 1827 int iIndexMask = 0;
1828 for (std::wstring::iterator it = wstrValue.begin(); it != wstrVa lue.end(); it++) 1828 for (std::wstring::iterator it = wstrValue.begin(); it != wstrVa lue.end(); it++)
1829 { 1829 {
1830 wchar_t w_Value = *it; 1830 wchar_t w_Value = *it;
1831 if (!maskSatisfied(w_Value,wstrMask[iIndexMask])) 1831 if (!maskSatisfied(w_Value,wstrMask[iIndexMask]))
1832 break; 1832 break;
1833 iIndexMask++; 1833 iIndexMask++;
1834 } 1834 }
1835 1835
1836 if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrVal ue.size() && wstrMask.GetLength() != 0)) 1836 if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrVal ue.size() && wstrMask.GetLength() != 0))
1837 { 1837 {
1838 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J SAFNUMBER_KEYSTROKE).c_str()); 1838 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J SAFNUMBER_KEYSTROKE).c_str());
1839 » » » pEvent->Rc() = FALSE; 1839 » » » pEvent->Rc() = false;
1840 } 1840 }
1841 » » return TRUE; 1841 » » return true;
1842 } 1842 }
1843 1843
1844 CFX_WideString &wideChange = pEvent->Change(); 1844 CFX_WideString &wideChange = pEvent->Change();
1845 std::wstring wChange = wideChange.c_str(); 1845 std::wstring wChange = wideChange.c_str();
1846 if (wChange.empty()) 1846 if (wChange.empty())
1847 » » return TRUE; 1847 » » return true;
1848 1848
1849 int iIndexMask = pEvent->SelStart(); 1849 int iIndexMask = pEvent->SelStart();
1850 1850
1851 if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange .length() > (FX_DWORD)wstrMask.GetLength()) 1851 if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange .length() > (FX_DWORD)wstrMask.GetLength())
1852 { 1852 {
1853 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T OOLONG).c_str()); 1853 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T OOLONG).c_str());
1854 » » pEvent->Rc() = FALSE; 1854 » » pEvent->Rc() = false;
1855 » » return TRUE; 1855 » » return true;
1856 } 1856 }
1857 1857
1858 if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty())) 1858 if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty()))
1859 { 1859 {
1860 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T OOLONG).c_str()); 1860 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T OOLONG).c_str());
1861 » » pEvent->Rc() = FALSE; 1861 » » pEvent->Rc() = false;
1862 » » return TRUE; 1862 » » return true;
1863 } 1863 }
1864 1864
1865 for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); i t++) 1865 for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); i t++)
1866 { 1866 {
1867 if (iIndexMask >= wstrMask.GetLength()) 1867 if (iIndexMask >= wstrMask.GetLength())
1868 { 1868 {
1869 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J SPARAM_TOOLONG).c_str()); 1869 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J SPARAM_TOOLONG).c_str());
1870 » » » pEvent->Rc() = FALSE; 1870 » » » pEvent->Rc() = false;
1871 » » » return TRUE; 1871 » » » return true;
1872 } 1872 }
1873 wchar_t w_Mask = wstrMask[iIndexMask]; 1873 wchar_t w_Mask = wstrMask[iIndexMask];
1874 if (!isReservedMaskChar(w_Mask)) 1874 if (!isReservedMaskChar(w_Mask))
1875 { 1875 {
1876 *it = w_Mask; 1876 *it = w_Mask;
1877 } 1877 }
1878 wchar_t w_Change = *it; 1878 wchar_t w_Change = *it;
1879 if (!maskSatisfied(w_Change,w_Mask)) 1879 if (!maskSatisfied(w_Change,w_Mask))
1880 { 1880 {
1881 » » » pEvent->Rc() = FALSE; 1881 » » » pEvent->Rc() = false;
1882 » » » return TRUE; 1882 » » » return true;
1883 } 1883 }
1884 iIndexMask++; 1884 iIndexMask++;
1885 } 1885 }
1886 1886
1887 wideChange = wChange.c_str(); 1887 wideChange = wChange.c_str();
1888 » return TRUE; 1888 » return true;
1889 } 1889 }
1890 1890
1891 1891
1892 //function AFSpecial_Keystroke(psf) 1892 //function AFSpecial_Keystroke(psf)
1893 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Para meters& params, CJS_Value& vRet, CFX_WideString& sError) 1893 bool CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Paramet ers& params, CJS_Value& vRet, CFX_WideString& sError)
1894 { 1894 {
1895 v8::Isolate* isolate = ::GetIsolate(cc); 1895 v8::Isolate* isolate = ::GetIsolate(cc);
1896 1896
1897 CJS_Context* pContext = (CJS_Context *)cc; 1897 CJS_Context* pContext = (CJS_Context *)cc;
1898 ASSERT(pContext != NULL); 1898 ASSERT(pContext != NULL);
1899 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1899 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1900 ASSERT(pEvent != NULL); 1900 ASSERT(pEvent != NULL);
1901 1901
1902 if (params.size() != 1) 1902 if (params.size() != 1)
1903 { 1903 {
1904 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1904 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1905 » » return FALSE; 1905 » » return false;
1906 } 1906 }
1907 1907
1908 std::string cFormat; 1908 std::string cFormat;
1909 int iIndex = params[0].ToInt(); 1909 int iIndex = params[0].ToInt();
1910 1910
1911 if(!pEvent->m_pValue) 1911 if(!pEvent->m_pValue)
1912 » » return FALSE; 1912 » » return false;
1913 //CJS_Value val = pEvent->Value(); 1913 //CJS_Value val = pEvent->Value();
1914 CFX_WideString& val = pEvent->Value(); 1914 CFX_WideString& val = pEvent->Value();
1915 std::string strSrc = CFX_ByteString::FromUnicode(val).c_str(); 1915 std::string strSrc = CFX_ByteString::FromUnicode(val).c_str();
1916 std::wstring wstrChange = pEvent->Change().c_str(); 1916 std::wstring wstrChange = pEvent->Change().c_str();
1917 1917
1918 switch (iIndex) 1918 switch (iIndex)
1919 { 1919 {
1920 case 0: 1920 case 0:
1921 cFormat = "99999"; 1921 cFormat = "99999";
1922 break; 1922 break;
(...skipping 19 matching lines...) Expand all
1942 break; 1942 break;
1943 } 1943 }
1944 1944
1945 CJS_Parameters params2; 1945 CJS_Parameters params2;
1946 CJS_Value vMask(isolate, cFormat.c_str()); 1946 CJS_Value vMask(isolate, cFormat.c_str());
1947 params2.push_back(vMask); 1947 params2.push_back(vMask);
1948 1948
1949 return AFSpecial_KeystrokeEx(cc,params2,vRet,sError); 1949 return AFSpecial_KeystrokeEx(cc,params2,vRet,sError);
1950 } 1950 }
1951 1951
1952 FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError) 1952 bool CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, const CJS_Parameters& p arams, CJS_Value& vRet, CFX_WideString& sError)
1953 { 1953 {
1954 CJS_Context* pContext = (CJS_Context *)cc; 1954 CJS_Context* pContext = (CJS_Context *)cc;
1955 ASSERT(pContext != NULL); 1955 ASSERT(pContext != NULL);
1956 CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); 1956 CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
1957 ASSERT(pEventHandler != NULL); 1957 ASSERT(pEventHandler != NULL);
1958 1958
1959 if (params.size() != 1) 1959 if (params.size() != 1)
1960 { 1960 {
1961 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1961 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1962 » » return FALSE; 1962 » » return false;
1963 } 1963 }
1964 1964
1965 CFX_WideString swValue; 1965 CFX_WideString swValue;
1966 if (pEventHandler->m_pValue != NULL) 1966 if (pEventHandler->m_pValue != NULL)
1967 swValue = pEventHandler->Value(); 1967 swValue = pEventHandler->Value();
1968 1968
1969 if (pEventHandler->WillCommit()) 1969 if (pEventHandler->WillCommit())
1970 { 1970 {
1971 vRet = swValue.c_str(); 1971 vRet = swValue.c_str();
1972 » » return TRUE; 1972 » » return true;
1973 } 1973 }
1974 1974
1975 CFX_WideString prefix,postfix; 1975 CFX_WideString prefix,postfix;
1976 1976
1977 if (pEventHandler->SelStart() >= 0) 1977 if (pEventHandler->SelStart() >= 0)
1978 prefix = swValue.Mid(0,pEventHandler->SelStart()); 1978 prefix = swValue.Mid(0,pEventHandler->SelStart());
1979 else 1979 else
1980 prefix = L""; 1980 prefix = L"";
1981 1981
1982 1982
1983 if (pEventHandler->SelEnd() >= 0 && pEventHandler->SelEnd() <= swValue.G etLength()) 1983 if (pEventHandler->SelEnd() >= 0 && pEventHandler->SelEnd() <= swValue.G etLength())
1984 postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength () - pEventHandler->SelEnd()); 1984 postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength () - pEventHandler->SelEnd());
1985 else postfix = L""; 1985 else postfix = L"";
1986 1986
1987 vRet = (prefix + pEventHandler->Change() + postfix).c_str(); 1987 vRet = (prefix + pEventHandler->Change() + postfix).c_str();
1988 1988
1989 » return TRUE; 1989 » return true;
1990 } 1990 }
1991 1991
1992 FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError) 1992 bool CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters& p arams, CJS_Value& vRet, CFX_WideString& sError)
1993 { 1993 {
1994 CJS_Context* pContext = (CJS_Context *)cc; 1994 CJS_Context* pContext = (CJS_Context *)cc;
1995 ASSERT(pContext != NULL); 1995 ASSERT(pContext != NULL);
1996 1996
1997 if (params.size() != 2) 1997 if (params.size() != 2)
1998 { 1998 {
1999 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1999 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2000 » » return FALSE; 2000 » » return false;
2001 } 2001 }
2002 2002
2003 CFX_WideString sValue = params[0].ToCFXWideString(); 2003 CFX_WideString sValue = params[0].ToCFXWideString();
2004 CFX_WideString sFormat = params[1].ToCFXWideString(); 2004 CFX_WideString sFormat = params[1].ToCFXWideString();
2005 2005
2006 » FX_BOOL bWrongFormat = FALSE; 2006 » bool bWrongFormat = false;
2007 double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat); 2007 double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat);
2008 2008
2009 if (JS_PortIsNan(dDate)) 2009 if (JS_PortIsNan(dDate))
2010 { 2010 {
2011 CFX_WideString swMsg; 2011 CFX_WideString swMsg;
2012 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE) .c_str(), sFormat.c_str()); 2012 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE) .c_str(), sFormat.c_str());
2013 Alert((CJS_Context *)cc, swMsg.c_str()); 2013 Alert((CJS_Context *)cc, swMsg.c_str());
2014 » » return FALSE; 2014 » » return false;
2015 } 2015 }
2016 2016
2017 vRet = dDate; 2017 vRet = dDate;
2018 » return TRUE; 2018 » return true;
2019 } 2019 }
2020 2020
2021 FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par ams, CJS_Value& vRet, CFX_WideString& sError) 2021 bool CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& params , CJS_Value& vRet, CFX_WideString& sError)
2022 { 2022 {
2023 if (params.size() != 3) 2023 if (params.size() != 3)
2024 { 2024 {
2025 CJS_Context* pContext = (CJS_Context *)cc; 2025 CJS_Context* pContext = (CJS_Context *)cc;
2026 ASSERT(pContext != NULL); 2026 ASSERT(pContext != NULL);
2027 2027
2028 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2028 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2029 » » return FALSE; 2029 » » return false;
2030 } 2030 }
2031 2031
2032 vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1]. ToDouble(), params[2].ToDouble()); 2032 vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1]. ToDouble(), params[2].ToDouble());
2033 » return TRUE; 2033 » return true;
2034 } 2034 }
2035 2035
2036 FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) 2036 bool CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters& pa rams, CJS_Value& vRet, CFX_WideString& sError)
2037 { 2037 {
2038 if (params.size() != 1) 2038 if (params.size() != 1)
2039 { 2039 {
2040 CJS_Context* pContext = (CJS_Context *)cc; 2040 CJS_Context* pContext = (CJS_Context *)cc;
2041 ASSERT(pContext != NULL); 2041 ASSERT(pContext != NULL);
2042 2042
2043 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2043 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2044 » » return FALSE; 2044 » » return false;
2045 } 2045 }
2046 vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str()); 2046 vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str());
2047 » return TRUE; 2047 » return true;
2048 } 2048 }
2049 2049
2050 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param eters& params, CJS_Value& vRet, CFX_WideString& sError) 2050 bool CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Paramete rs& params, CJS_Value& vRet, CFX_WideString& sError)
2051 { 2051 {
2052 v8::Isolate* isolate = ::GetIsolate(cc); 2052 v8::Isolate* isolate = ::GetIsolate(cc);
2053 2053
2054 CJS_Context* pContext = (CJS_Context *)cc; 2054 CJS_Context* pContext = (CJS_Context *)cc;
2055 ASSERT(pContext != NULL); 2055 ASSERT(pContext != NULL);
2056 2056
2057 if (params.size() != 2) 2057 if (params.size() != 2)
2058 { 2058 {
2059 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2059 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2060 » » return FALSE; 2060 » » return false;
2061 } 2061 }
2062 2062
2063 CJS_Value params1 = params[1]; 2063 CJS_Value params1 = params[1];
2064 2064
2065 if (!params1.IsArrayObject() && params1.GetType() != VT_string) 2065 if (!params1.IsArrayObject() && params1.GetType() != VT_string)
2066 { 2066 {
2067 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2067 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2068 » » return FALSE; 2068 » » return false;
2069 } 2069 }
2070 2070
2071 CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument(); 2071 CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument();
2072 ASSERT(pReaderDoc != NULL); 2072 ASSERT(pReaderDoc != NULL);
2073 2073
2074 CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm(); 2074 CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm();
2075 ASSERT(pReaderInterForm != NULL); 2075 ASSERT(pReaderInterForm != NULL);
2076 2076
2077 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); 2077 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
2078 ASSERT(pInterForm != NULL); 2078 ASSERT(pInterForm != NULL);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2158 } 2158 }
2159 2159
2160 if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0) 2160 if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0)
2161 dValue /= nFieldsCount; 2161 dValue /= nFieldsCount;
2162 2162
2163 dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49) / FXSYS_pow((double)10,(double)6); 2163 dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49) / FXSYS_pow((double)10,(double)6);
2164 CJS_Value jsValue(isolate,dValue); 2164 CJS_Value jsValue(isolate,dValue);
2165 if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue) 2165 if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue)
2166 ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsVa lue.ToCFXWideString(); 2166 ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsVa lue.ToCFXWideString();
2167 2167
2168 » return TRUE; 2168 » return true;
2169 } 2169 }
2170 2170
2171 /* This function validates the current event to ensure that its value is 2171 /* This function validates the current event to ensure that its value is
2172 ** within the specified range. */ 2172 ** within the specified range. */
2173 2173
2174 FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Paramet ers& params, CJS_Value& vRet, CFX_WideString& sError) 2174 bool CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError)
2175 { 2175 {
2176 CJS_Context* pContext = (CJS_Context *)cc; 2176 CJS_Context* pContext = (CJS_Context *)cc;
2177 ASSERT(pContext != NULL); 2177 ASSERT(pContext != NULL);
2178 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 2178 CJS_EventHandler* pEvent = pContext->GetEventHandler();
2179 ASSERT(pEvent != NULL); 2179 ASSERT(pEvent != NULL);
2180 2180
2181 if (params.size() != 4) 2181 if (params.size() != 4)
2182 { 2182 {
2183 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2183 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2184 » » return FALSE; 2184 » » return false;
2185 } 2185 }
2186 2186
2187 if(!pEvent->m_pValue) 2187 if(!pEvent->m_pValue)
2188 » » return FALSE; 2188 » » return false;
2189 if (pEvent->Value().IsEmpty() ) 2189 if (pEvent->Value().IsEmpty() )
2190 » » return TRUE; 2190 » » return true;
2191 double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value())); 2191 double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value()));
2192 » FX_BOOL bGreaterThan = params[0].ToBool(); 2192 » bool bGreaterThan = params[0].ToBool();
2193 double dGreaterThan = params[1].ToDouble(); 2193 double dGreaterThan = params[1].ToDouble();
2194 » FX_BOOL bLessThan = params[2].ToBool(); 2194 » bool bLessThan = params[2].ToBool();
2195 double dLessThan = params[3].ToDouble(); 2195 double dLessThan = params[3].ToDouble();
2196 CFX_WideString swMsg; 2196 CFX_WideString swMsg;
2197 2197
2198 if (bGreaterThan && bLessThan) 2198 if (bGreaterThan && bLessThan)
2199 { 2199 {
2200 if (dEentValue < dGreaterThan || dEentValue > dLessThan) 2200 if (dEentValue < dGreaterThan || dEentValue > dLessThan)
2201 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA NGE1).c_str(), 2201 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA NGE1).c_str(),
2202 params[1].ToCFXWideString().c_s tr(), 2202 params[1].ToCFXWideString().c_s tr(),
2203 params[3].ToCFXWideString().c_s tr()); 2203 params[3].ToCFXWideString().c_s tr());
2204 } 2204 }
2205 else if (bGreaterThan) 2205 else if (bGreaterThan)
2206 { 2206 {
2207 if (dEentValue < dGreaterThan) 2207 if (dEentValue < dGreaterThan)
2208 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA NGE2).c_str(), 2208 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA NGE2).c_str(),
2209 params[1].ToCFXWideString().c_s tr()); 2209 params[1].ToCFXWideString().c_s tr());
2210 } 2210 }
2211 else if (bLessThan) 2211 else if (bLessThan)
2212 { 2212 {
2213 if (dEentValue > dLessThan) 2213 if (dEentValue > dLessThan)
2214 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA NGE3).c_str(), 2214 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA NGE3).c_str(),
2215 params[3].ToCFXWideString().c_s tr()); 2215 params[3].ToCFXWideString().c_s tr());
2216 } 2216 }
2217 2217
2218 if (!swMsg.IsEmpty()) 2218 if (!swMsg.IsEmpty())
2219 { 2219 {
2220 Alert(pContext, swMsg.c_str()); 2220 Alert(pContext, swMsg.c_str());
2221 » » pEvent->Rc() = FALSE; 2221 » » pEvent->Rc() = false;
2222 } 2222 }
2223 » return TRUE; 2223 » return true;
2224 } 2224 }
2225 2225
2226 FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters & params, CJS_Value& vRet, CFX_WideString& sError) 2226 bool CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters& p arams, CJS_Value& vRet, CFX_WideString& sError)
2227 { 2227 {
2228 v8::Isolate* isolate = ::GetIsolate(cc); 2228 v8::Isolate* isolate = ::GetIsolate(cc);
2229 CJS_Context* pContext = (CJS_Context*)cc; 2229 CJS_Context* pContext = (CJS_Context*)cc;
2230 ASSERT(pContext != NULL); 2230 ASSERT(pContext != NULL);
2231 2231
2232 if (params.size() != 1) 2232 if (params.size() != 1)
2233 { 2233 {
2234 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2234 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2235 » » return FALSE; 2235 » » return false;
2236 } 2236 }
2237 2237
2238 CJS_Array nums(isolate); 2238 CJS_Array nums(isolate);
2239 2239
2240 CFX_WideString str = params[0].ToCFXWideString(); 2240 CFX_WideString str = params[0].ToCFXWideString();
2241 CFX_WideString sPart; 2241 CFX_WideString sPart;
2242 2242
2243 if (str.GetAt(0) == L'.' || str.GetAt(0) == L',') 2243 if (str.GetAt(0) == L'.' || str.GetAt(0) == L',')
2244 str = L"0" + str; 2244 str = L"0" + str;
2245 2245
(...skipping 19 matching lines...) Expand all
2265 if (sPart.GetLength() > 0) 2265 if (sPart.GetLength() > 0)
2266 { 2266 {
2267 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); 2267 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str()));
2268 } 2268 }
2269 2269
2270 if (nums.GetLength() > 0) 2270 if (nums.GetLength() > 0)
2271 vRet = nums; 2271 vRet = nums;
2272 else 2272 else
2273 vRet.SetNull(); 2273 vRet.SetNull();
2274 2274
2275 » return TRUE; 2275 » return true;
2276 } 2276 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_Value.cpp ('k') | fpdfsdk/src/javascript/app.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698