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/cpdf_data_avail.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1416 m_docStatus = PDF_DATAAVAIL_DONE; | 1416 m_docStatus = PDF_DATAAVAIL_DONE; |
1417 return TRUE; | 1417 return TRUE; |
1418 } | 1418 } |
1419 } | 1419 } |
1420 return TRUE; | 1420 return TRUE; |
1421 } | 1421 } |
1422 | 1422 |
1423 FX_BOOL CPDF_DataAvail::LoadDocPage(uint32_t dwPage, DownloadHints* pHints) { | 1423 FX_BOOL CPDF_DataAvail::LoadDocPage(uint32_t dwPage, DownloadHints* pHints) { |
1424 FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage); | 1424 FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage); |
1425 int32_t iPage = safePage.ValueOrDie(); | 1425 int32_t iPage = safePage.ValueOrDie(); |
1426 // TODO(dsinclair): This won't work correctly for XFA as the pageList in | |
1427 // the document does not contain XFA pages. | |
npm
2016/09/21 21:59:22
I think I don't understand. You are not changing t
dsinclair
2016/09/22 14:06:02
The problem I see here is that, the page count for
| |
1426 if (m_pDocument->GetPageCount() <= iPage || | 1428 if (m_pDocument->GetPageCount() <= iPage || |
1427 m_pDocument->IsPageLoaded(iPage)) { | 1429 m_pDocument->IsPageLoaded(iPage)) { |
1428 m_docStatus = PDF_DATAAVAIL_DONE; | 1430 m_docStatus = PDF_DATAAVAIL_DONE; |
1429 return TRUE; | 1431 return TRUE; |
1430 } | 1432 } |
1431 | 1433 |
1432 if (m_pageNodes.m_type == PDF_PAGENODE_PAGE) { | 1434 if (m_pageNodes.m_type == PDF_PAGENODE_PAGE) { |
1433 if (iPage == 0) { | 1435 if (iPage == 0) { |
1434 m_docStatus = PDF_DATAAVAIL_DONE; | 1436 m_docStatus = PDF_DATAAVAIL_DONE; |
1435 return TRUE; | 1437 return TRUE; |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1757 if (pSize) | 1759 if (pSize) |
1758 *pSize = (uint32_t)(m_dwFileLen - m_dwLastXRefOffset); | 1760 *pSize = (uint32_t)(m_dwFileLen - m_dwLastXRefOffset); |
1759 } | 1761 } |
1760 | 1762 |
1761 int CPDF_DataAvail::GetPageCount() const { | 1763 int CPDF_DataAvail::GetPageCount() const { |
1762 if (m_pLinearized) { | 1764 if (m_pLinearized) { |
1763 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 1765 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
1764 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("N") : nullptr; | 1766 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("N") : nullptr; |
1765 return pObj ? pObj->GetInteger() : 0; | 1767 return pObj ? pObj->GetInteger() : 0; |
1766 } | 1768 } |
1769 // TODO(dsinclair): This will be wrong for XFA documents. | |
1767 return m_pDocument ? m_pDocument->GetPageCount() : 0; | 1770 return m_pDocument ? m_pDocument->GetPageCount() : 0; |
1768 } | 1771 } |
1769 | 1772 |
1770 CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) { | 1773 CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) { |
1771 if (!m_pDocument || index < 0 || index >= GetPageCount()) | 1774 if (!m_pDocument || index < 0 || index >= GetPageCount()) |
1772 return nullptr; | 1775 return nullptr; |
1773 | 1776 |
1774 if (m_pLinearized) { | 1777 if (m_pLinearized) { |
1775 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); | 1778 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
1776 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("P") : nullptr; | 1779 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("P") : nullptr; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1835 return FormAvailable; | 1838 return FormAvailable; |
1836 } | 1839 } |
1837 | 1840 |
1838 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} | 1841 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} |
1839 | 1842 |
1840 CPDF_DataAvail::PageNode::~PageNode() { | 1843 CPDF_DataAvail::PageNode::~PageNode() { |
1841 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) | 1844 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) |
1842 delete m_childNode[i]; | 1845 delete m_childNode[i]; |
1843 m_childNode.RemoveAll(); | 1846 m_childNode.RemoveAll(); |
1844 } | 1847 } |
OLD | NEW |