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

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

Issue 2411703003: Get rid of CFX_ArrayTemplate<CPDF_Object*> (Closed)
Patch Set: nit 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 | « core/fpdfapi/parser/cpdf_parser.h ('k') | fpdfsdk/fpdf_flatten.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 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/parser/cpdf_parser.h" 7 #include "core/fpdfapi/parser/cpdf_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 m_pTrailer->Release(); 65 m_pTrailer->Release();
66 66
67 ReleaseEncryptHandler(); 67 ReleaseEncryptHandler();
68 SetEncryptDictionary(nullptr); 68 SetEncryptDictionary(nullptr);
69 69
70 if (m_bOwnFileRead && m_pSyntax->m_pFileAccess) { 70 if (m_bOwnFileRead && m_pSyntax->m_pFileAccess) {
71 m_pSyntax->m_pFileAccess->Release(); 71 m_pSyntax->m_pFileAccess->Release();
72 m_pSyntax->m_pFileAccess = nullptr; 72 m_pSyntax->m_pFileAccess = nullptr;
73 } 73 }
74 74
75 int32_t iLen = m_Trailers.GetSize(); 75 for (CPDF_Dictionary* trailer : m_Trailers) {
76 for (int32_t i = 0; i < iLen; ++i) { 76 if (trailer)
77 if (CPDF_Dictionary* trailer = m_Trailers.GetAt(i))
78 trailer->Release(); 77 trailer->Release();
79 } 78 }
80 79
81 if (m_pLinearized) 80 if (m_pLinearized)
82 m_pLinearized->Release(); 81 m_pLinearized->Release();
83 } 82 }
84 83
85 uint32_t CPDF_Parser::GetLastObjNum() const { 84 uint32_t CPDF_Parser::GetLastObjNum() const {
86 return m_ObjectInfo.empty() ? 0 : m_ObjectInfo.rbegin()->first; 85 return m_ObjectInfo.empty() ? 0 : m_ObjectInfo.rbegin()->first;
87 } 86 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( 360 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
362 LoadTrailerV4()); 361 LoadTrailerV4());
363 if (!pDict) 362 if (!pDict)
364 return FALSE; 363 return FALSE;
365 364
366 xrefpos = GetDirectInteger(pDict.get(), "Prev"); 365 xrefpos = GetDirectInteger(pDict.get(), "Prev");
367 366
368 // SLOW ... 367 // SLOW ...
369 XRefStreamList.insert(XRefStreamList.begin(), 368 XRefStreamList.insert(XRefStreamList.begin(),
370 pDict->GetIntegerFor("XRefStm")); 369 pDict->GetIntegerFor("XRefStm"));
371 m_Trailers.Add(pDict.release()); 370 m_Trailers.push_back(pDict.release());
372 } 371 }
373 372
374 for (size_t i = 0; i < CrossRefList.size(); ++i) { 373 for (size_t i = 0; i < CrossRefList.size(); ++i) {
375 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE)) 374 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
376 return FALSE; 375 return FALSE;
377 if (i == 0 && !VerifyCrossRefV4()) 376 if (i == 0 && !VerifyCrossRefV4())
378 return FALSE; 377 return FALSE;
379 } 378 }
380 return TRUE; 379 return TRUE;
381 } 380 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( 415 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
417 LoadTrailerV4()); 416 LoadTrailerV4());
418 if (!pDict) 417 if (!pDict)
419 return FALSE; 418 return FALSE;
420 419
421 xrefpos = GetDirectInteger(pDict.get(), "Prev"); 420 xrefpos = GetDirectInteger(pDict.get(), "Prev");
422 421
423 // SLOW ... 422 // SLOW ...
424 XRefStreamList.insert(XRefStreamList.begin(), 423 XRefStreamList.insert(XRefStreamList.begin(),
425 pDict->GetIntegerFor("XRefStm")); 424 pDict->GetIntegerFor("XRefStm"));
426 m_Trailers.Add(pDict.release()); 425 m_Trailers.push_back(pDict.release());
427 } 426 }
428 427
429 for (size_t i = 1; i < CrossRefList.size(); ++i) { 428 for (size_t i = 1; i < CrossRefList.size(); ++i) {
430 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE)) 429 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
431 return FALSE; 430 return FALSE;
432 } 431 }
433 return TRUE; 432 return TRUE;
434 } 433 }
435 434
436 FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, 435 FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 if (size < 0) 984 if (size < 0)
986 return FALSE; 985 return FALSE;
987 986
988 CPDF_Dictionary* pNewTrailer = ToDictionary(pDict->Clone()); 987 CPDF_Dictionary* pNewTrailer = ToDictionary(pDict->Clone());
989 if (bMainXRef) { 988 if (bMainXRef) {
990 m_pTrailer = pNewTrailer; 989 m_pTrailer = pNewTrailer;
991 ShrinkObjectMap(size); 990 ShrinkObjectMap(size);
992 for (auto& it : m_ObjectInfo) 991 for (auto& it : m_ObjectInfo)
993 it.second.type = 0; 992 it.second.type = 0;
994 } else { 993 } else {
995 m_Trailers.Add(pNewTrailer); 994 m_Trailers.push_back(pNewTrailer);
996 } 995 }
997 996
998 std::vector<std::pair<int32_t, int32_t>> arrIndex; 997 std::vector<std::pair<int32_t, int32_t>> arrIndex;
999 CPDF_Array* pArray = pDict->GetArrayFor("Index"); 998 CPDF_Array* pArray = pDict->GetArrayFor("Index");
1000 if (pArray) { 999 if (pArray) {
1001 for (size_t i = 0; i < pArray->GetCount() / 2; i++) { 1000 for (size_t i = 0; i < pArray->GetCount() / 2; i++) {
1002 CPDF_Object* pStartNumObj = pArray->GetObjectAt(i * 2); 1001 CPDF_Object* pStartNumObj = pArray->GetObjectAt(i * 2);
1003 CPDF_Object* pCountObj = pArray->GetObjectAt(i * 2 + 1); 1002 CPDF_Object* pCountObj = pArray->GetObjectAt(i * 2 + 1);
1004 1003
1005 if (ToNumber(pStartNumObj) && ToNumber(pCountObj)) { 1004 if (ToNumber(pStartNumObj) && ToNumber(pCountObj)) {
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1618 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1620 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1619 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1621 m_LastXRefOffset = 0; 1620 m_LastXRefOffset = 0;
1622 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1621 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1623 return FORMAT_ERROR; 1622 return FORMAT_ERROR;
1624 } 1623 }
1625 1624
1626 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1625 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1627 return SUCCESS; 1626 return SUCCESS;
1628 } 1627 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_parser.h ('k') | fpdfsdk/fpdf_flatten.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698