summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp57
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 {