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

Side by Side Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 1885973002: Remove implicit cast from CFX_ByteString to (const char*). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Typo Created 4 years, 8 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 | « xfa/fxfa/app/xfa_ffwidget.cpp ('k') | xfa/fxfa/parser/xfa_locale.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 "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 3231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 } else { 3242 } else {
3243 CFX_WideTextBuf wsJavaScriptBuf; 3243 CFX_WideTextBuf wsJavaScriptBuf;
3244 CFX_WideString javaScript; 3244 CFX_WideString javaScript;
3245 CFX_WideString wsError; 3245 CFX_WideString wsError;
3246 XFA_FM2JS_Translate( 3246 XFA_FM2JS_Translate(
3247 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), 3247 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(),
3248 wsJavaScriptBuf, wsError); 3248 wsJavaScriptBuf, wsError);
3249 FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime); 3249 FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime);
3250 FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime); 3250 FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime);
3251 javaScript = wsJavaScriptBuf.GetWideString(); 3251 javaScript = wsJavaScriptBuf.GetWideString();
3252 FXJSE_ExecuteScript(hContext, 3252 FXJSE_ExecuteScript(
3253 FX_UTF8Encode(javaScript, javaScript.GetLength()), 3253 hContext, FX_UTF8Encode(javaScript, javaScript.GetLength()).c_str(),
3254 returnValue); 3254 returnValue);
3255 FXJSE_Value_Set(args.GetReturnValue(), returnValue); 3255 FXJSE_Value_Set(args.GetReturnValue(), returnValue);
3256 FXJSE_Value_Release(returnValue); 3256 FXJSE_Value_Release(returnValue);
3257 FXJSE_Context_Release(hContext); 3257 FXJSE_Context_Release(hContext);
3258 } 3258 }
3259 FXJSE_Value_Release(scriptValue); 3259 FXJSE_Value_Release(scriptValue);
3260 } else { 3260 } else {
3261 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3261 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3262 L"Eval"); 3262 L"Eval");
3263 } 3263 }
3264 } 3264 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3463 FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0); 3463 FXJSE_HVALUE unitspanValue = GetSimpleHValue(hThis, args, 0);
3464 FXJSE_HVALUE unitValue = 0; 3464 FXJSE_HVALUE unitValue = 0;
3465 CFX_ByteString unitspanString; 3465 CFX_ByteString unitspanString;
3466 FX_DOUBLE dFirstNumber = 0; 3466 FX_DOUBLE dFirstNumber = 0;
3467 CFX_ByteString strFirstUnit; 3467 CFX_ByteString strFirstUnit;
3468 CFX_ByteString strUnit; 3468 CFX_ByteString strUnit;
3469 if (FXJSE_Value_IsNull(unitspanValue)) { 3469 if (FXJSE_Value_IsNull(unitspanValue)) {
3470 FXJSE_Value_SetNull(args.GetReturnValue()); 3470 FXJSE_Value_SetNull(args.GetReturnValue());
3471 } else { 3471 } else {
3472 HValueToUTF8String(unitspanValue, unitspanString); 3472 HValueToUTF8String(unitspanValue, unitspanString);
3473 const FX_CHAR* pData = unitspanString; 3473 const FX_CHAR* pData = unitspanString.c_str();
3474 if (pData) { 3474 if (pData) {
3475 int32_t u = 0; 3475 int32_t u = 0;
3476 while (*(pData + u) == 0x20 || *(pData + u) == 0x09 || 3476 while (*(pData + u) == 0x20 || *(pData + u) == 0x09 ||
3477 *(pData + u) == 0x0B || *(pData + u) == 0x0C || 3477 *(pData + u) == 0x0B || *(pData + u) == 0x0C ||
3478 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { 3478 *(pData + u) == 0x0A || *(pData + u) == 0x0D) {
3479 ++u; 3479 ++u;
3480 } 3480 }
3481 while (u < unitspanString.GetLength()) { 3481 while (u < unitspanString.GetLength()) {
3482 if ((*(pData + u) > '9' || *(pData + u) < '0') && 3482 if ((*(pData + u) > '9' || *(pData + u) < '0') &&
3483 *(pData + u) != '.' && *(pData + u) != '-') { 3483 *(pData + u) != '.' && *(pData + u) != '-') {
(...skipping 14 matching lines...) Expand all
3498 break; 3498 break;
3499 } 3499 }
3500 strFirstUnit += (*(pData + u)); 3500 strFirstUnit += (*(pData + u));
3501 ++u; 3501 ++u;
3502 } 3502 }
3503 strFirstUnit.MakeLower(); 3503 strFirstUnit.MakeLower();
3504 if (argc == 2) { 3504 if (argc == 2) {
3505 unitValue = GetSimpleHValue(hThis, args, 1); 3505 unitValue = GetSimpleHValue(hThis, args, 1);
3506 CFX_ByteString unitTempString; 3506 CFX_ByteString unitTempString;
3507 HValueToUTF8String(unitValue, unitTempString); 3507 HValueToUTF8String(unitValue, unitTempString);
3508 const FX_CHAR* pData = unitTempString; 3508 const FX_CHAR* pData = unitTempString.c_str();
3509 int32_t u = 0; 3509 int32_t u = 0;
3510 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || 3510 while (*(pData + u) == ' ' || *(pData + u) == 0x09 ||
3511 *(pData + u) == 0x0B || *(pData + u) == 0x0C || 3511 *(pData + u) == 0x0B || *(pData + u) == 0x0C ||
3512 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { 3512 *(pData + u) == 0x0A || *(pData + u) == 0x0D) {
3513 ++u; 3513 ++u;
3514 } 3514 }
3515 while (u < unitTempString.GetLength()) { 3515 while (u < unitTempString.GetLength()) {
3516 if ((*(pData + u) > '9' || *(pData + u) < '0') && 3516 if ((*(pData + u) > '9' || *(pData + u) < '0') &&
3517 *(pData + u) != '.') { 3517 *(pData + u) != '.') {
3518 break; 3518 break;
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
4897 } 4897 }
4898 } 4898 }
4899 if (!bFlags) { 4899 if (!bFlags) {
4900 CFX_ByteString numberString; 4900 CFX_ByteString numberString;
4901 CFX_ByteString formatStr = "%"; 4901 CFX_ByteString formatStr = "%";
4902 if (iPrecision) { 4902 if (iPrecision) {
4903 formatStr += "."; 4903 formatStr += ".";
4904 formatStr += CFX_ByteString::FormatInteger(iPrecision); 4904 formatStr += CFX_ByteString::FormatInteger(iPrecision);
4905 } 4905 }
4906 formatStr += "f"; 4906 formatStr += "f";
4907 numberString.Format(formatStr, fNumber); 4907 numberString.Format(formatStr.c_str(), fNumber);
4908 const FX_CHAR* pData = numberString; 4908 const FX_CHAR* pData = numberString.c_str();
4909 int32_t iLength = numberString.GetLength(); 4909 int32_t iLength = numberString.GetLength();
4910 int32_t u = 0; 4910 int32_t u = 0;
4911 while (u < iLength) { 4911 while (u < iLength) {
4912 if (*(pData + u) == '.') { 4912 if (*(pData + u) == '.') {
4913 break; 4913 break;
4914 } 4914 }
4915 ++u; 4915 ++u;
4916 } 4916 }
4917 CFX_ByteTextBuf resultBuf; 4917 CFX_ByteTextBuf resultBuf;
4918 if (u > iWidth || (iPrecision + u) >= iWidth) { 4918 if (u > iWidth || (iPrecision + u) >= iWidth) {
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after
6983 return iValue; 6983 return iValue;
6984 } else if (FXJSE_Value_IsObject(hValue)) { 6984 } else if (FXJSE_Value_IsObject(hValue)) {
6985 FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime); 6985 FXJSE_HVALUE newProperty = FXJSE_Value_Create(hruntime);
6986 GetObjectDefaultValue(hValue, newProperty); 6986 GetObjectDefaultValue(hValue, newProperty);
6987 iValue = HValueToInteger(hThis, newProperty); 6987 iValue = HValueToInteger(hThis, newProperty);
6988 FXJSE_Value_Release(newProperty); 6988 FXJSE_Value_Release(newProperty);
6989 return iValue; 6989 return iValue;
6990 } else if (FXJSE_Value_IsUTF8String(hValue)) { 6990 } else if (FXJSE_Value_IsUTF8String(hValue)) {
6991 CFX_ByteString szValue; 6991 CFX_ByteString szValue;
6992 FXJSE_Value_ToUTF8String(hValue, szValue); 6992 FXJSE_Value_ToUTF8String(hValue, szValue);
6993 iValue = FXSYS_atoi(szValue); 6993 iValue = FXSYS_atoi(szValue.c_str());
6994 } else { 6994 } else {
6995 iValue = FXJSE_Value_ToInteger(hValue); 6995 iValue = FXJSE_Value_ToInteger(hValue);
6996 } 6996 }
6997 return iValue; 6997 return iValue;
6998 } 6998 }
6999 FX_DOUBLE CXFA_FM2JSContext::StringToDouble( 6999 FX_DOUBLE CXFA_FM2JSContext::StringToDouble(
7000 const CFX_ByteStringC& szStringVal) { 7000 const CFX_ByteStringC& szStringVal) {
7001 return XFA_ByteStringToDouble(szStringVal); 7001 return XFA_ByteStringToDouble(szStringVal);
7002 } 7002 }
7003 FX_FLOAT CXFA_FM2JSContext::HValueToFloat(FXJSE_HOBJECT hThis, 7003 FX_FLOAT CXFA_FM2JSContext::HValueToFloat(FXJSE_HOBJECT hThis,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
7228 CFX_WideString wsFormat; 7228 CFX_WideString wsFormat;
7229 pAppProvider->LoadString(iStringID, wsFormat); 7229 pAppProvider->LoadString(iStringID, wsFormat);
7230 CFX_WideString wsMessage; 7230 CFX_WideString wsMessage;
7231 va_list arg_ptr; 7231 va_list arg_ptr;
7232 va_start(arg_ptr, iStringID); 7232 va_start(arg_ptr, iStringID);
7233 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); 7233 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr);
7234 va_end(arg_ptr); 7234 va_end(arg_ptr);
7235 FXJSE_ThrowMessage( 7235 FXJSE_ThrowMessage(
7236 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsStringC()); 7236 "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsStringC());
7237 } 7237 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffwidget.cpp ('k') | xfa/fxfa/parser/xfa_locale.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698