From 4c3debb3c91f5842784be30a911b52cdabcab7df Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 8 Apr 2016 12:20:38 -0700 Subject: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). The naming is redundant given the base type, and will stand in the way of consolidating Byte and Wide code. BUG= Review URL: https://codereview.chromium.org/1862123003 --- .../fpdf_edit/cpdf_pagecontentgenerator.cpp | 4 +-- core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 31 +++++++++------------- core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp | 2 +- core/fpdfapi/fpdf_font/fpdf_font.cpp | 12 ++++----- core/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 2 +- core/fpdfapi/fpdf_page/cpdf_allstates.cpp | 2 +- core/fpdfapi/fpdf_page/fpdf_page_doc.cpp | 2 +- core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 23 ++++++++-------- core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 2 +- core/fpdfapi/fpdf_parser/cpdf_name.cpp | 2 +- core/fpdfapi/fpdf_parser/cpdf_number.cpp | 2 +- core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp | 2 +- core/fpdfapi/fpdf_parser/cpdf_parser.cpp | 4 +-- .../fpdf_parser/cpdf_standard_security_handler.cpp | 5 ++-- core/fpdfapi/fpdf_parser/cpdf_string.cpp | 2 +- core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp | 4 +-- 16 files changed, 47 insertions(+), 54 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp index af79fd31c1..a484edd6b9 100644 --- a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp @@ -74,12 +74,12 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource( int idnum = 1; while (1) { name.Format("FX%c%d", szType[0], idnum); - if (!pResList->KeyExist(name.AsByteStringC())) { + if (!pResList->KeyExist(name.AsStringC())) { break; } idnum++; } - pResList->AddReference(name.AsByteStringC(), m_pDocument, + pResList->AddReference(name.AsStringC(), m_pDocument, pResourceObj->GetObjNum()); return name; } diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 323602b0e1..c0d2ab0dd3 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -54,7 +54,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, if (pFile->AppendString(" ") < 0) { return -1; } - if ((len = pFile->AppendString(pObj->GetString().AsByteStringC())) < 0) { + if ((len = pFile->AppendString(pObj->GetString().AsStringC())) < 0) { return -1; } offset += len + 1; @@ -62,8 +62,8 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, case CPDF_Object::STRING: { CFX_ByteString str = pObj->GetString(); FX_BOOL bHex = pObj->AsString()->IsHex(); - if ((len = pFile->AppendString( - PDF_EncodeString(str, bHex).AsByteStringC())) < 0) { + if ((len = pFile->AppendString(PDF_EncodeString(str, bHex).AsStringC())) < + 0) { return -1; } offset += len; @@ -74,8 +74,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, return -1; } CFX_ByteString str = pObj->GetString(); - if ((len = pFile->AppendString(PDF_NameEncode(str).AsByteStringC())) < - 0) { + if ((len = pFile->AppendString(PDF_NameEncode(str).AsStringC())) < 0) { return -1; } offset += len + 1; @@ -134,8 +133,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, if (pFile->AppendString("/") < 0) { return -1; } - if ((len = pFile->AppendString(PDF_NameEncode(key).AsByteStringC())) < - 0) { + if ((len = pFile->AppendString(PDF_NameEncode(key).AsStringC())) < 0) { return -1; } offset += len + 1; @@ -214,8 +212,7 @@ int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument, if (pFile->AppendString(("/")) < 0) { return -1; } - if ((len = pFile->AppendString(PDF_NameEncode(key).AsByteStringC())) < - 0) { + if ((len = pFile->AppendString(PDF_NameEncode(key).AsStringC())) < 0) { return -1; } offset += len + 1; @@ -1118,7 +1115,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, if (m_File.AppendString(" ") < 0) { return -1; } - if ((len = m_File.AppendString(pObj->GetString().AsByteStringC())) < 0) { + if ((len = m_File.AppendString(pObj->GetString().AsStringC())) < 0) { return -1; } m_Offset += len + 1; @@ -1128,7 +1125,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, FX_BOOL bHex = pObj->AsString()->IsHex(); if (!m_pCryptoHandler || !bEncrypt) { CFX_ByteString content = PDF_EncodeString(str, bHex); - if ((len = m_File.AppendString(content.AsByteStringC())) < 0) { + if ((len = m_File.AppendString(content.AsStringC())) < 0) { return -1; } m_Offset += len; @@ -1140,7 +1137,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, CFX_ByteString content = PDF_EncodeString( CFX_ByteString((const FX_CHAR*)encryptor.m_pData, encryptor.m_dwSize), bHex); - if ((len = m_File.AppendString(content.AsByteStringC())) < 0) { + if ((len = m_File.AppendString(content.AsStringC())) < 0) { return -1; } m_Offset += len; @@ -1180,8 +1177,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, return -1; } CFX_ByteString str = pObj->GetString(); - if ((len = m_File.AppendString(PDF_NameEncode(str).AsByteStringC())) < - 0) { + if ((len = m_File.AppendString(PDF_NameEncode(str).AsStringC())) < 0) { return -1; } m_Offset += len + 1; @@ -1245,8 +1241,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, if (m_File.AppendString("/") < 0) { return -1; } - if ((len = m_File.AppendString(PDF_NameEncode(key).AsByteStringC())) < - 0) { + if ((len = m_File.AppendString(PDF_NameEncode(key).AsStringC())) < 0) { return -1; } m_Offset += len + 1; @@ -1648,7 +1643,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause* pPause) { str = m_ObjectOffset.GetPtrAt(1) ? "xref\r\n" : "xref\r\n0 1\r\n0000000000 65535 f\r\n"; - if (m_File.AppendString(str.AsByteStringC()) < 0) { + if (m_File.AppendString(str.AsStringC()) < 0) { return -1; } m_Pos = (void*)(uintptr_t)1; @@ -1777,7 +1772,7 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) { if (m_File.AppendString(("/")) < 0) { return -1; } - if (m_File.AppendString(PDF_NameEncode(key).AsByteStringC()) < 0) { + if (m_File.AppendString(PDF_NameEncode(key).AsStringC()) < 0) { return -1; } if (pValue->GetObjNum()) { diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index d70c04c690..04ab9ea863 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -1124,7 +1124,7 @@ CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font, CFX_ByteString name(font); if (PDF_GetStandardFontName(&name) < 0) return nullptr; - return GetPageData()->GetStandardFont(name.AsByteStringC(), pEncoding); + return GetPageData()->GetStandardFont(name.AsStringC(), pEncoding); } void CPDF_Document::DeletePage(int iPage) { diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp index a3adecc764..c405072502 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp @@ -233,9 +233,9 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { break; } high = parser.GetWord(); - uint32_t lowcode = StringToCode(low.AsByteStringC()); - uint32_t highcode = (lowcode & 0xffffff00) | - (StringToCode(high.AsByteStringC()) & 0xff); + uint32_t lowcode = StringToCode(low.AsStringC()); + uint32_t highcode = + (lowcode & 0xffffff00) | (StringToCode(high.AsStringC()) & 0xff); if (highcode == (uint32_t)-1) { break; } @@ -243,7 +243,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { if (start == "[") { for (uint32_t code = lowcode; code <= highcode; code++) { CFX_ByteString dest = parser.GetWord(); - CFX_WideString destcode = StringToWideString(dest.AsByteStringC()); + CFX_WideString destcode = StringToWideString(dest.AsStringC()); int len = destcode.GetLength(); if (len == 0) { continue; @@ -258,11 +258,11 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { } parser.GetWord(); } else { - CFX_WideString destcode = StringToWideString(start.AsByteStringC()); + CFX_WideString destcode = StringToWideString(start.AsStringC()); int len = destcode.GetLength(); uint32_t value = 0; if (len == 1) { - value = StringToCode(start.AsByteStringC()); + value = StringToCode(start.AsStringC()); for (uint32_t code = lowcode; code <= highcode; code++) { m_Map[code] = value++; } diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 78c72a7fef..da6b8de35b 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -440,7 +440,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { } if (m_CodeSeq % 2) { CMap_CodeRange range; - if (CMap_GetCodeRange(range, m_LastWord.AsByteStringC(), word)) { + if (CMap_GetCodeRange(range, m_LastWord.AsStringC(), word)) { m_CodeRanges.Add(range); } } diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp index d81a488d20..f2d637f888 100644 --- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp @@ -115,7 +115,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, CFX_ByteString mode = pArray ? pArray->GetStringAt(0) : pObject->GetString(); - pGeneralState->SetBlendMode(mode.AsByteStringC()); + pGeneralState->SetBlendMode(mode.AsStringC()); if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) { pParser->GetPageObjectHolder()->SetBackgroundAlphaNeeded(TRUE); } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp index 758ce940d2..2dfccb26d7 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -331,7 +331,7 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpace( if (!pCS && pResources) { CPDF_Dictionary* pList = pResources->GetDictBy("ColorSpace"); if (pList) { - pCSObj = pList->GetDirectObjectBy(name.AsByteStringC()); + pCSObj = pList->GetDirectObjectBy(name.AsStringC()); return GetColorSpace(pCSObj, nullptr); } } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 4f304a3b3b..21edc9e0cd 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -566,9 +566,9 @@ void CPDF_StreamContentParser::Handle_BeginImage() { if (!key.IsEmpty()) { uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0; if (dwObjNum) - pDict->SetAtReference(key.AsByteStringC(), m_pDocument, dwObjNum); + pDict->SetAtReference(key.AsStringC(), m_pDocument, dwObjNum); else - pDict->SetAt(key.AsByteStringC(), pObj.release()); + pDict->SetAt(key.AsStringC(), pObj.release()); } } PDF_ReplaceAbbr(pDict); @@ -721,8 +721,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { pList = m_pPageResources->GetDictBy("XObject"); if (!pList) return; - CPDF_Reference* pRes = - ToReference(pList->GetObjectBy(name.AsByteStringC())); + CPDF_Reference* pRes = ToReference(pList->GetObjectBy(name.AsStringC())); if (!pRes) return; @@ -1258,7 +1257,7 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj( if (!pList) { return NULL; } - CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC()); + CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); return pRes; } CPDF_Dictionary* pList = m_pResources->GetDictBy(type); @@ -1270,10 +1269,10 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj( if (!pList) { return NULL; } - CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC()); + CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); return pRes; } - CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC()); + CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); return pRes; } @@ -1766,7 +1765,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) { CPDF_Object* value = it.second; CFX_ByteStringC fullname = PDF_FindFullName(PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), - key.AsByteStringC()); + key.AsStringC()); if (!fullname.IsEmpty()) { AbbrReplacementOp op; op.is_replace_key = true; @@ -1780,7 +1779,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) { CFX_ByteString name = value->GetString(); fullname = PDF_FindFullName(PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), - name.AsByteStringC()); + name.AsStringC()); if (!fullname.IsEmpty()) { AbbrReplacementOp op; op.is_replace_key = false; @@ -1794,9 +1793,9 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) { } for (const auto& op : replacements) { if (op.is_replace_key) - pDict->ReplaceKey(op.key.AsByteStringC(), op.replacement); + pDict->ReplaceKey(op.key.AsStringC(), op.replacement); else - pDict->SetAtName(op.key.AsByteStringC(), op.replacement); + pDict->SetAtName(op.key.AsStringC(), op.replacement); } break; } @@ -1808,7 +1807,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) { CFX_ByteString name = pElement->GetString(); CFX_ByteStringC fullname = PDF_FindFullName( PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), - name.AsByteStringC()); + name.AsStringC()); if (!fullname.IsEmpty()) { pArray->SetAt(i, new CPDF_Name(fullname)); } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 058ac338b2..5ec25d9fde 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -427,7 +427,7 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray, return nullptr; } if (!key.IsEmpty()) { - pDict->SetAt(key.AsByteStringC(), pObj); + pDict->SetAt(key.AsStringC(), pObj); } else { pObj->Release(); } diff --git a/core/fpdfapi/fpdf_parser/cpdf_name.cpp b/core/fpdfapi/fpdf_parser/cpdf_name.cpp index a7adf1b3d6..d641374547 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_name.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_name.cpp @@ -29,7 +29,7 @@ CFX_ByteString CPDF_Name::GetString() const { } CFX_ByteStringC CPDF_Name::GetConstString() const { - return m_Name.AsByteStringC(); + return m_Name.AsStringC(); } void CPDF_Name::SetString(const CFX_ByteString& str) { diff --git a/core/fpdfapi/fpdf_parser/cpdf_number.cpp b/core/fpdfapi/fpdf_parser/cpdf_number.cpp index dbc17d5dd6..a6bace57c9 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_number.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_number.cpp @@ -47,7 +47,7 @@ const CPDF_Number* CPDF_Number::AsNumber() const { } void CPDF_Number::SetString(const CFX_ByteString& str) { - FX_atonum(str.AsByteStringC(), m_bInteger, &m_Integer); + FX_atonum(str.AsStringC(), m_bInteger, &m_Integer); } CFX_ByteString CPDF_Number::GetString() const { diff --git a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp index 17fd891d1b..362991f723 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp @@ -135,7 +135,7 @@ class PDFObjectsTest : public testing::Test { return false; for (CPDF_Dictionary::const_iterator it = dict1->begin(); it != dict1->end(); ++it) { - if (!Equal(it->second, dict2->GetObjectBy(it->first.AsByteStringC()))) + if (!Equal(it->second, dict2->GetObjectBy(it->first.AsStringC()))) return false; } return true; diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp index 15af1ca5c7..4ba43678b8 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -822,10 +822,10 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { uint32_t dwObjNum = pElement ? pElement->GetObjNum() : 0; if (dwObjNum) { - m_pTrailer->SetAtReference(key.AsByteStringC(), + m_pTrailer->SetAtReference(key.AsStringC(), m_pDocument, dwObjNum); } else { - m_pTrailer->SetAt(key.AsByteStringC(), + m_pTrailer->SetAt(key.AsStringC(), pElement->Clone()); } } diff --git a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp index 9846c40d8f..b7ed0315bb 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp @@ -173,7 +173,7 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) { if (stmf_name != strf_name) { return FALSE; } - if (!_LoadCryptInfo(pEncryptDict, strf_name.AsByteStringC(), m_Cipher, + if (!_LoadCryptInfo(pEncryptDict, strf_name.AsStringC(), m_Cipher, m_KeyLen)) { return FALSE; } @@ -196,8 +196,7 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, return FALSE; } } - if (!_LoadCryptInfo(pEncryptDict, strf_name.AsByteStringC(), cipher, - key_len)) { + if (!_LoadCryptInfo(pEncryptDict, strf_name.AsStringC(), cipher, key_len)) { return FALSE; } m_Cipher = cipher; diff --git a/core/fpdfapi/fpdf_parser/cpdf_string.cpp b/core/fpdfapi/fpdf_parser/cpdf_string.cpp index 3f04d125a2..52f6a5a836 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_string.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_string.cpp @@ -32,7 +32,7 @@ CFX_ByteString CPDF_String::GetString() const { } CFX_ByteStringC CPDF_String::GetConstString() const { - return m_String.AsByteStringC(); + return m_String.AsStringC(); } void CPDF_String::SetString(const CFX_ByteString& str) { diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index 3deecf54ff..0190c6e692 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -399,7 +399,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, } } m_Pos = SavedPos; - return new CPDF_Number(word.AsByteStringC()); + return new CPDF_Number(word.AsStringC()); } if (word == "true" || word == "false") @@ -521,7 +521,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( return new CPDF_Reference(pObjList, FXSYS_atoui(word)); } m_Pos = SavedPos; - return new CPDF_Number(word.AsByteStringC()); + return new CPDF_Number(word.AsStringC()); } if (word == "true" || word == "false") -- cgit v1.2.3