Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ |
| 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "core/include/fpdfapi/fpdf_parser.h" | 12 #include "core/include/fpdfapi/fpdf_parser.h" |
| 13 #include "core/include/fpdfapi/fpdf_resource.h" | 13 #include "core/include/fpdfapi/fpdf_resource.h" |
| 14 #include "core/include/fxge/fx_dib.h" | 14 #include "core/include/fxge/fx_dib.h" |
| 15 | 15 |
| 16 class CPDF_Page; | 16 class CPDF_Page; |
| 17 class CPDF_Form; | 17 class CPDF_Form; |
| 18 class CPDF_ParseOptions; | 18 class CPDF_ParseOptions; |
| 19 class CPDF_PageObject; | 19 class CPDF_PageObject; |
| 20 class CPDF_PageRenderCache; | 20 class CPDF_PageRenderCache; |
| 21 class CPDF_StreamFilter; | 21 class CPDF_StreamFilter; |
| 22 class CPDF_AllStates; | 22 class CPDF_AllStates; |
| 23 class CPDF_ContentParser; | 23 class CPDF_ContentParser; |
| 24 class CPDF_StreamContentParser; | 24 class CPDF_StreamContentParser; |
| 25 | |
| 25 #define PDFTRANS_GROUP 0x0100 | 26 #define PDFTRANS_GROUP 0x0100 |
| 26 #define PDFTRANS_ISOLATED 0x0200 | 27 #define PDFTRANS_ISOLATED 0x0200 |
| 27 #define PDFTRANS_KNOCKOUT 0x0400 | 28 #define PDFTRANS_KNOCKOUT 0x0400 |
| 28 | 29 |
| 29 class CPDF_PageObjectList { | 30 class CPDF_PageObjectList : public CFX_PtrList { |
| 30 public: | 31 public: |
| 31 CPDF_PageObjectList(); | 32 CPDF_PageObjectList(int nBlockSize) : CFX_PtrList(nBlockSize) {} |
|
Lei Zhang
2016/02/17 00:28:59
explicit
Tom Sepez
2016/02/17 00:59:45
Done.
| |
| 32 ~CPDF_PageObjectList(); | |
| 33 | |
| 34 void ContinueParse(IFX_Pause* pPause); | |
| 35 | |
| 36 FX_BOOL IsParsed() const { return m_ParseState == CONTENT_PARSED; } | |
| 37 | |
| 38 FX_POSITION GetFirstObjectPosition() const { | |
| 39 return m_ObjectList.GetHeadPosition(); | |
| 40 } | |
| 41 | |
| 42 FX_POSITION GetLastObjectPosition() const { | |
| 43 return m_ObjectList.GetTailPosition(); | |
| 44 } | |
| 45 | 33 |
| 46 CPDF_PageObject* GetNextObject(FX_POSITION& pos) const { | 34 CPDF_PageObject* GetNextObject(FX_POSITION& pos) const { |
| 47 return (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 35 return static_cast<CPDF_PageObject*>(GetNext(pos)); |
| 48 } | 36 } |
| 49 | 37 |
| 50 CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const { | 38 CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const { |
| 51 return (CPDF_PageObject*)m_ObjectList.GetPrev(pos); | 39 return static_cast<CPDF_PageObject*>(GetPrev(pos)); |
| 52 } | 40 } |
| 53 | 41 |
| 54 CPDF_PageObject* GetObjectAt(FX_POSITION pos) const { | 42 CPDF_PageObject* GetObjectAt(FX_POSITION pos) const { |
| 55 return (CPDF_PageObject*)m_ObjectList.GetAt(pos); | 43 return static_cast<CPDF_PageObject*>(GetAt(pos)); |
| 56 } | 44 } |
| 57 | 45 |
| 58 void AddTail(CPDF_PageObject* obj) { m_ObjectList.AddTail(obj); } | 46 // Linear complexity, to be avoided except as needed by public APIs. |
| 59 FX_DWORD CountObjects() const { return m_ObjectList.GetCount(); } | |
| 60 | |
| 61 int GetObjectIndex(CPDF_PageObject* pObj) const; | |
| 62 | |
| 63 CPDF_PageObject* GetObjectByIndex(int index) const; | 47 CPDF_PageObject* GetObjectByIndex(int index) const; |
| 64 | 48 |
| 65 FX_POSITION InsertObject(FX_POSITION posInsertAfter, | 49 FX_POSITION InsertObject(FX_POSITION posInsertAfter, |
| 66 CPDF_PageObject* pNewObject); | 50 CPDF_PageObject* pNewObject); |
| 51 }; | |
| 67 | 52 |
| 68 void Transform(const CFX_Matrix& matrix); | 53 class CPDF_PageObjectHolder { |
| 54 public: | |
| 55 CPDF_PageObjectHolder(); | |
| 56 ~CPDF_PageObjectHolder(); | |
| 57 | |
| 58 void ContinueParse(IFX_Pause* pPause); | |
| 59 FX_BOOL IsParsed() const { return m_ParseState == CONTENT_PARSED; } | |
| 60 | |
| 61 CPDF_PageObjectList* GetPageObjectList() { return &m_PageObjectList; } | |
| 62 const CPDF_PageObjectList* GetPageObjectList() const { | |
| 63 return &m_PageObjectList; | |
| 64 } | |
| 69 | 65 |
| 70 FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } | 66 FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } |
| 71 void SetBackgroundAlphaNeeded(FX_BOOL needed) { | 67 void SetBackgroundAlphaNeeded(FX_BOOL needed) { |
| 72 m_bBackgroundAlphaNeeded = needed; | 68 m_bBackgroundAlphaNeeded = needed; |
| 73 } | 69 } |
| 74 | 70 |
| 75 FX_BOOL HasImageMask() const { return m_bHasImageMask; } | 71 FX_BOOL HasImageMask() const { return m_bHasImageMask; } |
| 76 void SetHasImageMask(FX_BOOL value) { m_bHasImageMask = value; } | 72 void SetHasImageMask(FX_BOOL value) { m_bHasImageMask = value; } |
| 73 | |
| 74 void Transform(const CFX_Matrix& matrix); | |
| 77 CFX_FloatRect CalcBoundingBox() const; | 75 CFX_FloatRect CalcBoundingBox() const; |
| 78 | 76 |
| 79 CPDF_Dictionary* m_pFormDict; | 77 CPDF_Dictionary* m_pFormDict; |
| 80 CPDF_Stream* m_pFormStream; | 78 CPDF_Stream* m_pFormStream; |
| 81 CPDF_Document* m_pDocument; | 79 CPDF_Document* m_pDocument; |
| 82 CPDF_Dictionary* m_pPageResources; | 80 CPDF_Dictionary* m_pPageResources; |
| 83 CPDF_Dictionary* m_pResources; | 81 CPDF_Dictionary* m_pResources; |
| 84 CFX_FloatRect m_BBox; | 82 CFX_FloatRect m_BBox; |
| 85 int m_Transparency; | 83 int m_Transparency; |
| 86 | 84 |
| 87 protected: | 85 protected: |
| 88 enum ParseState { CONTENT_NOT_PARSED, CONTENT_PARSING, CONTENT_PARSED }; | 86 enum ParseState { CONTENT_NOT_PARSED, CONTENT_PARSING, CONTENT_PARSED }; |
| 89 | 87 |
| 90 void LoadTransInfo(); | 88 void LoadTransInfo(); |
| 91 | 89 |
| 92 FX_BOOL m_bBackgroundAlphaNeeded; | 90 FX_BOOL m_bBackgroundAlphaNeeded; |
| 93 FX_BOOL m_bHasImageMask; | 91 FX_BOOL m_bHasImageMask; |
| 94 ParseState m_ParseState; | 92 ParseState m_ParseState; |
| 95 std::unique_ptr<CPDF_ContentParser> m_pParser; | 93 std::unique_ptr<CPDF_ContentParser> m_pParser; |
| 96 CFX_PtrList m_ObjectList; | 94 CPDF_PageObjectList m_PageObjectList; |
| 97 }; | 95 }; |
| 98 | 96 |
| 99 class CPDF_Page : public CPDF_PageObjectList, public CFX_PrivateData { | 97 class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData { |
| 100 public: | 98 public: |
| 101 CPDF_Page(); | 99 CPDF_Page(); |
| 102 ~CPDF_Page(); | 100 ~CPDF_Page(); |
| 103 | 101 |
| 104 void Load(CPDF_Document* pDocument, | 102 void Load(CPDF_Document* pDocument, |
| 105 CPDF_Dictionary* pPageDict, | 103 CPDF_Dictionary* pPageDict, |
| 106 FX_BOOL bPageCache = TRUE); | 104 FX_BOOL bPageCache = TRUE); |
| 107 | 105 |
| 108 void ParseContent(CPDF_ParseOptions* pOptions); | 106 void ParseContent(CPDF_ParseOptions* pOptions); |
| 109 | 107 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 135 CPDF_ParseOptions(); | 133 CPDF_ParseOptions(); |
| 136 | 134 |
| 137 FX_BOOL m_bTextOnly; | 135 FX_BOOL m_bTextOnly; |
| 138 | 136 |
| 139 FX_BOOL m_bMarkedContent; | 137 FX_BOOL m_bMarkedContent; |
| 140 | 138 |
| 141 FX_BOOL m_bSeparateForm; | 139 FX_BOOL m_bSeparateForm; |
| 142 | 140 |
| 143 FX_BOOL m_bDecodeInlineImage; | 141 FX_BOOL m_bDecodeInlineImage; |
| 144 }; | 142 }; |
| 145 class CPDF_Form : public CPDF_PageObjectList { | 143 class CPDF_Form : public CPDF_PageObjectHolder { |
| 146 public: | 144 public: |
| 147 CPDF_Form(CPDF_Document* pDocument, | 145 CPDF_Form(CPDF_Document* pDocument, |
| 148 CPDF_Dictionary* pPageResources, | 146 CPDF_Dictionary* pPageResources, |
| 149 CPDF_Stream* pFormStream, | 147 CPDF_Stream* pFormStream, |
| 150 CPDF_Dictionary* pParentResources = NULL); | 148 CPDF_Dictionary* pParentResources = NULL); |
| 151 | 149 |
| 152 ~CPDF_Form(); | 150 ~CPDF_Form(); |
| 153 | 151 |
| 154 void StartParse(CPDF_AllStates* pGraphicStates, | 152 void StartParse(CPDF_AllStates* pGraphicStates, |
| 155 CFX_Matrix* pParentMatrix, | 153 CFX_Matrix* pParentMatrix, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 181 CFX_Matrix& matrix); | 179 CFX_Matrix& matrix); |
| 182 CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, | 180 CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, |
| 183 const FX_CHAR* szType); | 181 const FX_CHAR* szType); |
| 184 | 182 |
| 185 CPDF_Page* m_pPage; | 183 CPDF_Page* m_pPage; |
| 186 CPDF_Document* m_pDocument; | 184 CPDF_Document* m_pDocument; |
| 187 CFX_ArrayTemplate<CPDF_PageObject*> m_pageObjects; | 185 CFX_ArrayTemplate<CPDF_PageObject*> m_pageObjects; |
| 188 }; | 186 }; |
| 189 | 187 |
| 190 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | 188 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ |
| OLD | NEW |