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/parser/cpdf_parser.h" | 7 #include "core/fpdfapi/parser/cpdf_parser.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 if (last_xref != -1 && last_xref > last_obj) | 948 if (last_xref != -1 && last_xref > last_obj) |
949 last_trailer = last_xref; | 949 last_trailer = last_xref; |
950 else if (last_trailer == -1 || last_xref < last_obj) | 950 else if (last_trailer == -1 || last_xref < last_obj) |
951 last_trailer = m_pSyntax->m_FileLen; | 951 last_trailer = m_pSyntax->m_FileLen; |
952 | 952 |
953 m_SortedOffset.insert(last_trailer - m_pSyntax->m_HeaderOffset); | 953 m_SortedOffset.insert(last_trailer - m_pSyntax->m_HeaderOffset); |
954 return m_pTrailer && !m_ObjectInfo.empty(); | 954 return m_pTrailer && !m_ObjectInfo.empty(); |
955 } | 955 } |
956 | 956 |
957 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { | 957 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { |
958 std::unique_ptr<CPDF_Object> pObject( | 958 UniqueObject pObject(ParseIndirectObjectAt(m_pDocument, *pos, 0)); |
959 ParseIndirectObjectAt(m_pDocument, *pos, 0)); | |
960 if (!pObject) | 959 if (!pObject) |
961 return FALSE; | 960 return FALSE; |
962 | 961 |
963 CPDF_Object* pUnownedObject = pObject.get(); | 962 CPDF_Object* pUnownedObject = pObject.get(); |
964 | |
965 if (m_pDocument) { | 963 if (m_pDocument) { |
966 CPDF_Dictionary* pRootDict = m_pDocument->GetRoot(); | 964 CPDF_Dictionary* pRootDict = m_pDocument->GetRoot(); |
967 if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum) | 965 if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum) |
968 return FALSE; | 966 return FALSE; |
969 // Takes ownership of object (std::move someday). | |
970 uint32_t objnum = pObject->m_ObjNum; | 967 uint32_t objnum = pObject->m_ObjNum; |
971 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration( | 968 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration( |
972 objnum, pObject.release())) { | 969 objnum, std::move(pObject))) { |
973 return FALSE; | 970 return FALSE; |
974 } | 971 } |
975 } | 972 } |
976 | 973 |
977 CPDF_Stream* pStream = pUnownedObject->AsStream(); | 974 CPDF_Stream* pStream = pUnownedObject->AsStream(); |
978 if (!pStream) | 975 if (!pStream) |
979 return FALSE; | 976 return FALSE; |
980 | 977 |
981 CPDF_Dictionary* pDict = pStream->GetDict(); | 978 CPDF_Dictionary* pDict = pStream->GetDict(); |
982 *pos = pDict->GetIntegerFor("Prev"); | 979 *pos = pDict->GetIntegerFor("Prev"); |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && | 1615 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && |
1619 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1616 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
1620 m_LastXRefOffset = 0; | 1617 m_LastXRefOffset = 0; |
1621 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1618 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1622 return FORMAT_ERROR; | 1619 return FORMAT_ERROR; |
1623 } | 1620 } |
1624 | 1621 |
1625 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1622 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
1626 return SUCCESS; | 1623 return SUCCESS; |
1627 } | 1624 } |
OLD | NEW |