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/fx_system.h" | 10 #include "core/fxcrt/fx_system.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 CFDE_XMLNode* GetPath(const FX_WCHAR* pPath, | 57 CFDE_XMLNode* GetPath(const FX_WCHAR* pPath, |
58 int32_t iLength = -1, | 58 int32_t iLength = -1, |
59 bool bQualifiedName = true) const; | 59 bool bQualifiedName = true) const; |
60 | 60 |
61 int32_t GetNodeLevel() const; | 61 int32_t GetNodeLevel() const; |
62 CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const; | 62 CFDE_XMLNode* GetNodeItem(CFDE_XMLNode::NodeItem eItem) const; |
63 bool InsertNodeItem(CFDE_XMLNode::NodeItem eItem, CFDE_XMLNode* pNode); | 63 bool InsertNodeItem(CFDE_XMLNode::NodeItem eItem, CFDE_XMLNode* pNode); |
64 CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem); | 64 CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem); |
65 | 65 |
66 void SaveXMLNode(IFGAS_Stream* pXMLStream); | 66 void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream); |
67 | 67 |
68 CFDE_XMLNode* m_pParent; | 68 CFDE_XMLNode* m_pParent; |
69 CFDE_XMLNode* m_pChild; | 69 CFDE_XMLNode* m_pChild; |
70 CFDE_XMLNode* m_pPrior; | 70 CFDE_XMLNode* m_pPrior; |
71 CFDE_XMLNode* m_pNext; | 71 CFDE_XMLNode* m_pNext; |
72 }; | 72 }; |
73 | 73 |
74 class CFDE_XMLInstruction : public CFDE_XMLNode { | 74 class CFDE_XMLInstruction : public CFDE_XMLNode { |
75 public: | 75 public: |
76 explicit CFDE_XMLInstruction(const CFX_WideString& wsTarget); | 76 explicit CFDE_XMLInstruction(const CFX_WideString& wsTarget); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 class CFDE_XMLDoc : public CFX_Target { | 191 class CFDE_XMLDoc : public CFX_Target { |
192 public: | 192 public: |
193 CFDE_XMLDoc(); | 193 CFDE_XMLDoc(); |
194 ~CFDE_XMLDoc() override; | 194 ~CFDE_XMLDoc() override; |
195 | 195 |
196 bool LoadXML(CFDE_XMLParser* pXMLParser); | 196 bool LoadXML(CFDE_XMLParser* pXMLParser); |
197 int32_t DoLoad(IFX_Pause* pPause = nullptr); | 197 int32_t DoLoad(IFX_Pause* pPause = nullptr); |
198 void CloseXML(); | 198 void CloseXML(); |
199 CFDE_XMLNode* GetRoot() const { return m_pRoot; } | 199 CFDE_XMLNode* GetRoot() const { return m_pRoot; } |
200 void SaveXML(IFGAS_Stream* pXMLStream = nullptr, bool bSaveBOM = true); | 200 void SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream, bool bSaveBOM = true); |
201 void SaveXMLNode(IFGAS_Stream* pXMLStream, CFDE_XMLNode* pNode); | 201 void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream, |
| 202 CFDE_XMLNode* pNode); |
202 | 203 |
203 protected: | 204 protected: |
204 void Reset(bool bInitRoot); | 205 void Reset(bool bInitRoot); |
205 void ReleaseParser(); | 206 void ReleaseParser(); |
206 | 207 |
207 IFGAS_Stream* m_pStream; | 208 CFX_RetainPtr<IFGAS_Stream> m_pStream; |
208 int32_t m_iStatus; | 209 int32_t m_iStatus; |
209 CFDE_XMLNode* m_pRoot; | 210 CFDE_XMLNode* m_pRoot; |
210 CFDE_XMLSyntaxParser* m_pSyntaxParser; | 211 CFDE_XMLSyntaxParser* m_pSyntaxParser; |
211 CFDE_XMLParser* m_pXMLParser; | 212 CFDE_XMLParser* m_pXMLParser; |
212 }; | 213 }; |
213 | 214 |
214 class CFDE_XMLParser { | 215 class CFDE_XMLParser { |
215 public: | 216 public: |
216 virtual ~CFDE_XMLParser() {} | 217 virtual ~CFDE_XMLParser() {} |
217 | 218 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 int32_t m_iAllocStep; | 255 int32_t m_iAllocStep; |
255 int32_t m_iStartPosition; | 256 int32_t m_iStartPosition; |
256 }; | 257 }; |
257 | 258 |
258 class CFDE_XMLSyntaxParser : public CFX_Target { | 259 class CFDE_XMLSyntaxParser : public CFX_Target { |
259 public: | 260 public: |
260 CFDE_XMLSyntaxParser(); | 261 CFDE_XMLSyntaxParser(); |
261 ~CFDE_XMLSyntaxParser() override; | 262 ~CFDE_XMLSyntaxParser() override; |
262 | 263 |
263 void Release() { delete this; } | 264 void Release() { delete this; } |
264 void Init(IFGAS_Stream* pStream, | 265 void Init(const CFX_RetainPtr<IFGAS_Stream>& pStream, |
265 int32_t iXMLPlaneSize, | 266 int32_t iXMLPlaneSize, |
266 int32_t iTextDataSize = 256); | 267 int32_t iTextDataSize = 256); |
267 | 268 |
268 FDE_XmlSyntaxResult DoSyntaxParse(); | 269 FDE_XmlSyntaxResult DoSyntaxParse(); |
269 | 270 |
270 int32_t GetStatus() const; | 271 int32_t GetStatus() const; |
271 int32_t GetCurrentPos() const { | 272 int32_t GetCurrentPos() const { |
272 return m_iParsedChars + (m_pStart - m_pBuffer); | 273 return m_iParsedChars + (m_pStart - m_pBuffer); |
273 } | 274 } |
274 FX_FILESIZE GetCurrentBinaryPos() const; | 275 FX_FILESIZE GetCurrentBinaryPos() const; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 SkipDeclNode, | 314 SkipDeclNode, |
314 DeclCharData, | 315 DeclCharData, |
315 SkipComment, | 316 SkipComment, |
316 SkipCommentOrDecl, | 317 SkipCommentOrDecl, |
317 SkipCData, | 318 SkipCData, |
318 TargetData | 319 TargetData |
319 }; | 320 }; |
320 | 321 |
321 void ParseTextChar(FX_WCHAR ch); | 322 void ParseTextChar(FX_WCHAR ch); |
322 | 323 |
323 IFGAS_Stream* m_pStream; | 324 CFX_RetainPtr<IFGAS_Stream> m_pStream; |
324 int32_t m_iXMLPlaneSize; | 325 int32_t m_iXMLPlaneSize; |
325 int32_t m_iCurrentPos; | 326 int32_t m_iCurrentPos; |
326 int32_t m_iCurrentNodeNum; | 327 int32_t m_iCurrentNodeNum; |
327 int32_t m_iLastNodeNum; | 328 int32_t m_iLastNodeNum; |
328 int32_t m_iParsedChars; | 329 int32_t m_iParsedChars; |
329 int32_t m_iParsedBytes; | 330 int32_t m_iParsedBytes; |
330 FX_WCHAR* m_pBuffer; | 331 FX_WCHAR* m_pBuffer; |
331 int32_t m_iBufferChars; | 332 int32_t m_iBufferChars; |
332 bool m_bEOS; | 333 bool m_bEOS; |
333 FX_WCHAR* m_pStart; | 334 FX_WCHAR* m_pStart; |
334 FX_WCHAR* m_pEnd; | 335 FX_WCHAR* m_pEnd; |
335 FDE_XMLNODE m_CurNode; | 336 FDE_XMLNODE m_CurNode; |
336 CFX_StackTemplate<FDE_XMLNODE> m_XMLNodeStack; | 337 CFX_StackTemplate<FDE_XMLNODE> m_XMLNodeStack; |
337 CFDE_BlockBuffer m_BlockBuffer; | 338 CFDE_BlockBuffer m_BlockBuffer; |
338 int32_t m_iAllocStep; | 339 int32_t m_iAllocStep; |
339 int32_t& m_iDataLength; | 340 int32_t& m_iDataLength; |
340 FX_WCHAR* m_pCurrentBlock; | 341 FX_WCHAR* m_pCurrentBlock; |
341 int32_t m_iIndexInBlock; | 342 int32_t m_iIndexInBlock; |
342 int32_t m_iTextDataLength; | 343 int32_t m_iTextDataLength; |
343 FDE_XmlSyntaxResult m_syntaxParserResult; | 344 FDE_XmlSyntaxResult m_syntaxParserResult; |
344 FDE_XmlSyntaxState m_syntaxParserState; | 345 FDE_XmlSyntaxState m_syntaxParserState; |
345 FX_WCHAR m_wQuotationMark; | 346 FX_WCHAR m_wQuotationMark; |
346 int32_t m_iEntityStart; | 347 int32_t m_iEntityStart; |
347 CFX_StackTemplate<uint32_t> m_SkipStack; | 348 CFX_StackTemplate<uint32_t> m_SkipStack; |
348 FX_WCHAR m_SkipChar; | 349 FX_WCHAR m_SkipChar; |
349 }; | 350 }; |
350 | 351 |
351 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ | 352 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ |
OLD | NEW |