Chromium Code Reviews| Index: core/fpdfapi/parser/cpdf_parser.cpp |
| diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp |
| index c2748882cfde06fba94c4d0a550bbe0013e36e55..0d3442e3dc4f2cbe0b13ea828f6b2edcaa0dd081 100644 |
| --- a/core/fpdfapi/parser/cpdf_parser.cpp |
| +++ b/core/fpdfapi/parser/cpdf_parser.cpp |
| @@ -12,6 +12,7 @@ |
| #include "core/fpdfapi/parser/cpdf_crypto_handler.h" |
| #include "core/fpdfapi/parser/cpdf_dictionary.h" |
| #include "core/fpdfapi/parser/cpdf_document.h" |
| +#include "core/fpdfapi/parser/cpdf_linearized.h" |
| #include "core/fpdfapi/parser/cpdf_number.h" |
| #include "core/fpdfapi/parser/cpdf_reference.h" |
| #include "core/fpdfapi/parser/cpdf_security_handler.h" |
| @@ -54,7 +55,6 @@ CPDF_Parser::CPDF_Parser() |
| m_pTrailer(nullptr), |
| m_pEncryptDict(nullptr), |
| m_bVersionUpdated(false), |
| - m_pLinearized(nullptr), |
| m_dwFirstPageNo(0), |
| m_dwXrefStartObjNum(0) { |
| m_pSyntax.reset(new CPDF_SyntaxParser); |
| @@ -76,9 +76,6 @@ CPDF_Parser::~CPDF_Parser() { |
| if (trailer) |
| trailer->Release(); |
| } |
| - |
| - if (m_pLinearized) |
| - m_pLinearized->Release(); |
| } |
| uint32_t CPDF_Parser::GetLastObjNum() const { |
| @@ -1460,35 +1457,13 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess, |
| return FALSE; |
| } |
| - m_pLinearized = m_pSyntax->GetObject(nullptr, objnum, gennum, true); |
| + m_pLinearized = CPDF_Linearized::CreateForObject( |
| + UniqueObject(m_pSyntax->GetObject(nullptr, objnum, gennum, true))); |
| if (!m_pLinearized) |
| return FALSE; |
| - |
| - CPDF_Dictionary* pDict = m_pLinearized->GetDict(); |
| - if (pDict && pDict->GetObjectFor("Linearized")) { |
| - m_pSyntax->GetNextWord(nullptr); |
| - |
| - CPDF_Object* pLen = pDict->GetObjectFor("L"); |
| - if (!pLen) { |
| - m_pLinearized->Release(); |
| - m_pLinearized = nullptr; |
| - return FALSE; |
| - } |
| - |
| - if (pLen->GetInteger() != (int)pFileAccess->GetSize()) |
| - return FALSE; |
| - |
| - if (CPDF_Number* pNo = ToNumber(pDict->GetObjectFor("P"))) |
| - m_dwFirstPageNo = pNo->GetInteger(); |
| - |
| - if (CPDF_Number* pTable = ToNumber(pDict->GetObjectFor("T"))) |
| - m_LastXRefOffset = pTable->GetInteger(); |
| - |
| - return TRUE; |
| - } |
| - m_pLinearized->Release(); |
| - m_pLinearized = nullptr; |
| - return FALSE; |
| + m_dwFirstPageNo = m_pLinearized->GetFirstPageNo(); |
|
Lei Zhang
2016/11/02 21:34:22
You may want just get rid of |m_dwFirstPageNo| and
snake
2016/11/02 22:04:29
Done.
|
| + m_LastXRefOffset = m_pLinearized->GetLastXRefOffset(); |
| + return TRUE; |
| } |
| CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( |
| @@ -1511,6 +1486,7 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( |
| m_bHasParsed = true; |
| m_pDocument = pDocument; |
| + m_pSyntax->GetNextWord(nullptr); |
| FX_FILESIZE dwFirstXRefOffset = m_pSyntax->SavePos(); |
| FX_BOOL bXRefRebuilt = FALSE; |
| @@ -1537,7 +1513,7 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( |
| if (eRet != SUCCESS) |
| return eRet; |
| - m_pDocument->LoadLinearizedDoc(m_pLinearized->GetDict()); |
| + m_pDocument->LoadLinearizedDoc(m_pLinearized.get()); |
| if (!m_pDocument->GetRoot() || m_pDocument->GetPageCount() == 0) { |
| if (bXRefRebuilt) |
| return FORMAT_ERROR; |
| @@ -1550,7 +1526,7 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( |
| if (eRet != SUCCESS) |
| return eRet; |
| - m_pDocument->LoadLinearizedDoc(m_pLinearized->GetDict()); |
| + m_pDocument->LoadLinearizedDoc(m_pLinearized.get()); |
| if (!m_pDocument->GetRoot()) |
| return FORMAT_ERROR; |
| } |