| 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> | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 43 | 43 | 
| 44 class CFPDF_FileAvailWrap : public CPDF_DataAvail::FileAvail { | 44 class CFPDF_FileAvailWrap : public CPDF_DataAvail::FileAvail { | 
| 45  public: | 45  public: | 
| 46   CFPDF_FileAvailWrap() { m_pfileAvail = nullptr; } | 46   CFPDF_FileAvailWrap() { m_pfileAvail = nullptr; } | 
| 47   ~CFPDF_FileAvailWrap() override {} | 47   ~CFPDF_FileAvailWrap() override {} | 
| 48 | 48 | 
| 49   void Set(FX_FILEAVAIL* pfileAvail) { m_pfileAvail = pfileAvail; } | 49   void Set(FX_FILEAVAIL* pfileAvail) { m_pfileAvail = pfileAvail; } | 
| 50 | 50 | 
| 51   // CPDF_DataAvail::FileAvail: | 51   // CPDF_DataAvail::FileAvail: | 
| 52   FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size) override { | 52   FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size) override { | 
| 53     return m_pfileAvail->IsDataAvail(m_pfileAvail, offset, size); | 53     return !!m_pfileAvail->IsDataAvail(m_pfileAvail, offset, size); | 
| 54   } | 54   } | 
| 55 | 55 | 
| 56  private: | 56  private: | 
| 57   FX_FILEAVAIL* m_pfileAvail; | 57   FX_FILEAVAIL* m_pfileAvail; | 
| 58 }; | 58 }; | 
| 59 | 59 | 
| 60 class CFPDF_FileAccessWrap : public IFX_SeekableReadStream { | 60 class CFPDF_FileAccessWrap : public IFX_SeekableReadStream { | 
| 61  public: | 61  public: | 
| 62   CFPDF_FileAccessWrap() { m_pFileAccess = nullptr; } | 62   CFPDF_FileAccessWrap() { m_pFileAccess = nullptr; } | 
| 63   ~CFPDF_FileAccessWrap() override {} | 63   ~CFPDF_FileAccessWrap() override {} | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 110 } | 110 } | 
| 111 | 111 | 
| 112 }  // namespace | 112 }  // namespace | 
| 113 | 113 | 
| 114 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, | 114 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, | 
| 115                                               FPDF_FILEACCESS* file) { | 115                                               FPDF_FILEACCESS* file) { | 
| 116   CFPDF_DataAvail* pAvail = new CFPDF_DataAvail; | 116   CFPDF_DataAvail* pAvail = new CFPDF_DataAvail; | 
| 117   pAvail->m_FileAvail.Set(file_avail); | 117   pAvail->m_FileAvail.Set(file_avail); | 
| 118   pAvail->m_FileRead.Set(file); | 118   pAvail->m_FileRead.Set(file); | 
| 119   pAvail->m_pDataAvail = pdfium::MakeUnique<CPDF_DataAvail>( | 119   pAvail->m_pDataAvail = pdfium::MakeUnique<CPDF_DataAvail>( | 
| 120       &pAvail->m_FileAvail, &pAvail->m_FileRead, TRUE); | 120       &pAvail->m_FileAvail, &pAvail->m_FileRead, true); | 
| 121   return pAvail; | 121   return pAvail; | 
| 122 } | 122 } | 
| 123 | 123 | 
| 124 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) { | 124 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) { | 
| 125   delete (CFPDF_DataAvail*)avail; | 125   delete (CFPDF_DataAvail*)avail; | 
| 126 } | 126 } | 
| 127 | 127 | 
| 128 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, | 128 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, | 
| 129                                            FX_DOWNLOADHINTS* hints) { | 129                                            FX_DOWNLOADHINTS* hints) { | 
| 130   if (!avail || !hints) | 130   if (!avail || !hints) | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 180   CFPDF_DownloadHintsWrap hints_wrap(hints); | 180   CFPDF_DownloadHintsWrap hints_wrap(hints); | 
| 181   return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail( | 181   return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsFormAvail( | 
| 182       &hints_wrap); | 182       &hints_wrap); | 
| 183 } | 183 } | 
| 184 | 184 | 
| 185 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { | 185 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { | 
| 186   if (!avail) | 186   if (!avail) | 
| 187     return PDF_LINEARIZATION_UNKNOWN; | 187     return PDF_LINEARIZATION_UNKNOWN; | 
| 188   return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF(); | 188   return CFPDFDataAvailFromFPDFAvail(avail)->m_pDataAvail->IsLinearizedPDF(); | 
| 189 } | 189 } | 
| OLD | NEW | 
|---|