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_document.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
10 #include "core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h" | 10 #include "core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 "IPDF_DataAvail::FormError value mismatch"); | 30 "IPDF_DataAvail::FormError value mismatch"); |
31 static_assert(IPDF_DataAvail::FormNotAvailable == PDF_FORM_NOTAVAIL, | 31 static_assert(IPDF_DataAvail::FormNotAvailable == PDF_FORM_NOTAVAIL, |
32 "IPDF_DataAvail::FormNotAvailable value mismatch"); | 32 "IPDF_DataAvail::FormNotAvailable value mismatch"); |
33 static_assert(IPDF_DataAvail::FormAvailable == PDF_FORM_AVAIL, | 33 static_assert(IPDF_DataAvail::FormAvailable == PDF_FORM_AVAIL, |
34 "IPDF_DataAvail::FormAvailable value mismatch"); | 34 "IPDF_DataAvail::FormAvailable value mismatch"); |
35 static_assert(IPDF_DataAvail::FormNotExist == PDF_FORM_NOTEXIST, | 35 static_assert(IPDF_DataAvail::FormNotExist == PDF_FORM_NOTEXIST, |
36 "IPDF_DataAvail::FormNotExist value mismatch"); | 36 "IPDF_DataAvail::FormNotExist value mismatch"); |
37 | 37 |
38 class CFPDF_FileAvailWrap : public IPDF_DataAvail::FileAvail { | 38 class CFPDF_FileAvailWrap : public IPDF_DataAvail::FileAvail { |
39 public: | 39 public: |
40 CFPDF_FileAvailWrap() { m_pfileAvail = NULL; } | 40 CFPDF_FileAvailWrap() { m_pfileAvail = nullptr; } |
41 ~CFPDF_FileAvailWrap() override {} | 41 ~CFPDF_FileAvailWrap() override {} |
42 | 42 |
43 void Set(FX_FILEAVAIL* pfileAvail) { m_pfileAvail = pfileAvail; } | 43 void Set(FX_FILEAVAIL* pfileAvail) { m_pfileAvail = pfileAvail; } |
44 | 44 |
45 // IPDF_DataAvail::FileAvail: | 45 // IPDF_DataAvail::FileAvail: |
46 FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size) override { | 46 FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size) override { |
47 return m_pfileAvail->IsDataAvail(m_pfileAvail, offset, size); | 47 return m_pfileAvail->IsDataAvail(m_pfileAvail, offset, size); |
48 } | 48 } |
49 | 49 |
50 private: | 50 private: |
51 FX_FILEAVAIL* m_pfileAvail; | 51 FX_FILEAVAIL* m_pfileAvail; |
52 }; | 52 }; |
53 | 53 |
54 class CFPDF_FileAccessWrap : public IFX_FileRead { | 54 class CFPDF_FileAccessWrap : public IFX_FileRead { |
55 public: | 55 public: |
56 CFPDF_FileAccessWrap() { m_pFileAccess = NULL; } | 56 CFPDF_FileAccessWrap() { m_pFileAccess = nullptr; } |
57 ~CFPDF_FileAccessWrap() override {} | 57 ~CFPDF_FileAccessWrap() override {} |
58 | 58 |
59 void Set(FPDF_FILEACCESS* pFile) { m_pFileAccess = pFile; } | 59 void Set(FPDF_FILEACCESS* pFile) { m_pFileAccess = pFile; } |
60 | 60 |
61 // IFX_FileRead | 61 // IFX_FileRead |
62 FX_FILESIZE GetSize() override { return m_pFileAccess->m_FileLen; } | 62 FX_FILESIZE GetSize() override { return m_pFileAccess->m_FileLen; } |
63 | 63 |
64 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { | 64 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { |
65 return m_pFileAccess->m_GetBlock(m_pFileAccess->m_Param, offset, | 65 return m_pFileAccess->m_GetBlock(m_pFileAccess->m_Param, offset, |
66 (uint8_t*)buffer, size); | 66 (uint8_t*)buffer, size); |
(...skipping 17 matching lines...) Expand all Loading... |
84 void AddSegment(FX_FILESIZE offset, uint32_t size) override { | 84 void AddSegment(FX_FILESIZE offset, uint32_t size) override { |
85 m_pDownloadHints->AddSegment(m_pDownloadHints, offset, size); | 85 m_pDownloadHints->AddSegment(m_pDownloadHints, offset, size); |
86 } | 86 } |
87 | 87 |
88 private: | 88 private: |
89 FX_DOWNLOADHINTS* m_pDownloadHints; | 89 FX_DOWNLOADHINTS* m_pDownloadHints; |
90 }; | 90 }; |
91 | 91 |
92 class CFPDF_DataAvail { | 92 class CFPDF_DataAvail { |
93 public: | 93 public: |
94 CFPDF_DataAvail() { m_pDataAvail = NULL; } | 94 CFPDF_DataAvail() { m_pDataAvail = nullptr; } |
95 | 95 |
96 ~CFPDF_DataAvail() { delete m_pDataAvail; } | 96 ~CFPDF_DataAvail() { delete m_pDataAvail; } |
97 | 97 |
98 IPDF_DataAvail* m_pDataAvail; | 98 IPDF_DataAvail* m_pDataAvail; |
99 CFPDF_FileAvailWrap m_FileAvail; | 99 CFPDF_FileAvailWrap m_FileAvail; |
100 CFPDF_FileAccessWrap m_FileRead; | 100 CFPDF_FileAccessWrap m_FileRead; |
101 }; | 101 }; |
102 | 102 |
103 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, | 103 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, |
104 FPDF_FILEACCESS* file) { | 104 FPDF_FILEACCESS* file) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return PDF_FORM_ERROR; | 163 return PDF_FORM_ERROR; |
164 CFPDF_DownloadHintsWrap hints_wrap(hints); | 164 CFPDF_DownloadHintsWrap hints_wrap(hints); |
165 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap); | 165 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap); |
166 } | 166 } |
167 | 167 |
168 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { | 168 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { |
169 if (!avail) | 169 if (!avail) |
170 return PDF_LINEARIZATION_UNKNOWN; | 170 return PDF_LINEARIZATION_UNKNOWN; |
171 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF(); | 171 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF(); |
172 } | 172 } |
OLD | NEW |