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 "xfa/fxfa/parser/cxfa_xml_parser.h" | 7 #include "xfa/fxfa/parser/cxfa_xml_parser.h" |
8 | 8 |
9 CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream) | 9 CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream) |
10 : m_nElementStart(0), | 10 : m_nElementStart(0), |
11 m_dwCheckStatus(0), | 11 m_dwCheckStatus(0), |
12 m_dwCurrentCheckStatus(0), | 12 m_dwCurrentCheckStatus(0), |
13 m_pRoot(pRoot), | 13 m_pRoot(pRoot), |
14 m_pStream(pStream), | 14 m_pStream(pStream), |
15 m_pParser(new CFDE_XMLSyntaxParser), | 15 m_pParser(new CFDE_XMLSyntaxParser), |
16 m_pParent(pRoot), | 16 m_pParent(pRoot), |
17 m_pChild(nullptr), | 17 m_pChild(nullptr), |
18 m_NodeStack(16), | 18 m_NodeStack(16), |
19 m_syntaxParserResult(FDE_XmlSyntaxResult::None) { | 19 m_syntaxParserResult(FDE_XmlSyntaxResult::None) { |
20 ASSERT(m_pParent && m_pStream); | 20 ASSERT(m_pParent && m_pStream); |
21 m_NodeStack.Push(m_pParent); | 21 m_NodeStack.Push(m_pParent); |
22 m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); | 22 m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); |
23 } | 23 } |
24 | 24 |
25 CXFA_XMLParser::~CXFA_XMLParser() { | 25 CXFA_XMLParser::~CXFA_XMLParser() { |
26 m_NodeStack.RemoveAll(FALSE); | 26 m_NodeStack.RemoveAll(false); |
27 m_ws1.clear(); | 27 m_ws1.clear(); |
28 m_ws2.clear(); | 28 m_ws2.clear(); |
29 } | 29 } |
30 | 30 |
31 void CXFA_XMLParser::Release() { | 31 void CXFA_XMLParser::Release() { |
32 delete this; | 32 delete this; |
33 } | 33 } |
34 | 34 |
35 int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { | 35 int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { |
36 if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) | 36 if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) |
37 return -1; | 37 return -1; |
38 if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) | 38 if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) |
39 return 100; | 39 return 100; |
40 | 40 |
41 int32_t iCount = 0; | 41 int32_t iCount = 0; |
42 while (TRUE) { | 42 while (true) { |
43 m_syntaxParserResult = m_pParser->DoSyntaxParse(); | 43 m_syntaxParserResult = m_pParser->DoSyntaxParse(); |
44 switch (m_syntaxParserResult) { | 44 switch (m_syntaxParserResult) { |
45 case FDE_XmlSyntaxResult::InstructionOpen: | 45 case FDE_XmlSyntaxResult::InstructionOpen: |
46 break; | 46 break; |
47 case FDE_XmlSyntaxResult::InstructionClose: | 47 case FDE_XmlSyntaxResult::InstructionClose: |
48 if (m_pChild) { | 48 if (m_pChild) { |
49 if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { | 49 if (m_pChild->GetType() != FDE_XMLNODE_Instruction) { |
50 m_syntaxParserResult = FDE_XmlSyntaxResult::Error; | 50 m_syntaxParserResult = FDE_XmlSyntaxResult::Error; |
51 break; | 51 break; |
52 } | 52 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { | 168 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { |
169 break; | 169 break; |
170 } | 170 } |
171 } | 171 } |
172 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || | 172 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || |
173 m_NodeStack.GetSize() != 1) | 173 m_NodeStack.GetSize() != 1) |
174 ? -1 | 174 ? -1 |
175 : m_pParser->GetStatus(); | 175 : m_pParser->GetStatus(); |
176 } | 176 } |
OLD | NEW |