• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 #ifndef XFA_FXFA_PARSER_CXFA_SIMPLE_PARSER_H_
8 #define XFA_FXFA_PARSER_CXFA_SIMPLE_PARSER_H_
9 
10 #include <memory>
11 
12 #include "xfa/fde/xml/fde_xml_imp.h"
13 #include "xfa/fxfa/fxfa_basic.h"
14 
15 class CXFA_Document;
16 class CXFA_Node;
17 class CXFA_XMLParser;
18 class IFX_SeekableReadStream;
19 class IFX_Pause;
20 class IFGAS_Stream;
21 
22 class CXFA_SimpleParser {
23  public:
24   CXFA_SimpleParser(CXFA_Document* pFactory, bool bDocumentParser);
25   ~CXFA_SimpleParser();
26 
27   int32_t StartParse(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
28                      XFA_XDPPACKET ePacketID);
29   int32_t DoParse(IFX_Pause* pPause);
30   int32_t ParseXMLData(const CFX_WideString& wsXML,
31                        CFDE_XMLNode*& pXMLNode,
32                        IFX_Pause* pPause);
33   void ConstructXFANode(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLNode);
34   CXFA_Node* GetRootNode() const;
35   CFDE_XMLDoc* GetXMLDoc() const;
36   void CloseParser();
37 
38   void SetFactory(CXFA_Document* pFactory);
39 
40  private:
41   CXFA_Node* ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode,
42                               XFA_XDPPACKET ePacketID);
43   CXFA_Node* ParseAsXDPPacket_XDP(CFDE_XMLNode* pXMLDocumentNode,
44                                   XFA_XDPPACKET ePacketID);
45   CXFA_Node* ParseAsXDPPacket_Config(CFDE_XMLNode* pXMLDocumentNode,
46                                      XFA_XDPPACKET ePacketID);
47   CXFA_Node* ParseAsXDPPacket_TemplateForm(CFDE_XMLNode* pXMLDocumentNode,
48                                            XFA_XDPPACKET ePacketID);
49   CXFA_Node* ParseAsXDPPacket_Data(CFDE_XMLNode* pXMLDocumentNode,
50                                    XFA_XDPPACKET ePacketID);
51   CXFA_Node* ParseAsXDPPacket_LocaleConnectionSourceSet(
52       CFDE_XMLNode* pXMLDocumentNode,
53       XFA_XDPPACKET ePacketID);
54   CXFA_Node* ParseAsXDPPacket_Xdc(CFDE_XMLNode* pXMLDocumentNode,
55                                   XFA_XDPPACKET ePacketID);
56   CXFA_Node* ParseAsXDPPacket_User(CFDE_XMLNode* pXMLDocumentNode,
57                                    XFA_XDPPACKET ePacketID);
58   CXFA_Node* NormalLoader(CXFA_Node* pXFANode,
59                           CFDE_XMLNode* pXMLDoc,
60                           XFA_XDPPACKET ePacketID,
61                           bool bUseAttribute);
62   CXFA_Node* DataLoader(CXFA_Node* pXFANode,
63                         CFDE_XMLNode* pXMLDoc,
64                         bool bDoTransform);
65   CXFA_Node* UserPacketLoader(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLDoc);
66   void ParseContentNode(CXFA_Node* pXFANode,
67                         CFDE_XMLNode* pXMLNode,
68                         XFA_XDPPACKET ePacketID);
69   void ParseDataValue(CXFA_Node* pXFANode,
70                       CFDE_XMLNode* pXMLNode,
71                       XFA_XDPPACKET ePacketID);
72   void ParseDataGroup(CXFA_Node* pXFANode,
73                       CFDE_XMLNode* pXMLNode,
74                       XFA_XDPPACKET ePacketID);
75   void ParseInstruction(CXFA_Node* pXFANode,
76                         CFDE_XMLInstruction* pXMLInstruction,
77                         XFA_XDPPACKET ePacketID);
78 
79   CXFA_XMLParser* m_pXMLParser;
80   std::unique_ptr<CFDE_XMLDoc> m_pXMLDoc;
81   CFX_RetainPtr<IFGAS_Stream> m_pStream;
82   CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
83   CXFA_Document* m_pFactory;
84   CXFA_Node* m_pRootNode;
85   XFA_XDPPACKET m_ePacketID;
86   bool m_bDocumentParser;
87 };
88 
89 #endif  // XFA_FXFA_PARSER_CXFA_SIMPLE_PARSER_H_
90