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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) { | 155 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) { |
156 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); | 156 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); |
157 return pDoc ? pDoc->GetParser()->GetFirstPageNo() : 0; | 157 return pDoc ? pDoc->GetParser()->GetFirstPageNo() : 0; |
158 } | 158 } |
159 | 159 |
160 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, | 160 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, |
161 int page_index, | 161 int page_index, |
162 FX_DOWNLOADHINTS* hints) { | 162 FX_DOWNLOADHINTS* hints) { |
163 if (!avail || !hints) | 163 if (!avail || !hints) |
164 return PDF_DATA_ERROR; | 164 return PDF_DATA_ERROR; |
| 165 if (page_index < 0) |
| 166 return PDF_DATA_NOTAVAIL; |
165 CFPDF_DownloadHintsWrap hints_wrap(hints); | 167 CFPDF_DownloadHintsWrap hints_wrap(hints); |
166 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsPageAvail( | 168 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsPageAvail( |
167 page_index, &hints_wrap); | 169 page_index, &hints_wrap); |
168 } | 170 } |
169 | 171 |
170 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, | 172 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, |
171 FX_DOWNLOADHINTS* hints) { | 173 FX_DOWNLOADHINTS* hints) { |
172 if (!avail || !hints) | 174 if (!avail || !hints) |
173 return PDF_FORM_ERROR; | 175 return PDF_FORM_ERROR; |
174 CFPDF_DownloadHintsWrap hints_wrap(hints); | 176 CFPDF_DownloadHintsWrap hints_wrap(hints); |
175 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail( | 177 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail( |
176 &hints_wrap); | 178 &hints_wrap); |
177 } | 179 } |
178 | 180 |
179 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { | 181 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { |
180 if (!avail) | 182 if (!avail) |
181 return PDF_LINEARIZATION_UNKNOWN; | 183 return PDF_LINEARIZATION_UNKNOWN; |
182 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF(); | 184 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF(); |
183 } | 185 } |
OLD | NEW |