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

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

Issue 2001783003: Get rid of CPDF_Object::GetArray(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 7 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/fpdf_parser/cpdf_array.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_object.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/fpdf_parser/include/ipdf_data_avail.h" 7 #include "core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/cpdf_data_avail.h" 9 #include "core/fpdfapi/fpdf_parser/cpdf_data_avail.h"
10 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" 10 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 uint32_t count = 0; 144 uint32_t count = 0;
145 CFX_ArrayTemplate<CPDF_Object*> new_obj_array; 145 CFX_ArrayTemplate<CPDF_Object*> new_obj_array;
146 for (int i = 0; i < obj_array.GetSize(); i++) { 146 for (int i = 0; i < obj_array.GetSize(); i++) {
147 CPDF_Object* pObj = obj_array[i]; 147 CPDF_Object* pObj = obj_array[i];
148 if (!pObj) 148 if (!pObj)
149 continue; 149 continue;
150 150
151 int32_t type = pObj->GetType(); 151 int32_t type = pObj->GetType();
152 switch (type) { 152 switch (type) {
153 case CPDF_Object::ARRAY: { 153 case CPDF_Object::ARRAY: {
154 CPDF_Array* pArray = pObj->GetArray(); 154 CPDF_Array* pArray = pObj->AsArray();
155 for (size_t k = 0; k < pArray->GetCount(); ++k) 155 for (size_t k = 0; k < pArray->GetCount(); ++k)
156 new_obj_array.Add(pArray->GetObjectAt(k)); 156 new_obj_array.Add(pArray->GetObjectAt(k));
157 } break; 157 } break;
158 case CPDF_Object::STREAM: 158 case CPDF_Object::STREAM:
159 pObj = pObj->GetDict(); 159 pObj = pObj->GetDict();
160 case CPDF_Object::DICTIONARY: { 160 case CPDF_Object::DICTIONARY: {
161 CPDF_Dictionary* pDict = pObj->GetDict(); 161 CPDF_Dictionary* pDict = pObj->GetDict();
162 if (pDict && pDict->GetStringBy("Type") == "Page" && !bParsePage) 162 if (pDict && pDict->GetStringBy("Type") == "Page" && !bParsePage)
163 continue; 163 continue;
164 164
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 for (uint32_t i = 0; i < iPageObjs; ++i) { 502 for (uint32_t i = 0; i < iPageObjs; ++i) {
503 uint32_t dwPageObjNum = m_PageObjList.GetAt(i); 503 uint32_t dwPageObjNum = m_PageObjList.GetAt(i);
504 FX_BOOL bExist = FALSE; 504 FX_BOOL bExist = FALSE;
505 CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist); 505 CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist);
506 if (!pObj) { 506 if (!pObj) {
507 if (bExist) 507 if (bExist)
508 UnavailObjList.Add(dwPageObjNum); 508 UnavailObjList.Add(dwPageObjNum);
509 continue; 509 continue;
510 } 510 }
511 511
512 if (pObj->IsArray()) { 512 CPDF_Array* pArray = ToArray(pObj);
513 CPDF_Array* pArray = pObj->GetArray(); 513 if (pArray) {
514 if (pArray) { 514 for (CPDF_Object* pArrayObj : *pArray) {
515 for (size_t j = 0; j < pArray->GetCount(); ++j) { 515 if (CPDF_Reference* pRef = ToReference(pArrayObj))
516 if (CPDF_Reference* pRef = ToReference(pArray->GetObjectAt(j))) 516 UnavailObjList.Add(pRef->GetRefObjNum());
517 UnavailObjList.Add(pRef->GetRefObjNum());
518 }
519 } 517 }
520 } 518 }
521 519
522 if (!pObj->IsDictionary()) { 520 if (!pObj->IsDictionary()) {
523 pObj->Release(); 521 pObj->Release();
524 continue; 522 continue;
525 } 523 }
526 524
527 CFX_ByteString type = pObj->GetDict()->GetStringBy("Type"); 525 CFX_ByteString type = pObj->GetDict()->GetStringBy("Type");
528 if (type == "Pages") { 526 if (type == "Pages") {
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 return FormAvailable; 1829 return FormAvailable;
1832 } 1830 }
1833 1831
1834 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} 1832 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {}
1835 1833
1836 CPDF_DataAvail::PageNode::~PageNode() { 1834 CPDF_DataAvail::PageNode::~PageNode() {
1837 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) 1835 for (int32_t i = 0; i < m_childNode.GetSize(); ++i)
1838 delete m_childNode[i]; 1836 delete m_childNode[i];
1839 m_childNode.RemoveAll(); 1837 m_childNode.RemoveAll();
1840 } 1838 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_array.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_object.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698