OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 |
| 7 #ifndef CORE_INCLUDE_FPDFAPI_CPDF_STREAM_H_ |
| 8 #define CORE_INCLUDE_FPDFAPI_CPDF_STREAM_H_ |
| 9 |
| 10 #include "core/include/fpdfapi/cpdf_object.h" |
| 11 #include "core/include/fxcrt/fx_stream.h" |
| 12 |
| 13 class CPDF_Stream : public CPDF_Object { |
| 14 public: |
| 15 CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict); |
| 16 |
| 17 // CPDF_Object. |
| 18 Type GetType() const override; |
| 19 CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const override; |
| 20 CPDF_Dictionary* GetDict() const override; |
| 21 CFX_WideString GetUnicodeText() const override; |
| 22 bool IsStream() const override; |
| 23 CPDF_Stream* AsStream() override; |
| 24 const CPDF_Stream* AsStream() const override; |
| 25 |
| 26 FX_DWORD GetRawSize() const { return m_dwSize; } |
| 27 uint8_t* GetRawData() const { return m_pDataBuf; } |
| 28 |
| 29 void SetData(const uint8_t* pData, |
| 30 FX_DWORD size, |
| 31 FX_BOOL bCompressed, |
| 32 FX_BOOL bKeepBuf); |
| 33 |
| 34 void InitStream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict); |
| 35 void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict); |
| 36 |
| 37 FX_BOOL ReadRawData(FX_FILESIZE start_pos, |
| 38 uint8_t* pBuf, |
| 39 FX_DWORD buf_size) const; |
| 40 |
| 41 bool IsMemoryBased() const { return m_GenNum == kMemoryBasedGenNum; } |
| 42 |
| 43 protected: |
| 44 static const FX_DWORD kMemoryBasedGenNum = (FX_DWORD)-1; |
| 45 |
| 46 ~CPDF_Stream() override; |
| 47 |
| 48 void InitStreamInternal(CPDF_Dictionary* pDict); |
| 49 |
| 50 CPDF_Dictionary* m_pDict; |
| 51 FX_DWORD m_dwSize; |
| 52 FX_DWORD m_GenNum; |
| 53 |
| 54 union { |
| 55 uint8_t* m_pDataBuf; |
| 56 IFX_FileRead* m_pFile; |
| 57 }; |
| 58 }; |
| 59 |
| 60 inline CPDF_Stream* ToStream(CPDF_Object* obj) { |
| 61 return obj ? obj->AsStream() : nullptr; |
| 62 } |
| 63 |
| 64 inline const CPDF_Stream* ToStream(const CPDF_Object* obj) { |
| 65 return obj ? obj->AsStream() : nullptr; |
| 66 } |
| 67 |
| 68 class CPDF_StreamAcc { |
| 69 public: |
| 70 CPDF_StreamAcc(); |
| 71 ~CPDF_StreamAcc(); |
| 72 |
| 73 void LoadAllData(const CPDF_Stream* pStream, |
| 74 FX_BOOL bRawAccess = FALSE, |
| 75 FX_DWORD estimated_size = 0, |
| 76 FX_BOOL bImageAcc = FALSE); |
| 77 |
| 78 const CPDF_Stream* GetStream() const { return m_pStream; } |
| 79 CPDF_Dictionary* GetDict() const { |
| 80 return m_pStream ? m_pStream->GetDict() : nullptr; |
| 81 } |
| 82 const uint8_t* GetData() const; |
| 83 FX_DWORD GetSize() const; |
| 84 const CFX_ByteString& GetImageDecoder() const { return m_ImageDecoder; } |
| 85 const CPDF_Dictionary* GetImageParam() const { return m_pImageParam; } |
| 86 |
| 87 uint8_t* DetachData(); |
| 88 |
| 89 protected: |
| 90 uint8_t* m_pData; |
| 91 FX_DWORD m_dwSize; |
| 92 FX_BOOL m_bNewBuf; |
| 93 CFX_ByteString m_ImageDecoder; |
| 94 CPDF_Dictionary* m_pImageParam; |
| 95 const CPDF_Stream* m_pStream; |
| 96 uint8_t* m_pSrcData; |
| 97 }; |
| 98 |
| 99 #endif // CORE_INCLUDE_FPDFAPI_CPDF_STREAM_H_ |
OLD | NEW |