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 <memory> |
| 11 |
10 #include "core/fxcrt/fx_system.h" | 12 #include "core/fxcrt/fx_system.h" |
11 #include "xfa/fde/xml/fde_xml.h" | 13 #include "xfa/fde/xml/fde_xml.h" |
12 #include "xfa/fgas/crt/fgas_memory.h" | 14 #include "xfa/fgas/crt/fgas_memory.h" |
13 #include "xfa/fgas/crt/fgas_stream.h" | 15 #include "xfa/fgas/crt/fgas_stream.h" |
14 #include "xfa/fgas/crt/fgas_utils.h" | 16 #include "xfa/fgas/crt/fgas_utils.h" |
15 | 17 |
16 class CFDE_BlockBuffer; | 18 class CFDE_BlockBuffer; |
17 class CFDE_XMLInstruction; | 19 class CFDE_XMLInstruction; |
18 class CFDE_XMLElement; | 20 class CFDE_XMLElement; |
19 class CFDE_XMLText; | 21 class CFDE_XMLText; |
20 class CFDE_XMLDoc; | 22 class CFDE_XMLDoc; |
21 class CFDE_XMLDOMParser; | 23 class CFDE_XMLDOMParser; |
22 class CFDE_XMLParser; | |
23 class CFDE_XMLSyntaxParser; | 24 class CFDE_XMLSyntaxParser; |
| 25 class IFDE_XMLParser; |
24 | 26 |
25 class CFDE_XMLNode : public CFX_Target { | 27 class CFDE_XMLNode : public CFX_Target { |
26 public: | 28 public: |
27 enum NodeItem { | 29 enum NodeItem { |
28 Root = 0, | 30 Root = 0, |
29 Parent, | 31 Parent, |
30 FirstSibling, | 32 FirstSibling, |
31 PriorSibling, | 33 PriorSibling, |
32 NextSibling, | 34 NextSibling, |
33 LastSibling, | 35 LastSibling, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 void SetCharData(const CFX_WideString& wsCData) { m_wsCharData = wsCData; } | 188 void SetCharData(const CFX_WideString& wsCData) { m_wsCharData = wsCData; } |
187 | 189 |
188 CFX_WideString m_wsCharData; | 190 CFX_WideString m_wsCharData; |
189 }; | 191 }; |
190 | 192 |
191 class CFDE_XMLDoc : public CFX_Target { | 193 class CFDE_XMLDoc : public CFX_Target { |
192 public: | 194 public: |
193 CFDE_XMLDoc(); | 195 CFDE_XMLDoc(); |
194 ~CFDE_XMLDoc() override; | 196 ~CFDE_XMLDoc() override; |
195 | 197 |
196 bool LoadXML(CFDE_XMLParser* pXMLParser); | 198 bool LoadXML(std::unique_ptr<IFDE_XMLParser> pXMLParser); |
197 int32_t DoLoad(IFX_Pause* pPause = nullptr); | 199 int32_t DoLoad(IFX_Pause* pPause = nullptr); |
198 void CloseXML(); | 200 void CloseXML(); |
199 CFDE_XMLNode* GetRoot() const { return m_pRoot; } | 201 CFDE_XMLNode* GetRoot() const { return m_pRoot; } |
200 void SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream, bool bSaveBOM = true); | 202 void SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream, bool bSaveBOM = true); |
201 void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream, | 203 void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream, |
202 CFDE_XMLNode* pNode); | 204 CFDE_XMLNode* pNode); |
203 | 205 |
204 protected: | 206 protected: |
205 void Reset(bool bInitRoot); | 207 void Reset(bool bInitRoot); |
206 void ReleaseParser(); | 208 void ReleaseParser(); |
207 | 209 |
208 CFX_RetainPtr<IFGAS_Stream> m_pStream; | 210 CFX_RetainPtr<IFGAS_Stream> m_pStream; |
209 int32_t m_iStatus; | 211 int32_t m_iStatus; |
210 CFDE_XMLNode* m_pRoot; | 212 CFDE_XMLNode* m_pRoot; |
211 CFDE_XMLSyntaxParser* m_pSyntaxParser; | 213 CFDE_XMLSyntaxParser* m_pSyntaxParser; |
212 CFDE_XMLParser* m_pXMLParser; | 214 std::unique_ptr<IFDE_XMLParser> m_pXMLParser; |
213 }; | 215 }; |
214 | 216 |
215 class CFDE_XMLParser { | 217 class IFDE_XMLParser { |
216 public: | 218 public: |
217 virtual ~CFDE_XMLParser() {} | 219 virtual ~IFDE_XMLParser() {} |
218 | |
219 virtual void Release() = 0; | |
220 virtual int32_t DoParser(IFX_Pause* pPause) = 0; | 220 virtual int32_t DoParser(IFX_Pause* pPause) = 0; |
221 }; | 221 }; |
222 | 222 |
223 class CFDE_BlockBuffer : public CFX_Target { | 223 class CFDE_BlockBuffer : public CFX_Target { |
224 public: | 224 public: |
225 explicit CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); | 225 explicit CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); |
226 ~CFDE_BlockBuffer() override; | 226 ~CFDE_BlockBuffer() override; |
227 | 227 |
228 bool InitBuffer(int32_t iBufferSize = 1024 * 1024); | 228 bool InitBuffer(int32_t iBufferSize = 1024 * 1024); |
229 bool IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } | 229 bool IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 int32_t m_iTextDataLength; | 343 int32_t m_iTextDataLength; |
344 FDE_XmlSyntaxResult m_syntaxParserResult; | 344 FDE_XmlSyntaxResult m_syntaxParserResult; |
345 FDE_XmlSyntaxState m_syntaxParserState; | 345 FDE_XmlSyntaxState m_syntaxParserState; |
346 FX_WCHAR m_wQuotationMark; | 346 FX_WCHAR m_wQuotationMark; |
347 int32_t m_iEntityStart; | 347 int32_t m_iEntityStart; |
348 CFX_StackTemplate<uint32_t> m_SkipStack; | 348 CFX_StackTemplate<uint32_t> m_SkipStack; |
349 FX_WCHAR m_SkipChar; | 349 FX_WCHAR m_SkipChar; |
350 }; | 350 }; |
351 | 351 |
352 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ | 352 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ |
OLD | NEW |