| 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 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 if (CPDF_Number* pTable = ToNumber(pDict->GetObjectBy("T"))) | 1536 if (CPDF_Number* pTable = ToNumber(pDict->GetObjectBy("T"))) |
| 1537 m_LastXRefOffset = pTable->GetInteger(); | 1537 m_LastXRefOffset = pTable->GetInteger(); |
| 1538 | 1538 |
| 1539 return TRUE; | 1539 return TRUE; |
| 1540 } | 1540 } |
| 1541 m_pLinearized->Release(); | 1541 m_pLinearized->Release(); |
| 1542 m_pLinearized = nullptr; | 1542 m_pLinearized = nullptr; |
| 1543 return FALSE; | 1543 return FALSE; |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 CPDF_Parser::Error CPDF_Parser::StartAsyncParse(IFX_FileRead* pFileAccess) { | 1546 CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( |
| 1547 IFX_FileRead* pFileAccess) { |
| 1547 CloseParser(); | 1548 CloseParser(); |
| 1548 m_bXRefStream = FALSE; | 1549 m_bXRefStream = FALSE; |
| 1549 m_LastXRefOffset = 0; | 1550 m_LastXRefOffset = 0; |
| 1550 m_bOwnFileRead = true; | 1551 m_bOwnFileRead = true; |
| 1551 | 1552 |
| 1552 int32_t offset = GetHeaderOffset(pFileAccess); | 1553 int32_t offset = GetHeaderOffset(pFileAccess); |
| 1553 if (offset == -1) | 1554 if (offset == -1) |
| 1554 return FORMAT_ERROR; | 1555 return FORMAT_ERROR; |
| 1555 | 1556 |
| 1556 if (!IsLinearizedFile(pFileAccess, offset)) { | 1557 if (!IsLinearizedFile(pFileAccess, offset)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1578 | 1579 |
| 1579 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size"); | 1580 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size"); |
| 1580 if (xrefsize > 0) | 1581 if (xrefsize > 0) |
| 1581 ShrinkObjectMap(xrefsize); | 1582 ShrinkObjectMap(xrefsize); |
| 1582 } | 1583 } |
| 1583 | 1584 |
| 1584 Error eRet = SetEncryptHandler(); | 1585 Error eRet = SetEncryptHandler(); |
| 1585 if (eRet != SUCCESS) | 1586 if (eRet != SUCCESS) |
| 1586 return eRet; | 1587 return eRet; |
| 1587 | 1588 |
| 1588 m_pDocument->LoadAsynDoc(m_pLinearized->GetDict()); | 1589 m_pDocument->LoadLinearizedDoc(m_pLinearized->GetDict()); |
| 1589 if (!m_pDocument->GetRoot() || m_pDocument->GetPageCount() == 0) { | 1590 if (!m_pDocument->GetRoot() || m_pDocument->GetPageCount() == 0) { |
| 1590 if (bXRefRebuilt) | 1591 if (bXRefRebuilt) |
| 1591 return FORMAT_ERROR; | 1592 return FORMAT_ERROR; |
| 1592 | 1593 |
| 1593 ReleaseEncryptHandler(); | 1594 ReleaseEncryptHandler(); |
| 1594 if (!RebuildCrossRef()) | 1595 if (!RebuildCrossRef()) |
| 1595 return FORMAT_ERROR; | 1596 return FORMAT_ERROR; |
| 1596 | 1597 |
| 1597 eRet = SetEncryptHandler(); | 1598 eRet = SetEncryptHandler(); |
| 1598 if (eRet != SUCCESS) | 1599 if (eRet != SUCCESS) |
| 1599 return eRet; | 1600 return eRet; |
| 1600 | 1601 |
| 1601 m_pDocument->LoadAsynDoc(m_pLinearized->GetDict()); | 1602 m_pDocument->LoadLinearizedDoc(m_pLinearized->GetDict()); |
| 1602 if (!m_pDocument->GetRoot()) | 1603 if (!m_pDocument->GetRoot()) |
| 1603 return FORMAT_ERROR; | 1604 return FORMAT_ERROR; |
| 1604 } | 1605 } |
| 1605 | 1606 |
| 1606 if (GetRootObjNum() == 0) { | 1607 if (GetRootObjNum() == 0) { |
| 1607 ReleaseEncryptHandler(); | 1608 ReleaseEncryptHandler(); |
| 1608 if (!RebuildCrossRef() || GetRootObjNum() == 0) | 1609 if (!RebuildCrossRef() || GetRootObjNum() == 0) |
| 1609 return FORMAT_ERROR; | 1610 return FORMAT_ERROR; |
| 1610 | 1611 |
| 1611 eRet = SetEncryptHandler(); | 1612 eRet = SetEncryptHandler(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && | 1668 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && |
| 1668 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1669 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
| 1669 m_LastXRefOffset = 0; | 1670 m_LastXRefOffset = 0; |
| 1670 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1671 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
| 1671 return FORMAT_ERROR; | 1672 return FORMAT_ERROR; |
| 1672 } | 1673 } |
| 1673 | 1674 |
| 1674 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1675 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
| 1675 return SUCCESS; | 1676 return SUCCESS; |
| 1676 } | 1677 } |
| OLD | NEW |