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

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

Issue 1644633003: Member function name refactoring (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 FX_DWORD GetVarInt(const uint8_t* p, int32_t n) { 65 FX_DWORD GetVarInt(const uint8_t* p, int32_t n) {
66 FX_DWORD result = 0; 66 FX_DWORD result = 0;
67 for (int32_t i = 0; i < n; ++i) 67 for (int32_t i = 0; i < n; ++i)
68 result = result * 256 + p[i]; 68 result = result * 256 + p[i];
69 return result; 69 return result;
70 } 70 }
71 71
72 int32_t GetStreamNCount(CPDF_StreamAcc* pObjStream) { 72 int32_t GetStreamNCount(CPDF_StreamAcc* pObjStream) {
73 return pObjStream->GetDict()->GetInteger("N"); 73 return pObjStream->GetDict()->GetIntegerBy("N");
74 } 74 }
75 75
76 int32_t GetStreamFirst(CPDF_StreamAcc* pObjStream) { 76 int32_t GetStreamFirst(CPDF_StreamAcc* pObjStream) {
77 return pObjStream->GetDict()->GetInteger("First"); 77 return pObjStream->GetDict()->GetIntegerBy("First");
78 } 78 }
79 79
80 bool CanReadFromBitStream(const CFX_BitStream* hStream, 80 bool CanReadFromBitStream(const CFX_BitStream* hStream,
81 const FX_SAFE_DWORD& num_bits) { 81 const FX_SAFE_DWORD& num_bits) {
82 return (num_bits.IsValid() && 82 return (num_bits.IsValid() &&
83 hStream->BitsRemaining() >= num_bits.ValueOrDie()); 83 hStream->BitsRemaining() >= num_bits.ValueOrDie());
84 } 84 }
85 85
86 } // namespace 86 } // namespace
87 87
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (!m_pSecurityHandler->OnInit(this, m_pEncryptDict)) { 307 if (!m_pSecurityHandler->OnInit(this, m_pEncryptDict)) {
308 return HANDLER_ERROR; 308 return HANDLER_ERROR;
309 } 309 }
310 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler( 310 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler(
311 m_pSecurityHandler->CreateCryptoHandler()); 311 m_pSecurityHandler->CreateCryptoHandler());
312 if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) { 312 if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) {
313 return HANDLER_ERROR; 313 return HANDLER_ERROR;
314 } 314 }
315 m_Syntax.SetEncrypt(pCryptoHandler.release()); 315 m_Syntax.SetEncrypt(pCryptoHandler.release());
316 } else if (m_pEncryptDict) { 316 } else if (m_pEncryptDict) {
317 CFX_ByteString filter = m_pEncryptDict->GetString("Filter"); 317 CFX_ByteString filter = m_pEncryptDict->GetStringBy("Filter");
318 std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler; 318 std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler;
319 Error err = HANDLER_ERROR; 319 Error err = HANDLER_ERROR;
320 if (filter == "Standard") { 320 if (filter == "Standard") {
321 pSecurityHandler.reset(FPDF_CreateStandardSecurityHandler()); 321 pSecurityHandler.reset(FPDF_CreateStandardSecurityHandler());
322 err = PASSWORD_ERROR; 322 err = PASSWORD_ERROR;
323 } 323 }
324 if (!pSecurityHandler) { 324 if (!pSecurityHandler) {
325 return HANDLER_ERROR; 325 return HANDLER_ERROR;
326 } 326 }
327 if (!pSecurityHandler->OnInit(this, m_pEncryptDict)) { 327 if (!pSecurityHandler->OnInit(this, m_pEncryptDict)) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 return FALSE; 389 return FALSE;
390 seen_xrefpos.insert(xrefpos); 390 seen_xrefpos.insert(xrefpos);
391 CrossRefList.InsertAt(0, xrefpos); 391 CrossRefList.InsertAt(0, xrefpos);
392 LoadCrossRefV4(xrefpos, 0, TRUE); 392 LoadCrossRefV4(xrefpos, 0, TRUE);
393 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( 393 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
394 LoadTrailerV4()); 394 LoadTrailerV4());
395 if (!pDict) 395 if (!pDict)
396 return FALSE; 396 return FALSE;
397 xrefpos = GetDirectInteger(pDict.get(), "Prev"); 397 xrefpos = GetDirectInteger(pDict.get(), "Prev");
398 398
399 XRefStreamList.InsertAt(0, pDict->GetInteger("XRefStm")); 399 XRefStreamList.InsertAt(0, pDict->GetIntegerBy("XRefStm"));
400 m_Trailers.Add(pDict.release()); 400 m_Trailers.Add(pDict.release());
401 } 401 }
402 for (int32_t i = 0; i < CrossRefList.GetSize(); i++) { 402 for (int32_t i = 0; i < CrossRefList.GetSize(); i++) {
403 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE)) 403 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
404 return FALSE; 404 return FALSE;
405 } 405 }
406 return TRUE; 406 return TRUE;
407 } 407 }
408 FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, 408 FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
409 FX_DWORD dwObjCount) { 409 FX_DWORD dwObjCount) {
(...skipping 22 matching lines...) Expand all
432 seen_xrefpos.insert(xrefpos); 432 seen_xrefpos.insert(xrefpos);
433 CrossRefList.InsertAt(0, xrefpos); 433 CrossRefList.InsertAt(0, xrefpos);
434 LoadCrossRefV4(xrefpos, 0, TRUE); 434 LoadCrossRefV4(xrefpos, 0, TRUE);
435 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict( 435 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
436 LoadTrailerV4()); 436 LoadTrailerV4());
437 if (!pDict) { 437 if (!pDict) {
438 return FALSE; 438 return FALSE;
439 } 439 }
440 xrefpos = GetDirectInteger(pDict.get(), "Prev"); 440 xrefpos = GetDirectInteger(pDict.get(), "Prev");
441 441
442 XRefStreamList.InsertAt(0, pDict->GetInteger("XRefStm")); 442 XRefStreamList.InsertAt(0, pDict->GetIntegerBy("XRefStm"));
443 m_Trailers.Add(pDict.release()); 443 m_Trailers.Add(pDict.release());
444 } 444 }
445 for (int32_t i = 1; i < CrossRefList.GetSize(); i++) 445 for (int32_t i = 1; i < CrossRefList.GetSize(); i++)
446 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE)) { 446 if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE)) {
447 return FALSE; 447 return FALSE;
448 } 448 }
449 return TRUE; 449 return TRUE;
450 } 450 }
451 FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, 451 FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
452 FX_DWORD dwObjCount) { 452 FX_DWORD dwObjCount) {
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 CompareFileSize); 783 CompareFileSize);
784 if (!pResult) { 784 if (!pResult) {
785 m_SortedOffset.Add(obj_pos); 785 m_SortedOffset.Add(obj_pos);
786 } 786 }
787 FX_FILESIZE obj_end = 0; 787 FX_FILESIZE obj_end = 0;
788 CPDF_Object* pObject = ParseIndirectObjectAtByStrict( 788 CPDF_Object* pObject = ParseIndirectObjectAtByStrict(
789 m_pDocument, obj_pos, objnum, &obj_end); 789 m_pDocument, obj_pos, objnum, &obj_end);
790 if (CPDF_Stream* pStream = ToStream(pObject)) { 790 if (CPDF_Stream* pStream = ToStream(pObject)) {
791 if (CPDF_Dictionary* pDict = pStream->GetDict()) { 791 if (CPDF_Dictionary* pDict = pStream->GetDict()) {
792 if ((pDict->KeyExist("Type")) && 792 if ((pDict->KeyExist("Type")) &&
793 (pDict->GetString("Type") == "XRef" && 793 (pDict->GetStringBy("Type") == "XRef" &&
794 pDict->KeyExist("Size"))) { 794 pDict->KeyExist("Size"))) {
795 CPDF_Object* pRoot = pDict->GetElement("Root"); 795 CPDF_Object* pRoot = pDict->GetElement("Root");
796 if (pRoot && pRoot->GetDict() && 796 if (pRoot && pRoot->GetDict() &&
797 pRoot->GetDict()->GetElement("Pages")) { 797 pRoot->GetDict()->GetElement("Pages")) {
798 if (m_pTrailer) 798 if (m_pTrailer)
799 m_pTrailer->Release(); 799 m_pTrailer->Release();
800 m_pTrailer = ToDictionary(pDict->Clone()); 800 m_pTrailer = ToDictionary(pDict->Clone());
801 } 801 }
802 } 802 }
803 } 803 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 pObject->Release(); 1007 pObject->Release();
1008 } 1008 }
1009 if (!bInserted) 1009 if (!bInserted)
1010 return FALSE; 1010 return FALSE;
1011 } 1011 }
1012 1012
1013 CPDF_Stream* pStream = pObject->AsStream(); 1013 CPDF_Stream* pStream = pObject->AsStream();
1014 if (!pStream) 1014 if (!pStream)
1015 return FALSE; 1015 return FALSE;
1016 1016
1017 *pos = pStream->GetDict()->GetInteger("Prev"); 1017 *pos = pStream->GetDict()->GetIntegerBy("Prev");
1018 int32_t size = pStream->GetDict()->GetInteger("Size"); 1018 int32_t size = pStream->GetDict()->GetIntegerBy("Size");
1019 if (size < 0) { 1019 if (size < 0) {
1020 pStream->Release(); 1020 pStream->Release();
1021 return FALSE; 1021 return FALSE;
1022 } 1022 }
1023 if (bMainXRef) { 1023 if (bMainXRef) {
1024 m_pTrailer = ToDictionary(pStream->GetDict()->Clone()); 1024 m_pTrailer = ToDictionary(pStream->GetDict()->Clone());
1025 ShrinkObjectMap(size); 1025 ShrinkObjectMap(size);
1026 if (m_V5Type.SetSize(size)) { 1026 if (m_V5Type.SetSize(size)) {
1027 FXSYS_memset(m_V5Type.GetData(), 0, size); 1027 FXSYS_memset(m_V5Type.GetData(), 0, size);
1028 } 1028 }
1029 } else { 1029 } else {
1030 m_Trailers.Add(ToDictionary(pStream->GetDict()->Clone())); 1030 m_Trailers.Add(ToDictionary(pStream->GetDict()->Clone()));
1031 } 1031 }
1032 std::vector<std::pair<int32_t, int32_t> > arrIndex; 1032 std::vector<std::pair<int32_t, int32_t> > arrIndex;
1033 CPDF_Array* pArray = pStream->GetDict()->GetArray("Index"); 1033 CPDF_Array* pArray = pStream->GetDict()->GetArrayBy("Index");
1034 if (pArray) { 1034 if (pArray) {
1035 FX_DWORD nPairSize = pArray->GetCount() / 2; 1035 FX_DWORD nPairSize = pArray->GetCount() / 2;
1036 for (FX_DWORD i = 0; i < nPairSize; i++) { 1036 for (FX_DWORD i = 0; i < nPairSize; i++) {
1037 CPDF_Object* pStartNumObj = pArray->GetElement(i * 2); 1037 CPDF_Object* pStartNumObj = pArray->GetElement(i * 2);
1038 CPDF_Object* pCountObj = pArray->GetElement(i * 2 + 1); 1038 CPDF_Object* pCountObj = pArray->GetElement(i * 2 + 1);
1039 if (ToNumber(pStartNumObj) && ToNumber(pCountObj)) { 1039 if (ToNumber(pStartNumObj) && ToNumber(pCountObj)) {
1040 int nStartNum = pStartNumObj->GetInteger(); 1040 int nStartNum = pStartNumObj->GetInteger();
1041 int nCount = pCountObj->GetInteger(); 1041 int nCount = pCountObj->GetInteger();
1042 if (nStartNum >= 0 && nCount > 0) { 1042 if (nStartNum >= 0 && nCount > 0) {
1043 arrIndex.push_back(std::make_pair(nStartNum, nCount)); 1043 arrIndex.push_back(std::make_pair(nStartNum, nCount));
1044 } 1044 }
1045 } 1045 }
1046 } 1046 }
1047 } 1047 }
1048 if (arrIndex.size() == 0) { 1048 if (arrIndex.size() == 0) {
1049 arrIndex.push_back(std::make_pair(0, size)); 1049 arrIndex.push_back(std::make_pair(0, size));
1050 } 1050 }
1051 pArray = pStream->GetDict()->GetArray("W"); 1051 pArray = pStream->GetDict()->GetArrayBy("W");
1052 if (!pArray) { 1052 if (!pArray) {
1053 pStream->Release(); 1053 pStream->Release();
1054 return FALSE; 1054 return FALSE;
1055 } 1055 }
1056 CFX_DWordArray WidthArray; 1056 CFX_DWordArray WidthArray;
1057 FX_SAFE_DWORD dwAccWidth = 0; 1057 FX_SAFE_DWORD dwAccWidth = 0;
1058 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { 1058 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
1059 WidthArray.Add(pArray->GetInteger(i)); 1059 WidthArray.Add(pArray->GetIntegerAt(i));
1060 dwAccWidth += WidthArray[i]; 1060 dwAccWidth += WidthArray[i];
1061 } 1061 }
1062 if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) { 1062 if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) {
1063 pStream->Release(); 1063 pStream->Release();
1064 return FALSE; 1064 return FALSE;
1065 } 1065 }
1066 FX_DWORD totalWidth = dwAccWidth.ValueOrDie(); 1066 FX_DWORD totalWidth = dwAccWidth.ValueOrDie();
1067 CPDF_StreamAcc acc; 1067 CPDF_StreamAcc acc;
1068 acc.LoadAllData(pStream); 1068 acc.LoadAllData(pStream);
1069 const uint8_t* pData = acc.GetData(); 1069 const uint8_t* pData = acc.GetData();
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 if (!ToDictionary(pObj.get())) 1480 if (!ToDictionary(pObj.get()))
1481 return nullptr; 1481 return nullptr;
1482 return pObj.release()->AsDictionary(); 1482 return pObj.release()->AsDictionary();
1483 } 1483 }
1484 1484
1485 FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) { 1485 FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) {
1486 if (!m_pSecurityHandler) { 1486 if (!m_pSecurityHandler) {
1487 return (FX_DWORD)-1; 1487 return (FX_DWORD)-1;
1488 } 1488 }
1489 FX_DWORD dwPermission = m_pSecurityHandler->GetPermissions(); 1489 FX_DWORD dwPermission = m_pSecurityHandler->GetPermissions();
1490 if (m_pEncryptDict && m_pEncryptDict->GetString("Filter") == "Standard") { 1490 if (m_pEncryptDict && m_pEncryptDict->GetStringBy("Filter") == "Standard") {
1491 dwPermission &= 0xFFFFFFFC; 1491 dwPermission &= 0xFFFFFFFC;
1492 dwPermission |= 0xFFFFF0C0; 1492 dwPermission |= 0xFFFFF0C0;
1493 if (bCheckRevision && m_pEncryptDict->GetInteger("R") == 2) { 1493 if (bCheckRevision && m_pEncryptDict->GetIntegerBy("R") == 2) {
1494 dwPermission &= 0xFFFFF0FF; 1494 dwPermission &= 0xFFFFF0FF;
1495 } 1495 }
1496 } 1496 }
1497 return dwPermission; 1497 return dwPermission;
1498 } 1498 }
1499 FX_BOOL CPDF_Parser::IsOwner() { 1499 FX_BOOL CPDF_Parser::IsOwner() {
1500 return !m_pSecurityHandler || m_pSecurityHandler->IsOwner(); 1500 return !m_pSecurityHandler || m_pSecurityHandler->IsOwner();
1501 } 1501 }
1502 void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, 1502 void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler,
1503 FX_BOOL bForced) { 1503 FX_BOOL bForced) {
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2942 case CPDF_Object::ARRAY: { 2942 case CPDF_Object::ARRAY: {
2943 CPDF_Array* pArray = pObj->GetArray(); 2943 CPDF_Array* pArray = pObj->GetArray();
2944 for (FX_DWORD k = 0; k < pArray->GetCount(); k++) { 2944 for (FX_DWORD k = 0; k < pArray->GetCount(); k++) {
2945 new_obj_array.Add(pArray->GetElement(k)); 2945 new_obj_array.Add(pArray->GetElement(k));
2946 } 2946 }
2947 } break; 2947 } break;
2948 case CPDF_Object::STREAM: 2948 case CPDF_Object::STREAM:
2949 pObj = pObj->GetDict(); 2949 pObj = pObj->GetDict();
2950 case CPDF_Object::DICTIONARY: { 2950 case CPDF_Object::DICTIONARY: {
2951 CPDF_Dictionary* pDict = pObj->GetDict(); 2951 CPDF_Dictionary* pDict = pObj->GetDict();
2952 if (pDict && pDict->GetString("Type") == "Page" && !bParsePage) { 2952 if (pDict && pDict->GetStringBy("Type") == "Page" && !bParsePage) {
2953 continue; 2953 continue;
2954 } 2954 }
2955 for (const auto& it : *pDict) { 2955 for (const auto& it : *pDict) {
2956 const CFX_ByteString& key = it.first; 2956 const CFX_ByteString& key = it.first;
2957 CPDF_Object* value = it.second; 2957 CPDF_Object* value = it.second;
2958 if (key != "Parent") { 2958 if (key != "Parent") {
2959 new_obj_array.Add(value); 2959 new_obj_array.Add(value);
2960 } 2960 }
2961 } 2961 }
2962 } break; 2962 } break;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 for (int32_t j = 0; j < iSize; ++j) { 3293 for (int32_t j = 0; j < iSize; ++j) {
3294 if (CPDF_Reference* pRef = ToReference(pArray->GetElement(j))) 3294 if (CPDF_Reference* pRef = ToReference(pArray->GetElement(j)))
3295 UnavailObjList.Add(pRef->GetRefObjNum()); 3295 UnavailObjList.Add(pRef->GetRefObjNum());
3296 } 3296 }
3297 } 3297 }
3298 } 3298 }
3299 if (!pObj->IsDictionary()) { 3299 if (!pObj->IsDictionary()) {
3300 pObj->Release(); 3300 pObj->Release();
3301 continue; 3301 continue;
3302 } 3302 }
3303 CFX_ByteString type = pObj->GetDict()->GetString("Type"); 3303 CFX_ByteString type = pObj->GetDict()->GetStringBy("Type");
3304 if (type == "Pages") { 3304 if (type == "Pages") {
3305 m_PagesArray.Add(pObj); 3305 m_PagesArray.Add(pObj);
3306 continue; 3306 continue;
3307 } 3307 }
3308 pObj->Release(); 3308 pObj->Release();
3309 } 3309 }
3310 m_PageObjList.RemoveAll(); 3310 m_PageObjList.RemoveAll();
3311 if (UnavailObjList.GetSize()) { 3311 if (UnavailObjList.GetSize()) {
3312 m_PageObjList.Append(UnavailObjList); 3312 m_PageObjList.Append(UnavailObjList);
3313 return FALSE; 3313 return FALSE;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
3494 } 3494 }
3495 if (!pDict->KeyExist("H") || !pDict->KeyExist("O") || !pDict->KeyExist("N")) { 3495 if (!pDict->KeyExist("H") || !pDict->KeyExist("O") || !pDict->KeyExist("N")) {
3496 m_docStatus = PDF_DATAAVAIL_ERROR; 3496 m_docStatus = PDF_DATAAVAIL_ERROR;
3497 return FALSE; 3497 return FALSE;
3498 } 3498 }
3499 int nPageCount = pDict->GetElementValue("N")->GetInteger(); 3499 int nPageCount = pDict->GetElementValue("N")->GetInteger();
3500 if (nPageCount <= 1) { 3500 if (nPageCount <= 1) {
3501 m_docStatus = PDF_DATAAVAIL_DONE; 3501 m_docStatus = PDF_DATAAVAIL_DONE;
3502 return TRUE; 3502 return TRUE;
3503 } 3503 }
3504 CPDF_Array* pHintStreamRange = pDict->GetArray("H"); 3504 CPDF_Array* pHintStreamRange = pDict->GetArrayBy("H");
3505 FX_FILESIZE szHSStart = 3505 FX_FILESIZE szHSStart =
3506 pHintStreamRange->GetElementValue(0) 3506 pHintStreamRange->GetElementValue(0)
3507 ? pHintStreamRange->GetElementValue(0)->GetInteger() 3507 ? pHintStreamRange->GetElementValue(0)->GetInteger()
3508 : 0; 3508 : 0;
3509 FX_FILESIZE szHSLength = 3509 FX_FILESIZE szHSLength =
3510 pHintStreamRange->GetElementValue(1) 3510 pHintStreamRange->GetElementValue(1)
3511 ? pHintStreamRange->GetElementValue(1)->GetInteger() 3511 ? pHintStreamRange->GetElementValue(1)->GetInteger()
3512 : 0; 3512 : 0;
3513 if (szHSStart < 0 || szHSLength <= 0) { 3513 if (szHSStart < 0 || szHSLength <= 0) {
3514 m_docStatus = PDF_DATAAVAIL_ERROR; 3514 m_docStatus = PDF_DATAAVAIL_ERROR;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3675 CPDF_Object* pObj = m_parser.ParseIndirectObjectAt(nullptr, 0, objNum); 3675 CPDF_Object* pObj = m_parser.ParseIndirectObjectAt(nullptr, 0, objNum);
3676 if (!pObj) { 3676 if (!pObj) {
3677 m_Pos += m_parser.m_Syntax.SavePos(); 3677 m_Pos += m_parser.m_Syntax.SavePos();
3678 return 0; 3678 return 0;
3679 } 3679 }
3680 CPDF_Dictionary* pDict = pObj->GetDict(); 3680 CPDF_Dictionary* pDict = pObj->GetDict();
3681 CPDF_Name* pName = ToName(pDict ? pDict->GetElement("Type") : nullptr); 3681 CPDF_Name* pName = ToName(pDict ? pDict->GetElement("Type") : nullptr);
3682 if (pName) { 3682 if (pName) {
3683 if (pName->GetString() == "XRef") { 3683 if (pName->GetString() == "XRef") {
3684 m_Pos += m_parser.m_Syntax.SavePos(); 3684 m_Pos += m_parser.m_Syntax.SavePos();
3685 xref_offset = pObj->GetDict()->GetInteger("Prev"); 3685 xref_offset = pObj->GetDict()->GetIntegerBy("Prev");
3686 pObj->Release(); 3686 pObj->Release();
3687 return 1; 3687 return 1;
3688 } 3688 }
3689 } 3689 }
3690 pObj->Release(); 3690 pObj->Release();
3691 return -1; 3691 return -1;
3692 } 3692 }
3693 pHints->AddSegment(m_Pos, req_size); 3693 pHints->AddSegment(m_Pos, req_size);
3694 return 0; 3694 return 0;
3695 } 3695 }
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
4025 pPage->Release(); 4025 pPage->Release();
4026 return TRUE; 4026 return TRUE;
4027 } 4027 }
4028 if (!pPage->IsDictionary()) { 4028 if (!pPage->IsDictionary()) {
4029 pPage->Release(); 4029 pPage->Release();
4030 m_docStatus = PDF_DATAAVAIL_ERROR; 4030 m_docStatus = PDF_DATAAVAIL_ERROR;
4031 return FALSE; 4031 return FALSE;
4032 } 4032 }
4033 pPageNode->m_dwPageNo = dwPageNo; 4033 pPageNode->m_dwPageNo = dwPageNo;
4034 CPDF_Dictionary* pDict = pPage->GetDict(); 4034 CPDF_Dictionary* pDict = pPage->GetDict();
4035 CFX_ByteString type = pDict->GetString("Type"); 4035 CFX_ByteString type = pDict->GetStringBy("Type");
4036 if (type == "Pages") { 4036 if (type == "Pages") {
4037 pPageNode->m_type = PDF_PAGENODE_PAGES; 4037 pPageNode->m_type = PDF_PAGENODE_PAGES;
4038 CPDF_Object* pKids = pDict->GetElement("Kids"); 4038 CPDF_Object* pKids = pDict->GetElement("Kids");
4039 if (!pKids) { 4039 if (!pKids) {
4040 m_docStatus = PDF_DATAAVAIL_PAGE; 4040 m_docStatus = PDF_DATAAVAIL_PAGE;
4041 return TRUE; 4041 return TRUE;
4042 } 4042 }
4043 switch (pKids->GetType()) { 4043 switch (pKids->GetType()) {
4044 case CPDF_Object::REFERENCE: { 4044 case CPDF_Object::REFERENCE: {
4045 CPDF_Reference* pKid = pKids->AsReference(); 4045 CPDF_Reference* pKid = pKids->AsReference();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
4152 CPDF_Dictionary* pPagesDict = pPages->GetDict(); 4152 CPDF_Dictionary* pPagesDict = pPages->GetDict();
4153 if (!pPagesDict) { 4153 if (!pPagesDict) {
4154 pPages->Release(); 4154 pPages->Release();
4155 m_docStatus = PDF_DATAAVAIL_ERROR; 4155 m_docStatus = PDF_DATAAVAIL_ERROR;
4156 return FALSE; 4156 return FALSE;
4157 } 4157 }
4158 if (!pPagesDict->KeyExist("Kids")) { 4158 if (!pPagesDict->KeyExist("Kids")) {
4159 pPages->Release(); 4159 pPages->Release();
4160 return TRUE; 4160 return TRUE;
4161 } 4161 }
4162 int count = pPagesDict->GetInteger("Count"); 4162 int count = pPagesDict->GetIntegerBy("Count");
4163 if (count > 0) { 4163 if (count > 0) {
4164 pPages->Release(); 4164 pPages->Release();
4165 return TRUE; 4165 return TRUE;
4166 } 4166 }
4167 pPages->Release(); 4167 pPages->Release();
4168 return FALSE; 4168 return FALSE;
4169 } 4169 }
4170 FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) { 4170 FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) {
4171 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) { 4171 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) {
4172 return FALSE; 4172 return FALSE;
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
4868 CFX_BitStream bs; 4868 CFX_BitStream bs;
4869 bs.Init(acc.GetData(), size); 4869 bs.Init(acc.GetData(), size);
4870 return ReadPageHintTable(&bs) && 4870 return ReadPageHintTable(&bs) &&
4871 ReadSharedObjHintTable(&bs, pdfium::base::checked_cast<FX_DWORD>( 4871 ReadSharedObjHintTable(&bs, pdfium::base::checked_cast<FX_DWORD>(
4872 shared_hint_table_offset)); 4872 shared_hint_table_offset));
4873 } 4873 }
4874 4874
4875 int CPDF_HintTables::ReadPrimaryHintStreamOffset() const { 4875 int CPDF_HintTables::ReadPrimaryHintStreamOffset() const {
4876 if (!m_pLinearizedDict) 4876 if (!m_pLinearizedDict)
4877 return -1; 4877 return -1;
4878 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); 4878 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H");
4879 if (!pRange) 4879 if (!pRange)
4880 return -1; 4880 return -1;
4881 CPDF_Object* pStreamOffset = pRange->GetElementValue(0); 4881 CPDF_Object* pStreamOffset = pRange->GetElementValue(0);
4882 if (!pStreamOffset) 4882 if (!pStreamOffset)
4883 return -1; 4883 return -1;
4884 return pStreamOffset->GetInteger(); 4884 return pStreamOffset->GetInteger();
4885 } 4885 }
4886 int CPDF_HintTables::ReadPrimaryHintStreamLength() const { 4886 int CPDF_HintTables::ReadPrimaryHintStreamLength() const {
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->GetArrayBy("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