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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1636503006: Merge to XFA: War on #defines, part 1. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Dircet -> Direct typo. Created 4 years, 11 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 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/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 2922 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 FX_DWORD count = 0; 2933 FX_DWORD count = 0;
2934 CFX_ArrayTemplate<CPDF_Object*> new_obj_array; 2934 CFX_ArrayTemplate<CPDF_Object*> new_obj_array;
2935 int32_t i = 0; 2935 int32_t i = 0;
2936 for (i = 0; i < obj_array.GetSize(); i++) { 2936 for (i = 0; i < obj_array.GetSize(); i++) {
2937 CPDF_Object* pObj = obj_array[i]; 2937 CPDF_Object* pObj = obj_array[i];
2938 if (!pObj) 2938 if (!pObj)
2939 continue; 2939 continue;
2940 2940
2941 int32_t type = pObj->GetType(); 2941 int32_t type = pObj->GetType();
2942 switch (type) { 2942 switch (type) {
2943 case PDFOBJ_ARRAY: { 2943 case CPDF_Object::ARRAY: {
2944 CPDF_Array* pArray = pObj->GetArray(); 2944 CPDF_Array* pArray = pObj->GetArray();
2945 for (FX_DWORD k = 0; k < pArray->GetCount(); k++) { 2945 for (FX_DWORD k = 0; k < pArray->GetCount(); k++) {
2946 new_obj_array.Add(pArray->GetElement(k)); 2946 new_obj_array.Add(pArray->GetElement(k));
2947 } 2947 }
2948 } break; 2948 } break;
2949 case PDFOBJ_STREAM: 2949 case CPDF_Object::STREAM:
2950 pObj = pObj->GetDict(); 2950 pObj = pObj->GetDict();
2951 case PDFOBJ_DICTIONARY: { 2951 case CPDF_Object::DICTIONARY: {
2952 CPDF_Dictionary* pDict = pObj->GetDict(); 2952 CPDF_Dictionary* pDict = pObj->GetDict();
2953 if (pDict && pDict->GetString("Type") == "Page" && !bParsePage) { 2953 if (pDict && pDict->GetString("Type") == "Page" && !bParsePage) {
2954 continue; 2954 continue;
2955 } 2955 }
2956 for (const auto& it : *pDict) { 2956 for (const auto& it : *pDict) {
2957 const CFX_ByteString& key = it.first; 2957 const CFX_ByteString& key = it.first;
2958 CPDF_Object* value = it.second; 2958 CPDF_Object* value = it.second;
2959 if (key != "Parent") { 2959 if (key != "Parent") {
2960 new_obj_array.Add(value); 2960 new_obj_array.Add(value);
2961 } 2961 }
2962 } 2962 }
2963 } break; 2963 } break;
2964 case PDFOBJ_REFERENCE: { 2964 case CPDF_Object::REFERENCE: {
2965 CPDF_Reference* pRef = pObj->AsReference(); 2965 CPDF_Reference* pRef = pObj->AsReference();
2966 FX_DWORD dwNum = pRef->GetRefObjNum(); 2966 FX_DWORD dwNum = pRef->GetRefObjNum();
2967 FX_FILESIZE offset; 2967 FX_FILESIZE offset;
2968 FX_DWORD size = GetObjectSize(dwNum, offset); 2968 FX_DWORD size = GetObjectSize(dwNum, offset);
2969 if (size == 0 || offset < 0 || offset >= m_dwFileLen) { 2969 if (size == 0 || offset < 0 || offset >= m_dwFileLen) {
2970 break; 2970 break;
2971 } 2971 }
2972 if (!IsDataAvail(offset, size, pHints)) { 2972 if (!IsDataAvail(offset, size, pHints)) {
2973 ret_array.Add(pObj); 2973 ret_array.Add(pObj);
2974 count++; 2974 count++;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 if (!pParser) { 3341 if (!pParser) {
3342 m_docStatus = PDF_DATAAVAIL_ERROR; 3342 m_docStatus = PDF_DATAAVAIL_ERROR;
3343 return FALSE; 3343 return FALSE;
3344 } 3344 }
3345 CPDF_Dictionary* pDict = pPages->GetDict(); 3345 CPDF_Dictionary* pDict = pPages->GetDict();
3346 CPDF_Object* pKids = pDict ? pDict->GetElement("Kids") : NULL; 3346 CPDF_Object* pKids = pDict ? pDict->GetElement("Kids") : NULL;
3347 if (!pKids) { 3347 if (!pKids) {
3348 return TRUE; 3348 return TRUE;
3349 } 3349 }
3350 switch (pKids->GetType()) { 3350 switch (pKids->GetType()) {
3351 case PDFOBJ_REFERENCE: 3351 case CPDF_Object::REFERENCE:
3352 m_PageObjList.Add(pKids->AsReference()->GetRefObjNum()); 3352 m_PageObjList.Add(pKids->AsReference()->GetRefObjNum());
3353 break; 3353 break;
3354 case PDFOBJ_ARRAY: { 3354 case CPDF_Object::ARRAY: {
3355 CPDF_Array* pKidsArray = pKids->AsArray(); 3355 CPDF_Array* pKidsArray = pKids->AsArray();
3356 for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) { 3356 for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) {
3357 if (CPDF_Reference* pRef = ToReference(pKidsArray->GetElement(i))) 3357 if (CPDF_Reference* pRef = ToReference(pKidsArray->GetElement(i)))
3358 m_PageObjList.Add(pRef->GetRefObjNum()); 3358 m_PageObjList.Add(pRef->GetRefObjNum());
3359 } 3359 }
3360 } break; 3360 } break;
3361 default: 3361 default:
3362 m_docStatus = PDF_DATAAVAIL_ERROR; 3362 m_docStatus = PDF_DATAAVAIL_ERROR;
3363 return FALSE; 3363 return FALSE;
3364 } 3364 }
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
4035 CPDF_Dictionary* pDict = pPage->GetDict(); 4035 CPDF_Dictionary* pDict = pPage->GetDict();
4036 CFX_ByteString type = pDict->GetString("Type"); 4036 CFX_ByteString type = pDict->GetString("Type");
4037 if (type == "Pages") { 4037 if (type == "Pages") {
4038 pPageNode->m_type = PDF_PAGENODE_PAGES; 4038 pPageNode->m_type = PDF_PAGENODE_PAGES;
4039 CPDF_Object* pKids = pDict->GetElement("Kids"); 4039 CPDF_Object* pKids = pDict->GetElement("Kids");
4040 if (!pKids) { 4040 if (!pKids) {
4041 m_docStatus = PDF_DATAAVAIL_PAGE; 4041 m_docStatus = PDF_DATAAVAIL_PAGE;
4042 return TRUE; 4042 return TRUE;
4043 } 4043 }
4044 switch (pKids->GetType()) { 4044 switch (pKids->GetType()) {
4045 case PDFOBJ_REFERENCE: { 4045 case CPDF_Object::REFERENCE: {
4046 CPDF_Reference* pKid = pKids->AsReference(); 4046 CPDF_Reference* pKid = pKids->AsReference();
4047 CPDF_PageNode* pNode = new CPDF_PageNode(); 4047 CPDF_PageNode* pNode = new CPDF_PageNode();
4048 pPageNode->m_childNode.Add(pNode); 4048 pPageNode->m_childNode.Add(pNode);
4049 pNode->m_dwPageNo = pKid->GetRefObjNum(); 4049 pNode->m_dwPageNo = pKid->GetRefObjNum();
4050 } break; 4050 } break;
4051 case PDFOBJ_ARRAY: { 4051 case CPDF_Object::ARRAY: {
4052 CPDF_Array* pKidsArray = pKids->AsArray(); 4052 CPDF_Array* pKidsArray = pKids->AsArray();
4053 for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) { 4053 for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) {
4054 CPDF_Reference* pKid = ToReference(pKidsArray->GetElement(i)); 4054 CPDF_Reference* pKid = ToReference(pKidsArray->GetElement(i));
4055 if (!pKid) 4055 if (!pKid)
4056 continue; 4056 continue;
4057 4057
4058 CPDF_PageNode* pNode = new CPDF_PageNode(); 4058 CPDF_PageNode* pNode = new CPDF_PageNode();
4059 pPageNode->m_childNode.Add(pNode); 4059 pPageNode->m_childNode.Add(pNode);
4060 pNode->m_dwPageNo = pKid->GetRefObjNum(); 4060 pNode->m_dwPageNo = pKid->GetRefObjNum();
4061 } 4061 }
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
4844 } 4844 }
4845 } 4845 }
4846 return IPDF_DataAvail::DataAvailable; 4846 return IPDF_DataAvail::DataAvailable;
4847 } 4847 }
4848 4848
4849 FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) { 4849 FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) {
4850 if (!pHintStream || !m_pLinearizedDict) 4850 if (!pHintStream || !m_pLinearizedDict)
4851 return FALSE; 4851 return FALSE;
4852 CPDF_Dictionary* pDict = pHintStream->GetDict(); 4852 CPDF_Dictionary* pDict = pHintStream->GetDict();
4853 CPDF_Object* pOffset = pDict ? pDict->GetElement("S") : nullptr; 4853 CPDF_Object* pOffset = pDict ? pDict->GetElement("S") : nullptr;
4854 if (!pOffset || pOffset->GetType() != PDFOBJ_NUMBER) 4854 if (!pOffset || pOffset->GetType() != CPDF_Object::NUMBER)
4855 return FALSE; 4855 return FALSE;
4856 int shared_hint_table_offset = pOffset->GetInteger(); 4856 int shared_hint_table_offset = pOffset->GetInteger();
4857 CPDF_StreamAcc acc; 4857 CPDF_StreamAcc acc;
4858 acc.LoadAllData(pHintStream); 4858 acc.LoadAllData(pHintStream);
4859 FX_DWORD size = acc.GetSize(); 4859 FX_DWORD size = acc.GetSize();
4860 // The header section of page offset hint table is 36 bytes. 4860 // The header section of page offset hint table is 36 bytes.
4861 // The header section of shared object hint table is 24 bytes. 4861 // The header section of shared object hint table is 24 bytes.
4862 // Hint table has at least 60 bytes. 4862 // Hint table has at least 60 bytes.
4863 const FX_DWORD MIN_STREAM_LEN = 60; 4863 const FX_DWORD MIN_STREAM_LEN = 60;
4864 if (size < MIN_STREAM_LEN || shared_hint_table_offset <= 0 || 4864 if (size < MIN_STREAM_LEN || shared_hint_table_offset <= 0 ||
(...skipping 22 matching lines...) Expand all
4887 if (!m_pLinearizedDict) 4887 if (!m_pLinearizedDict)
4888 return -1; 4888 return -1;
4889 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); 4889 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H");
4890 if (!pRange) 4890 if (!pRange)
4891 return -1; 4891 return -1;
4892 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4892 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
4893 if (!pStreamLen) 4893 if (!pStreamLen)
4894 return -1; 4894 return -1;
4895 return pStreamLen->GetInteger(); 4895 return pStreamLen->GetInteger();
4896 } 4896 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698