| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "../../../include/fpdfapi/fpdf_module.h" | 10 #include "../../../include/fpdfapi/fpdf_module.h" |
| (...skipping 4086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4097 } | 4097 } |
| 4098 } | 4098 } |
| 4099 if (m_dwPrevXRefOffset) { | 4099 if (m_dwPrevXRefOffset) { |
| 4100 SetStartOffset(m_dwPrevXRefOffset); | 4100 SetStartOffset(m_dwPrevXRefOffset); |
| 4101 m_docStatus = PDF_DATAAVAIL_CROSSREF; | 4101 m_docStatus = PDF_DATAAVAIL_CROSSREF; |
| 4102 } else { | 4102 } else { |
| 4103 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; | 4103 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; |
| 4104 } | 4104 } |
| 4105 return TRUE; | 4105 return TRUE; |
| 4106 } | 4106 } |
| 4107 |
| 4107 FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) { | 4108 FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) { |
| 4108 int32_t iTrailerSize = | 4109 int32_t iTrailerSize = |
| 4109 (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); | 4110 (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); |
| 4110 if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { | 4111 if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { |
| 4111 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); | 4112 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); |
| 4112 CFX_BinaryBuf buf(iSize); | 4113 CFX_BinaryBuf buf(iSize); |
| 4113 uint8_t* pBuf = buf.GetBuffer(); | 4114 uint8_t* pBuf = buf.GetBuffer(); |
| 4114 if (!pBuf) { | 4115 if (!pBuf) { |
| 4115 m_docStatus = PDF_DATAAVAIL_ERROR; | 4116 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 4116 return FALSE; | 4117 return FALSE; |
| 4117 } | 4118 } |
| 4118 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { | 4119 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { |
| 4119 return FALSE; | 4120 return FALSE; |
| 4120 } | 4121 } |
| 4121 CFX_SmartPointer<IFX_FileStream> file( | 4122 CFX_SmartPointer<IFX_FileStream> file( |
| 4122 FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); | 4123 FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); |
| 4123 m_syntaxParser.InitParser(file.Get(), 0); | 4124 m_syntaxParser.InitParser(file.Get(), 0); |
| 4124 CPDF_Object* pTrailer = m_syntaxParser.GetObject(NULL, 0, 0, 0); | 4125 CPDF_Object* pTrailer = m_syntaxParser.GetObject(nullptr, 0, 0); |
| 4125 if (!pTrailer) { | 4126 if (!pTrailer) { |
| 4126 m_Pos += m_syntaxParser.SavePos(); | 4127 m_Pos += m_syntaxParser.SavePos(); |
| 4127 pHints->AddSegment(m_Pos, iTrailerSize); | 4128 pHints->AddSegment(m_Pos, iTrailerSize); |
| 4128 return FALSE; | 4129 return FALSE; |
| 4129 } | 4130 } |
| 4130 if (pTrailer->GetType() != PDFOBJ_DICTIONARY) { | 4131 if (pTrailer->GetType() != PDFOBJ_DICTIONARY) { |
| 4132 pTrailer->Release(); |
| 4131 return FALSE; | 4133 return FALSE; |
| 4132 } | 4134 } |
| 4133 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); | 4135 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); |
| 4134 if (pTrailerDict) { | 4136 if (pTrailerDict) { |
| 4135 CPDF_Object* pEncrypt = pTrailerDict->GetElement("Encrypt"); | 4137 CPDF_Object* pEncrypt = pTrailerDict->GetElement("Encrypt"); |
| 4136 if (pEncrypt && pEncrypt->GetType() == PDFOBJ_REFERENCE) { | 4138 if (pEncrypt && pEncrypt->GetType() == PDFOBJ_REFERENCE) { |
| 4137 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 4139 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 4138 pTrailer->Release(); | 4140 pTrailer->Release(); |
| 4139 return TRUE; | 4141 return TRUE; |
| 4140 } | 4142 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4158 return TRUE; | 4160 return TRUE; |
| 4159 } | 4161 } |
| 4160 m_dwPrevXRefOffset = 0; | 4162 m_dwPrevXRefOffset = 0; |
| 4161 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; | 4163 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; |
| 4162 pTrailer->Release(); | 4164 pTrailer->Release(); |
| 4163 return TRUE; | 4165 return TRUE; |
| 4164 } | 4166 } |
| 4165 pHints->AddSegment(m_Pos, iTrailerSize); | 4167 pHints->AddSegment(m_Pos, iTrailerSize); |
| 4166 return FALSE; | 4168 return FALSE; |
| 4167 } | 4169 } |
| 4170 |
| 4168 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) { | 4171 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) { |
| 4169 while (TRUE) { | 4172 while (TRUE) { |
| 4170 switch (m_docStatus) { | 4173 switch (m_docStatus) { |
| 4171 case PDF_DATAAVAIL_PAGETREE: | 4174 case PDF_DATAAVAIL_PAGETREE: |
| 4172 if (!LoadDocPages(pHints)) { | 4175 if (!LoadDocPages(pHints)) { |
| 4173 return FALSE; | 4176 return FALSE; |
| 4174 } | 4177 } |
| 4175 break; | 4178 break; |
| 4176 case PDF_DATAAVAIL_PAGE: | 4179 case PDF_DATAAVAIL_PAGE: |
| 4177 if (!LoadDocPage(iPage, pHints)) { | 4180 if (!LoadDocPage(iPage, pHints)) { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4710 return FALSE; | 4713 return FALSE; |
| 4711 } | 4714 } |
| 4712 CPDF_PageNode::~CPDF_PageNode() { | 4715 CPDF_PageNode::~CPDF_PageNode() { |
| 4713 int32_t iSize = m_childNode.GetSize(); | 4716 int32_t iSize = m_childNode.GetSize(); |
| 4714 for (int32_t i = 0; i < iSize; ++i) { | 4717 for (int32_t i = 0; i < iSize; ++i) { |
| 4715 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; | 4718 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; |
| 4716 delete pNode; | 4719 delete pNode; |
| 4717 } | 4720 } |
| 4718 m_childNode.RemoveAll(); | 4721 m_childNode.RemoveAll(); |
| 4719 } | 4722 } |
| OLD | NEW |