summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-13 15:41:21 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-13 15:41:21 -0700
commitb4c9f3f04673753da30011e9f1282cd5d1fa0f40 (patch)
tree9890d43409c8d60b1041de921c961067907419fb /fpdfsdk
parentcdce75706de7e76e73550a0582e1fd28af324fd0 (diff)
downloadpdfium-b4c9f3f04673753da30011e9f1282cd5d1fa0f40.tar.xz
Remove implicit cast from CFX_ByteString to (const char*).
BUG= Review URL: https://codereview.chromium.org/1885973002
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_sysfontinfo.cpp2
-rw-r--r--fpdfsdk/fpdfformfill.cpp3
-rw-r--r--fpdfsdk/fpdfppo.cpp24
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp15
-rw-r--r--fpdfsdk/fsdk_actionhandler.cpp2
-rw-r--r--fpdfsdk/fsdk_mgr.cpp3
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp17
-rw-r--r--fpdfsdk/javascript/global.cpp2
-rw-r--r--fpdfsdk/pdfwindow/PWL_FontMap.cpp4
9 files changed, 37 insertions, 35 deletions
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 7fe4b08e46..d5ee7d186f 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -152,7 +152,7 @@ static unsigned long DefaultGetFaceName(struct _FPDF_SYSFONTINFO* pThis,
return 0;
if (name.GetLength() >= (long)buf_size)
return name.GetLength() + 1;
- FXSYS_strcpy(buffer, name);
+ FXSYS_strcpy(buffer, name.c_str());
return name.GetLength() + 1;
}
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index aa8bc9a0a0..9f4e2944ca 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -597,8 +597,7 @@ FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle,
uint32_t real_size = len < *size ? len : *size;
if (real_size > 0)
- FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(*sSuggestWords)[index],
- real_size);
+ FXSYS_memcpy((void*)bsText, (*sSuggestWords)[index].c_str(), real_size);
*size = real_size;
return TRUE;
}
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index 777310bb2b..300e7ba36e 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -191,12 +191,13 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
if (!pp)
return nullptr;
- if (pDict->KeyExist((const char*)nSrctag))
- return pDict->GetObjectBy((const char*)nSrctag);
+ CFX_ByteStringC sSrcTag = nSrctag.AsStringC();
+ if (pDict->KeyExist(sSrcTag))
+ return pDict->GetObjectBy(sSrcTag);
while (pp) {
- if (pp->KeyExist((const char*)nSrctag))
- return pp->GetObjectBy((const char*)nSrctag);
+ if (pp->KeyExist(sSrcTag))
+ return pp->GetObjectBy(sSrcTag);
if (!pp->KeyExist("Parent"))
break;
pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect());
@@ -223,8 +224,9 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
const CFX_ByteString& key = it->first;
CPDF_Object* pNextObj = it->second;
++it;
- if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") ||
- !FXSYS_strcmp(key, "First")) {
+ if (!FXSYS_strcmp(key.c_str(), "Parent") ||
+ !FXSYS_strcmp(key.c_str(), "Prev") ||
+ !FXSYS_strcmp(key.c_str(), "First")) {
continue;
}
if (pNextObj) {
@@ -290,11 +292,11 @@ uint32_t CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) {
if (pDictClone->KeyExist("Type")) {
CFX_ByteString strType = pDictClone->GetStringBy("Type");
- if (!FXSYS_stricmp(strType, "Pages")) {
+ if (!FXSYS_stricmp(strType.c_str(), "Pages")) {
pDictClone->Release();
return 4;
}
- if (!FXSYS_stricmp(strType, "Page")) {
+ if (!FXSYS_stricmp(strType.c_str(), "Page")) {
pDictClone->Release();
return 0;
}
@@ -330,12 +332,12 @@ FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring,
cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom);
int nMid = cbMidRange.Find('-');
if (nMid == -1) {
- long lPageNum = atol(cbMidRange);
+ long lPageNum = atol(cbMidRange.c_str());
if (lPageNum <= 0 || lPageNum > nCount)
return FALSE;
pageArray->push_back((uint16_t)lPageNum);
} else {
- int nStartPageNum = atol(cbMidRange.Mid(0, nMid));
+ int nStartPageNum = atol(cbMidRange.Mid(0, nMid).c_str());
if (nStartPageNum == 0)
return FALSE;
@@ -344,7 +346,7 @@ FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring,
if (nEnd == 0)
return FALSE;
- int nEndPageNum = atol(cbMidRange.Mid(nMid, nEnd));
+ int nEndPageNum = atol(cbMidRange.Mid(nMid, nEnd).c_str());
if (nStartPageNum < 0 || nStartPageNum > nEndPageNum ||
nEndPageNum > nCount) {
return FALSE;
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index 7fa258c506..53068d345d 100644
--- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
+++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
@@ -39,7 +39,6 @@
#ifndef _WIN32
extern void SetLastError(int err);
-
extern int GetLastError();
#endif
@@ -655,7 +654,7 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
CFX_ByteString content;
if (fileType == FXFA_SAVEAS_XML) {
content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
- fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(),
+ fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
content.GetLength());
CFX_WideStringC data(L"data");
if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) {
@@ -698,13 +697,13 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
} else {
if (i == size - 1) {
CFX_WideString wPath = CFX_WideString::FromUTF16LE(
- (unsigned short*)(const FX_CHAR*)bs,
+ reinterpret_cast<const unsigned short*>(bs.c_str()),
bs.GetLength() / sizeof(unsigned short));
CFX_ByteString bPath = wPath.UTF8Encode();
- CFX_ByteString szFormat =
+ const char* szFormat =
"\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
- content.Format(szFormat, (char*)(const FX_CHAR*)bPath);
- fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(),
+ content.Format(szFormat, bPath.c_str());
+ fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
content.GetLength());
}
@@ -954,8 +953,8 @@ FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
if (fileType == FXFA_SAVEAS_XML) {
CFX_WideString ws;
ws.FromLocal("data");
- CFX_ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
- fileStream.WriteBlock((const FX_CHAR*)content, 0, content.GetLength());
+ const char* content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+ fileStream.WriteBlock(content, 0, strlen(content));
m_pXFADoc->SavePackage(ws.AsStringC(), &fileStream);
} else if (fileType == FXFA_SAVEAS_XDP) {
if (flag == 0)
diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp
index 0bbdbab137..912bc40c7f 100644
--- a/fpdfsdk/fsdk_actionhandler.cpp
+++ b/fpdfsdk/fsdk_actionhandler.cpp
@@ -470,7 +470,7 @@ void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument,
ASSERT(action.GetDict());
CFX_ByteString csName = action.GetNamedAction();
- pDocument->GetEnv()->FFI_ExecuteNamedAction(csName);
+ pDocument->GetEnv()->FFI_ExecuteNamedAction(csName.c_str());
}
void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument,
diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp
index 3412516f65..7240fe1d0b 100644
--- a/fpdfsdk/fsdk_mgr.cpp
+++ b/fpdfsdk/fsdk_mgr.cpp
@@ -840,7 +840,8 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) {
#endif // PDF_ENABLE_XFA
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) {
- return pDict ? AddAnnot(pDict->GetStringBy("Subtype"), pDict) : nullptr;
+ return pDict ? AddAnnot(pDict->GetStringBy("Subtype").c_str(), pDict)
+ : nullptr;
}
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 5a694c742a..d03f671599 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -162,7 +162,7 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime,
}
CFX_WideString wsStr = val.ToCFXWideString();
CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr);
- const char* p = (const char*)t;
+ const char* p = t.c_str();
int ch = ',';
int nIndex = 0;
@@ -170,8 +170,8 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime,
while (*p) {
const char* pTemp = strchr(p, ch);
if (!pTemp) {
- StrArray.SetElement(nIndex,
- CJS_Value(pRuntime, StrTrim(CFX_ByteString(p))));
+ StrArray.SetElement(
+ nIndex, CJS_Value(pRuntime, StrTrim(CFX_ByteString(p)).c_str()));
break;
}
@@ -179,8 +179,8 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime,
strncpy(pSub, p, pTemp - p);
*(pSub + (pTemp - p)) = '\0';
- StrArray.SetElement(nIndex,
- CJS_Value(pRuntime, StrTrim(CFX_ByteString(pSub))));
+ StrArray.SetElement(
+ nIndex, CJS_Value(pRuntime, StrTrim(CFX_ByteString(pSub)).c_str()));
delete[] pSub;
nIndex++;
@@ -756,7 +756,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
// for processing decimal places
strValue.Replace(",", ".");
- double dValue = atof(strValue);
+ double dValue = atof(strValue.c_str());
if (iDec > 0)
dValue += DOUBLE_CORRECT;
@@ -1040,7 +1040,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(
iSepStyle = 0;
// for processing decimal places
- double dValue = atof(strValue);
+ double dValue = atof(strValue.c_str());
dValue *= 100;
if (iDec > 0)
dValue += DOUBLE_CORRECT;
@@ -1778,7 +1778,8 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(
return FALSE;
if (pEvent->Value().IsEmpty())
return TRUE;
- double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value()));
+ double dEentValue =
+ atof(CFX_ByteString::FromUnicode(pEvent->Value()).c_str());
FX_BOOL bGreaterThan = params[0].ToBool();
double dGreaterThan = params[1].ToDouble();
FX_BOOL bLessThan = params[2].ToBool();
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index d843b60105..7242a144c9 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -414,7 +414,7 @@ FX_BOOL JSGlobalAlternate::SetGlobalVariables(const CFX_ByteString& propname,
const CFX_ByteString& sData,
v8::Local<v8::Object> pData,
bool bDefaultPersistent) {
- if (!propname)
+ if (propname.IsEmpty())
return FALSE;
auto it = m_mapGlobal.find(propname);
diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/pdfwindow/PWL_FontMap.cpp
index 42beab7d21..96ca6ea2ff 100644
--- a/fpdfsdk/pdfwindow/PWL_FontMap.cpp
+++ b/fpdfsdk/pdfwindow/PWL_FontMap.cpp
@@ -306,10 +306,10 @@ CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc,
CPDF_Font* pFont = NULL;
if (sFontName == "ZapfDingbats") {
- pFont = pDoc->AddStandardFont(sFontName, NULL);
+ pFont = pDoc->AddStandardFont(sFontName.c_str(), NULL);
} else {
CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI);
- pFont = pDoc->AddStandardFont(sFontName, &fe);
+ pFont = pDoc->AddStandardFont(sFontName.c_str(), &fe);
}
return pFont;