From fcb6398ea511e32a09d192543f70041b82646df1 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 20 Jan 2016 14:33:49 -0800 Subject: Merge to XFA: Replace more CFX_MapPtrToPtr. Original Review URL: https://codereview.chromium.org/1580573002 . (cherry picked from commit a505d9d3e13485e090e50d5d83f882fb707d3f48) R=ochang@chromium.org Review URL: https://codereview.chromium.org/1610163003 . --- core/src/fpdfdoc/doc_tagged.cpp | 30 ++++++++++++++++-------------- core/src/fpdfdoc/tagged_int.h | 9 ++++++--- 2 files changed, 22 insertions(+), 17 deletions(-) (limited to 'core/src/fpdfdoc') 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 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& 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 + #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& map, + int nLevel = 0); FX_BOOL AddTopLevelNode(CPDF_Dictionary* pDict, CPDF_StructElementImpl* pElement); -- cgit v1.2.3