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 <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 m_bMemoryBased = true; | 55 m_bMemoryBased = true; |
56 m_pFile = nullptr; | 56 m_pFile = nullptr; |
57 m_pDataBuf.reset(FX_Alloc(uint8_t, size)); | 57 m_pDataBuf.reset(FX_Alloc(uint8_t, size)); |
58 if (pData) | 58 if (pData) |
59 FXSYS_memcpy(m_pDataBuf.get(), pData, size); | 59 FXSYS_memcpy(m_pDataBuf.get(), pData, size); |
60 m_dwSize = size; | 60 m_dwSize = size; |
61 if (m_pDict) | 61 if (m_pDict) |
62 m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(m_dwSize)); | 62 m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(m_dwSize)); |
63 } | 63 } |
64 | 64 |
65 void CPDF_Stream::InitStreamFromFile(IFX_SeekableReadStream* pFile, | 65 void CPDF_Stream::InitStreamFromFile( |
66 std::unique_ptr<CPDF_Dictionary> pDict) { | 66 const CFX_RetainPtr<IFX_SeekableReadStream>& pFile, |
| 67 std::unique_ptr<CPDF_Dictionary> pDict) { |
67 m_pDict = std::move(pDict); | 68 m_pDict = std::move(pDict); |
68 m_bMemoryBased = false; | 69 m_bMemoryBased = false; |
69 m_pDataBuf.reset(); | 70 m_pDataBuf.reset(); |
70 m_pFile = pFile; | 71 m_pFile = pFile; |
71 m_dwSize = pdfium::base::checked_cast<uint32_t>(pFile->GetSize()); | 72 m_dwSize = pdfium::base::checked_cast<uint32_t>(pFile->GetSize()); |
72 if (m_pDict) | 73 if (m_pDict) |
73 m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(m_dwSize)); | 74 m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(m_dwSize)); |
74 } | 75 } |
75 | 76 |
76 std::unique_ptr<CPDF_Object> CPDF_Stream::Clone() const { | 77 std::unique_ptr<CPDF_Object> CPDF_Stream::Clone() const { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 123 |
123 bool CPDF_Stream::HasFilter() const { | 124 bool CPDF_Stream::HasFilter() const { |
124 return m_pDict && m_pDict->KeyExist("Filter"); | 125 return m_pDict && m_pDict->KeyExist("Filter"); |
125 } | 126 } |
126 | 127 |
127 CFX_WideString CPDF_Stream::GetUnicodeText() const { | 128 CFX_WideString CPDF_Stream::GetUnicodeText() const { |
128 CPDF_StreamAcc stream; | 129 CPDF_StreamAcc stream; |
129 stream.LoadAllData(this, false); | 130 stream.LoadAllData(this, false); |
130 return PDF_DecodeText(stream.GetData(), stream.GetSize()); | 131 return PDF_DecodeText(stream.GetData(), stream.GetSize()); |
131 } | 132 } |
OLD | NEW |