diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp | 5 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_doc.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 16 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp | 79 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_parser.cpp | 7 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h | 60 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_fontmap.cpp | 5 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.cpp | 16 | ||||
-rw-r--r-- | core/fpdfdoc/doc_annot.cpp | 4 | ||||
-rw-r--r-- | core/fpdfdoc/doc_basic.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/doc_form.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/doc_formcontrol.cpp | 6 | ||||
-rw-r--r-- | core/fpdfdoc/doc_formfield.cpp | 6 | ||||
-rw-r--r-- | core/fpdfdoc/doc_ocg.cpp | 8 | ||||
-rw-r--r-- | core/fpdfdoc/doc_tagged.cpp | 7 | ||||
-rw-r--r-- | core/fpdfdoc/doc_utils.cpp | 9 |
19 files changed, 115 insertions, 129 deletions
diff --git a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp index 28cbdfc02e..20fd1959f2 100644 --- a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp @@ -74,13 +74,12 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource( int idnum = 1; while (1) { name.Format("FX%c%d", szType[0], idnum); - if (!pResList->KeyExist(name.AsStringC())) { + if (!pResList->KeyExist(name)) { break; } idnum++; } - pResList->AddReference(name.AsStringC(), m_pDocument, - pResourceObj->GetObjNum()); + pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum()); return name; } void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp index 6cd66185c6..b9019f8577 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.AsStringC()); + pCSObj = pList->GetDirectObjectBy(name); 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 654c9350a9..d2889d89b1 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.AsStringC(), m_pDocument, dwObjNum); + pDict->SetAtReference(key, m_pDocument, dwObjNum); else - pDict->SetAt(key.AsStringC(), pObj.release()); + pDict->SetAt(key, pObj.release()); } } PDF_ReplaceAbbr(pDict); @@ -721,7 +721,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { pList = m_pPageResources->GetDictBy("XObject"); if (!pList) return; - CPDF_Reference* pRes = ToReference(pList->GetObjectBy(name.AsStringC())); + CPDF_Reference* pRes = ToReference(pList->GetObjectBy(name)); if (!pRes) return; @@ -1258,7 +1258,7 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj( if (!pList) { return NULL; } - CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); + CPDF_Object* pRes = pList->GetDirectObjectBy(name); return pRes; } CPDF_Dictionary* pList = m_pResources->GetDictBy(type); @@ -1270,10 +1270,10 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj( if (!pList) { return NULL; } - CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); + CPDF_Object* pRes = pList->GetDirectObjectBy(name); return pRes; } - CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsStringC()); + CPDF_Object* pRes = pList->GetDirectObjectBy(name); return pRes; } @@ -1794,9 +1794,9 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) { } for (const auto& op : replacements) { if (op.is_replace_key) - pDict->ReplaceKey(op.key.AsStringC(), op.replacement); + pDict->ReplaceKey(op.key, op.replacement); else - pDict->SetAtName(op.key.AsStringC(), op.replacement); + pDict->SetAtName(op.key, op.replacement); } break; } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 48bb667ec7..940881bacb 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.AsStringC(), pObj); + pDict->SetAt(key, pObj); } else { pObj->Release(); } diff --git a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp index f03b14d8e1..27b866a65b 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp @@ -51,59 +51,58 @@ CPDF_Object* CPDF_Dictionary::Clone(FX_BOOL bDirect) const { return pCopy; } -CPDF_Object* CPDF_Dictionary::GetObjectBy(const CFX_ByteStringC& key) const { +CPDF_Object* CPDF_Dictionary::GetObjectBy(const CFX_ByteString& key) const { auto it = m_Map.find(key); - if (it == m_Map.end()) - return nullptr; - return it->second; + return it != m_Map.end() ? it->second : nullptr; } + CPDF_Object* CPDF_Dictionary::GetDirectObjectBy( - const CFX_ByteStringC& key) const { + const CFX_ByteString& key) const { CPDF_Object* p = GetObjectBy(key); return p ? p->GetDirect() : nullptr; } -CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key) const { +CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteString& key) const { CPDF_Object* p = GetObjectBy(key); return p ? p->GetString() : CFX_ByteString(); } CFX_WideString CPDF_Dictionary::GetUnicodeTextBy( - const CFX_ByteStringC& key) const { + const CFX_ByteString& key) const { CPDF_Object* p = GetObjectBy(key); if (CPDF_Reference* pRef = ToReference(p)) p = pRef->GetDirect(); return p ? p->GetUnicodeText() : CFX_WideString(); } -CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key, - const CFX_ByteStringC& def) const { +CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteString& key, + const CFX_ByteString& def) const { CPDF_Object* p = GetObjectBy(key); return p ? p->GetString() : CFX_ByteString(def); } -int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key) const { +int CPDF_Dictionary::GetIntegerBy(const CFX_ByteString& key) const { CPDF_Object* p = GetObjectBy(key); return p ? p->GetInteger() : 0; } -int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key, int def) const { +int CPDF_Dictionary::GetIntegerBy(const CFX_ByteString& key, int def) const { CPDF_Object* p = GetObjectBy(key); return p ? p->GetInteger() : def; } -FX_FLOAT CPDF_Dictionary::GetNumberBy(const CFX_ByteStringC& key) const { +FX_FLOAT CPDF_Dictionary::GetNumberBy(const CFX_ByteString& key) const { CPDF_Object* p = GetObjectBy(key); return p ? p->GetNumber() : 0; } -FX_BOOL CPDF_Dictionary::GetBooleanBy(const CFX_ByteStringC& key, +FX_BOOL CPDF_Dictionary::GetBooleanBy(const CFX_ByteString& key, FX_BOOL bDefault) const { CPDF_Object* p = GetObjectBy(key); return ToBoolean(p) ? p->GetInteger() : bDefault; } -CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteStringC& key) const { +CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteString& key) const { CPDF_Object* p = GetDirectObjectBy(key); if (!p) return nullptr; @@ -114,15 +113,15 @@ CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteStringC& key) const { return nullptr; } -CPDF_Array* CPDF_Dictionary::GetArrayBy(const CFX_ByteStringC& key) const { +CPDF_Array* CPDF_Dictionary::GetArrayBy(const CFX_ByteString& key) const { return ToArray(GetDirectObjectBy(key)); } -CPDF_Stream* CPDF_Dictionary::GetStreamBy(const CFX_ByteStringC& key) const { +CPDF_Stream* CPDF_Dictionary::GetStreamBy(const CFX_ByteString& key) const { return ToStream(GetDirectObjectBy(key)); } -CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteStringC& key) const { +CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteString& key) const { CFX_FloatRect rect; CPDF_Array* pArray = GetArrayBy(key); if (pArray) @@ -130,7 +129,7 @@ CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteStringC& key) const { return rect; } -CFX_Matrix CPDF_Dictionary::GetMatrixBy(const CFX_ByteStringC& key) const { +CFX_Matrix CPDF_Dictionary::GetMatrixBy(const CFX_ByteString& key) const { CFX_Matrix matrix; CPDF_Array* pArray = GetArrayBy(key); if (pArray) @@ -138,7 +137,7 @@ CFX_Matrix CPDF_Dictionary::GetMatrixBy(const CFX_ByteStringC& key) const { return matrix; } -FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const { +FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteString& key) const { return pdfium::ContainsKey(m_Map, key); } @@ -149,14 +148,11 @@ bool CPDF_Dictionary::IsSignatureDict() const { return pType && pType->GetString() == "Sig"; } -void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) { - ASSERT(IsDictionary()); - // Avoid 2 constructions of CFX_ByteString. - CFX_ByteString key_bytestring = key; - auto it = m_Map.find(key_bytestring); +void CPDF_Dictionary::SetAt(const CFX_ByteString& key, CPDF_Object* pObj) { + auto it = m_Map.find(key); if (it == m_Map.end()) { if (pObj) - m_Map.insert(std::make_pair(key_bytestring, pObj)); + m_Map.insert(std::make_pair(key, pObj)); return; } @@ -170,7 +166,7 @@ void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) { m_Map.erase(it); } -void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) { +void CPDF_Dictionary::RemoveAt(const CFX_ByteString& key) { auto it = m_Map.find(key); if (it == m_Map.end()) return; @@ -179,15 +175,13 @@ void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) { m_Map.erase(it); } -void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey, - const CFX_ByteStringC& newkey) { +void CPDF_Dictionary::ReplaceKey(const CFX_ByteString& oldkey, + const CFX_ByteString& newkey) { auto old_it = m_Map.find(oldkey); if (old_it == m_Map.end()) return; - // Avoid 2 constructions of CFX_ByteString. - CFX_ByteString newkey_bytestring = newkey; - auto new_it = m_Map.find(newkey_bytestring); + auto new_it = m_Map.find(newkey); if (new_it == old_it) return; @@ -195,47 +189,46 @@ void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey, new_it->second->Release(); new_it->second = old_it->second; } else { - m_Map.insert(std::make_pair(newkey_bytestring, old_it->second)); + m_Map.insert(std::make_pair(newkey, old_it->second)); } m_Map.erase(old_it); } -void CPDF_Dictionary::SetAtInteger(const CFX_ByteStringC& key, int i) { +void CPDF_Dictionary::SetAtInteger(const CFX_ByteString& key, int i) { SetAt(key, new CPDF_Number(i)); } -void CPDF_Dictionary::SetAtName(const CFX_ByteStringC& key, +void CPDF_Dictionary::SetAtName(const CFX_ByteString& key, const CFX_ByteString& name) { SetAt(key, new CPDF_Name(name)); } -void CPDF_Dictionary::SetAtString(const CFX_ByteStringC& key, +void CPDF_Dictionary::SetAtString(const CFX_ByteString& key, const CFX_ByteString& str) { SetAt(key, new CPDF_String(str, FALSE)); } -void CPDF_Dictionary::SetAtReference(const CFX_ByteStringC& key, +void CPDF_Dictionary::SetAtReference(const CFX_ByteString& key, CPDF_IndirectObjectHolder* pDoc, uint32_t objnum) { SetAt(key, new CPDF_Reference(pDoc, objnum)); } -void CPDF_Dictionary::AddReference(const CFX_ByteStringC& key, +void CPDF_Dictionary::AddReference(const CFX_ByteString& key, CPDF_IndirectObjectHolder* pDoc, uint32_t objnum) { SetAt(key, new CPDF_Reference(pDoc, objnum)); } -void CPDF_Dictionary::SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f) { - CPDF_Number* pNumber = new CPDF_Number(f); - SetAt(key, pNumber); +void CPDF_Dictionary::SetAtNumber(const CFX_ByteString& key, FX_FLOAT f) { + SetAt(key, new CPDF_Number(f)); } -void CPDF_Dictionary::SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue) { +void CPDF_Dictionary::SetAtBoolean(const CFX_ByteString& key, FX_BOOL bValue) { SetAt(key, new CPDF_Boolean(bValue)); } -void CPDF_Dictionary::SetAtRect(const CFX_ByteStringC& key, +void CPDF_Dictionary::SetAtRect(const CFX_ByteString& key, const CFX_FloatRect& rect) { CPDF_Array* pArray = new CPDF_Array; pArray->AddNumber(rect.left); @@ -245,7 +238,7 @@ void CPDF_Dictionary::SetAtRect(const CFX_ByteStringC& key, SetAt(key, pArray); } -void CPDF_Dictionary::SetAtMatrix(const CFX_ByteStringC& key, +void CPDF_Dictionary::SetAtMatrix(const CFX_ByteString& key, const CFX_Matrix& matrix) { CPDF_Array* pArray = new CPDF_Array; pArray->AddNumber(matrix.a); diff --git a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp index 3d0947d643..62f1357572 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp @@ -134,7 +134,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.AsStringC()))) + if (!Equal(it->second, dict2->GetObjectBy(it->first))) return false; } return true; @@ -556,7 +556,7 @@ TEST(PDFArrayTest, GetTypeAt) { char buf[33]; key.append(FXSYS_itoa(j, buf, 10)); int value = j + 200; - vals[i]->SetAt(CFX_ByteStringC(key.c_str()), new CPDF_Number(value)); + vals[i]->SetAt(key.c_str(), new CPDF_Number(value)); } arr->InsertAt(i, vals[i]); } @@ -583,7 +583,7 @@ TEST(PDFArrayTest, GetTypeAt) { char buf[33]; key.append(FXSYS_itoa(j, buf, 10)); int value = j + 200; - vals[i]->SetAt(CFX_ByteStringC(key.c_str()), new CPDF_Number(value)); + vals[i]->SetAt(key.c_str(), new CPDF_Number(value)); } uint8_t content[] = "content: this is a stream"; size_t data_size = FX_ArraySize(content); diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp index d6531f5184..7fed6a380c 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -822,11 +822,10 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { uint32_t dwObjNum = pElement ? pElement->GetObjNum() : 0; if (dwObjNum) { - m_pTrailer->SetAtReference(key.AsStringC(), - m_pDocument, dwObjNum); + m_pTrailer->SetAtReference(key, m_pDocument, + dwObjNum); } else { - m_pTrailer->SetAt(key.AsStringC(), - pElement->Clone()); + m_pTrailer->SetAt(key, pElement->Clone()); } } } diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index 16daba184d..5c3398d50a 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -590,7 +590,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( } if (key.GetLength() > 1) { - pDict->SetAt(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1), + pDict->SetAt(CFX_ByteString(key.c_str() + 1, key.GetLength() - 1), obj.release()); } } diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h b/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h index c39370e6ec..e3b7496da7 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h @@ -31,56 +31,56 @@ class CPDF_Dictionary : public CPDF_Object { const CPDF_Dictionary* AsDictionary() const override; size_t GetCount() const { return m_Map.size(); } - CPDF_Object* GetObjectBy(const CFX_ByteStringC& key) const; - CPDF_Object* GetDirectObjectBy(const CFX_ByteStringC& key) const; - CFX_ByteString GetStringBy(const CFX_ByteStringC& key) const; - CFX_ByteString GetStringBy(const CFX_ByteStringC& key, - const CFX_ByteStringC& default_str) const; - CFX_WideString GetUnicodeTextBy(const CFX_ByteStringC& key) const; - int GetIntegerBy(const CFX_ByteStringC& key) const; - int GetIntegerBy(const CFX_ByteStringC& key, int default_int) const; - FX_BOOL GetBooleanBy(const CFX_ByteStringC& key, + CPDF_Object* GetObjectBy(const CFX_ByteString& key) const; + CPDF_Object* GetDirectObjectBy(const CFX_ByteString& key) const; + CFX_ByteString GetStringBy(const CFX_ByteString& key) const; + CFX_ByteString GetStringBy(const CFX_ByteString& key, + const CFX_ByteString& default_str) const; + CFX_WideString GetUnicodeTextBy(const CFX_ByteString& key) const; + int GetIntegerBy(const CFX_ByteString& key) const; + int GetIntegerBy(const CFX_ByteString& key, int default_int) const; + FX_BOOL GetBooleanBy(const CFX_ByteString& key, FX_BOOL bDefault = FALSE) const; - FX_FLOAT GetNumberBy(const CFX_ByteStringC& key) const; - CPDF_Dictionary* GetDictBy(const CFX_ByteStringC& key) const; - CPDF_Stream* GetStreamBy(const CFX_ByteStringC& key) const; - CPDF_Array* GetArrayBy(const CFX_ByteStringC& key) const; - CFX_FloatRect GetRectBy(const CFX_ByteStringC& key) const; - CFX_Matrix GetMatrixBy(const CFX_ByteStringC& key) const; - FX_FLOAT GetFloatBy(const CFX_ByteStringC& key) const { + FX_FLOAT GetNumberBy(const CFX_ByteString& key) const; + CPDF_Dictionary* GetDictBy(const CFX_ByteString& key) const; + CPDF_Stream* GetStreamBy(const CFX_ByteString& key) const; + CPDF_Array* GetArrayBy(const CFX_ByteString& key) const; + CFX_FloatRect GetRectBy(const CFX_ByteString& key) const; + CFX_Matrix GetMatrixBy(const CFX_ByteString& key) const; + FX_FLOAT GetFloatBy(const CFX_ByteString& key) const { return GetNumberBy(key); } - FX_BOOL KeyExist(const CFX_ByteStringC& key) const; + FX_BOOL KeyExist(const CFX_ByteString& key) const; bool IsSignatureDict() const; // Set* functions invalidate iterators for the element with the key |key|. - void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj); - void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name); - void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& str); - void SetAtInteger(const CFX_ByteStringC& key, int i); - void SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f); - void SetAtReference(const CFX_ByteStringC& key, + void SetAt(const CFX_ByteString& key, CPDF_Object* pObj); + void SetAtName(const CFX_ByteString& key, const CFX_ByteString& name); + void SetAtString(const CFX_ByteString& key, const CFX_ByteString& str); + void SetAtInteger(const CFX_ByteString& key, int i); + void SetAtNumber(const CFX_ByteString& key, FX_FLOAT f); + void SetAtReference(const CFX_ByteString& key, CPDF_IndirectObjectHolder* pDoc, uint32_t objnum); - void SetAtReference(const CFX_ByteStringC& key, + void SetAtReference(const CFX_ByteString& key, CPDF_IndirectObjectHolder* pDoc, CPDF_Object* obj) { SetAtReference(key, pDoc, obj->GetObjNum()); } - void SetAtRect(const CFX_ByteStringC& key, const CFX_FloatRect& rect); - void SetAtMatrix(const CFX_ByteStringC& key, const CFX_Matrix& matrix); - void SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue); + void SetAtRect(const CFX_ByteString& key, const CFX_FloatRect& rect); + void SetAtMatrix(const CFX_ByteString& key, const CFX_Matrix& matrix); + void SetAtBoolean(const CFX_ByteString& key, FX_BOOL bValue); - void AddReference(const CFX_ByteStringC& key, + void AddReference(const CFX_ByteString& key, CPDF_IndirectObjectHolder* pDoc, uint32_t objnum); // Invalidates iterators for the element with the key |key|. - void RemoveAt(const CFX_ByteStringC& key); + void RemoveAt(const CFX_ByteString& key); // Invalidates iterators for the element with the key |oldkey|. - void ReplaceKey(const CFX_ByteStringC& oldkey, const CFX_ByteStringC& newkey); + void ReplaceKey(const CFX_ByteString& oldkey, const CFX_ByteString& newkey); iterator begin() { return m_Map.begin(); } iterator end() { return m_Map.end(); } diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index a0919ed084..d4171bd147 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -38,9 +38,8 @@ void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc, return; if (CPDF_Dictionary* pFontList = pResDict->GetDictBy("Font")) { - if (!pFontList->KeyExist(sSysFontAlias.AsStringC())) - pFontList->SetAtReference(sSysFontAlias.AsStringC(), pDoc, - pPDFFont->GetFontDict()); + if (!pFontList->KeyExist(sSysFontAlias)) + pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->GetFontDict()); } pSysFont = pPDFFont; } diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 3c2b47c275..06a64359e9 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -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).AsStringC()); + pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1)); if (!pFontDict && !bUseFormRes) { pDRDict = pFormDict->GetDictBy("DR"); pDRFontDict = pDRDict->GetDictBy("Font"); if (pDRFontDict) - pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsStringC()); + pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1)); } } if (!pDRFontDict) @@ -72,7 +72,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, pFontDict->SetAtName("BaseFont", "Helvetica"); pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); pDoc->AddIndirectObject(pFontDict); - pDRFontDict->SetAtReference(sFontName.Mid(1).AsStringC(), pDoc, pFontDict); + pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); } CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); if (!pDefFont) @@ -189,9 +189,8 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, pStreamResFontList = new CPDF_Dictionary; pStreamResList->SetAt("Font", pStreamResFontList); } - if (!pStreamResFontList->KeyExist(sFontName.AsStringC())) - pStreamResFontList->SetAtReference(sFontName.AsStringC(), pDoc, - pFontDict); + if (!pStreamResFontList->KeyExist(sFontName)) + pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); } else { pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone()); pStreamResList = pStreamDict->GetDictBy("Resources"); @@ -437,9 +436,8 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, pStreamResFontList = new CPDF_Dictionary; pStreamResList->SetAt("Font", pStreamResFontList); } - if (!pStreamResFontList->KeyExist(sFontName.AsStringC())) - pStreamResFontList->SetAtReference(sFontName.AsStringC(), pDoc, - pFontDict); + if (!pStreamResFontList->KeyExist(sFontName)) + pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); } else { pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone()); pStreamResList = pStreamDict->GetDictBy("Resources"); diff --git a/core/fpdfdoc/doc_annot.cpp b/core/fpdfdoc/doc_annot.cpp index 3b90b0b4b5..42d4a665fe 100644 --- a/core/fpdfdoc/doc_annot.cpp +++ b/core/fpdfdoc/doc_annot.cpp @@ -183,12 +183,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.AsStringC())) + if (value.IsEmpty() || !pDict->KeyExist(value)) as = "Off"; else as = value; } - return pDict->GetStreamBy(as.AsStringC()); + return pDict->GetStreamBy(as); } return nullptr; } diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp index 6d6e5c234f..a3e94cb033 100644 --- a/core/fpdfdoc/doc_basic.cpp +++ b/core/fpdfdoc/doc_basic.cpp @@ -482,7 +482,7 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { if (pLabel->KeyExist("P")) { wsLabel += pLabel->GetUnicodeTextBy("P"); } - CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", NULL); + CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", nullptr); int nLabelNum = nPage - n + pLabel->GetIntegerBy("St", 1); CFX_WideString wsNumPortion = _GetLabelNumPortion(nLabelNum, bsNumberingStyle); diff --git a/core/fpdfdoc/doc_form.cpp b/core/fpdfdoc/doc_form.cpp index 6ca40fdaf6..5062b45452 100644 --- a/core/fpdfdoc/doc_form.cpp +++ b/core/fpdfdoc/doc_form.cpp @@ -343,7 +343,7 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName( CFX_ByteString bsNum; while (TRUE) { CFX_ByteString csKey = csTmp + bsNum; - if (!pDict->KeyExist(csKey.AsStringC())) { + if (!pDict->KeyExist(csKey)) { return csKey; } if (m < iCount) { diff --git a/core/fpdfdoc/doc_formcontrol.cpp b/core/fpdfdoc/doc_formcontrol.cpp index b187ea7999..b833f89c17 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.AsStringC(), csValue.AsStringC()); + pSubDict->ReplaceKey(csKey2, csValue); break; } } @@ -286,7 +286,7 @@ 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.AsStringC()); + CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag); if (pElement) { CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); if (pFont) { @@ -303,7 +303,7 @@ 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.AsStringC()); + CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag); 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 7f0ff8716b..d9333eef90 100644 --- a/core/fpdfdoc/doc_formfield.cpp +++ b/core/fpdfdoc/doc_formfield.cpp @@ -1065,11 +1065,11 @@ void CPDF_FormField::LoadDA() { 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")) + m_pForm->m_pFormDict->GetDictBy("DR")->GetDictBy("Font")) { pFontDict = m_pForm->m_pFormDict->GetDictBy("DR") ->GetDictBy("Font") - ->GetDictBy(font_name.AsStringC()); - + ->GetDictBy(font_name); + } if (!pFontDict) { return; } diff --git a/core/fpdfdoc/doc_ocg.cpp b/core/fpdfdoc/doc_ocg.cpp index b4fb3e1c01..bea3c2ce33 100644 --- a/core/fpdfdoc/doc_ocg.cpp +++ b/core/fpdfdoc/doc_ocg.cpp @@ -138,7 +138,7 @@ FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, if (!pState) { continue; } - bState = pState->GetStringBy(csFind.AsStringC()) != "OFF"; + bState = pState->GetStringBy(csFind) != "OFF"; } } return bState; @@ -150,11 +150,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.AsStringC()); + CPDF_Dictionary* pState = pUsage->GetDictBy(csState); if (pState) { CFX_ByteString csFind = csState + "State"; - if (pState->KeyExist(csFind.AsStringC())) { - return pState->GetStringBy(csFind.AsStringC()) != "OFF"; + if (pState->KeyExist(csFind)) { + return pState->GetStringBy(csFind) != "OFF"; } } if (csState != "View") { diff --git a/core/fpdfdoc/doc_tagged.cpp b/core/fpdfdoc/doc_tagged.cpp index b60c83932e..f559c0ac2b 100644 --- a/core/fpdfdoc/doc_tagged.cpp +++ b/core/fpdfdoc/doc_tagged.cpp @@ -205,7 +205,7 @@ 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.AsStringC()); + CFX_ByteString mapped = pTree->m_pRoleMap->GetStringBy(m_Type); if (!mapped.IsEmpty()) { m_Type = mapped; } @@ -373,15 +373,14 @@ 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.AsStringC()); + CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name); 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.AsStringC()); + CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name); 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 2df7d97e31..ccb244d87c 100644 --- a/core/fpdfdoc/doc_utils.cpp +++ b/core/fpdfdoc/doc_utils.cpp @@ -386,7 +386,7 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, if (!pFonts) { return NULL; } - CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias.AsStringC()); + CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias); if (!pElement) { return NULL; } @@ -605,8 +605,7 @@ void AddInterFormFont(CPDF_Dictionary*& pFormDict, csNameTag.Remove(' '); csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag.c_str()); - pFonts->SetAtReference(csNameTag.AsStringC(), pDocument, - pFont->GetFontDict()); + pFonts->SetAtReference(csNameTag, pDocument, pFont->GetFontDict()); } CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, @@ -650,7 +649,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.AsStringC()); + pFonts->RemoveAt(csTag); } void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) { if (!pFormDict || csNameTag.IsEmpty()) { @@ -664,7 +663,7 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) { if (!pFonts) { return; } - pFonts->RemoveAt(csNameTag.AsStringC()); + pFonts->RemoveAt(csNameTag); } CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, |