diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 32 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_tagged.cpp | 30 | ||||
-rw-r--r-- | core/src/fpdfdoc/tagged_int.h | 9 | ||||
-rw-r--r-- | core/src/fxge/android/fpf_skiafontmgr.cpp | 23 | ||||
-rw-r--r-- | core/src/fxge/android/fpf_skiafontmgr.h | 6 |
5 files changed, 45 insertions, 55 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index cd22b31238..97c5a75082 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -161,14 +161,7 @@ void CPDF_Parser::CloseParser(FX_BOOL bReParse) { m_Syntax.m_pFileAccess->Release(); m_Syntax.m_pFileAccess = NULL; } - FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); - while (pos) { - void* objnum; - CPDF_StreamAcc* pStream; - m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); - delete pStream; - } - m_ObjectStreamMap.RemoveAll(); + m_ObjectStreamMap.clear(); m_ObjCache.clear(); m_SortedOffset.RemoveAll(); @@ -616,7 +609,7 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV5(FX_FILESIZE xrefpos) { return FALSE; } } - m_ObjectStreamMap.InitHashTable(101, FALSE); + m_ObjectStreamMap.clear(); m_bXRefStream = TRUE; return TRUE; } @@ -1252,18 +1245,18 @@ CPDF_Object* CPDF_Parser::ParseIndirectObject( } CPDF_StreamAcc* CPDF_Parser::GetObjectStream(FX_DWORD objnum) { - CPDF_StreamAcc* pStreamAcc = nullptr; - if (m_ObjectStreamMap.Lookup((void*)(uintptr_t)objnum, (void*&)pStreamAcc)) - return pStreamAcc; + auto it = m_ObjectStreamMap.find(objnum); + if (it != m_ObjectStreamMap.end()) + return it->second.get(); const CPDF_Stream* pStream = ToStream( m_pDocument ? m_pDocument->GetIndirectObject(objnum, nullptr) : nullptr); if (!pStream) return nullptr; - pStreamAcc = new CPDF_StreamAcc; + CPDF_StreamAcc* pStreamAcc = new CPDF_StreamAcc; pStreamAcc->LoadAllData(pStream); - m_ObjectStreamMap.SetAt((void*)(uintptr_t)objnum, pStreamAcc); + m_ObjectStreamMap[objnum].reset(pStreamAcc); return pStreamAcc; } @@ -1671,7 +1664,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV5(FX_FILESIZE xrefpos) { return FALSE; } } - m_ObjectStreamMap.InitHashTable(101, FALSE); + m_ObjectStreamMap.clear(); m_bXRefStream = TRUE; return TRUE; } @@ -1695,14 +1688,7 @@ FX_DWORD CPDF_Parser::LoadLinearizedMainXRefTable() { m_Syntax.GetNextChar(ch); } m_LastXRefOffset += dwCount; - FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); - while (pos) { - void* objnum; - CPDF_StreamAcc* pStream; - m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); - delete pStream; - } - m_ObjectStreamMap.RemoveAll(); + m_ObjectStreamMap.clear(); m_ObjCache.clear(); if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp index d51743b0dc..3510eb6c8e 100644 --- a/core/src/fpdfdoc/doc_tagged.cpp +++ b/core/src/fpdfdoc/doc_tagged.cpp @@ -93,7 +93,7 @@ void CPDF_StructTreeImpl::LoadPageTree(const CPDF_Dictionary* pPageDict) { for (i = 0; i < dwKids; i++) { m_Kids[i] = NULL; } - CFX_MapPtrToPtr element_map; + std::map<CPDF_Dictionary*, CPDF_StructElementImpl*> element_map; CPDF_Dictionary* pParentTree = m_pTreeRoot->GetDict("ParentTree"); if (!pParentTree) { return; @@ -114,23 +114,25 @@ void CPDF_StructTreeImpl::LoadPageTree(const CPDF_Dictionary* pPageDict) { } } } -CPDF_StructElementImpl* CPDF_StructTreeImpl::AddPageNode(CPDF_Dictionary* pDict, - CFX_MapPtrToPtr& map, - int nLevel) { - if (nLevel > nMaxRecursion) { +CPDF_StructElementImpl* CPDF_StructTreeImpl::AddPageNode( + CPDF_Dictionary* pDict, + std::map<CPDF_Dictionary*, CPDF_StructElementImpl*>& map, + int nLevel) { + if (nLevel > nMaxRecursion) return NULL; - } - CPDF_StructElementImpl* pElement = NULL; - if (map.Lookup(pDict, (void*&)pElement)) { - return pElement; - } - pElement = new CPDF_StructElementImpl(this, NULL, pDict); - map.SetAt(pDict, pElement); + + auto it = map.find(pDict); + if (it != map.end()) + return it->second; + + CPDF_StructElementImpl* pElement = + new CPDF_StructElementImpl(this, NULL, pDict); + map[pDict] = pElement; CPDF_Dictionary* pParent = pDict->GetDict("P"); if (!pParent || pParent->GetString("Type") == "StructTreeRoot") { if (!AddTopLevelNode(pDict, pElement)) { pElement->Release(); - map.RemoveKey(pDict); + map.erase(pDict); } } else { CPDF_StructElementImpl* pParentElement = @@ -148,7 +150,7 @@ CPDF_StructElementImpl* CPDF_StructTreeImpl::AddPageNode(CPDF_Dictionary* pDict, } if (!bSave) { pElement->Release(); - map.RemoveKey(pDict); + map.erase(pDict); } } return pElement; diff --git a/core/src/fpdfdoc/tagged_int.h b/core/src/fpdfdoc/tagged_int.h index b9ae86bc6a..7dc9549569 100644 --- a/core/src/fpdfdoc/tagged_int.h +++ b/core/src/fpdfdoc/tagged_int.h @@ -7,6 +7,8 @@ #ifndef CORE_SRC_FPDFDOC_TAGGED_INT_H_ #define CORE_SRC_FPDFDOC_TAGGED_INT_H_ +#include <map> + #include "core/include/fpdfdoc/fpdf_tagged.h" class CPDF_StructElementImpl; @@ -24,9 +26,10 @@ class CPDF_StructTreeImpl : public CPDF_StructTree { void LoadDocTree(); void LoadPageTree(const CPDF_Dictionary* pPageDict); - CPDF_StructElementImpl* AddPageNode(CPDF_Dictionary* pElement, - CFX_MapPtrToPtr& map, - int nLevel = 0); + CPDF_StructElementImpl* AddPageNode( + CPDF_Dictionary* pElement, + std::map<CPDF_Dictionary*, CPDF_StructElementImpl*>& map, + int nLevel = 0); FX_BOOL AddTopLevelNode(CPDF_Dictionary* pDict, CPDF_StructElementImpl* pElement); diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp index 9dbe35d0e5..d4de2b812e 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.cpp +++ b/core/src/fxge/android/fpf_skiafontmgr.cpp @@ -219,14 +219,11 @@ CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() : m_bLoaded(FALSE), m_FTLibrary(NULL) {} CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() { void* pkey = NULL; CFPF_SkiaFont* pValue = NULL; - FX_POSITION pos = m_FamilyFonts.GetStartPosition(); - while (pos) { - m_FamilyFonts.GetNextAssoc(pos, pkey, (void*&)pValue); - if (pValue) { - pValue->Release(); - } + for (const auto& pair : m_FamilyFonts) { + if (pair.second) + pair.second->Release(); } - m_FamilyFonts.RemoveAll(); + m_FamilyFonts.clear(); for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) { CFPF_SkiaFontDescriptor* pFont = (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(i); @@ -259,12 +256,10 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, FX_DWORD dwStyle, FX_DWORD dwMatch) { FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset); - IFPF_Font* pFont = NULL; - if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { - if (pFont) { - return pFont->Retain(); - } - } + auto it = m_FamilyFonts.find(dwHash); + if (it != m_FamilyFonts.end() && it->second) + return it->second->Retain(); + FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname); FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName); FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName); @@ -335,7 +330,7 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(nItem); CFPF_SkiaFont* pFont = new CFPF_SkiaFont; if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) { - m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + m_FamilyFonts[dwHash] = pFont; return pFont->Retain(); } pFont->Release(); diff --git a/core/src/fxge/android/fpf_skiafontmgr.h b/core/src/fxge/android/fpf_skiafontmgr.h index cd503f58a9..4625e8c605 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.h +++ b/core/src/fxge/android/fpf_skiafontmgr.h @@ -9,6 +9,8 @@ #if _FX_OS_ == _FX_ANDROID_ +#include <map> + #include "core/include/fxge/fpf.h" #define FPF_SKIAFONTTYPE_Unknown 0 @@ -16,6 +18,8 @@ #define FPF_SKIAFONTTYPE_File 2 #define FPF_SKIAFONTTYPE_Buffer 3 +class CFPF_SkiaFont; + class CFPF_SkiaFontDescriptor { public: CFPF_SkiaFontDescriptor() @@ -110,7 +114,7 @@ class CFPF_SkiaFontMgr : public IFPF_FontMgr { FX_BOOL m_bLoaded; CFX_PtrArray m_FontFaces; FXFT_Library m_FTLibrary; - CFX_MapPtrToPtr m_FamilyFonts; + std::map<FX_DWORD, CFPF_SkiaFont*> m_FamilyFonts; }; #endif |