Kill CFX_ArchiveLoader / CFX_ArchiveSaver and subclasses
[pdfium.git] / core / include / fpdfapi / fpdf_serial.h
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 CORE_INCLUDE_FPDFAPI_FPDF_SERIAL_H_
8 #define CORE_INCLUDE_FPDFAPI_FPDF_SERIAL_H_
9
10 #include "fpdf_page.h"
11 #include "fpdf_pageobj.h"
12
13 class CPDF_ObjectStream;
14 class CPDF_XRefStream;
15 CFX_ByteTextBuf& operator << (CFX_ByteTextBuf& buf, const CPDF_Object* pObj);
16 #define FPDFCREATE_INCREMENTAL          1
17 #define FPDFCREATE_NO_ORIGINAL          2
18 #define FPDFCREATE_PROGRESSIVE          4
19 #define FPDFCREATE_OBJECTSTREAM         8
20 class CPDF_Creator
21 {
22 public:
23
24     CPDF_Creator(CPDF_Document* pDoc);
25
26     ~CPDF_Creator();
27
28     void                                RemoveSecurity();
29
30     FX_BOOL                             Create(const FX_WCHAR* filename, FX_DWORD flags = 0);
31
32     FX_BOOL                             Create(const FX_CHAR* filename, FX_DWORD flags = 0);
33
34     FX_BOOL                             Create(IFX_StreamWrite* pFile, FX_DWORD flags = 0);
35
36     int32_t                     Continue(IFX_Pause *pPause = NULL);
37
38     FX_BOOL                             SetFileVersion(int32_t fileVersion = 17);
39 protected:
40
41     CPDF_Document*              m_pDocument;
42
43     CPDF_Parser*                m_pParser;
44
45     FX_BOOL                             m_bCompress;
46
47     FX_BOOL                             m_bSecurityChanged;
48
49     CPDF_Dictionary*    m_pEncryptDict;
50     FX_DWORD                    m_dwEnryptObjNum;
51     FX_BOOL                             m_bEncryptCloned;
52
53     FX_BOOL                             m_bStandardSecurity;
54
55     CPDF_CryptoHandler* m_pCryptoHandler;
56     FX_BOOL                             m_bNewCrypto;
57
58     FX_BOOL                             m_bEncryptMetadata;
59
60     CPDF_Object*                m_pMetadata;
61
62     CPDF_XRefStream*    m_pXRefStream;
63
64     int32_t                     m_ObjectStreamSize;
65
66     FX_DWORD                    m_dwLastObjNum;
67     FX_BOOL                             Create(FX_DWORD flags);
68     void                                ResetStandardSecurity();
69     void                                Clear();
70     int32_t                     WriteDoc_Stage1(IFX_Pause *pPause);
71     int32_t                     WriteDoc_Stage2(IFX_Pause *pPause);
72     int32_t                     WriteDoc_Stage3(IFX_Pause *pPause);
73     int32_t                     WriteDoc_Stage4(IFX_Pause *pPause);
74
75     CFX_FileBufferArchive       m_File;
76
77     FX_FILESIZE                 m_Offset;
78     void                                InitOldObjNumOffsets();
79     void                                InitNewObjNumOffsets();
80     void                                AppendNewObjNum(FX_DWORD objbum);
81     int32_t                     WriteOldIndirectObject(FX_DWORD objnum);
82     int32_t                     WriteOldObjs(IFX_Pause *pPause);
83     int32_t                     WriteNewObjs(FX_BOOL bIncremental, IFX_Pause *pPause);
84     int32_t                     WriteIndirectObj(const CPDF_Object* pObj);
85     int32_t                     WriteDirectObj(FX_DWORD objnum, const CPDF_Object* pObj, FX_BOOL bEncrypt = TRUE);
86     int32_t                     WriteIndirectObjectToStream(const CPDF_Object* pObj);
87     int32_t                     WriteIndirectObj(FX_DWORD objnum, const CPDF_Object* pObj);
88     int32_t                     WriteIndirectObjectToStream(FX_DWORD objnum, const uint8_t* pBuffer, FX_DWORD dwSize);
89     int32_t                     AppendObjectNumberToXRef(FX_DWORD objnum);
90     void                                InitID(FX_BOOL bDefault = TRUE);
91     int32_t                     WriteStream(const CPDF_Object* pStream, FX_DWORD objnum, CPDF_CryptoHandler* pCrypto);
92
93     int32_t                     m_iStage;
94     FX_DWORD                    m_dwFlags;
95     FX_POSITION                 m_Pos;
96     FX_FILESIZE                 m_XrefStart;
97
98     CFX_FileSizeListArray       m_ObjectOffset;
99
100     CFX_DWordListArray          m_ObjectSize;
101     CFX_DWordArray              m_NewObjNumArray;
102
103     CPDF_Array*                 m_pIDArray;
104
105     int32_t                     m_FileVersion;
106     friend class CPDF_ObjectStream;
107     friend class CPDF_XRefStream;
108 };
109
110 #endif  // CORE_INCLUDE_FPDFAPI_FPDF_SERIAL_H_