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 <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "core/fpdfapi/fpdf_parser/cpdf_data_avail.h" | 12 #include "core/fpdfapi/fpdf_parser/cpdf_data_avail.h" |
13 #include "core/fpdfapi/fpdf_parser/cpdf_document.h" | 13 #include "core/fpdfapi/fpdf_parser/cpdf_document.h" |
14 #include "fpdfsdk/fsdk_define.h" | 14 #include "fpdfsdk/fsdk_define.h" |
15 #include "public/fpdf_formfill.h" | 15 #include "public/fpdf_formfill.h" |
| 16 #include "third_party/base/ptr_util.h" |
16 | 17 |
17 // These checks are here because core/ and public/ cannot depend on each other. | 18 // These checks are here because core/ and public/ cannot depend on each other. |
18 static_assert(CPDF_DataAvail::DataError == PDF_DATA_ERROR, | 19 static_assert(CPDF_DataAvail::DataError == PDF_DATA_ERROR, |
19 "CPDF_DataAvail::DataError value mismatch"); | 20 "CPDF_DataAvail::DataError value mismatch"); |
20 static_assert(CPDF_DataAvail::DataNotAvailable == PDF_DATA_NOTAVAIL, | 21 static_assert(CPDF_DataAvail::DataNotAvailable == PDF_DATA_NOTAVAIL, |
21 "CPDF_DataAvail::DataNotAvailable value mismatch"); | 22 "CPDF_DataAvail::DataNotAvailable value mismatch"); |
22 static_assert(CPDF_DataAvail::DataAvailable == PDF_DATA_AVAIL, | 23 static_assert(CPDF_DataAvail::DataAvailable == PDF_DATA_AVAIL, |
23 "CPDF_DataAvail::DataAvailable value mismatch"); | 24 "CPDF_DataAvail::DataAvailable value mismatch"); |
24 | 25 |
25 static_assert(CPDF_DataAvail::LinearizationUnknown == PDF_LINEARIZATION_UNKNOWN, | 26 static_assert(CPDF_DataAvail::LinearizationUnknown == PDF_LINEARIZATION_UNKNOWN, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return static_cast<CFPDF_DataAvail*>(avail); | 109 return static_cast<CFPDF_DataAvail*>(avail); |
109 } | 110 } |
110 | 111 |
111 } // namespace | 112 } // namespace |
112 | 113 |
113 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, | 114 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, |
114 FPDF_FILEACCESS* file) { | 115 FPDF_FILEACCESS* file) { |
115 CFPDF_DataAvail* pAvail = new CFPDF_DataAvail; | 116 CFPDF_DataAvail* pAvail = new CFPDF_DataAvail; |
116 pAvail->m_FileAvail.Set(file_avail); | 117 pAvail->m_FileAvail.Set(file_avail); |
117 pAvail->m_FileRead.Set(file); | 118 pAvail->m_FileRead.Set(file); |
118 pAvail->m_pDataAvail = WrapUnique( | 119 pAvail->m_pDataAvail = pdfium::MakeUnique<CPDF_DataAvail>( |
119 new CPDF_DataAvail(&pAvail->m_FileAvail, &pAvail->m_FileRead, TRUE)); | 120 &pAvail->m_FileAvail, &pAvail->m_FileRead, TRUE); |
120 return pAvail; | 121 return pAvail; |
121 } | 122 } |
122 | 123 |
123 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) { | 124 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) { |
124 delete (CFPDF_DataAvail*)avail; | 125 delete (CFPDF_DataAvail*)avail; |
125 } | 126 } |
126 | 127 |
127 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, | 128 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, |
128 FX_DOWNLOADHINTS* hints) { | 129 FX_DOWNLOADHINTS* hints) { |
129 if (!avail || !hints) | 130 if (!avail || !hints) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 CFPDF_DownloadHintsWrap hints_wrap(hints); | 180 CFPDF_DownloadHintsWrap hints_wrap(hints); |
180 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail( | 181 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail( |
181 &hints_wrap); | 182 &hints_wrap); |
182 } | 183 } |
183 | 184 |
184 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { | 185 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { |
185 if (!avail) | 186 if (!avail) |
186 return PDF_LINEARIZATION_UNKNOWN; | 187 return PDF_LINEARIZATION_UNKNOWN; |
187 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF(); | 188 return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF(); |
188 } | 189 } |
OLD | NEW |