diff options
author | dsinclair <dsinclair@chromium.org> | 2016-08-17 12:45:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-17 12:45:26 -0700 |
commit | 260f5fbf3553a96fa49b029cc050220039c30e2a (patch) | |
tree | bd2cb6ee2909cb33f0b78969086ec3aaf83e548a /core/fpdfapi/fpdf_parser/include | |
parent | 70ba38a9a1af0240529a96904dfdb8868b868719 (diff) | |
download | pdfium-260f5fbf3553a96fa49b029cc050220039c30e2a.tar.xz |
Move parser pointer to CPDF_Document
The CPDF_IndirectObjectHolder has two subclasses, CPDF_Document and
CFDF_Document. The CPDF document requires the parser and the CFDF document
does not. This cl moves the parser pointer up to CPDF_Document.
Review-Url: https://codereview.chromium.org/2253723002
Diffstat (limited to 'core/fpdfapi/fpdf_parser/include')
4 files changed, 23 insertions, 12 deletions
diff --git a/core/fpdfapi/fpdf_parser/include/cfdf_document.h b/core/fpdfapi/fpdf_parser/include/cfdf_document.h index 18b9442fa9..834aecd1ba 100644 --- a/core/fpdfapi/fpdf_parser/include/cfdf_document.h +++ b/core/fpdfapi/fpdf_parser/include/cfdf_document.h @@ -19,7 +19,7 @@ class CFDF_Document : public CPDF_IndirectObjectHolder { static CFDF_Document* ParseFile(IFX_FileRead* pFile, FX_BOOL bOwnFile = FALSE); static CFDF_Document* ParseMemory(const uint8_t* pData, uint32_t size); - ~CFDF_Document(); + ~CFDF_Document() override; FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const; CPDF_Dictionary* GetRoot() const { return m_pRootDict; } diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h index 4a12ea97dc..adb8587f4f 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h @@ -40,7 +40,7 @@ class JBig2_DocumentContext; class CPDF_Document : public CPDF_IndirectObjectHolder { public: explicit CPDF_Document(CPDF_Parser* pParser); - ~CPDF_Document(); + ~CPDF_Document() override; CPDF_Parser* GetParser() const { return m_pParser; } CPDF_Dictionary* GetRoot() const { return m_pRootDict; } @@ -125,7 +125,9 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { int& index, int level = 0); FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting); + CPDF_Object* ParseIndirectObject(uint32_t objnum) override; + CPDF_Parser* m_pParser; CPDF_Dictionary* m_pRootDict; CPDF_Dictionary* m_pInfoDict; CFX_ByteString m_ID1; diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h b/core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h index c29746fdd7..63fadf19d6 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h @@ -19,24 +19,32 @@ class CPDF_IndirectObjectHolder { using iterator = std::map<uint32_t, CPDF_Object*>::iterator; using const_iterator = std::map<uint32_t, CPDF_Object*>::const_iterator; - explicit CPDF_IndirectObjectHolder(CPDF_Parser* pParser); - ~CPDF_IndirectObjectHolder(); + CPDF_IndirectObjectHolder(); + virtual ~CPDF_IndirectObjectHolder(); + + CPDF_Object* GetIndirectObject(uint32_t objnum) const; + CPDF_Object* GetOrParseIndirectObject(uint32_t objnum); - CPDF_Object* GetIndirectObject(uint32_t objnum); - uint32_t AddIndirectObject(CPDF_Object* pObj); void ReleaseIndirectObject(uint32_t objnum); - // Takes ownership of |pObj|. - bool InsertIndirectObject(uint32_t objnum, CPDF_Object* pObj); + // The following take ownership of |pObj|. + uint32_t AddIndirectObject(CPDF_Object* pObj); + void ReplaceIndirectObject(CPDF_Object* pObj); + bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, + CPDF_Object* pObj); uint32_t GetLastObjNum() const { return m_LastObjNum; } + void SetLastObjNum(uint32_t objnum) { m_LastObjNum = objnum; } + iterator begin() { return m_IndirectObjs.begin(); } const_iterator begin() const { return m_IndirectObjs.begin(); } iterator end() { return m_IndirectObjs.end(); } const_iterator end() const { return m_IndirectObjs.end(); } protected: - CPDF_Parser* m_pParser; + virtual CPDF_Object* ParseIndirectObject(uint32_t objnum); + + private: uint32_t m_LastObjNum; std::map<uint32_t, CPDF_Object*> m_IndirectObjs; }; diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_object.h b/core/fpdfapi/fpdf_parser/include/cpdf_object.h index f637e36667..86f3879ce1 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_object.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_object.h @@ -79,6 +79,10 @@ class CPDF_Object { virtual const CPDF_String* AsString() const; protected: + friend class CPDF_Document; + friend class CPDF_IndirectObjectHolder; + friend class CPDF_Parser; + CPDF_Object() : m_ObjNum(0), m_GenNum(0) {} virtual ~CPDF_Object(); void Destroy() { delete this; } @@ -86,9 +90,6 @@ class CPDF_Object { uint32_t m_ObjNum; uint32_t m_GenNum; - friend class CPDF_IndirectObjectHolder; - friend class CPDF_Parser; - private: CPDF_Object(const CPDF_Object& src) {} }; |