Merge to XFA: Kill CFX_Object.
[pdfium.git] / xfa / src / fxfa / src / parser / xfa_parser_imp.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _XFA_PARSER_IMP\r
8 #define _XFA_PARSER_IMP\r
9 #define _XFA_VERIFY_Checksum_\r
10 class CXFA_XMLParser;\r
11 class CXFA_SimpleParser : public IXFA_Parser\r
12 {\r
13 public:\r
14     CXFA_SimpleParser(IXFA_ObjFactory *pFactory, FX_BOOL bDocumentParser = FALSE);\r
15     ~CXFA_SimpleParser();\r
16     virtual void                                Release()\r
17     {\r
18         delete this;\r
19     }\r
20 \r
21     virtual FX_INT32                    StartParse(IFX_FileRead *pStream, XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP);\r
22     virtual FX_INT32                    DoParse(IFX_Pause *pPause = NULL);\r
23     virtual FX_INT32                    ParseXMLData(const CFX_WideString &wsXML, IFDE_XMLNode* &pXMLNode, IFX_Pause *pPause = NULL);\r
24     virtual void                                ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode);\r
25     virtual IXFA_ObjFactory*    GetFactory() const\r
26     {\r
27         return m_pFactory;\r
28     }\r
29     virtual CXFA_Node*                  GetRootNode() const\r
30     {\r
31         return m_pRootNode;\r
32     }\r
33     virtual IFDE_XMLDoc*                GetXMLDoc() const\r
34     {\r
35         return m_pXMLDoc;\r
36     }\r
37     virtual void                                CloseParser();\r
38 protected:\r
39     CXFA_Node*                          ParseAsXDPPacket                                                        (IFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID);\r
40     CXFA_Node*                          ParseAsXDPPacket_XDP                                            (IFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID);\r
41     CXFA_Node*                          ParseAsXDPPacket_Config                                         (IFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID);\r
42     CXFA_Node*                          ParseAsXDPPacket_TemplateForm                           (IFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID);\r
43     CXFA_Node*                          ParseAsXDPPacket_Data                                           (IFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID);\r
44     CXFA_Node*                          ParseAsXDPPacket_LocaleConnectionSourceSet      (IFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID);\r
45     CXFA_Node*                          ParseAsXDPPacket_Xdc                                            (IFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID);\r
46     CXFA_Node*                          ParseAsXDPPacket_User                                           (IFDE_XMLNode* pXMLDocumentNode, XFA_XDPPACKET ePacketID);\r
47     CXFA_Node*                          NormalLoader                                                            (CXFA_Node* pXFANode, IFDE_XMLNode* pXMLDoc, XFA_XDPPACKET ePacketID, FX_BOOL bUseAttribute = TRUE);\r
48     CXFA_Node*                          DataLoader                                                                      (CXFA_Node* pXFANode, IFDE_XMLNode* pXMLDoc, FX_BOOL bDoTransform);\r
49     CXFA_Node*                          UserPacketLoader                                                        (CXFA_Node* pXFANode, IFDE_XMLNode* pXMLDoc);\r
50     void                                        ParseContentNode                                                        (CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID);\r
51     void                                        ParseDataValue                                                          (CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID);\r
52     void                                        ParseDataGroup                                                          (CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode, XFA_XDPPACKET ePacketID);\r
53     void                                        ParseInstruction                                                        (CXFA_Node *pXFANode, IFDE_XMLInstruction *pXMLInstruction, XFA_XDPPACKET ePacketID);\r
54 protected:\r
55     void                                        SetFactory                                                                      (IXFA_ObjFactory* pFactory);\r
56     CXFA_XMLParser*                             m_pXMLParser;\r
57     IFDE_XMLDoc*                                m_pXMLDoc;\r
58     IFX_Stream*                                 m_pStream;\r
59     IFX_FileRead*                               m_pFileRead;\r
60     IXFA_ObjFactory*                    m_pFactory;\r
61     CXFA_Node*                                  m_pRootNode;\r
62     XFA_XDPPACKET                               m_ePacketID;\r
63     FX_BOOL                                             m_bDocumentParser;\r
64     friend class CXFA_DocumentParser;\r
65 };\r
66 class CXFA_DocumentParser : public IXFA_DocParser\r
67 {\r
68 public:\r
69     CXFA_DocumentParser(IXFA_Notify *pNotify);\r
70     ~CXFA_DocumentParser();\r
71     virtual void                                Release()\r
72     {\r
73         delete this;\r
74     }\r
75     virtual FX_INT32                    StartParse(IFX_FileRead *pStream, XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP);\r
76     virtual FX_INT32                    DoParse(IFX_Pause *pPause = NULL);\r
77     virtual FX_INT32                    ParseXMLData(const CFX_WideString &wsXML, IFDE_XMLNode* &pXMLNode, IFX_Pause *pPause = NULL);\r
78     virtual void                                ConstructXFANode(CXFA_Node* pXFANode, IFDE_XMLNode* pXMLNode);\r
79     virtual IXFA_ObjFactory*    GetFactory() const\r
80     {\r
81         return m_nodeParser.GetFactory();\r
82     }\r
83     virtual CXFA_Node*                  GetRootNode() const\r
84     {\r
85         return m_nodeParser.GetRootNode();\r
86     }\r
87     virtual IFDE_XMLDoc*                GetXMLDoc() const\r
88     {\r
89         return m_nodeParser.GetXMLDoc();\r
90     }\r
91     virtual IXFA_Notify*                GetNotify() const\r
92     {\r
93         return m_pNotify;\r
94     }\r
95     virtual CXFA_Document*              GetDocument() const\r
96     {\r
97         return m_pDocument;\r
98     }\r
99     virtual void                                CloseParser();\r
100 protected:\r
101     CXFA_SimpleParser                   m_nodeParser;\r
102     IXFA_Notify*                                m_pNotify;\r
103     CXFA_Document*                              m_pDocument;\r
104 };\r
105 typedef CFX_StackTemplate<IFDE_XMLNode*> CXFA_XMLNodeStack;\r
106 class CXFA_XMLParser : public IFDE_XMLParser\r
107 {\r
108 public:\r
109     CXFA_XMLParser(IFDE_XMLNode *pRoot, IFX_Stream *pStream);\r
110     ~CXFA_XMLParser();\r
111 \r
112     virtual void                        Release()\r
113     {\r
114         delete this;\r
115     }\r
116     virtual FX_INT32            DoParser(IFX_Pause *pPause);\r
117 protected:\r
118     IFDE_XMLNode                        *m_pRoot;\r
119     IFX_Stream                          *m_pStream;\r
120     IFDE_XMLSyntaxParser        *m_pParser;\r
121 \r
122     IFDE_XMLNode                        *m_pParent;\r
123     IFDE_XMLNode                        *m_pChild;\r
124     CXFA_XMLNodeStack           m_NodeStack;\r
125     CFX_WideString                      m_ws1;\r
126     CFX_WideString                      m_ws2;\r
127     FX_DWORD                            m_dwStatus;\r
128 #ifdef _XFA_VERIFY_Checksum_\r
129 public:\r
130     FX_FILESIZE                         m_nStart[2];\r
131     size_t                                      m_nSize[2];\r
132     FX_FILESIZE                         m_nElementStart;\r
133     FX_WORD                                     m_dwCheckStatus;\r
134     FX_WORD                                     m_dwCurrentCheckStatus;\r
135 #endif\r
136 };\r
137 #endif\r