summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc
diff options
context:
space:
mode:
authorOliver Chang <ochang@chromium.org>2016-01-11 08:45:31 -0800
committerOliver Chang <ochang@chromium.org>2016-01-11 08:45:31 -0800
commit3f1c71f5a6ea058e3eec611c9dcc759b374dcb80 (patch)
treeb4ef8de26360979381c441cbdfaba94e493b09f6 /core/src/fpdfdoc
parentc909ce872d999a17ffd44afdc88caf2de43e6cba (diff)
downloadpdfium-3f1c71f5a6ea058e3eec611c9dcc759b374dcb80.tar.xz
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 .
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 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;
}
diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp
index 01a7470ef0..89836739b3 100644
--- a/core/src/fpdfdoc/doc_utils.cpp
+++ b/core/src/fpdfdoc/doc_utils.cpp
@@ -279,11 +279,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;
}
@@ -311,11 +308,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;
}
@@ -371,11 +366,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;
}
@@ -414,11 +407,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;
}
@@ -472,11 +463,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;
}
@@ -512,11 +501,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;
}