From f82efcc72fa16b145f101b38ea55d674278e32a1 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 8 May 2017 17:08:08 -0400 Subject: Remove editint.h and create individual headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl creates a cpdf_objectstream and cpdf_xrefstream headers from the editint header. Change-Id: I857981fa055ee9296cbd344860e55c67acf200ce Reviewed-on: https://pdfium-review.googlesource.com/5113 Commit-Queue: dsinclair Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña --- BUILD.gn | 3 +- core/fpdfapi/edit/cpdf_objectstream.h | 40 ++++++++++++++++++ core/fpdfapi/edit/cpdf_xrefstream.h | 50 ++++++++++++++++++++++ core/fpdfapi/edit/editint.h | 77 ---------------------------------- core/fpdfapi/edit/fpdf_edit_create.cpp | 14 +++---- 5 files changed, 99 insertions(+), 85 deletions(-) create mode 100644 core/fpdfapi/edit/cpdf_objectstream.h create mode 100644 core/fpdfapi/edit/cpdf_xrefstream.h delete mode 100644 core/fpdfapi/edit/editint.h diff --git a/BUILD.gn b/BUILD.gn index 73d339fa6f..adf318e234 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -436,9 +436,10 @@ static_library("fpdfapi") { "core/fpdfapi/cpdf_pagerendercontext.cpp", "core/fpdfapi/cpdf_pagerendercontext.h", "core/fpdfapi/edit/cpdf_creator.h", + "core/fpdfapi/edit/cpdf_objectstream.h", "core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp", "core/fpdfapi/edit/cpdf_pagecontentgenerator.h", - "core/fpdfapi/edit/editint.h", + "core/fpdfapi/edit/cpdf_xrefstream.h", "core/fpdfapi/edit/fpdf_edit_create.cpp", "core/fpdfapi/font/cpdf_cidfont.cpp", "core/fpdfapi/font/cpdf_cidfont.h", diff --git a/core/fpdfapi/edit/cpdf_objectstream.h b/core/fpdfapi/edit/cpdf_objectstream.h new file mode 100644 index 0000000000..3e5c5a72a9 --- /dev/null +++ b/core/fpdfapi/edit/cpdf_objectstream.h @@ -0,0 +1,40 @@ +// Copyright 2017 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_EDIT_CPDF_OBJECTSTREAM_H_ +#define CORE_FPDFAPI_EDIT_CPDF_OBJECTSTREAM_H_ + +#include + +#include "core/fxcrt/fx_basic.h" + +class CPDF_Creator; +class CPDF_Object; + +class CPDF_ObjectStream { + public: + struct Item { + uint32_t objnum; + FX_STRSIZE offset; + }; + + CPDF_ObjectStream(); + ~CPDF_ObjectStream(); + + void Start(); + FX_FILESIZE End(CPDF_Creator* pCreator); + void CompressIndirectObject(uint32_t dwObjNum, const CPDF_Object* pObj); + void CompressIndirectObject(uint32_t dwObjNum, + const uint8_t* pBuffer, + uint32_t dwSize); + + std::vector m_Items; + CFX_ByteTextBuf m_Buffer; + uint32_t m_dwObjNum; + int32_t m_index; +}; + +#endif // CORE_FPDFAPI_EDIT_CPDF_OBJECTSTREAM_H_ diff --git a/core/fpdfapi/edit/cpdf_xrefstream.h b/core/fpdfapi/edit/cpdf_xrefstream.h new file mode 100644 index 0000000000..cb11261f9f --- /dev/null +++ b/core/fpdfapi/edit/cpdf_xrefstream.h @@ -0,0 +1,50 @@ +// Copyright 2017 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_EDIT_CPDF_XREFSTREAM_H_ +#define CORE_FPDFAPI_EDIT_CPDF_XREFSTREAM_H_ + +#include + +class CPDF_Creator; +class CPDF_Object; + +class CPDF_XRefStream { + public: + struct Index { + uint32_t objnum; + uint32_t count; + }; + + CPDF_XRefStream(); + ~CPDF_XRefStream(); + + bool Start(); + int32_t CompressIndirectObject(uint32_t dwObjNum, + const CPDF_Object* pObj, + CPDF_Creator* pCreator); + int32_t CompressIndirectObject(uint32_t dwObjNum, + const uint8_t* pBuffer, + uint32_t dwSize, + CPDF_Creator* pCreator); + bool End(CPDF_Creator* pCreator, bool bEOF); + void AddObjectNumberToIndexArray(uint32_t objnum); + bool EndXRefStream(CPDF_Creator* pCreator); + + std::vector m_IndexArray; + FX_FILESIZE m_PrevOffset; + uint32_t m_dwTempObjNum; + + protected: + int32_t EndObjectStream(CPDF_Creator* pCreator, bool bEOF); + bool GenerateXRefStream(CPDF_Creator* pCreator, bool bEOF); + + size_t m_iSeg; + CPDF_ObjectStream m_ObjStream; + CFX_ByteTextBuf m_Buffer; +}; + +#endif // CORE_FPDFAPI_EDIT_CPDF_XREFSTREAM_H_ diff --git a/core/fpdfapi/edit/editint.h b/core/fpdfapi/edit/editint.h deleted file mode 100644 index 881c2cca36..0000000000 --- a/core/fpdfapi/edit/editint.h +++ /dev/null @@ -1,77 +0,0 @@ -// 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_EDIT_EDITINT_H_ -#define CORE_FPDFAPI_EDIT_EDITINT_H_ - -#include - -#include "core/fxcrt/fx_basic.h" -#include "core/fxcrt/fx_stream.h" -#include "core/fxcrt/fx_system.h" - -class CPDF_Creator; -class CPDF_Object; - -class CPDF_ObjectStream { - public: - struct Item { - uint32_t objnum; - FX_STRSIZE offset; - }; - - CPDF_ObjectStream(); - ~CPDF_ObjectStream(); - - void Start(); - FX_FILESIZE End(CPDF_Creator* pCreator); - void CompressIndirectObject(uint32_t dwObjNum, const CPDF_Object* pObj); - void CompressIndirectObject(uint32_t dwObjNum, - const uint8_t* pBuffer, - uint32_t dwSize); - - std::vector m_Items; - CFX_ByteTextBuf m_Buffer; - uint32_t m_dwObjNum; - int32_t m_index; -}; - -class CPDF_XRefStream { - public: - struct Index { - uint32_t objnum; - uint32_t count; - }; - - CPDF_XRefStream(); - ~CPDF_XRefStream(); - - bool Start(); - int32_t CompressIndirectObject(uint32_t dwObjNum, - const CPDF_Object* pObj, - CPDF_Creator* pCreator); - int32_t CompressIndirectObject(uint32_t dwObjNum, - const uint8_t* pBuffer, - uint32_t dwSize, - CPDF_Creator* pCreator); - bool End(CPDF_Creator* pCreator, bool bEOF = false); - void AddObjectNumberToIndexArray(uint32_t objnum); - bool EndXRefStream(CPDF_Creator* pCreator); - - std::vector m_IndexArray; - FX_FILESIZE m_PrevOffset; - uint32_t m_dwTempObjNum; - - protected: - int32_t EndObjectStream(CPDF_Creator* pCreator, bool bEOF = true); - bool GenerateXRefStream(CPDF_Creator* pCreator, bool bEOF); - - size_t m_iSeg; - CPDF_ObjectStream m_ObjStream; - CFX_ByteTextBuf m_Buffer; -}; - -#endif // CORE_FPDFAPI_EDIT_EDITINT_H_ diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp index ecae681eb0..42fe13d4e9 100644 --- a/core/fpdfapi/edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/edit/fpdf_edit_create.cpp @@ -4,12 +4,12 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fpdfapi/edit/editint.h" - #include #include #include "core/fpdfapi/edit/cpdf_creator.h" +#include "core/fpdfapi/edit/cpdf_objectstream.h" +#include "core/fpdfapi/edit/cpdf_xrefstream.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_crypto_handler.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" @@ -420,7 +420,7 @@ int32_t CPDF_XRefStream::CompressIndirectObject(uint32_t dwObjNum, m_ObjStream.m_Buffer.GetLength() < kObjectStreamMaxLength) { return 1; } - return EndObjectStream(pCreator); + return EndObjectStream(pCreator, true); } int32_t CPDF_XRefStream::CompressIndirectObject(uint32_t dwObjNum, @@ -436,7 +436,7 @@ int32_t CPDF_XRefStream::CompressIndirectObject(uint32_t dwObjNum, m_ObjStream.m_Buffer.GetLength() < kObjectStreamMaxLength) { return 1; } - return EndObjectStream(pCreator); + return EndObjectStream(pCreator, true); } int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator* pCreator, bool bEOF) { @@ -728,7 +728,7 @@ int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) { return -1; if (!IsXRefNeedEnd()) return 0; - if (!m_pXRefStream->End(this)) + if (!m_pXRefStream->End(this, false)) return -1; if (!m_pXRefStream->Start()) return -1; @@ -747,7 +747,7 @@ int32_t CPDF_Creator::WriteIndirectObjectToStream(uint32_t objnum, return iRet; if (!IsXRefNeedEnd()) return 0; - if (!m_pXRefStream->End(this)) + if (!m_pXRefStream->End(this, false)) return -1; if (!m_pXRefStream->Start()) return -1; @@ -761,7 +761,7 @@ int32_t CPDF_Creator::AppendObjectNumberToXRef(uint32_t objnum) { m_pXRefStream->AddObjectNumberToIndexArray(objnum); if (!IsXRefNeedEnd()) return 0; - if (!m_pXRefStream->End(this)) + if (!m_pXRefStream->End(this, false)) return -1; if (!m_pXRefStream->Start()) return -1; -- cgit v1.2.3