diff options
author | tsepez <tsepez@chromium.org> | 2016-08-16 11:12:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-16 11:12:21 -0700 |
commit | 4540fbaa718b0b06e076321e0e1a61e80a161499 (patch) | |
tree | 0264321d30996058a3b120cff7707e93562bb425 /core/fpdfapi/fpdf_parser | |
parent | 3421d2bd1f12dc51916df1869ec8beab8711faec (diff) | |
download | pdfium-4540fbaa718b0b06e076321e0e1a61e80a161499.tar.xz |
Get CPDF_Parser out of the document creation business.
Precursor to someday using possibly subclassed documents.
Review-Url: https://codereview.chromium.org/2248123002
Diffstat (limited to 'core/fpdfapi/fpdf_parser')
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_parser.cpp | 14 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/include/cpdf_parser.h | 10 |
2 files changed, 15 insertions, 9 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp index e2c88d7e71..7bcbf392d6 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -158,7 +158,9 @@ void CPDF_Parser::CloseParser() { } } -CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess) { +CPDF_Parser::Error CPDF_Parser::StartParse( + IFX_FileRead* pFileAccess, + std::unique_ptr<CPDF_Document> pDocument) { CloseParser(); m_bXRefStream = FALSE; @@ -188,7 +190,7 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess) { return FORMAT_ERROR; m_pSyntax->RestorePos(m_pSyntax->m_FileLen - m_pSyntax->m_HeaderOffset - 9); - m_pDocument.reset(new CPDF_Document(this)); + m_pDocument = std::move(pDocument); FX_BOOL bXRefRebuilt = FALSE; if (m_pSyntax->SearchWord("startxref", TRUE, FALSE, 4096)) { @@ -1543,7 +1545,9 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, return FALSE; } -CPDF_Parser::Error CPDF_Parser::StartAsyncParse(IFX_FileRead* pFileAccess) { +CPDF_Parser::Error CPDF_Parser::StartAsyncParse( + IFX_FileRead* pFileAccess, + std::unique_ptr<CPDF_Document> pDocument) { CloseParser(); m_bXRefStream = FALSE; m_LastXRefOffset = 0; @@ -1555,10 +1559,10 @@ CPDF_Parser::Error CPDF_Parser::StartAsyncParse(IFX_FileRead* pFileAccess) { if (!IsLinearizedFile(pFileAccess, offset)) { m_pSyntax->m_pFileAccess = nullptr; - return StartParse(pFileAccess); + return StartParse(pFileAccess, std::move(pDocument)); } - m_pDocument.reset(new CPDF_Document(this)); + m_pDocument = std::move(pDocument); FX_FILESIZE dwFirstXRefOffset = m_pSyntax->SavePos(); FX_BOOL bXRefRebuilt = FALSE; diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_parser.h b/core/fpdfapi/fpdf_parser/include/cpdf_parser.h index 1291180197..3ad3b867df 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_parser.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_parser.h @@ -37,8 +37,11 @@ class CPDF_Parser { CPDF_Parser(); ~CPDF_Parser(); - Error StartParse(IFX_FileRead* pFile); - uint32_t GetPermissions() const; + Error StartParse(IFX_FileRead* pFile, + std::unique_ptr<CPDF_Document> pDocument); + + Error StartAsyncParse(IFX_FileRead* pFile, + std::unique_ptr<CPDF_Document> pDocument); void SetPassword(const FX_CHAR* password) { m_Password = password; } CFX_ByteString GetPassword() { return m_Password; } @@ -46,6 +49,7 @@ class CPDF_Parser { FX_FILESIZE GetLastXRefOffset() const { return m_LastXRefOffset; } CPDF_Document* GetDocument() const { return m_pDocument.get(); } + uint32_t GetPermissions() const; uint32_t GetRootObjNum(); uint32_t GetInfoObjNum(); CPDF_Array* GetIDArray(); @@ -83,8 +87,6 @@ class CPDF_Parser { uint32_t objnum, FX_FILESIZE* pResultPos); - Error StartAsyncParse(IFX_FileRead* pFile); - uint32_t GetFirstPageNo() const { return m_dwFirstPageNo; } protected: |