OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfapi/parser/cpdf_stream.h" | 7 #include "core/fpdfapi/parser/cpdf_stream.h" |
8 | 8 |
9 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 9 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
10 #include "core/fpdfapi/parser/cpdf_stream_acc.h" | 10 #include "core/fpdfapi/parser/cpdf_stream_acc.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 m_bMemoryBased = true; | 50 m_bMemoryBased = true; |
51 m_pFile = nullptr; | 51 m_pFile = nullptr; |
52 m_pDataBuf.reset(FX_Alloc(uint8_t, size)); | 52 m_pDataBuf.reset(FX_Alloc(uint8_t, size)); |
53 if (pData) | 53 if (pData) |
54 FXSYS_memcpy(m_pDataBuf.get(), pData, size); | 54 FXSYS_memcpy(m_pDataBuf.get(), pData, size); |
55 m_dwSize = size; | 55 m_dwSize = size; |
56 if (m_pDict) | 56 if (m_pDict) |
57 m_pDict->SetIntegerFor("Length", m_dwSize); | 57 m_pDict->SetIntegerFor("Length", m_dwSize); |
58 } | 58 } |
59 | 59 |
60 void CPDF_Stream::InitStreamFromFile(IFX_FileRead* pFile, | 60 void CPDF_Stream::InitStreamFromFile(IFX_SeekableReadStream* pFile, |
61 CPDF_Dictionary* pDict) { | 61 CPDF_Dictionary* pDict) { |
62 m_pDict.reset(pDict); | 62 m_pDict.reset(pDict); |
63 m_bMemoryBased = false; | 63 m_bMemoryBased = false; |
64 m_pDataBuf.reset(); | 64 m_pDataBuf.reset(); |
65 m_pFile = pFile; | 65 m_pFile = pFile; |
66 m_dwSize = pdfium::base::checked_cast<uint32_t>(pFile->GetSize()); | 66 m_dwSize = pdfium::base::checked_cast<uint32_t>(pFile->GetSize()); |
67 if (m_pDict) | 67 if (m_pDict) |
68 m_pDict->SetIntegerFor("Length", m_dwSize); | 68 m_pDict->SetIntegerFor("Length", m_dwSize); |
69 } | 69 } |
70 | 70 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 FXSYS_memcpy(buf, m_pDataBuf.get() + offset, size); | 111 FXSYS_memcpy(buf, m_pDataBuf.get() + offset, size); |
112 | 112 |
113 return TRUE; | 113 return TRUE; |
114 } | 114 } |
115 | 115 |
116 CFX_WideString CPDF_Stream::GetUnicodeText() const { | 116 CFX_WideString CPDF_Stream::GetUnicodeText() const { |
117 CPDF_StreamAcc stream; | 117 CPDF_StreamAcc stream; |
118 stream.LoadAllData(this, FALSE); | 118 stream.LoadAllData(this, FALSE); |
119 return PDF_DecodeText(stream.GetData(), stream.GetSize()); | 119 return PDF_DecodeText(stream.GetData(), stream.GetSize()); |
120 } | 120 } |
OLD | NEW |