summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_simple_parser.h
blob: ccb258a7d499bff2aed33f2ea6d1916163d53e57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_FXFA_PARSER_CXFA_SIMPLE_PARSER_H_
#define XFA_FXFA_PARSER_CXFA_SIMPLE_PARSER_H_

#include <memory>

#include "xfa/fxfa/fxfa_basic.h"

class CXFA_Document;
class CXFA_Node;
class CFDE_XMLDoc;
class CFDE_XMLInstruction;
class CFDE_XMLNode;
class CFDE_XMLParser;
class IFX_SeekableStream;
class IFX_Pause;
class IFGAS_Stream;

class CXFA_SimpleParser {
 public:
  CXFA_SimpleParser(CXFA_Document* pFactory, bool bDocumentParser);
  ~CXFA_SimpleParser();

  int32_t StartParse(const CFX_RetainPtr<IFX_SeekableStream>& pStream,
                     XFA_XDPPACKET ePacketID);
  int32_t DoParse(IFX_Pause* pPause);
  int32_t ParseXMLData(const CFX_WideString& wsXML,
                       CFDE_XMLNode*& pXMLNode,
                       IFX_Pause* pPause);
  void ConstructXFANode(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLNode);
  CXFA_Node* GetRootNode() const;
  CFDE_XMLDoc* GetXMLDoc() const;
  void CloseParser();

  void SetFactory(CXFA_Document* pFactory);

 private:
  CXFA_Node* ParseAsXDPPacket(CFDE_XMLNode* pXMLDocumentNode,
                              XFA_XDPPACKET ePacketID);
  CXFA_Node* ParseAsXDPPacket_XDP(CFDE_XMLNode* pXMLDocumentNode,
                                  XFA_XDPPACKET ePacketID);
  CXFA_Node* ParseAsXDPPacket_Config(CFDE_XMLNode* pXMLDocumentNode,
                                     XFA_XDPPACKET ePacketID);
  CXFA_Node* ParseAsXDPPacket_TemplateForm(CFDE_XMLNode* pXMLDocumentNode,
                                           XFA_XDPPACKET ePacketID);
  CXFA_Node* ParseAsXDPPacket_Data(CFDE_XMLNode* pXMLDocumentNode,
                                   XFA_XDPPACKET ePacketID);
  CXFA_Node* ParseAsXDPPacket_LocaleConnectionSourceSet(
      CFDE_XMLNode* pXMLDocumentNode,
      XFA_XDPPACKET ePacketID);
  CXFA_Node* ParseAsXDPPacket_Xdc(CFDE_XMLNode* pXMLDocumentNode,
                                  XFA_XDPPACKET ePacketID);
  CXFA_Node* ParseAsXDPPacket_User(CFDE_XMLNode* pXMLDocumentNode,
                                   XFA_XDPPACKET ePacketID);
  CXFA_Node* NormalLoader(CXFA_Node* pXFANode,
                          CFDE_XMLNode* pXMLDoc,
                          XFA_XDPPACKET ePacketID,
                          bool bUseAttribute);
  CXFA_Node* DataLoader(CXFA_Node* pXFANode,
                        CFDE_XMLNode* pXMLDoc,
                        bool bDoTransform);
  CXFA_Node* UserPacketLoader(CXFA_Node* pXFANode, CFDE_XMLNode* pXMLDoc);
  void ParseContentNode(CXFA_Node* pXFANode,
                        CFDE_XMLNode* pXMLNode,
                        XFA_XDPPACKET ePacketID);
  void ParseDataValue(CXFA_Node* pXFANode,
                      CFDE_XMLNode* pXMLNode,
                      XFA_XDPPACKET ePacketID);
  void ParseDataGroup(CXFA_Node* pXFANode,
                      CFDE_XMLNode* pXMLNode,
                      XFA_XDPPACKET ePacketID);
  void ParseInstruction(CXFA_Node* pXFANode,
                        CFDE_XMLInstruction* pXMLInstruction,
                        XFA_XDPPACKET ePacketID);

  CFDE_XMLParser* m_pXMLParser;
  std::unique_ptr<CFDE_XMLDoc> m_pXMLDoc;
  CFX_RetainPtr<IFGAS_Stream> m_pStream;
  CFX_RetainPtr<IFX_SeekableStream> m_pFileRead;
  CXFA_Document* m_pFactory;
  CXFA_Node* m_pRootNode;
  XFA_XDPPACKET m_ePacketID;
  bool m_bDocumentParser;
};

#endif  // XFA_FXFA_PARSER_CXFA_SIMPLE_PARSER_H_