| 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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 m_SortedOffset.Add(offset); | 980 m_SortedOffset.Add(offset); |
| 981 } | 981 } |
| 982 FX_Free(buffer); | 982 FX_Free(buffer); |
| 983 return m_pTrailer && m_CrossRef.GetSize() > 0; | 983 return m_pTrailer && m_CrossRef.GetSize() > 0; |
| 984 } | 984 } |
| 985 | 985 |
| 986 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { | 986 FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { |
| 987 CPDF_Object* pObject = ParseIndirectObjectAt(m_pDocument, *pos, 0, nullptr); | 987 CPDF_Object* pObject = ParseIndirectObjectAt(m_pDocument, *pos, 0, nullptr); |
| 988 if (!pObject) | 988 if (!pObject) |
| 989 return FALSE; | 989 return FALSE; |
| 990 | |
| 991 if (m_pDocument) { | 990 if (m_pDocument) { |
| 991 FX_BOOL bInserted = FALSE; |
| 992 CPDF_Dictionary* pDict = m_pDocument->GetRoot(); | 992 CPDF_Dictionary* pDict = m_pDocument->GetRoot(); |
| 993 if (!pDict || pDict->GetObjNum() != pObject->m_ObjNum) { | 993 if (!pDict || pDict->GetObjNum() != pObject->m_ObjNum) { |
| 994 m_pDocument->InsertIndirectObject(pObject->m_ObjNum, pObject); | 994 bInserted = m_pDocument->InsertIndirectObject(pObject->m_ObjNum, pObject); |
| 995 } else { | 995 } else { |
| 996 if (pObject->IsStream()) | 996 if (pObject->IsStream()) |
| 997 pObject->Release(); | 997 pObject->Release(); |
| 998 } |
| 999 if (!bInserted) |
| 998 return FALSE; | 1000 return FALSE; |
| 999 } | |
| 1000 } | 1001 } |
| 1001 | 1002 |
| 1002 CPDF_Stream* pStream = pObject->AsStream(); | 1003 CPDF_Stream* pStream = pObject->AsStream(); |
| 1003 if (!pStream) | 1004 if (!pStream) |
| 1004 return FALSE; | 1005 return FALSE; |
| 1005 | 1006 |
| 1006 *pos = pStream->GetDict()->GetInteger(FX_BSTRC("Prev")); | 1007 *pos = pStream->GetDict()->GetInteger(FX_BSTRC("Prev")); |
| 1007 int32_t size = pStream->GetDict()->GetInteger(FX_BSTRC("Size")); | 1008 int32_t size = pStream->GetDict()->GetInteger(FX_BSTRC("Size")); |
| 1008 if (size < 0) { | 1009 if (size < 0) { |
| 1009 pStream->Release(); | 1010 pStream->Release(); |
| (...skipping 3536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4546 FX_BOOL bPagePosGot = m_pHintTables->GetPagePos(index, szPageStartPos, | 4547 FX_BOOL bPagePosGot = m_pHintTables->GetPagePos(index, szPageStartPos, |
| 4547 szPageLength, dwObjNum); | 4548 szPageLength, dwObjNum); |
| 4548 if (!bPagePosGot) { | 4549 if (!bPagePosGot) { |
| 4549 return nullptr; | 4550 return nullptr; |
| 4550 } | 4551 } |
| 4551 m_syntaxParser.InitParser(m_pFileRead, (FX_DWORD)szPageStartPos); | 4552 m_syntaxParser.InitParser(m_pFileRead, (FX_DWORD)szPageStartPos); |
| 4552 CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); | 4553 CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); |
| 4553 if (!pPageDict) { | 4554 if (!pPageDict) { |
| 4554 return nullptr; | 4555 return nullptr; |
| 4555 } | 4556 } |
| 4556 m_pDocument->InsertIndirectObject(dwObjNum, pPageDict); | 4557 if (!m_pDocument->InsertIndirectObject(dwObjNum, pPageDict)) |
| 4558 return nullptr; |
| 4557 return pPageDict->GetDict(); | 4559 return pPageDict->GetDict(); |
| 4558 } | 4560 } |
| 4559 } | 4561 } |
| 4560 return m_pDocument->GetPage(index); | 4562 return m_pDocument->GetPage(index); |
| 4561 } | 4563 } |
| 4562 IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( | 4564 IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( |
| 4563 IFX_DownloadHints* pHints) { | 4565 IFX_DownloadHints* pHints) { |
| 4564 if (!m_pDocument) { | 4566 if (!m_pDocument) { |
| 4565 return FormAvailable; | 4567 return FormAvailable; |
| 4566 } | 4568 } |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4947 if (!m_pLinearizedDict) | 4949 if (!m_pLinearizedDict) |
| 4948 return -1; | 4950 return -1; |
| 4949 CPDF_Array* pRange = m_pLinearizedDict->GetArray(FX_BSTRC("H")); | 4951 CPDF_Array* pRange = m_pLinearizedDict->GetArray(FX_BSTRC("H")); |
| 4950 if (!pRange) | 4952 if (!pRange) |
| 4951 return -1; | 4953 return -1; |
| 4952 CPDF_Object* pStreamLen = pRange->GetElementValue(1); | 4954 CPDF_Object* pStreamLen = pRange->GetElementValue(1); |
| 4953 if (!pStreamLen) | 4955 if (!pStreamLen) |
| 4954 return -1; | 4956 return -1; |
| 4955 return pStreamLen->GetInteger(); | 4957 return pStreamLen->GetInteger(); |
| 4956 } | 4958 } |
| OLD | NEW |