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_FXFA_INCLUDE_XFA_CHECKSUM_H_ | 7 #ifndef XFA_FXFA_INCLUDE_XFA_CHECKSUM_H_ |
8 #define XFA_FXFA_INCLUDE_XFA_CHECKSUM_H_ | 8 #define XFA_FXFA_INCLUDE_XFA_CHECKSUM_H_ |
9 | 9 |
10 #include "xfa/fgas/xml/fgas_sax.h" | 10 #include "xfa/fgas/xml/fgas_sax.h" |
11 #include "xfa/fxfa/include/fxfa.h" | 11 #include "xfa/fxfa/include/fxfa.h" |
12 | 12 |
13 class CXFA_SAXReaderHandler; | 13 class CXFA_SAXReaderHandler; |
14 class CXFA_ChecksumContext; | 14 class CXFA_ChecksumContext; |
15 | 15 |
16 class CXFA_SAXContext { | 16 class CXFA_SAXContext { |
17 public: | 17 public: |
18 CXFA_SAXContext() : m_eNode(FX_SAXNODE_Unknown) {} | 18 CXFA_SAXContext() : m_eNode(FX_SAXNODE_Unknown) {} |
| 19 |
19 CFX_ByteTextBuf m_TextBuf; | 20 CFX_ByteTextBuf m_TextBuf; |
20 CFX_ByteString m_bsTagName; | 21 CFX_ByteString m_bsTagName; |
21 FX_SAXNODE m_eNode; | 22 FX_SAXNODE m_eNode; |
22 }; | 23 }; |
23 class CXFA_SAXReaderHandler : public IFX_SAXReaderHandler { | 24 |
| 25 class CXFA_SAXReaderHandler { |
24 public: | 26 public: |
25 CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext); | 27 CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext); |
26 virtual ~CXFA_SAXReaderHandler(); | 28 ~CXFA_SAXReaderHandler(); |
27 virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName, | |
28 FX_SAXNODE eType, | |
29 uint32_t dwStartPos); | |
30 virtual void OnTagAttribute(void* pTag, | |
31 const CFX_ByteStringC& bsAttri, | |
32 const CFX_ByteStringC& bsValue); | |
33 virtual void OnTagBreak(void* pTag); | |
34 virtual void OnTagData(void* pTag, | |
35 FX_SAXNODE eType, | |
36 const CFX_ByteStringC& bsData, | |
37 uint32_t dwStartPos); | |
38 virtual void OnTagClose(void* pTag, uint32_t dwEndPos); | |
39 virtual void OnTagEnd(void* pTag, | |
40 const CFX_ByteStringC& bsTagName, | |
41 uint32_t dwEndPos); | |
42 | 29 |
43 virtual void OnTargetData(void* pTag, | 30 void* OnTagEnter(const CFX_ByteStringC& bsTagName, |
44 FX_SAXNODE eType, | 31 FX_SAXNODE eType, |
45 const CFX_ByteStringC& bsData, | 32 uint32_t dwStartPos); |
46 uint32_t dwStartPos); | 33 void OnTagAttribute(void* pTag, |
| 34 const CFX_ByteStringC& bsAttri, |
| 35 const CFX_ByteStringC& bsValue); |
| 36 void OnTagBreak(void* pTag); |
| 37 void OnTagData(void* pTag, |
| 38 FX_SAXNODE eType, |
| 39 const CFX_ByteStringC& bsData, |
| 40 uint32_t dwStartPos); |
| 41 void OnTagClose(void* pTag, uint32_t dwEndPos); |
| 42 void OnTagEnd(void* pTag, |
| 43 const CFX_ByteStringC& bsTagName, |
| 44 uint32_t dwEndPos); |
| 45 |
| 46 void OnTargetData(void* pTag, |
| 47 FX_SAXNODE eType, |
| 48 const CFX_ByteStringC& bsData, |
| 49 uint32_t dwStartPos); |
47 | 50 |
48 protected: | 51 protected: |
49 void UpdateChecksum(FX_BOOL bCheckSpace); | 52 void UpdateChecksum(FX_BOOL bCheckSpace); |
| 53 |
50 CXFA_ChecksumContext* m_pContext; | 54 CXFA_ChecksumContext* m_pContext; |
51 CXFA_SAXContext m_SAXContext; | 55 CXFA_SAXContext m_SAXContext; |
52 }; | 56 }; |
53 | 57 |
54 class CXFA_ChecksumContext { | 58 class CXFA_ChecksumContext { |
55 public: | 59 public: |
56 CXFA_ChecksumContext(); | 60 CXFA_ChecksumContext(); |
57 ~CXFA_ChecksumContext(); | 61 ~CXFA_ChecksumContext(); |
58 | 62 |
59 void Release() { delete this; } | 63 void Release() { delete this; } |
60 FX_BOOL StartChecksum(); | 64 void StartChecksum(); |
61 FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile, | 65 FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile, |
62 FX_FILESIZE offset = 0, | 66 FX_FILESIZE offset = 0, |
63 size_t size = 0); | 67 size_t size = 0); |
64 void FinishChecksum(); | 68 void FinishChecksum(); |
65 void GetChecksum(CFX_ByteString& bsChecksum); | 69 void GetChecksum(CFX_ByteString& bsChecksum); |
66 void Update(const CFX_ByteStringC& bsText); | 70 void Update(const CFX_ByteStringC& bsText); |
67 | 71 |
68 protected: | 72 protected: |
69 IFX_SAXReader* m_pSAXReader; | 73 CFX_SAXReader* m_pSAXReader; |
70 uint8_t* m_pByteContext; | 74 uint8_t* m_pByteContext; |
71 CFX_ByteString m_bsChecksum; | 75 CFX_ByteString m_bsChecksum; |
72 }; | 76 }; |
73 | 77 |
74 #endif // XFA_FXFA_INCLUDE_XFA_CHECKSUM_H_ | 78 #endif // XFA_FXFA_INCLUDE_XFA_CHECKSUM_H_ |
OLD | NEW |