| 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 4095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4106 } | 4106 } |
| 4107 } | 4107 } |
| 4108 if (m_dwPrevXRefOffset) { | 4108 if (m_dwPrevXRefOffset) { |
| 4109 SetStartOffset(m_dwPrevXRefOffset); | 4109 SetStartOffset(m_dwPrevXRefOffset); |
| 4110 m_docStatus = PDF_DATAAVAIL_CROSSREF; | 4110 m_docStatus = PDF_DATAAVAIL_CROSSREF; |
| 4111 } else { | 4111 } else { |
| 4112 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; | 4112 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; |
| 4113 } | 4113 } |
| 4114 return TRUE; | 4114 return TRUE; |
| 4115 } | 4115 } |
| 4116 |
| 4116 FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) { | 4117 FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) { |
| 4117 int32_t iTrailerSize = | 4118 int32_t iTrailerSize = |
| 4118 (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); | 4119 (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); |
| 4119 if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { | 4120 if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { |
| 4120 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); | 4121 int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); |
| 4121 CFX_BinaryBuf buf(iSize); | 4122 CFX_BinaryBuf buf(iSize); |
| 4122 uint8_t* pBuf = buf.GetBuffer(); | 4123 uint8_t* pBuf = buf.GetBuffer(); |
| 4123 if (!pBuf) { | 4124 if (!pBuf) { |
| 4124 m_docStatus = PDF_DATAAVAIL_ERROR; | 4125 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 4125 return FALSE; | 4126 return FALSE; |
| 4126 } | 4127 } |
| 4127 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { | 4128 if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { |
| 4128 return FALSE; | 4129 return FALSE; |
| 4129 } | 4130 } |
| 4130 CFX_SmartPointer<IFX_FileStream> file( | 4131 CFX_SmartPointer<IFX_FileStream> file( |
| 4131 FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); | 4132 FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); |
| 4132 m_syntaxParser.InitParser(file.Get(), 0); | 4133 m_syntaxParser.InitParser(file.Get(), 0); |
| 4133 CPDF_Object* pTrailer = m_syntaxParser.GetObject(NULL, 0, 0, 0); | 4134 CPDF_Object* pTrailer = m_syntaxParser.GetObject(nullptr, 0, 0); |
| 4134 if (!pTrailer) { | 4135 if (!pTrailer) { |
| 4135 m_Pos += m_syntaxParser.SavePos(); | 4136 m_Pos += m_syntaxParser.SavePos(); |
| 4136 pHints->AddSegment(m_Pos, iTrailerSize); | 4137 pHints->AddSegment(m_Pos, iTrailerSize); |
| 4137 return FALSE; | 4138 return FALSE; |
| 4138 } | 4139 } |
| 4139 if (pTrailer->GetType() != PDFOBJ_DICTIONARY) { | 4140 if (pTrailer->GetType() != PDFOBJ_DICTIONARY) { |
| 4141 pTrailer->Release(); |
| 4140 return FALSE; | 4142 return FALSE; |
| 4141 } | 4143 } |
| 4142 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); | 4144 CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); |
| 4143 if (pTrailerDict) { | 4145 if (pTrailerDict) { |
| 4144 CPDF_Object* pEncrypt = pTrailerDict->GetElement("Encrypt"); | 4146 CPDF_Object* pEncrypt = pTrailerDict->GetElement("Encrypt"); |
| 4145 if (pEncrypt && pEncrypt->GetType() == PDFOBJ_REFERENCE) { | 4147 if (pEncrypt && pEncrypt->GetType() == PDFOBJ_REFERENCE) { |
| 4146 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 4148 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 4147 pTrailer->Release(); | 4149 pTrailer->Release(); |
| 4148 return TRUE; | 4150 return TRUE; |
| 4149 } | 4151 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4167 return TRUE; | 4169 return TRUE; |
| 4168 } | 4170 } |
| 4169 m_dwPrevXRefOffset = 0; | 4171 m_dwPrevXRefOffset = 0; |
| 4170 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; | 4172 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; |
| 4171 pTrailer->Release(); | 4173 pTrailer->Release(); |
| 4172 return TRUE; | 4174 return TRUE; |
| 4173 } | 4175 } |
| 4174 pHints->AddSegment(m_Pos, iTrailerSize); | 4176 pHints->AddSegment(m_Pos, iTrailerSize); |
| 4175 return FALSE; | 4177 return FALSE; |
| 4176 } | 4178 } |
| 4179 |
| 4177 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) { | 4180 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) { |
| 4178 while (TRUE) { | 4181 while (TRUE) { |
| 4179 switch (m_docStatus) { | 4182 switch (m_docStatus) { |
| 4180 case PDF_DATAAVAIL_PAGETREE: | 4183 case PDF_DATAAVAIL_PAGETREE: |
| 4181 if (!LoadDocPages(pHints)) { | 4184 if (!LoadDocPages(pHints)) { |
| 4182 return FALSE; | 4185 return FALSE; |
| 4183 } | 4186 } |
| 4184 break; | 4187 break; |
| 4185 case PDF_DATAAVAIL_PAGE: | 4188 case PDF_DATAAVAIL_PAGE: |
| 4186 if (!LoadDocPage(iPage, pHints)) { | 4189 if (!LoadDocPage(iPage, pHints)) { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4719 return FALSE; | 4722 return FALSE; |
| 4720 } | 4723 } |
| 4721 CPDF_PageNode::~CPDF_PageNode() { | 4724 CPDF_PageNode::~CPDF_PageNode() { |
| 4722 int32_t iSize = m_childNode.GetSize(); | 4725 int32_t iSize = m_childNode.GetSize(); |
| 4723 for (int32_t i = 0; i < iSize; ++i) { | 4726 for (int32_t i = 0; i < iSize; ++i) { |
| 4724 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; | 4727 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; |
| 4725 delete pNode; | 4728 delete pNode; |
| 4726 } | 4729 } |
| 4727 m_childNode.RemoveAll(); | 4730 m_childNode.RemoveAll(); |
| 4728 } | 4731 } |
| OLD | NEW |