Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp

Issue 1541703003: Use std::map as CPDF_Dictionary's underlying store. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: XFA still uses CFX_CMapByteStringToPtr :( Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "editint.h" 7 #include "editint.h"
8 8
9 #include "core/include/fxcrt/fx_ext.h" 9 #include "core/include/fxcrt/fx_ext.h"
10 #include "core/include/fpdfapi/fpdf_serial.h" 10 #include "core/include/fpdfapi/fpdf_serial.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 offset += 1; 102 offset += 1;
103 break; 103 break;
104 } 104 }
105 case PDFOBJ_DICTIONARY: { 105 case PDFOBJ_DICTIONARY: {
106 if (pFile->AppendString("<<") < 0) { 106 if (pFile->AppendString("<<") < 0) {
107 return -1; 107 return -1;
108 } 108 }
109 offset += 2; 109 offset += 2;
110 const CPDF_Dictionary* p = pObj->AsDictionary(); 110 const CPDF_Dictionary* p = pObj->AsDictionary();
111 FX_POSITION pos = p->GetStartPos(); 111 for (const auto& it : *p) {
112 while (pos) { 112 const CFX_ByteString& key = it.first;
113 CFX_ByteString key; 113 CPDF_Object* pValue = it.second;
114 CPDF_Object* pValue = p->GetNextElement(pos, key);
115 if (pFile->AppendString("/") < 0) { 114 if (pFile->AppendString("/") < 0) {
116 return -1; 115 return -1;
117 } 116 }
118 if ((len = pFile->AppendString(PDF_NameEncode(key))) < 0) { 117 if ((len = pFile->AppendString(PDF_NameEncode(key))) < 0) {
119 return -1; 118 return -1;
120 } 119 }
121 offset += len + 1; 120 offset += len + 1;
122 if (pValue->GetObjNum()) { 121 if (pValue->GetObjNum()) {
123 if (pFile->AppendString(" ") < 0) { 122 if (pFile->AppendString(" ") < 0) {
124 return -1; 123 return -1;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument, 171 int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument,
173 CFX_FileBufferArchive* pFile, 172 CFX_FileBufferArchive* pFile,
174 CPDF_Array* pIDArray, 173 CPDF_Array* pIDArray,
175 FX_BOOL bCompress) { 174 FX_BOOL bCompress) {
176 FX_FILESIZE offset = 0; 175 FX_FILESIZE offset = 0;
177 int32_t len = 0; 176 int32_t len = 0;
178 FXSYS_assert(pDocument && pFile); 177 FXSYS_assert(pDocument && pFile);
179 CPDF_Parser* pParser = (CPDF_Parser*)pDocument->GetParser(); 178 CPDF_Parser* pParser = (CPDF_Parser*)pDocument->GetParser();
180 if (pParser) { 179 if (pParser) {
181 CPDF_Dictionary* p = pParser->GetTrailer(); 180 CPDF_Dictionary* p = pParser->GetTrailer();
182 FX_POSITION pos = p->GetStartPos(); 181 for (const auto& it : *p) {
183 while (pos) { 182 const CFX_ByteString& key = it.first;
184 CFX_ByteString key; 183 CPDF_Object* pValue = it.second;
185 CPDF_Object* pValue = p->GetNextElement(pos, key);
186 if (key == "Encrypt" || key == "Size" || key == "Filter" || 184 if (key == "Encrypt" || key == "Size" || key == "Filter" ||
187 key == "Index" || key == "Length" || key == "Prev" || key == "W" || 185 key == "Index" || key == "Length" || key == "Prev" || key == "W" ||
188 key == "XRefStm" || key == "Type" || key == "ID") { 186 key == "XRefStm" || key == "Type" || key == "ID") {
189 continue; 187 continue;
190 } 188 }
191 if (bCompress && key == "DecodeParms") { 189 if (bCompress && key == "DecodeParms") {
192 continue; 190 continue;
193 } 191 }
194 if (pFile->AppendString(("/")) < 0) { 192 if (pFile->AppendString(("/")) < 0) {
195 return -1; 193 return -1;
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 case PDFOBJ_DICTIONARY: { 1200 case PDFOBJ_DICTIONARY: {
1203 if (!m_pCryptoHandler || pObj == m_pEncryptDict) { 1201 if (!m_pCryptoHandler || pObj == m_pEncryptDict) {
1204 return PDF_CreatorAppendObject(pObj, &m_File, m_Offset); 1202 return PDF_CreatorAppendObject(pObj, &m_File, m_Offset);
1205 } 1203 }
1206 if (m_File.AppendString("<<") < 0) { 1204 if (m_File.AppendString("<<") < 0) {
1207 return -1; 1205 return -1;
1208 } 1206 }
1209 m_Offset += 2; 1207 m_Offset += 2;
1210 const CPDF_Dictionary* p = pObj->AsDictionary(); 1208 const CPDF_Dictionary* p = pObj->AsDictionary();
1211 FX_BOOL bSignDict = IsSignatureDict(p); 1209 FX_BOOL bSignDict = IsSignatureDict(p);
1212 FX_POSITION pos = p->GetStartPos(); 1210 for (const auto& it : *p) {
1213 while (pos) {
1214 FX_BOOL bSignValue = FALSE; 1211 FX_BOOL bSignValue = FALSE;
1215 CFX_ByteString key; 1212 const CFX_ByteString& key = it.first;
1216 CPDF_Object* pValue = p->GetNextElement(pos, key); 1213 CPDF_Object* pValue = it.second;
1217 if (m_File.AppendString("/") < 0) { 1214 if (m_File.AppendString("/") < 0) {
1218 return -1; 1215 return -1;
1219 } 1216 }
1220 if ((len = m_File.AppendString(PDF_NameEncode(key))) < 0) { 1217 if ((len = m_File.AppendString(PDF_NameEncode(key))) < 0) {
1221 return -1; 1218 return -1;
1222 } 1219 }
1223 m_Offset += len + 1; 1220 m_Offset += len + 1;
1224 if (bSignDict && key == "Contents") { 1221 if (bSignDict && key == "Contents") {
1225 bSignValue = TRUE; 1222 bSignValue = TRUE;
1226 } 1223 }
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 } else { 1776 } else {
1780 if (m_File.AppendDWord(m_pDocument->m_LastObjNum + 1) < 0) { 1777 if (m_File.AppendDWord(m_pDocument->m_LastObjNum + 1) < 0) {
1781 return -1; 1778 return -1;
1782 } 1779 }
1783 if (m_File.AppendString(" 0 obj <<") < 0) { 1780 if (m_File.AppendString(" 0 obj <<") < 0) {
1784 return -1; 1781 return -1;
1785 } 1782 }
1786 } 1783 }
1787 if (m_pParser) { 1784 if (m_pParser) {
1788 CPDF_Dictionary* p = m_pParser->m_pTrailer; 1785 CPDF_Dictionary* p = m_pParser->m_pTrailer;
1789 FX_POSITION pos = p->GetStartPos(); 1786 for (const auto& it : *p) {
1790 while (pos) { 1787 const CFX_ByteString& key = it.first;
1791 CFX_ByteString key; 1788 CPDF_Object* pValue = it.second;
1792 CPDF_Object* pValue = p->GetNextElement(pos, key);
1793 if (key == "Encrypt" || key == "Size" || key == "Filter" || 1789 if (key == "Encrypt" || key == "Size" || key == "Filter" ||
1794 key == "Index" || key == "Length" || key == "Prev" || key == "W" || 1790 key == "Index" || key == "Length" || key == "Prev" || key == "W" ||
1795 key == "XRefStm" || key == "ID") { 1791 key == "XRefStm" || key == "ID") {
1796 continue; 1792 continue;
1797 } 1793 }
1798 if (m_File.AppendString(("/")) < 0) { 1794 if (m_File.AppendString(("/")) < 0) {
1799 return -1; 1795 return -1;
1800 } 1796 }
1801 if (m_File.AppendString(PDF_NameEncode(key)) < 0) { 1797 if (m_File.AppendString(PDF_NameEncode(key)) < 0) {
1802 return -1; 1798 return -1;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 m_bNewCrypto = FALSE; 2099 m_bNewCrypto = FALSE;
2104 if (!m_bStandardSecurity) { 2100 if (!m_bStandardSecurity) {
2105 return; 2101 return;
2106 } 2102 }
2107 if (m_pEncryptDict) { 2103 if (m_pEncryptDict) {
2108 m_pEncryptDict->Release(); 2104 m_pEncryptDict->Release();
2109 m_pEncryptDict = NULL; 2105 m_pEncryptDict = NULL;
2110 } 2106 }
2111 m_bStandardSecurity = FALSE; 2107 m_bStandardSecurity = FALSE;
2112 } 2108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698