OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef XFA_FDE_XML_FDE_XML_IMP_H_ | 7 #ifndef XFA_FDE_XML_FDE_XML_IMP_H_ |
8 #define XFA_FDE_XML_FDE_XML_IMP_H_ | 8 #define XFA_FDE_XML_FDE_XML_IMP_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_system.h" | 10 #include "core/fxcrt/include/fx_system.h" |
11 #include "xfa/fde/xml/fde_xml.h" | 11 #include "xfa/fde/xml/fde_xml.h" |
12 #include "xfa/fgas/crt/fgas_memory.h" | 12 #include "xfa/fgas/crt/fgas_memory.h" |
13 #include "xfa/fgas/crt/fgas_stream.h" | 13 #include "xfa/fgas/crt/fgas_stream.h" |
14 | 14 |
15 class CFDE_BlockBuffer; | 15 class CFDE_BlockBuffer; |
16 class CFDE_XMLInstruction; | 16 class CFDE_XMLInstruction; |
17 class CFDE_XMLElement; | 17 class CFDE_XMLElement; |
18 class CFDE_XMLText; | 18 class CFDE_XMLText; |
19 class CFDE_XMLDoc; | 19 class CFDE_XMLDoc; |
20 class CFDE_XMLDOMParser; | 20 class CFDE_XMLDOMParser; |
21 class CFDE_XMLParser; | |
22 class CFDE_XMLSAXParser; | 21 class CFDE_XMLSAXParser; |
23 class CFDE_XMLSyntaxParser; | 22 class CFDE_XMLSyntaxParser; |
| 23 class IFDE_XMLParser; |
24 | 24 |
25 class CFDE_XMLNode : public CFX_Target { | 25 class CFDE_XMLNode : public CFX_Target { |
26 public: | 26 public: |
27 enum NodeItem { | 27 enum NodeItem { |
28 Root = 0, | 28 Root = 0, |
29 Parent, | 29 Parent, |
30 FirstSibling, | 30 FirstSibling, |
31 PriorSibling, | 31 PriorSibling, |
32 NextSibling, | 32 NextSibling, |
33 LastSibling, | 33 LastSibling, |
34 FirstNeighbor, | 34 FirstNeighbor, |
35 PriorNeighbor, | 35 PriorNeighbor, |
36 NextNeighbor, | 36 NextNeighbor, |
37 LastNeighbor, | 37 LastNeighbor, |
38 FirstChild, | 38 FirstChild, |
39 LastChild | 39 LastChild |
40 }; | 40 }; |
41 | 41 |
42 CFDE_XMLNode(); | 42 CFDE_XMLNode(); |
| 43 ~CFDE_XMLNode() override; |
43 | 44 |
44 virtual void Release() { delete this; } | |
45 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; } | 45 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; } |
46 virtual int32_t CountChildNodes() const; | 46 virtual int32_t CountChildNodes() const; |
47 virtual CFDE_XMLNode* GetChildNode(int32_t index) const; | 47 virtual CFDE_XMLNode* GetChildNode(int32_t index) const; |
48 virtual int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const; | 48 virtual int32_t GetChildNodeIndex(CFDE_XMLNode* pNode) const; |
49 virtual CFDE_XMLNode* GetPath(const FX_WCHAR* pPath, | 49 virtual CFDE_XMLNode* GetPath(const FX_WCHAR* pPath, |
50 int32_t iLength = -1, | 50 int32_t iLength = -1, |
51 FX_BOOL bQualifiedName = TRUE) const; | 51 FX_BOOL bQualifiedName = TRUE) const; |
52 virtual int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1); | 52 virtual int32_t InsertChildNode(CFDE_XMLNode* pNode, int32_t index = -1); |
53 virtual void RemoveChildNode(CFDE_XMLNode* pNode); | 53 virtual void RemoveChildNode(CFDE_XMLNode* pNode); |
54 virtual void DeleteChildren(); | 54 virtual void DeleteChildren(); |
55 virtual CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const; | 55 virtual CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const; |
56 virtual int32_t GetNodeLevel() const; | 56 virtual int32_t GetNodeLevel() const; |
57 virtual FX_BOOL InsertNodeItem(CFDE_XMLNode::NodeItem eItem, | 57 virtual FX_BOOL InsertNodeItem(CFDE_XMLNode::NodeItem eItem, |
58 CFDE_XMLNode* pNode); | 58 CFDE_XMLNode* pNode); |
59 virtual CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem); | 59 virtual CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem); |
60 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); | 60 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); |
61 virtual void SaveXMLNode(IFX_Stream* pXMLStream); | 61 virtual void SaveXMLNode(IFX_Stream* pXMLStream); |
62 | 62 |
63 public: | |
64 ~CFDE_XMLNode(); | |
65 void CloneChildren(CFDE_XMLNode* pClone); | 63 void CloneChildren(CFDE_XMLNode* pClone); |
| 64 |
66 CFDE_XMLNode* m_pParent; | 65 CFDE_XMLNode* m_pParent; |
67 CFDE_XMLNode* m_pChild; | 66 CFDE_XMLNode* m_pChild; |
68 CFDE_XMLNode* m_pPrior; | 67 CFDE_XMLNode* m_pPrior; |
69 CFDE_XMLNode* m_pNext; | 68 CFDE_XMLNode* m_pNext; |
70 }; | 69 }; |
| 70 |
71 class CFDE_XMLInstruction : public CFDE_XMLNode { | 71 class CFDE_XMLInstruction : public CFDE_XMLNode { |
72 public: | 72 public: |
73 CFDE_XMLInstruction(const CFX_WideString& wsTarget); | 73 CFDE_XMLInstruction(const CFX_WideString& wsTarget); |
74 virtual void Release() { delete this; } | 74 ~CFDE_XMLInstruction() override; |
75 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Instruction; } | 75 |
76 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); | 76 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Instruction; } |
| 77 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; |
| 78 |
77 virtual void GetTargetName(CFX_WideString& wsTarget) const { | 79 virtual void GetTargetName(CFX_WideString& wsTarget) const { |
78 wsTarget = m_wsTarget; | 80 wsTarget = m_wsTarget; |
79 } | 81 } |
80 virtual int32_t CountAttributes() const; | 82 virtual int32_t CountAttributes() const; |
81 virtual FX_BOOL GetAttribute(int32_t index, | 83 virtual FX_BOOL GetAttribute(int32_t index, |
82 CFX_WideString& wsAttriName, | 84 CFX_WideString& wsAttriName, |
83 CFX_WideString& wsAttriValue) const; | 85 CFX_WideString& wsAttriValue) const; |
84 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; | 86 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; |
85 virtual void GetString(const FX_WCHAR* pwsAttriName, | 87 virtual void GetString(const FX_WCHAR* pwsAttriName, |
86 CFX_WideString& wsAttriValue, | 88 CFX_WideString& wsAttriValue, |
87 const FX_WCHAR* pwsDefValue = NULL) const; | 89 const FX_WCHAR* pwsDefValue = NULL) const; |
88 virtual void SetString(const CFX_WideString& wsAttriName, | 90 virtual void SetString(const CFX_WideString& wsAttriName, |
89 const CFX_WideString& wsAttriValue); | 91 const CFX_WideString& wsAttriValue); |
90 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, | 92 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, |
91 int32_t iDefValue = 0) const; | 93 int32_t iDefValue = 0) const; |
92 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); | 94 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); |
93 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, | 95 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, |
94 FX_FLOAT fDefValue = 0) const; | 96 FX_FLOAT fDefValue = 0) const; |
95 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); | 97 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); |
96 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); | 98 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); |
97 virtual int32_t CountData() const; | 99 virtual int32_t CountData() const; |
98 virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const; | 100 virtual FX_BOOL GetData(int32_t index, CFX_WideString& wsData) const; |
99 virtual void AppendData(const CFX_WideString& wsData); | 101 virtual void AppendData(const CFX_WideString& wsData); |
100 virtual void RemoveData(int32_t index); | 102 virtual void RemoveData(int32_t index); |
101 | 103 |
102 public: | |
103 ~CFDE_XMLInstruction() {} | |
104 CFX_WideString m_wsTarget; | 104 CFX_WideString m_wsTarget; |
105 CFX_WideStringArray m_Attributes; | 105 CFX_WideStringArray m_Attributes; |
106 CFX_WideStringArray m_TargetData; | 106 CFX_WideStringArray m_TargetData; |
107 }; | 107 }; |
| 108 |
108 class CFDE_XMLElement : public CFDE_XMLNode { | 109 class CFDE_XMLElement : public CFDE_XMLNode { |
109 public: | 110 public: |
110 CFDE_XMLElement(const CFX_WideString& wsTag); | 111 CFDE_XMLElement(const CFX_WideString& wsTag); |
111 virtual void Release() { delete this; } | 112 ~CFDE_XMLElement() override; |
112 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Element; } | 113 |
113 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); | 114 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Element; } |
| 115 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; |
| 116 |
114 virtual void GetTagName(CFX_WideString& wsTag) const; | 117 virtual void GetTagName(CFX_WideString& wsTag) const; |
115 virtual void GetLocalTagName(CFX_WideString& wsTag) const; | 118 virtual void GetLocalTagName(CFX_WideString& wsTag) const; |
116 virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const; | 119 virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const; |
117 virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const; | 120 virtual void GetNamespaceURI(CFX_WideString& wsNamespace) const; |
118 virtual int32_t CountAttributes() const; | 121 virtual int32_t CountAttributes() const; |
119 virtual FX_BOOL GetAttribute(int32_t index, | 122 virtual FX_BOOL GetAttribute(int32_t index, |
120 CFX_WideString& wsAttriName, | 123 CFX_WideString& wsAttriName, |
121 CFX_WideString& wsAttriValue) const; | 124 CFX_WideString& wsAttriValue) const; |
122 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; | 125 virtual FX_BOOL HasAttribute(const FX_WCHAR* pwsAttriName) const; |
123 virtual void GetString(const FX_WCHAR* pwsAttriName, | 126 virtual void GetString(const FX_WCHAR* pwsAttriName, |
124 CFX_WideString& wsAttriValue, | 127 CFX_WideString& wsAttriValue, |
125 const FX_WCHAR* pwsDefValue = NULL) const; | 128 const FX_WCHAR* pwsDefValue = NULL) const; |
126 virtual void SetString(const CFX_WideString& wsAttriName, | 129 virtual void SetString(const CFX_WideString& wsAttriName, |
127 const CFX_WideString& wsAttriValue); | 130 const CFX_WideString& wsAttriValue); |
128 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, | 131 virtual int32_t GetInteger(const FX_WCHAR* pwsAttriName, |
129 int32_t iDefValue = 0) const; | 132 int32_t iDefValue = 0) const; |
130 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); | 133 virtual void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); |
131 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, | 134 virtual FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, |
132 FX_FLOAT fDefValue = 0) const; | 135 FX_FLOAT fDefValue = 0) const; |
133 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); | 136 virtual void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); |
134 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); | 137 virtual void RemoveAttribute(const FX_WCHAR* pwsAttriName); |
135 virtual void GetTextData(CFX_WideString& wsText) const; | 138 virtual void GetTextData(CFX_WideString& wsText) const; |
136 virtual void SetTextData(const CFX_WideString& wsText); | 139 virtual void SetTextData(const CFX_WideString& wsText); |
137 | 140 |
138 public: | |
139 ~CFDE_XMLElement(); | |
140 CFX_WideString m_wsTag; | 141 CFX_WideString m_wsTag; |
141 CFX_WideStringArray m_Attributes; | 142 CFX_WideStringArray m_Attributes; |
142 }; | 143 }; |
| 144 |
143 class CFDE_XMLText : public CFDE_XMLNode { | 145 class CFDE_XMLText : public CFDE_XMLNode { |
144 public: | 146 public: |
145 CFDE_XMLText(const CFX_WideString& wsText); | 147 CFDE_XMLText(const CFX_WideString& wsText); |
146 virtual void Release() { delete this; } | 148 ~CFDE_XMLText() override; |
147 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Text; } | 149 |
148 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); | 150 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Text; } |
| 151 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; |
| 152 |
149 virtual void GetText(CFX_WideString& wsText) const { wsText = m_wsText; } | 153 virtual void GetText(CFX_WideString& wsText) const { wsText = m_wsText; } |
150 virtual void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } | 154 virtual void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } |
151 | 155 |
152 public: | |
153 ~CFDE_XMLText() {} | |
154 CFX_WideString m_wsText; | 156 CFX_WideString m_wsText; |
155 }; | 157 }; |
| 158 |
156 class CFDE_XMLDeclaration : public CFDE_XMLNode { | 159 class CFDE_XMLDeclaration : public CFDE_XMLNode { |
157 public: | 160 public: |
158 CFDE_XMLDeclaration() : CFDE_XMLNode() {} | 161 CFDE_XMLDeclaration() : CFDE_XMLNode() {} |
159 }; | 162 }; |
| 163 |
160 class CFDE_XMLCharData : public CFDE_XMLDeclaration { | 164 class CFDE_XMLCharData : public CFDE_XMLDeclaration { |
161 public: | 165 public: |
162 CFDE_XMLCharData(const CFX_WideString& wsCData); | 166 CFDE_XMLCharData(const CFX_WideString& wsCData); |
| 167 ~CFDE_XMLCharData() override; |
163 | 168 |
164 virtual void Release() { delete this; } | 169 FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_CharData; } |
165 virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_CharData; } | 170 CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; |
166 virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); | 171 |
167 virtual void GetCharData(CFX_WideString& wsCharData) const { | 172 virtual void GetCharData(CFX_WideString& wsCharData) const { |
168 wsCharData = m_wsCharData; | 173 wsCharData = m_wsCharData; |
169 } | 174 } |
170 virtual void SetCharData(const CFX_WideString& wsCData) { | 175 virtual void SetCharData(const CFX_WideString& wsCData) { |
171 m_wsCharData = wsCData; | 176 m_wsCharData = wsCData; |
172 } | 177 } |
173 | 178 |
174 public: | |
175 ~CFDE_XMLCharData() {} | |
176 | |
177 CFX_WideString m_wsCharData; | 179 CFX_WideString m_wsCharData; |
178 }; | 180 }; |
| 181 |
179 class CFDE_XMLDoc : public CFX_Target { | 182 class CFDE_XMLDoc : public CFX_Target { |
180 public: | 183 public: |
181 CFDE_XMLDoc(); | 184 CFDE_XMLDoc(); |
182 ~CFDE_XMLDoc(); | 185 ~CFDE_XMLDoc() override; |
183 virtual void Release() { delete this; } | 186 |
184 virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream, | 187 virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream, |
185 int32_t iXMLPlaneSize = 8192, | 188 int32_t iXMLPlaneSize = 8192, |
186 int32_t iTextDataSize = 256, | 189 int32_t iTextDataSize = 256, |
187 FDE_XMLREADERHANDLER* pHandler = NULL); | 190 FDE_XMLREADERHANDLER* pHandler = NULL); |
188 virtual FX_BOOL LoadXML(CFDE_XMLParser* pXMLParser); | 191 virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser); |
189 virtual int32_t DoLoad(IFX_Pause* pPause = NULL); | 192 virtual int32_t DoLoad(IFX_Pause* pPause = NULL); |
190 virtual void CloseXML(); | 193 virtual void CloseXML(); |
191 virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; } | 194 virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; } |
192 virtual void SaveXML(IFX_Stream* pXMLStream = NULL, FX_BOOL bSaveBOM = TRUE); | 195 virtual void SaveXML(IFX_Stream* pXMLStream = NULL, FX_BOOL bSaveBOM = TRUE); |
193 virtual void SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pNode); | 196 virtual void SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pNode); |
194 | 197 |
195 protected: | 198 protected: |
196 IFX_Stream* m_pStream; | 199 IFX_Stream* m_pStream; |
197 int32_t m_iStatus; | 200 int32_t m_iStatus; |
198 CFDE_XMLNode* m_pRoot; | 201 CFDE_XMLNode* m_pRoot; |
199 CFDE_XMLSyntaxParser* m_pSyntaxParser; | 202 CFDE_XMLSyntaxParser* m_pSyntaxParser; |
200 CFDE_XMLParser* m_pXMLParser; | 203 IFDE_XMLParser* m_pXMLParser; |
201 void Reset(FX_BOOL bInitRoot); | 204 void Reset(FX_BOOL bInitRoot); |
202 void ReleaseParser(); | 205 void ReleaseParser(); |
203 }; | 206 }; |
204 typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack; | 207 typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack; |
205 | 208 |
206 class CFDE_XMLParser { | 209 class IFDE_XMLParser { |
207 public: | 210 public: |
208 virtual ~CFDE_XMLParser() {} | 211 virtual ~IFDE_XMLParser() {} |
209 | 212 |
210 virtual void Release() = 0; | |
211 virtual int32_t DoParser(IFX_Pause* pPause) = 0; | 213 virtual int32_t DoParser(IFX_Pause* pPause) = 0; |
212 }; | 214 }; |
213 | 215 |
214 class CFDE_XMLDOMParser : public CFDE_XMLParser, public CFX_Target { | 216 class CFDE_XMLDOMParser : public IFDE_XMLParser, public CFX_Target { |
215 public: | 217 public: |
216 CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, CFDE_XMLSyntaxParser* pParser); | 218 CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, CFDE_XMLSyntaxParser* pParser); |
217 ~CFDE_XMLDOMParser(); | 219 ~CFDE_XMLDOMParser() override; |
218 | 220 |
219 virtual void Release() { delete this; } | 221 int32_t DoParser(IFX_Pause* pPause) override; |
220 virtual int32_t DoParser(IFX_Pause* pPause); | |
221 | 222 |
222 private: | 223 private: |
223 CFDE_XMLSyntaxParser* m_pParser; | 224 CFDE_XMLSyntaxParser* m_pParser; |
224 CFDE_XMLNode* m_pParent; | 225 CFDE_XMLNode* m_pParent; |
225 CFDE_XMLNode* m_pChild; | 226 CFDE_XMLNode* m_pChild; |
226 CFDE_XMLDOMNodeStack m_NodeStack; | 227 CFDE_XMLDOMNodeStack m_NodeStack; |
227 CFX_WideString m_ws1; | 228 CFX_WideString m_ws1; |
228 CFX_WideString m_ws2; | 229 CFX_WideString m_ws2; |
229 }; | 230 }; |
230 class CFDE_XMLTAG : public CFX_Target { | 231 class CFDE_XMLTAG : public CFX_Target { |
231 public: | 232 public: |
232 CFDE_XMLTAG() : eType(FDE_XMLNODE_Unknown) {} | 233 CFDE_XMLTAG() : eType(FDE_XMLNODE_Unknown) {} |
233 CFDE_XMLTAG(const CFDE_XMLTAG& src) | 234 CFDE_XMLTAG(const CFDE_XMLTAG& src) |
234 : wsTagName(src.wsTagName), eType(src.eType) {} | 235 : wsTagName(src.wsTagName), eType(src.eType) {} |
235 CFX_WideString wsTagName; | 236 CFX_WideString wsTagName; |
236 FDE_XMLNODETYPE eType; | 237 FDE_XMLNODETYPE eType; |
237 }; | 238 }; |
238 typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack; | 239 typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack; |
239 class CFDE_XMLSAXParser : public CFDE_XMLParser, public CFX_Target { | 240 |
| 241 class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target { |
240 public: | 242 public: |
241 CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, | 243 CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, |
242 CFDE_XMLSyntaxParser* pParser); | 244 CFDE_XMLSyntaxParser* pParser); |
243 ~CFDE_XMLSAXParser(); | 245 ~CFDE_XMLSAXParser() override; |
244 | 246 |
245 virtual void Release() { delete this; } | 247 int32_t DoParser(IFX_Pause* pPause) override; |
246 virtual int32_t DoParser(IFX_Pause* pPause); | |
247 | 248 |
248 private: | 249 private: |
249 void Push(const CFDE_XMLTAG& xmlTag); | 250 void Push(const CFDE_XMLTAG& xmlTag); |
250 void Pop(); | 251 void Pop(); |
251 FDE_XMLREADERHANDLER* m_pHandler; | 252 FDE_XMLREADERHANDLER* m_pHandler; |
252 CFDE_XMLSyntaxParser* m_pParser; | 253 CFDE_XMLSyntaxParser* m_pParser; |
253 CFDE_XMLTagStack m_TagStack; | 254 CFDE_XMLTagStack m_TagStack; |
254 CFDE_XMLTAG* m_pTagTop; | 255 CFDE_XMLTAG* m_pTagTop; |
255 CFX_WideString m_ws1; | 256 CFX_WideString m_ws1; |
256 CFX_WideString m_ws2; | 257 CFX_WideString m_ws2; |
257 }; | 258 }; |
258 | 259 |
259 class CFDE_BlockBuffer : public CFX_Target { | 260 class CFDE_BlockBuffer : public CFX_Target { |
260 public: | 261 public: |
261 CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); | 262 CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); |
262 ~CFDE_BlockBuffer(); | 263 ~CFDE_BlockBuffer() override; |
263 | 264 |
264 FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024); | 265 FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024); |
265 FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } | 266 FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } |
266 void ReleaseBuffer() { delete this; } | 267 |
267 FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); | 268 FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); |
268 inline int32_t GetAllocStep() const { return m_iAllocStep; } | 269 inline int32_t GetAllocStep() const { return m_iAllocStep; } |
269 inline int32_t& GetDataLengthRef() { return m_iDataLength; } | 270 inline int32_t& GetDataLengthRef() { return m_iDataLength; } |
270 inline void Reset(FX_BOOL bReserveData = TRUE) { | 271 inline void Reset(FX_BOOL bReserveData = TRUE) { |
271 if (!bReserveData) { | 272 if (!bReserveData) { |
272 m_iStartPosition = 0; | 273 m_iStartPosition = 0; |
273 } | 274 } |
274 m_iDataLength = 0; | 275 m_iDataLength = 0; |
275 } | 276 } |
276 void SetTextChar(int32_t iIndex, FX_WCHAR ch); | 277 void SetTextChar(int32_t iIndex, FX_WCHAR ch); |
(...skipping 10 matching lines...) Expand all Loading... |
287 CFX_ArrayTemplate<FX_WCHAR*> m_BlockArray; | 288 CFX_ArrayTemplate<FX_WCHAR*> m_BlockArray; |
288 int32_t m_iDataLength; | 289 int32_t m_iDataLength; |
289 int32_t m_iBufferSize; | 290 int32_t m_iBufferSize; |
290 int32_t m_iAllocStep; | 291 int32_t m_iAllocStep; |
291 int32_t m_iStartPosition; | 292 int32_t m_iStartPosition; |
292 }; | 293 }; |
293 | 294 |
294 class CFDE_XMLSyntaxParser : public CFX_Target { | 295 class CFDE_XMLSyntaxParser : public CFX_Target { |
295 public: | 296 public: |
296 CFDE_XMLSyntaxParser(); | 297 CFDE_XMLSyntaxParser(); |
297 ~CFDE_XMLSyntaxParser(); | 298 ~CFDE_XMLSyntaxParser() override; |
298 void Release() { delete this; } | 299 |
299 void Init(IFX_Stream* pStream, | 300 void Init(IFX_Stream* pStream, |
300 int32_t iXMLPlaneSize, | 301 int32_t iXMLPlaneSize, |
301 int32_t iTextDataSize = 256); | 302 int32_t iTextDataSize = 256); |
302 FDE_XmlSyntaxResult DoSyntaxParse(); | 303 FDE_XmlSyntaxResult DoSyntaxParse(); |
303 int32_t GetStatus() const; | 304 int32_t GetStatus() const; |
304 int32_t GetCurrentPos() const { | 305 int32_t GetCurrentPos() const { |
305 return m_iParsedChars + (m_pStart - m_pBuffer); | 306 return m_iParsedChars + (m_pStart - m_pBuffer); |
306 } | 307 } |
307 FX_FILESIZE GetCurrentBinaryPos() const; | 308 FX_FILESIZE GetCurrentBinaryPos() const; |
308 int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } | 309 int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 FDE_XmlSyntaxResult m_syntaxParserResult; | 375 FDE_XmlSyntaxResult m_syntaxParserResult; |
375 FDE_XmlSyntaxState m_syntaxParserState; | 376 FDE_XmlSyntaxState m_syntaxParserState; |
376 FX_WCHAR m_wQuotationMark; | 377 FX_WCHAR m_wQuotationMark; |
377 int32_t m_iEntityStart; | 378 int32_t m_iEntityStart; |
378 CFX_DWordStack m_SkipStack; | 379 CFX_DWordStack m_SkipStack; |
379 FX_WCHAR m_SkipChar; | 380 FX_WCHAR m_SkipChar; |
380 inline void ParseTextChar(FX_WCHAR ch); | 381 inline void ParseTextChar(FX_WCHAR ch); |
381 }; | 382 }; |
382 | 383 |
383 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ | 384 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ |
OLD | NEW |