summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp5
-rw-r--r--core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp30
-rw-r--r--core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp2
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font.cpp12
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font_cid.cpp2
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_allstates.cpp2
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_doc.cpp2
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser.cpp28
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp2
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_name.cpp2
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_number.cpp2
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp2
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_parser.cpp7
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp8
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_string.cpp2
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp4
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_object.h2
-rw-r--r--core/fpdfdoc/cpvt_color.cpp2
-rw-r--r--core/fpdfdoc/cpvt_fontmap.cpp5
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp19
-rw-r--r--core/fpdfdoc/doc_action.cpp4
-rw-r--r--core/fpdfdoc/doc_annot.cpp4
-rw-r--r--core/fpdfdoc/doc_basic.cpp12
-rw-r--r--core/fpdfdoc/doc_bookmark.cpp4
-rw-r--r--core/fpdfdoc/doc_form.cpp5
-rw-r--r--core/fpdfdoc/doc_formcontrol.cpp20
-rw-r--r--core/fpdfdoc/doc_formfield.cpp4
-rw-r--r--core/fpdfdoc/doc_link.cpp4
-rw-r--r--core/fpdfdoc/doc_ocg.cpp10
-rw-r--r--core/fpdfdoc/doc_tagged.cpp9
-rw-r--r--core/fpdfdoc/doc_utils.cpp67
-rw-r--r--core/fxcrt/fx_basic_buffer.cpp2
-rw-r--r--core/fxcrt/fx_xml_parser.cpp7
-rw-r--r--core/fxcrt/fxcrt_posix.cpp2
-rw-r--r--core/fxcrt/include/fx_basic.h10
-rw-r--r--core/fxcrt/include/fx_string.h30
-rw-r--r--core/fxge/ge/fx_ge_ps.cpp2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp2
38 files changed, 187 insertions, 151 deletions
diff --git a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
index 6c5339128b..af79fd31c1 100644
--- a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
@@ -74,12 +74,13 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource(
int idnum = 1;
while (1) {
name.Format("FX%c%d", szType[0], idnum);
- if (!pResList->KeyExist(name)) {
+ if (!pResList->KeyExist(name.AsByteStringC())) {
break;
}
idnum++;
}
- pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum());
+ pResList->AddReference(name.AsByteStringC(), m_pDocument,
+ pResourceObj->GetObjNum());
return name;
}
void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf,
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index 21934d35c4..323602b0e1 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())) < 0) {
+ if ((len = pFile->AppendString(pObj->GetString().AsByteStringC())) < 0) {
return -1;
}
offset += len + 1;
@@ -62,7 +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))) < 0) {
+ if ((len = pFile->AppendString(
+ PDF_EncodeString(str, bHex).AsByteStringC())) < 0) {
return -1;
}
offset += len;
@@ -73,7 +74,8 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
return -1;
}
CFX_ByteString str = pObj->GetString();
- if ((len = pFile->AppendString(PDF_NameEncode(str))) < 0) {
+ if ((len = pFile->AppendString(PDF_NameEncode(str).AsByteStringC())) <
+ 0) {
return -1;
}
offset += len + 1;
@@ -132,7 +134,8 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
if (pFile->AppendString("/") < 0) {
return -1;
}
- if ((len = pFile->AppendString(PDF_NameEncode(key))) < 0) {
+ if ((len = pFile->AppendString(PDF_NameEncode(key).AsByteStringC())) <
+ 0) {
return -1;
}
offset += len + 1;
@@ -211,7 +214,8 @@ int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument,
if (pFile->AppendString(("/")) < 0) {
return -1;
}
- if ((len = pFile->AppendString(PDF_NameEncode(key))) < 0) {
+ if ((len = pFile->AppendString(PDF_NameEncode(key).AsByteStringC())) <
+ 0) {
return -1;
}
offset += len + 1;
@@ -1114,7 +1118,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
if (m_File.AppendString(" ") < 0) {
return -1;
}
- if ((len = m_File.AppendString(pObj->GetString())) < 0) {
+ if ((len = m_File.AppendString(pObj->GetString().AsByteStringC())) < 0) {
return -1;
}
m_Offset += len + 1;
@@ -1124,7 +1128,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)) < 0) {
+ if ((len = m_File.AppendString(content.AsByteStringC())) < 0) {
return -1;
}
m_Offset += len;
@@ -1136,7 +1140,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)) < 0) {
+ if ((len = m_File.AppendString(content.AsByteStringC())) < 0) {
return -1;
}
m_Offset += len;
@@ -1176,7 +1180,8 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
return -1;
}
CFX_ByteString str = pObj->GetString();
- if ((len = m_File.AppendString(PDF_NameEncode(str))) < 0) {
+ if ((len = m_File.AppendString(PDF_NameEncode(str).AsByteStringC())) <
+ 0) {
return -1;
}
m_Offset += len + 1;
@@ -1240,7 +1245,8 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
if (m_File.AppendString("/") < 0) {
return -1;
}
- if ((len = m_File.AppendString(PDF_NameEncode(key))) < 0) {
+ if ((len = m_File.AppendString(PDF_NameEncode(key).AsByteStringC())) <
+ 0) {
return -1;
}
m_Offset += len + 1;
@@ -1642,7 +1648,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) < 0) {
+ if (m_File.AppendString(str.AsByteStringC()) < 0) {
return -1;
}
m_Pos = (void*)(uintptr_t)1;
@@ -1771,7 +1777,7 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
if (m_File.AppendString(("/")) < 0) {
return -1;
}
- if (m_File.AppendString(PDF_NameEncode(key)) < 0) {
+ if (m_File.AppendString(PDF_NameEncode(key).AsByteStringC()) < 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 0f75cb04a8..d70c04c690 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, pEncoding);
+ return GetPageData()->GetStandardFont(name.AsByteStringC(), 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 ce2390ec08..aff2b72960 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);
- uint32_t highcode =
- (lowcode & 0xffffff00) | (StringToCode(high) & 0xff);
+ uint32_t lowcode = StringToCode(low.AsByteStringC());
+ uint32_t highcode = (lowcode & 0xffffff00) |
+ (StringToCode(high.AsByteStringC()) & 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);
+ CFX_WideString destcode = StringToWideString(dest.AsByteStringC());
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);
+ CFX_WideString destcode = StringToWideString(start.AsByteStringC());
int len = destcode.GetLength();
uint32_t value = 0;
if (len == 1) {
- value = StringToCode(start);
+ value = StringToCode(start.AsByteStringC());
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 2552a3c0a6..fb3707f498 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, word)) {
+ if (CMap_GetCodeRange(range, m_LastWord.AsByteStringC(), word)) {
m_CodeRanges.Add(range);
}
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
index 159de584ee..d81a488d20 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);
+ pGeneralState->SetBlendMode(mode.AsByteStringC());
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 9f4ad5a7d5..758ce940d2 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);
+ pCSObj = pList->GetDirectObjectBy(name.AsByteStringC());
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 daddb9f05b..4f304a3b3b 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, m_pDocument, dwObjNum);
+ pDict->SetAtReference(key.AsByteStringC(), m_pDocument, dwObjNum);
else
- pDict->SetAt(key, pObj.release());
+ pDict->SetAt(key.AsByteStringC(), pObj.release());
}
}
PDF_ReplaceAbbr(pDict);
@@ -721,7 +721,8 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
pList = m_pPageResources->GetDictBy("XObject");
if (!pList)
return;
- CPDF_Reference* pRes = ToReference(pList->GetObjectBy(name));
+ CPDF_Reference* pRes =
+ ToReference(pList->GetObjectBy(name.AsByteStringC()));
if (!pRes)
return;
@@ -1257,7 +1258,7 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
if (!pList) {
return NULL;
}
- CPDF_Object* pRes = pList->GetDirectObjectBy(name);
+ CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC());
return pRes;
}
CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
@@ -1269,10 +1270,10 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
if (!pList) {
return NULL;
}
- CPDF_Object* pRes = pList->GetDirectObjectBy(name);
+ CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC());
return pRes;
}
- CPDF_Object* pRes = pList->GetDirectObjectBy(name);
+ CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC());
return pRes;
}
@@ -1763,8 +1764,9 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
for (const auto& it : *pDict) {
CFX_ByteString key = it.first;
CPDF_Object* value = it.second;
- CFX_ByteStringC fullname = PDF_FindFullName(
- PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key);
+ CFX_ByteStringC fullname =
+ PDF_FindFullName(PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr),
+ key.AsByteStringC());
if (!fullname.IsEmpty()) {
AbbrReplacementOp op;
op.is_replace_key = true;
@@ -1777,7 +1779,8 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
if (value->IsName()) {
CFX_ByteString name = value->GetString();
fullname = PDF_FindFullName(PDF_InlineValueAbbr,
- FX_ArraySize(PDF_InlineValueAbbr), name);
+ FX_ArraySize(PDF_InlineValueAbbr),
+ name.AsByteStringC());
if (!fullname.IsEmpty()) {
AbbrReplacementOp op;
op.is_replace_key = false;
@@ -1791,9 +1794,9 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
}
for (const auto& op : replacements) {
if (op.is_replace_key)
- pDict->ReplaceKey(op.key, op.replacement);
+ pDict->ReplaceKey(op.key.AsByteStringC(), op.replacement);
else
- pDict->SetAtName(op.key, op.replacement);
+ pDict->SetAtName(op.key.AsByteStringC(), op.replacement);
}
break;
}
@@ -1804,7 +1807,8 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
if (pElement->IsName()) {
CFX_ByteString name = pElement->GetString();
CFX_ByteStringC fullname = PDF_FindFullName(
- PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name);
+ PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr),
+ name.AsByteStringC());
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 a5db2d6d20..a3c88c00df 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, pObj);
+ pDict->SetAt(key.AsByteStringC(), pObj);
} else {
pObj->Release();
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_name.cpp b/core/fpdfapi/fpdf_parser/cpdf_name.cpp
index db37754b66..a7adf1b3d6 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 CFX_ByteStringC(m_Name);
+ return m_Name.AsByteStringC();
}
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 d2f0503bc1..dbc17d5dd6 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, m_bInteger, &m_Integer);
+ FX_atonum(str.AsByteStringC(), 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 2069a161ea..6c1738d5a6 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)))
+ if (!Equal(it->second, dict2->GetObjectBy(it->first.AsByteStringC())))
return false;
}
return true;
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
index 305401525c..73ca71ef1a 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
@@ -822,10 +822,11 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
uint32_t dwObjNum =
pElement ? pElement->GetObjNum() : 0;
if (dwObjNum) {
- m_pTrailer->SetAtReference(key, m_pDocument,
- dwObjNum);
+ m_pTrailer->SetAtReference(key.AsByteStringC(),
+ m_pDocument, dwObjNum);
} else {
- m_pTrailer->SetAt(key, pElement->Clone());
+ m_pTrailer->SetAt(key.AsByteStringC(),
+ 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 ac7667c3ea..9846c40d8f 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp
@@ -166,14 +166,15 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
m_Revision = pEncryptDict->GetIntegerBy("R");
m_Permissions = pEncryptDict->GetIntegerBy("P", -1);
if (m_Version < 4) {
- return _LoadCryptInfo(pEncryptDict, CFX_ByteString(), m_Cipher, m_KeyLen);
+ return _LoadCryptInfo(pEncryptDict, CFX_ByteStringC(), m_Cipher, m_KeyLen);
}
CFX_ByteString stmf_name = pEncryptDict->GetStringBy("StmF");
CFX_ByteString strf_name = pEncryptDict->GetStringBy("StrF");
if (stmf_name != strf_name) {
return FALSE;
}
- if (!_LoadCryptInfo(pEncryptDict, strf_name, m_Cipher, m_KeyLen)) {
+ if (!_LoadCryptInfo(pEncryptDict, strf_name.AsByteStringC(), m_Cipher,
+ m_KeyLen)) {
return FALSE;
}
return TRUE;
@@ -195,7 +196,8 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
return FALSE;
}
}
- if (!_LoadCryptInfo(pEncryptDict, strf_name, cipher, key_len)) {
+ if (!_LoadCryptInfo(pEncryptDict, strf_name.AsByteStringC(), 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 9a88e937ab..3f04d125a2 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 CFX_ByteStringC(m_String);
+ return m_String.AsByteStringC();
}
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 5a3db292e0..d04a682b77 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);
+ return new CPDF_Number(word.AsByteStringC());
}
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);
+ return new CPDF_Number(word.AsByteStringC());
}
if (word == "true" || word == "false")
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_object.h b/core/fpdfapi/fpdf_parser/include/cpdf_object.h
index 802cbbc638..6cdaaf58fd 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_object.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_object.h
@@ -46,6 +46,8 @@ class CPDF_Object {
void Release();
virtual CFX_ByteString GetString() const;
+
+ // Note: |this| must outlive the use of |GetConstString|'s result.
virtual CFX_ByteStringC GetConstString() const;
virtual CFX_WideString GetUnicodeText() const;
virtual FX_FLOAT GetNumber() const;
diff --git a/core/fpdfdoc/cpvt_color.cpp b/core/fpdfdoc/cpvt_color.cpp
index afeff23e15..7ddb9df0d0 100644
--- a/core/fpdfdoc/cpvt_color.cpp
+++ b/core/fpdfdoc/cpvt_color.cpp
@@ -10,7 +10,7 @@
// Static.
CPVT_Color CPVT_Color::ParseColor(const CFX_ByteString& str) {
- CPDF_SimpleParser syntax(str);
+ CPDF_SimpleParser syntax(str.AsByteStringC());
if (syntax.FindTagParamFromStart("g", 1))
return CPVT_Color(CPVT_Color::kGray, FX_atof(syntax.GetWord()));
diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp
index 529f85169e..0aa7ac3486 100644
--- a/core/fpdfdoc/cpvt_fontmap.cpp
+++ b/core/fpdfdoc/cpvt_fontmap.cpp
@@ -38,8 +38,9 @@ void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc,
return;
if (CPDF_Dictionary* pFontList = pResDict->GetDictBy("Font")) {
- if (!pFontList->KeyExist(sSysFontAlias))
- pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->GetFontDict());
+ if (!pFontList->KeyExist(sSysFontAlias.AsByteStringC()))
+ pFontList->SetAtReference(sSysFontAlias.AsByteStringC(), pDoc,
+ pPDFFont->GetFontDict());
}
pSysFont = pPDFFont;
}
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index dd935de61e..c5e2cc7fab 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -36,7 +36,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
if (DA.IsEmpty())
return FALSE;
- CPDF_SimpleParser syntax(DA);
+ CPDF_SimpleParser syntax(DA.AsByteStringC());
syntax.FindTagParamFromStart("Tf", 2);
CFX_ByteString sFontName = syntax.GetWord();
sFontName = PDF_NameDecode(sFontName);
@@ -54,12 +54,12 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
}
CPDF_Dictionary* pDRFontDict = pDRDict ? pDRDict->GetDictBy("Font") : nullptr;
if (pDRFontDict) {
- pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
+ pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsByteStringC());
if (!pFontDict && !bUseFormRes) {
pDRDict = pFormDict->GetDictBy("DR");
pDRFontDict = pDRDict->GetDictBy("Font");
if (pDRFontDict)
- pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
+ pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsByteStringC());
}
}
if (!pDRFontDict)
@@ -72,7 +72,8 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
pFontDict->SetAtName("BaseFont", "Helvetica");
pFontDict->SetAtName("Encoding", "WinAnsiEncoding");
pDoc->AddIndirectObject(pFontDict);
- pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict);
+ pDRFontDict->SetAtReference(sFontName.Mid(1).AsByteStringC(), pDoc,
+ pFontDict);
}
CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
if (!pDefFont)
@@ -189,8 +190,9 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
pStreamResFontList = new CPDF_Dictionary;
pStreamResList->SetAt("Font", pStreamResFontList);
}
- if (!pStreamResFontList->KeyExist(sFontName))
- pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict);
+ if (!pStreamResFontList->KeyExist(sFontName.AsByteStringC()))
+ pStreamResFontList->SetAtReference(sFontName.AsByteStringC(), pDoc,
+ pFontDict);
} else {
pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone());
pStreamResList = pStreamDict->GetDictBy("Resources");
@@ -435,8 +437,9 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
pStreamResFontList = new CPDF_Dictionary;
pStreamResList->SetAt("Font", pStreamResFontList);
}
- if (!pStreamResFontList->KeyExist(sFontName))
- pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict);
+ if (!pStreamResFontList->KeyExist(sFontName.AsByteStringC()))
+ pStreamResFontList->SetAtReference(sFontName.AsByteStringC(), pDoc,
+ pFontDict);
} else {
pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone());
pStreamResList = pStreamDict->GetDictBy("Resources");
diff --git a/core/fpdfdoc/doc_action.cpp b/core/fpdfdoc/doc_action.cpp
index 2f08bfa3af..9a43b58e98 100644
--- a/core/fpdfdoc/doc_action.cpp
+++ b/core/fpdfdoc/doc_action.cpp
@@ -38,8 +38,8 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
}
if (pDest->IsString() || pDest->IsName()) {
CPDF_NameTree name_tree(pDoc, "Dests");
- CFX_ByteStringC name = pDest->GetString();
- return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name));
+ return CPDF_Dest(
+ name_tree.LookupNamedDest(pDoc, pDest->GetString().AsByteStringC()));
}
if (CPDF_Array* pArray = pDest->AsArray())
return CPDF_Dest(pArray);
diff --git a/core/fpdfdoc/doc_annot.cpp b/core/fpdfdoc/doc_annot.cpp
index 276516589a..ca900acb9a 100644
--- a/core/fpdfdoc/doc_annot.cpp
+++ b/core/fpdfdoc/doc_annot.cpp
@@ -181,12 +181,12 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
CPDF_Dictionary* pDict = pAnnotDict->GetDictBy("Parent");
value = pDict ? pDict->GetStringBy("V") : CFX_ByteString();
}
- if (value.IsEmpty() || !pDict->KeyExist(value))
+ if (value.IsEmpty() || !pDict->KeyExist(value.AsByteStringC()))
as = "Off";
else
as = value;
}
- return pDict->GetStreamBy(as);
+ return pDict->GetStreamBy(as.AsByteStringC());
}
return nullptr;
}
diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp
index c711709e73..0c7f895405 100644
--- a/core/fpdfdoc/doc_basic.cpp
+++ b/core/fpdfdoc/doc_basic.cpp
@@ -90,12 +90,13 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
if (pLimits) {
CFX_ByteString csLeft = pLimits->GetStringAt(0);
CFX_ByteString csRight = pLimits->GetStringAt(1);
- if (csLeft.Compare(csRight) > 0) {
+ if (csLeft.Compare(csRight.AsByteStringC()) > 0) {
CFX_ByteString csTmp = csRight;
csRight = csLeft;
csLeft = csTmp;
}
- if (csName.Compare(csLeft) < 0 || csName.Compare(csRight) > 0) {
+ if (csName.Compare(csLeft.AsByteStringC()) < 0 ||
+ csName.Compare(csRight.AsByteStringC()) > 0) {
return NULL;
}
}
@@ -104,7 +105,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
uint32_t dwCount = pNames->GetCount() / 2;
for (uint32_t i = 0; i < dwCount; i++) {
CFX_ByteString csValue = pNames->GetStringAt(i * 2);
- int32_t iCompare = csValue.Compare(csName);
+ int32_t iCompare = csValue.Compare(csName.AsByteStringC());
if (iCompare <= 0) {
if (ppFind) {
*ppFind = pNames;
@@ -500,7 +501,7 @@ int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
CFX_ByteString bsOrig = bsLabel;
for (int i = 0; i < nPages; i++) {
bsLbl = PDF_EncodeText(GetLabel(i));
- if (!bsLbl.Compare(bsOrig)) {
+ if (!bsLbl.Compare(bsOrig.AsByteStringC())) {
return i;
}
}
@@ -512,6 +513,5 @@ int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
return -1;
}
int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
- CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr());
- return GetPageByLabel(bsLabel);
+ return GetPageByLabel(PDF_EncodeText(wsLabel.GetPtr()).AsByteStringC());
}
diff --git a/core/fpdfdoc/doc_bookmark.cpp b/core/fpdfdoc/doc_bookmark.cpp
index 22ff7921ef..35a04043fe 100644
--- a/core/fpdfdoc/doc_bookmark.cpp
+++ b/core/fpdfdoc/doc_bookmark.cpp
@@ -80,8 +80,8 @@ CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const {
return CPDF_Dest();
if (pDest->IsString() || pDest->IsName()) {
CPDF_NameTree name_tree(pDocument, "Dests");
- CFX_ByteStringC name = pDest->GetString();
- return CPDF_Dest(name_tree.LookupNamedDest(pDocument, name));
+ return CPDF_Dest(name_tree.LookupNamedDest(
+ pDocument, pDest->GetString().AsByteStringC()));
}
if (CPDF_Array* pArray = pDest->AsArray())
return CPDF_Dest(pArray);
diff --git a/core/fpdfdoc/doc_form.cpp b/core/fpdfdoc/doc_form.cpp
index 2a6d739549..aa4b5c9f30 100644
--- a/core/fpdfdoc/doc_form.cpp
+++ b/core/fpdfdoc/doc_form.cpp
@@ -343,8 +343,9 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName(
int num = 0;
CFX_ByteString bsNum;
while (TRUE) {
- if (!pDict->KeyExist(csTmp + bsNum)) {
- return csTmp + bsNum;
+ CFX_ByteString csKey = csTmp + bsNum;
+ if (!pDict->KeyExist(csKey.AsByteStringC())) {
+ return csKey;
}
if (m < iCount) {
csTmp += csStr[m++];
diff --git a/core/fpdfdoc/doc_formcontrol.cpp b/core/fpdfdoc/doc_formcontrol.cpp
index 1fcc4a386b..0a0a8c9a03 100644
--- a/core/fpdfdoc/doc_formcontrol.cpp
+++ b/core/fpdfdoc/doc_formcontrol.cpp
@@ -78,7 +78,7 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
continue;
}
if (csKey2 != "Off") {
- pSubDict->ReplaceKey(csKey2, csValue);
+ pSubDict->ReplaceKey(csKey2.AsByteStringC(), csValue.AsByteStringC());
break;
}
}
@@ -202,7 +202,7 @@ CPDF_ApSettings CPDF_FormControl::GetMK() const {
}
bool CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) const {
- return GetMK().HasMKEntry(csEntry);
+ return GetMK().HasMKEntry(csEntry.AsByteStringC());
}
int CPDF_FormControl::GetRotation() {
@@ -210,24 +210,24 @@ int CPDF_FormControl::GetRotation() {
}
FX_ARGB CPDF_FormControl::GetColor(int& iColorType, CFX_ByteString csEntry) {
- return GetMK().GetColor(iColorType, csEntry);
+ return GetMK().GetColor(iColorType, csEntry.AsByteStringC());
}
FX_FLOAT CPDF_FormControl::GetOriginalColor(int index, CFX_ByteString csEntry) {
- return GetMK().GetOriginalColor(index, csEntry);
+ return GetMK().GetOriginalColor(index, csEntry.AsByteStringC());
}
void CPDF_FormControl::GetOriginalColor(int& iColorType,
FX_FLOAT fc[4],
CFX_ByteString csEntry) {
- GetMK().GetOriginalColor(iColorType, fc, csEntry);
+ GetMK().GetOriginalColor(iColorType, fc, csEntry.AsByteStringC());
}
CFX_WideString CPDF_FormControl::GetCaption(CFX_ByteString csEntry) {
- return GetMK().GetCaption(csEntry);
+ return GetMK().GetCaption(csEntry.AsByteStringC());
}
CPDF_Stream* CPDF_FormControl::GetIcon(CFX_ByteString csEntry) {
- return GetMK().GetIcon(csEntry);
+ return GetMK().GetIcon(csEntry.AsByteStringC());
}
CPDF_IconFit CPDF_FormControl::GetIconFit() {
@@ -286,7 +286,8 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
if (CPDF_Dictionary* pDict = ToDictionary(pObj)) {
CPDF_Dictionary* pFonts = pDict->GetDictBy("Font");
if (pFonts) {
- CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag);
+ CPDF_Dictionary* pElement =
+ pFonts->GetDictBy(csFontNameTag.AsByteStringC());
if (pElement) {
CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement);
if (pFont) {
@@ -303,7 +304,8 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
if (CPDF_Dictionary* pDict = ToDictionary(pObj)) {
CPDF_Dictionary* pFonts = pDict->GetDictBy("Font");
if (pFonts) {
- CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag);
+ CPDF_Dictionary* pElement =
+ pFonts->GetDictBy(csFontNameTag.AsByteStringC());
if (pElement) {
CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement);
if (pFont) {
diff --git a/core/fpdfdoc/doc_formfield.cpp b/core/fpdfdoc/doc_formfield.cpp
index 0f8b3dd5ea..931f9e18d9 100644
--- a/core/fpdfdoc/doc_formfield.cpp
+++ b/core/fpdfdoc/doc_formfield.cpp
@@ -1054,7 +1054,7 @@ void CPDF_FormField::LoadDA() {
if (DA.IsEmpty()) {
return;
}
- CPDF_SimpleParser syntax(DA);
+ CPDF_SimpleParser syntax(DA.AsByteStringC());
syntax.FindTagParamFromStart("Tf", 2);
CFX_ByteString font_name = syntax.GetWord();
CPDF_Dictionary* pFontDict = NULL;
@@ -1062,7 +1062,7 @@ void CPDF_FormField::LoadDA() {
m_pForm->m_pFormDict->GetDictBy("DR")->GetDictBy("Font"))
pFontDict = m_pForm->m_pFormDict->GetDictBy("DR")
->GetDictBy("Font")
- ->GetDictBy(font_name);
+ ->GetDictBy(font_name.AsByteStringC());
if (!pFontDict) {
return;
diff --git a/core/fpdfdoc/doc_link.cpp b/core/fpdfdoc/doc_link.cpp
index 723955f9ea..d86bf203e4 100644
--- a/core/fpdfdoc/doc_link.cpp
+++ b/core/fpdfdoc/doc_link.cpp
@@ -81,8 +81,8 @@ CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) {
if (pDest->IsString() || pDest->IsName()) {
CPDF_NameTree name_tree(pDoc, "Dests");
- CFX_ByteStringC name = pDest->GetString();
- return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name));
+ return CPDF_Dest(
+ name_tree.LookupNamedDest(pDoc, pDest->GetString().AsByteStringC()));
}
if (CPDF_Array* pArray = pDest->AsArray())
return CPDF_Dest(pArray);
diff --git a/core/fpdfdoc/doc_ocg.cpp b/core/fpdfdoc/doc_ocg.cpp
index a739c1675c..7464936b62 100644
--- a/core/fpdfdoc/doc_ocg.cpp
+++ b/core/fpdfdoc/doc_ocg.cpp
@@ -142,7 +142,7 @@ FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig,
if (!pState) {
continue;
}
- bState = pState->GetStringBy(csFind) != "OFF";
+ bState = pState->GetStringBy(csFind.AsByteStringC()) != "OFF";
}
}
return bState;
@@ -154,11 +154,11 @@ FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const {
CFX_ByteString csState = FPDFDOC_OCG_GetUsageTypeString(m_eUsageType);
CPDF_Dictionary* pUsage = pOCGDict->GetDictBy("Usage");
if (pUsage) {
- CPDF_Dictionary* pState = pUsage->GetDictBy(csState);
+ CPDF_Dictionary* pState = pUsage->GetDictBy(csState.AsByteStringC());
if (pState) {
CFX_ByteString csFind = csState + "State";
- if (pState->KeyExist(csFind)) {
- return pState->GetStringBy(csFind) != "OFF";
+ if (pState->KeyExist(csFind.AsByteStringC())) {
+ return pState->GetStringBy(csFind.AsByteStringC()) != "OFF";
}
}
if (csState != "View") {
@@ -169,7 +169,7 @@ FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const {
}
}
FX_BOOL bDefValid = FALSE;
- return LoadOCGStateFromConfig(csState, pOCGDict, bDefValid);
+ return LoadOCGStateFromConfig(csState.AsByteStringC(), pOCGDict, bDefValid);
}
FX_BOOL CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) {
diff --git a/core/fpdfdoc/doc_tagged.cpp b/core/fpdfdoc/doc_tagged.cpp
index 684789acc2..2a3554c499 100644
--- a/core/fpdfdoc/doc_tagged.cpp
+++ b/core/fpdfdoc/doc_tagged.cpp
@@ -205,7 +205,8 @@ CPDF_StructElementImpl::CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree,
m_pDict = pDict;
m_Type = pDict->GetStringBy("S");
if (pTree->m_pRoleMap) {
- CFX_ByteString mapped = pTree->m_pRoleMap->GetStringBy(m_Type);
+ CFX_ByteString mapped =
+ pTree->m_pRoleMap->GetStringBy(m_Type.AsByteStringC());
if (!mapped.IsEmpty()) {
m_Type = mapped;
}
@@ -373,14 +374,16 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner,
if (CPDF_Array* pArray = pC->AsArray()) {
for (uint32_t i = 0; i < pArray->GetCount(); i++) {
CFX_ByteString class_name = pArray->GetStringAt(i);
- CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name);
+ CPDF_Dictionary* pClassDict =
+ pClassMap->GetDictBy(class_name.AsByteStringC());
if (pClassDict && pClassDict->GetStringBy("O") == owner)
return pClassDict->GetDirectObjectBy(name);
}
return nullptr;
}
CFX_ByteString class_name = pC->GetString();
- CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name);
+ CPDF_Dictionary* pClassDict =
+ pClassMap->GetDictBy(class_name.AsByteStringC());
if (pClassDict && pClassDict->GetStringBy("O") == owner)
return pClassDict->GetDirectObjectBy(name);
return nullptr;
diff --git a/core/fpdfdoc/doc_utils.cpp b/core/fpdfdoc/doc_utils.cpp
index f83d001af5..d3b3cac627 100644
--- a/core/fpdfdoc/doc_utils.cpp
+++ b/core/fpdfdoc/doc_utils.cpp
@@ -82,7 +82,7 @@ FX_BOOL CPDF_DefaultAppearance::HasFont() {
if (m_csDA.IsEmpty()) {
return FALSE;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
return syntax.FindTagParamFromStart("Tf", 2);
}
CFX_ByteString CPDF_DefaultAppearance::GetFontString() {
@@ -90,7 +90,7 @@ CFX_ByteString CPDF_DefaultAppearance::GetFontString() {
if (m_csDA.IsEmpty()) {
return csFont;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
if (syntax.FindTagParamFromStart("Tf", 2)) {
csFont += (CFX_ByteString)syntax.GetWord();
csFont += " ";
@@ -107,11 +107,11 @@ void CPDF_DefaultAppearance::GetFont(CFX_ByteString& csFontNameTag,
if (m_csDA.IsEmpty()) {
return;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
if (syntax.FindTagParamFromStart("Tf", 2)) {
- csFontNameTag = (CFX_ByteString)syntax.GetWord();
+ csFontNameTag = CFX_ByteString(syntax.GetWord());
csFontNameTag.Delete(0, 1);
- fFontSize = FX_atof((CFX_ByteString)syntax.GetWord());
+ fFontSize = FX_atof(syntax.GetWord());
}
csFontNameTag = PDF_NameDecode(csFontNameTag);
}
@@ -119,7 +119,7 @@ FX_BOOL CPDF_DefaultAppearance::HasColor(FX_BOOL bStrokingOperation) {
if (m_csDA.IsEmpty()) {
return FALSE;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
return TRUE;
}
@@ -134,7 +134,7 @@ CFX_ByteString CPDF_DefaultAppearance::GetColorString(
if (m_csDA.IsEmpty()) {
return csColor;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
csColor += (CFX_ByteString)syntax.GetWord();
csColor += " ";
@@ -174,25 +174,25 @@ void CPDF_DefaultAppearance::GetColor(int& iColorType,
if (m_csDA.IsEmpty()) {
return;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
iColorType = COLORTYPE_GRAY;
- fc[0] = FX_atof((CFX_ByteString)syntax.GetWord());
+ fc[0] = FX_atof(syntax.GetWord());
return;
}
if (syntax.FindTagParamFromStart(bStrokingOperation ? "RG" : "rg", 3)) {
iColorType = COLORTYPE_RGB;
- fc[0] = FX_atof((CFX_ByteString)syntax.GetWord());
- fc[1] = FX_atof((CFX_ByteString)syntax.GetWord());
- fc[2] = FX_atof((CFX_ByteString)syntax.GetWord());
+ fc[0] = FX_atof(syntax.GetWord());
+ fc[1] = FX_atof(syntax.GetWord());
+ fc[2] = FX_atof(syntax.GetWord());
return;
}
if (syntax.FindTagParamFromStart(bStrokingOperation ? "K" : "k", 4)) {
iColorType = COLORTYPE_CMYK;
- fc[0] = FX_atof((CFX_ByteString)syntax.GetWord());
- fc[1] = FX_atof((CFX_ByteString)syntax.GetWord());
- fc[2] = FX_atof((CFX_ByteString)syntax.GetWord());
- fc[3] = FX_atof((CFX_ByteString)syntax.GetWord());
+ fc[0] = FX_atof(syntax.GetWord());
+ fc[1] = FX_atof(syntax.GetWord());
+ fc[2] = FX_atof(syntax.GetWord());
+ fc[3] = FX_atof(syntax.GetWord());
}
}
void CPDF_DefaultAppearance::GetColor(FX_ARGB& color,
@@ -203,27 +203,27 @@ void CPDF_DefaultAppearance::GetColor(FX_ARGB& color,
if (m_csDA.IsEmpty()) {
return;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
iColorType = COLORTYPE_GRAY;
- FX_FLOAT g = FX_atof((CFX_ByteString)syntax.GetWord()) * 255 + 0.5f;
+ FX_FLOAT g = FX_atof(syntax.GetWord()) * 255 + 0.5f;
color = ArgbEncode(255, (int)g, (int)g, (int)g);
return;
}
if (syntax.FindTagParamFromStart(bStrokingOperation ? "RG" : "rg", 3)) {
iColorType = COLORTYPE_RGB;
- FX_FLOAT r = FX_atof((CFX_ByteString)syntax.GetWord()) * 255 + 0.5f;
- FX_FLOAT g = FX_atof((CFX_ByteString)syntax.GetWord()) * 255 + 0.5f;
- FX_FLOAT b = FX_atof((CFX_ByteString)syntax.GetWord()) * 255 + 0.5f;
+ FX_FLOAT r = FX_atof(syntax.GetWord()) * 255 + 0.5f;
+ FX_FLOAT g = FX_atof(syntax.GetWord()) * 255 + 0.5f;
+ FX_FLOAT b = FX_atof(syntax.GetWord()) * 255 + 0.5f;
color = ArgbEncode(255, (int)r, (int)g, (int)b);
return;
}
if (syntax.FindTagParamFromStart(bStrokingOperation ? "K" : "k", 4)) {
iColorType = COLORTYPE_CMYK;
- FX_FLOAT c = FX_atof((CFX_ByteString)syntax.GetWord());
- FX_FLOAT m = FX_atof((CFX_ByteString)syntax.GetWord());
- FX_FLOAT y = FX_atof((CFX_ByteString)syntax.GetWord());
- FX_FLOAT k = FX_atof((CFX_ByteString)syntax.GetWord());
+ FX_FLOAT c = FX_atof(syntax.GetWord());
+ FX_FLOAT m = FX_atof(syntax.GetWord());
+ FX_FLOAT y = FX_atof(syntax.GetWord());
+ FX_FLOAT k = FX_atof(syntax.GetWord());
FX_FLOAT r = 1.0f - std::min(1.0f, c + k);
FX_FLOAT g = 1.0f - std::min(1.0f, m + k);
FX_FLOAT b = 1.0f - std::min(1.0f, y + k);
@@ -235,7 +235,7 @@ FX_BOOL CPDF_DefaultAppearance::HasTextMatrix() {
if (m_csDA.IsEmpty()) {
return FALSE;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
return syntax.FindTagParamFromStart("Tm", 6);
}
CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() {
@@ -243,7 +243,7 @@ CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() {
if (m_csDA.IsEmpty()) {
return csTM;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
if (syntax.FindTagParamFromStart("Tm", 6)) {
for (int i = 0; i < 6; i++) {
csTM += (CFX_ByteString)syntax.GetWord();
@@ -258,11 +258,11 @@ CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() {
if (m_csDA.IsEmpty()) {
return tm;
}
- CPDF_SimpleParser syntax(m_csDA);
+ CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
if (syntax.FindTagParamFromStart("Tm", 6)) {
FX_FLOAT f[6];
for (int i = 0; i < 6; i++) {
- f[i] = FX_atof((CFX_ByteString)syntax.GetWord());
+ f[i] = FX_atof(syntax.GetWord());
}
tm.Set(f[0], f[1], f[2], f[3], f[4], f[5]);
}
@@ -387,7 +387,7 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
if (!pFonts) {
return NULL;
}
- CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias);
+ CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias.AsByteStringC());
if (!pElement) {
return NULL;
}
@@ -606,7 +606,8 @@ void AddInterFormFont(CPDF_Dictionary*& pFormDict,
csNameTag.Remove(' ');
csNameTag =
CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag);
- pFonts->SetAtReference(csNameTag, pDocument, pFont->GetFontDict());
+ pFonts->SetAtReference(csNameTag.AsByteStringC(), pDocument,
+ pFont->GetFontDict());
}
CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
@@ -650,7 +651,7 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) {
}
CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR");
CPDF_Dictionary* pFonts = pDR->GetDictBy("Font");
- pFonts->RemoveAt(csTag);
+ pFonts->RemoveAt(csTag.AsByteStringC());
}
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) {
if (!pFormDict || csNameTag.IsEmpty()) {
@@ -664,7 +665,7 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) {
if (!pFonts) {
return;
}
- pFonts->RemoveAt(csNameTag);
+ pFonts->RemoveAt(csNameTag.AsByteStringC());
}
CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict,
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp
index 28c8ac0f32..de7bff2401 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/fx_basic_buffer.cpp
@@ -248,7 +248,7 @@ CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const FX_WCHAR* wstr) {
}
CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const CFX_WideString& wstr) {
CFX_ByteString encoded = wstr.UTF16LE_Encode();
- return operator<<(encoded);
+ return operator<<(encoded.AsByteStringC());
}
void CFX_ArchiveSaver::Write(const void* pData, FX_STRSIZE dwSize) {
if (m_pStream) {
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index 9cdf73ca90..b39c32bfbd 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -371,7 +371,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
}
CXML_Element* pElement = new CXML_Element;
pElement->m_pParent = pParent;
- pElement->SetTag(tag_space, tag_name);
+ pElement->SetTag(tag_space.AsByteStringC(), tag_name.AsByteStringC());
do {
CFX_ByteString attr_space, attr_name;
while (m_dwIndex < m_dwBufferSize) {
@@ -397,7 +397,8 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
}
CFX_WideString attr_value;
GetAttrValue(attr_value);
- pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value);
+ pElement->m_AttrMap.SetAt(attr_space.AsByteStringC(),
+ attr_name.AsByteStringC(), attr_value);
}
m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
if (m_dwIndex < m_dwBufferSize || IsEOF()) {
@@ -600,7 +601,7 @@ CFX_ByteString CXML_Element::GetNamespace(FX_BOOL bQualified) const {
if (bQualified) {
return m_QSpaceName;
}
- return GetNamespaceURI(m_QSpaceName);
+ return GetNamespaceURI(m_QSpaceName.AsByteStringC());
}
CFX_ByteString CXML_Element::GetNamespaceURI(
const CFX_ByteStringC& qName) const {
diff --git a/core/fxcrt/fxcrt_posix.cpp b/core/fxcrt/fxcrt_posix.cpp
index 2f17e71567..0226313934 100644
--- a/core/fxcrt/fxcrt_posix.cpp
+++ b/core/fxcrt/fxcrt_posix.cpp
@@ -45,7 +45,7 @@ FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName,
}
FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName,
uint32_t dwMode) {
- return Open(FX_UTF8Encode(fileName), dwMode);
+ return Open(FX_UTF8Encode(fileName).AsByteStringC(), dwMode);
}
void CFXCRT_FileAccess_Posix::Close() {
if (m_nFD < 0) {
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h
index feeb6e756d..2ef11beb27 100644
--- a/core/fxcrt/include/fx_basic.h
+++ b/core/fxcrt/include/fx_basic.h
@@ -27,8 +27,8 @@ class CFX_BinaryBuf {
void Clear();
void EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0);
void AppendBlock(const void* pBuf, FX_STRSIZE size);
- void AppendString(const CFX_ByteStringC& str) {
- AppendBlock(str.GetPtr(), str.GetLength());
+ void AppendString(const CFX_ByteString& str) {
+ AppendBlock(str.c_str(), str.GetLength());
}
void AppendByte(uint8_t byte) {
@@ -63,6 +63,12 @@ class CFX_ByteTextBuf : public CFX_BinaryBuf {
CFX_ByteTextBuf& operator<<(int i);
CFX_ByteTextBuf& operator<<(uint32_t i);
CFX_ByteTextBuf& operator<<(double f);
+ CFX_ByteTextBuf& operator<<(const FX_CHAR* pStr) {
+ return *this << CFX_ByteStringC(pStr);
+ }
+ CFX_ByteTextBuf& operator<<(const CFX_ByteString& str) {
+ return *this << str.AsByteStringC();
+ }
CFX_ByteTextBuf& operator<<(const CFX_ByteStringC& lpsz);
CFX_ByteTextBuf& operator<<(const CFX_ByteTextBuf& buf);
};
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index 9aa67845f8..cbf8c4de2f 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -61,8 +61,6 @@ class CFX_ByteStringC {
m_Length = src.m_Length;
}
- CFX_ByteStringC(const CFX_ByteString& src);
-
CFX_ByteStringC& operator=(const FX_CHAR* src) {
m_Ptr = (const uint8_t*)src;
m_Length = m_Ptr ? FXSYS_strlen(src) : 0;
@@ -167,12 +165,14 @@ class CFX_ByteString {
static CFX_ByteString FromUnicode(const CFX_WideString& str);
// Explicit conversion to C-style string.
+ // Note: |this| must outlive the use of the result.
const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; }
// Implicit conversion to C-style string -- deprecated.
operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; }
// Explicit conversion to uint8_t*.
+ // Note: |this| must outlive the use of the result.
const uint8_t* raw_str() const {
return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String)
: nullptr;
@@ -184,6 +184,12 @@ class CFX_ByteString {
: nullptr;
}
+ // Explicit conversion to CFX_ByteStringC.
+ // Note: |this| must outlive the use of the result.
+ CFX_ByteStringC AsByteStringC() const {
+ return CFX_ByteStringC(raw_str(), GetLength());
+ }
+
FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
bool IsEmpty() const { return !GetLength(); }
@@ -330,10 +336,6 @@ class CFX_ByteString {
friend class fxcrt_ByteStringConcat_Test;
};
-inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src) {
- m_Ptr = (const uint8_t*)src;
- m_Length = src.GetLength();
-}
inline CFX_ByteStringC& CFX_ByteStringC::operator=(const CFX_ByteString& src) {
m_Ptr = (const uint8_t*)src;
m_Length = src.GetLength();
@@ -373,29 +375,29 @@ inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteStringC& str2) {
}
inline CFX_ByteString operator+(const CFX_ByteString& str1,
const CFX_ByteString& str2) {
- return CFX_ByteString(str1, str2);
+ return CFX_ByteString(str1.AsByteStringC(), str2.AsByteStringC());
}
inline CFX_ByteString operator+(const CFX_ByteString& str1, FX_CHAR ch) {
- return CFX_ByteString(str1, CFX_ByteStringC(ch));
+ return CFX_ByteString(str1.AsByteStringC(), CFX_ByteStringC(ch));
}
inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteString& str2) {
- return CFX_ByteString(ch, str2);
+ return CFX_ByteString(ch, str2.AsByteStringC());
}
inline CFX_ByteString operator+(const CFX_ByteString& str1,
const FX_CHAR* str2) {
- return CFX_ByteString(str1, str2);
+ return CFX_ByteString(str1.AsByteStringC(), str2);
}
inline CFX_ByteString operator+(const FX_CHAR* str1,
const CFX_ByteString& str2) {
- return CFX_ByteString(str1, str2);
+ return CFX_ByteString(str1, str2.AsByteStringC());
}
inline CFX_ByteString operator+(const CFX_ByteString& str1,
const CFX_ByteStringC& str2) {
- return CFX_ByteString(str1, str2);
+ return CFX_ByteString(str1.AsByteStringC(), str2);
}
inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
const CFX_ByteString& str2) {
- return CFX_ByteString(str1, str2);
+ return CFX_ByteString(str1, str2.AsByteStringC());
}
class CFX_WideStringC {
@@ -758,7 +760,7 @@ inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr) {
FX_FLOAT FX_atof(const CFX_ByteStringC& str);
inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) {
- return FX_atof(FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()));
+ return FX_atof(FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()).c_str());
}
void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData);
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
diff --git a/core/fxge/ge/fx_ge_ps.cpp b/core/fxge/ge/fx_ge_ps.cpp
index 32f2fce914..ec8f18e774 100644
--- a/core/fxge/ge/fx_ge_ps.cpp
+++ b/core/fxge/ge/fx_ge_ps.cpp
@@ -680,7 +680,7 @@ FX_BOOL CFX_PSRenderer::DrawText(int nChars,
buf << pCharPos[i].m_OriginX << " " << pCharPos[i].m_OriginY << " m";
CFX_ByteString hex;
hex.Format("<%02X>", ps_glyphindex);
- buf << hex << "Tj\n";
+ buf << hex.AsByteStringC() << "Tj\n";
}
buf << "Q\n";
m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize());
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index cb3f331d49..ed57a02c23 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -460,7 +460,7 @@ IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) {
if (path_len > 0 && path_len < MAX_PATH) {
CFX_ByteString fonts_path(windows_path);
fonts_path += "\\Fonts";
- pInfoFallback->AddPath(fonts_path);
+ pInfoFallback->AddPath(fonts_path.AsByteStringC());
}
return pInfoFallback;
}