From 09b5ce623fc47bc3d19d60aa2a219c838971dd4b Mon Sep 17 00:00:00 2001 From: Artem Strygin Date: Fri, 22 Sep 2017 00:06:59 +0300 Subject: Rename CPDF_SyntaxParser::GetObject to GetObjectBody Change-Id: Ia8fd1893f862391fbada396f505ac16985b59cd6 Reviewed-on: https://pdfium-review.googlesource.com/12850 Commit-Queue: Art Snake Reviewed-by: dsinclair --- core/fpdfapi/parser/cfdf_document.cpp | 4 +-- core/fpdfapi/parser/cpdf_data_avail.cpp | 4 +-- core/fpdfapi/parser/cpdf_parser.cpp | 8 +++--- core/fpdfapi/parser/cpdf_syntax_parser.cpp | 30 ++++++++++++---------- core/fpdfapi/parser/cpdf_syntax_parser.h | 13 +++++----- .../fpdfapi/parser/cpdf_syntax_parser_unittest.cpp | 2 +- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp index 1d5cf8ade7..9c833cedcf 100644 --- a/core/fpdfapi/parser/cfdf_document.cpp +++ b/core/fpdfapi/parser/cfdf_document.cpp @@ -67,7 +67,7 @@ void CFDF_Document::ParseStream( break; std::unique_ptr pObj = - parser.GetObject(this, objnum, 0, false); + parser.GetObjectBody(this, objnum, 0, false); if (!pObj) break; @@ -80,7 +80,7 @@ void CFDF_Document::ParseStream( break; std::unique_ptr pMainDict = - ToDictionary(parser.GetObject(this, 0, 0, false)); + ToDictionary(parser.GetObjectBody(this, 0, 0, false)); if (pMainDict) m_pRootDict = pMainDict->GetDictFor("Root"); diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index 98afd450d7..ec865ba936 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -677,7 +677,7 @@ std::unique_ptr CPDF_DataAvail::ParseIndirectObjectAt( } std::unique_ptr pObj = - m_syntaxParser.GetObject(pObjList, parser_objnum, gennum, false); + m_syntaxParser.GetObjectBody(pObjList, parser_objnum, gennum, false); m_syntaxParser.SetPos(SavedPos); return pObj; } @@ -923,7 +923,7 @@ bool CPDF_DataAvail::CheckTrailer() { const CPDF_ReadValidator::Session read_session(GetValidator().Get()); m_syntaxParser.SetPos(m_dwTrailerOffset); const std::unique_ptr pTrailer = - m_syntaxParser.GetObject(nullptr, 0, 0, false); + m_syntaxParser.GetObjectBody(nullptr, 0, 0, false); if (!pTrailer) { if (!GetValidator()->has_read_problems()) m_docStatus = PDF_DATAAVAIL_ERROR; diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index a45ac13ad5..6fb0d5fa1d 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -876,7 +876,7 @@ bool CPDF_Parser::RebuildCrossRef() { m_pSyntax->SetPos(pos + i - m_pSyntax->m_HeaderOffset); std::unique_ptr pObj = - m_pSyntax->GetObject(m_pDocument.Get(), 0, 0, false); + m_pSyntax->GetObjectBody(m_pDocument.Get(), 0, 0, false); if (pObj) { if (pObj->IsDictionary() || pObj->AsStream()) { CPDF_Stream* pStream = pObj->AsStream(); @@ -1237,7 +1237,7 @@ std::unique_ptr CPDF_Parser::ParseIndirectObject( return nullptr; syntax.SetPos(offset + it->second); - return syntax.GetObject(pObjList, 0, 0, false); + return syntax.GetObjectBody(pObjList, 0, 0, false); } RetainPtr CPDF_Parser::GetObjectStream(uint32_t objnum) { @@ -1300,7 +1300,7 @@ std::unique_ptr CPDF_Parser::LoadTrailerV4() { if (m_pSyntax->GetKeyword() != "trailer") return nullptr; - return ToDictionary(m_pSyntax->GetObject(m_pDocument.Get(), 0, 0, false)); + return ToDictionary(m_pSyntax->GetObjectBody(m_pDocument.Get(), 0, 0, false)); } uint32_t CPDF_Parser::GetPermissions() const { @@ -1337,7 +1337,7 @@ bool CPDF_Parser::ParseLinearizedHeader() { } m_pLinearized = CPDF_LinearizedHeader::CreateForObject( - m_pSyntax->GetObject(nullptr, objnum, gennum, false)); + m_pSyntax->GetObjectBody(nullptr, objnum, gennum, false)); if (!m_pLinearized) return false; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index bf6d90ca9a..96a863e661 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -360,20 +360,20 @@ ByteString CPDF_SyntaxParser::GetKeyword() { return GetNextWord(nullptr); } -std::unique_ptr CPDF_SyntaxParser::GetObject( +std::unique_ptr CPDF_SyntaxParser::GetObjectBody( CPDF_IndirectObjectHolder* pObjList, uint32_t objnum, uint32_t gennum, bool bDecrypt) { const CPDF_ReadValidator::Session read_session(GetValidator().Get()); - auto result = - GetObjectInternal(pObjList, objnum, gennum, bDecrypt, ParseType::kLoose); + auto result = GetObjectBodyInternal(pObjList, objnum, gennum, bDecrypt, + ParseType::kLoose); if (GetValidator()->has_read_problems()) return nullptr; return result; } -std::unique_ptr CPDF_SyntaxParser::GetObjectInternal( +std::unique_ptr CPDF_SyntaxParser::GetObjectBodyInternal( CPDF_IndirectObjectHolder* pObjList, uint32_t objnum, uint32_t gennum, @@ -425,8 +425,8 @@ std::unique_ptr CPDF_SyntaxParser::GetObjectInternal( } if (word == "[") { auto pArray = pdfium::MakeUnique(); - while (std::unique_ptr pObj = - GetObject(pObjList, objnum, gennum, true)) { + while (std::unique_ptr pObj = GetObjectBodyInternal( + pObjList, objnum, gennum, true, ParseType::kLoose)) { pArray->Add(std::move(pObj)); } return (parse_type == ParseType::kLoose || m_WordBuffer[0] == ']') @@ -465,8 +465,8 @@ std::unique_ptr CPDF_SyntaxParser::GetObjectInternal( if (key.IsEmpty() && parse_type == ParseType::kLoose) continue; - std::unique_ptr pObj = - GetObject(pObjList, objnum, gennum, true); + std::unique_ptr pObj = GetObjectBodyInternal( + pObjList, objnum, gennum, true, ParseType::kLoose); if (!pObj) { if (parse_type == ParseType::kLoose) continue; @@ -487,7 +487,9 @@ std::unique_ptr CPDF_SyntaxParser::GetObjectInternal( dwSignValuePos) { AutoRestorer save_pos(&m_Pos); m_Pos = dwSignValuePos; - pDict->SetFor("Contents", GetObject(pObjList, objnum, gennum, false)); + pDict->SetFor("Contents", + GetObjectBodyInternal(pObjList, objnum, gennum, false, + ParseType::kLoose)); } FX_FILESIZE SavedPos = m_Pos; @@ -504,14 +506,14 @@ std::unique_ptr CPDF_SyntaxParser::GetObjectInternal( return nullptr; } -std::unique_ptr CPDF_SyntaxParser::GetObjectForStrict( +std::unique_ptr CPDF_SyntaxParser::GetObjectBodyForStrict( CPDF_IndirectObjectHolder* pObjList, uint32_t objnum, uint32_t gennum, bool bDecrypt) { const CPDF_ReadValidator::Session read_session(GetValidator().Get()); - auto result = - GetObjectInternal(pObjList, objnum, gennum, bDecrypt, ParseType::kStrict); + auto result = GetObjectBodyInternal(pObjList, objnum, gennum, bDecrypt, + ParseType::kStrict); if (GetValidator()->has_read_problems()) return nullptr; return result; @@ -549,8 +551,8 @@ std::unique_ptr CPDF_SyntaxParser::GetIndirectObject( return nullptr; } - std::unique_ptr pObj = - GetObjectInternal(pObjList, objnum, parser_gennum, bDecrypt, parse_type); + std::unique_ptr pObj = GetObjectBodyInternal( + pObjList, objnum, parser_gennum, bDecrypt, parse_type); if (pObj) { if (!objnum) pObj->m_ObjNum = parser_objnum; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h index 2b642b5963..3a8f7c59ec 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/parser/cpdf_syntax_parser.h @@ -38,12 +38,13 @@ class CPDF_SyntaxParser { FX_FILESIZE GetPos() const { return m_Pos; } void SetPos(FX_FILESIZE pos) { m_Pos = std::min(pos, m_FileLen); } - std::unique_ptr GetObject(CPDF_IndirectObjectHolder* pObjList, - uint32_t objnum, - uint32_t gennum, - bool bDecrypt); + std::unique_ptr GetObjectBody( + CPDF_IndirectObjectHolder* pObjList, + uint32_t objnum, + uint32_t gennum, + bool bDecrypt); - std::unique_ptr GetObjectForStrict( + std::unique_ptr GetObjectBodyForStrict( CPDF_IndirectObjectHolder* pObjList, uint32_t objnum, uint32_t gennum, @@ -103,7 +104,7 @@ class CPDF_SyntaxParser { static_cast(m_BufOffset + m_BufSize) <= pos; } - std::unique_ptr GetObjectInternal( + std::unique_ptr GetObjectBodyInternal( CPDF_IndirectObjectHolder* pObjList, uint32_t objnum, uint32_t gennum, diff --git a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp index 6b54c70db6..af559c5ba6 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp @@ -152,7 +152,7 @@ TEST(cpdf_syntax_parser, GetInvalidReference) { uint8_t data[] = "4294967295 0 R"; parser.InitParser(pdfium::MakeRetain(data, 14, false), 0); std::unique_ptr ref = - parser.GetObject(nullptr, CPDF_Object::kInvalidObjNum, 0, false); + parser.GetObjectBody(nullptr, CPDF_Object::kInvalidObjNum, 0, false); EXPECT_FALSE(ref); } -- cgit v1.2.3