OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 formcalc_fm2js_functions, // methods | 351 formcalc_fm2js_functions, // methods |
352 0, // number of properties | 352 0, // number of properties |
353 FX_ArraySize(formcalc_fm2js_functions), // number of methods | 353 FX_ArraySize(formcalc_fm2js_functions), // number of methods |
354 nullptr, // dynamic prop type | 354 nullptr, // dynamic prop type |
355 nullptr, // dynamic prop getter | 355 nullptr, // dynamic prop getter |
356 nullptr, // dynamic prop setter | 356 nullptr, // dynamic prop setter |
357 nullptr, // dynamic prop deleter | 357 nullptr, // dynamic prop deleter |
358 nullptr, // dynamic prop method call | 358 nullptr, // dynamic prop method call |
359 }; | 359 }; |
360 | 360 |
361 const uint8_t g_sAltTable_Date[] = { | 361 const uint8_t g_sAltTable_Date[] = { |
Lei Zhang
2016/06/01 18:01:35
Maybe static_assert(FX_ArraySize(g_sAltTable_Date)
Oliver Chang
2016/06/01 19:09:51
Done.
| |
362 255, 255, 255, 3, 9, 255, 255, 255, 255, 255, 255, 255, 2, | 362 255, 255, 255, 3, 9, 255, 255, 255, 255, 255, 255, |
363 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1, 255, | 363 255, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
364 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | 364 255, 255, 1, 255, 255, 255, 255, 255, 255, 255, 255, |
365 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | |
366 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | |
367 }; | 365 }; |
368 | 366 |
369 const uint8_t g_sAltTable_Time[] = { | 367 const uint8_t g_sAltTable_Time[] = { |
370 14, 255, 255, 3, 9, 255, 255, 15, 255, 255, 255, 255, 6, | 368 14, 255, 255, 3, 9, 255, 255, 15, 255, 255, 255, |
371 255, 255, 255, 255, 255, 7, 255, 255, 255, 255, 255, 1, 17, | 369 255, 6, 255, 255, 255, 255, 255, 7, 255, 255, 255, |
372 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | 370 255, 255, 1, 17, 255, 255, 255, 255, 255, 255, 255, |
373 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | |
374 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | |
375 }; | 371 }; |
376 | 372 |
377 void AlternateDateTimeSymbols(CFX_WideString& wsPattern, | 373 void AlternateDateTimeSymbols(CFX_WideString& wsPattern, |
378 const CFX_WideString& wsAltSymbols, | 374 const CFX_WideString& wsAltSymbols, |
379 const uint8_t* pAltTable) { | 375 const uint8_t* pAltTable) { |
380 int32_t nLength = wsPattern.GetLength(); | 376 int32_t nLength = wsPattern.GetLength(); |
381 FX_BOOL bInConstRange = FALSE; | 377 FX_BOOL bInConstRange = FALSE; |
382 FX_BOOL bEscape = FALSE; | 378 FX_BOOL bEscape = FALSE; |
383 int32_t i = 0, n = 0; | 379 int32_t i = 0; |
384 while (i < nLength) { | 380 while (i < nLength) { |
385 FX_WCHAR wc = wsPattern[i]; | 381 FX_WCHAR wc = wsPattern[i]; |
386 if (wc == L'\'') { | 382 if (wc == L'\'') { |
387 bInConstRange = !bInConstRange; | 383 bInConstRange = !bInConstRange; |
388 if (bEscape) { | 384 if (bEscape) { |
389 i++; | 385 i++; |
390 } else { | 386 } else { |
391 wsPattern.Delete(i); | 387 wsPattern.Delete(i); |
392 nLength--; | 388 nLength--; |
393 } | 389 } |
394 bEscape = !bEscape; | 390 bEscape = !bEscape; |
395 continue; | 391 continue; |
396 } | 392 } |
397 if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { | 393 if (!bInConstRange && wc >= L'A' && wc <= L'a') { |
398 int32_t nAlt = (int32_t)pAltTable[n]; | 394 uint8_t nAlt = pAltTable[wc - L'A']; |
399 if (nAlt != 255) | 395 if (nAlt != 255) |
400 wsPattern.SetAt(i, wsAltSymbols[nAlt]); | 396 wsPattern.SetAt(i, wsAltSymbols[nAlt]); |
401 } | 397 } |
402 i++; | 398 i++; |
403 bEscape = FALSE; | 399 bEscape = FALSE; |
404 } | 400 } |
405 } | 401 } |
406 | 402 |
407 bool PatternStringType(const CFX_ByteStringC& szPattern, | 403 bool PatternStringType(const CFX_ByteStringC& szPattern, |
408 uint32_t& patternType) { | 404 uint32_t& patternType) { |
(...skipping 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4221 strEncode[2] = strCode[ch - iIndex * 16]; | 4217 strEncode[2] = strCode[ch - iIndex * 16]; |
4222 wsResultBuf << FX_WSTRC(strEncode); | 4218 wsResultBuf << FX_WSTRC(strEncode); |
4223 } else if (ch <= 0x1f || ch == 0x7f) { | 4219 } else if (ch <= 0x1f || ch == 0x7f) { |
4224 int32_t iIndex = ch / 16; | 4220 int32_t iIndex = ch / 16; |
4225 strEncode[1] = strCode[iIndex]; | 4221 strEncode[1] = strCode[iIndex]; |
4226 strEncode[2] = strCode[ch - iIndex * 16]; | 4222 strEncode[2] = strCode[ch - iIndex * 16]; |
4227 wsResultBuf << FX_WSTRC(strEncode); | 4223 wsResultBuf << FX_WSTRC(strEncode); |
4228 } else if (ch >= 0x20 && ch <= 0x7e) { | 4224 } else if (ch >= 0x20 && ch <= 0x7e) { |
4229 wsResultBuf.AppendChar(ch); | 4225 wsResultBuf.AppendChar(ch); |
4230 } else { | 4226 } else { |
4231 int32_t iRadix = 16; | 4227 const FX_WCHAR iRadix = 16; |
4232 CFX_WideString strTmp; | 4228 CFX_WideString strTmp; |
4233 while (ch >= iRadix) { | 4229 while (ch >= iRadix) { |
4234 FX_WCHAR tmp = strCode[ch % iRadix]; | 4230 FX_WCHAR tmp = strCode[ch % iRadix]; |
4235 ch /= iRadix; | 4231 ch /= iRadix; |
4236 strTmp += tmp; | 4232 strTmp += tmp; |
4237 } | 4233 } |
4238 strTmp += strCode[ch]; | 4234 strTmp += strCode[ch]; |
4239 int32_t iLen = strTmp.GetLength(); | 4235 int32_t iLen = strTmp.GetLength(); |
4240 if (iLen < 2) { | 4236 if (iLen < 2) { |
4241 break; | 4237 break; |
(...skipping 2903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7145 CFX_WideString wsFormat; | 7141 CFX_WideString wsFormat; |
7146 pAppProvider->LoadString(iStringID, wsFormat); | 7142 pAppProvider->LoadString(iStringID, wsFormat); |
7147 CFX_WideString wsMessage; | 7143 CFX_WideString wsMessage; |
7148 va_list arg_ptr; | 7144 va_list arg_ptr; |
7149 va_start(arg_ptr, iStringID); | 7145 va_start(arg_ptr, iStringID); |
7150 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7146 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
7151 va_end(arg_ptr); | 7147 va_end(arg_ptr); |
7152 FXJSE_ThrowMessage( | 7148 FXJSE_ThrowMessage( |
7153 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7149 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
7154 } | 7150 } |
OLD | NEW |