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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 jsDate.GetMonth() + 1, | 258 jsDate.GetMonth() + 1, |
259 jsDate.GetDay(), | 259 jsDate.GetDay(), |
260 jsDate.GetHours(), | 260 jsDate.GetHours(), |
261 jsDate.GetMinutes(), | 261 jsDate.GetMinutes(), |
262 jsDate.GetSeconds()); | 262 jsDate.GetSeconds()); |
263 break; | 263 break; |
264 default: | 264 default: |
265 return FALSE; | 265 return FALSE; |
266 } | 266 } |
267 | 267 |
268 » » vRet = swResult; | 268 » » vRet = swResult.c_str(); |
269 return TRUE; | 269 return TRUE; |
270 } | 270 } |
271 else if (p1.GetType() == VT_string) | 271 else if (p1.GetType() == VT_string) |
272 { | 272 { |
273 std::basic_string<wchar_t> cFormat = p1.ToCFXWideString().c_str(
); | 273 std::basic_string<wchar_t> cFormat = p1.ToCFXWideString().c_str(
); |
274 | 274 |
275 bool bXFAPicture = false; | 275 bool bXFAPicture = false; |
276 if (iSize > 2) | 276 if (iSize > 2) |
277 { | 277 { |
278 bXFAPicture = params[2].ToBool(); | 278 bXFAPicture = params[2].ToBool(); |
279 } | 279 } |
280 | 280 |
281 if (bXFAPicture) | 281 if (bXFAPicture) |
282 { | 282 { |
283 return FALSE; //currently, it doesn't support XFAPicture
. | 283 return FALSE; //currently, it doesn't support XFAPicture
. |
284 } | 284 } |
285 | 285 |
286 int iIndex; | 286 int iIndex; |
287 for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIn
dex++) | 287 for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIn
dex++) |
288 { | 288 { |
289 int iStart = 0; | 289 int iStart = 0; |
290 int iEnd; | 290 int iEnd; |
291 » » » while((iEnd = cFormat.find((CFX_WideString)fcTable[iInde
x].lpszJSMark, iStart)) != -1) | 291 » » » while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, i
Start)) != -1) |
292 { | 292 { |
293 » » » » cFormat.replace(iEnd, FXSYS_wcslen(fcTable[iInde
x].lpszJSMark), (CFX_WideString)fcTable[iIndex].lpszCppMark); | 293 » » » » cFormat.replace(iEnd, FXSYS_wcslen(fcTable[iInde
x].lpszJSMark), fcTable[iIndex].lpszCppMark); |
294 iStart = iEnd; | 294 iStart = iEnd; |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 int iYear,iMonth,iDay,iHour,iMin,iSec; | 298 int iYear,iMonth,iDay,iHour,iMin,iSec; |
299 iYear = jsDate.GetYear(); | 299 iYear = jsDate.GetYear(); |
300 iMonth = jsDate.GetMonth(); | 300 iMonth = jsDate.GetMonth(); |
301 iDay = jsDate.GetDay(); | 301 iDay = jsDate.GetDay(); |
302 iHour = jsDate.GetHours(); | 302 iHour = jsDate.GetHours(); |
303 iMin = jsDate.GetMinutes(); | 303 iMin = jsDate.GetMinutes(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 //_itot(cTableAd[iIndex].iValue,tszValue,10); | 335 //_itot(cTableAd[iIndex].iValue,tszValue,10); |
336 CFX_WideString sValue; | 336 CFX_WideString sValue; |
337 sValue.Format(L"%d",cTableAd[iIndex].iValue); | 337 sValue.Format(L"%d",cTableAd[iIndex].iValue); |
338 memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetL
ength()+1), | 338 memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetL
ength()+1), |
339 (sValue.GetLength()+1)*sizeof(wchar_t)); | 339 (sValue.GetLength()+1)*sizeof(wchar_t)); |
340 | 340 |
341 //strFormat.Replace(cTableAd[iIndex].lpszJSMark,"%d"); | 341 //strFormat.Replace(cTableAd[iIndex].lpszJSMark,"%d"); |
342 //strFormat.Format(strFormat,cTableAd[iIndex].iValue); | 342 //strFormat.Format(strFormat,cTableAd[iIndex].iValue); |
343 int iStart = 0; | 343 int iStart = 0; |
344 int iEnd; | 344 int iEnd; |
345 » » » while((iEnd = cFormat.find((CFX_WideString)cTableAd[iInd
ex].lpszJSMark,iStart)) != -1) | 345 » » » while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark,
iStart)) != -1) |
346 { | 346 { |
347 if (iEnd > 0) | 347 if (iEnd > 0) |
348 { | 348 { |
349 if (cFormat[iEnd-1] == L'%') | 349 if (cFormat[iEnd-1] == L'%') |
350 { | 350 { |
351 iStart = iEnd+1; | 351 iStart = iEnd+1; |
352 continue; | 352 continue; |
353 } | 353 } |
354 } | 354 } |
355 cFormat.replace(iEnd, FXSYS_wcslen(cTableAd[iInd
ex].lpszJSMark), tszValue); | 355 cFormat.replace(iEnd, FXSYS_wcslen(cTableAd[iInd
ex].lpszJSMark), tszValue); |
(...skipping 21 matching lines...) Expand all Loading... |
377 if (bXFAPicture) | 377 if (bXFAPicture) |
378 { | 378 { |
379 return ; //currently, it doesn't support XFAPicture. | 379 return ; //currently, it doesn't support XFAPicture. |
380 } | 380 } |
381 | 381 |
382 int iIndex; | 382 int iIndex; |
383 for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIndex++) | 383 for(iIndex = 0;iIndex<sizeof(fcTable)/sizeof(stru_TbConvert);iIndex++) |
384 { | 384 { |
385 int iStart = 0; | 385 int iStart = 0; |
386 int iEnd; | 386 int iEnd; |
387 » » while((iEnd = cFormat.find((CFX_WideString)fcTable[iIndex].lpszJ
SMark,iStart)) != -1) | 387 » » while((iEnd = cFormat.find(fcTable[iIndex].lpszJSMark, iStart))
!= -1) |
388 { | 388 { |
389 » » » cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJS
Mark), (CFX_WideString)fcTable[iIndex].lpszCppMark); | 389 » » » cFormat.replace(iEnd,FXSYS_wcslen(fcTable[iIndex].lpszJS
Mark), fcTable[iIndex].lpszCppMark); |
390 iStart = iEnd; | 390 iStart = iEnd; |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 int iYear,iMonth,iDay,iHour,iMin,iSec; | 394 int iYear,iMonth,iDay,iHour,iMin,iSec; |
395 iYear = jsDate.GetYear(); | 395 iYear = jsDate.GetYear(); |
396 iMonth = jsDate.GetMonth(); | 396 iMonth = jsDate.GetMonth(); |
397 iDay = jsDate.GetDay(); | 397 iDay = jsDate.GetDay(); |
398 iHour = jsDate.GetHours(); | 398 iHour = jsDate.GetHours(); |
399 iMin = jsDate.GetMinutes(); | 399 iMin = jsDate.GetMinutes(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 //_itot(cTableAd[iIndex].iValue,tszValue,10); | 431 //_itot(cTableAd[iIndex].iValue,tszValue,10); |
432 CFX_WideString sValue; | 432 CFX_WideString sValue; |
433 sValue.Format(L"%d",cTableAd[iIndex].iValue); | 433 sValue.Format(L"%d",cTableAd[iIndex].iValue); |
434 memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetLength()+
1),sValue.GetLength()*sizeof(wchar_t)); | 434 memcpy(tszValue, (wchar_t *)sValue.GetBuffer(sValue.GetLength()+
1),sValue.GetLength()*sizeof(wchar_t)); |
435 | 435 |
436 | 436 |
437 //strFormat.Replace(cTableAd[iIndex].lpszJSMark,"%d"); | 437 //strFormat.Replace(cTableAd[iIndex].lpszJSMark,"%d"); |
438 //strFormat.Format(strFormat,cTableAd[iIndex].iValue); | 438 //strFormat.Format(strFormat,cTableAd[iIndex].iValue); |
439 int iStart = 0; | 439 int iStart = 0; |
440 int iEnd; | 440 int iEnd; |
441 » » while((iEnd = cFormat.find((CFX_WideString)cTableAd[iIndex].lpsz
JSMark,iStart)) != -1) | 441 » » while((iEnd = cFormat.find(cTableAd[iIndex].lpszJSMark, iStart))
!= -1) |
442 { | 442 { |
443 if (iEnd > 0) | 443 if (iEnd > 0) |
444 { | 444 { |
445 if (cFormat[iEnd-1] == L'%') | 445 if (cFormat[iEnd-1] == L'%') |
446 { | 446 { |
447 iStart = iEnd+1; | 447 iStart = iEnd+1; |
448 continue; | 448 continue; |
449 } | 449 } |
450 } | 450 } |
451 cFormat.replace(iEnd,FXSYS_wcslen(cTableAd[iIndex].lpszJ
SMark),tszValue); | 451 cFormat.replace(iEnd,FXSYS_wcslen(cTableAd[iIndex].lpszJ
SMark),tszValue); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 | 633 |
634 FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 634 FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
635 { | 635 { |
636 int iSize = params.size(); | 636 int iSize = params.size(); |
637 if (iSize == 0) | 637 if (iSize == 0) |
638 return FALSE; | 638 return FALSE; |
639 int nByte = params[0].ToInt(); | 639 int nByte = params[0].ToInt(); |
640 unsigned char cByte = (unsigned char)nByte; | 640 unsigned char cByte = (unsigned char)nByte; |
641 CFX_WideString csValue; | 641 CFX_WideString csValue; |
642 csValue.Format(L"%c", cByte); | 642 csValue.Format(L"%c", cByte); |
643 » vRet = csValue; | 643 » vRet = csValue.c_str(); |
644 return TRUE; | 644 return TRUE; |
645 } | 645 } |
OLD | NEW |