• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 _FXFA_FORMFILLER_CHECKSUM_IMP_H
8 #define _FXFA_FORMFILLER_CHECKSUM_IMP_H
9 class CXFA_SAXReaderHandler;
10 class CXFA_ChecksumContext;
11 class CXFA_SAXContext {
12  public:
CXFA_SAXContext()13   CXFA_SAXContext() : m_eNode(FX_SAXNODE_Unknown) {}
14   CFX_ByteTextBuf m_TextBuf;
15   CFX_ByteString m_bsTagName;
16   FX_SAXNODE m_eNode;
17 };
18 class CXFA_SAXReaderHandler : public IFX_SAXReaderHandler {
19  public:
20   CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext);
21   virtual ~CXFA_SAXReaderHandler();
22   virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName,
23                            FX_SAXNODE eType,
24                            FX_DWORD dwStartPos);
25   virtual void OnTagAttribute(void* pTag,
26                               const CFX_ByteStringC& bsAttri,
27                               const CFX_ByteStringC& bsValue);
28   virtual void OnTagBreak(void* pTag);
29   virtual void OnTagData(void* pTag,
30                          FX_SAXNODE eType,
31                          const CFX_ByteStringC& bsData,
32                          FX_DWORD dwStartPos);
33   virtual void OnTagClose(void* pTag, FX_DWORD dwEndPos);
34   virtual void OnTagEnd(void* pTag,
35                         const CFX_ByteStringC& bsTagName,
36                         FX_DWORD dwEndPos);
37 
38   virtual void OnTargetData(void* pTag,
39                             FX_SAXNODE eType,
40                             const CFX_ByteStringC& bsData,
41                             FX_DWORD dwStartPos);
42 
43  protected:
44   void UpdateChecksum(FX_BOOL bCheckSpace);
45   CXFA_ChecksumContext* m_pContext;
46   CXFA_SAXContext m_SAXContext;
47 };
48 class CXFA_ChecksumContext : public IXFA_ChecksumContext {
49  public:
50   CXFA_ChecksumContext();
51   virtual ~CXFA_ChecksumContext();
Release()52   virtual void Release() { delete this; }
53   virtual FX_BOOL StartChecksum();
54   virtual FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile,
55                                  FX_FILESIZE offset = 0,
56                                  size_t size = 0);
57   virtual void FinishChecksum();
58   virtual void GetChecksum(CFX_ByteString& bsChecksum);
59   void Update(const CFX_ByteStringC& bsText);
60 
61  protected:
62   IFX_SAXReader* m_pSAXReader;
63   uint8_t* m_pByteContext;
64   CFX_ByteString m_bsChecksum;
65 };
66 #endif
67