OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef XFA_SRC_FXFA_APP_XFA_CHECKSUM_H_ | |
8 #define XFA_SRC_FXFA_APP_XFA_CHECKSUM_H_ | |
9 | |
10 #include "xfa/include/fxfa/fxfa.h" | |
11 #include "xfa/src/fgas/xml/fgas_sax.h" | |
12 | |
13 class CXFA_SAXReaderHandler; | |
14 class CXFA_ChecksumContext; | |
15 | |
16 class CXFA_SAXContext { | |
17 public: | |
18 CXFA_SAXContext() : m_eNode(FX_SAXNODE_Unknown) {} | |
19 CFX_ByteTextBuf m_TextBuf; | |
20 CFX_ByteString m_bsTagName; | |
21 FX_SAXNODE m_eNode; | |
22 }; | |
23 class CXFA_SAXReaderHandler : public IFX_SAXReaderHandler { | |
24 public: | |
25 CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext); | |
26 virtual ~CXFA_SAXReaderHandler(); | |
27 virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName, | |
28 FX_SAXNODE eType, | |
29 FX_DWORD 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 FX_DWORD dwStartPos); | |
38 virtual void OnTagClose(void* pTag, FX_DWORD dwEndPos); | |
39 virtual void OnTagEnd(void* pTag, | |
40 const CFX_ByteStringC& bsTagName, | |
41 FX_DWORD dwEndPos); | |
42 | |
43 virtual void OnTargetData(void* pTag, | |
44 FX_SAXNODE eType, | |
45 const CFX_ByteStringC& bsData, | |
46 FX_DWORD dwStartPos); | |
47 | |
48 protected: | |
49 void UpdateChecksum(FX_BOOL bCheckSpace); | |
50 CXFA_ChecksumContext* m_pContext; | |
51 CXFA_SAXContext m_SAXContext; | |
52 }; | |
53 | |
54 class CXFA_ChecksumContext : public IXFA_ChecksumContext { | |
55 public: | |
56 CXFA_ChecksumContext(); | |
57 virtual ~CXFA_ChecksumContext(); | |
58 virtual void Release() { delete this; } | |
59 virtual FX_BOOL StartChecksum(); | |
60 virtual FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile, | |
61 FX_FILESIZE offset = 0, | |
62 size_t size = 0); | |
63 virtual void FinishChecksum(); | |
64 virtual void GetChecksum(CFX_ByteString& bsChecksum); | |
65 void Update(const CFX_ByteStringC& bsText); | |
66 | |
67 protected: | |
68 IFX_SAXReader* m_pSAXReader; | |
69 uint8_t* m_pByteContext; | |
70 CFX_ByteString m_bsChecksum; | |
71 }; | |
72 | |
73 #endif // XFA_SRC_FXFA_APP_XFA_CHECKSUM_H_ | |
OLD | NEW |