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