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 "fpdfsdk/javascript/util.h" | 7 #include "fpdfsdk/javascript/util.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 305 |
306 | 306 |
307 FX_BOOL util::printx(IJS_Context* cc, | 307 FX_BOOL util::printx(IJS_Context* cc, |
308 const std::vector<CJS_Value>& params, | 308 const std::vector<CJS_Value>& params, |
309 CJS_Value& vRet, | 309 CJS_Value& vRet, |
310 CFX_WideString& sError) { | 310 CFX_WideString& sError) { |
311 if (params.size() < 2) { | 311 if (params.size() < 2) { |
312 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); | 312 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); |
313 return FALSE; | 313 return FALSE; |
314 } | 314 } |
315 vRet = printx(params[0].ToCFXWideString(), params[1].ToCFXWideString()); | 315 vRet = |
| 316 printx(params[0].ToCFXWideString(), params[1].ToCFXWideString()).c_str(); |
316 return TRUE; | 317 return TRUE; |
317 } | 318 } |
318 | 319 |
319 enum CaseMode { kPreserveCase, kUpperCase, kLowerCase }; | 320 enum CaseMode { kPreserveCase, kUpperCase, kLowerCase }; |
320 | 321 |
321 static FX_WCHAR TranslateCase(FX_WCHAR input, CaseMode eMode) { | 322 static FX_WCHAR TranslateCase(FX_WCHAR input, CaseMode eMode) { |
322 if (eMode == kLowerCase && input >= 'A' && input <= 'Z') | 323 if (eMode == kLowerCase && input >= 'A' && input <= 'Z') |
323 return input | 0x20; | 324 return input | 0x20; |
324 if (eMode == kUpperCase && input >= 'a' && input <= 'z') | 325 if (eMode == kUpperCase && input >= 'a' && input <= 'z') |
325 return input & ~0x20; | 326 return input & ~0x20; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 } | 453 } |
453 int arg = params[0].ToInt(); | 454 int arg = params[0].ToInt(); |
454 if (arg < 0 || arg > 255) { | 455 if (arg < 0 || arg > 255) { |
455 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 456 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
456 return FALSE; | 457 return FALSE; |
457 } | 458 } |
458 CFX_WideString wStr(static_cast<FX_WCHAR>(arg)); | 459 CFX_WideString wStr(static_cast<FX_WCHAR>(arg)); |
459 vRet = wStr.c_str(); | 460 vRet = wStr.c_str(); |
460 return TRUE; | 461 return TRUE; |
461 } | 462 } |
OLD | NEW |