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

Side by Side Diff: core/fpdfapi/edit/fpdf_edit_create.cpp

Issue 2425783002: Revert "Make CPDF_Object containers hold objects via unique pointers." (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « no previous file | core/fpdfapi/page/cpdf_allstates.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "core/fpdfapi/edit/editint.h" 7 #include "core/fpdfapi/edit/editint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 break; 121 break;
122 } 122 }
123 case CPDF_Object::DICTIONARY: { 123 case CPDF_Object::DICTIONARY: {
124 if (pFile->AppendString("<<") < 0) { 124 if (pFile->AppendString("<<") < 0) {
125 return -1; 125 return -1;
126 } 126 }
127 offset += 2; 127 offset += 2;
128 const CPDF_Dictionary* p = pObj->AsDictionary(); 128 const CPDF_Dictionary* p = pObj->AsDictionary();
129 for (const auto& it : *p) { 129 for (const auto& it : *p) {
130 const CFX_ByteString& key = it.first; 130 const CFX_ByteString& key = it.first;
131 CPDF_Object* pValue = it.second.get(); 131 CPDF_Object* pValue = it.second;
132 if (pFile->AppendString("/") < 0) { 132 if (pFile->AppendString("/") < 0) {
133 return -1; 133 return -1;
134 } 134 }
135 if ((len = pFile->AppendString(PDF_NameEncode(key).AsStringC())) < 0) { 135 if ((len = pFile->AppendString(PDF_NameEncode(key).AsStringC())) < 0) {
136 return -1; 136 return -1;
137 } 137 }
138 offset += len + 1; 138 offset += len + 1;
139 if (!pValue->IsInline()) { 139 if (!pValue->IsInline()) {
140 if (pFile->AppendString(" ") < 0) { 140 if (pFile->AppendString(" ") < 0) {
141 return -1; 141 return -1;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument, 190 int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument,
191 CFX_FileBufferArchive* pFile, 191 CFX_FileBufferArchive* pFile,
192 CPDF_Array* pIDArray) { 192 CPDF_Array* pIDArray) {
193 FX_FILESIZE offset = 0; 193 FX_FILESIZE offset = 0;
194 int32_t len = 0; 194 int32_t len = 0;
195 CPDF_Parser* pParser = pDocument->GetParser(); 195 CPDF_Parser* pParser = pDocument->GetParser();
196 if (pParser) { 196 if (pParser) {
197 CPDF_Dictionary* p = pParser->GetTrailer(); 197 CPDF_Dictionary* p = pParser->GetTrailer();
198 for (const auto& it : *p) { 198 for (const auto& it : *p) {
199 const CFX_ByteString& key = it.first; 199 const CFX_ByteString& key = it.first;
200 CPDF_Object* pValue = it.second.get(); 200 CPDF_Object* pValue = it.second;
201 if (key == "Encrypt" || key == "Size" || key == "Filter" || 201 if (key == "Encrypt" || key == "Size" || key == "Filter" ||
202 key == "Index" || key == "Length" || key == "Prev" || key == "W" || 202 key == "Index" || key == "Length" || key == "Prev" || key == "W" ||
203 key == "XRefStm" || key == "Type" || key == "ID") { 203 key == "XRefStm" || key == "Type" || key == "ID") {
204 continue; 204 continue;
205 } 205 }
206 if (key == "DecodeParms") 206 if (key == "DecodeParms")
207 continue; 207 continue;
208 208
209 if (pFile->AppendString(("/")) < 0) { 209 if (pFile->AppendString(("/")) < 0) {
210 return -1; 210 return -1;
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 return PDF_CreatorAppendObject(pObj, &m_File, m_Offset); 1185 return PDF_CreatorAppendObject(pObj, &m_File, m_Offset);
1186 if (m_File.AppendString("<<") < 0) 1186 if (m_File.AppendString("<<") < 0)
1187 return -1; 1187 return -1;
1188 1188
1189 m_Offset += 2; 1189 m_Offset += 2;
1190 const CPDF_Dictionary* p = pObj->AsDictionary(); 1190 const CPDF_Dictionary* p = pObj->AsDictionary();
1191 bool bSignDict = p->IsSignatureDict(); 1191 bool bSignDict = p->IsSignatureDict();
1192 for (const auto& it : *p) { 1192 for (const auto& it : *p) {
1193 FX_BOOL bSignValue = FALSE; 1193 FX_BOOL bSignValue = FALSE;
1194 const CFX_ByteString& key = it.first; 1194 const CFX_ByteString& key = it.first;
1195 CPDF_Object* pValue = it.second.get(); 1195 CPDF_Object* pValue = it.second;
1196 if (m_File.AppendString("/") < 0) { 1196 if (m_File.AppendString("/") < 0) {
1197 return -1; 1197 return -1;
1198 } 1198 }
1199 if ((len = m_File.AppendString(PDF_NameEncode(key).AsStringC())) < 0) { 1199 if ((len = m_File.AppendString(PDF_NameEncode(key).AsStringC())) < 0) {
1200 return -1; 1200 return -1;
1201 } 1201 }
1202 m_Offset += len + 1; 1202 m_Offset += len + 1;
1203 if (bSignDict && key == "Contents") { 1203 if (bSignDict && key == "Contents") {
1204 bSignValue = TRUE; 1204 bSignValue = TRUE;
1205 } 1205 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 return -1; 1707 return -1;
1708 } 1708 }
1709 if (m_File.AppendString(" 0 obj <<") < 0) { 1709 if (m_File.AppendString(" 0 obj <<") < 0) {
1710 return -1; 1710 return -1;
1711 } 1711 }
1712 } 1712 }
1713 if (m_pParser) { 1713 if (m_pParser) {
1714 CPDF_Dictionary* p = m_pParser->GetTrailer(); 1714 CPDF_Dictionary* p = m_pParser->GetTrailer();
1715 for (const auto& it : *p) { 1715 for (const auto& it : *p) {
1716 const CFX_ByteString& key = it.first; 1716 const CFX_ByteString& key = it.first;
1717 CPDF_Object* pValue = it.second.get(); 1717 CPDF_Object* pValue = it.second;
1718 // TODO(ochang): Consolidate with similar check in 1718 // TODO(ochang): Consolidate with similar check in
1719 // PDF_CreatorWriteTrailer. 1719 // PDF_CreatorWriteTrailer.
1720 if (key == "Encrypt" || key == "Size" || key == "Filter" || 1720 if (key == "Encrypt" || key == "Size" || key == "Filter" ||
1721 key == "Index" || key == "Length" || key == "Prev" || key == "W" || 1721 key == "Index" || key == "Length" || key == "Prev" || key == "W" ||
1722 key == "XRefStm" || key == "ID") { 1722 key == "XRefStm" || key == "ID") {
1723 continue; 1723 continue;
1724 } 1724 }
1725 if (m_File.AppendString(("/")) < 0) { 1725 if (m_File.AppendString(("/")) < 0) {
1726 return -1; 1726 return -1;
1727 } 1727 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 m_pCryptoHandler = nullptr; 2013 m_pCryptoHandler = nullptr;
2014 } 2014 }
2015 void CPDF_Creator::ResetStandardSecurity() { 2015 void CPDF_Creator::ResetStandardSecurity() {
2016 if (!m_bLocalCryptoHandler) 2016 if (!m_bLocalCryptoHandler)
2017 return; 2017 return;
2018 2018
2019 delete m_pCryptoHandler; 2019 delete m_pCryptoHandler;
2020 m_pCryptoHandler = nullptr; 2020 m_pCryptoHandler = nullptr;
2021 m_bLocalCryptoHandler = FALSE; 2021 m_bLocalCryptoHandler = FALSE;
2022 } 2022 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/page/cpdf_allstates.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698