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