OLD | NEW |
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 for (i = 0; i < obj_array.GetSize(); i++) { | 146 for (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->GetArray(); |
155 for (uint32_t k = 0; k < pArray->GetCount(); ++k) | 155 for (uint32_t k = 0; k < pArray->GetCount(); ++k) |
156 new_obj_array.Add(pArray->GetElement(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 |
165 for (const auto& it : *pDict) { | 165 for (const auto& it : *pDict) { |
166 const CFX_ByteString& key = it.first; | 166 const CFX_ByteString& key = it.first; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 444 } |
445 return FALSE; | 445 return FALSE; |
446 } | 446 } |
447 | 447 |
448 CPDF_Dictionary* pDict = m_pRoot->GetDict(); | 448 CPDF_Dictionary* pDict = m_pRoot->GetDict(); |
449 if (!pDict) { | 449 if (!pDict) { |
450 m_docStatus = PDF_DATAAVAIL_ERROR; | 450 m_docStatus = PDF_DATAAVAIL_ERROR; |
451 return FALSE; | 451 return FALSE; |
452 } | 452 } |
453 | 453 |
454 CPDF_Reference* pRef = ToReference(pDict->GetElement("Pages")); | 454 CPDF_Reference* pRef = ToReference(pDict->GetObjectBy("Pages")); |
455 if (!pRef) { | 455 if (!pRef) { |
456 m_docStatus = PDF_DATAAVAIL_ERROR; | 456 m_docStatus = PDF_DATAAVAIL_ERROR; |
457 return FALSE; | 457 return FALSE; |
458 } | 458 } |
459 | 459 |
460 m_PagesObjNum = pRef->GetRefObjNum(); | 460 m_PagesObjNum = pRef->GetRefObjNum(); |
461 CPDF_Reference* pAcroFormRef = | 461 CPDF_Reference* pAcroFormRef = |
462 ToReference(m_pRoot->GetDict()->GetElement("AcroForm")); | 462 ToReference(m_pRoot->GetDict()->GetObjectBy("AcroForm")); |
463 if (pAcroFormRef) { | 463 if (pAcroFormRef) { |
464 m_bHaveAcroForm = TRUE; | 464 m_bHaveAcroForm = TRUE; |
465 m_dwAcroFormObjNum = pAcroFormRef->GetRefObjNum(); | 465 m_dwAcroFormObjNum = pAcroFormRef->GetRefObjNum(); |
466 } | 466 } |
467 | 467 |
468 if (m_dwInfoObjNum) { | 468 if (m_dwInfoObjNum) { |
469 m_docStatus = PDF_DATAAVAIL_INFO; | 469 m_docStatus = PDF_DATAAVAIL_INFO; |
470 } else { | 470 } else { |
471 m_docStatus = | 471 m_docStatus = |
472 m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE; | 472 m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE; |
473 } | 473 } |
474 return TRUE; | 474 return TRUE; |
475 } | 475 } |
476 | 476 |
477 FX_BOOL CPDF_DataAvail::PreparePageItem() { | 477 FX_BOOL CPDF_DataAvail::PreparePageItem() { |
478 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); | 478 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); |
479 CPDF_Reference* pRef = | 479 CPDF_Reference* pRef = |
480 ToReference(pRoot ? pRoot->GetElement("Pages") : nullptr); | 480 ToReference(pRoot ? pRoot->GetObjectBy("Pages") : nullptr); |
481 if (!pRef) { | 481 if (!pRef) { |
482 m_docStatus = PDF_DATAAVAIL_ERROR; | 482 m_docStatus = PDF_DATAAVAIL_ERROR; |
483 return FALSE; | 483 return FALSE; |
484 } | 484 } |
485 | 485 |
486 m_PagesObjNum = pRef->GetRefObjNum(); | 486 m_PagesObjNum = pRef->GetRefObjNum(); |
487 m_pCurrentParser = m_pDocument->GetParser(); | 487 m_pCurrentParser = m_pDocument->GetParser(); |
488 m_docStatus = PDF_DATAAVAIL_PAGETREE; | 488 m_docStatus = PDF_DATAAVAIL_PAGETREE; |
489 return TRUE; | 489 return TRUE; |
490 } | 490 } |
(...skipping 17 matching lines...) Expand all Loading... |
508 if (bExist) | 508 if (bExist) |
509 UnavailObjList.Add(dwPageObjNum); | 509 UnavailObjList.Add(dwPageObjNum); |
510 continue; | 510 continue; |
511 } | 511 } |
512 | 512 |
513 if (pObj->IsArray()) { | 513 if (pObj->IsArray()) { |
514 CPDF_Array* pArray = pObj->GetArray(); | 514 CPDF_Array* pArray = pObj->GetArray(); |
515 if (pArray) { | 515 if (pArray) { |
516 int32_t iSize = pArray->GetCount(); | 516 int32_t iSize = pArray->GetCount(); |
517 for (int32_t j = 0; j < iSize; ++j) { | 517 for (int32_t j = 0; j < iSize; ++j) { |
518 if (CPDF_Reference* pRef = ToReference(pArray->GetElement(j))) | 518 if (CPDF_Reference* pRef = ToReference(pArray->GetObjectAt(j))) |
519 UnavailObjList.Add(pRef->GetRefObjNum()); | 519 UnavailObjList.Add(pRef->GetRefObjNum()); |
520 } | 520 } |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 if (!pObj->IsDictionary()) { | 524 if (!pObj->IsDictionary()) { |
525 pObj->Release(); | 525 pObj->Release(); |
526 continue; | 526 continue; |
527 } | 527 } |
528 | 528 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 return TRUE; | 566 return TRUE; |
567 } | 567 } |
568 | 568 |
569 FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { | 569 FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { |
570 if (!pParser) { | 570 if (!pParser) { |
571 m_docStatus = PDF_DATAAVAIL_ERROR; | 571 m_docStatus = PDF_DATAAVAIL_ERROR; |
572 return FALSE; | 572 return FALSE; |
573 } | 573 } |
574 | 574 |
575 CPDF_Dictionary* pDict = pPages->GetDict(); | 575 CPDF_Dictionary* pDict = pPages->GetDict(); |
576 CPDF_Object* pKids = pDict ? pDict->GetElement("Kids") : NULL; | 576 CPDF_Object* pKids = pDict ? pDict->GetObjectBy("Kids") : NULL; |
577 if (!pKids) | 577 if (!pKids) |
578 return TRUE; | 578 return TRUE; |
579 | 579 |
580 switch (pKids->GetType()) { | 580 switch (pKids->GetType()) { |
581 case CPDF_Object::REFERENCE: | 581 case CPDF_Object::REFERENCE: |
582 m_PageObjList.Add(pKids->AsReference()->GetRefObjNum()); | 582 m_PageObjList.Add(pKids->AsReference()->GetRefObjNum()); |
583 break; | 583 break; |
584 case CPDF_Object::ARRAY: { | 584 case CPDF_Object::ARRAY: { |
585 CPDF_Array* pKidsArray = pKids->AsArray(); | 585 CPDF_Array* pKidsArray = pKids->AsArray(); |
586 for (uint32_t i = 0; i < pKidsArray->GetCount(); ++i) { | 586 for (uint32_t i = 0; i < pKidsArray->GetCount(); ++i) { |
587 if (CPDF_Reference* pRef = ToReference(pKidsArray->GetElement(i))) | 587 if (CPDF_Reference* pRef = ToReference(pKidsArray->GetObjectAt(i))) |
588 m_PageObjList.Add(pRef->GetRefObjNum()); | 588 m_PageObjList.Add(pRef->GetRefObjNum()); |
589 } | 589 } |
590 } break; | 590 } break; |
591 default: | 591 default: |
592 m_docStatus = PDF_DATAAVAIL_ERROR; | 592 m_docStatus = PDF_DATAAVAIL_ERROR; |
593 return FALSE; | 593 return FALSE; |
594 } | 594 } |
595 return TRUE; | 595 return TRUE; |
596 } | 596 } |
597 | 597 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 } | 640 } |
641 return TRUE; | 641 return TRUE; |
642 } | 642 } |
643 | 643 |
644 pHints->AddSegment(0, req_size); | 644 pHints->AddSegment(0, req_size); |
645 return FALSE; | 645 return FALSE; |
646 } | 646 } |
647 | 647 |
648 FX_BOOL CPDF_DataAvail::CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints) { | 648 FX_BOOL CPDF_DataAvail::CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints) { |
649 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 649 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
650 CPDF_Object* pEndOffSet = pDict ? pDict->GetElement("E") : NULL; | 650 CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectBy("E") : NULL; |
651 if (!pEndOffSet) { | 651 if (!pEndOffSet) { |
652 m_docStatus = PDF_DATAAVAIL_ERROR; | 652 m_docStatus = PDF_DATAAVAIL_ERROR; |
653 return FALSE; | 653 return FALSE; |
654 } | 654 } |
655 | 655 |
656 CPDF_Object* pXRefOffset = pDict ? pDict->GetElement("T") : NULL; | 656 CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectBy("T") : NULL; |
657 if (!pXRefOffset) { | 657 if (!pXRefOffset) { |
658 m_docStatus = PDF_DATAAVAIL_ERROR; | 658 m_docStatus = PDF_DATAAVAIL_ERROR; |
659 return FALSE; | 659 return FALSE; |
660 } | 660 } |
661 | 661 |
662 CPDF_Object* pFileLen = pDict ? pDict->GetElement("L") : NULL; | 662 CPDF_Object* pFileLen = pDict ? pDict->GetObjectBy("L") : NULL; |
663 if (!pFileLen) { | 663 if (!pFileLen) { |
664 m_docStatus = PDF_DATAAVAIL_ERROR; | 664 m_docStatus = PDF_DATAAVAIL_ERROR; |
665 return FALSE; | 665 return FALSE; |
666 } | 666 } |
667 | 667 |
668 FX_BOOL bNeedDownLoad = FALSE; | 668 FX_BOOL bNeedDownLoad = FALSE; |
669 if (pEndOffSet->IsNumber()) { | 669 if (pEndOffSet->IsNumber()) { |
670 uint32_t dwEnd = pEndOffSet->GetInteger(); | 670 uint32_t dwEnd = pEndOffSet->GetInteger(); |
671 dwEnd += 512; | 671 dwEnd += 512; |
672 if ((FX_FILESIZE)dwEnd > m_dwFileLen) | 672 if ((FX_FILESIZE)dwEnd > m_dwFileLen) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 if (!pDict) { | 739 if (!pDict) { |
740 m_docStatus = PDF_DATAAVAIL_ERROR; | 740 m_docStatus = PDF_DATAAVAIL_ERROR; |
741 return FALSE; | 741 return FALSE; |
742 } | 742 } |
743 | 743 |
744 if (!pDict->KeyExist("H") || !pDict->KeyExist("O") || !pDict->KeyExist("N")) { | 744 if (!pDict->KeyExist("H") || !pDict->KeyExist("O") || !pDict->KeyExist("N")) { |
745 m_docStatus = PDF_DATAAVAIL_ERROR; | 745 m_docStatus = PDF_DATAAVAIL_ERROR; |
746 return FALSE; | 746 return FALSE; |
747 } | 747 } |
748 | 748 |
749 int nPageCount = pDict->GetElementValue("N")->GetInteger(); | 749 int nPageCount = pDict->GetDirectObjectBy("N")->GetInteger(); |
750 if (nPageCount <= 1) { | 750 if (nPageCount <= 1) { |
751 m_docStatus = PDF_DATAAVAIL_DONE; | 751 m_docStatus = PDF_DATAAVAIL_DONE; |
752 return TRUE; | 752 return TRUE; |
753 } | 753 } |
754 | 754 |
755 CPDF_Array* pHintStreamRange = pDict->GetArrayBy("H"); | 755 CPDF_Array* pHintStreamRange = pDict->GetArrayBy("H"); |
756 FX_FILESIZE szHSStart = | 756 FX_FILESIZE szHSStart = |
757 pHintStreamRange->GetElementValue(0) | 757 pHintStreamRange->GetDirectObjectAt(0) |
758 ? pHintStreamRange->GetElementValue(0)->GetInteger() | 758 ? pHintStreamRange->GetDirectObjectAt(0)->GetInteger() |
759 : 0; | 759 : 0; |
760 FX_FILESIZE szHSLength = | 760 FX_FILESIZE szHSLength = |
761 pHintStreamRange->GetElementValue(1) | 761 pHintStreamRange->GetDirectObjectAt(1) |
762 ? pHintStreamRange->GetElementValue(1)->GetInteger() | 762 ? pHintStreamRange->GetDirectObjectAt(1)->GetInteger() |
763 : 0; | 763 : 0; |
764 if (szHSStart < 0 || szHSLength <= 0) { | 764 if (szHSStart < 0 || szHSLength <= 0) { |
765 m_docStatus = PDF_DATAAVAIL_ERROR; | 765 m_docStatus = PDF_DATAAVAIL_ERROR; |
766 return FALSE; | 766 return FALSE; |
767 } | 767 } |
768 | 768 |
769 if (!IsDataAvail(szHSStart, szHSLength, pHints)) | 769 if (!IsDataAvail(szHSStart, szHSLength, pHints)) |
770 return FALSE; | 770 return FALSE; |
771 | 771 |
772 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); | 772 m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 m_pLinearized->Release(); | 857 m_pLinearized->Release(); |
858 m_pLinearized = nullptr; | 858 m_pLinearized = nullptr; |
859 } | 859 } |
860 | 860 |
861 m_pLinearized = | 861 m_pLinearized = |
862 ParseIndirectObjectAt(m_syntaxParser.m_HeaderOffset + 9, objnum); | 862 ParseIndirectObjectAt(m_syntaxParser.m_HeaderOffset + 9, objnum); |
863 if (!m_pLinearized) | 863 if (!m_pLinearized) |
864 return FALSE; | 864 return FALSE; |
865 | 865 |
866 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 866 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
867 if (pDict && pDict->GetElement("Linearized")) { | 867 if (pDict && pDict->GetObjectBy("Linearized")) { |
868 CPDF_Object* pLen = pDict->GetElement("L"); | 868 CPDF_Object* pLen = pDict->GetObjectBy("L"); |
869 if (!pLen) | 869 if (!pLen) |
870 return FALSE; | 870 return FALSE; |
871 | 871 |
872 if ((FX_FILESIZE)pLen->GetInteger() != m_pFileRead->GetSize()) | 872 if ((FX_FILESIZE)pLen->GetInteger() != m_pFileRead->GetSize()) |
873 return FALSE; | 873 return FALSE; |
874 | 874 |
875 m_bLinearized = TRUE; | 875 m_bLinearized = TRUE; |
876 | 876 |
877 if (CPDF_Number* pNo = ToNumber(pDict->GetElement("P"))) | 877 if (CPDF_Number* pNo = ToNumber(pDict->GetObjectBy("P"))) |
878 m_dwFirstPageNo = pNo->GetInteger(); | 878 m_dwFirstPageNo = pNo->GetInteger(); |
879 | 879 |
880 return TRUE; | 880 return TRUE; |
881 } | 881 } |
882 return FALSE; | 882 return FALSE; |
883 } | 883 } |
884 | 884 |
885 FX_BOOL CPDF_DataAvail::CheckEnd(IPDF_DataAvail::DownloadHints* pHints) { | 885 FX_BOOL CPDF_DataAvail::CheckEnd(IPDF_DataAvail::DownloadHints* pHints) { |
886 uint32_t req_pos = (uint32_t)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); | 886 uint32_t req_pos = (uint32_t)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); |
887 uint32_t dwSize = (uint32_t)(m_dwFileLen - req_pos); | 887 uint32_t dwSize = (uint32_t)(m_dwFileLen - req_pos); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 return -1; | 947 return -1; |
948 | 948 |
949 uint32_t objNum = FXSYS_atoui(objnum); | 949 uint32_t objNum = FXSYS_atoui(objnum); |
950 CPDF_Object* pObj = m_parser.ParseIndirectObjectAt(nullptr, 0, objNum); | 950 CPDF_Object* pObj = m_parser.ParseIndirectObjectAt(nullptr, 0, objNum); |
951 if (!pObj) { | 951 if (!pObj) { |
952 m_Pos += m_parser.m_pSyntax->SavePos(); | 952 m_Pos += m_parser.m_pSyntax->SavePos(); |
953 return 0; | 953 return 0; |
954 } | 954 } |
955 | 955 |
956 CPDF_Dictionary* pDict = pObj->GetDict(); | 956 CPDF_Dictionary* pDict = pObj->GetDict(); |
957 CPDF_Name* pName = ToName(pDict ? pDict->GetElement("Type") : nullptr); | 957 CPDF_Name* pName = ToName(pDict ? pDict->GetObjectBy("Type") : nullptr); |
958 if (pName) { | 958 if (pName) { |
959 if (pName->GetString() == "XRef") { | 959 if (pName->GetString() == "XRef") { |
960 m_Pos += m_parser.m_pSyntax->SavePos(); | 960 m_Pos += m_parser.m_pSyntax->SavePos(); |
961 xref_offset = pObj->GetDict()->GetIntegerBy("Prev"); | 961 xref_offset = pObj->GetDict()->GetIntegerBy("Prev"); |
962 pObj->Release(); | 962 pObj->Release(); |
963 return 1; | 963 return 1; |
964 } | 964 } |
965 } | 965 } |
966 pObj->Release(); | 966 pObj->Release(); |
967 return -1; | 967 return -1; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 if (!pTrailer) { | 1197 if (!pTrailer) { |
1198 m_Pos += m_syntaxParser.SavePos(); | 1198 m_Pos += m_syntaxParser.SavePos(); |
1199 pHints->AddSegment(m_Pos, iTrailerSize); | 1199 pHints->AddSegment(m_Pos, iTrailerSize); |
1200 return FALSE; | 1200 return FALSE; |
1201 } | 1201 } |
1202 | 1202 |
1203 if (!pTrailer->IsDictionary()) | 1203 if (!pTrailer->IsDictionary()) |
1204 return FALSE; | 1204 return FALSE; |
1205 | 1205 |
1206 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); | 1206 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); |
1207 CPDF_Object* pEncrypt = pTrailerDict->GetElement("Encrypt"); | 1207 CPDF_Object* pEncrypt = pTrailerDict->GetObjectBy("Encrypt"); |
1208 if (ToReference(pEncrypt)) { | 1208 if (ToReference(pEncrypt)) { |
1209 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 1209 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
1210 return TRUE; | 1210 return TRUE; |
1211 } | 1211 } |
1212 | 1212 |
1213 uint32_t xrefpos = GetDirectInteger(pTrailerDict, "Prev"); | 1213 uint32_t xrefpos = GetDirectInteger(pTrailerDict, "Prev"); |
1214 if (xrefpos) { | 1214 if (xrefpos) { |
1215 m_dwPrevXRefOffset = GetDirectInteger(pTrailerDict, "XRefStm"); | 1215 m_dwPrevXRefOffset = GetDirectInteger(pTrailerDict, "XRefStm"); |
1216 if (m_dwPrevXRefOffset) { | 1216 if (m_dwPrevXRefOffset) { |
1217 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 1217 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 | 1279 |
1280 CPDF_Array* pArray = pPages->AsArray(); | 1280 CPDF_Array* pArray = pPages->AsArray(); |
1281 if (!pArray) { | 1281 if (!pArray) { |
1282 pPages->Release(); | 1282 pPages->Release(); |
1283 m_docStatus = PDF_DATAAVAIL_ERROR; | 1283 m_docStatus = PDF_DATAAVAIL_ERROR; |
1284 return FALSE; | 1284 return FALSE; |
1285 } | 1285 } |
1286 | 1286 |
1287 pPageNode->m_type = PDF_PAGENODE_PAGES; | 1287 pPageNode->m_type = PDF_PAGENODE_PAGES; |
1288 for (uint32_t i = 0; i < pArray->GetCount(); ++i) { | 1288 for (uint32_t i = 0; i < pArray->GetCount(); ++i) { |
1289 CPDF_Reference* pKid = ToReference(pArray->GetElement(i)); | 1289 CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i)); |
1290 if (!pKid) | 1290 if (!pKid) |
1291 continue; | 1291 continue; |
1292 | 1292 |
1293 PageNode* pNode = new PageNode(); | 1293 PageNode* pNode = new PageNode(); |
1294 pPageNode->m_childNode.Add(pNode); | 1294 pPageNode->m_childNode.Add(pNode); |
1295 pNode->m_dwPageNo = pKid->GetRefObjNum(); | 1295 pNode->m_dwPageNo = pKid->GetRefObjNum(); |
1296 } | 1296 } |
1297 pPages->Release(); | 1297 pPages->Release(); |
1298 return TRUE; | 1298 return TRUE; |
1299 } | 1299 } |
(...skipping 26 matching lines...) Expand all Loading... |
1326 pPage->Release(); | 1326 pPage->Release(); |
1327 m_docStatus = PDF_DATAAVAIL_ERROR; | 1327 m_docStatus = PDF_DATAAVAIL_ERROR; |
1328 return FALSE; | 1328 return FALSE; |
1329 } | 1329 } |
1330 | 1330 |
1331 pPageNode->m_dwPageNo = dwPageNo; | 1331 pPageNode->m_dwPageNo = dwPageNo; |
1332 CPDF_Dictionary* pDict = pPage->GetDict(); | 1332 CPDF_Dictionary* pDict = pPage->GetDict(); |
1333 CFX_ByteString type = pDict->GetStringBy("Type"); | 1333 CFX_ByteString type = pDict->GetStringBy("Type"); |
1334 if (type == "Pages") { | 1334 if (type == "Pages") { |
1335 pPageNode->m_type = PDF_PAGENODE_PAGES; | 1335 pPageNode->m_type = PDF_PAGENODE_PAGES; |
1336 CPDF_Object* pKids = pDict->GetElement("Kids"); | 1336 CPDF_Object* pKids = pDict->GetObjectBy("Kids"); |
1337 if (!pKids) { | 1337 if (!pKids) { |
1338 m_docStatus = PDF_DATAAVAIL_PAGE; | 1338 m_docStatus = PDF_DATAAVAIL_PAGE; |
1339 return TRUE; | 1339 return TRUE; |
1340 } | 1340 } |
1341 | 1341 |
1342 switch (pKids->GetType()) { | 1342 switch (pKids->GetType()) { |
1343 case CPDF_Object::REFERENCE: { | 1343 case CPDF_Object::REFERENCE: { |
1344 CPDF_Reference* pKid = pKids->AsReference(); | 1344 CPDF_Reference* pKid = pKids->AsReference(); |
1345 PageNode* pNode = new PageNode(); | 1345 PageNode* pNode = new PageNode(); |
1346 pPageNode->m_childNode.Add(pNode); | 1346 pPageNode->m_childNode.Add(pNode); |
1347 pNode->m_dwPageNo = pKid->GetRefObjNum(); | 1347 pNode->m_dwPageNo = pKid->GetRefObjNum(); |
1348 } break; | 1348 } break; |
1349 case CPDF_Object::ARRAY: { | 1349 case CPDF_Object::ARRAY: { |
1350 CPDF_Array* pKidsArray = pKids->AsArray(); | 1350 CPDF_Array* pKidsArray = pKids->AsArray(); |
1351 for (uint32_t i = 0; i < pKidsArray->GetCount(); ++i) { | 1351 for (uint32_t i = 0; i < pKidsArray->GetCount(); ++i) { |
1352 CPDF_Reference* pKid = ToReference(pKidsArray->GetElement(i)); | 1352 CPDF_Reference* pKid = ToReference(pKidsArray->GetObjectAt(i)); |
1353 if (!pKid) | 1353 if (!pKid) |
1354 continue; | 1354 continue; |
1355 | 1355 |
1356 PageNode* pNode = new PageNode(); | 1356 PageNode* pNode = new PageNode(); |
1357 pPageNode->m_childNode.Add(pNode); | 1357 pPageNode->m_childNode.Add(pNode); |
1358 pNode->m_dwPageNo = pKid->GetRefObjNum(); | 1358 pNode->m_dwPageNo = pKid->GetRefObjNum(); |
1359 } | 1359 } |
1360 } break; | 1360 } break; |
1361 default: | 1361 default: |
1362 break; | 1362 break; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, | 1537 FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, |
1538 IPDF_DataAvail::DownloadHints* pHints) { | 1538 IPDF_DataAvail::DownloadHints* pHints) { |
1539 if (!m_objs_array.GetSize()) { | 1539 if (!m_objs_array.GetSize()) { |
1540 m_objs_array.RemoveAll(); | 1540 m_objs_array.RemoveAll(); |
1541 m_ObjectSet.clear(); | 1541 m_ObjectSet.clear(); |
1542 | 1542 |
1543 CPDF_Dictionary* pPageDict = m_pDocument->GetPage(iPage); | 1543 CPDF_Dictionary* pPageDict = m_pDocument->GetPage(iPage); |
1544 if (!pPageDict) | 1544 if (!pPageDict) |
1545 return TRUE; | 1545 return TRUE; |
1546 | 1546 |
1547 CPDF_Object* pAnnots = pPageDict->GetElement("Annots"); | 1547 CPDF_Object* pAnnots = pPageDict->GetObjectBy("Annots"); |
1548 if (!pAnnots) | 1548 if (!pAnnots) |
1549 return TRUE; | 1549 return TRUE; |
1550 | 1550 |
1551 CFX_ArrayTemplate<CPDF_Object*> obj_array; | 1551 CFX_ArrayTemplate<CPDF_Object*> obj_array; |
1552 obj_array.Add(pAnnots); | 1552 obj_array.Add(pAnnots); |
1553 | 1553 |
1554 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); | 1554 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); |
1555 if (bRet) | 1555 if (bRet) |
1556 m_objs_array.RemoveAll(); | 1556 m_objs_array.RemoveAll(); |
1557 | 1557 |
(...skipping 22 matching lines...) Expand all Loading... |
1580 if (nRet == DataAvailable) | 1580 if (nRet == DataAvailable) |
1581 m_bPageLoadedOK = FALSE; | 1581 m_bPageLoadedOK = FALSE; |
1582 return nRet; | 1582 return nRet; |
1583 } | 1583 } |
1584 | 1584 |
1585 FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary* pDict) { | 1585 FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary* pDict) { |
1586 CFX_AutoRestorer<int> restorer(&s_CurrentDataAvailRecursionDepth); | 1586 CFX_AutoRestorer<int> restorer(&s_CurrentDataAvailRecursionDepth); |
1587 if (++s_CurrentDataAvailRecursionDepth > kMaxDataAvailRecursionDepth) | 1587 if (++s_CurrentDataAvailRecursionDepth > kMaxDataAvailRecursionDepth) |
1588 return FALSE; | 1588 return FALSE; |
1589 | 1589 |
1590 CPDF_Object* pParent = pDict->GetElement("Parent"); | 1590 CPDF_Object* pParent = pDict->GetObjectBy("Parent"); |
1591 if (!pParent) | 1591 if (!pParent) |
1592 return FALSE; | 1592 return FALSE; |
1593 | 1593 |
1594 CPDF_Dictionary* pParentDict = pParent->GetDict(); | 1594 CPDF_Dictionary* pParentDict = pParent->GetDict(); |
1595 if (!pParentDict) | 1595 if (!pParentDict) |
1596 return FALSE; | 1596 return FALSE; |
1597 | 1597 |
1598 CPDF_Object* pRet = pParentDict->GetElement("Resources"); | 1598 CPDF_Object* pRet = pParentDict->GetObjectBy("Resources"); |
1599 if (pRet) { | 1599 if (pRet) { |
1600 m_pPageResource = pRet; | 1600 m_pPageResource = pRet; |
1601 return TRUE; | 1601 return TRUE; |
1602 } | 1602 } |
1603 | 1603 |
1604 return HaveResourceAncestor(pParentDict); | 1604 return HaveResourceAncestor(pParentDict); |
1605 } | 1605 } |
1606 | 1606 |
1607 IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( | 1607 IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( |
1608 int32_t iPage, | 1608 int32_t iPage, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 m_bPageLoadedOK = TRUE; | 1702 m_bPageLoadedOK = TRUE; |
1703 } | 1703 } |
1704 | 1704 |
1705 if (!m_bAnnotsLoad) { | 1705 if (!m_bAnnotsLoad) { |
1706 if (!CheckPageAnnots(iPage, pHints)) | 1706 if (!CheckPageAnnots(iPage, pHints)) |
1707 return DataNotAvailable; | 1707 return DataNotAvailable; |
1708 m_bAnnotsLoad = TRUE; | 1708 m_bAnnotsLoad = TRUE; |
1709 } | 1709 } |
1710 | 1710 |
1711 if (m_pPageDict && !m_bNeedDownLoadResource) { | 1711 if (m_pPageDict && !m_bNeedDownLoadResource) { |
1712 m_pPageResource = m_pPageDict->GetElement("Resources"); | 1712 m_pPageResource = m_pPageDict->GetObjectBy("Resources"); |
1713 if (!m_pPageResource) | 1713 if (!m_pPageResource) |
1714 m_bNeedDownLoadResource = HaveResourceAncestor(m_pPageDict); | 1714 m_bNeedDownLoadResource = HaveResourceAncestor(m_pPageDict); |
1715 else | 1715 else |
1716 m_bNeedDownLoadResource = TRUE; | 1716 m_bNeedDownLoadResource = TRUE; |
1717 } | 1717 } |
1718 | 1718 |
1719 if (m_bNeedDownLoadResource) { | 1719 if (m_bNeedDownLoadResource) { |
1720 FX_BOOL bRet = CheckResources(pHints); | 1720 FX_BOOL bRet = CheckResources(pHints); |
1721 if (!bRet) | 1721 if (!bRet) |
1722 return DataNotAvailable; | 1722 return DataNotAvailable; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 uint32_t* pSize) { | 1756 uint32_t* pSize) { |
1757 if (pPos) | 1757 if (pPos) |
1758 *pPos = m_dwLastXRefOffset; | 1758 *pPos = m_dwLastXRefOffset; |
1759 if (pSize) | 1759 if (pSize) |
1760 *pSize = (uint32_t)(m_dwFileLen - m_dwLastXRefOffset); | 1760 *pSize = (uint32_t)(m_dwFileLen - m_dwLastXRefOffset); |
1761 } | 1761 } |
1762 | 1762 |
1763 int CPDF_DataAvail::GetPageCount() const { | 1763 int CPDF_DataAvail::GetPageCount() const { |
1764 if (m_pLinearized) { | 1764 if (m_pLinearized) { |
1765 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 1765 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
1766 CPDF_Object* pObj = pDict ? pDict->GetElementValue("N") : nullptr; | 1766 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectBy("N") : nullptr; |
1767 return pObj ? pObj->GetInteger() : 0; | 1767 return pObj ? pObj->GetInteger() : 0; |
1768 } | 1768 } |
1769 return m_pDocument ? m_pDocument->GetPageCount() : 0; | 1769 return m_pDocument ? m_pDocument->GetPageCount() : 0; |
1770 } | 1770 } |
1771 | 1771 |
1772 CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) { | 1772 CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) { |
1773 if (!m_pDocument || index < 0 || index >= GetPageCount()) | 1773 if (!m_pDocument || index < 0 || index >= GetPageCount()) |
1774 return nullptr; | 1774 return nullptr; |
1775 | 1775 |
1776 if (m_pLinearized) { | 1776 if (m_pLinearized) { |
1777 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 1777 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
1778 CPDF_Object* pObj = pDict ? pDict->GetElementValue("P") : nullptr; | 1778 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectBy("P") : nullptr; |
1779 | 1779 |
1780 int pageNum = pObj ? pObj->GetInteger() : 0; | 1780 int pageNum = pObj ? pObj->GetInteger() : 0; |
1781 if (m_pHintTables && index != pageNum) { | 1781 if (m_pHintTables && index != pageNum) { |
1782 FX_FILESIZE szPageStartPos = 0; | 1782 FX_FILESIZE szPageStartPos = 0; |
1783 FX_FILESIZE szPageLength = 0; | 1783 FX_FILESIZE szPageLength = 0; |
1784 uint32_t dwObjNum = 0; | 1784 uint32_t dwObjNum = 0; |
1785 FX_BOOL bPagePosGot = m_pHintTables->GetPagePos(index, szPageStartPos, | 1785 FX_BOOL bPagePosGot = m_pHintTables->GetPagePos(index, szPageStartPos, |
1786 szPageLength, dwObjNum); | 1786 szPageLength, dwObjNum); |
1787 if (!bPagePosGot) | 1787 if (!bPagePosGot) |
1788 return nullptr; | 1788 return nullptr; |
(...skipping 14 matching lines...) Expand all Loading... |
1803 IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( | 1803 IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( |
1804 IPDF_DataAvail::DownloadHints* pHints) { | 1804 IPDF_DataAvail::DownloadHints* pHints) { |
1805 if (!m_pDocument) | 1805 if (!m_pDocument) |
1806 return FormAvailable; | 1806 return FormAvailable; |
1807 | 1807 |
1808 if (!m_bLinearizedFormParamLoad) { | 1808 if (!m_bLinearizedFormParamLoad) { |
1809 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); | 1809 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); |
1810 if (!pRoot) | 1810 if (!pRoot) |
1811 return FormAvailable; | 1811 return FormAvailable; |
1812 | 1812 |
1813 CPDF_Object* pAcroForm = pRoot->GetElement("AcroForm"); | 1813 CPDF_Object* pAcroForm = pRoot->GetObjectBy("AcroForm"); |
1814 if (!pAcroForm) | 1814 if (!pAcroForm) |
1815 return FormNotExist; | 1815 return FormNotExist; |
1816 | 1816 |
1817 DocAvailStatus nDocStatus = CheckLinearizedData(pHints); | 1817 DocAvailStatus nDocStatus = CheckLinearizedData(pHints); |
1818 if (nDocStatus == DataError) | 1818 if (nDocStatus == DataError) |
1819 return FormError; | 1819 return FormError; |
1820 if (nDocStatus == DataNotAvailable) | 1820 if (nDocStatus == DataNotAvailable) |
1821 return FormNotAvailable; | 1821 return FormNotAvailable; |
1822 | 1822 |
1823 if (!m_objs_array.GetSize()) | 1823 if (!m_objs_array.GetSize()) |
(...skipping 11 matching lines...) Expand all Loading... |
1835 return FormAvailable; | 1835 return FormAvailable; |
1836 } | 1836 } |
1837 | 1837 |
1838 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} | 1838 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} |
1839 | 1839 |
1840 CPDF_DataAvail::PageNode::~PageNode() { | 1840 CPDF_DataAvail::PageNode::~PageNode() { |
1841 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) | 1841 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) |
1842 delete m_childNode[i]; | 1842 delete m_childNode[i]; |
1843 m_childNode.RemoveAll(); | 1843 m_childNode.RemoveAll(); |
1844 } | 1844 } |
OLD | NEW |