| 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/app/xfa_ffapp.h" | 7 #include "xfa/fxfa/app/xfa_ffapp.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" | 11 #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" |
| 12 #include "xfa/fxfa/app/xfa_ffdoc.h" | 12 #include "xfa/fxfa/app/xfa_ffdoc.h" |
| 13 #include "xfa/fxfa/app/xfa_ffdochandler.h" | 13 #include "xfa/fxfa/app/xfa_ffdochandler.h" |
| 14 #include "xfa/fxfa/app/xfa_ffwidgethandler.h" | 14 #include "xfa/fxfa/app/xfa_ffwidgethandler.h" |
| 15 #include "xfa/fxfa/app/xfa_fontmgr.h" | 15 #include "xfa/fxfa/app/xfa_fontmgr.h" |
| 16 #include "xfa/fxfa/app/xfa_fwladapter.h" | 16 #include "xfa/fxfa/app/xfa_fwladapter.h" |
| 17 #include "xfa/fxfa/app/xfa_fwltheme.h" | 17 #include "xfa/fxfa/app/xfa_fwltheme.h" |
| 18 | 18 |
| 19 CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) { | 19 CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) { |
| 20 int32_t iCount = streams.GetSize(); | 20 int32_t iCount = streams.GetSize(); |
| 21 for (int32_t i = 0; i < iCount; i++) { | 21 for (int32_t i = 0; i < iCount; i++) { |
| 22 CPDF_StreamAcc& acc = m_Data.Add(); | 22 CPDF_StreamAcc& acc = m_Data.Add(); |
| 23 acc.LoadAllData(streams[i]); | 23 acc.LoadAllData(streams[i]); |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 FX_FILESIZE CXFA_FileRead::GetSize() { | 26 FX_FILESIZE CXFA_FileRead::GetSize() { |
| 27 FX_DWORD dwSize = 0; | 27 uint32_t dwSize = 0; |
| 28 int32_t iCount = m_Data.GetSize(); | 28 int32_t iCount = m_Data.GetSize(); |
| 29 for (int32_t i = 0; i < iCount; i++) { | 29 for (int32_t i = 0; i < iCount; i++) { |
| 30 CPDF_StreamAcc& acc = m_Data[i]; | 30 CPDF_StreamAcc& acc = m_Data[i]; |
| 31 dwSize += acc.GetSize(); | 31 dwSize += acc.GetSize(); |
| 32 } | 32 } |
| 33 return dwSize; | 33 return dwSize; |
| 34 } | 34 } |
| 35 FX_BOOL CXFA_FileRead::ReadBlock(void* buffer, | 35 FX_BOOL CXFA_FileRead::ReadBlock(void* buffer, |
| 36 FX_FILESIZE offset, | 36 FX_FILESIZE offset, |
| 37 size_t size) { | 37 size_t size) { |
| 38 int32_t iCount = m_Data.GetSize(); | 38 int32_t iCount = m_Data.GetSize(); |
| 39 int32_t index = 0; | 39 int32_t index = 0; |
| 40 while (index < iCount) { | 40 while (index < iCount) { |
| 41 CPDF_StreamAcc& acc = m_Data[index]; | 41 CPDF_StreamAcc& acc = m_Data[index]; |
| 42 FX_FILESIZE dwSize = acc.GetSize(); | 42 FX_FILESIZE dwSize = acc.GetSize(); |
| 43 if (offset < dwSize) { | 43 if (offset < dwSize) { |
| 44 break; | 44 break; |
| 45 } | 45 } |
| 46 offset -= dwSize; | 46 offset -= dwSize; |
| 47 index++; | 47 index++; |
| 48 } | 48 } |
| 49 while (index < iCount) { | 49 while (index < iCount) { |
| 50 CPDF_StreamAcc& acc = m_Data[index]; | 50 CPDF_StreamAcc& acc = m_Data[index]; |
| 51 FX_DWORD dwSize = acc.GetSize(); | 51 uint32_t dwSize = acc.GetSize(); |
| 52 size_t dwRead = std::min(size, static_cast<size_t>(dwSize - offset)); | 52 size_t dwRead = std::min(size, static_cast<size_t>(dwSize - offset)); |
| 53 FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead); | 53 FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead); |
| 54 size -= dwRead; | 54 size -= dwRead; |
| 55 if (size == 0) { | 55 if (size == 0) { |
| 56 return TRUE; | 56 return TRUE; |
| 57 } | 57 } |
| 58 buffer = (uint8_t*)buffer + dwRead; | 58 buffer = (uint8_t*)buffer + dwRead; |
| 59 offset = 0; | 59 offset = 0; |
| 60 index++; | 60 index++; |
| 61 } | 61 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 181 } |
| 182 IFWL_AdapterThreadMgr* CXFA_FFApp::GetThreadMgr() { | 182 IFWL_AdapterThreadMgr* CXFA_FFApp::GetThreadMgr() { |
| 183 if (!m_pAdapterThreadMgr) { | 183 if (!m_pAdapterThreadMgr) { |
| 184 m_pAdapterThreadMgr = new CFWL_SDAdapterThreadMgr; | 184 m_pAdapterThreadMgr = new CFWL_SDAdapterThreadMgr; |
| 185 } | 185 } |
| 186 return m_pAdapterThreadMgr; | 186 return m_pAdapterThreadMgr; |
| 187 } | 187 } |
| 188 IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() { | 188 IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() { |
| 189 return m_pProvider->GetTimerMgr(); | 189 return m_pProvider->GetTimerMgr(); |
| 190 } | 190 } |
| OLD | NEW |