Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: fpdfsdk/fpdf_dataavail.cpp

Issue 2275773003: Flip document and parser ownership (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@private_parser
Patch Set: Rebase to master Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_parser/include/cpdf_parser.h ('k') | fpdfsdk/fpdfdoc_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "public/fpdf_dataavail.h" 7 #include "public/fpdf_dataavail.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 DLLEXPORT FPDF_DOCUMENT STDCALL 133 DLLEXPORT FPDF_DOCUMENT STDCALL
134 FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { 134 FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
135 CFPDF_DataAvail* pDataAvail = static_cast<CFPDF_DataAvail*>(avail); 135 CFPDF_DataAvail* pDataAvail = static_cast<CFPDF_DataAvail*>(avail);
136 if (!pDataAvail) 136 if (!pDataAvail)
137 return nullptr; 137 return nullptr;
138 138
139 std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser); 139 std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser);
140 pParser->SetPassword(password); 140 pParser->SetPassword(password);
141 141
142 std::unique_ptr<CPDF_Document> pDocument(new CPDF_Document(pParser.get())); 142 std::unique_ptr<CPDF_Document> pDocument(
143 CPDF_Parser::Error error = pParser->StartLinearizedParse( 143 new CPDF_Document(std::move(pParser)));
144 pDataAvail->m_pDataAvail->GetFileRead(), std::move(pDocument)); 144 CPDF_Parser::Error error = pDocument->GetParser()->StartLinearizedParse(
145 pDataAvail->m_pDataAvail->GetFileRead(), pDocument.get());
145 if (error != CPDF_Parser::SUCCESS) { 146 if (error != CPDF_Parser::SUCCESS) {
146 ProcessParseError(error); 147 ProcessParseError(error);
147 return nullptr; 148 return nullptr;
148 } 149 }
149 pDataAvail->m_pDataAvail->SetDocument(pParser->GetDocument()); 150 pDataAvail->m_pDataAvail->SetDocument(pDocument.get());
150 CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS); 151 CheckUnSupportError(pDocument.get(), FPDF_ERR_SUCCESS);
151 return FPDFDocumentFromCPDFDocument(pParser.release()->GetDocument()); 152 return FPDFDocumentFromCPDFDocument(pDocument.release());
152 } 153 }
153 154
154 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) { 155 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) {
155 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); 156 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc);
156 return pDoc ? pDoc->GetParser()->GetFirstPageNo() : 0; 157 return pDoc ? pDoc->GetParser()->GetFirstPageNo() : 0;
157 } 158 }
158 159
159 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, 160 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail,
160 int page_index, 161 int page_index,
161 FX_DOWNLOADHINTS* hints) { 162 FX_DOWNLOADHINTS* hints) {
(...skipping 11 matching lines...) Expand all
173 CFPDF_DownloadHintsWrap hints_wrap(hints); 174 CFPDF_DownloadHintsWrap hints_wrap(hints);
174 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail( 175 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail(
175 &hints_wrap); 176 &hints_wrap);
176 } 177 }
177 178
178 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { 179 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) {
179 if (!avail) 180 if (!avail)
180 return PDF_LINEARIZATION_UNKNOWN; 181 return PDF_LINEARIZATION_UNKNOWN;
181 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF(); 182 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF();
182 } 183 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/include/cpdf_parser.h ('k') | fpdfsdk/fpdfdoc_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698