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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_parser.cpp

Issue 2275593002: IndirectObjectHolder API updates (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Missed one Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/fpdf_parser/include/cpdf_parser.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 SetEncryptDictionary(nullptr); 260 SetEncryptDictionary(nullptr);
261 261
262 if (!m_pTrailer) 262 if (!m_pTrailer)
263 return FORMAT_ERROR; 263 return FORMAT_ERROR;
264 264
265 CPDF_Object* pEncryptObj = m_pTrailer->GetObjectBy("Encrypt"); 265 CPDF_Object* pEncryptObj = m_pTrailer->GetObjectBy("Encrypt");
266 if (pEncryptObj) { 266 if (pEncryptObj) {
267 if (CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) { 267 if (CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) {
268 SetEncryptDictionary(pEncryptDict); 268 SetEncryptDictionary(pEncryptDict);
269 } else if (CPDF_Reference* pRef = pEncryptObj->AsReference()) { 269 } else if (CPDF_Reference* pRef = pEncryptObj->AsReference()) {
270 pEncryptObj = m_pDocument->GetIndirectObject(pRef->GetRefObjNum()); 270 pEncryptObj = m_pDocument->GetOrParseIndirectObject(pRef->GetRefObjNum());
271 if (pEncryptObj) 271 if (pEncryptObj)
272 SetEncryptDictionary(pEncryptObj->GetDict()); 272 SetEncryptDictionary(pEncryptObj->GetDict());
273 } 273 }
274 } 274 }
275 275
276 if (m_pEncryptDict) { 276 if (m_pEncryptDict) {
277 CFX_ByteString filter = m_pEncryptDict->GetStringBy("Filter"); 277 CFX_ByteString filter = m_pEncryptDict->GetStringBy("Filter");
278 std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler; 278 std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler;
279 Error err = HANDLER_ERROR; 279 Error err = HANDLER_ERROR;
280 if (filter == "Standard") { 280 if (filter == "Standard") {
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 if (!pObject) 979 if (!pObject)
980 return FALSE; 980 return FALSE;
981 981
982 if (m_pDocument) { 982 if (m_pDocument) {
983 CPDF_Dictionary* pRootDict = m_pDocument->GetRoot(); 983 CPDF_Dictionary* pRootDict = m_pDocument->GetRoot();
984 if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum) { 984 if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum) {
985 if (pObject->IsStream()) 985 if (pObject->IsStream())
986 pObject->Release(); 986 pObject->Release();
987 return FALSE; 987 return FALSE;
988 } 988 }
989 if (!m_pDocument->InsertIndirectObject(pObject->m_ObjNum, pObject)) 989 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(pObject->m_ObjNum,
990 pObject)) {
990 return FALSE; 991 return FALSE;
992 }
991 } 993 }
992 994
993 CPDF_Stream* pStream = pObject->AsStream(); 995 CPDF_Stream* pStream = pObject->AsStream();
994 if (!pStream) 996 if (!pStream)
995 return FALSE; 997 return FALSE;
996 998
997 CPDF_Dictionary* pDict = pStream->GetDict(); 999 CPDF_Dictionary* pDict = pStream->GetDict();
998 *pos = pDict->GetIntegerBy("Prev"); 1000 *pos = pDict->GetIntegerBy("Prev");
999 int32_t size = pDict->GetIntegerBy("Size"); 1001 int32_t size = pDict->GetIntegerBy("Size");
1000 if (size < 0) { 1002 if (size < 0) {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 } 1225 }
1224 1226
1225 CPDF_StreamAcc* CPDF_Parser::GetObjectStream(uint32_t objnum) { 1227 CPDF_StreamAcc* CPDF_Parser::GetObjectStream(uint32_t objnum) {
1226 auto it = m_ObjectStreamMap.find(objnum); 1228 auto it = m_ObjectStreamMap.find(objnum);
1227 if (it != m_ObjectStreamMap.end()) 1229 if (it != m_ObjectStreamMap.end())
1228 return it->second.get(); 1230 return it->second.get();
1229 1231
1230 if (!m_pDocument) 1232 if (!m_pDocument)
1231 return nullptr; 1233 return nullptr;
1232 1234
1233 const CPDF_Stream* pStream = ToStream(m_pDocument->GetIndirectObject(objnum)); 1235 const CPDF_Stream* pStream =
1236 ToStream(m_pDocument->GetOrParseIndirectObject(objnum));
1234 if (!pStream) 1237 if (!pStream)
1235 return nullptr; 1238 return nullptr;
1236 1239
1237 CPDF_StreamAcc* pStreamAcc = new CPDF_StreamAcc; 1240 CPDF_StreamAcc* pStreamAcc = new CPDF_StreamAcc;
1238 pStreamAcc->LoadAllData(pStream); 1241 pStreamAcc->LoadAllData(pStream);
1239 m_ObjectStreamMap[objnum].reset(pStreamAcc); 1242 m_ObjectStreamMap[objnum].reset(pStreamAcc);
1240 return pStreamAcc; 1243 return pStreamAcc;
1241 } 1244 }
1242 1245
1243 FX_FILESIZE CPDF_Parser::GetObjectSize(uint32_t objnum) const { 1246 FX_FILESIZE CPDF_Parser::GetObjectSize(uint32_t objnum) const {
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1674 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1672 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1675 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1673 m_LastXRefOffset = 0; 1676 m_LastXRefOffset = 0;
1674 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1677 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1675 return FORMAT_ERROR; 1678 return FORMAT_ERROR;
1676 } 1679 }
1677 1680
1678 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1681 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1679 return SUCCESS; 1682 return SUCCESS;
1680 } 1683 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_reference.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698