From 3f1c71f5a6ea058e3eec611c9dcc759b374dcb80 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Mon, 11 Jan 2016 08:45:31 -0800 Subject: Merge to XFA: Use std::map as CPDF_Dictionary's underlying store. Replaces CFX_CMapByteStringToPtr. XFA still uses CFX_CMapByteStringToPtr so it's not completely removed just yet. Adds begin()/end() to CPDF_Dictionary and removes the GetStartPos()/GetNextElement() functions to traverse the dictionary. Callers are changed accordingly. AddValue() is also removed. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1541703003 . (cherry picked from commit 14f39950451bb9c2a11fbc7173fd47367410f80f) Review URL: https://codereview.chromium.org/1576033002 . --- core/src/fpdfdoc/doc_formcontrol.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'core/src/fpdfdoc/doc_formcontrol.cpp') diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp index 93e837feaf..bd339e375c 100644 --- a/core/src/fpdfdoc/doc_formcontrol.cpp +++ b/core/src/fpdfdoc/doc_formcontrol.cpp @@ -27,11 +27,9 @@ CFX_ByteString CPDF_FormControl::GetOnStateName() { if (!pN) { return csOn; } - FX_POSITION pos = pN->GetStartPos(); - while (pos) { - pN->GetNextElement(pos, csOn); - if (csOn != "Off") { - return csOn; + for (const auto& it : *pN) { + if (it.first != "Off") { + return it.first; } } return CFX_ByteString(); @@ -54,10 +52,8 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) { if (!pAP) { return; } - FX_POSITION pos1 = pAP->GetStartPos(); - while (pos1) { - CFX_ByteString csKey1; - CPDF_Object* pObj1 = pAP->GetNextElement(pos1, csKey1); + for (const auto& it : *pAP) { + CPDF_Object* pObj1 = it.second; if (!pObj1) { continue; } @@ -66,10 +62,9 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) { if (!pSubDict) continue; - FX_POSITION pos2 = pSubDict->GetStartPos(); - while (pos2) { - CFX_ByteString csKey2; - CPDF_Object* pObj2 = pSubDict->GetNextElement(pos2, csKey2); + for (const auto& subdict_it : *pSubDict) { + const CFX_ByteString& csKey2 = subdict_it.first; + CPDF_Object* pObj2 = subdict_it.second; if (!pObj2) { continue; } -- cgit v1.2.3