| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "parser_int.h" | 7 #include "parser_int.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 4889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4900 return TRUE; | 4900 return TRUE; |
| 4901 } | 4901 } |
| 4902 int32_t CPDF_HintTables::CheckPage(int index, IFX_DownloadHints* pHints) { | 4902 int32_t CPDF_HintTables::CheckPage(int index, IFX_DownloadHints* pHints) { |
| 4903 if (!m_pLinearizedDict || !pHints) | 4903 if (!m_pLinearizedDict || !pHints) |
| 4904 return IPDF_DataAvail::DataError; | 4904 return IPDF_DataAvail::DataError; |
| 4905 CPDF_Object* pFirstAvailPage = m_pLinearizedDict->GetElementValue("P"); | 4905 CPDF_Object* pFirstAvailPage = m_pLinearizedDict->GetElementValue("P"); |
| 4906 int nFirstAvailPage = pFirstAvailPage ? pFirstAvailPage->GetInteger() : 0; | 4906 int nFirstAvailPage = pFirstAvailPage ? pFirstAvailPage->GetInteger() : 0; |
| 4907 if (index == nFirstAvailPage) | 4907 if (index == nFirstAvailPage) |
| 4908 return IPDF_DataAvail::DataAvailable; | 4908 return IPDF_DataAvail::DataAvailable; |
| 4909 FX_DWORD dwLength = GetItemLength(index, m_szPageOffsetArray); | 4909 FX_DWORD dwLength = GetItemLength(index, m_szPageOffsetArray); |
| 4910 if (!dwLength || | 4910 // If two pages have the same offset, it should be treated as an error. |
| 4911 !m_pDataAvail->IsDataAvail(m_szPageOffsetArray[index], dwLength, | 4911 if (!dwLength) |
| 4912 pHints)) { | 4912 return IPDF_DataAvail::DataError; |
| 4913 if (!m_pDataAvail->IsDataAvail(m_szPageOffsetArray[index], dwLength, pHints)) |
| 4913 return IPDF_DataAvail::DataNotAvailable; | 4914 return IPDF_DataAvail::DataNotAvailable; |
| 4914 } | |
| 4915 // Download data of shared objects in the page. | 4915 // Download data of shared objects in the page. |
| 4916 FX_DWORD offset = 0; | 4916 FX_DWORD offset = 0; |
| 4917 for (int i = 0; i < index; ++i) { | 4917 for (int i = 0; i < index; ++i) { |
| 4918 offset += m_dwNSharedObjsArray[i]; | 4918 offset += m_dwNSharedObjsArray[i]; |
| 4919 } | 4919 } |
| 4920 CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetElementValue("O"); | 4920 CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetElementValue("O"); |
| 4921 int nFirstPageObjNum = pFirstPageObj ? pFirstPageObj->GetInteger() : -1; | 4921 int nFirstPageObjNum = pFirstPageObj ? pFirstPageObj->GetInteger() : -1; |
| 4922 if (nFirstPageObjNum < 0) | 4922 if (nFirstPageObjNum < 0) |
| 4923 return FALSE; // TODO(thestig): Fix this and the return type. | 4923 return IPDF_DataAvail::DataError; |
| 4924 FX_DWORD dwIndex = 0; | 4924 FX_DWORD dwIndex = 0; |
| 4925 FX_DWORD dwObjNum = 0; | 4925 FX_DWORD dwObjNum = 0; |
| 4926 for (int j = 0; j < m_dwNSharedObjsArray[index]; ++j) { | 4926 for (int j = 0; j < m_dwNSharedObjsArray[index]; ++j) { |
| 4927 dwIndex = m_dwIdentifierArray[offset + j]; | 4927 dwIndex = m_dwIdentifierArray[offset + j]; |
| 4928 if (dwIndex >= m_dwSharedObjNumArray.GetSize()) | 4928 if (dwIndex >= m_dwSharedObjNumArray.GetSize()) |
| 4929 return IPDF_DataAvail::DataNotAvailable; | 4929 return IPDF_DataAvail::DataNotAvailable; |
| 4930 dwObjNum = m_dwSharedObjNumArray[dwIndex]; | 4930 dwObjNum = m_dwSharedObjNumArray[dwIndex]; |
| 4931 if (dwObjNum >= nFirstPageObjNum && | 4931 if (dwObjNum >= nFirstPageObjNum && |
| 4932 dwObjNum < nFirstPageObjNum + m_nFirstPageSharedObjs) { | 4932 dwObjNum < nFirstPageObjNum + m_nFirstPageSharedObjs) { |
| 4933 continue; | 4933 continue; |
| 4934 } | 4934 } |
| 4935 dwLength = GetItemLength(dwIndex, m_szSharedObjOffsetArray); | 4935 dwLength = GetItemLength(dwIndex, m_szSharedObjOffsetArray); |
| 4936 if (!dwLength || | 4936 // If two objects have the same offset, it should be treated as an error. |
| 4937 !m_pDataAvail->IsDataAvail(m_szSharedObjOffsetArray[dwIndex], dwLength, | 4937 if (!dwLength) |
| 4938 return IPDF_DataAvail::DataError; |
| 4939 if (!m_pDataAvail->IsDataAvail(m_szSharedObjOffsetArray[dwIndex], dwLength, |
| 4938 pHints)) { | 4940 pHints)) { |
| 4939 return IPDF_DataAvail::DataNotAvailable; | 4941 return IPDF_DataAvail::DataNotAvailable; |
| 4940 } | 4942 } |
| 4941 } | 4943 } |
| 4942 return IPDF_DataAvail::DataAvailable; | 4944 return IPDF_DataAvail::DataAvailable; |
| 4943 } | 4945 } |
| 4944 FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) { | 4946 FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) { |
| 4945 if (!pHintStream || !m_pLinearizedDict) | 4947 if (!pHintStream || !m_pLinearizedDict) |
| 4946 return FALSE; | 4948 return FALSE; |
| 4947 CPDF_Dictionary* pDict = pHintStream->GetDict(); | 4949 CPDF_Dictionary* pDict = pHintStream->GetDict(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4981 if (!m_pLinearizedDict) | 4983 if (!m_pLinearizedDict) |
| 4982 return -1; | 4984 return -1; |
| 4983 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); | 4985 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); |
| 4984 if (!pRange) | 4986 if (!pRange) |
| 4985 return -1; | 4987 return -1; |
| 4986 CPDF_Object* pStreamLen = pRange->GetElementValue(1); | 4988 CPDF_Object* pStreamLen = pRange->GetElementValue(1); |
| 4987 if (!pStreamLen) | 4989 if (!pStreamLen) |
| 4988 return -1; | 4990 return -1; |
| 4989 return pStreamLen->GetInteger(); | 4991 return pStreamLen->GetInteger(); |
| 4990 } | 4992 } |
| OLD | NEW |