From 71a452f8ce12e31cc4e0d8c7878567b0c7fc63c2 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 13 May 2016 17:51:27 -0700 Subject: Make CFX_ByteString(const CFX_ByteStringC&) explicit. Add missing helper function to CFX_ByteTextBuf to avoid the anti-pattern CFX_ByteString(sBuf.AsStringC()), using the name "Make" to indicate there's an allocation going on in this case. Change some method arguments to take pre-existing ByteStrings where possible. Review-Url: https://codereview.chromium.org/1977093002 --- core/fpdfapi/fpdf_page/fpdf_page_doc.cpp | 7 ++-- core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 8 ++-- core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 6 +-- core/fpdfapi/fpdf_page/pageint.h | 4 +- core/fpdfapi/fpdf_parser/cpdf_document.cpp | 2 +- core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp | 36 ++++++++-------- core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp | 8 ++-- core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 4 +- core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 4 +- core/fpdfapi/fpdf_parser/fpdf_parser_utility.h | 2 +- core/fpdfapi/fpdf_render/fpdf_render_text.cpp | 2 +- core/fpdfdoc/cpvt_generateap.cpp | 16 +++---- core/fpdfdoc/doc_action.cpp | 3 +- core/fpdfdoc/doc_basic.cpp | 25 +++++------ core/fpdfdoc/doc_bookmark.cpp | 3 +- core/fpdfdoc/doc_formfield.cpp | 2 +- core/fpdfdoc/doc_link.cpp | 3 +- core/fpdfdoc/doc_ocg.cpp | 36 ++++++++-------- core/fpdfdoc/doc_tagged.cpp | 8 ++-- core/fpdfdoc/include/fpdf_doc.h | 2 +- core/fxcodec/codec/fx_codec_icc.cpp | 2 +- core/fxcrt/fx_basic_bstring.cpp | 2 +- core/fxcrt/fx_basic_buffer.cpp | 4 -- core/fxcrt/fx_basic_utf.cpp | 11 +++-- core/fxcrt/fx_xml_parser.cpp | 49 ++++++++++++---------- core/fxcrt/include/fx_basic.h | 9 +++- core/fxcrt/include/fx_string.h | 3 +- core/fxcrt/include/fx_xml.h | 14 +++---- core/fxge/ge/fx_ge_fontmap.cpp | 11 +++-- core/fxge/ge/fx_ge_text.cpp | 6 +-- core/fxge/include/fx_font.h | 2 +- fpdfsdk/formfiller/cba_fontmap.cpp | 4 +- fpdfsdk/fpdf_transformpage.cpp | 24 +++++------ fpdfsdk/fpdfppo.cpp | 15 ++++--- fpdfsdk/fxedit/fxet_ap.cpp | 15 +++---- fpdfsdk/fxedit/fxet_pageobjs.cpp | 22 +++++----- fpdfsdk/pdfwindow/PWL_Caret.cpp | 2 +- fpdfsdk/pdfwindow/PWL_Edit.cpp | 4 +- fpdfsdk/pdfwindow/PWL_Icon.cpp | 2 +- fpdfsdk/pdfwindow/PWL_Label.cpp | 4 +- fpdfsdk/pdfwindow/PWL_Utils.cpp | 49 ++++++++++------------ xfa/fwl/basewidget/fwl_editimp.cpp | 2 +- 42 files changed, 210 insertions(+), 227 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); 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(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(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, diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index 00e213c7d7..4c74d5a242 100644 --- a/fpdfsdk/formfiller/cba_fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -167,7 +167,7 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, if (!pStream) { pStream = new CPDF_Stream(NULL, 0, NULL); int32_t objnum = m_pDocument->AddIndirectObject(pStream); - pAPDict->SetAtReference(m_sAPType.AsStringC(), m_pDocument, objnum); + pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); } CPDF_Dictionary* pStreamDict = pStream->GetDict(); @@ -223,7 +223,7 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) { if (!sDA.IsEmpty()) { CPDF_SimpleParser syntax(sDA.AsStringC()); syntax.FindTagParamFromStart("Tf", 2); - CFX_ByteString sFontName = syntax.GetWord(); + CFX_ByteString sFontName(syntax.GetWord()); sAlias = PDF_NameDecode(sFontName).Mid(1); if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR")) diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index d47cb02b1d..5fe6e4ebcc 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp @@ -20,36 +20,34 @@ namespace { void SetBoundingBox(CPDF_Page* page, - const CFX_ByteStringC& key, + const CFX_ByteString& key, float left, float bottom, float right, float top) { - CPDF_Dictionary* pPageDict = page->m_pFormDict; CPDF_Array* pBoundingBoxArray = new CPDF_Array; pBoundingBoxArray->Add(new CPDF_Number(left)); pBoundingBoxArray->Add(new CPDF_Number(bottom)); pBoundingBoxArray->Add(new CPDF_Number(right)); pBoundingBoxArray->Add(new CPDF_Number(top)); - pPageDict->SetAt(key, pBoundingBoxArray); + page->m_pFormDict->SetAt(key, pBoundingBoxArray); } -FPDF_BOOL GetBoundingBox(CPDF_Page* page, - const CFX_ByteStringC& key, - float* left, - float* bottom, - float* right, - float* top) { - CPDF_Dictionary* pPageDict = page->m_pFormDict; - CPDF_Array* pArray = pPageDict->GetArrayBy(key); +bool GetBoundingBox(CPDF_Page* page, + const CFX_ByteString& key, + float* left, + float* bottom, + float* right, + float* top) { + CPDF_Array* pArray = page->m_pFormDict->GetArrayBy(key); if (!pArray) - return FALSE; + return false; *left = pArray->GetFloatAt(0); *bottom = pArray->GetFloatAt(1); *right = pArray->GetFloatAt(2); *top = pArray->GetFloatAt(3); - return TRUE; + return true; } } // namespace diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp index 1ec968ddf4..97fd390cb3 100644 --- a/fpdfsdk/fpdfppo.cpp +++ b/fpdfsdk/fpdfppo.cpp @@ -32,7 +32,7 @@ class CPDF_PageOrganizer { CPDF_Document* pDestPDFDoc, int nIndex); CPDF_Object* PageDictGetInheritableTag(CPDF_Dictionary* pDict, - CFX_ByteString nSrctag); + const CFX_ByteString& bsSrctag); FX_BOOL UpdateReference(CPDF_Object* pObj, CPDF_Document* pDoc, ObjectNumberMap* pObjNumberMap); @@ -175,8 +175,8 @@ FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( CPDF_Dictionary* pDict, - CFX_ByteString nSrctag) { - if (!pDict || nSrctag.IsEmpty()) + const CFX_ByteString& bsSrcTag) { + if (!pDict || bsSrcTag.IsEmpty()) return nullptr; if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type")) return nullptr; @@ -191,13 +191,12 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( if (!pp) return nullptr; - CFX_ByteStringC sSrcTag = nSrctag.AsStringC(); - if (pDict->KeyExist(sSrcTag)) - return pDict->GetObjectBy(sSrcTag); + if (pDict->KeyExist(bsSrcTag)) + return pDict->GetObjectBy(bsSrcTag); while (pp) { - if (pp->KeyExist(sSrcTag)) - return pp->GetObjectBy(sSrcTag); + if (pp->KeyExist(bsSrcTag)) + return pp->GetObjectBy(bsSrcTag); if (!pp->KeyExist("Parent")) break; pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect()); diff --git a/fpdfsdk/fxedit/fxet_ap.cpp b/fpdfsdk/fxedit/fxet_ap.cpp index 262f1e70cd..563acb65b5 100644 --- a/fpdfsdk/fxedit/fxet_ap.cpp +++ b/fpdfsdk/fxedit/fxet_ap.cpp @@ -48,15 +48,12 @@ static CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap, int32_t nFontIndex, FX_FLOAT fFontSize) { CFX_ByteTextBuf sRet; - if (pFontMap) { CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); - if (sFontAlias.GetLength() > 0 && fFontSize > 0) sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; } - - return sRet.AsStringC(); + return sRet.MakeString(); } CFX_ByteString IFX_Edit::GetEditAppearanceStream( @@ -87,7 +84,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream( if (bContinuous) { if (place.LineCmp(oldplace) != 0) { if (sWords.GetSize() > 0) { - sEditStream << GetWordRenderString(sWords.AsStringC()); + sEditStream << GetWordRenderString(sWords.MakeString()); sWords.Clear(); } @@ -114,7 +111,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream( if (pIterator->GetWord(word)) { if (word.nFontIndex != nCurFontIndex) { if (sWords.GetSize() > 0) { - sEditStream << GetWordRenderString(sWords.AsStringC()); + sEditStream << GetWordRenderString(sWords.MakeString()); sWords.Clear(); } sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex, @@ -152,7 +149,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream( } if (sWords.GetSize() > 0) { - sEditStream << GetWordRenderString(sWords.AsStringC()); + sEditStream << GetWordRenderString(sWords.MakeString()); sWords.Clear(); } @@ -171,7 +168,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream( sAppStream << sEditStream; } - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } CFX_ByteString IFX_Edit::GetSelectAppearanceStream( @@ -200,5 +197,5 @@ CFX_ByteString IFX_Edit::GetSelectAppearanceStream( } } - return sRet.AsStringC(); + return sRet.MakeString(); } diff --git a/fpdfsdk/fxedit/fxet_pageobjs.cpp b/fpdfsdk/fxedit/fxet_pageobjs.cpp index 1fe29af283..e8d9e2a371 100644 --- a/fpdfsdk/fxedit/fxet_pageobjs.cpp +++ b/fpdfsdk/fxedit/fxet_pageobjs.cpp @@ -228,7 +228,7 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, - sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale); + sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale); sTextBuf.Clear(); } @@ -253,10 +253,10 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, } if (sTextBuf.GetLength() > 0) { - DrawTextString(pDevice, - CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), - pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, - sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale); + DrawTextString( + pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), + pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device, + sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale); } } @@ -340,7 +340,7 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, - sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale); + sTextBuf.MakeString(), crOld, 0, wp.nHorzScale); sTextBuf.Clear(); } @@ -381,7 +381,7 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, DrawTextString( pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device, - sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale); + sTextBuf.MakeString(), crOld, 0, wp.nHorzScale); } } @@ -483,7 +483,7 @@ void IFX_Edit::GeneratePageObjects( pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), - sTextBuf.AsStringC())); + sTextBuf.MakeString())); sTextBuf.Clear(); } @@ -502,7 +502,7 @@ void IFX_Edit::GeneratePageObjects( ObjArray.Add(AddTextObjToPageObjects( pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), - sTextBuf.AsStringC())); + sTextBuf.MakeString())); } } } @@ -551,7 +551,7 @@ void IFX_Edit::GenerateRichPageObjects( pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, wp.fCharSpace, wp.nHorzScale, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), - sTextBuf.AsStringC())); + sTextBuf.MakeString())); sTextBuf.Clear(); } @@ -594,7 +594,7 @@ void IFX_Edit::GenerateRichPageObjects( pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, wp.fCharSpace, wp.nHorzScale, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), - sTextBuf.AsStringC())); + sTextBuf.MakeString())); } } } diff --git a/fpdfsdk/pdfwindow/PWL_Caret.cpp b/fpdfsdk/pdfwindow/PWL_Caret.cpp index 88ce429c85..a5728ceac8 100644 --- a/fpdfsdk/pdfwindow/PWL_Caret.cpp +++ b/fpdfsdk/pdfwindow/PWL_Caret.cpp @@ -95,7 +95,7 @@ CFX_ByteString CPWL_Caret::GetCaretAppearanceStream( const CFX_FloatPoint& ptOffset) { CFX_ByteTextBuf sCaret; GetCaretApp(sCaret, ptOffset); - return sCaret.AsStringC(); + return sCaret.MakeString(); } void CPWL_Caret::TimerProc() { diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index 80aa629a06..ae95570d6c 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -503,13 +503,11 @@ CFX_ByteString CPWL_Edit::GetTextAppearanceStream( const CFX_FloatPoint& ptOffset) const { CFX_ByteTextBuf sRet; CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); - if (sEdit.GetLength() > 0) { sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC() << sEdit.AsStringC() << "ET\n"; } - - return sRet.AsStringC(); + return sRet.MakeString(); } CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( diff --git a/fpdfsdk/pdfwindow/PWL_Icon.cpp b/fpdfsdk/pdfwindow/PWL_Icon.cpp index 08ba970225..cfd62dfcd9 100644 --- a/fpdfsdk/pdfwindow/PWL_Icon.cpp +++ b/fpdfsdk/pdfwindow/PWL_Icon.cpp @@ -46,7 +46,7 @@ CFX_ByteString CPWL_Image::GetImageAppStream() { << "Q\n"; } - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } void CPWL_Image::SetPDFStream(CPDF_Stream* pStream) { diff --git a/fpdfsdk/pdfwindow/PWL_Label.cpp b/fpdfsdk/pdfwindow/PWL_Label.cpp index 7abeb0d558..203ec49e0f 100644 --- a/fpdfsdk/pdfwindow/PWL_Label.cpp +++ b/fpdfsdk/pdfwindow/PWL_Label.cpp @@ -123,13 +123,11 @@ CFX_ByteString CPWL_Label::GetTextAppearanceStream( const CFX_FloatPoint& ptOffset) const { CFX_ByteTextBuf sRet; CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); - if (sEdit.GetLength() > 0) { sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC() << sEdit.AsStringC() << "ET\n"; } - - return sRet.AsStringC(); + return sRet.MakeString(); } CFX_WideString CPWL_Label::GetText() const { diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp index 2e60471927..60949abd4e 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp @@ -44,7 +44,7 @@ CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, } } - return csAP.AsStringC(); + return csAP.MakeString(); } void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, @@ -185,7 +185,7 @@ CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) { << pts[nNext][0].y << " c\n"; } - return csAP.AsStringC(); + return csAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) { @@ -227,7 +227,7 @@ CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) { csAP << pt4.x - px * FX_BEZIER << " " << pt4.y << " " << pt1.x << " " << pt1.y - py * FX_BEZIER << " " << pt1.x << " " << pt1.y << " c\n"; - return csAP.AsStringC(); + return csAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) { @@ -238,7 +238,7 @@ CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) { csAP << crBBox.left << " " << crBBox.bottom << " m\n"; csAP << crBBox.right << " " << crBBox.top << " l\n"; - return csAP.AsStringC(); + return csAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) { @@ -258,7 +258,7 @@ CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) { csAP << pt4.x << " " << pt4.y << " l\n"; csAP << pt1.x << " " << pt1.y << " l\n"; - return csAP.AsStringC(); + return csAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) { @@ -270,7 +270,7 @@ CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) { csAP << crBBox.left << " " << crBBox.bottom << " l\n"; csAP << crBBox.left << " " << crBBox.top << " l\n"; - return csAP.AsStringC(); + return csAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) { @@ -302,7 +302,7 @@ CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) { csAP << px[nNext] << " " << py[nNext] << " l\n"; } - return csAP.AsStringC(); + return csAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox, @@ -337,7 +337,7 @@ CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox, csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " " << pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n"; - return csAP.AsStringC(); + return csAP.MakeString(); } CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect, @@ -378,7 +378,6 @@ CFX_FloatRect CPWL_Utils::ScaleRect(const CFX_FloatRect& rcRect, CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect, const CPWL_Color& color) { CFX_ByteTextBuf sAppStream; - CFX_ByteString sColor = GetColorAppStream(color, TRUE); if (sColor.GetLength() > 0) { sAppStream << "q\n" << sColor; @@ -387,19 +386,17 @@ CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect, << " re f\nQ\n"; } - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect, const CPWL_Color& color) { CFX_ByteTextBuf sAppStream; - CFX_ByteString sColor = GetColorAppStream(color, TRUE); if (sColor.GetLength() > 0) { sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n"; } - - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) { @@ -462,7 +459,7 @@ CFX_ByteString CPWL_Utils::GetTextAppStream(const CFX_FloatRect& rcBBox, sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"; IFX_Edit::DelEdit(pEdit); - return sRet.AsStringC(); + return sRet.MakeString(); } CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox, @@ -678,7 +675,6 @@ CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox, } IFX_Edit::DelEdit(pEdit); - if (sTemp.GetSize() > 0) { sAppStream << "q\n" << rcBBox.left << " " << rcBBox.bottom << " " @@ -686,8 +682,7 @@ CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox, << rcBBox.top - rcBBox.bottom << " re W n\n"; sAppStream << sTemp << "Q\n"; } - - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color, @@ -711,7 +706,7 @@ CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color, break; } - return sColorStream.AsStringC(); + return sColorStream.MakeString(); } CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, @@ -827,7 +822,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, sAppStream << "Q\n"; } - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( @@ -926,7 +921,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( sAppStream << "Q\n"; } - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor, @@ -985,7 +980,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox, CFX_ByteTextBuf sAP; sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n"; - return sAP.AsStringC(); + return sAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox, @@ -993,7 +988,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox, CFX_ByteTextBuf sAP; sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n"; - return sAP.AsStringC(); + return sAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox, @@ -1001,7 +996,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox, CFX_ByteTextBuf sAP; sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, FALSE) << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n"; - return sAP.AsStringC(); + return sAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox, @@ -1009,7 +1004,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox, CFX_ByteTextBuf sAP; sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n"; - return sAP.AsStringC(); + return sAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox, @@ -1017,7 +1012,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox, CFX_ByteTextBuf sAP; sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n"; - return sAP.AsStringC(); + return sAP.MakeString(); } CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox, @@ -1025,7 +1020,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox, CFX_ByteTextBuf sAP; sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n"; - return sAP.AsStringC(); + return sAP.MakeString(); } CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox, @@ -1104,7 +1099,7 @@ CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) { } } - return sAppStream.AsStringC(); + return sAppStream.MakeString(); } void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC, diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index a2eab8a60d..1e0fede4be 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -1480,7 +1480,7 @@ int32_t CFWL_EditImp::AddDoRecord(const CFX_ByteStringC& bsDoRecord) { m_RecordArr.RemoveAt(i); } } - m_RecordArr.Add(bsDoRecord); + m_RecordArr.Add(CFX_ByteString(bsDoRecord)); return m_iCurRecord = m_RecordArr.GetSize() - 1; } void CFWL_EditImp::Layout() { -- cgit v1.2.3