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 #include "core/fpdfapi/page/cpdf_form.h" 8 9 #include "core/fpdfapi/page/cpdf_contentparser.h" 10 #include "core/fpdfapi/page/cpdf_pageobject.h" 11 #include "core/fpdfapi/page/cpdf_pageobjectholder.h" 12 #include "core/fpdfapi/page/pageint.h" 13 #include "core/fpdfapi/parser/cpdf_dictionary.h" 14 #include "core/fpdfapi/parser/cpdf_stream.h" 15 #include "third_party/base/ptr_util.h" 16 17 CPDF_Form::CPDF_Form(CPDF_Document* pDoc, 18 CPDF_Dictionary* pPageResources, 19 CPDF_Stream* pFormStream, 20 CPDF_Dictionary* pParentResources) { 21 m_pDocument = pDoc; 22 m_pFormStream = pFormStream; 23 m_pFormDict = pFormStream ? pFormStream->GetDict() : nullptr; 24 m_pResources = m_pFormDict->GetDictFor("Resources"); 25 m_pPageResources = pPageResources; 26 if (!m_pResources) 27 m_pResources = pParentResources; 28 if (!m_pResources) 29 m_pResources = pPageResources; 30 m_Transparency = 0; 31 LoadTransInfo(); 32 } 33 34 CPDF_Form::~CPDF_Form() {} 35 36 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, 37 const CFX_Matrix* pParentMatrix, 38 CPDF_Type3Char* pType3Char, 39 int level) { 40 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) 41 return; 42 43 m_pParser = pdfium::MakeUnique<CPDF_ContentParser>(); 44 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, level); 45 m_ParseState = CONTENT_PARSING; 46 } 47 48 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, 49 const CFX_Matrix* pParentMatrix, 50 CPDF_Type3Char* pType3Char, 51 int level) { 52 StartParse(pGraphicStates, pParentMatrix, pType3Char, level); 53 ContinueParse(nullptr); 54 } 55