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

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

Issue 2385293002: Make CPDF_Object containers hold objects via unique pointers (Closed)
Patch Set: Remove duplicated line 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_array.cpp ('k') | core/fpdfapi/parser/cpdf_dictionary.h » ('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_data_avail.h" 7 #include "core/fpdfapi/parser/cpdf_data_avail.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } break; 148 } break;
149 case CPDF_Object::STREAM: 149 case CPDF_Object::STREAM:
150 pObj = pObj->GetDict(); 150 pObj = pObj->GetDict();
151 case CPDF_Object::DICTIONARY: { 151 case CPDF_Object::DICTIONARY: {
152 CPDF_Dictionary* pDict = pObj->GetDict(); 152 CPDF_Dictionary* pDict = pObj->GetDict();
153 if (pDict && pDict->GetStringFor("Type") == "Page" && !bParsePage) 153 if (pDict && pDict->GetStringFor("Type") == "Page" && !bParsePage)
154 continue; 154 continue;
155 155
156 for (const auto& it : *pDict) { 156 for (const auto& it : *pDict) {
157 const CFX_ByteString& key = it.first; 157 const CFX_ByteString& key = it.first;
158 CPDF_Object* value = it.second; 158 CPDF_Object* value = it.second.get();
159 if (key != "Parent") 159 if (key != "Parent")
160 new_obj_array.push_back(value); 160 new_obj_array.push_back(value);
161 } 161 }
162 } break; 162 } break;
163 case CPDF_Object::REFERENCE: { 163 case CPDF_Object::REFERENCE: {
164 CPDF_Reference* pRef = pObj->AsReference(); 164 CPDF_Reference* pRef = pObj->AsReference();
165 uint32_t dwNum = pRef->GetRefObjNum(); 165 uint32_t dwNum = pRef->GetRefObjNum();
166 166
167 FX_FILESIZE offset; 167 FX_FILESIZE offset;
168 uint32_t size = GetObjectSize(dwNum, offset); 168 uint32_t size = GetObjectSize(dwNum, offset);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 FX_BOOL bExist = FALSE; 486 FX_BOOL bExist = FALSE;
487 CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist); 487 CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist);
488 if (!pObj) { 488 if (!pObj) {
489 if (bExist) 489 if (bExist)
490 UnavailObjList.Add(dwPageObjNum); 490 UnavailObjList.Add(dwPageObjNum);
491 continue; 491 continue;
492 } 492 }
493 493
494 CPDF_Array* pArray = ToArray(pObj); 494 CPDF_Array* pArray = ToArray(pObj);
495 if (pArray) { 495 if (pArray) {
496 for (CPDF_Object* pArrayObj : *pArray) { 496 for (auto& pArrayObj : *pArray) {
497 if (CPDF_Reference* pRef = ToReference(pArrayObj)) 497 if (CPDF_Reference* pRef = ToReference(pArrayObj.get()))
498 UnavailObjList.Add(pRef->GetRefObjNum()); 498 UnavailObjList.Add(pRef->GetRefObjNum());
499 } 499 }
500 } 500 }
501 501
502 if (!pObj->IsDictionary()) { 502 if (!pObj->IsDictionary()) {
503 pObj->Release(); 503 pObj->Release();
504 continue; 504 continue;
505 } 505 }
506 506
507 CFX_ByteString type = pObj->GetDict()->GetStringFor("Type"); 507 CFX_ByteString type = pObj->GetDict()->GetStringFor("Type");
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 return TRUE; 735 return TRUE;
736 } 736 }
737 737
738 CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H"); 738 CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H");
739 size_t nHintStreamSize = pHintStreamRange ? pHintStreamRange->GetCount() : 0; 739 size_t nHintStreamSize = pHintStreamRange ? pHintStreamRange->GetCount() : 0;
740 if (nHintStreamSize != 2 && nHintStreamSize != 4) { 740 if (nHintStreamSize != 2 && nHintStreamSize != 4) {
741 m_docStatus = PDF_DATAAVAIL_ERROR; 741 m_docStatus = PDF_DATAAVAIL_ERROR;
742 return FALSE; 742 return FALSE;
743 } 743 }
744 744
745 for (const CPDF_Object* pArrayObject : *pHintStreamRange) { 745 for (const auto& pArrayObject : *pHintStreamRange) {
746 const CPDF_Number* pNumber = ToNumber(pArrayObject->GetDirect()); 746 const CPDF_Number* pNumber = ToNumber(pArrayObject->GetDirect());
747 if (!pNumber || !pNumber->IsInteger()) { 747 if (!pNumber || !pNumber->IsInteger()) {
748 m_docStatus = PDF_DATAAVAIL_ERROR; 748 m_docStatus = PDF_DATAAVAIL_ERROR;
749 return FALSE; 749 return FALSE;
750 } 750 }
751 } 751 }
752 752
753 FX_FILESIZE szHintStart = pHintStreamRange->GetIntegerAt(0); 753 FX_FILESIZE szHintStart = pHintStreamRange->GetIntegerAt(0);
754 FX_FILESIZE szHintLength = pHintStreamRange->GetIntegerAt(1); 754 FX_FILESIZE szHintLength = pHintStreamRange->GetIntegerAt(1);
755 if (szHintStart < 0 || szHintLength <= 0) { 755 if (szHintStart < 0 || szHintLength <= 0) {
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 return FormAvailable; 1816 return FormAvailable;
1817 } 1817 }
1818 1818
1819 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} 1819 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {}
1820 1820
1821 CPDF_DataAvail::PageNode::~PageNode() { 1821 CPDF_DataAvail::PageNode::~PageNode() {
1822 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) 1822 for (int32_t i = 0; i < m_childNode.GetSize(); ++i)
1823 delete m_childNode[i]; 1823 delete m_childNode[i];
1824 m_childNode.RemoveAll(); 1824 m_childNode.RemoveAll();
1825 } 1825 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_array.cpp ('k') | core/fpdfapi/parser/cpdf_dictionary.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698