| 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 #include "core/fpdfapi/parser/cpdf_document.h" | 5 #include "core/fpdfapi/parser/cpdf_document.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "core/fpdfapi/cpdf_modulemgr.h" | 10 #include "core/fpdfapi/cpdf_modulemgr.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 allPages->AddNew<CPDF_Reference>(this, branch2->GetObjNum()); | 81 allPages->AddNew<CPDF_Reference>(this, branch2->GetObjNum()); |
| 82 allPages->AddNew<CPDF_Reference>(this, branch3->GetObjNum()); | 82 allPages->AddNew<CPDF_Reference>(this, branch3->GetObjNum()); |
| 83 allPages->AddNew<CPDF_Reference>(this, branch4->GetObjNum()); | 83 allPages->AddNew<CPDF_Reference>(this, branch4->GetObjNum()); |
| 84 CPDF_Dictionary* pagesDict = | 84 CPDF_Dictionary* pagesDict = |
| 85 CreatePageTreeNode(std::move(allPages), this, 7); | 85 CreatePageTreeNode(std::move(allPages), this, 7); |
| 86 | 86 |
| 87 m_pOwnedRootDict = pdfium::MakeUnique<CPDF_Dictionary>(); | 87 m_pOwnedRootDict = pdfium::MakeUnique<CPDF_Dictionary>(); |
| 88 m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this, | 88 m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this, |
| 89 pagesDict->GetObjNum()); | 89 pagesDict->GetObjNum()); |
| 90 m_pRootDict = m_pOwnedRootDict.get(); | 90 m_pRootDict = m_pOwnedRootDict.get(); |
| 91 m_PageList.SetSize(7); | 91 m_PageList.resize(7); |
| 92 } | 92 } |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict; | 95 std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 class CPDF_TestDocumentWithPageWithoutPageNum : public CPDF_Document { | 98 class CPDF_TestDocumentWithPageWithoutPageNum : public CPDF_Document { |
| 99 public: | 99 public: |
| 100 CPDF_TestDocumentWithPageWithoutPageNum() : CPDF_Document(nullptr) { | 100 CPDF_TestDocumentWithPageWithoutPageNum() : CPDF_Document(nullptr) { |
| 101 // Set up test | 101 // Set up test |
| 102 auto allPages = pdfium::MakeUnique<CPDF_Array>(); | 102 auto allPages = pdfium::MakeUnique<CPDF_Array>(); |
| 103 allPages->AddNew<CPDF_Reference>( | 103 allPages->AddNew<CPDF_Reference>( |
| 104 this, AddIndirectObject(CreateNumberedPage(0))->GetObjNum()); | 104 this, AddIndirectObject(CreateNumberedPage(0))->GetObjNum()); |
| 105 allPages->AddNew<CPDF_Reference>( | 105 allPages->AddNew<CPDF_Reference>( |
| 106 this, AddIndirectObject(CreateNumberedPage(1))->GetObjNum()); | 106 this, AddIndirectObject(CreateNumberedPage(1))->GetObjNum()); |
| 107 // Page without pageNum. | 107 // Page without pageNum. |
| 108 allPages->Add(CreateNumberedPage(2)); | 108 allPages->Add(CreateNumberedPage(2)); |
| 109 CPDF_Dictionary* pagesDict = | 109 CPDF_Dictionary* pagesDict = |
| 110 CreatePageTreeNode(std::move(allPages), this, 3); | 110 CreatePageTreeNode(std::move(allPages), this, 3); |
| 111 m_pOwnedRootDict = pdfium::MakeUnique<CPDF_Dictionary>(); | 111 m_pOwnedRootDict = pdfium::MakeUnique<CPDF_Dictionary>(); |
| 112 m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this, | 112 m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this, |
| 113 pagesDict->GetObjNum()); | 113 pagesDict->GetObjNum()); |
| 114 m_pRootDict = m_pOwnedRootDict.get(); | 114 m_pRootDict = m_pOwnedRootDict.get(); |
| 115 m_PageList.SetSize(3); | 115 m_PageList.resize(3); |
| 116 } | 116 } |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict; | 119 std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 class TestLinearized : public CPDF_LinearizedHeader { | 122 class TestLinearized : public CPDF_LinearizedHeader { |
| 123 public: | 123 public: |
| 124 explicit TestLinearized(CPDF_Dictionary* dict) | 124 explicit TestLinearized(CPDF_Dictionary* dict) |
| 125 : CPDF_LinearizedHeader(dict) {} | 125 : CPDF_LinearizedHeader(dict) {} |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 const uint32_t obj_num = page_stub->GetObjNum(); | 212 const uint32_t obj_num = page_stub->GetObjNum(); |
| 213 const int test_page_num = 33; | 213 const int test_page_num = 33; |
| 214 | 214 |
| 215 EXPECT_FALSE(document.IsPageLoaded(test_page_num)); | 215 EXPECT_FALSE(document.IsPageLoaded(test_page_num)); |
| 216 EXPECT_EQ(nullptr, document.GetPage(test_page_num)); | 216 EXPECT_EQ(nullptr, document.GetPage(test_page_num)); |
| 217 | 217 |
| 218 document.SetPageObjNum(test_page_num, obj_num); | 218 document.SetPageObjNum(test_page_num, obj_num); |
| 219 EXPECT_TRUE(document.IsPageLoaded(test_page_num)); | 219 EXPECT_TRUE(document.IsPageLoaded(test_page_num)); |
| 220 EXPECT_EQ(page_stub, document.GetPage(test_page_num)); | 220 EXPECT_EQ(page_stub, document.GetPage(test_page_num)); |
| 221 } | 221 } |
| OLD | NEW |