| 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 "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
| 8 #include "../include/fpdf_dataavail.h" | 8 #include "../include/fpdf_dataavail.h" |
| 9 | 9 |
| 10 extern void ProcessParseError(FX_DWORD err_code); | 10 extern void ProcessParseError(FX_DWORD err_code); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (m_pDataAvail) delete m_pDataAvail; | 90 if (m_pDataAvail) delete m_pDataAvail; |
| 91 } | 91 } |
| 92 | 92 |
| 93 IPDF_DataAvail* m_pDataAvail; | 93 IPDF_DataAvail* m_pDataAvail; |
| 94 CFPDF_FileAvailWrap m_FileAvail; | 94 CFPDF_FileAvailWrap m_FileAvail; |
| 95 CFPDF_FileAccessWrap m_FileRead; | 95 CFPDF_FileAccessWrap m_FileRead; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FIL
EACCESS* file) | 98 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FIL
EACCESS* file) |
| 99 { | 99 { |
| 100 » CFPDF_DataAvail* pAvail = FX_NEW CFPDF_DataAvail; | 100 » CFPDF_DataAvail* pAvail = new CFPDF_DataAvail; |
| 101 pAvail->m_FileAvail.Set(file_avail); | 101 pAvail->m_FileAvail.Set(file_avail); |
| 102 pAvail->m_FileRead.Set(file); | 102 pAvail->m_FileRead.Set(file); |
| 103 pAvail->m_pDataAvail = IPDF_DataAvail::Create(&pAvail->m_FileAvail, &pAv
ail->m_FileRead); | 103 pAvail->m_pDataAvail = IPDF_DataAvail::Create(&pAvail->m_FileAvail, &pAv
ail->m_FileRead); |
| 104 return pAvail; | 104 return pAvail; |
| 105 } | 105 } |
| 106 | 106 |
| 107 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) | 107 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) |
| 108 { | 108 { |
| 109 if (avail == NULL) return; | 109 if (avail == NULL) return; |
| 110 delete (CFPDF_DataAvail*)avail; | 110 delete (CFPDF_DataAvail*)avail; |
| 111 } | 111 } |
| 112 | 112 |
| 113 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* h
ints) | 113 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* h
ints) |
| 114 { | 114 { |
| 115 if (avail == NULL || hints == NULL) return 0; | 115 if (avail == NULL || hints == NULL) return 0; |
| 116 CFPDF_DownloadHintsWrap hints_wrap(hints); | 116 CFPDF_DownloadHintsWrap hints_wrap(hints); |
| 117 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap); | 117 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap); |
| 118 } | 118 } |
| 119 | 119 |
| 120 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); | 120 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); |
| 121 | 121 |
| 122 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYT
ESTRING password) | 122 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYT
ESTRING password) |
| 123 { | 123 { |
| 124 if (avail == NULL) return NULL; | 124 if (avail == NULL) return NULL; |
| 125 » CPDF_Parser* pParser = FX_NEW CPDF_Parser; | 125 » CPDF_Parser* pParser = new CPDF_Parser; |
| 126 pParser->SetPassword(password); | 126 pParser->SetPassword(password); |
| 127 | 127 |
| 128 FX_DWORD err_code = pParser->StartAsynParse(((CFPDF_DataAvail*)avail)->m
_pDataAvail->GetFileRead()); | 128 FX_DWORD err_code = pParser->StartAsynParse(((CFPDF_DataAvail*)avail)->m
_pDataAvail->GetFileRead()); |
| 129 if (err_code) { | 129 if (err_code) { |
| 130 delete pParser; | 130 delete pParser; |
| 131 ProcessParseError(err_code); | 131 ProcessParseError(err_code); |
| 132 return NULL; | 132 return NULL; |
| 133 } | 133 } |
| 134 ((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocumen
t()); | 134 ((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocumen
t()); |
| 135 CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS); | 135 CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 156 CFPDF_DownloadHintsWrap hints_wrap(hints); | 156 CFPDF_DownloadHintsWrap hints_wrap(hints); |
| 157 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap)
; | 157 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap)
; |
| 158 } | 158 } |
| 159 | 159 |
| 160 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) | 160 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) |
| 161 { | 161 { |
| 162 if (avail == NULL) return -1; | 162 if (avail == NULL) return -1; |
| 163 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF(); | 163 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF(); |
| 164 | 164 |
| 165 } | 165 } |
| OLD | NEW |