diff options
Diffstat (limited to 'core')
31 files changed, 146 insertions, 148 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp index 8287ea562d..f872906674 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -159,7 +159,7 @@ CPDF_Font* CPDF_DocPageData::GetFont(CPDF_Dictionary* pFontDict, return fontData->AddRef(); } -CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteStringC& fontName, +CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteString& fontName, CPDF_FontEncoding* pEncoding) { if (fontName.IsEmpty()) return nullptr; @@ -425,7 +425,8 @@ CPDF_IccProfile* CPDF_DocPageData::GetIccProfile( stream.LoadAllData(pIccProfileStream, FALSE); uint8_t digest[20]; CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest); - auto hash_it = m_HashProfileMap.find(CFX_ByteStringC(digest, 20)); + CFX_ByteString bsDigest(digest, 20); + auto hash_it = m_HashProfileMap.find(bsDigest); if (hash_it != m_HashProfileMap.end()) { auto it_copied_stream = m_IccProfileMap.find(hash_it->second); return it_copied_stream->second->AddRef(); @@ -434,7 +435,7 @@ CPDF_IccProfile* CPDF_DocPageData::GetIccProfile( new CPDF_IccProfile(stream.GetData(), stream.GetSize()); CPDF_CountedIccProfile* ipData = new CPDF_CountedIccProfile(pProfile); m_IccProfileMap[pIccProfileStream] = ipData; - m_HashProfileMap[CFX_ByteStringC(digest, 20)] = pIccProfileStream; + m_HashProfileMap[bsDigest] = pIccProfileStream; return ipData->AddRef(); } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index da1355724f..8c16d8c41f 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -1143,7 +1143,7 @@ void CPDF_StreamContentParser::Handle_SetFont() { } CPDF_Object* CPDF_StreamContentParser::FindResourceObj( - const CFX_ByteStringC& type, + const CFX_ByteString& type, const CFX_ByteString& name) { if (!m_pResources) { return NULL; @@ -1683,9 +1683,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, CFX_ByteString(op.replacement)); else - pDict->SetAtName(op.key, op.replacement); + pDict->SetAtName(op.key, CFX_ByteString(op.replacement)); } break; } @@ -1699,7 +1699,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) { PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name.AsStringC()); if (!fullname.IsEmpty()) { - pArray->SetAt(i, new CPDF_Name(fullname)); + pArray->SetAt(i, new CPDF_Name(CFX_ByteString(fullname))); } } else { PDF_ReplaceAbbr(pElement); diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 58ecb6c4d6..5bac23e137 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -502,7 +502,7 @@ CFX_ByteString CPDF_StreamParser::ReadString() { if (buf.GetLength() > kMaxStringLength) { return CFX_ByteString(buf.GetBuffer(), kMaxStringLength); } - return buf.AsStringC(); + return buf.MakeString(); } parlevel--; buf.AppendChar(')'); @@ -581,7 +581,7 @@ CFX_ByteString CPDF_StreamParser::ReadString() { if (buf.GetLength() > kMaxStringLength) { return CFX_ByteString(buf.GetBuffer(), kMaxStringLength); } - return buf.AsStringC(); + return buf.MakeString(); } CFX_ByteString CPDF_StreamParser::ReadHexString() { @@ -615,7 +615,7 @@ CFX_ByteString CPDF_StreamParser::ReadHexString() { if (buf.GetLength() > kMaxStringLength) return CFX_ByteString(buf.GetBuffer(), kMaxStringLength); - return buf.AsStringC(); + return buf.MakeString(); } bool CPDF_StreamParser::PositionIsInBounds() const { diff --git a/core/fpdfapi/fpdf_page/pageint.h b/core/fpdfapi/fpdf_page/pageint.h index e904234e9f..6534186dc8 100644 --- a/core/fpdfapi/fpdf_page/pageint.h +++ b/core/fpdfapi/fpdf_page/pageint.h @@ -155,7 +155,7 @@ class CPDF_StreamContentParser { CPDF_Font* FindFont(const CFX_ByteString& name); CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name); CPDF_Pattern* FindPattern(const CFX_ByteString& name, bool bShading); - CPDF_Object* FindResourceObj(const CFX_ByteStringC& type, + CPDF_Object* FindResourceObj(const CFX_ByteString& type, const CFX_ByteString& name); protected: @@ -318,7 +318,7 @@ class CPDF_DocPageData { void Clear(FX_BOOL bRelease = FALSE); CPDF_Font* GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly); - CPDF_Font* GetStandardFont(const CFX_ByteStringC& fontName, + CPDF_Font* GetStandardFont(const CFX_ByteString& fontName, CPDF_FontEncoding* pEncoding); void ReleaseFont(CPDF_Dictionary* pFontDict); CPDF_ColorSpace* GetColorSpace(CPDF_Object* pCSObj, diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp index 39694c1c1a..52899eedb3 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp @@ -839,7 +839,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.AsStringC(), pEncoding); + return GetPageData()->GetStandardFont(name, pEncoding); } CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { diff --git a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp index 38099e0328..d6416fb055 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp @@ -112,10 +112,11 @@ FX_BOOL CPDF_SecurityHandler::CheckSecurity(int32_t key_len) { uint32_t CPDF_SecurityHandler::GetPermissions() { return m_Permissions; } -static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict, - const CFX_ByteStringC& name, - int& cipher, - int& keylen) { + +static FX_BOOL LoadCryptInfo(CPDF_Dictionary* pEncryptDict, + const CFX_ByteString& name, + int& cipher, + int& keylen) { int Version = pEncryptDict->GetIntegerBy("V"); cipher = FXCIPHER_RC4; keylen = 0; @@ -163,19 +164,15 @@ FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) { m_Version = pEncryptDict->GetIntegerBy("V"); m_Revision = pEncryptDict->GetIntegerBy("R"); m_Permissions = pEncryptDict->GetIntegerBy("P", -1); - if (m_Version < 4) { - return _LoadCryptInfo(pEncryptDict, CFX_ByteStringC(), m_Cipher, m_KeyLen); - } + if (m_Version < 4) + return LoadCryptInfo(pEncryptDict, CFX_ByteString(), m_Cipher, m_KeyLen); + CFX_ByteString stmf_name = pEncryptDict->GetStringBy("StmF"); CFX_ByteString strf_name = pEncryptDict->GetStringBy("StrF"); - if (stmf_name != strf_name) { + if (stmf_name != strf_name) return FALSE; - } - if (!_LoadCryptInfo(pEncryptDict, strf_name.AsStringC(), m_Cipher, - m_KeyLen)) { - return FALSE; - } - return TRUE; + + return LoadCryptInfo(pEncryptDict, strf_name, m_Cipher, m_KeyLen); } FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, @@ -186,17 +183,18 @@ FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, m_Version = pEncryptDict->GetIntegerBy("V"); m_Revision = pEncryptDict->GetIntegerBy("R"); m_Permissions = pEncryptDict->GetIntegerBy("P", -1); - CFX_ByteString strf_name, stmf_name; + + CFX_ByteString strf_name; + CFX_ByteString stmf_name; if (m_Version >= 4) { stmf_name = pEncryptDict->GetStringBy("StmF"); strf_name = pEncryptDict->GetStringBy("StrF"); - if (stmf_name != strf_name) { + if (stmf_name != strf_name) return FALSE; - } } - if (!_LoadCryptInfo(pEncryptDict, strf_name.AsStringC(), cipher, key_len)) { + if (!LoadCryptInfo(pEncryptDict, strf_name, cipher, key_len)) return FALSE; - } + m_Cipher = cipher; m_KeyLen = key_len; return TRUE; diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index ae066f94c1..13a9972425 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -217,7 +217,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() { case 0: if (ch == ')') { if (parlevel == 0) { - return buf.AsStringC(); + return buf.MakeString(); } parlevel--; buf.AppendChar(')'); @@ -290,7 +290,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() { } GetNextChar(ch); - return buf.AsStringC(); + return buf.MakeString(); } CFX_ByteString CPDF_SyntaxParser::ReadHexString() { @@ -322,7 +322,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString() { if (!bFirst) buf.AppendByte(code); - return buf.AsStringC(); + return buf.MakeString(); } void CPDF_SyntaxParser::ToNextLine() { @@ -470,7 +470,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, if (!pObj) continue; - CFX_ByteStringC keyNoSlash(key.raw_str() + 1, key.GetLength() - 1); + CFX_ByteString keyNoSlash(key.raw_str() + 1, key.GetLength() - 1); pDict->SetAt(keyNoSlash, pObj); } diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 3893d9bd41..e9f5a6d468 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -528,7 +528,7 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) { result.AppendChar("0123456789ABCDEF"[src[i] % 16]); } result.AppendChar('>'); - return result.AsStringC(); + return result.MakeString(); } result.AppendChar('('); for (int i = 0; i < srclen; i++) { @@ -545,7 +545,7 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) { result.AppendChar(ch); } result.AppendChar(')'); - return result.AsStringC(); + return result.MakeString(); } void FlateEncode(const uint8_t* src_buf, diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 1e9252fa82..a738356e43 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -81,14 +81,14 @@ int32_t GetHeaderOffset(IFX_FileRead* pFile) { return -1; } -int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) { +int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key) { CPDF_Number* pObj = ToNumber(pDict->GetObjectBy(key)); return pObj ? pObj->GetInteger() : 0; } CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { if (bstr.Find('#') == -1) - return bstr; + return CFX_ByteString(bstr); int size = bstr.GetLength(); CFX_ByteString result; diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h index d072fbc191..0b27a1fe9a 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h @@ -34,6 +34,6 @@ inline bool PDFCharIsLineEnding(uint8_t c) { } int32_t GetHeaderOffset(IFX_FileRead* pFile); -int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key); +int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key); #endif // CORE_FPDFAPI_FPDF_PARSER_FPDF_PARSER_UTILITY_H_ diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp index 33ad21351e..225b6726e2 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -57,7 +57,7 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode, keygen.Generate( 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000), FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000)); - CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); + CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); CPDF_Type3Glyphs* pSizeCache; auto it = m_SizeMap.find(FaceGlyphsKey); if (it == m_SizeMap.end()) { diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 2fc0644bcc..adaee6363e 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -38,7 +38,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_SimpleParser syntax(DA.AsStringC()); syntax.FindTagParamFromStart("Tf", 2); - CFX_ByteString sFontName = syntax.GetWord(); + CFX_ByteString sFontName(syntax.GetWord()); sFontName = PDF_NameDecode(sFontName); if (sFontName.IsEmpty()) return FALSE; @@ -519,7 +519,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( if (bContinuous) { if (place.LineCmp(oldplace) != 0) { if (sWords.GetSize() > 0) { - sLineStream << GetWordRenderString(sWords.AsStringC()); + sLineStream << GetWordRenderString(sWords.MakeString()); sEditStream << sLineStream; sLineStream.Clear(); sWords.Clear(); @@ -544,7 +544,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( if (pIterator->GetWord(word)) { if (word.nFontIndex != nCurFontIndex) { if (sWords.GetSize() > 0) { - sLineStream << GetWordRenderString(sWords.AsStringC()); + sLineStream << GetWordRenderString(sWords.MakeString()); sWords.Clear(); } sLineStream << GetFontSetString(pFontMap, word.nFontIndex, @@ -575,11 +575,11 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( } } if (sWords.GetSize() > 0) { - sLineStream << GetWordRenderString(sWords.AsStringC()); + sLineStream << GetWordRenderString(sWords.MakeString()); sEditStream << sLineStream; sWords.Clear(); } - return sEditStream.AsStringC(); + return sEditStream.MakeString(); } // Static. @@ -687,7 +687,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( break; } } - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } // Static. @@ -712,7 +712,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, case CPVT_Color::kTransparent: break; } - return sColorStream.AsStringC(); + return sColorStream.MakeString(); } // Static. @@ -760,5 +760,5 @@ CFX_ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap, if (sFontAlias.GetLength() > 0 && fFontSize > 0) sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; } - return sRet.AsStringC(); + return sRet.MakeString(); } diff --git a/core/fpdfdoc/doc_action.cpp b/core/fpdfdoc/doc_action.cpp index c478bbe1f4..6f3e2945fa 100644 --- a/core/fpdfdoc/doc_action.cpp +++ b/core/fpdfdoc/doc_action.cpp @@ -38,8 +38,7 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const { } if (pDest->IsString() || pDest->IsName()) { CPDF_NameTree name_tree(pDoc, "Dests"); - return CPDF_Dest( - name_tree.LookupNamedDest(pDoc, pDest->GetString().AsStringC())); + return CPDF_Dest(name_tree.LookupNamedDest(pDoc, pDest->GetString())); } if (CPDF_Array* pArray = pDest->AsArray()) return CPDF_Dest(pArray); diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp index 76639efac6..ab99cff772 100644 --- a/core/fpdfdoc/doc_basic.cpp +++ b/core/fpdfdoc/doc_basic.cpp @@ -500,30 +500,25 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { wsLabel.Format(L"%d", nPage + 1); return wsLabel; } + int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { - if (!m_pDocument) { + if (!m_pDocument) return -1; - } + CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); - if (!pPDFRoot) { + if (!pPDFRoot) return -1; - } + int nPages = m_pDocument->GetPageCount(); - CFX_ByteString bsLbl; - CFX_ByteString bsOrig = bsLabel; for (int i = 0; i < nPages; i++) { - bsLbl = PDF_EncodeText(GetLabel(i)); - if (!bsLbl.Compare(bsOrig.AsStringC())) { + if (PDF_EncodeText(GetLabel(i)).Compare(bsLabel)) return i; - } - } - bsLbl = bsOrig; - int nPage = FXSYS_atoi(bsLbl.c_str()); - if (nPage > 0 && nPage <= nPages) { - return nPage; } - return -1; + + int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate. + return nPage > 0 && nPage <= nPages ? nPage : -1; } + int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC()); } diff --git a/core/fpdfdoc/doc_bookmark.cpp b/core/fpdfdoc/doc_bookmark.cpp index aee9fb7b14..05ebc07a90 100644 --- a/core/fpdfdoc/doc_bookmark.cpp +++ b/core/fpdfdoc/doc_bookmark.cpp @@ -80,8 +80,7 @@ CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const { return CPDF_Dest(); if (pDest->IsString() || pDest->IsName()) { CPDF_NameTree name_tree(pDocument, "Dests"); - return CPDF_Dest( - name_tree.LookupNamedDest(pDocument, pDest->GetString().AsStringC())); + return CPDF_Dest(name_tree.LookupNamedDest(pDocument, pDest->GetString())); } if (CPDF_Array* pArray = pDest->AsArray()) return CPDF_Dest(pArray); diff --git a/core/fpdfdoc/doc_formfield.cpp b/core/fpdfdoc/doc_formfield.cpp index d9333eef90..84d9a52dac 100644 --- a/core/fpdfdoc/doc_formfield.cpp +++ b/core/fpdfdoc/doc_formfield.cpp @@ -1062,7 +1062,7 @@ void CPDF_FormField::LoadDA() { } CPDF_SimpleParser syntax(DA.AsStringC()); syntax.FindTagParamFromStart("Tf", 2); - CFX_ByteString font_name = syntax.GetWord(); + CFX_ByteString font_name(syntax.GetWord()); CPDF_Dictionary* pFontDict = NULL; if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDictBy("DR") && m_pForm->m_pFormDict->GetDictBy("DR")->GetDictBy("Font")) { diff --git a/core/fpdfdoc/doc_link.cpp b/core/fpdfdoc/doc_link.cpp index 995290b9fb..5d21e1d9aa 100644 --- a/core/fpdfdoc/doc_link.cpp +++ b/core/fpdfdoc/doc_link.cpp @@ -81,8 +81,7 @@ CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) { if (pDest->IsString() || pDest->IsName()) { CPDF_NameTree name_tree(pDoc, "Dests"); - return CPDF_Dest( - name_tree.LookupNamedDest(pDoc, pDest->GetString().AsStringC())); + return CPDF_Dest(name_tree.LookupNamedDest(pDoc, pDest->GetString())); } 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 2249574b7f..51e018aea5 100644 --- a/core/fpdfdoc/doc_ocg.cpp +++ b/core/fpdfdoc/doc_ocg.cpp @@ -43,21 +43,21 @@ static FX_BOOL FPDFDOC_OCG_HasIntent(const CPDF_Dictionary* pDict, bsIntent = pIntent->GetString(); return bsIntent == "All" || bsIntent == csElement; } + static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document* pDoc, - const CPDF_Dictionary* pOCGDict, - const CFX_ByteStringC& bsState) { - ASSERT(pDoc && pOCGDict); + const CPDF_Dictionary* pOCGDict) { + ASSERT(pOCGDict); CPDF_Dictionary* pOCProperties = pDoc->GetRoot()->GetDictBy("OCProperties"); - if (!pOCProperties) { - return NULL; - } + if (!pOCProperties) + return nullptr; + CPDF_Array* pOCGs = pOCProperties->GetArrayBy("OCGs"); - if (!pOCGs) { - return NULL; - } - if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) { - return NULL; - } + if (!pOCGs) + return nullptr; + + if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) + return nullptr; + CPDF_Dictionary* pConfig = pOCProperties->GetDictBy("D"); CPDF_Array* pConfigs = pOCProperties->GetArrayBy("Configs"); if (pConfigs) { @@ -96,14 +96,14 @@ CPDF_OCContext::CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType) { CPDF_OCContext::~CPDF_OCContext() { m_OCGStates.clear(); } -FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, + +FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteString& csConfig, const CPDF_Dictionary* pOCGDict, FX_BOOL& bValidConfig) const { - CPDF_Dictionary* pConfig = - FPDFDOC_OCG_GetConfig(m_pDocument, pOCGDict, csConfig); - if (!pConfig) { + CPDF_Dictionary* pConfig = FPDFDOC_OCG_GetConfig(m_pDocument, pOCGDict); + if (!pConfig) return TRUE; - } + bValidConfig = TRUE; FX_BOOL bState = pConfig->GetStringBy("BaseState", "ON") != "OFF"; CPDF_Array* pArray = pConfig->GetArrayBy("ON"); @@ -167,7 +167,7 @@ FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const { } } FX_BOOL bDefValid = FALSE; - return LoadOCGStateFromConfig(csState.AsStringC(), pOCGDict, bDefValid); + return LoadOCGStateFromConfig(csState, 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 f559c0ac2b..2eca698614 100644 --- a/core/fpdfdoc/doc_tagged.cpp +++ b/core/fpdfdoc/doc_tagged.cpp @@ -356,7 +356,7 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, if (pA) { CPDF_Dictionary* pAttrDict = FindAttrDict(pA, owner); if (pAttrDict) { - CPDF_Object* pAttr = pAttrDict->GetDirectObjectBy(name); + CPDF_Object* pAttr = pAttrDict->GetDirectObjectBy(CFX_ByteString(name)); if (pAttr) { return pAttr; } @@ -375,14 +375,14 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, CFX_ByteString class_name = pArray->GetStringAt(i); CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name); if (pClassDict && pClassDict->GetStringBy("O") == owner) - return pClassDict->GetDirectObjectBy(name); + return pClassDict->GetDirectObjectBy(CFX_ByteString(name)); } return nullptr; } CFX_ByteString class_name = pC->GetString(); CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name); if (pClassDict && pClassDict->GetStringBy("O") == owner) - return pClassDict->GetDirectObjectBy(name); + return pClassDict->GetDirectObjectBy(CFX_ByteString(name)); return nullptr; } CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, @@ -407,7 +407,7 @@ CFX_ByteString CPDF_StructElementImpl::GetName( CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex); if (ToName(pAttr)) return pAttr->GetString(); - return default_value; + return CFX_ByteString(default_value); } FX_ARGB CPDF_StructElementImpl::GetColor(const CFX_ByteStringC& owner, diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h index 306b131b88..d69887bd78 100644 --- a/core/fpdfdoc/include/fpdf_doc.h +++ b/core/fpdfdoc/include/fpdf_doc.h @@ -134,7 +134,7 @@ class CPDF_OCContext { void ResetOCContext(); protected: - FX_BOOL LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, + FX_BOOL LoadOCGStateFromConfig(const CFX_ByteString& csConfig, const CPDF_Dictionary* pOCGDict, FX_BOOL& bValidConfig) const; FX_BOOL LoadOCGState(const CPDF_Dictionary* pOCGDict) const; diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index 324c01ad0b..876297fd40 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -500,7 +500,7 @@ void* CCodec_IccModule::CreateTransform( } key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag << (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag; - CFX_ByteStringC TransformKey(key.GetBuffer(), key.GetSize()); + CFX_ByteString TransformKey(key.GetBuffer(), key.GetSize()); CFX_IccTransformCache* pTransformCache; auto it = m_MapTranform.find(TransformKey); if (it == m_MapTranform.end()) { diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index c774e80cb7..379f1ee882 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -408,7 +408,7 @@ void CFX_ByteString::AllocCopy(CFX_ByteString& dest, CFX_ByteString CFX_ByteString::FormatInteger(int i, uint32_t flags) { char buf[32]; - return CFX_ByteStringC(buf, Buffer_itoa(buf, i, flags)); + return CFX_ByteString(buf, Buffer_itoa(buf, i, flags)); } void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) { diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index 6008a00b40..2762497e5c 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -100,10 +100,6 @@ void CFX_BinaryBuf::InsertBlock(FX_STRSIZE pos, m_DataSize += size; } -CFX_ByteStringC CFX_ByteTextBuf::AsStringC() const { - return CFX_ByteStringC(m_pBuffer.get(), m_DataSize); -} - CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(const CFX_ByteStringC& lpsz) { AppendBlock(lpsz.raw_str(), lpsz.GetLength()); return *this; diff --git a/core/fxcrt/fx_basic_utf.cpp b/core/fxcrt/fx_basic_utf.cpp index 61b200fab4..de219b40fd 100644 --- a/core/fxcrt/fx_basic_utf.cpp +++ b/core/fxcrt/fx_basic_utf.cpp @@ -74,13 +74,12 @@ void CFX_UTF8Encoder::Input(FX_WCHAR unicode) { } } CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len) { - ASSERT(pwsStr); - if (len < 0) { + if (len < 0) len = FXSYS_wcslen(pwsStr); - } + CFX_UTF8Encoder encoder; - while (len-- > 0) { + while (len-- > 0) encoder.Input(*pwsStr++); - } - return encoder.GetResult(); + + return CFX_ByteString(encoder.GetResult()); } diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index a5e351fe56..6017bd8fda 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -397,8 +397,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, } CFX_WideString attr_value; GetAttrValue(attr_value); - pElement->m_AttrMap.SetAt(attr_space.AsStringC(), attr_name.AsStringC(), - attr_value.AsStringC()); + pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value); } m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (m_dwIndex < m_dwBufferSize || IsEOF()) { @@ -597,14 +596,13 @@ CFX_ByteString CXML_Element::GetTagName(FX_BOOL bQualified) const { bsTag += m_TagName; return bsTag; } + CFX_ByteString CXML_Element::GetNamespace(FX_BOOL bQualified) const { - if (bQualified) { - return m_QSpaceName; - } - return GetNamespaceURI(m_QSpaceName.AsStringC()); + return bQualified ? m_QSpaceName : GetNamespaceURI(m_QSpaceName); } + CFX_ByteString CXML_Element::GetNamespaceURI( - const CFX_ByteStringC& qName) const { + const CFX_ByteString& qName) const { const CFX_WideString* pwsSpace; const CXML_Element* pElement = this; do { @@ -633,20 +631,23 @@ void CXML_Element::GetAttrByIndex(int index, value = item.m_Value; } FX_BOOL CXML_Element::HasAttr(const CFX_ByteStringC& name) const { - CFX_ByteStringC bsSpace, bsName; + CFX_ByteStringC bsSpace; + CFX_ByteStringC bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); - return !!m_AttrMap.Lookup(bsSpace, bsName); + return !!m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName)); } FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& name, CFX_WideString& attribute) const { - CFX_ByteStringC bsSpace, bsName; + CFX_ByteStringC bsSpace; + CFX_ByteStringC bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); return GetAttrValue(bsSpace, bsName, attribute); } FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name, CFX_WideString& attribute) const { - const CFX_WideString* pValue = m_AttrMap.Lookup(space, name); + const CFX_WideString* pValue = + m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); if (pValue) { attribute = *pValue; return TRUE; @@ -655,9 +656,11 @@ FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& space, } FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const { - CFX_ByteStringC bsSpace, bsName; + CFX_ByteStringC bsSpace; + CFX_ByteStringC bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); - const CFX_WideString* pwsValue = m_AttrMap.Lookup(bsSpace, bsName); + const CFX_WideString* pwsValue = + m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName)); if (pwsValue) { attribute = pwsValue->GetInteger(); return TRUE; @@ -667,7 +670,8 @@ FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& name, FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name, int& attribute) const { - const CFX_WideString* pwsValue = m_AttrMap.Lookup(space, name); + const CFX_WideString* pwsValue = + m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); if (pwsValue) { attribute = pwsValue->GetInteger(); return TRUE; @@ -683,7 +687,8 @@ FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& name, FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, FX_FLOAT& attribute) const { - const CFX_WideString* pValue = m_AttrMap.Lookup(space, name); + const CFX_WideString* pValue = + m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); if (pValue) { attribute = pValue->GetFloat(); return TRUE; @@ -754,13 +759,13 @@ uint32_t CXML_Element::FindElement(CXML_Element* pChild) const { return (uint32_t)-1; } -bool CXML_AttrItem::Matches(const CFX_ByteStringC& space, - const CFX_ByteStringC& name) const { +bool CXML_AttrItem::Matches(const CFX_ByteString& space, + const CFX_ByteString& name) const { return (space.IsEmpty() || m_QSpaceName == space) && m_AttrName == name; } -const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space, - const CFX_ByteStringC& name) const { +const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteString& space, + const CFX_ByteString& name) const { if (!m_pMap) return nullptr; @@ -771,9 +776,9 @@ const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space, return nullptr; } -void CXML_AttrMap::SetAt(const CFX_ByteStringC& space, - const CFX_ByteStringC& name, - const CFX_WideStringC& value) { +void CXML_AttrMap::SetAt(const CFX_ByteString& space, + const CFX_ByteString& name, + const CFX_WideString& value) { if (!m_pMap) m_pMap.reset(new std::vector<CXML_AttrItem>); diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 48999c4f19..7121ffcd0b 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -56,10 +56,15 @@ class CFX_BinaryBuf { class CFX_ByteTextBuf : public CFX_BinaryBuf { public: - void AppendChar(int ch) { AppendByte((uint8_t)ch); } FX_STRSIZE GetLength() const { return m_DataSize; } - CFX_ByteStringC AsStringC() const; + CFX_ByteString MakeString() const { + return CFX_ByteString(m_pBuffer.get(), m_DataSize); + } + CFX_ByteStringC AsStringC() const { + return CFX_ByteStringC(m_pBuffer.get(), m_DataSize); + } + void AppendChar(int ch) { AppendByte(static_cast<uint8_t>(ch)); } CFX_ByteTextBuf& operator<<(int i); CFX_ByteTextBuf& operator<<(uint32_t i); CFX_ByteTextBuf& operator<<(double f); diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h index df8afb386f..142f9372d0 100644 --- a/core/fxcrt/include/fx_string.h +++ b/core/fxcrt/include/fx_string.h @@ -46,8 +46,7 @@ class CFX_ByteString { CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len); CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len); - // TODO(tsepez): mark constructor as explicit. - CFX_ByteString(const CFX_ByteStringC& bstrc); + explicit CFX_ByteString(const CFX_ByteStringC& bstrc); CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2); ~CFX_ByteString(); diff --git a/core/fxcrt/include/fx_xml.h b/core/fxcrt/include/fx_xml.h index 3e22883c7f..8816e2eae1 100644 --- a/core/fxcrt/include/fx_xml.h +++ b/core/fxcrt/include/fx_xml.h @@ -14,7 +14,7 @@ class CXML_AttrItem { public: - bool Matches(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const; + bool Matches(const CFX_ByteString& space, const CFX_ByteString& name) const; CFX_ByteString m_QSpaceName; CFX_ByteString m_AttrName; @@ -23,11 +23,11 @@ class CXML_AttrItem { class CXML_AttrMap { public: - const CFX_WideString* Lookup(const CFX_ByteStringC& space, - const CFX_ByteStringC& name) const; - void SetAt(const CFX_ByteStringC& space, - const CFX_ByteStringC& name, - const CFX_WideStringC& value); + const CFX_WideString* Lookup(const CFX_ByteString& space, + const CFX_ByteString& name) const; + void SetAt(const CFX_ByteString& space, + const CFX_ByteString& name, + const CFX_WideString& value); int GetSize() const; CXML_AttrItem& GetAt(int index) const; @@ -69,7 +69,7 @@ class CXML_Element { void Empty(); CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const; CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const; - CFX_ByteString GetNamespaceURI(const CFX_ByteStringC& qName) const; + CFX_ByteString GetNamespaceURI(const CFX_ByteString& qName) const; CXML_Element* GetParent() const { return m_pParent; } uint32_t CountAttrs() const { return m_AttrMap.GetSize(); } void GetAttrByIndex(int index, diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index 8524660043..e8af2dce53 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -317,7 +317,7 @@ CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { CFX_ByteTextBuf buf; if (!iLen || iLen <= iIndex) { - return buf.AsStringC(); + return buf.MakeString(); } while (iIndex < iLen) { if (pStyle[iIndex] == ',') { @@ -326,7 +326,7 @@ CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { buf.AppendChar(pStyle[iIndex]); ++iIndex; } - return buf.AsStringC(); + return buf.MakeString(); } int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) { @@ -688,7 +688,7 @@ static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr, if (string_ptr_length < static_cast<uint32_t>(offset + length)) { return CFX_ByteString(); } - return CFX_ByteStringC(string_ptr + offset, length); + return CFX_ByteString(string_ptr + offset, length); } CFX_ByteString GetNameFromTT(const uint8_t* name_table, @@ -1368,12 +1368,15 @@ CFX_FolderFontInfo::~CFX_FolderFontInfo() { delete pair.second; } } + void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) { - m_PathList.push_back(path); + m_PathList.push_back(CFX_ByteString(path)); } + void CFX_FolderFontInfo::Release() { delete this; } + FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { m_pMapper = pMapper; for (const auto& path : m_PathList) diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index 3372b7f95d..b0f6a6e63a 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -1288,7 +1288,7 @@ void CFX_FaceCache::InitPlatform() {} CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( CFX_Font* pFont, const CFX_Matrix* pMatrix, - CFX_ByteStringC& FaceGlyphsKey, + const CFX_ByteString& FaceGlyphsKey, uint32_t glyph_index, FX_BOOL bFontStyle, int dest_width, @@ -1359,7 +1359,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, dest_width, anti_alias, 3); } #endif - CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); + CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias); @@ -1401,7 +1401,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias); - CFX_ByteStringC FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen); + CFX_ByteString FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen); text_flags |= FXTEXT_NO_NATIVETEXT; return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey2, glyph_index, bFontStyle, dest_width, anti_alias); diff --git a/core/fxge/include/fx_font.h b/core/fxge/include/fx_font.h index 02ab44d6b8..dad10f2ccb 100644 --- a/core/fxge/include/fx_font.h +++ b/core/fxge/include/fx_font.h @@ -501,7 +501,7 @@ class CFX_FaceCache { int anti_alias); CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Matrix* pMatrix, - CFX_ByteStringC& FaceGlyphsKey, + const CFX_ByteString& FaceGlyphsKey, uint32_t glyph_index, FX_BOOL bFontStyle, int dest_width, |