| 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 "fpdfsdk/include/fsdk_define.h" | 9 #include "fpdfsdk/include/fsdk_define.h" |
| 10 #include "public/fpdf_formfill.h" | 10 #include "public/fpdf_formfill.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 DLLEXPORT int STDCALL | 115 DLLEXPORT int STDCALL |
| 116 FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints) { | 116 FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints) { |
| 117 if (!avail || !hints) | 117 if (!avail || !hints) |
| 118 return PDF_DATA_ERROR; | 118 return PDF_DATA_ERROR; |
| 119 CFPDF_DownloadHintsWrap hints_wrap(hints); | 119 CFPDF_DownloadHintsWrap hints_wrap(hints); |
| 120 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap); | 120 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap); |
| 121 } | 121 } |
| 122 | 122 |
| 123 DLLEXPORT FPDF_DOCUMENT STDCALL | 123 DLLEXPORT FPDF_DOCUMENT STDCALL |
| 124 FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { | 124 FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { |
| 125 if (!avail) | 125 CFPDF_DataAvail* pDataAvail = static_cast<CFPDF_DataAvail*>(avail); |
| 126 if (!pDataAvail) |
| 126 return NULL; | 127 return NULL; |
| 128 |
| 127 CPDF_Parser* pParser = new CPDF_Parser; | 129 CPDF_Parser* pParser = new CPDF_Parser; |
| 128 pParser->SetPassword(password); | 130 pParser->SetPassword(password); |
| 129 | 131 CPDF_Parser::Error error = |
| 130 FX_DWORD err_code = pParser->StartAsynParse( | 132 pParser->StartAsynParse(pDataAvail->m_pDataAvail->GetFileRead()); |
| 131 ((CFPDF_DataAvail*)avail)->m_pDataAvail->GetFileRead()); | 133 if (error != CPDF_Parser::SUCCESS) { |
| 132 if (err_code) { | |
| 133 delete pParser; | 134 delete pParser; |
| 134 ProcessParseError(err_code); | 135 ProcessParseError(error); |
| 135 return NULL; | 136 return NULL; |
| 136 } | 137 } |
| 137 ((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocument()); | 138 pDataAvail->m_pDataAvail->SetDocument(pParser->GetDocument()); |
| 138 CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS); | 139 CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS); |
| 139 return FPDFDocumentFromCPDFDocument(pParser->GetDocument()); | 140 return FPDFDocumentFromCPDFDocument(pParser->GetDocument()); |
| 140 } | 141 } |
| 141 | 142 |
| 142 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) { | 143 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) { |
| 143 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); | 144 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); |
| 144 return pDoc ? pDoc->GetParser()->GetFirstPageNo() : 0; | 145 return pDoc ? pDoc->GetParser()->GetFirstPageNo() : 0; |
| 145 } | 146 } |
| 146 | 147 |
| 147 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, | 148 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 160 return PDF_FORM_ERROR; | 161 return PDF_FORM_ERROR; |
| 161 CFPDF_DownloadHintsWrap hints_wrap(hints); | 162 CFPDF_DownloadHintsWrap hints_wrap(hints); |
| 162 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap); | 163 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap); |
| 163 } | 164 } |
| 164 | 165 |
| 165 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { | 166 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { |
| 166 if (!avail) | 167 if (!avail) |
| 167 return PDF_LINEARIZATION_UNKNOWN; | 168 return PDF_LINEARIZATION_UNKNOWN; |
| 168 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF(); | 169 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF(); |
| 169 } | 170 } |
| OLD | NEW |