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 "../../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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 { | 130 { |
131 continue; | 131 continue; |
132 } | 132 } |
133 else break; | 133 else break; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 return -1; | 137 return -1; |
138 } | 138 } |
139 | 139 |
140 FX_BOOL util::printf(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, JS_ErrorString& sError) | 140 FX_BOOL util::printf(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, CFX_WideString& sError) |
141 { | 141 { |
142 int iSize = params.size(); | 142 int iSize = params.size(); |
143 if (iSize < 1) | 143 if (iSize < 1) |
144 return FALSE; | 144 return FALSE; |
145 std::wstring c_ConvChar((const wchar_t*)(FX_LPCWSTR)params[0].operator
CFX_WideString()); | 145 std::wstring c_ConvChar((const wchar_t*)(FX_LPCWSTR)params[0].operator
CFX_WideString()); |
146 std::vector<std::wstring> c_strConvers; | 146 std::vector<std::wstring> c_strConvers; |
147 int iOffset = 0; | 147 int iOffset = 0; |
148 int iOffend = 0; | 148 int iOffend = 0; |
149 c_ConvChar.insert(c_ConvChar.begin(),L'S'); | 149 c_ConvChar.insert(c_ConvChar.begin(),L'S'); |
150 while(iOffset != -1) | 150 while(iOffset != -1) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 break; | 195 break; |
196 } | 196 } |
197 c_strResult += strSegment.GetBuffer(strSegment.GetLength()+1); | 197 c_strResult += strSegment.GetBuffer(strSegment.GetLength()+1); |
198 } | 198 } |
199 | 199 |
200 c_strResult.erase(c_strResult.begin()); | 200 c_strResult.erase(c_strResult.begin()); |
201 vRet = c_strResult.c_str(); | 201 vRet = c_strResult.c_str(); |
202 return TRUE; | 202 return TRUE; |
203 } | 203 } |
204 | 204 |
205 FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, JS_ErrorString& sError) | 205 FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, CFX_WideString& sError) |
206 { | 206 { |
207 v8::Isolate* isolate = GetIsolate(cc); | 207 v8::Isolate* isolate = GetIsolate(cc); |
208 | 208 |
209 int iSize = params.size(); | 209 int iSize = params.size(); |
210 if (iSize < 2) | 210 if (iSize < 2) |
211 return FALSE; | 211 return FALSE; |
212 | 212 |
213 CJS_Value p1(isolate); | 213 CJS_Value p1(isolate); |
214 p1 = params[0]; | 214 p1 = params[0]; |
215 | 215 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 { | 448 { |
449 iStart = iEnd+1; | 449 iStart = iEnd+1; |
450 continue; | 450 continue; |
451 } | 451 } |
452 } | 452 } |
453 cFormat.replace(iEnd,FXSYS_wcslen(cTableAd[iIndex].lpszJ
SMark),tszValue); | 453 cFormat.replace(iEnd,FXSYS_wcslen(cTableAd[iIndex].lpszJ
SMark),tszValue); |
454 iStart = iEnd; | 454 iStart = iEnd; |
455 } | 455 } |
456 } | 456 } |
457 | 457 |
458 » » CFX_WideString strFormat; | 458 » CFX_WideString strFormat; |
459 //» » strFormat.Format(L"%d,%d,%d,%d,%d,%d",iYear, iMonth, iDay, iHour
, iMin, iSec); | 459 » wchar_t buf[64] = {0}; |
460 //» » CString strFormat = cppTm.Format(cFormat.c_str()); | 460 » strFormat = wcsftime(buf, 64, cFormat.c_str(), &time); |
461 » » wchar_t buf[64] = {0}; | 461 » cFormat = buf; |
462 » » strFormat = wcsftime(buf, 64, cFormat.c_str(), &time); | 462 » cPurpose = cFormat; |
463 » » cFormat = buf; | |
464 » » cPurpose = cFormat; | |
465 } | 463 } |
466 | 464 |
467 FX_BOOL util::printx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, JS_ErrorString& sError) | 465 FX_BOOL util::printx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, CFX_WideString& sError) |
468 { | 466 { |
469 int iSize = params.size(); | 467 int iSize = params.size(); |
470 if (iSize<2) | 468 if (iSize<2) |
471 return FALSE; | 469 return FALSE; |
472 CFX_WideString sFormat = params[0].operator CFX_WideString(); | 470 CFX_WideString sFormat = params[0].operator CFX_WideString(); |
473 CFX_WideString sSource = params[1].operator CFX_WideString(); | 471 CFX_WideString sSource = params[1].operator CFX_WideString(); |
474 std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str(); | 472 std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str(); |
475 std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str(); | 473 std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str(); |
476 std::string cDest; | 474 std::string cDest; |
477 printx(cFormat,cSource,cDest); | 475 printx(cFormat,cSource,cDest); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 case '=': | 569 case '=': |
572 break; | 570 break; |
573 default: | 571 default: |
574 //cPurpose.push_back(letter); | 572 //cPurpose.push_back(letter); |
575 cPurpose += letter; | 573 cPurpose += letter; |
576 break; | 574 break; |
577 } | 575 } |
578 } | 576 } |
579 } | 577 } |
580 | 578 |
581 FX_BOOL util::scand(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, JS_ErrorString& sError) | 579 FX_BOOL util::scand(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, CFX_WideString& sError) |
582 { | 580 { |
583 v8::Isolate* isolate = GetIsolate(cc); | 581 v8::Isolate* isolate = GetIsolate(cc); |
584 int iSize = params.size(); | 582 int iSize = params.size(); |
585 if (iSize < 2) | 583 if (iSize < 2) |
586 return FALSE; | 584 return FALSE; |
587 CFX_WideString sFormat = params[0].operator CFX_WideString(); | 585 CFX_WideString sFormat = params[0].operator CFX_WideString(); |
588 CFX_WideString sDate = params[1].operator CFX_WideString(); | 586 CFX_WideString sDate = params[1].operator CFX_WideString(); |
589 | 587 |
590 double dDate = JS_GetDateTime(); | 588 double dDate = JS_GetDateTime(); |
591 if (sDate.GetLength() > 0) | 589 if (sDate.GetLength() > 0) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 total = 10 * total + (c - '0'); /* accumulate digit */ | 626 total = 10 * total + (c - '0'); /* accumulate digit */ |
629 c = (int)(unsigned char)*nptr++; /* get next char */ | 627 c = (int)(unsigned char)*nptr++; /* get next char */ |
630 } | 628 } |
631 | 629 |
632 if (sign == '-') | 630 if (sign == '-') |
633 return -total; | 631 return -total; |
634 else | 632 else |
635 return total; /* return result, negated if necessary */ | 633 return total; /* return result, negated if necessary */ |
636 } | 634 } |
637 | 635 |
638 FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, JS_ErrorString& sError) | 636 FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
639 { | 637 { |
640 int iSize = params.size(); | 638 int iSize = params.size(); |
641 if (iSize == 0) | 639 if (iSize == 0) |
642 return FALSE; | 640 return FALSE; |
643 int nByte = (int)params[0]; | 641 int nByte = (int)params[0]; |
644 unsigned char cByte = (unsigned char)nByte; | 642 unsigned char cByte = (unsigned char)nByte; |
645 CFX_WideString csValue; | 643 CFX_WideString csValue; |
646 csValue.Format(L"%c", cByte); | 644 csValue.Format(L"%c", cByte); |
647 vRet = csValue; | 645 vRet = csValue; |
648 return TRUE; | 646 return TRUE; |
649 } | 647 } |
OLD | NEW |