| 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 "xfa/fxfa/xfa_ffapp.h" | 7 #include "xfa/fxfa/xfa_ffapp.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class CXFA_FileRead : public IFX_SeekableReadStream { | 26 class CXFA_FileRead : public IFX_SeekableReadStream { |
| 27 public: | 27 public: |
| 28 explicit CXFA_FileRead(const std::vector<CPDF_Stream*>& streams); | 28 explicit CXFA_FileRead(const std::vector<CPDF_Stream*>& streams); |
| 29 ~CXFA_FileRead() override; | 29 ~CXFA_FileRead() override; |
| 30 | 30 |
| 31 // IFX_SeekableReadStream | 31 // IFX_SeekableReadStream |
| 32 FX_FILESIZE GetSize() override; | 32 FX_FILESIZE GetSize() override; |
| 33 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; | 33 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; |
| 34 void Release() override; | |
| 35 | 34 |
| 36 private: | 35 private: |
| 37 CFX_ObjectArray<CPDF_StreamAcc> m_Data; | 36 CFX_ObjectArray<CPDF_StreamAcc> m_Data; |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 CXFA_FileRead::CXFA_FileRead(const std::vector<CPDF_Stream*>& streams) { | 39 CXFA_FileRead::CXFA_FileRead(const std::vector<CPDF_Stream*>& streams) { |
| 41 for (CPDF_Stream* pStream : streams) { | 40 for (CPDF_Stream* pStream : streams) { |
| 42 CPDF_StreamAcc& acc = m_Data.Add(); | 41 CPDF_StreamAcc& acc = m_Data.Add(); |
| 43 acc.LoadAllData(pStream); | 42 acc.LoadAllData(pStream); |
| 44 } | 43 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (size == 0) { | 76 if (size == 0) { |
| 78 return true; | 77 return true; |
| 79 } | 78 } |
| 80 buffer = (uint8_t*)buffer + dwRead; | 79 buffer = (uint8_t*)buffer + dwRead; |
| 81 offset = 0; | 80 offset = 0; |
| 82 index++; | 81 index++; |
| 83 } | 82 } |
| 84 return false; | 83 return false; |
| 85 } | 84 } |
| 86 | 85 |
| 87 void CXFA_FileRead::Release() { | |
| 88 delete this; | |
| 89 } | |
| 90 | |
| 91 } // namespace | 86 } // namespace |
| 92 | 87 |
| 93 IFX_SeekableReadStream* MakeSeekableReadStream( | 88 CFX_RetainPtr<IFX_SeekableReadStream> MakeSeekableReadStream( |
| 94 const std::vector<CPDF_Stream*>& streams) { | 89 const std::vector<CPDF_Stream*>& streams) { |
| 95 return new CXFA_FileRead(streams); | 90 return CFX_RetainPtr<IFX_SeekableReadStream>(new CXFA_FileRead(streams)); |
| 96 } | 91 } |
| 97 | 92 |
| 98 CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) | 93 CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) |
| 99 : m_pProvider(pProvider), | 94 : m_pProvider(pProvider), |
| 100 m_pWidgetMgrDelegate(nullptr), | 95 m_pWidgetMgrDelegate(nullptr), |
| 101 m_pFWLApp(new CFWL_App(this)) {} | 96 m_pFWLApp(new CFWL_App(this)) {} |
| 102 | 97 |
| 103 CXFA_FFApp::~CXFA_FFApp() {} | 98 CXFA_FFApp::~CXFA_FFApp() {} |
| 104 | 99 |
| 105 CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { | 100 CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { |
| 106 if (!m_pDocHandler) | 101 if (!m_pDocHandler) |
| 107 m_pDocHandler.reset(new CXFA_FFDocHandler); | 102 m_pDocHandler.reset(new CXFA_FFDocHandler); |
| 108 return m_pDocHandler.get(); | 103 return m_pDocHandler.get(); |
| 109 } | 104 } |
| 110 | 105 |
| 111 CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment, | 106 CXFA_FFDoc* CXFA_FFApp::CreateDoc( |
| 112 IFX_SeekableReadStream* pStream, | 107 IXFA_DocEnvironment* pDocEnvironment, |
| 113 bool bTakeOverFile) { | 108 const CFX_RetainPtr<IFX_SeekableReadStream>& pStream) { |
| 114 std::unique_ptr<CXFA_FFDoc> pDoc(new CXFA_FFDoc(this, pDocEnvironment)); | 109 auto pDoc = pdfium::MakeUnique<CXFA_FFDoc>(this, pDocEnvironment); |
| 115 bool bSuccess = pDoc->OpenDoc(pStream, bTakeOverFile); | 110 return pDoc->OpenDoc(pStream) ? pDoc.release() : nullptr; |
| 116 return bSuccess ? pDoc.release() : nullptr; | |
| 117 } | 111 } |
| 118 | 112 |
| 119 CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment, | 113 CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment, |
| 120 CPDF_Document* pPDFDoc) { | 114 CPDF_Document* pPDFDoc) { |
| 121 if (!pPDFDoc) | 115 if (!pPDFDoc) |
| 122 return nullptr; | 116 return nullptr; |
| 123 | 117 |
| 124 std::unique_ptr<CXFA_FFDoc> pDoc(new CXFA_FFDoc(this, pDocEnvironment)); | 118 std::unique_ptr<CXFA_FFDoc> pDoc(new CXFA_FFDoc(this, pDocEnvironment)); |
| 125 bool bSuccess = pDoc->OpenDoc(pPDFDoc); | 119 bool bSuccess = pDoc->OpenDoc(pPDFDoc); |
| 126 return bSuccess ? pDoc.release() : nullptr; | 120 return bSuccess ? pDoc.release() : nullptr; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return m_pAdapterWidgetMgr.get(); | 158 return m_pAdapterWidgetMgr.get(); |
| 165 } | 159 } |
| 166 | 160 |
| 167 IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() const { | 161 IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() const { |
| 168 return m_pProvider->GetTimerMgr(); | 162 return m_pProvider->GetTimerMgr(); |
| 169 } | 163 } |
| 170 | 164 |
| 171 void CXFA_FFApp::ClearEventTargets() { | 165 void CXFA_FFApp::ClearEventTargets() { |
| 172 m_pFWLApp->GetNoteDriver()->ClearEventTargets(false); | 166 m_pFWLApp->GetNoteDriver()->ClearEventTargets(false); |
| 173 } | 167 } |
| OLD | NEW |