From 33dd830890d38f9083b732cd908ef082f1d89d65 Mon Sep 17 00:00:00 2001 From: Artem Strygin Date: Fri, 28 Jul 2017 19:05:55 +0300 Subject: Add public access for read stream into CPDF_SyntaxParser Change-Id: I5deb6049db41387ac030a6ba5296ee6187120190 Reviewed-on: https://pdfium-review.googlesource.com/9470 Commit-Queue: Lei Zhang Reviewed-by: Lei Zhang --- core/fpdfapi/parser/cpdf_parser.cpp | 5 ++--- core/fpdfapi/parser/cpdf_syntax_parser.cpp | 4 ++++ core/fpdfapi/parser/cpdf_syntax_parser.h | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 657d0e0865..2ca820eb98 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -126,7 +126,7 @@ CFX_RetainPtr CPDF_Parser::GetCryptoHandler() const { } CFX_RetainPtr CPDF_Parser::GetFileAccess() const { - return m_pSyntax->m_pFileAccess; + return m_pSyntax->GetFileAccess(); } void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) { @@ -615,7 +615,7 @@ bool CPDF_Parser::RebuildCrossRef() { bool bOverFlow = false; uint32_t size = std::min((uint32_t)(m_pSyntax->m_FileLen - pos), kBufferSize); - if (!m_pSyntax->m_pFileAccess->ReadBlock(buffer.data(), pos, size)) + if (!m_pSyntax->GetFileAccess()->ReadBlock(buffer.data(), pos, size)) break; for (uint32_t i = 0; i < size; i++) { @@ -1506,7 +1506,6 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse( return FORMAT_ERROR; if (!IsLinearizedFile(pFileAccess, offset)) { - m_pSyntax->m_pFileAccess = nullptr; return StartParse(pFileAccess, std::move(pDocument)); } m_bHasParsed = true; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index ce5a83579d..5fa3372d50 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -879,3 +879,7 @@ void CPDF_SyntaxParser::SetEncrypt( const CFX_RetainPtr& pCryptoHandler) { m_pCryptoHandler = pCryptoHandler; } + +CFX_RetainPtr CPDF_SyntaxParser::GetFileAccess() const { + return m_pFileAccess; +} diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h index 4c5e252978..d522b4ae7a 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/parser/cpdf_syntax_parser.h @@ -53,6 +53,8 @@ class CPDF_SyntaxParser { bool GetCharAt(FX_FILESIZE pos, uint8_t& ch); CFX_ByteString GetNextWord(bool* bIsNumber); + CFX_RetainPtr GetFileAccess() const; + private: friend class CPDF_Parser; friend class CPDF_DataAvail; -- cgit v1.2.3