diff options
Diffstat (limited to 'core')
-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: |