summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_edit
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/fpdfapi/fpdf_edit
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/fpdfapi/fpdf_edit')
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index c1ef37dab6..65bb3d985e 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -15,6 +15,8 @@
#define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024)
#define PDF_XREFSTREAM_MAXSIZE 10000
+// TODO(ochang): Make helper for appending "objnum 0 R ".
+
namespace {
int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
@@ -112,10 +114,9 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
}
offset += 2;
const CPDF_Dictionary* p = pObj->AsDictionary();
- FX_POSITION pos = p->GetStartPos();
- while (pos) {
- CFX_ByteString key;
- CPDF_Object* pValue = p->GetNextElement(pos, key);
+ for (const auto& it : *p) {
+ const CFX_ByteString& key = it.first;
+ CPDF_Object* pValue = it.second;
if (pFile->AppendString("/") < 0) {
return -1;
}
@@ -184,10 +185,9 @@ int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument,
CPDF_Parser* pParser = (CPDF_Parser*)pDocument->GetParser();
if (pParser) {
CPDF_Dictionary* p = pParser->GetTrailer();
- FX_POSITION pos = p->GetStartPos();
- while (pos) {
- CFX_ByteString key;
- CPDF_Object* pValue = p->GetNextElement(pos, key);
+ for (const auto& it : *p) {
+ const CFX_ByteString& key = it.first;
+ CPDF_Object* pValue = it.second;
if (key == "Encrypt" || key == "Size" || key == "Filter" ||
key == "Index" || key == "Length" || key == "Prev" || key == "W" ||
key == "XRefStm" || key == "Type" || key == "ID") {
@@ -1238,11 +1238,10 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
m_Offset += 2;
const CPDF_Dictionary* p = pObj->AsDictionary();
bool bSignDict = IsSignatureDict(p);
- FX_POSITION pos = p->GetStartPos();
- while (pos) {
+ for (const auto& it : *p) {
FX_BOOL bSignValue = FALSE;
- CFX_ByteString key;
- CPDF_Object* pValue = p->GetNextElement(pos, key);
+ const CFX_ByteString& key = it.first;
+ CPDF_Object* pValue = it.second;
if (m_File.AppendString("/") < 0) {
return -1;
}
@@ -1773,10 +1772,11 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
}
if (m_pParser) {
CPDF_Dictionary* p = m_pParser->m_pTrailer;
- FX_POSITION pos = p->GetStartPos();
- while (pos) {
- CFX_ByteString key;
- CPDF_Object* pValue = p->GetNextElement(pos, key);
+ for (const auto& it : *p) {
+ const CFX_ByteString& key = it.first;
+ CPDF_Object* pValue = it.second;
+ // TODO(ochang): Consolidate with similar check in
+ // PDF_CreatorWriteTrailer.
if (key == "Encrypt" || key == "Size" || key == "Filter" ||
key == "Index" || key == "Length" || key == "Prev" || key == "W" ||
key == "XRefStm" || key == "ID") {