Merge to XFA: Fix ALL the include guards.
[pdfium.git] / core / include / fpdfapi / fpdf_pageobj.h
index 1e82680..1b53bdc 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#ifndef _FPDF_PAGEOBJ_H_\r
-#define _FPDF_PAGEOBJ_H_\r
-#ifndef _FPDF_RESOURCE_\r
-#include "fpdf_resource.h"\r
-#endif\r
-#ifndef _FX_GE_H_\r
-#include "../fxge/fx_ge.h"\r
-#endif\r
-class CPDF_Path;\r
-class CPDF_ClipPathData;\r
-class CPDF_ClipPath;\r
-class CPDF_ColorStateData;\r
-class CPDF_ColorState;\r
-class CPDF_GraphState;\r
-class CPDF_TextStateData;\r
-class CPDF_TextState;\r
-class CPDF_GeneralStateData;\r
-class CPDF_GeneralState;\r
-class CPDF_ContentMarkItem;\r
-class CPDF_ContentMark;\r
-class CPDF_GraphicStates;\r
-class CPDF_PageObject;\r
-class CPDF_TextObject;\r
-class CPDF_PathObject;\r
-class CPDF_ImageObject;\r
-class CPDF_ShadingObject;\r
-class CPDF_FormObject;\r
-class CPDF_InlineImages;\r
-typedef CFX_PathData CPDF_PathData;\r
-class CPDF_Path : public CFX_CountRef<CFX_PathData>\r
-{\r
-public:\r
-\r
-\r
-\r
-\r
-    int                                        GetPointCount()\r
-    {\r
-        return m_pObject->m_PointCount;\r
-    }\r
-\r
-    int                                        GetFlag(int index)\r
-    {\r
-        return m_pObject->m_pPoints[index].m_Flag;\r
-    }\r
-\r
-    FX_FLOAT                   GetPointX(int index)\r
-    {\r
-        return m_pObject->m_pPoints[index].m_PointX;\r
-    }\r
-\r
-    FX_FLOAT                   GetPointY(int index)\r
-    {\r
-        return m_pObject->m_pPoints[index].m_PointY;\r
-    }\r
-\r
-\r
-\r
-\r
-    FX_PATHPOINT*              GetPoints()\r
-    {\r
-        return m_pObject->m_pPoints;\r
-    }\r
-\r
-\r
-    CFX_FloatRect              GetBoundingBox() const\r
-    {\r
-        return m_pObject->GetBoundingBox();\r
-    }\r
-\r
-    CFX_FloatRect              GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const\r
-    {\r
-        return m_pObject->GetBoundingBox(line_width, miter_limit);\r
-    }\r
-\r
-    void                               Transform(const CFX_AffineMatrix* pMatrix)\r
-    {\r
-        GetModify()->Transform(pMatrix);\r
-    }\r
-\r
-    void                               Append(CPDF_Path src, const CFX_AffineMatrix* pMatrix)\r
-    {\r
-        m_pObject->Append(src.m_pObject, pMatrix);\r
-    }\r
-\r
-    void                               AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)\r
-    {\r
-        m_pObject->AppendRect(left, bottom, right, top);\r
-    }\r
-\r
-    FX_BOOL                            IsRect() const\r
-    {\r
-        return m_pObject->IsRect();\r
-    }\r
-};\r
-class CPDF_ClipPathData : public CFX_Object\r
-{\r
-public:\r
-\r
-    CPDF_ClipPathData();\r
-\r
-    CPDF_ClipPathData(const CPDF_ClipPathData&);\r
-\r
-    ~CPDF_ClipPathData();\r
-\r
-    void                               SetCount(int path_count, int text_count);\r
-public:\r
-\r
-    int                                        m_PathCount;\r
-\r
-    CPDF_Path*                 m_pPathList;\r
-\r
-    FX_BYTE*                   m_pTypeList;\r
-\r
-    int                                        m_TextCount;\r
-\r
-    CPDF_TextObject**  m_pTextList;\r
-};\r
-class CPDF_ClipPath : public CFX_CountRef<CPDF_ClipPathData>\r
-{\r
-public:\r
-\r
-    FX_DWORD                   GetPathCount() const\r
-    {\r
-        return m_pObject->m_PathCount;\r
-    }\r
-\r
-    CPDF_Path                  GetPath(int i) const\r
-    {\r
-        return m_pObject->m_pPathList[i];\r
-    }\r
-\r
-    int                                        GetClipType(int i) const\r
-    {\r
-        return m_pObject->m_pTypeList[i];\r
-    }\r
-\r
-    FX_DWORD                   GetTextCount() const\r
-    {\r
-        return m_pObject->m_TextCount;\r
-    }\r
-\r
-    CPDF_TextObject*   GetText(int i) const\r
-    {\r
-        return m_pObject->m_pTextList[i];\r
-    }\r
-\r
-    CFX_FloatRect              GetClipBox() const;\r
-\r
-    void                               AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);\r
-\r
-    void                               DeletePath(int layer_index);\r
-\r
-    void                               AppendTexts(CPDF_TextObject** pTexts, int count);\r
-\r
-    void                               Transform(const CFX_AffineMatrix& matrix);\r
-};\r
-class CPDF_ColorStateData : public CFX_Object\r
-{\r
-public:\r
-\r
-    CPDF_ColorStateData() {}\r
-\r
-    CPDF_ColorStateData(const CPDF_ColorStateData& src);\r
-\r
-    void                               Default();\r
-\r
-    CPDF_Color                 m_FillColor;\r
-\r
-    FX_DWORD                   m_FillRGB;\r
-\r
-    CPDF_Color                 m_StrokeColor;\r
-\r
-    FX_DWORD                   m_StrokeRGB;\r
-};\r
-class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData>\r
-{\r
-public:\r
-\r
-    CPDF_Color*                        GetFillColor() const\r
-    {\r
-        return m_pObject ? &m_pObject->m_FillColor : NULL;\r
-    }\r
-\r
-    CPDF_Color*                        GetStrokeColor() const\r
-    {\r
-        return m_pObject ? &m_pObject->m_StrokeColor : NULL;\r
-    }\r
-\r
-    void                               SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);\r
-\r
-    void                               SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);\r
-\r
-    void                               SetFillPattern(CPDF_Pattern* pattern, FX_FLOAT* pValue, int nValues);\r
-\r
-    void                               SetStrokePattern(CPDF_Pattern* pattern, FX_FLOAT* pValue, int nValues);\r
-private:\r
-    void                               SetColor(CPDF_Color& color, FX_DWORD& rgb, CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);\r
-};\r
-typedef CFX_GraphStateData CPDF_GraphStateData;\r
-class CPDF_GraphState : public CFX_CountRef<CFX_GraphStateData>\r
-{\r
-public:\r
-};\r
-class CPDF_TextStateData : public CFX_Object\r
-{\r
-public:\r
-\r
-    CPDF_TextStateData();\r
-\r
-    CPDF_TextStateData(const CPDF_TextStateData& src);\r
-\r
-    ~CPDF_TextStateData();\r
-\r
-    CPDF_Font*                 m_pFont;\r
-\r
-    FX_FLOAT                   m_FontSize;\r
-\r
-    FX_FLOAT                   m_CharSpace;\r
-\r
-    FX_FLOAT                   m_WordSpace;\r
-\r
-    FX_FLOAT           m_Matrix[4];\r
-\r
-    int                                        m_TextMode;\r
-\r
-    FX_FLOAT           m_CTM[4];\r
-};\r
-class CPDF_TextState : public CFX_CountRef<CPDF_TextStateData>\r
-{\r
-public:\r
-\r
-    CPDF_Font*                 GetFont() const\r
-    {\r
-        return m_pObject->m_pFont;\r
-    }\r
-\r
-    void                               SetFont(CPDF_Font* pFont);\r
-\r
-    FX_FLOAT                   GetFontSize() const\r
-    {\r
-        return m_pObject->m_FontSize;\r
-    }\r
-\r
-    FX_FLOAT*                  GetMatrix() const\r
-    {\r
-        return m_pObject->m_Matrix;\r
-    }\r
-\r
-\r
-\r
-    FX_FLOAT                   GetFontSizeV() const;\r
-\r
-    FX_FLOAT                   GetFontSizeH() const;\r
-\r
-    FX_FLOAT                   GetBaselineAngle() const;\r
-\r
-    FX_FLOAT                   GetShearAngle() const;\r
-\r
-};\r
-class CPDF_TransferFunc;\r
-class CPDF_GeneralStateData : public CFX_Object\r
-{\r
-public:\r
-\r
-    CPDF_GeneralStateData();\r
-\r
-    CPDF_GeneralStateData(const CPDF_GeneralStateData& src);\r
-    ~CPDF_GeneralStateData();\r
-\r
-    void                               SetBlendMode(FX_BSTR blend_mode);\r
-\r
-    char                               m_BlendMode[16];\r
-\r
-    int                                        m_BlendType;\r
-\r
-    CPDF_Object*               m_pSoftMask;\r
-\r
-    FX_FLOAT                   m_SMaskMatrix[6];\r
-\r
-    FX_FLOAT                   m_StrokeAlpha;\r
-\r
-    FX_FLOAT                   m_FillAlpha;\r
-\r
-    CPDF_Object*               m_pTR;\r
-\r
-    CPDF_TransferFunc* m_pTransferFunc;\r
-\r
-    CFX_Matrix                 m_Matrix;\r
-\r
-    int                                        m_RenderIntent;\r
-\r
-    FX_BOOL                            m_StrokeAdjust;\r
-\r
-    FX_BOOL                            m_AlphaSource;\r
-\r
-    FX_BOOL                            m_TextKnockout;\r
-\r
-    FX_BOOL                            m_StrokeOP;\r
-\r
-    FX_BOOL                            m_FillOP;\r
-\r
-    int                                        m_OPMode;\r
-\r
-    CPDF_Object*               m_pBG;\r
-\r
-    CPDF_Object*               m_pUCR;\r
-\r
-    CPDF_Object*               m_pHT;\r
-\r
-    FX_FLOAT                   m_Flatness;\r
-\r
-    FX_FLOAT                   m_Smoothness;\r
-};\r
-class CPDF_GeneralState : public CFX_CountRef<CPDF_GeneralStateData>\r
-{\r
-public:\r
-\r
-    void                               SetRenderIntent(const CFX_ByteString& ri);\r
-\r
-    int                                        GetBlendType() const\r
-    {\r
-        return m_pObject ? m_pObject->m_BlendType : FXDIB_BLEND_NORMAL;\r
-    }\r
-\r
-    int                                        GetAlpha(FX_BOOL bStroke) const\r
-    {\r
-        return m_pObject ? FXSYS_round((bStroke ? m_pObject->m_StrokeAlpha : m_pObject->m_FillAlpha) * 255) : 255;\r
-    }\r
-};\r
-class CPDF_ContentMarkItem : public CFX_Object\r
-{\r
-public:\r
-\r
-    typedef enum {\r
-        None,\r
-        PropertiesDict,\r
-        DirectDict,\r
-        MCID\r
-    } ParamType;\r
-\r
-    CPDF_ContentMarkItem();\r
-\r
-    CPDF_ContentMarkItem(const CPDF_ContentMarkItem& src);\r
-\r
-    ~CPDF_ContentMarkItem();\r
-\r
-    inline const CFX_ByteString&       GetName() const\r
-    {\r
-        return m_MarkName;\r
-    }\r
-\r
-    inline ParamType   GetParamType() const\r
-    {\r
-        return m_ParamType;\r
-    }\r
-\r
-    inline void*               GetParam() const\r
-    {\r
-        return m_pParam;\r
-    }\r
-\r
-    inline FX_BOOL             HasMCID() const;\r
-\r
-    inline void                        SetName(const CFX_ByteString& name)\r
-    {\r
-        m_MarkName = name;\r
-    }\r
-\r
-    inline void                        SetParam(ParamType type, void* param)\r
-    {\r
-        m_ParamType = type;\r
-        m_pParam = param;\r
-    }\r
-private:\r
-\r
-    CFX_ByteString             m_MarkName;\r
-\r
-    ParamType                  m_ParamType;\r
-\r
-    void*                              m_pParam;\r
-};\r
-class CPDF_ContentMarkData : public CFX_Object\r
-{\r
-public:\r
-\r
-    CPDF_ContentMarkData() { }\r
-\r
-    CPDF_ContentMarkData(const CPDF_ContentMarkData& src);\r
-\r
-    inline int                 CountItems() const\r
-    {\r
-        return m_Marks.GetSize();\r
-    }\r
-\r
-    inline CPDF_ContentMarkItem&       GetItem(int index) const\r
-    {\r
-        return m_Marks[index];\r
-    }\r
-\r
-    int                                        GetMCID() const;\r
-\r
-    void                               AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, FX_BOOL bDictNeedClone);\r
-\r
-    void                               DeleteLastMark();\r
-private:\r
-\r
-    CFX_ObjectArray<CPDF_ContentMarkItem>      m_Marks;\r
-};\r
-class CPDF_ContentMark : public CFX_CountRef<CPDF_ContentMarkData>\r
-{\r
-public:\r
-\r
-    int                                        GetMCID() const\r
-    {\r
-        return m_pObject ? m_pObject->GetMCID() : -1;\r
-    }\r
-\r
-    FX_BOOL                            HasMark(FX_BSTR mark) const;\r
-\r
-    FX_BOOL                            LookupMark(FX_BSTR mark, CPDF_Dictionary*& pDict) const;\r
-};\r
-#define PDFPAGE_TEXT           1\r
-#define PDFPAGE_PATH           2\r
-#define PDFPAGE_IMAGE          3\r
-#define PDFPAGE_SHADING                4\r
-#define PDFPAGE_FORM           5\r
-#define PDFPAGE_INLINES                6\r
-class CPDF_GraphicStates : public CFX_Object\r
-{\r
-public:\r
-\r
-    void                               CopyStates(const CPDF_GraphicStates& src);\r
-\r
-    void                               DefaultStates();\r
-\r
-    CPDF_ClipPath              m_ClipPath;\r
-\r
-    CPDF_GraphState            m_GraphState;\r
-\r
-    CPDF_ColorState            m_ColorState;\r
-\r
-    CPDF_TextState             m_TextState;\r
-\r
-    CPDF_GeneralState  m_GeneralState;\r
-};\r
-class CPDF_PageObject : public CPDF_GraphicStates\r
-{\r
-public:\r
-\r
-    static CPDF_PageObject* Create(int type);\r
-\r
-    void                               Release();\r
-\r
-    CPDF_PageObject*   Clone() const;\r
-\r
-    void                               Copy(const CPDF_PageObject* pSrcObject);\r
-\r
-    virtual void               Transform(const CFX_AffineMatrix& matrix) = 0;\r
-\r
-\r
-\r
-    void                               RemoveClipPath();\r
-\r
-    void                               AppendClipPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);\r
-\r
-    void                               CopyClipPath(CPDF_PageObject* pObj);\r
-\r
-    void                               TransformClipPath(CFX_AffineMatrix& matrix);\r
-\r
-    void                               TransformGeneralState(CFX_AffineMatrix& matrix);\r
-\r
-\r
-    void                               SetColorState(CPDF_ColorState state)\r
-    {\r
-        m_ColorState = state;\r
-    }\r
-\r
-    FX_RECT                            GetBBox(const CFX_AffineMatrix* pMatrix) const;\r
-\r
-    int                                        m_Type;\r
-\r
-    FX_FLOAT                   m_Left;\r
-\r
-    FX_FLOAT                   m_Right;\r
-\r
-    FX_FLOAT                   m_Top;\r
-\r
-    FX_FLOAT                   m_Bottom;\r
-\r
-    CPDF_ContentMark   m_ContentMark;\r
-protected:\r
-\r
-    virtual void               CopyData(const CPDF_PageObject* pSrcObject) {}\r
-\r
-    void                               RecalcBBox();\r
-\r
-    CPDF_PageObject() {}\r
-\r
-    virtual ~CPDF_PageObject() {}\r
-};\r
-struct CPDF_TextObjectItem : public CFX_Object {\r
-\r
-    FX_DWORD                   m_CharCode;\r
-\r
-    FX_FLOAT                   m_OriginX;\r
-\r
-    FX_FLOAT                   m_OriginY;\r
-};\r
-class CPDF_TextObject : public CPDF_PageObject\r
-{\r
-public:\r
-\r
-    CPDF_TextObject();\r
-\r
-    virtual ~CPDF_TextObject();\r
-\r
-    int                                        CountItems() const\r
-    {\r
-        return m_nChars;\r
-    }\r
-\r
-    void                               GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const;\r
-\r
-    int                                        CountChars() const;\r
-\r
-    void                               GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const;\r
-    void                               GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const;\r
-\r
-    void                               GetCharRect(int index, CFX_FloatRect& rect) const;\r
-\r
-\r
-    FX_FLOAT                   GetCharWidth(FX_DWORD charcode) const;\r
-    FX_FLOAT                   GetSpaceCharWidth() const;\r
-\r
-    FX_FLOAT                   GetPosX() const\r
-    {\r
-        return m_PosX;\r
-    }\r
-\r
-    FX_FLOAT                   GetPosY() const\r
-    {\r
-        return m_PosY;\r
-    }\r
-\r
-    void                               GetTextMatrix(CFX_AffineMatrix* pMatrix) const;\r
-\r
-    CPDF_Font*                 GetFont() const\r
-    {\r
-        return m_TextState.GetFont();\r
-    }\r
-\r
-    FX_FLOAT                   GetFontSize() const\r
-    {\r
-        return m_TextState.GetFontSize();\r
-    }\r
-\r
-    void                               SetEmpty();\r
-\r
-    void                               SetText(const CFX_ByteString& text);\r
-\r
-    void                               SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);\r
-\r
-    void                               SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings);\r
-\r
-    void                               SetPosition(FX_FLOAT x, FX_FLOAT y);\r
-\r
-    void                               SetTextState(CPDF_TextState TextState);\r
-    virtual void               Transform(const CFX_AffineMatrix& matrix);\r
-\r
-    void                               CalcCharPos(FX_FLOAT* pPosArray) const;\r
-\r
-\r
-\r
-    void                               SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos, FX_FLOAT x, FX_FLOAT y);\r
-\r
-    void                               GetData(int& nChars, FX_DWORD*& pCharCodes, FX_FLOAT*& pCharPos)\r
-    {\r
-        nChars = m_nChars;\r
-        pCharCodes = m_pCharCodes;\r
-        pCharPos = m_pCharPos;\r
-    }\r
-\r
-\r
-    void                               RecalcPositionData()\r
-    {\r
-        CalcPositionData(NULL, NULL, 1);\r
-    }\r
-protected:\r
-    virtual void               CopyData(const CPDF_PageObject* pSrcObject);\r
-\r
-    FX_FLOAT                   m_PosX;\r
-\r
-    FX_FLOAT                   m_PosY;\r
-\r
-    int                                        m_nChars;\r
-\r
-    FX_DWORD*                  m_pCharCodes;\r
-\r
-    FX_FLOAT*          m_pCharPos;\r
-\r
-    void                               SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);\r
-\r
-    void                               CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextAdvanceY, FX_FLOAT horz_scale, int level = 0);\r
-    friend class               CPDF_StreamContentParser;\r
-    friend class               CPDF_RenderStatus;\r
-    friend class               CPDF_QuickDrawer;\r
-    friend class               CPDF_TextRenderer;\r
-    friend class               CTextPage;\r
-    friend class               CPDF_ContentGenerator;\r
-};\r
-class CPDF_PathObject : public CPDF_PageObject\r
-{\r
-public:\r
-\r
-    CPDF_PathObject()\r
-    {\r
-        m_Type = PDFPAGE_PATH;\r
-    }\r
-\r
-    virtual ~CPDF_PathObject() {}\r
-    virtual void               Transform(const CFX_AffineMatrix& maxtrix);\r
-\r
-    void                               SetGraphState(CPDF_GraphState GraphState);\r
-\r
-    CPDF_Path                  m_Path;\r
-\r
-    int                                        m_FillType;\r
-\r
-    FX_BOOL                            m_bStroke;\r
-\r
-    CFX_AffineMatrix   m_Matrix;\r
-\r
-\r
-    void                               CalcBoundingBox();\r
-protected:\r
-    virtual void               CopyData(const CPDF_PageObject* pSrcObjet);\r
-};\r
-class CPDF_ImageObject : public CPDF_PageObject\r
-{\r
-public:\r
-\r
-    CPDF_ImageObject();\r
-\r
-    virtual ~CPDF_ImageObject();\r
-    virtual void               Transform(const CFX_AffineMatrix& matrix);\r
-\r
-    CPDF_Image*                        m_pImage;\r
-\r
-    CFX_AffineMatrix   m_Matrix;\r
-\r
-    void                               CalcBoundingBox();\r
-private:\r
-    virtual void               CopyData(const CPDF_PageObject* pSrcObjet);\r
-};\r
-class CPDF_ShadingObject : public CPDF_PageObject\r
-{\r
-public:\r
-\r
-    CPDF_ShadingObject();\r
-\r
-    virtual ~CPDF_ShadingObject();\r
-\r
-    CPDF_ShadingPattern*       m_pShading;\r
-\r
-    CFX_AffineMatrix   m_Matrix;\r
-\r
-    CPDF_Page*                 m_pPage;\r
-    virtual void               Transform(const CFX_AffineMatrix& matrix);\r
-\r
-    void                               CalcBoundingBox();\r
-protected:\r
-    virtual void               CopyData(const CPDF_PageObject* pSrcObjet);\r
-};\r
-class CPDF_FormObject : public CPDF_PageObject\r
-{\r
-public:\r
-\r
-    CPDF_FormObject()\r
-    {\r
-        m_Type = PDFPAGE_FORM;\r
-        m_pForm = NULL;\r
-    }\r
-\r
-    virtual ~CPDF_FormObject();\r
-    virtual void               Transform(const CFX_AffineMatrix& matrix);\r
-\r
-    CPDF_Form*                 m_pForm;\r
-\r
-    CFX_AffineMatrix   m_FormMatrix;\r
-\r
-    void                               CalcBoundingBox();\r
-protected:\r
-    virtual void               CopyData(const CPDF_PageObject* pSrcObjet);\r
-};\r
-class CPDF_InlineImages : public CPDF_PageObject\r
-{\r
-public:\r
-\r
-    CPDF_InlineImages();\r
-\r
-    virtual ~CPDF_InlineImages();\r
-\r
-    CPDF_Stream*               m_pStream;\r
-\r
-    CFX_DIBitmap*              m_pBitmap;\r
-\r
-    CFX_ArrayTemplate<CFX_AffineMatrix>        m_Matrices;\r
-\r
-    void                               AddMatrix(CFX_AffineMatrix& matrix);\r
-protected:\r
-    virtual void               Transform(const CFX_AffineMatrix& matrix) {}\r
-    virtual void               CopyData(const CPDF_PageObject* pSrcObjet) {}\r
-};\r
-#endif\r
+// 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_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_
+#define CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_
+
+#include "../fxge/fx_ge.h"
+#include "fpdf_resource.h"
+
+class CPDF_Path;
+class CPDF_ClipPathData;
+class CPDF_ClipPath;
+class CPDF_ColorStateData;
+class CPDF_ColorState;
+class CPDF_GraphState;
+class CPDF_TextStateData;
+class CPDF_TextState;
+class CPDF_GeneralStateData;
+class CPDF_GeneralState;
+class CPDF_ContentMarkItem;
+class CPDF_ContentMark;
+class CPDF_GraphicStates;
+class CPDF_PageObject;
+class CPDF_TextObject;
+class CPDF_PathObject;
+class CPDF_ImageObject;
+class CPDF_ShadingObject;
+class CPDF_FormObject;
+class CPDF_InlineImages;
+typedef CFX_PathData CPDF_PathData;
+class CPDF_Path : public CFX_CountRef<CFX_PathData>
+{
+public:
+
+
+
+
+    int                                        GetPointCount()
+    {
+        return m_pObject->m_PointCount;
+    }
+
+    int                                        GetFlag(int index)
+    {
+        return m_pObject->m_pPoints[index].m_Flag;
+    }
+
+    FX_FLOAT                   GetPointX(int index)
+    {
+        return m_pObject->m_pPoints[index].m_PointX;
+    }
+
+    FX_FLOAT                   GetPointY(int index)
+    {
+        return m_pObject->m_pPoints[index].m_PointY;
+    }
+
+
+
+
+    FX_PATHPOINT*              GetPoints()
+    {
+        return m_pObject->m_pPoints;
+    }
+
+
+    CFX_FloatRect              GetBoundingBox() const
+    {
+        return m_pObject->GetBoundingBox();
+    }
+
+    CFX_FloatRect              GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const
+    {
+        return m_pObject->GetBoundingBox(line_width, miter_limit);
+    }
+
+    void                               Transform(const CFX_AffineMatrix* pMatrix)
+    {
+        GetModify()->Transform(pMatrix);
+    }
+
+    void                               Append(CPDF_Path src, const CFX_AffineMatrix* pMatrix)
+    {
+        m_pObject->Append(src.m_pObject, pMatrix);
+    }
+
+    void                               AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
+    {
+        m_pObject->AppendRect(left, bottom, right, top);
+    }
+
+    FX_BOOL                            IsRect() const
+    {
+        return m_pObject->IsRect();
+    }
+};
+class CPDF_ClipPathData 
+{
+public:
+
+    CPDF_ClipPathData();
+
+    CPDF_ClipPathData(const CPDF_ClipPathData&);
+
+    ~CPDF_ClipPathData();
+
+    void                               SetCount(int path_count, int text_count);
+public:
+
+    int                                        m_PathCount;
+
+    CPDF_Path*                 m_pPathList;
+
+    FX_BYTE*                   m_pTypeList;
+
+    int                                        m_TextCount;
+
+    CPDF_TextObject**  m_pTextList;
+};
+class CPDF_ClipPath : public CFX_CountRef<CPDF_ClipPathData>
+{
+public:
+
+    FX_DWORD                   GetPathCount() const
+    {
+        return m_pObject->m_PathCount;
+    }
+
+    CPDF_Path                  GetPath(int i) const
+    {
+        return m_pObject->m_pPathList[i];
+    }
+
+    int                                        GetClipType(int i) const
+    {
+        return m_pObject->m_pTypeList[i];
+    }
+
+    FX_DWORD                   GetTextCount() const
+    {
+        return m_pObject->m_TextCount;
+    }
+
+    CPDF_TextObject*   GetText(int i) const
+    {
+        return m_pObject->m_pTextList[i];
+    }
+
+    CFX_FloatRect              GetClipBox() const;
+
+    void                               AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);
+
+    void                               DeletePath(int layer_index);
+
+    void                               AppendTexts(CPDF_TextObject** pTexts, int count);
+
+    void                               Transform(const CFX_AffineMatrix& matrix);
+};
+class CPDF_ColorStateData 
+{
+public:
+
+    CPDF_ColorStateData(): m_FillRGB(0), m_StrokeRGB(0) {}
+
+    CPDF_ColorStateData(const CPDF_ColorStateData& src);
+
+    void                               Default();
+
+    CPDF_Color                 m_FillColor;
+
+    FX_DWORD                   m_FillRGB;
+
+    CPDF_Color                 m_StrokeColor;
+
+    FX_DWORD                   m_StrokeRGB;
+};
+class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData>
+{
+public:
+
+    CPDF_Color*                        GetFillColor() const
+    {
+        return m_pObject ? &m_pObject->m_FillColor : NULL;
+    }
+
+    CPDF_Color*                        GetStrokeColor() const
+    {
+        return m_pObject ? &m_pObject->m_StrokeColor : NULL;
+    }
+
+    void                               SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
+
+    void                               SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
+
+    void                               SetFillPattern(CPDF_Pattern* pattern, FX_FLOAT* pValue, int nValues);
+
+    void                               SetStrokePattern(CPDF_Pattern* pattern, FX_FLOAT* pValue, int nValues);
+private:
+    void                               SetColor(CPDF_Color& color, FX_DWORD& rgb, CPDF_ColorSpace* pCS, FX_FLOAT* pValue, int nValues);
+};
+typedef CFX_GraphStateData CPDF_GraphStateData;
+class CPDF_GraphState : public CFX_CountRef<CFX_GraphStateData>
+{
+public:
+};
+class CPDF_TextStateData 
+{
+public:
+
+    CPDF_TextStateData();
+
+    CPDF_TextStateData(const CPDF_TextStateData& src);
+
+    ~CPDF_TextStateData();
+
+    CPDF_Font*                 m_pFont;
+
+    CPDF_Document*             m_pDocument;
+
+    FX_FLOAT                   m_FontSize;
+
+    FX_FLOAT                   m_CharSpace;
+
+    FX_FLOAT                   m_WordSpace;
+
+    FX_FLOAT           m_Matrix[4];
+
+    int                                        m_TextMode;
+
+    FX_FLOAT           m_CTM[4];
+};
+class CPDF_TextState : public CFX_CountRef<CPDF_TextStateData>
+{
+public:
+
+    CPDF_Font*                 GetFont() const
+    {
+        return m_pObject->m_pFont;
+    }
+
+    void                               SetFont(CPDF_Font* pFont);
+
+    FX_FLOAT                   GetFontSize() const
+    {
+        return m_pObject->m_FontSize;
+    }
+
+    FX_FLOAT*                  GetMatrix() const
+    {
+        return m_pObject->m_Matrix;
+    }
+
+
+
+    FX_FLOAT                   GetFontSizeV() const;
+
+    FX_FLOAT                   GetFontSizeH() const;
+
+    FX_FLOAT                   GetBaselineAngle() const;
+
+    FX_FLOAT                   GetShearAngle() const;
+
+};
+class CPDF_TransferFunc;
+class CPDF_GeneralStateData 
+{
+public:
+
+    CPDF_GeneralStateData();
+
+    CPDF_GeneralStateData(const CPDF_GeneralStateData& src);
+    ~CPDF_GeneralStateData();
+
+    void                               SetBlendMode(FX_BSTR blend_mode);
+
+    char                               m_BlendMode[16];
+
+    int                                        m_BlendType;
+
+    CPDF_Object*               m_pSoftMask;
+
+    FX_FLOAT                   m_SMaskMatrix[6];
+
+    FX_FLOAT                   m_StrokeAlpha;
+
+    FX_FLOAT                   m_FillAlpha;
+
+    CPDF_Object*               m_pTR;
+
+    CPDF_TransferFunc* m_pTransferFunc;
+
+    CFX_Matrix                 m_Matrix;
+
+    int                                        m_RenderIntent;
+
+    FX_BOOL                            m_StrokeAdjust;
+
+    FX_BOOL                            m_AlphaSource;
+
+    FX_BOOL                            m_TextKnockout;
+
+    FX_BOOL                            m_StrokeOP;
+
+    FX_BOOL                            m_FillOP;
+
+    int                                        m_OPMode;
+
+    CPDF_Object*               m_pBG;
+
+    CPDF_Object*               m_pUCR;
+
+    CPDF_Object*               m_pHT;
+
+    FX_FLOAT                   m_Flatness;
+
+    FX_FLOAT                   m_Smoothness;
+};
+class CPDF_GeneralState : public CFX_CountRef<CPDF_GeneralStateData>
+{
+public:
+
+    void                               SetRenderIntent(const CFX_ByteString& ri);
+
+    int                                        GetBlendType() const
+    {
+        return m_pObject ? m_pObject->m_BlendType : FXDIB_BLEND_NORMAL;
+    }
+
+    int                                        GetAlpha(FX_BOOL bStroke) const
+    {
+        return m_pObject ? FXSYS_round((bStroke ? m_pObject->m_StrokeAlpha : m_pObject->m_FillAlpha) * 255) : 255;
+    }
+};
+class CPDF_ContentMarkItem 
+{
+public:
+
+    typedef enum {
+        None,
+        PropertiesDict,
+        DirectDict,
+        MCID
+    } ParamType;
+
+    CPDF_ContentMarkItem();
+
+    CPDF_ContentMarkItem(const CPDF_ContentMarkItem& src);
+
+    ~CPDF_ContentMarkItem();
+
+    inline const CFX_ByteString&       GetName() const
+    {
+        return m_MarkName;
+    }
+
+    inline ParamType   GetParamType() const
+    {
+        return m_ParamType;
+    }
+
+    inline void*               GetParam() const
+    {
+        return m_pParam;
+    }
+
+    inline FX_BOOL             HasMCID() const;
+
+    inline void                        SetName(const CFX_ByteString& name)
+    {
+        m_MarkName = name;
+    }
+
+    inline void                        SetParam(ParamType type, void* param)
+    {
+        m_ParamType = type;
+        m_pParam = param;
+    }
+private:
+
+    CFX_ByteString             m_MarkName;
+
+    ParamType                  m_ParamType;
+
+    void*                              m_pParam;
+};
+class CPDF_ContentMarkData 
+{
+public:
+
+    CPDF_ContentMarkData() { }
+
+    CPDF_ContentMarkData(const CPDF_ContentMarkData& src);
+
+    inline int                 CountItems() const
+    {
+        return m_Marks.GetSize();
+    }
+
+    inline CPDF_ContentMarkItem&       GetItem(int index) const
+    {
+        return m_Marks[index];
+    }
+
+    int                                        GetMCID() const;
+
+    void                               AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, FX_BOOL bDictNeedClone);
+
+    void                               DeleteLastMark();
+private:
+
+    CFX_ObjectArray<CPDF_ContentMarkItem>      m_Marks;
+};
+class CPDF_ContentMark : public CFX_CountRef<CPDF_ContentMarkData>
+{
+public:
+
+    int                                        GetMCID() const
+    {
+        return m_pObject ? m_pObject->GetMCID() : -1;
+    }
+
+    FX_BOOL                            HasMark(FX_BSTR mark) const;
+
+    FX_BOOL                            LookupMark(FX_BSTR mark, CPDF_Dictionary*& pDict) const;
+};
+#define PDFPAGE_TEXT           1
+#define PDFPAGE_PATH           2
+#define PDFPAGE_IMAGE          3
+#define PDFPAGE_SHADING                4
+#define PDFPAGE_FORM           5
+#define PDFPAGE_INLINES                6
+class CPDF_GraphicStates 
+{
+public:
+
+    void                               CopyStates(const CPDF_GraphicStates& src);
+
+    void                               DefaultStates();
+
+    CPDF_ClipPath              m_ClipPath;
+
+    CPDF_GraphState            m_GraphState;
+
+    CPDF_ColorState            m_ColorState;
+
+    CPDF_TextState             m_TextState;
+
+    CPDF_GeneralState  m_GeneralState;
+};
+class CPDF_PageObject : public CPDF_GraphicStates
+{
+public:
+    static CPDF_PageObject* Create(int type);
+    virtual ~CPDF_PageObject();
+
+    CPDF_PageObject*   Clone() const;
+
+    void                               Copy(const CPDF_PageObject* pSrcObject);
+
+    virtual void               Transform(const CFX_AffineMatrix& matrix) = 0;
+
+
+
+    void                               RemoveClipPath();
+
+    void                               AppendClipPath(CPDF_Path path, int type, FX_BOOL bAutoMerge);
+
+    void                               CopyClipPath(CPDF_PageObject* pObj);
+
+    void                               TransformClipPath(CFX_AffineMatrix& matrix);
+
+    void                               TransformGeneralState(CFX_AffineMatrix& matrix);
+
+
+    void                               SetColorState(CPDF_ColorState state)
+    {
+        m_ColorState = state;
+    }
+
+    FX_RECT                            GetBBox(const CFX_AffineMatrix* pMatrix) const;
+
+    int                                        m_Type;
+
+    FX_FLOAT                   m_Left;
+
+    FX_FLOAT                   m_Right;
+
+    FX_FLOAT                   m_Top;
+
+    FX_FLOAT                   m_Bottom;
+
+    CPDF_ContentMark   m_ContentMark;
+protected:
+
+    virtual void               CopyData(const CPDF_PageObject* pSrcObject) {}
+
+    void                               RecalcBBox();
+
+    CPDF_PageObject() {}
+
+};
+struct CPDF_TextObjectItem  {
+
+    FX_DWORD                   m_CharCode;
+
+    FX_FLOAT                   m_OriginX;
+
+    FX_FLOAT                   m_OriginY;
+};
+class CPDF_TextObject : public CPDF_PageObject
+{
+public:
+
+    CPDF_TextObject();
+
+    virtual ~CPDF_TextObject();
+
+    int                                        CountItems() const
+    {
+        return m_nChars;
+    }
+
+    void                               GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const;
+
+    int                                        CountChars() const;
+
+    void                               GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const;
+    void                               GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const;
+
+    void                               GetCharRect(int index, CFX_FloatRect& rect) const;
+
+
+    FX_FLOAT                   GetCharWidth(FX_DWORD charcode) const;
+    FX_FLOAT                   GetSpaceCharWidth() const;
+
+    FX_FLOAT                   GetPosX() const
+    {
+        return m_PosX;
+    }
+
+    FX_FLOAT                   GetPosY() const
+    {
+        return m_PosY;
+    }
+
+    void                               GetTextMatrix(CFX_AffineMatrix* pMatrix) const;
+
+    CPDF_Font*                 GetFont() const
+    {
+        return m_TextState.GetFont();
+    }
+
+    FX_FLOAT                   GetFontSize() const
+    {
+        return m_TextState.GetFontSize();
+    }
+
+    void                               SetEmpty();
+
+    void                               SetText(const CFX_ByteString& text);
+
+    void                               SetText(CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
+
+    void                               SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings);
+
+    void                               SetPosition(FX_FLOAT x, FX_FLOAT y);
+
+    void                               SetTextState(CPDF_TextState TextState);
+    virtual void               Transform(const CFX_AffineMatrix& matrix);
+
+    void                               CalcCharPos(FX_FLOAT* pPosArray) const;
+
+
+
+    void                               SetData(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos, FX_FLOAT x, FX_FLOAT y);
+
+    void                               GetData(int& nChars, FX_DWORD*& pCharCodes, FX_FLOAT*& pCharPos)
+    {
+        nChars = m_nChars;
+        pCharCodes = m_pCharCodes;
+        pCharPos = m_pCharPos;
+    }
+
+
+    void                               RecalcPositionData()
+    {
+        CalcPositionData(NULL, NULL, 1);
+    }
+protected:
+    virtual void               CopyData(const CPDF_PageObject* pSrcObject);
+
+    FX_FLOAT                   m_PosX;
+
+    FX_FLOAT                   m_PosY;
+
+    int                                        m_nChars;
+
+    FX_DWORD*                  m_pCharCodes;
+
+    FX_FLOAT*          m_pCharPos;
+
+    void                               SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs);
+
+    void                               CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT* pTextAdvanceY, FX_FLOAT horz_scale, int level = 0);
+    friend class               CPDF_StreamContentParser;
+    friend class               CPDF_RenderStatus;
+    friend class               CPDF_QuickDrawer;
+    friend class               CPDF_TextRenderer;
+    friend class               CTextPage;
+    friend class               CPDF_ContentGenerator;
+};
+class CPDF_PathObject : public CPDF_PageObject
+{
+public:
+
+    CPDF_PathObject()
+    {
+        m_Type = PDFPAGE_PATH;
+    }
+
+    virtual ~CPDF_PathObject() {}
+    virtual void               Transform(const CFX_AffineMatrix& maxtrix);
+
+    void                               SetGraphState(CPDF_GraphState GraphState);
+
+    CPDF_Path                  m_Path;
+
+    int                                        m_FillType;
+
+    FX_BOOL                            m_bStroke;
+
+    CFX_AffineMatrix   m_Matrix;
+
+
+    void                               CalcBoundingBox();
+protected:
+    virtual void               CopyData(const CPDF_PageObject* pSrcObjet);
+};
+class CPDF_ImageObject : public CPDF_PageObject
+{
+public:
+
+    CPDF_ImageObject();
+
+    virtual ~CPDF_ImageObject();
+    virtual void               Transform(const CFX_AffineMatrix& matrix);
+
+    CPDF_Image*                        m_pImage;
+
+    CFX_AffineMatrix   m_Matrix;
+
+    void                               CalcBoundingBox();
+private:
+    virtual void               CopyData(const CPDF_PageObject* pSrcObjet);
+};
+class CPDF_ShadingObject : public CPDF_PageObject
+{
+public:
+
+    CPDF_ShadingObject();
+
+    virtual ~CPDF_ShadingObject();
+
+    CPDF_ShadingPattern*       m_pShading;
+
+    CFX_AffineMatrix   m_Matrix;
+
+    CPDF_Page*                 m_pPage;
+    virtual void               Transform(const CFX_AffineMatrix& matrix);
+
+    void                               CalcBoundingBox();
+protected:
+    virtual void               CopyData(const CPDF_PageObject* pSrcObjet);
+};
+class CPDF_FormObject : public CPDF_PageObject
+{
+public:
+
+    CPDF_FormObject()
+    {
+        m_Type = PDFPAGE_FORM;
+        m_pForm = NULL;
+    }
+
+    virtual ~CPDF_FormObject();
+    virtual void               Transform(const CFX_AffineMatrix& matrix);
+
+    CPDF_Form*                 m_pForm;
+
+    CFX_AffineMatrix   m_FormMatrix;
+
+    void                               CalcBoundingBox();
+protected:
+    virtual void               CopyData(const CPDF_PageObject* pSrcObjet);
+};
+class CPDF_InlineImages : public CPDF_PageObject
+{
+public:
+
+    CPDF_InlineImages();
+
+    virtual ~CPDF_InlineImages();
+
+    CPDF_Stream*               m_pStream;
+
+    CFX_DIBitmap*              m_pBitmap;
+
+    CFX_ArrayTemplate<CFX_AffineMatrix>        m_Matrices;
+
+    void                               AddMatrix(CFX_AffineMatrix& matrix);
+protected:
+    virtual void               Transform(const CFX_AffineMatrix& matrix) {}
+    virtual void               CopyData(const CPDF_PageObject* pSrcObjet) {}
+};
+
+#endif  // CORE_INCLUDE_FPDFAPI_FPDF_PAGEOBJ_H_