Home | History | Annotate | Download | only in edit
      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_EDIT_EDITINT_H_
      8 #define CORE_FPDFAPI_EDIT_EDITINT_H_
      9 
     10 #include <vector>
     11 
     12 #include "core/fxcrt/fx_basic.h"
     13 #include "core/fxcrt/fx_stream.h"
     14 #include "core/fxcrt/fx_system.h"
     15 
     16 class CPDF_Creator;
     17 class CPDF_Object;
     18 
     19 class CPDF_ObjectStream {
     20  public:
     21   struct Item {
     22     uint32_t objnum;
     23     FX_STRSIZE offset;
     24   };
     25 
     26   CPDF_ObjectStream();
     27   ~CPDF_ObjectStream();
     28 
     29   void Start();
     30   FX_FILESIZE End(CPDF_Creator* pCreator);
     31   void CompressIndirectObject(uint32_t dwObjNum, const CPDF_Object* pObj);
     32   void CompressIndirectObject(uint32_t dwObjNum,
     33                               const uint8_t* pBuffer,
     34                               uint32_t dwSize);
     35 
     36   std::vector<Item> m_Items;
     37   CFX_ByteTextBuf m_Buffer;
     38   uint32_t m_dwObjNum;
     39   int32_t m_index;
     40 };
     41 
     42 class CPDF_XRefStream {
     43  public:
     44   struct Index {
     45     uint32_t objnum;
     46     uint32_t count;
     47   };
     48 
     49   CPDF_XRefStream();
     50   ~CPDF_XRefStream();
     51 
     52   bool Start();
     53   int32_t CompressIndirectObject(uint32_t dwObjNum,
     54                                  const CPDF_Object* pObj,
     55                                  CPDF_Creator* pCreator);
     56   int32_t CompressIndirectObject(uint32_t dwObjNum,
     57                                  const uint8_t* pBuffer,
     58                                  uint32_t dwSize,
     59                                  CPDF_Creator* pCreator);
     60   bool End(CPDF_Creator* pCreator, bool bEOF = false);
     61   void AddObjectNumberToIndexArray(uint32_t objnum);
     62   bool EndXRefStream(CPDF_Creator* pCreator);
     63 
     64   std::vector<Index> m_IndexArray;
     65   FX_FILESIZE m_PrevOffset;
     66   uint32_t m_dwTempObjNum;
     67 
     68  protected:
     69   int32_t EndObjectStream(CPDF_Creator* pCreator, bool bEOF = true);
     70   bool GenerateXRefStream(CPDF_Creator* pCreator, bool bEOF);
     71 
     72   size_t m_iSeg;
     73   CPDF_ObjectStream m_ObjStream;
     74   CFX_ByteTextBuf m_Buffer;
     75 };
     76 
     77 #endif  // CORE_FPDFAPI_EDIT_EDITINT_H_
     78