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 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" |
| 8 |
| 9 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" |
| 10 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
| 13 |
| 14 CPDF_Form::CPDF_Form(CPDF_Document* pDoc, |
| 15 CPDF_Dictionary* pPageResources, |
| 16 CPDF_Stream* pFormStream, |
| 17 CPDF_Dictionary* pParentResources) { |
| 18 m_pDocument = pDoc; |
| 19 m_pFormStream = pFormStream; |
| 20 m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL; |
| 21 m_pResources = m_pFormDict->GetDictBy("Resources"); |
| 22 m_pPageResources = pPageResources; |
| 23 if (!m_pResources) { |
| 24 m_pResources = pParentResources; |
| 25 } |
| 26 if (!m_pResources) { |
| 27 m_pResources = pPageResources; |
| 28 } |
| 29 m_Transparency = 0; |
| 30 LoadTransInfo(); |
| 31 } |
| 32 |
| 33 CPDF_Form::~CPDF_Form() {} |
| 34 |
| 35 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, |
| 36 CFX_Matrix* pParentMatrix, |
| 37 CPDF_Type3Char* pType3Char, |
| 38 CPDF_ParseOptions* pOptions, |
| 39 int level) { |
| 40 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { |
| 41 return; |
| 42 } |
| 43 m_pParser.reset(new CPDF_ContentParser); |
| 44 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions, |
| 45 level); |
| 46 m_ParseState = CONTENT_PARSING; |
| 47 } |
| 48 |
| 49 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, |
| 50 CFX_Matrix* pParentMatrix, |
| 51 CPDF_Type3Char* pType3Char, |
| 52 CPDF_ParseOptions* pOptions, |
| 53 int level) { |
| 54 StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level); |
| 55 ContinueParse(NULL); |
| 56 } |
| 57 |
| 58 CPDF_Form* CPDF_Form::Clone() const { |
| 59 CPDF_Form* pCloneForm = |
| 60 new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources); |
| 61 for (const auto& pObj : m_PageObjectList) |
| 62 pCloneForm->m_PageObjectList.emplace_back(pObj->Clone()); |
| 63 |
| 64 return pCloneForm; |
| 65 } |
OLD | NEW |