diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-11-02 14:40:38 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-02 14:40:38 +0000 |
commit | 1beb4a9c5ff7ac58450310493783ef7869f4de71 (patch) | |
tree | 8fc8c18dd575cccbfb22e98611af5c7a850371bb /core/fpdfapi/parser/cpdf_parser.cpp | |
parent | d4ef57288f19317de4e60a3b20425250cd6cd933 (diff) | |
download | pdfium-1beb4a9c5ff7ac58450310493783ef7869f4de71.tar.xz |
Unify parsing of linearized header.
Change-Id: I3b55b1331ee97af254c248d4ac91b627c9603b59
Reviewed-on: https://pdfium-review.googlesource.com/13831
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 6957c84071..7a8f4f9ce7 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -1280,34 +1280,8 @@ uint32_t CPDF_Parser::GetPermissions() const { return dwPermission; } -bool CPDF_Parser::ParseLinearizedHeader() { - m_pSyntax->SetPos(m_pSyntax->m_HeaderOffset + 9); - - FX_FILESIZE SavedPos = m_pSyntax->GetPos(); - bool bIsNumber; - ByteString word = m_pSyntax->GetNextWord(&bIsNumber); - if (!bIsNumber) - return false; - - word = m_pSyntax->GetNextWord(&bIsNumber); - if (!bIsNumber) - return false; - - if (m_pSyntax->GetKeyword() != "obj") { - m_pSyntax->SetPos(SavedPos); - return false; - } - - m_pLinearized = - CPDF_LinearizedHeader::CreateForObject(m_pSyntax->GetObjectBody(nullptr)); - if (!m_pLinearized) - return false; - - // Move parser onto first page xref table start. - m_pSyntax->GetNextWord(nullptr); - - m_LastXRefOffset = m_pSyntax->GetPos(); - return true; +std::unique_ptr<CPDF_LinearizedHeader> CPDF_Parser::ParseLinearizedHeader() { + return CPDF_LinearizedHeader::Parse(m_pSyntax.get()); } CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( @@ -1320,12 +1294,14 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( if (!InitSyntaxParser(pFileAccess)) return FORMAT_ERROR; - if (!ParseLinearizedHeader()) + m_pLinearized = ParseLinearizedHeader(); + if (!m_pLinearized) return StartParseInternal(std::move(pDocument)); m_bHasParsed = true; m_pDocument = pDocument; + m_LastXRefOffset = m_pLinearized->GetLastXRefOffset(); FX_FILESIZE dwFirstXRefOffset = m_LastXRefOffset; bool bXRefRebuilt = false; bool bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, false); |