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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 uint32_t size = GetObjectSize(dwNum, offset); | 169 uint32_t size = GetObjectSize(dwNum, offset); |
170 if (size == 0 || offset < 0 || offset >= m_dwFileLen) | 170 if (size == 0 || offset < 0 || offset >= m_dwFileLen) |
171 break; | 171 break; |
172 | 172 |
173 if (!IsDataAvail(offset, size, pHints)) { | 173 if (!IsDataAvail(offset, size, pHints)) { |
174 ret_array.Add(pObj); | 174 ret_array.Add(pObj); |
175 count++; | 175 count++; |
176 } else if (!pdfium::ContainsKey(m_ObjectSet, dwNum)) { | 176 } else if (!pdfium::ContainsKey(m_ObjectSet, dwNum)) { |
177 m_ObjectSet.insert(dwNum); | 177 m_ObjectSet.insert(dwNum); |
178 CPDF_Object* pReferred = | 178 CPDF_Object* pReferred = |
179 m_pDocument->GetIndirectObject(pRef->GetRefObjNum()); | 179 m_pDocument->GetOrParseIndirectObject(pRef->GetRefObjNum()); |
180 if (pReferred) | 180 if (pReferred) |
181 new_obj_array.Add(pReferred); | 181 new_obj_array.Add(pReferred); |
182 } | 182 } |
183 } break; | 183 } break; |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 if (count > 0) { | 187 if (count > 0) { |
188 for (int i = 0; i < new_obj_array.GetSize(); ++i) { | 188 for (int i = 0; i < new_obj_array.GetSize(); ++i) { |
189 CPDF_Object* pObj = new_obj_array[i]; | 189 CPDF_Object* pObj = new_obj_array[i]; |
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 bool bPagePosGot = m_pHintTables->GetPagePos(index, &szPageStartPos, | 1781 bool bPagePosGot = m_pHintTables->GetPagePos(index, &szPageStartPos, |
1782 &szPageLength, &dwObjNum); | 1782 &szPageLength, &dwObjNum); |
1783 if (!bPagePosGot) | 1783 if (!bPagePosGot) |
1784 return nullptr; | 1784 return nullptr; |
1785 | 1785 |
1786 m_syntaxParser.InitParser(m_pFileRead, (uint32_t)szPageStartPos); | 1786 m_syntaxParser.InitParser(m_pFileRead, (uint32_t)szPageStartPos); |
1787 CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); | 1787 CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); |
1788 if (!pPageDict) | 1788 if (!pPageDict) |
1789 return nullptr; | 1789 return nullptr; |
1790 | 1790 |
1791 if (!m_pDocument->InsertIndirectObject(dwObjNum, pPageDict)) | 1791 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(dwObjNum, |
| 1792 pPageDict)) { |
1792 return nullptr; | 1793 return nullptr; |
| 1794 } |
1793 return pPageDict->GetDict(); | 1795 return pPageDict->GetDict(); |
1794 } | 1796 } |
1795 } | 1797 } |
1796 return m_pDocument->GetPage(index); | 1798 return m_pDocument->GetPage(index); |
1797 } | 1799 } |
1798 | 1800 |
1799 CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( | 1801 CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( |
1800 DownloadHints* pHints) { | 1802 DownloadHints* pHints) { |
1801 if (!m_pDocument) | 1803 if (!m_pDocument) |
1802 return FormAvailable; | 1804 return FormAvailable; |
(...skipping 28 matching lines...) Expand all Loading... |
1831 return FormAvailable; | 1833 return FormAvailable; |
1832 } | 1834 } |
1833 | 1835 |
1834 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} | 1836 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} |
1835 | 1837 |
1836 CPDF_DataAvail::PageNode::~PageNode() { | 1838 CPDF_DataAvail::PageNode::~PageNode() { |
1837 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) | 1839 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) |
1838 delete m_childNode[i]; | 1840 delete m_childNode[i]; |
1839 m_childNode.RemoveAll(); | 1841 m_childNode.RemoveAll(); |
1840 } | 1842 } |
OLD | NEW |