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 CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_ | |
8 #define CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_ | |
9 | |
10 #include <memory> | |
11 | |
12 #include "core/fxcrt/include/fx_basic.h" | |
13 | |
14 class CPDF_Array; | |
15 class CPDF_CryptoHandler; | |
16 class CPDF_Dictionary; | |
17 class CPDF_Document; | |
18 class CPDF_Object; | |
19 class CPDF_Parser; | |
20 class CPDF_XRefStream; | |
21 | |
22 #define FPDFCREATE_INCREMENTAL 1 | |
23 #define FPDFCREATE_NO_ORIGINAL 2 | |
24 #define FPDFCREATE_PROGRESSIVE 4 | |
25 #define FPDFCREATE_OBJECTSTREAM 8 | |
26 | |
27 CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj); | |
28 | |
29 class CPDF_Creator { | |
30 public: | |
31 explicit CPDF_Creator(CPDF_Document* pDoc); | |
32 ~CPDF_Creator(); | |
33 | |
34 void RemoveSecurity(); | |
35 bool Create(IFX_StreamWrite* pFile, uint32_t flags = 0); | |
36 int32_t Continue(IFX_Pause* pPause = nullptr); | |
37 FX_BOOL SetFileVersion(int32_t fileVersion = 17); | |
38 | |
39 private: | |
40 friend class CPDF_ObjectStream; | |
41 friend class CPDF_XRefStream; | |
42 | |
43 bool Create(uint32_t flags); | |
44 void ResetStandardSecurity(); | |
45 void Clear(); | |
46 | |
47 void InitOldObjNumOffsets(); | |
48 void InitNewObjNumOffsets(); | |
49 void InitID(FX_BOOL bDefault = TRUE); | |
50 | |
51 void AppendNewObjNum(uint32_t objbum); | |
52 int32_t AppendObjectNumberToXRef(uint32_t objnum); | |
53 | |
54 int32_t WriteDoc_Stage1(IFX_Pause* pPause); | |
55 int32_t WriteDoc_Stage2(IFX_Pause* pPause); | |
56 int32_t WriteDoc_Stage3(IFX_Pause* pPause); | |
57 int32_t WriteDoc_Stage4(IFX_Pause* pPause); | |
58 | |
59 int32_t WriteOldIndirectObject(uint32_t objnum); | |
60 int32_t WriteOldObjs(IFX_Pause* pPause); | |
61 int32_t WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause); | |
62 int32_t WriteIndirectObj(const CPDF_Object* pObj); | |
63 int32_t WriteDirectObj(uint32_t objnum, | |
64 const CPDF_Object* pObj, | |
65 FX_BOOL bEncrypt = TRUE); | |
66 int32_t WriteIndirectObjectToStream(const CPDF_Object* pObj); | |
67 int32_t WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj); | |
68 int32_t WriteIndirectObjectToStream(uint32_t objnum, | |
69 const uint8_t* pBuffer, | |
70 uint32_t dwSize); | |
71 | |
72 int32_t WriteStream(const CPDF_Object* pStream, | |
73 uint32_t objnum, | |
74 CPDF_CryptoHandler* pCrypto); | |
75 | |
76 CPDF_Document* const m_pDocument; | |
77 CPDF_Parser* const m_pParser; | |
78 FX_BOOL m_bSecurityChanged; | |
79 CPDF_Dictionary* m_pEncryptDict; | |
80 uint32_t m_dwEncryptObjNum; | |
81 FX_BOOL m_bEncryptCloned; | |
82 CPDF_CryptoHandler* m_pCryptoHandler; | |
83 // Whether this owns the crypto handler |m_pCryptoHandler|. | |
84 FX_BOOL m_bLocalCryptoHandler; | |
85 CPDF_Object* m_pMetadata; | |
86 std::unique_ptr<CPDF_XRefStream> m_pXRefStream; | |
87 int32_t m_ObjectStreamSize; | |
88 uint32_t m_dwLastObjNum; | |
89 CFX_FileBufferArchive m_File; | |
90 FX_FILESIZE m_Offset; | |
91 int32_t m_iStage; | |
92 uint32_t m_dwFlags; | |
93 FX_POSITION m_Pos; | |
94 FX_FILESIZE m_XrefStart; | |
95 CFX_FileSizeListArray m_ObjectOffset; | |
96 CFX_ArrayTemplate<uint32_t> m_NewObjNumArray; | |
97 std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> m_pIDArray; | |
98 int32_t m_FileVersion; | |
99 }; | |
100 | |
101 #endif // CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_ | |
OLD | NEW |