diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-09-01 18:52:30 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-05 15:07:57 +0000 |
commit | d2608a87173f00cb80830d56b52eeb588055ba3a (patch) | |
tree | 7cb97990ac1407f25c3f6415b346c7c049b649bc /core/fpdfapi/parser/cpdf_parser.cpp | |
parent | 088ca03f25fe1f6d75c0ff3b71e0ad3d018a5e0c (diff) | |
download | pdfium-d2608a87173f00cb80830d56b52eeb588055ba3a.tar.xz |
Move Parsing of indirect object logic into CPDF_SyntaxParser.
Change-Id: I5473d6db3e6fc247d52a83b34424958dc20387f4
Reviewed-on: https://pdfium-review.googlesource.com/12150
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 57 |
1 files changed, 12 insertions, 45 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index fffa7f9b00..a9cad02f5e 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -1012,7 +1012,7 @@ bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) { if (!pObject) return false; - uint32_t objnum = pObject->m_ObjNum; + uint32_t objnum = pObject->GetObjNum(); if (!objnum) return false; @@ -1258,58 +1258,24 @@ std::unique_ptr<CPDF_Object> CPDF_Parser::ParseIndirectObjectAt( CPDF_IndirectObjectHolder* pObjList, FX_FILESIZE pos, uint32_t objnum) { - return ParseIndirectObjectAtInternal(pObjList, pos, objnum, false, nullptr); + return ParseIndirectObjectAtInternal( + pObjList, pos, objnum, CPDF_SyntaxParser::ParseType::kLoose, nullptr); } std::unique_ptr<CPDF_Object> CPDF_Parser::ParseIndirectObjectAtInternal( CPDF_IndirectObjectHolder* pObjList, FX_FILESIZE pos, uint32_t objnum, - bool strict_parse, + CPDF_SyntaxParser::ParseType parse_type, FX_FILESIZE* pResultPos) { - FX_FILESIZE SavedPos = m_pSyntax->GetPos(); + const FX_FILESIZE saved_pos = m_pSyntax->GetPos(); m_pSyntax->SetPos(pos); - bool bIsNumber; - CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber); - if (!bIsNumber) { - m_pSyntax->SetPos(SavedPos); - return nullptr; - } - - uint32_t parser_objnum = FXSYS_atoui(word.c_str()); - if (objnum && parser_objnum != objnum) { - m_pSyntax->SetPos(SavedPos); - return nullptr; - } - - word = m_pSyntax->GetNextWord(&bIsNumber); - if (!bIsNumber) { - m_pSyntax->SetPos(SavedPos); - return nullptr; - } - - uint32_t parser_gennum = FXSYS_atoui(word.c_str()); - if (m_pSyntax->GetKeyword() != "obj") { - m_pSyntax->SetPos(SavedPos); - return nullptr; - } - - std::unique_ptr<CPDF_Object> pObj = - strict_parse - ? m_pSyntax->GetObjectForStrict(pObjList, objnum, parser_gennum, true) - : m_pSyntax->GetObject(pObjList, objnum, parser_gennum, true); - + auto result = + m_pSyntax->GetIndirectObject(pObjList, objnum, true, parse_type); if (pResultPos) - *pResultPos = m_pSyntax->m_Pos; - - if (pObj) { - if (!objnum) - pObj->m_ObjNum = parser_objnum; - pObj->m_GenNum = parser_gennum; - } - - m_pSyntax->SetPos(SavedPos); - return pObj; + *pResultPos = m_pSyntax->GetPos(); + m_pSyntax->SetPos(saved_pos); + return result; } std::unique_ptr<CPDF_Object> CPDF_Parser::ParseIndirectObjectAtByStrict( @@ -1317,7 +1283,8 @@ std::unique_ptr<CPDF_Object> CPDF_Parser::ParseIndirectObjectAtByStrict( FX_FILESIZE pos, uint32_t objnum, FX_FILESIZE* pResultPos) { - return ParseIndirectObjectAtInternal(pObjList, pos, objnum, true, pResultPos); + return ParseIndirectObjectAtInternal( + pObjList, pos, objnum, CPDF_SyntaxParser::ParseType::kStrict, pResultPos); } uint32_t CPDF_Parser::GetFirstPageNo() const { |