// Copyright 2016 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #ifndef CORE_FPDFAPI_PAGE_CPDF_CONTENTPARSER_H_ #define CORE_FPDFAPI_PAGE_CPDF_CONTENTPARSER_H_ #include #include #include #include "core/fpdfapi/page/cpdf_pageobjectholder.h" #include "core/fpdfapi/page/cpdf_streamcontentparser.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fxcrt/unowned_ptr.h" class CPDF_AllStates; class CPDF_Form; class CPDF_Page; class CPDF_StreamAcc; class CPDF_Type3Char; class CPDF_ContentParser { public: explicit CPDF_ContentParser(CPDF_Page* pPage); CPDF_ContentParser(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, const CFX_Matrix* pParentMatrix, CPDF_Type3Char* pType3Char, std::set* parsedSet); ~CPDF_ContentParser(); const CPDF_AllStates* GetCurStates() const { return m_pParser ? m_pParser->GetCurStates() : nullptr; } // Returns whether to continue or not. bool Continue(IFX_PauseIndicator* pPause); private: enum InternalStage { STAGE_GETCONTENT = 1, STAGE_PARSE, STAGE_CHECKCLIP, }; bool m_bIsDone = false; InternalStage m_InternalStage; UnownedPtr const m_pObjectHolder; UnownedPtr m_pType3Char; // Only used when parsing forms. uint32_t m_nStreams = 0; RetainPtr m_pSingleStream; std::vector> m_StreamArray; uint8_t* m_pData = nullptr; uint32_t m_Size = 0; uint32_t m_CurrentOffset = 0; // Only used when parsing pages. std::unique_ptr> m_parsedSet; // |m_pParser| has a reference to |m_parsedSet|, so must be below and thus // destroyed first. std::unique_ptr m_pParser; }; #endif // CORE_FPDFAPI_PAGE_CPDF_CONTENTPARSER_H_