summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc
diff options
context:
space:
mode:
authorOliver Chang <ochang@chromium.org>2016-01-11 08:30:17 -0800
committerOliver Chang <ochang@chromium.org>2016-01-11 08:30:17 -0800
commit14f39950451bb9c2a11fbc7173fd47367410f80f (patch)
treecec41364915b38e6a7709c76fc2fb02f6994990a /core/src/fpdfdoc
parent9adfbb0920a258e916003b1ee9515e97879db82a (diff)
downloadpdfium-14f39950451bb9c2a11fbc7173fd47367410f80f.tar.xz
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. R=tsepez@chromium.org, thestig@chromium.org Review URL: https://codereview.chromium.org/1541703003 .
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r--core/src/fpdfdoc/doc_action.cpp31
-rw-r--r--core/src/fpdfdoc/doc_formcontrol.cpp21
-rw-r--r--core/src/fpdfdoc/doc_utils.cpp47
3 files changed, 25 insertions, 74 deletions
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp
index e68a8c8a06..28d17cd673 100644
--- a/core/src/fpdfdoc/doc_action.cpp
+++ b/core/src/fpdfdoc/doc_action.cpp
@@ -257,37 +257,6 @@ CPDF_Action CPDF_AAction::GetAction(AActionType eType) const {
}
return CPDF_Action(m_pDict->GetDict(g_sAATypes[(int)eType]));
}
-FX_POSITION CPDF_AAction::GetStartPos() const {
- if (!m_pDict) {
- return NULL;
- }
- return m_pDict->GetStartPos();
-}
-CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos,
- AActionType& eType) const {
- if (!m_pDict) {
- return CPDF_Action();
- }
- CFX_ByteString csKey;
- CPDF_Object* pObj = m_pDict->GetNextElement(pos, csKey);
- if (!pObj) {
- return CPDF_Action();
- }
- CPDF_Object* pDirect = pObj->GetDirect();
- CPDF_Dictionary* pDict = ToDictionary(pDirect);
- if (!pDict)
- return CPDF_Action();
-
- int i = 0;
- while (g_sAATypes[i][0] != '\0') {
- if (csKey == g_sAATypes[i]) {
- break;
- }
- i++;
- }
- eType = (AActionType)i;
- return CPDF_Action(pDict);
-}
CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {}
diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp
index 29d3211f30..6c3d1ec9c4 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -29,11 +29,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();
@@ -56,10 +54,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;
}
@@ -68,10 +64,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;
}
diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp
index 0f54198c6f..4856cb51e5 100644
--- a/core/src/fpdfdoc/doc_utils.cpp
+++ b/core/src/fpdfdoc/doc_utils.cpp
@@ -281,11 +281,8 @@ FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) {
return 0;
}
FX_DWORD dwCount = 0;
- FX_POSITION pos = pFonts->GetStartPos();
- while (pos) {
- CPDF_Object* pObj = NULL;
- CFX_ByteString csKey;
- pObj = pFonts->GetNextElement(pos, csKey);
+ for (const auto& it : *pFonts) {
+ CPDF_Object* pObj = it.second;
if (!pObj) {
continue;
}
@@ -313,11 +310,9 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
return NULL;
}
FX_DWORD dwCount = 0;
- FX_POSITION pos = pFonts->GetStartPos();
- while (pos) {
- CPDF_Object* pObj = NULL;
- CFX_ByteString csKey;
- pObj = pFonts->GetNextElement(pos, csKey);
+ for (const auto& it : *pFonts) {
+ const CFX_ByteString& csKey = it.first;
+ CPDF_Object* pObj = it.second;
if (!pObj) {
continue;
}
@@ -373,11 +368,9 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
if (!pFonts) {
return NULL;
}
- FX_POSITION pos = pFonts->GetStartPos();
- while (pos) {
- CPDF_Object* pObj = NULL;
- CFX_ByteString csKey;
- pObj = pFonts->GetNextElement(pos, csKey);
+ for (const auto& it : *pFonts) {
+ const CFX_ByteString& csKey = it.first;
+ CPDF_Object* pObj = it.second;
if (!pObj) {
continue;
}
@@ -416,11 +409,9 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
if (!pFonts) {
return NULL;
}
- FX_POSITION pos = pFonts->GetStartPos();
- while (pos) {
- CPDF_Object* pObj = NULL;
- CFX_ByteString csKey;
- pObj = pFonts->GetNextElement(pos, csKey);
+ for (const auto& it : *pFonts) {
+ const CFX_ByteString& csKey = it.first;
+ CPDF_Object* pObj = it.second;
if (!pObj) {
continue;
}
@@ -474,11 +465,9 @@ FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
if (!pFonts) {
return FALSE;
}
- FX_POSITION pos = pFonts->GetStartPos();
- while (pos) {
- CPDF_Object* pObj = NULL;
- CFX_ByteString csKey;
- pObj = pFonts->GetNextElement(pos, csKey);
+ for (const auto& it : *pFonts) {
+ const CFX_ByteString& csKey = it.first;
+ CPDF_Object* pObj = it.second;
if (!pObj) {
continue;
}
@@ -514,11 +503,9 @@ FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
if (csFontName.GetLength() > 0) {
csFontName.Remove(' ');
}
- FX_POSITION pos = pFonts->GetStartPos();
- while (pos) {
- CPDF_Object* pObj = NULL;
- CFX_ByteString csKey, csTmp;
- pObj = pFonts->GetNextElement(pos, csKey);
+ for (const auto& it : *pFonts) {
+ const CFX_ByteString& csKey = it.first;
+ CPDF_Object* pObj = it.second;
if (!pObj) {
continue;
}