OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" |
11 #include "core/fpdfapi/fpdf_page/pageint.h" | 11 #include "core/fpdfapi/fpdf_page/pageint.h" |
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
14 | 14 |
15 CPDF_Form::CPDF_Form(CPDF_Document* pDoc, | 15 CPDF_Form::CPDF_Form(CPDF_Document* pDoc, |
16 CPDF_Dictionary* pPageResources, | 16 CPDF_Dictionary* pPageResources, |
17 CPDF_Stream* pFormStream, | 17 CPDF_Stream* pFormStream, |
18 CPDF_Dictionary* pParentResources) { | 18 CPDF_Dictionary* pParentResources) { |
19 m_pDocument = pDoc; | 19 m_pDocument = pDoc; |
20 m_pFormStream = pFormStream; | 20 m_pFormStream = pFormStream; |
21 m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL; | 21 m_pFormDict = pFormStream ? pFormStream->GetDict() : nullptr; |
22 m_pResources = m_pFormDict->GetDictBy("Resources"); | 22 m_pResources = m_pFormDict->GetDictBy("Resources"); |
23 m_pPageResources = pPageResources; | 23 m_pPageResources = pPageResources; |
24 if (!m_pResources) { | 24 if (!m_pResources) |
25 m_pResources = pParentResources; | 25 m_pResources = pParentResources; |
26 } | 26 if (!m_pResources) |
27 if (!m_pResources) { | |
28 m_pResources = pPageResources; | 27 m_pResources = pPageResources; |
29 } | |
30 m_Transparency = 0; | 28 m_Transparency = 0; |
31 LoadTransInfo(); | 29 LoadTransInfo(); |
32 } | 30 } |
33 | 31 |
34 CPDF_Form::~CPDF_Form() {} | 32 CPDF_Form::~CPDF_Form() {} |
35 | 33 |
36 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, | 34 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, |
37 CFX_Matrix* pParentMatrix, | 35 const CFX_Matrix* pParentMatrix, |
38 CPDF_Type3Char* pType3Char, | 36 CPDF_Type3Char* pType3Char, |
39 int level) { | 37 int level) { |
40 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) { | 38 if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) |
41 return; | 39 return; |
42 } | 40 |
43 m_pParser.reset(new CPDF_ContentParser); | 41 m_pParser.reset(new CPDF_ContentParser); |
44 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, level); | 42 m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, level); |
45 m_ParseState = CONTENT_PARSING; | 43 m_ParseState = CONTENT_PARSING; |
46 } | 44 } |
47 | 45 |
48 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, | 46 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, |
49 CFX_Matrix* pParentMatrix, | 47 const CFX_Matrix* pParentMatrix, |
50 CPDF_Type3Char* pType3Char, | 48 CPDF_Type3Char* pType3Char, |
51 int level) { | 49 int level) { |
52 StartParse(pGraphicStates, pParentMatrix, pType3Char, level); | 50 StartParse(pGraphicStates, pParentMatrix, pType3Char, level); |
53 ContinueParse(NULL); | 51 ContinueParse(nullptr); |
54 } | 52 } |
55 | 53 |
56 CPDF_Form* CPDF_Form::Clone() const { | 54 CPDF_Form* CPDF_Form::Clone() const { |
57 CPDF_Form* pCloneForm = | 55 CPDF_Form* pCloneForm = |
58 new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources); | 56 new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources); |
59 for (const auto& pObj : m_PageObjectList) | 57 for (const auto& pObj : m_PageObjectList) |
60 pCloneForm->m_PageObjectList.emplace_back(pObj->Clone()); | 58 pCloneForm->m_PageObjectList.emplace_back(pObj->Clone()); |
61 | 59 |
62 return pCloneForm; | 60 return pCloneForm; |
63 } | 61 } |
OLD | NEW |