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/parser/cpdf_data_avail.h" | 7 #include "core/fpdfapi/parser/cpdf_data_avail.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 } | 1618 } |
1619 | 1619 |
1620 DocAvailStatus nResult = CheckLinearizedData(pHints); | 1620 DocAvailStatus nResult = CheckLinearizedData(pHints); |
1621 if (nResult != DataAvailable) | 1621 if (nResult != DataAvailable) |
1622 return nResult; | 1622 return nResult; |
1623 | 1623 |
1624 if (m_pHintTables) { | 1624 if (m_pHintTables) { |
1625 nResult = m_pHintTables->CheckPage(dwPage, pHints); | 1625 nResult = m_pHintTables->CheckPage(dwPage, pHints); |
1626 if (nResult != DataAvailable) | 1626 if (nResult != DataAvailable) |
1627 return nResult; | 1627 return nResult; |
1628 // We should say to the document, which object is the page. | |
1629 m_pDocument->SetPageObjNum(dwPage, GetPage(dwPage)->GetObjNum()); | |
1630 m_pagesLoadState.insert(dwPage); | 1628 m_pagesLoadState.insert(dwPage); |
1631 return DataAvailable; | 1629 return DataAvailable; |
1632 } | 1630 } |
1633 | 1631 |
1634 if (m_bMainXRefLoadedOK) { | 1632 if (m_bMainXRefLoadedOK) { |
1635 if (m_bTotalLoadPageTree) { | 1633 if (m_bTotalLoadPageTree) { |
1636 if (!LoadPages(pHints)) | 1634 if (!LoadPages(pHints)) |
1637 return DataNotAvailable; | 1635 return DataNotAvailable; |
1638 } else { | 1636 } else { |
1639 if (!m_bCurPageDictLoadOK && !CheckPage(dwPage, pHints)) | 1637 if (!m_bCurPageDictLoadOK && !CheckPage(dwPage, pHints)) |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 1756 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
1759 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("P") : nullptr; | 1757 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("P") : nullptr; |
1760 | 1758 |
1761 int pageNum = pObj ? pObj->GetInteger() : 0; | 1759 int pageNum = pObj ? pObj->GetInteger() : 0; |
1762 if (m_pHintTables && index != pageNum) { | 1760 if (m_pHintTables && index != pageNum) { |
1763 FX_FILESIZE szPageStartPos = 0; | 1761 FX_FILESIZE szPageStartPos = 0; |
1764 FX_FILESIZE szPageLength = 0; | 1762 FX_FILESIZE szPageLength = 0; |
1765 uint32_t dwObjNum = 0; | 1763 uint32_t dwObjNum = 0; |
1766 bool bPagePosGot = m_pHintTables->GetPagePos(index, &szPageStartPos, | 1764 bool bPagePosGot = m_pHintTables->GetPagePos(index, &szPageStartPos, |
1767 &szPageLength, &dwObjNum); | 1765 &szPageLength, &dwObjNum); |
1768 if (!dwObjNum) | |
1769 return nullptr; | |
1770 // Page object already can be parsed in document. | |
1771 CPDF_Object* pPageDict = m_pDocument->GetIndirectObject(dwObjNum); | |
1772 if (pPageDict) | |
1773 return pPageDict->GetDict(); | |
1774 | |
1775 if (!bPagePosGot) | 1766 if (!bPagePosGot) |
1776 return nullptr; | 1767 return nullptr; |
1777 | 1768 |
1778 m_syntaxParser.InitParser(m_pFileRead, (uint32_t)szPageStartPos); | 1769 m_syntaxParser.InitParser(m_pFileRead, (uint32_t)szPageStartPos); |
1779 pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); | 1770 CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); |
1780 if (!pPageDict) | 1771 if (!pPageDict) |
1781 return nullptr; | 1772 return nullptr; |
1782 | 1773 |
1783 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(dwObjNum, | 1774 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(dwObjNum, |
1784 pPageDict)) { | 1775 pPageDict)) { |
1785 return nullptr; | 1776 return nullptr; |
1786 } | 1777 } |
1787 return pPageDict->GetDict(); | 1778 return pPageDict->GetDict(); |
1788 } | 1779 } |
1789 } | 1780 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 return FormAvailable; | 1816 return FormAvailable; |
1826 } | 1817 } |
1827 | 1818 |
1828 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} | 1819 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} |
1829 | 1820 |
1830 CPDF_DataAvail::PageNode::~PageNode() { | 1821 CPDF_DataAvail::PageNode::~PageNode() { |
1831 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) | 1822 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) |
1832 delete m_childNode[i]; | 1823 delete m_childNode[i]; |
1833 m_childNode.RemoveAll(); | 1824 m_childNode.RemoveAll(); |
1834 } | 1825 } |
OLD | NEW |