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_parser.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 ToReference(m_pTrailer ? m_pTrailer->GetObjectFor("Root") : nullptr); | 1123 ToReference(m_pTrailer ? m_pTrailer->GetObjectFor("Root") : nullptr); |
1124 return pRef ? pRef->GetRefObjNum() : 0; | 1124 return pRef ? pRef->GetRefObjNum() : 0; |
1125 } | 1125 } |
1126 | 1126 |
1127 uint32_t CPDF_Parser::GetInfoObjNum() { | 1127 uint32_t CPDF_Parser::GetInfoObjNum() { |
1128 CPDF_Reference* pRef = | 1128 CPDF_Reference* pRef = |
1129 ToReference(m_pTrailer ? m_pTrailer->GetObjectFor("Info") : nullptr); | 1129 ToReference(m_pTrailer ? m_pTrailer->GetObjectFor("Info") : nullptr); |
1130 return pRef ? pRef->GetRefObjNum() : 0; | 1130 return pRef ? pRef->GetRefObjNum() : 0; |
1131 } | 1131 } |
1132 | 1132 |
1133 FX_BOOL CPDF_Parser::IsFormStream(uint32_t objnum, FX_BOOL& bForm) { | |
1134 bForm = FALSE; | |
1135 if (!IsValidObjectNumber(objnum)) | |
1136 return TRUE; | |
1137 | |
1138 if (GetObjectType(objnum) == 0) | |
1139 return TRUE; | |
1140 | |
1141 if (GetObjectType(objnum) == 2) | |
1142 return TRUE; | |
1143 | |
1144 FX_FILESIZE pos = m_ObjectInfo[objnum].pos; | |
1145 auto it = m_SortedOffset.find(pos); | |
1146 if (it == m_SortedOffset.end()) | |
1147 return TRUE; | |
1148 | |
1149 if (++it == m_SortedOffset.end()) | |
1150 return FALSE; | |
1151 | |
1152 FX_FILESIZE size = *it - pos; | |
1153 FX_FILESIZE SavedPos = m_pSyntax->SavePos(); | |
1154 m_pSyntax->RestorePos(pos); | |
1155 | |
1156 const char kFormStream[] = "/Form\0stream"; | |
1157 const CFX_ByteStringC kFormStreamStr(kFormStream, sizeof(kFormStream) - 1); | |
1158 bForm = m_pSyntax->SearchMultiWord(kFormStreamStr, TRUE, size) == 0; | |
1159 m_pSyntax->RestorePos(SavedPos); | |
1160 return TRUE; | |
1161 } | |
1162 | |
1163 CPDF_Object* CPDF_Parser::ParseIndirectObject( | 1133 CPDF_Object* CPDF_Parser::ParseIndirectObject( |
1164 CPDF_IndirectObjectHolder* pObjList, | 1134 CPDF_IndirectObjectHolder* pObjList, |
1165 uint32_t objnum) { | 1135 uint32_t objnum) { |
1166 if (!IsValidObjectNumber(objnum)) | 1136 if (!IsValidObjectNumber(objnum)) |
1167 return nullptr; | 1137 return nullptr; |
1168 | 1138 |
1169 // Prevent circular parsing the same object. | 1139 // Prevent circular parsing the same object. |
1170 if (pdfium::ContainsKey(m_ParsingObjNums, objnum)) | 1140 if (pdfium::ContainsKey(m_ParsingObjNums, objnum)) |
1171 return nullptr; | 1141 return nullptr; |
1172 | 1142 |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && | 1628 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && |
1659 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1629 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
1660 m_LastXRefOffset = 0; | 1630 m_LastXRefOffset = 0; |
1661 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1631 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1662 return FORMAT_ERROR; | 1632 return FORMAT_ERROR; |
1663 } | 1633 } |
1664 | 1634 |
1665 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1635 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1666 return SUCCESS; | 1636 return SUCCESS; |
1667 } | 1637 } |
OLD | NEW |