diff options
Diffstat (limited to 'core/fpdfapi/fpdf_edit')
-rw-r--r-- | core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 18 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp | 14 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_edit/include/cpdf_creator.h | 98 |
5 files changed, 125 insertions, 27 deletions
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp index ad77455949..6010a04369 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_content.cpp @@ -4,14 +4,13 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" #include "core/fpdfapi/fpdf_page/pageint.h" -#include "core/include/fpdfapi/cpdf_array.h" -#include "core/include/fpdfapi/cpdf_dictionary.h" -#include "core/include/fpdfapi/cpdf_document.h" -#include "core/include/fpdfapi/fpdf_module.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/include/fpdfapi/fpdf_page.h" -#include "core/include/fpdfapi/fpdf_parser_decode.h" -#include "core/include/fpdfapi/fpdf_serial.h" CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& ar, CFX_Matrix& matrix) { ar << matrix.a << " " << matrix.b << " " << matrix.c << " " << matrix.d << " " diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 2dc2e3eb8e..da3c18fc3f 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -8,17 +8,17 @@ #include <vector> +#include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" #include "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h" #include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h" -#include "core/include/fpdfapi/cpdf_array.h" -#include "core/include/fpdfapi/cpdf_dictionary.h" -#include "core/include/fpdfapi/cpdf_document.h" -#include "core/include/fpdfapi/cpdf_parser.h" -#include "core/include/fpdfapi/cpdf_reference.h" -#include "core/include/fpdfapi/cpdf_string.h" -#include "core/include/fpdfapi/fpdf_parser_decode.h" -#include "core/include/fpdfapi/fpdf_serial.h" -#include "core/include/fpdfapi/ipdf_crypto_handler.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" +#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" +#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h" #include "core/include/fxcrt/fx_ext.h" #include "third_party/base/stl_util.h" diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 48e42e2a1f..121498ccd2 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -7,11 +7,12 @@ #include <limits.h> #include "core/fpdfapi/fpdf_page/pageint.h" -#include "core/include/fpdfapi/cpdf_array.h" -#include "core/include/fpdfapi/cpdf_dictionary.h" -#include "core/include/fpdfapi/cpdf_document.h" -#include "core/include/fpdfapi/cpdf_reference.h" -#include "core/include/fpdfapi/fpdf_module.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" +#include "core/fpdfapi/include/cpdf_modulemgr.h" +#include "core/fpdfapi/ipdf_rendermodule.h" #include "core/include/fpdfapi/fpdf_page.h" CPDF_Document::CPDF_Document() : CPDF_IndirectObjectHolder(NULL) { diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp index f3e6a439c2..fec596cdb2 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_image.cpp @@ -5,15 +5,15 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fpdfapi/fpdf_page/pageint.h" +#include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" +#include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" #include "core/fpdfapi/fpdf_render/render_int.h" -#include "core/include/fpdfapi/cpdf_array.h" -#include "core/include/fpdfapi/cpdf_boolean.h" -#include "core/include/fpdfapi/cpdf_dictionary.h" -#include "core/include/fpdfapi/cpdf_document.h" -#include "core/include/fpdfapi/cpdf_string.h" -#include "core/include/fpdfapi/fpdf_module.h" +#include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/include/fpdfapi/fpdf_page.h" -#include "core/include/fpdfapi/fpdf_render.h" #include "core/include/fxcodec/fx_codec.h" CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, FX_DWORD size) { diff --git a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h new file mode 100644 index 0000000000..5b5671b7e9 --- /dev/null +++ b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h @@ -0,0 +1,98 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_ +#define CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_ + +#include "core/include/fpdfapi/fpdf_page.h" +#include "core/include/fpdfapi/fpdf_pageobj.h" + +class CPDF_Parser; +class CPDF_XRefStream; +class IPDF_CryptoHandler; + +#define FPDFCREATE_INCREMENTAL 1 +#define FPDFCREATE_NO_ORIGINAL 2 +#define FPDFCREATE_PROGRESSIVE 4 +#define FPDFCREATE_OBJECTSTREAM 8 + +CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj); + +class CPDF_Creator { + public: + CPDF_Creator(CPDF_Document* pDoc); + ~CPDF_Creator(); + + void RemoveSecurity(); + bool Create(IFX_StreamWrite* pFile, FX_DWORD flags = 0); + int32_t Continue(IFX_Pause* pPause = NULL); + FX_BOOL SetFileVersion(int32_t fileVersion = 17); + + private: + friend class CPDF_ObjectStream; + friend class CPDF_XRefStream; + + bool Create(FX_DWORD flags); + void ResetStandardSecurity(); + void Clear(); + + void InitOldObjNumOffsets(); + void InitNewObjNumOffsets(); + void InitID(FX_BOOL bDefault = TRUE); + + void AppendNewObjNum(FX_DWORD objbum); + int32_t AppendObjectNumberToXRef(FX_DWORD objnum); + + int32_t WriteDoc_Stage1(IFX_Pause* pPause); + int32_t WriteDoc_Stage2(IFX_Pause* pPause); + int32_t WriteDoc_Stage3(IFX_Pause* pPause); + int32_t WriteDoc_Stage4(IFX_Pause* pPause); + + int32_t WriteOldIndirectObject(FX_DWORD objnum); + int32_t WriteOldObjs(IFX_Pause* pPause); + int32_t WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause); + int32_t WriteIndirectObj(const CPDF_Object* pObj); + int32_t WriteDirectObj(FX_DWORD objnum, + const CPDF_Object* pObj, + FX_BOOL bEncrypt = TRUE); + int32_t WriteIndirectObjectToStream(const CPDF_Object* pObj); + int32_t WriteIndirectObj(FX_DWORD objnum, const CPDF_Object* pObj); + int32_t WriteIndirectObjectToStream(FX_DWORD objnum, + const uint8_t* pBuffer, + FX_DWORD dwSize); + + int32_t WriteStream(const CPDF_Object* pStream, + FX_DWORD objnum, + IPDF_CryptoHandler* pCrypto); + + CPDF_Document* m_pDocument; + CPDF_Parser* m_pParser; + FX_BOOL m_bCompress; + FX_BOOL m_bSecurityChanged; + CPDF_Dictionary* m_pEncryptDict; + FX_DWORD m_dwEnryptObjNum; + FX_BOOL m_bEncryptCloned; + FX_BOOL m_bStandardSecurity; + IPDF_CryptoHandler* m_pCryptoHandler; + FX_BOOL m_bNewCrypto; + FX_BOOL m_bEncryptMetadata; + CPDF_Object* m_pMetadata; + CPDF_XRefStream* m_pXRefStream; + int32_t m_ObjectStreamSize; + FX_DWORD m_dwLastObjNum; + CFX_FileBufferArchive m_File; + FX_FILESIZE m_Offset; + int32_t m_iStage; + FX_DWORD m_dwFlags; + FX_POSITION m_Pos; + FX_FILESIZE m_XrefStart; + CFX_FileSizeListArray m_ObjectOffset; + CFX_DWordArray m_NewObjNumArray; + CPDF_Array* m_pIDArray; + int32_t m_FileVersion; +}; + +#endif // CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_ |