From d7999f6a794207842544214d015af6f06322157c Mon Sep 17 00:00:00 2001 From: Artem Strygin Date: Thu, 2 Nov 2017 21:31:30 +0000 Subject: Move parsing logic from FPDF_DataAvail into CPDF_DataAvail. Change-Id: Iacae9723e88eeae52154276b2478e4fd8c309c2d Reviewed-on: https://pdfium-review.googlesource.com/15512 Commit-Queue: Art Snake Reviewed-by: dsinclair --- fpdfsdk/fpdf_dataavail.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp index 0a74c9c245..b1a134d914 100644 --- a/fpdfsdk/fpdf_dataavail.cpp +++ b/fpdfsdk/fpdf_dataavail.cpp @@ -147,20 +147,15 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { auto* pDataAvail = FPDFAvailContextFromFPDFAvail(avail); if (!pDataAvail) return nullptr; - - auto pParser = pdfium::MakeUnique(); - pParser->SetPassword(password); - - auto pDocument = pdfium::MakeUnique(std::move(pParser)); - CPDF_Parser::Error error = pDocument->GetParser()->StartLinearizedParse( - pDataAvail->m_pDataAvail->GetFileRead(), pDocument.get()); + CPDF_Parser::Error error; + std::unique_ptr document; + std::tie(error, document) = pDataAvail->m_pDataAvail->ParseDocument(password); if (error != CPDF_Parser::SUCCESS) { ProcessParseError(error); return nullptr; } - pDataAvail->m_pDataAvail->SetDocument(pDocument.get()); - CheckUnSupportError(pDocument.get(), FPDF_ERR_SUCCESS); - return FPDFDocumentFromCPDFDocument(pDocument.release()); + CheckUnSupportError(document.get(), FPDF_ERR_SUCCESS); + return FPDFDocumentFromCPDFDocument(document.release()); } FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) { -- cgit v1.2.3