OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |