From 659a56bcbeb12b22708fe979d12b318080d828ba Mon Sep 17 00:00:00 2001 From: Bo Xu Date: Tue, 30 Dec 2014 16:56:12 -0800 Subject: Get rid of FX_LPCSTR cast. Follow up on https://codereview.chromium.org/733693003 R=brucedawson@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/809993004 --- fpdfsdk/src/formfiller/FFL_ComboBox.cpp | 2 +- fpdfsdk/src/formfiller/FFL_TextField.cpp | 2 +- fpdfsdk/src/fpdf_flatten.cpp | 6 +++--- fpdfsdk/src/fpdfdoc.cpp | 4 ++-- fpdfsdk/src/fsdk_baseannot.cpp | 2 +- fpdfsdk/src/fsdk_baseform.cpp | 2 +- fpdfsdk/src/javascript/JS_Value.cpp | 2 +- fpdfsdk/src/javascript/PublicMethods.cpp | 8 ++++---- fpdfsdk/src/javascript/util.cpp | 4 ++-- fpdfsdk/src/jsapi/fxjs_v8.cpp | 8 ++++---- fpdfsdk/src/pdfwindow/PWL_Edit.cpp | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp index ee6b7bd83a..9e58c952aa 100644 --- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp +++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp @@ -364,7 +364,7 @@ void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) CFX_WideString wsText = pEdit->GetText(); int nCharacters = wsText.GetLength(); CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); - unsigned short* pBuffer = (unsigned short*)(FX_LPCSTR)bsUTFText; + unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE); pEdit->SetEditNotify(this); diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp index 45c716280c..6a70981e4f 100644 --- a/fpdfsdk/src/formfiller/FFL_TextField.cpp +++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp @@ -364,7 +364,7 @@ void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) CFX_WideString wsText = pEdit->GetText(); int nCharacters = wsText.GetLength(); CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); - unsigned short* pBuffer = (unsigned short*)(FX_LPCSTR)bsUTFText; + unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE); pEdit->SetEditNotify(this); diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp index 6d3440f556..6c2d05c771 100644 --- a/fpdfsdk/src/fpdf_flatten.cpp +++ b/fpdfsdk/src/fpdf_flatten.cpp @@ -220,7 +220,7 @@ void SetPageContents(CFX_ByteString key, CPDF_Dictionary* pPage, CPDF_Document* pPage->SetAtReference("Contents", pDocument, pDocument->AddIndirectObject(pNewContents)); CFX_ByteString sStream; - sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", (FX_LPCSTR)key); + sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), FALSE, FALSE); } return; @@ -267,7 +267,7 @@ void SetPageContents(CFX_ByteString key, CPDF_Dictionary* pPage, CPDF_Document* pContentsArray->AddReference(pDocument, dwObjNum); CFX_ByteString sStream; - sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", (FX_LPCSTR)key); + sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), FALSE, FALSE); } } @@ -547,7 +547,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten( FPDF_PAGE page, int nFlag) } CFX_AffineMatrix m = GetMatrix(rcAnnot, rcStream, matrix); - sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f, (FX_LPCSTR)sFormName); + sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f, sFormName.c_str()); sStream += sTemp; pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), FALSE, FALSE); diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp index e974ffbcf2..19ca06ca27 100644 --- a/fpdfsdk/src/fpdfdoc.cpp +++ b/fpdfsdk/src/fpdfdoc.cpp @@ -107,7 +107,7 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FP CFX_ByteString path = Action.GetURI(pDoc); unsigned long len = path.GetLength() + 1; if (buffer != NULL && buflen >= len) - FXSYS_memcpy(buffer, (FX_LPCSTR)path, len); + FXSYS_memcpy(buffer, path.c_str(), len); return len; } @@ -251,7 +251,7 @@ DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR CFX_ByteString bstr = text.UTF16LE_Encode(); unsigned long len = bstr.GetLength(); if (buffer != NULL && buflen >= len+2) { - FXSYS_memcpy(buffer, (FX_LPCSTR)bstr, len); + FXSYS_memcpy(buffer, bstr.c_str(), len); // use double zero as trailer ((FX_BYTE*)buffer)[len] = ((FX_BYTE*)buffer)[len+1] = 0; } diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp index ff054c8b20..2b8cee9035 100644 --- a/fpdfsdk/src/fsdk_baseannot.cpp +++ b/fpdfsdk/src/fsdk_baseannot.cpp @@ -1062,7 +1062,7 @@ void CPDFSDK_Annot::WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Re pStreamDict->SetAtRect("BBox", rcBBox); } - pStream->SetData((FX_BYTE*)(FX_LPCSTR)sContents, sContents.GetLength(), FALSE, FALSE); + pStream->SetData((FX_BYTE*)sContents.c_str(), sContents.GetLength(), FALSE, FALSE); } #define BA_ANNOT_MINWIDTH 1 diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index e73bd32913..37caf2d1ed 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -1916,7 +1916,7 @@ CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) pRetStream = new CPDF_Stream(NULL, 0, NULL); CFX_ByteString csStream; csStream.Format("q\n%d 0 0 %d 0 0 cm\n/Img Do\nQ", nWidth, nHeight); - pRetStream->InitStream((FX_BYTE*)(FX_LPCSTR)csStream, csStream.GetLength(), pStreamDict); + pRetStream->InitStream((FX_BYTE*)csStream.c_str(), csStream.GetLength(), pStreamDict); pDocument->AddIndirectObject(pRetStream); } diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp index 93da9bea2e..9279ff5db4 100644 --- a/fpdfsdk/src/javascript/JS_Value.cpp +++ b/fpdfsdk/src/javascript/JS_Value.cpp @@ -400,7 +400,7 @@ void CJS_PropValue::StartGetting() void CJS_PropValue::operator <<(CFX_ByteString string) { ASSERT(!m_bIsSetting); - CJS_Value::operator =((FX_LPCSTR)string); + CJS_Value::operator = (string.c_str()); } void CJS_PropValue::operator >>(CFX_ByteString &string) const diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index b29a5b4f3c..3eb8a09ee7 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -443,7 +443,7 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu const char * pTemp = strchr(p, ch); if (pTemp == NULL) { - StrArray.SetElement(nIndex, CJS_Value(isolate,(FX_LPCSTR)StrTrim(p))); + StrArray.SetElement(nIndex, CJS_Value(isolate, StrTrim(p).c_str())); break; } else @@ -452,7 +452,7 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu strncpy(pSub, p, pTemp - p); *(pSub + (pTemp - p)) = '\0'; - StrArray.SetElement(nIndex, CJS_Value(isolate,(FX_LPCSTR)StrTrim(pSub))); + StrArray.SetElement(nIndex, CJS_Value(isolate, StrTrim(pSub).c_str())); delete []pSub; nIndex ++; @@ -1807,7 +1807,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Format(OBJ_METHOD_PARAMS) if(!pEvent->m_pValue) return FALSE; CFX_WideString& Value = pEvent->Value(); - std::string strSrc = (FX_LPCSTR)CFX_ByteString::FromUnicode(Value); + std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str(); switch (iIndex) { @@ -1962,7 +1962,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(OBJ_METHOD_PARAMS) return FALSE; //CJS_Value val = pEvent->Value(); CFX_WideString& val = pEvent->Value(); - std::string strSrc = (FX_LPCSTR)CFX_ByteString::FromUnicode(val); + std::string strSrc = CFX_ByteString::FromUnicode(val).c_str(); std::wstring wstrChange(pEvent->Change()); switch (iIndex) diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp index d2813f5083..83fb32cb82 100644 --- a/fpdfsdk/src/javascript/util.cpp +++ b/fpdfsdk/src/javascript/util.cpp @@ -471,8 +471,8 @@ FX_BOOL util::printx(OBJ_METHOD_PARAMS) return FALSE; CFX_WideString sFormat = params[0].operator CFX_WideString(); CFX_WideString sSource = params[1].operator CFX_WideString(); - std::string cFormat = (FX_LPCSTR)CFX_ByteString::FromUnicode(sFormat); - std::string cSource = (FX_LPCSTR)CFX_ByteString::FromUnicode(sSource); + std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str(); + std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str(); std::string cDest; printx(cFormat,cSource,cDest); vRet = cDest.c_str(); diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp index 1f47864e96..7d919a74f8 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp @@ -251,7 +251,7 @@ void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_ CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); CFX_WideString ws = CFX_WideString(pObjDef->objName); CFX_ByteString bs = ws.UTF8Encode(); - v8::Handle objName = v8::String::NewFromUtf8(isolate,(FX_LPCSTR)bs, v8::String::kNormalString, bs.GetLength()); + v8::Handle objName = v8::String::NewFromUtf8(isolate, bs.c_str(), v8::String::kNormalString, bs.GetLength()); if(pObjDef->objType == JS_DYNAMIC) @@ -324,7 +324,7 @@ int JS_Parse(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* CFX_ByteString bsScript = wsScript.UTF8Encode(); - v8::Handle compiled_script = v8::Script::Compile(v8::String::NewFromUtf8(isolate,(FX_LPCSTR)bsScript,v8::String::kNormalString, bsScript.GetLength())); + v8::Handle compiled_script = v8::Script::Compile(v8::String::NewFromUtf8(isolate, bsScript.c_str(), v8::String::kNormalString, bsScript.GetLength())); if (compiled_script.IsEmpty()) { v8::String::Utf8Value error(try_catch.Exception()); return -1; @@ -341,7 +341,7 @@ int JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t CFX_WideString wsScript(script); CFX_ByteString bsScript = wsScript.UTF8Encode(); - v8::Handle compiled_script = v8::Script::Compile(v8::String::NewFromUtf8(isolate,(FX_LPCSTR)bsScript,v8::String::kNormalString, bsScript.GetLength())); + v8::Handle compiled_script = v8::Script::Compile(v8::String::NewFromUtf8(isolate, bsScript.c_str(), v8::String::kNormalString, bsScript.GetLength())); if (compiled_script.IsEmpty()) { v8::String::Utf8Value error(try_catch.Exception()); return -1; @@ -553,7 +553,7 @@ v8::Handle WSToJSString(IJS_Runtime* pJSRuntime, const wchar_t* Prop CFX_WideString ws = CFX_WideString(PropertyName,Len); CFX_ByteString bs = ws.UTF8Encode(); if(!pJSRuntime) pJSRuntime = v8::Isolate::GetCurrent(); - return v8::String::NewFromUtf8(pJSRuntime, (FX_LPCSTR)bs); + return v8::String::NewFromUtf8(pJSRuntime, bs.c_str()); } v8::Handle JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Handle pObj,const wchar_t* PropertyName) diff --git a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp index dfdbf64f0e..bbac382967 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp @@ -44,7 +44,7 @@ void CPWL_Edit::SetText(FX_LPCWSTR csText) { CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText); - if (CXML_Element * pXML = CXML_Element::Parse((FX_LPCSTR)sValue,sValue.GetLength())) + if (CXML_Element * pXML = CXML_Element::Parse(sValue.c_str(), sValue.GetLength())) { FX_INT32 nCount = pXML->CountChildren(); FX_BOOL bFirst = TRUE; -- cgit v1.2.3