• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_PAGE_CPDF_PAGEOBJECT_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECT_H_
9 
10 #include "core/fpdfapi/page/cpdf_contentmark.h"
11 #include "core/fpdfapi/page/cpdf_graphicstates.h"
12 #include "core/fxcrt/fx_coordinates.h"
13 #include "core/fxcrt/fx_system.h"
14 
15 class CPDF_TextObject;
16 class CPDF_PathObject;
17 class CPDF_ImageObject;
18 class CPDF_ShadingObject;
19 class CPDF_FormObject;
20 
21 class CPDF_PageObject : public CPDF_GraphicStates {
22  public:
23   enum Type {
24     TEXT = 1,
25     PATH,
26     IMAGE,
27     SHADING,
28     FORM,
29   };
30 
31   CPDF_PageObject();
32   ~CPDF_PageObject() override;
33 
34   virtual Type GetType() const = 0;
35   virtual void Transform(const CFX_Matrix& matrix) = 0;
36   virtual bool IsText() const;
37   virtual bool IsPath() const;
38   virtual bool IsImage() const;
39   virtual bool IsShading() const;
40   virtual bool IsForm() const;
41   virtual CPDF_TextObject* AsText();
42   virtual const CPDF_TextObject* AsText() const;
43   virtual CPDF_PathObject* AsPath();
44   virtual const CPDF_PathObject* AsPath() const;
45   virtual CPDF_ImageObject* AsImage();
46   virtual const CPDF_ImageObject* AsImage() const;
47   virtual CPDF_ShadingObject* AsShading();
48   virtual const CPDF_ShadingObject* AsShading() const;
49   virtual CPDF_FormObject* AsForm();
50   virtual const CPDF_FormObject* AsForm() const;
51 
SetDirty(bool value)52   void SetDirty(bool value) { m_bDirty = value; }
IsDirty()53   bool IsDirty() const { return m_bDirty; }
54   void TransformClipPath(CFX_Matrix& matrix);
55   void TransformGeneralState(CFX_Matrix& matrix);
56 
GetRect()57   CFX_FloatRect GetRect() const {
58     return CFX_FloatRect(m_Left, m_Bottom, m_Right, m_Top);
59   }
60   FX_RECT GetBBox(const CFX_Matrix* pMatrix) const;
61 
62   float m_Left;
63   float m_Right;
64   float m_Top;
65   float m_Bottom;
66   CPDF_ContentMark m_ContentMark;
67 
68  protected:
69   void CopyData(const CPDF_PageObject* pSrcObject);
70 
71  private:
72   CPDF_PageObject(const CPDF_PageObject& src) = delete;
73   void operator=(const CPDF_PageObject& src) = delete;
74 
75   bool m_bDirty;
76 };
77 
78 #endif  // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECT_H_
79