Tom Sepez | f040890 | 2016-03-10 09:20:03 -0800 | [diff] [blame] | 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 | |
dsinclair | 488b7ad | 2016-10-04 11:55:50 -0700 | [diff] [blame] | 7 | #ifndef CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_ |
| 8 | #define CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_ |
Tom Sepez | f040890 | 2016-03-10 09:20:03 -0800 | [diff] [blame] | 9 | |
tsepez | 05e0169 | 2016-11-28 17:30:09 -0800 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
dsinclair | 488b7ad | 2016-10-04 11:55:50 -0700 | [diff] [blame] | 12 | #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" |
| 13 | #include "core/fpdfapi/parser/cpdf_object.h" |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame^] | 14 | #include "core/fxcrt/cfx_unowned_ptr.h" |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 15 | #include "core/fxcrt/fx_basic.h" |
Tom Sepez | f040890 | 2016-03-10 09:20:03 -0800 | [diff] [blame] | 16 | |
| 17 | class CPDF_Dictionary; |
| 18 | |
| 19 | class CFDF_Document : public CPDF_IndirectObjectHolder { |
| 20 | public: |
tsepez | 05e0169 | 2016-11-28 17:30:09 -0800 | [diff] [blame] | 21 | static std::unique_ptr<CFDF_Document> CreateNewDoc(); |
tsepez | 833619b | 2016-12-07 09:21:17 -0800 | [diff] [blame] | 22 | static std::unique_ptr<CFDF_Document> ParseFile( |
| 23 | const CFX_RetainPtr<IFX_SeekableReadStream>& pFile); |
| 24 | static std::unique_ptr<CFDF_Document> ParseMemory(uint8_t* pData, |
tsepez | 05e0169 | 2016-11-28 17:30:09 -0800 | [diff] [blame] | 25 | uint32_t size); |
| 26 | |
| 27 | CFDF_Document(); |
dsinclair | a61c01e | 2016-08-24 10:31:23 -0700 | [diff] [blame] | 28 | ~CFDF_Document() override; |
Tom Sepez | f040890 | 2016-03-10 09:20:03 -0800 | [diff] [blame] | 29 | |
tsepez | 12f3e4a | 2016-11-02 15:17:29 -0700 | [diff] [blame] | 30 | bool WriteBuf(CFX_ByteTextBuf& buf) const; |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame^] | 31 | CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); } |
Tom Sepez | f040890 | 2016-03-10 09:20:03 -0800 | [diff] [blame] | 32 | |
| 33 | protected: |
tsepez | 833619b | 2016-12-07 09:21:17 -0800 | [diff] [blame] | 34 | void ParseStream(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile); |
Tom Sepez | f040890 | 2016-03-10 09:20:03 -0800 | [diff] [blame] | 35 | |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame^] | 36 | CFX_UnownedPtr<CPDF_Dictionary> m_pRootDict; |
tsepez | 833619b | 2016-12-07 09:21:17 -0800 | [diff] [blame] | 37 | CFX_RetainPtr<IFX_SeekableReadStream> m_pFile; |
Tom Sepez | f040890 | 2016-03-10 09:20:03 -0800 | [diff] [blame] | 38 | }; |
| 39 | |
dsinclair | 488b7ad | 2016-10-04 11:55:50 -0700 | [diff] [blame] | 40 | #endif // CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_ |